CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DataROOTDumper2 Class Reference

#include <DataROOTDumper2.h>

Inheritance diagram for DataROOTDumper2:
EmulationObserverBase IOMTFEmulationObserver

Public Member Functions

 DataROOTDumper2 (const edm::ParameterSet &edmCfg, const OMTFConfiguration *omtfConfig, std::string rootFileName)
 
void endJob () override
 
void observeEventEnd (const edm::Event &iEvent, std::unique_ptr< l1t::RegionalMuonCandBxCollection > &finalCandidates) override
 
 ~DataROOTDumper2 () override
 
- Public Member Functions inherited from EmulationObserverBase
 EmulationObserverBase (const edm::ParameterSet &edmCfg, const OMTFConfiguration *omtfConfig)
 
const SimTrackfindSimMuon (const edm::Event &event, const SimTrack *previous=nullptr)
 
void observeEventBegin (const edm::Event &iEvent) override
 
void observeProcesorEmulation (unsigned int iProcessor, l1t::tftype mtfType, const std::shared_ptr< OMTFinput > &input, const AlgoMuons &algoCandidates, const AlgoMuons &gbCandidates, const std::vector< l1t::RegionalMuonCand > &candMuons) override
 
 ~EmulationObserverBase () override
 
- Public Member Functions inherited from IOMTFEmulationObserver
virtual void beginRun (edm::EventSetup const &eventSetup)
 
 IOMTFEmulationObserver ()
 
virtual ~IOMTFEmulationObserver ()
 

Private Member Functions

void initializeTTree (std::string rootFileName)
 
void saveTTree ()
 

Private Attributes

unsigned int evntCnt = 0
 
std::vector< TH2 * > hitVsPt
 
OmtfEvent omtfEvent
 
TH1I * ptGenNeg = nullptr
 
TH1I * ptGenPos = nullptr
 
TFile * rootFile = nullptr
 
TTree * rootTree = nullptr
 

Additional Inherited Members

- Protected Attributes inherited from EmulationObserverBase
unsigned int candProcIndx = 0
 
edm::ParameterSet edmCfg
 
AlgoMuons::value_type omtfCand
 
const OMTFConfigurationomtfConfig
 
l1t::RegionalMuonCand regionalMuonCand
 
const SimTracksimMuon = nullptr
 

Detailed Description

Definition at line 59 of file DataROOTDumper2.h.

Constructor & Destructor Documentation

◆ DataROOTDumper2()

DataROOTDumper2::DataROOTDumper2 ( const edm::ParameterSet edmCfg,
const OMTFConfiguration omtfConfig,
std::string  rootFileName 
)

Definition at line 19 of file DataROOTDumper2.cc.

References initializeTTree(), OMTFConfiguration::nTestRefHits(), EmulationObserverBase::omtfConfig, and CSCSkim_cfi::rootFileName.

23  edm::LogVerbatim("l1tOmtfEventPrint") << " omtfConfig->nTestRefHits() " << omtfConfig->nTestRefHits()
24  << " event.omtfGpResultsPdfSum.num_elements() " << endl;
26 
27  edm::LogVerbatim("l1tOmtfEventPrint") << " DataROOTDumper2 created" << std::endl;
28 }
Log< level::Info, true > LogVerbatim
EmulationObserverBase(const edm::ParameterSet &edmCfg, const OMTFConfiguration *omtfConfig)
void initializeTTree(std::string rootFileName)
unsigned int nTestRefHits() const
const OMTFConfiguration * omtfConfig

◆ ~DataROOTDumper2()

DataROOTDumper2::~DataROOTDumper2 ( )
override

Definition at line 30 of file DataROOTDumper2.cc.

References saveTTree().

30 { saveTTree(); }

Member Function Documentation

◆ endJob()

void DataROOTDumper2::endJob ( void  )
overridevirtual

Implements IOMTFEmulationObserver.

Definition at line 169 of file DataROOTDumper2.cc.

References evntCnt.

169 { edm::LogVerbatim("l1tOmtfEventPrint") << " evntCnt " << evntCnt << endl; }
Log< level::Info, true > LogVerbatim
unsigned int evntCnt

◆ initializeTTree()

void DataROOTDumper2::initializeTTree ( std::string  rootFileName)
private

Definition at line 32 of file DataROOTDumper2.cc.

