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 28 of file DataROOTDumper2.cc.

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

32  edm::LogVerbatim("l1tOmtfEventPrint") << " omtfConfig->nTestRefHits() " << omtfConfig->nTestRefHits()
33  << " event.omtfGpResultsPdfSum.num_elements() " << endl;
35 
36  edm::LogVerbatim("l1tOmtfEventPrint") << " DataROOTDumper2 created" << std::endl;
37 }
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 39 of file DataROOTDumper2.cc.

References saveTTree().

39 { saveTTree(); }

Member Function Documentation

◆ endJob()

void DataROOTDumper2::endJob ( void  )
overridevirtual

Implements IOMTFEmulationObserver.

Definition at line 178 of file DataROOTDumper2.cc.

References evntCnt.

178 { 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 41 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().

41  {
42  rootFile = new TFile(rootFileName.c_str(), "RECREATE");
43  rootTree = new TTree("OMTFHitsTree", "");
44 
45  rootTree->Branch("muonPt", &omtfEvent.muonPt);
46  rootTree->Branch("muonEta", &omtfEvent.muonEta);
47  rootTree->Branch("muonPhi", &omtfEvent.muonPhi);
48  rootTree->Branch("muonCharge", &omtfEvent.muonCharge);
49 
50  rootTree->Branch("omtfPt", &omtfEvent.omtfPt);
51  rootTree->Branch("omtfEta", &omtfEvent.omtfEta);
52  rootTree->Branch("omtfPhi", &omtfEvent.omtfPhi);
53  rootTree->Branch("omtfCharge", &omtfEvent.omtfCharge);
54 
55  rootTree->Branch("omtfScore", &omtfEvent.omtfScore);
56  rootTree->Branch("omtfQuality", &omtfEvent.omtfQuality);
57  rootTree->Branch("omtfRefLayer", &omtfEvent.omtfRefLayer);
58  rootTree->Branch("omtfProcessor", &omtfEvent.omtfProcessor);
59 
60  rootTree->Branch("omtfFiredLayers", &omtfEvent.omtfFiredLayers); //<<<<<<<<<<<<<<<<<<<<<<!!!!TODOO
61 
62  ptGenPos = new TH1I("ptGenPos", "ptGenPos", 400, 0, 200);
63  ptGenNeg = new TH1I("ptGenNeg", "ptGenNeg", 400, 0, 200);
64 }
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 75 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, conifer::pow(), ptGenNeg, ptGenPos, EmulationObserverBase::regionalMuonCand, rootTree, EmulationObserverBase::simMuon, CoreSimTrack::type(), and hit::z.

76  {
77  int muonCharge = 0;
78  if (simMuon) {
79  if (abs(simMuon->momentum().eta()) < 0.8 || abs(simMuon->momentum().eta()) > 1.24)
80  return;
81 
82  muonCharge = (abs(simMuon->type()) == 13) ? simMuon->type() / -13 : 0;
83  if (muonCharge > 0)
84  ptGenPos->Fill(simMuon->momentum().pt());
85  else
86  ptGenNeg->Fill(simMuon->momentum().pt());
87  }
88 
89  if (simMuon == nullptr || !omtfCand->isValid()) //no sim muon or empty candidate
90  return;
91 
92  omtfEvent.muonPt = simMuon->momentum().pt();
93  omtfEvent.muonEta = simMuon->momentum().eta();
94 
95  //TODO add cut on ete if needed
96  /* if(abs(event.muonEta) < 0.8 || abs(event.muonEta) > 1.24)
97  return;*/
98 
99  omtfEvent.muonPhi = simMuon->momentum().phi();
100  omtfEvent.muonCharge = muonCharge; //TODO
101 
102  if (omtfCand->getPt() > 0) { //&& omtfCand->getFiredLayerCnt() > 3 TODO add to the if needed
105  omtfEvent.omtfPhi = omtfCand->getPhi();
107  omtfEvent.omtfScore = omtfCand->getPdfSum();
108  omtfEvent.omtfQuality = regionalMuonCand.hwQual(); //omtfCand->getQ();
109  omtfEvent.omtfFiredLayers = omtfCand->getFiredLayerBits();
110  omtfEvent.omtfRefLayer = omtfCand->getRefLayer();
112 
113  omtfEvent.hits.clear();
114 
115  auto& gpResult = omtfCand->getGpResult();
116 
117  /*
118  edm::LogVerbatim("l1tOmtfEventPrint")<<"DataROOTDumper2:;observeEventEnd muonPt "<<event.muonPt<<" muonCharge "<<event.muonCharge
119  <<" omtfPt "<<event.omtfPt<<" RefLayer "<<event.omtfRefLayer<<" omtfPtCont "<<event.omtfPtCont
120  <<std::endl;
121 */
122 
123  for (unsigned int iLogicLayer = 0; iLogicLayer < gpResult.getStubResults().size(); ++iLogicLayer) {
124  auto& stubResult = gpResult.getStubResults()[iLogicLayer];
125  if (stubResult.getMuonStub()) { //&& stubResult.getValid() //TODO!!!!!!!!!!!!!!!!1
127  hit.layer = iLogicLayer;
128  hit.quality = stubResult.getMuonStub()->qualityHw;
129  hit.eta = stubResult.getMuonStub()->etaHw; //in which scale?
130  hit.valid = stubResult.getValid();
131 
132  int hitPhi = stubResult.getMuonStub()->phiHw;
133  unsigned int refLayerLogicNum = omtfConfig->getRefToLogicNumber()[omtfCand->getRefLayer()];
134  int phiRefHit = gpResult.getStubResults()[refLayerLogicNum].getMuonStub()->phiHw;
135 
136  if (omtfConfig->isBendingLayer(iLogicLayer)) {
137  hitPhi = stubResult.getMuonStub()->phiBHw;
138  phiRefHit = 0; //phi ref hit for the bending layer set to 0, since it should not be included in the phiDist
139  }
140 
141  //phiDist = hitPhi - phiRefHit;
142  hit.phiDist = hitPhi - phiRefHit;
143 
144  /* LogTrace("l1tOmtfEventPrint")<<" muonPt "<<event.muonPt<<" omtfPt "<<event.omtfPt<<" RefLayer "<<event.omtfRefLayer
145  <<" layer "<<int(hit.layer)<<" PdfBin "<<stubResult.getPdfBin()<<" hit.phiDist "<<hit.phiDist<<" valid "<<stubResult.getValid()<<" " //<<" phiDist "<<phiDist
146  <<" getDistPhiBitShift "<<omtfCand->getGoldenPatern()->getDistPhiBitShift(iLogicLayer, omtfCand->getRefLayer())
147  <<" meanDistPhiValue "<<omtfCand->getGoldenPatern()->meanDistPhiValue(iLogicLayer, omtfCand->getRefLayer())//<<(phiDist != hit.phiDist? "!!!!!!!<<<<<" : "")
148  <<endl;*/
149 
150  if (hit.phiDist > 504 || hit.phiDist < -512) {
151  edm::LogVerbatim("l1tOmtfEventPrint")
152  << " muonPt " << omtfEvent.muonPt << " omtfPt " << omtfEvent.omtfPt << " RefLayer "
153  << omtfEvent.omtfRefLayer << " layer " << int(hit.layer) << " hit.phiDist " << hit.phiDist << " valid "
154  << stubResult.getValid() << " !!!!!!!!!!!!!!!!!!!!!!!!" << endl;
155  }
156 
157  DetId detId(stubResult.getMuonStub()->detId);
158  if (detId.subdetId() == MuonSubdetId::CSC) {
159  CSCDetId cscId(detId);
160  hit.z = cscId.chamber() % 2;
161  }
162 
163  omtfEvent.hits.push_back(hit.rawData);
164  }
165  }
166 
167  //debug
168  /*if( (int)event.hits.size() != omtfCand->getQ()) {
169  LogTrace("l1tOmtfEventPrint")<<" muonPt "<<event.muonPt<<" omtfPt "<<event.omtfPt<<" RefLayer "<<event.omtfRefLayer
170  <<" hits.size "<<event.hits.size()<<" omtfCand->getQ "<<omtfCand->getQ()<<" !!!!!!!!!!!!!!!!!!aaa!!!!!!"<<endl;
171  }*/
172 
173  rootTree->Fill();
174  evntCnt++;
175  }
176 }
Log< level::Info, true > LogVerbatim
AlgoMuons::value_type omtfCand
double omtfPt
constexpr int pow(int x)
Definition: conifer.h:24
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
bool isBendingLayer(unsigned int iLayer) const override

◆ saveTTree()

void DataROOTDumper2::saveTTree ( )
private

Definition at line 66 of file DataROOTDumper2.cc.

References ptGenNeg, ptGenPos, rootFile, and rootTree.

Referenced by ~DataROOTDumper2().

66  {
67  rootFile->Write();
68  ptGenPos->Write();
69  ptGenNeg->Write();
70 
71  delete rootFile;
72  delete rootTree;
73 }

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().