References OmtfEvent::muonCharge, OmtfEvent::muonEta, OmtfEvent::muonPhi, OmtfEvent::muonPt, OmtfEvent::omtfCharge, OmtfEvent::omtfEta, omtfEvent, OmtfEvent::omtfFiredLayers, OmtfEvent::omtfPhi, OmtfEvent::omtfProcessor, OmtfEvent::omtfPt, OmtfEvent::omtfQuality, OmtfEvent::omtfRefLayer, OmtfEvent::omtfScore, ptGenNeg, ptGenPos, rootFile, CSCSkim_cfi::rootFileName, and rootTree.

Referenced by DataROOTDumper2().

32  {
33  rootFile = new TFile(rootFileName.c_str(), "RECREATE");
34  rootTree = new TTree("OMTFHitsTree", "");
35 
36  rootTree->Branch("muonPt", &omtfEvent.muonPt);
37  rootTree->Branch("muonEta", &omtfEvent.muonEta);
38  rootTree->Branch("muonPhi", &omtfEvent.muonPhi);
39  rootTree->Branch("muonCharge", &omtfEvent.muonCharge);
40 
41  rootTree->Branch("omtfPt", &omtfEvent.omtfPt);
42  rootTree->Branch("omtfEta", &omtfEvent.omtfEta);
43  rootTree->Branch("omtfPhi", &omtfEvent.omtfPhi);
44  rootTree->Branch("omtfCharge", &omtfEvent.omtfCharge);
45 
46  rootTree->Branch("omtfScore", &omtfEvent.omtfScore);
47  rootTree->Branch("omtfQuality", &omtfEvent.omtfQuality);
48  rootTree->Branch("omtfRefLayer", &omtfEvent.omtfRefLayer);
49  rootTree->Branch("omtfProcessor", &omtfEvent.omtfProcessor);
50 
51  rootTree->Branch("omtfFiredLayers", &omtfEvent.omtfFiredLayers); //<<<<<<<<<<<<<<<<<<<<<<!!!!TODOO
52 
53  ptGenPos = new TH1I("ptGenPos", "ptGenPos", 400, 0, 200);
54  ptGenNeg = new TH1I("ptGenNeg", "ptGenNeg", 400, 0, 200);
55 }
double omtfPt
unsigned int omtfFiredLayers
double muonPt
OmtfEvent omtfEvent
double muonPhi
double omtfPhi
double omtfEta
unsigned int omtfQuality
double muonEta
unsigned int omtfRefLayer

◆ observeEventEnd()

void DataROOTDumper2::observeEventEnd ( const edm::Event iEvent,
std::unique_ptr< l1t::RegionalMuonCandBxCollection > &  finalCandidates 
)
overridevirtual

Reimplemented from IOMTFEmulationObserver.

Definition at line 66 of file DataROOTDumper2.cc.

References funct::abs(), EmulationObserverBase::candProcIndx, CSCDetId::chamber(), MuonSubdetId::CSC, hcalRecHitTable_cff::detId, evntCnt, OMTFConfiguration::getRefToLogicNumber(), OmtfEvent::hits, OMTFConfiguration::hwEtaToEta(), OMTFConfiguration::hwPtToGev(), l1t::RegionalMuonCand::hwQual(), l1t::RegionalMuonCand::hwSign(), createfilelist::int, OMTFConfiguration::isBendingLayer(), CoreSimTrack::momentum(), OmtfEvent::muonCharge, OmtfEvent::muonEta, OmtfEvent::muonPhi, OmtfEvent::muonPt, EmulationObserverBase::omtfCand, OmtfEvent::omtfCharge, EmulationObserverBase::omtfConfig, OmtfEvent::omtfEta, omtfEvent, OmtfEvent::omtfFiredLayers, OmtfEvent::omtfPhi, OmtfEvent::omtfProcessor, OmtfEvent::omtfPt, OmtfEvent::omtfQuality, OmtfEvent::omtfRefLayer, OmtfEvent::omtfScore, funct::pow(), ptGenNeg, ptGenPos, EmulationObserverBase::regionalMuonCand, rootTree, EmulationObserverBase::simMuon, CoreSimTrack::type(), and hit::z.

67  {
68  int muonCharge = 0;
69  if (simMuon) {
70  if (abs(simMuon->momentum().eta()) < 0.8 || abs(simMuon->momentum().eta()) > 1.24)
71  return;
72 
73  muonCharge = (abs(simMuon->type()) == 13) ? simMuon->type() / -13 : 0;
74  if (muonCharge > 0)
75  ptGenPos->Fill(simMuon->momentum().pt());
76  else
77  ptGenNeg->Fill(simMuon->momentum().pt());
78  }
79 
80  if (simMuon == nullptr || !omtfCand->isValid()) //no sim muon or empty candidate
81  return;
82 
83  omtfEvent.muonPt = simMuon->momentum().pt();
84  omtfEvent.muonEta = simMuon->momentum().eta();
85 
86  //TODO add cut on ete if needed
87  /* if(abs(event.muonEta) < 0.8 || abs(event.muonEta) > 1.24)
88  return;*/
89 
90  omtfEvent.muonPhi = simMuon->momentum().phi();
91  omtfEvent.muonCharge = muonCharge; //TODO
92 
93  if (omtfCand->getPt() > 0) { //&& omtfCand->getFiredLayerCnt() > 3 TODO add to the if needed
96  omtfEvent.omtfPhi = omtfCand->getPhi();
98  omtfEvent.omtfScore = omtfCand->getPdfSum();
99  omtfEvent.omtfQuality = regionalMuonCand.hwQual(); //omtfCand->getQ();
100  omtfEvent.omtfFiredLayers = omtfCand->getFiredLayerBits();
101  omtfEvent.omtfRefLayer = omtfCand->getRefLayer();
103 
104  omtfEvent.hits.clear();
105 
106  auto& gpResult = omtfCand->getGpResult();
107 
108  /*
109  edm::LogVerbatim("l1tOmtfEventPrint")<<"DataROOTDumper2:;observeEventEnd muonPt "<<event.muonPt<<" muonCharge "<<event.muonCharge
110  <<" omtfPt "<<event.omtfPt<<" RefLayer "<<event.omtfRefLayer<<" omtfPtCont "<<event.omtfPtCont
111  <<std::endl;
112 */
113 
114  for (unsigned int iLogicLayer = 0; iLogicLayer < gpResult.getStubResults().size(); ++iLogicLayer) {
115  auto& stubResult = gpResult.getStubResults()[iLogicLayer];
116  if (stubResult.getMuonStub()) { //&& stubResult.getValid() //TODO!!!!!!!!!!!!!!!!1
118  hit.layer = iLogicLayer;
119  hit.quality = stubResult.getMuonStub()->qualityHw;
120  hit.eta = stubResult.getMuonStub()->etaHw; //in which scale?
121  hit.valid = stubResult.getValid();
122 
123  int hitPhi = stubResult.getMuonStub()->phiHw;
124  unsigned int refLayerLogicNum = omtfConfig->getRefToLogicNumber()[omtfCand->getRefLayer()];
125  int phiRefHit = gpResult.getStubResults()[refLayerLogicNum].getMuonStub()->phiHw;
126 
127  if (omtfConfig->isBendingLayer(iLogicLayer)) {
128  hitPhi = stubResult.getMuonStub()->phiBHw;
129  phiRefHit = 0; //phi ref hit for the bending layer set to 0, since it should not be included in the phiDist
130  }
131 
132  //phiDist = hitPhi - phiRefHit;
133  hit.phiDist = hitPhi - phiRefHit;
134 
135  /* LogTrace("l1tOmtfEventPrint")<<" muonPt "<<event.muonPt<<" omtfPt "<<event.omtfPt<<" RefLayer "<<event.omtfRefLayer
136  <<" layer "<<int(hit.layer)<<" PdfBin "<<stubResult.getPdfBin()<<" hit.phiDist "<<hit.phiDist<<" valid "<<stubResult.getValid()<<" " //<<" phiDist "<<phiDist
137  <<" getDistPhiBitShift "<<omtfCand->getGoldenPatern()->getDistPhiBitShift(iLogicLayer, omtfCand->getRefLayer())
138  <<" meanDistPhiValue "<<omtfCand->getGoldenPatern()->meanDistPhiValue(iLogicLayer, omtfCand->getRefLayer())//<<(phiDist != hit.phiDist? "!!!!!!!<<<<<" : "")
139  <<endl;*/
140 
141  if (hit.phiDist > 504 || hit.phiDist < -512) {
142  edm::LogVerbatim("l1tOmtfEventPrint")
143  << " muonPt " << omtfEvent.muonPt << " omtfPt " << omtfEvent.omtfPt << " RefLayer "
144  << omtfEvent.omtfRefLayer << " layer " << int(hit.layer) << " hit.phiDist " << hit.phiDist << " valid "
145  << stubResult.getValid() << " !!!!!!!!!!!!!!!!!!!!!!!!" << endl;
146  }
147 
148  DetId detId(stubResult.getMuonStub()->detId);
149  if (detId.subdetId() == MuonSubdetId::CSC) {
150  CSCDetId cscId(detId);
151  hit.z = cscId.chamber() % 2;
152  }
153 
154  omtfEvent.hits.push_back(hit.rawData);
155  }
156  }
157 
158  //debug
159  /*if( (int)event.hits.size() != omtfCand->getQ()) {
160  LogTrace("l1tOmtfEventPrint")<<" muonPt "<<event.muonPt<<" omtfPt "<<event.omtfPt<<" RefLayer "<<event.omtfRefLayer
161  <<" hits.size "<<event.hits.size()<<" omtfCand->getQ "<<omtfCand->getQ()<<" !!!!!!!!!!!!!!!!!!aaa!!!!!!"<<endl;
162  }*/
163 
164  rootTree->Fill();
165  evntCnt++;
166  }
167 }
Log< level::Info, true > LogVerbatim
AlgoMuons::value_type omtfCand
double omtfPt
virtual double hwEtaToEta(int hwEta) const
center of eta bin
unsigned int omtfFiredLayers
double muonPt
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:19
const int hwQual() const
Get quality code.
OmtfEvent omtfEvent
double muonPhi
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:22
double omtfPhi
unsigned int evntCnt
l1t::RegionalMuonCand regionalMuonCand
double omtfEta
unsigned int omtfQuality
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::vector< int > & getRefToLogicNumber() const
double hwPtToGev(int hwPt) const override
uGMT pt scale conversion
const int hwSign() const
Get charge sign bit (charge = (-1)^(sign))
Definition: DetId.h:17
std::vector< unsigned long > hits
double muonEta
static constexpr int CSC
Definition: MuonSubdetId.h:12
unsigned int omtfRefLayer
const OMTFConfiguration * omtfConfig
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
bool isBendingLayer(unsigned int iLayer) const override

◆ saveTTree()

void DataROOTDumper2::saveTTree ( )
private

Definition at line 57 of file DataROOTDumper2.cc.

References ptGenNeg, ptGenPos, rootFile, and rootTree.

Referenced by ~DataROOTDumper2().

57  {
58  rootFile->Write();
59  ptGenPos->Write();
60  ptGenNeg->Write();
61 
62  delete rootFile;
63  delete rootTree;
64 }

Member Data Documentation

◆ evntCnt

unsigned int DataROOTDumper2::evntCnt = 0
private

Definition at line 79 of file DataROOTDumper2.h.

Referenced by endJob(), and observeEventEnd().

◆ hitVsPt

std::vector<TH2*> DataROOTDumper2::hitVsPt
private

Definition at line 84 of file DataROOTDumper2.h.

◆ omtfEvent

OmtfEvent DataROOTDumper2::omtfEvent
private

Definition at line 77 of file DataROOTDumper2.h.

Referenced by initializeTTree(), and observeEventEnd().

◆ ptGenNeg

TH1I* DataROOTDumper2::ptGenNeg = nullptr
private

Definition at line 82 of file DataROOTDumper2.h.

Referenced by initializeTTree(), observeEventEnd(), and saveTTree().

◆ ptGenPos

TH1I* DataROOTDumper2::ptGenPos = nullptr
private

Definition at line 81 of file DataROOTDumper2.h.

Referenced by initializeTTree(), observeEventEnd(), and saveTTree().

◆ rootFile

TFile* DataROOTDumper2::rootFile = nullptr
private

Definition at line 74 of file DataROOTDumper2.h.

Referenced by initializeTTree(), and saveTTree().

◆ rootTree

TTree* DataROOTDumper2::rootTree = nullptr
private

Definition at line 75 of file DataROOTDumper2.h.

Referenced by initializeTTree(), observeEventEnd(), and saveTTree().