CMS 3D CMS Logo

EcalTPGAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Class: EcalTPGAnalyzer
4 //
5 //
6 // Original Author: Pascal Paganini
7 //
8 //
9 
10 // system include files
11 #include <memory>
12 #include <utility>
13 
14 // user include files
18 
22 
25 
31 
41 
42 #include "EcalTPGAnalyzer.h"
43 
44 #include <TMath.h>
45 #include <sstream>
46 
47 using namespace edm;
49 
51  tpCollection_ = iConfig.getParameter<edm::InputTag>("TPCollection");
52  tpEmulatorCollection_ = iConfig.getParameter<edm::InputTag>("TPEmulatorCollection");
53  digiCollectionEB_ = iConfig.getParameter<edm::InputTag>("DigiCollectionEB");
54  digiCollectionEE_ = iConfig.getParameter<edm::InputTag>("DigiCollectionEE");
55  gtRecordCollectionTag_ = iConfig.getParameter<std::string>("GTRecordCollection");
56 
57  allowTP_ = iConfig.getParameter<bool>("ReadTriggerPrimitives");
58  useEE_ = iConfig.getParameter<bool>("UseEndCap");
59  print_ = iConfig.getParameter<bool>("Print");
60 
61  // file
62  file_ = new TFile("ECALTPGtree.root", "RECREATE");
63  file_->cd();
64 
65  // tree
66  tree_ = new TTree("EcalTPGAnalysis", "EcalTPGAnalysis");
67 
68  tree_->Branch("runNb", &treeVariables_.runNb, "runNb/i"); //
69  tree_->Branch("evtNb", &treeVariables_.evtNb, "evtNb/i"); //
70  tree_->Branch("bxNb", &treeVariables_.bxNb, "bxNb/i"); //
71  tree_->Branch("orbitNb", &treeVariables_.orbitNb, "orbitNb/i"); //
72  tree_->Branch("nbOfActiveTriggers", &treeVariables_.nbOfActiveTriggers, "nbOfActiveTriggers/i"); //
73  tree_->Branch("activeTriggers", treeVariables_.activeTriggers, "activeTriggers[nbOfActiveTriggers]/I"); //
74 
75  tree_->Branch("nbOfTowers", &treeVariables_.nbOfTowers, "nbOfTowers/i"); //
76  tree_->Branch("ieta", treeVariables_.ieta, "ieta[nbOfTowers]/I"); //
77  tree_->Branch("iphi", treeVariables_.iphi, "iphi[nbOfTowers]/I"); //
78  tree_->Branch("nbOfXtals", treeVariables_.nbOfXtals, "nbOfXtals[nbOfTowers]/I"); //
79  tree_->Branch("rawTPData", treeVariables_.rawTPData, "rawTPData[nbOfTowers]/I"); //
80  tree_->Branch("rawTPEmul1", treeVariables_.rawTPEmul1, "rawTPEmul1[nbOfTowers]/I"); //
81  tree_->Branch("rawTPEmul2", treeVariables_.rawTPEmul2, "rawTPEmul2[nbOfTowers]/I"); //
82  tree_->Branch("rawTPEmul3", treeVariables_.rawTPEmul3, "rawTPEmul3[nbOfTowers]/I"); //
83  tree_->Branch("rawTPEmul4", treeVariables_.rawTPEmul4, "rawTPEmul4[nbOfTowers]/I"); //
84  tree_->Branch("rawTPEmul5", treeVariables_.rawTPEmul5, "rawTPEmul5[nbOfTowers]/I"); //
85  tree_->Branch("eRec", treeVariables_.eRec, "eRec[nbOfTowers]/F"); //
86 }
87 
89  file_->cd();
90  tree_->Write();
91  file_->Close();
92 }
93 
94 void EcalTPGAnalyzer::beginRun(edm::Run const&, edm::EventSetup const& evtSetup) {
95  // geometry
96  ESHandle<CaloGeometry> theGeometry;
97  ESHandle<CaloSubdetectorGeometry> theEndcapGeometry_handle, theBarrelGeometry_handle;
98 
99  evtSetup.get<CaloGeometryRecord>().get(theGeometry);
100  evtSetup.get<EcalEndcapGeometryRecord>().get("EcalEndcap", theEndcapGeometry_handle);
101  evtSetup.get<EcalBarrelGeometryRecord>().get("EcalBarrel", theBarrelGeometry_handle);
102 
103  evtSetup.get<IdealGeometryRecord>().get(eTTmap_);
104  theEndcapGeometry_ = &(*theEndcapGeometry_handle);
105  theBarrelGeometry_ = &(*theBarrelGeometry_handle);
106 }
107 
109  using namespace edm;
110  using namespace std;
111 
112  if (print_)
113  std::cout << "===========" << iEvent.id() << std::endl;
114 
115  map<EcalTrigTowerDetId, towerEner> mapTower;
116  map<EcalTrigTowerDetId, towerEner>::iterator itTT;
117 
119  // get Evts info
121 
122  treeVariables_.runNb = iEvent.id().run();
123  treeVariables_.evtNb = iEvent.id().event();
124  treeVariables_.bxNb = iEvent.bunchCrossing();
125  treeVariables_.orbitNb = iEvent.orbitNumber();
126 
128  // get L1 info
130 
132  iEvent.getByLabel(edm::InputTag(gtRecordCollectionTag_), gtRecord);
133  DecisionWord dWord = gtRecord->decisionWord(); // this will get the decision word *before* masking disabled bits
134 
136  iSetup.get<L1GtTriggerMaskAlgoTrigRcd>().get(l1GtTmAlgo);
137  std::vector<unsigned int> triggerMaskAlgoTrig = l1GtTmAlgo.product()->gtTriggerMask();
138 
139  // apply masks on algo
140  int iDaq = 0;
141  int iBit = -1;
142  treeVariables_.nbOfActiveTriggers = 0;
143  for (std::vector<bool>::iterator itBit = dWord.begin(); itBit != dWord.end(); ++itBit) {
144  iBit++;
145  int maskBit = triggerMaskAlgoTrig[iBit] & (1 << iDaq);
146  if (maskBit)
147  *itBit = false;
148  if (*itBit) {
149  treeVariables_.activeTriggers[treeVariables_.nbOfActiveTriggers] = iBit;
150  treeVariables_.nbOfActiveTriggers++;
151  }
152  }
153 
155  // Get TP data
157 
159  iEvent.getByLabel(tpCollection_, tp);
160  if (print_)
161  std::cout << "TP collection size=" << tp.product()->size() << std::endl;
162 
163  for (unsigned int i = 0; i < tp.product()->size(); i++) {
164  EcalTriggerPrimitiveDigi d = (*(tp.product()))[i];
165  const EcalTrigTowerDetId TPtowid = d.id();
166  towerEner tE;
167  tE.iphi_ = TPtowid.iphi();
168  tE.ieta_ = TPtowid.ieta();
169  tE.tpgADC_ = d[0].raw();
170  mapTower[TPtowid] = tE;
171  }
172 
174  // Get Emulators TP
176 
178  iEvent.getByLabel(tpEmulatorCollection_, tpEmul);
179  if (print_)
180  std::cout << "TPEmulator collection size=" << tpEmul.product()->size() << std::endl;
181 
182  for (unsigned int i = 0; i < tpEmul.product()->size(); i++) {
183  EcalTriggerPrimitiveDigi d = (*(tpEmul.product()))[i];
184  const EcalTrigTowerDetId TPtowid = d.id();
185  itTT = mapTower.find(TPtowid);
186  if (itTT != mapTower.end())
187  for (int j = 0; j < 5; j++)
188  (itTT->second).tpgEmul_[j] = d[j].raw();
189  }
190 
192  // Get nb of crystals read out
194 
195  // Get EB xtal digi inputs
197  iEvent.getByLabel(digiCollectionEB_, digiEB);
198 
199  for (unsigned int i = 0; i < digiEB.product()->size(); i++) {
200  const EBDataFrame& df = (*(digiEB.product()))[i];
201  const EBDetId& id = df.id();
202  const EcalTrigTowerDetId towid = id.tower();
203  itTT = mapTower.find(towid);
204  if (itTT != mapTower.end())
205  (itTT->second).nbXtal_++;
206  }
207 
208  if (useEE_) {
209  // Get EE xtal digi inputs
211  iEvent.getByLabel(digiCollectionEE_, digiEE);
212  for (unsigned int i = 0; i < digiEE.product()->size(); i++) {
213  const EEDataFrame& df = (*(digiEE.product()))[i];
214  const EEDetId& id = df.id();
215  const EcalTrigTowerDetId towid = (*eTTmap_).towerOf(id);
216  itTT = mapTower.find(towid);
217  if (itTT != mapTower.end())
218  (itTT->second).nbXtal_++;
219  }
220  }
221 
223  // Get rechits
225 
226  //... to be completed
227 
229  // fill tree
231 
232  treeVariables_.nbOfTowers = mapTower.size();
233  int towerNb = 0;
234  for (itTT = mapTower.begin(); itTT != mapTower.end(); ++itTT) {
235  treeVariables_.ieta[towerNb] = (itTT->second).ieta_;
236  treeVariables_.iphi[towerNb] = (itTT->second).iphi_;
237  treeVariables_.nbOfXtals[towerNb] = (itTT->second).nbXtal_;
238  treeVariables_.rawTPData[towerNb] = (itTT->second).tpgADC_;
239  treeVariables_.rawTPEmul1[towerNb] = (itTT->second).tpgEmul_[0];
240  treeVariables_.rawTPEmul2[towerNb] = (itTT->second).tpgEmul_[1];
241  treeVariables_.rawTPEmul3[towerNb] = (itTT->second).tpgEmul_[2];
242  treeVariables_.rawTPEmul4[towerNb] = (itTT->second).tpgEmul_[3];
243  treeVariables_.rawTPEmul5[towerNb] = (itTT->second).tpgEmul_[4];
244  treeVariables_.eRec[towerNb] = (itTT->second).eRec_;
245  towerNb++;
246  }
247 
248  tree_->Fill();
249 }
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
L1GtTriggerMenu.h
EcalTPGAnalyzer.h
mps_fire.i
i
Definition: mps_fire.py:428
EcalTrigTowerDetId::iphi
int iphi() const
get the tower iphi
Definition: EcalTrigTowerDetId.h:52
L1GtTriggerMaskAlgoTrigRcd.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
L1GtTriggerMask.h
towerEner::iphi_
int iphi_
Definition: EcalTPGAnalyzer.h:28
ESHandle.h
L1GlobalTriggerReadoutSetupFwd.h
edm::Run
Definition: Run.h:45
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
EBDetId
Definition: EBDetId.h:17
edm
HLT enums.
Definition: AlignableModifier.h:19
EBDataFrame
Definition: EBDataFrame.h:11
L1GtTriggerMenuRcd.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
EcalEndcapGeometryRecord
Definition: EcalEndcapGeometryRecord.h:23
L1GtTriggerMaskTechTrigRcd.h
edm::SortedCollection::size
size_type size() const
Definition: SortedCollection.h:215
EDAnalyzer.h
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
edm::Handle
Definition: AssociativeIterator.h:50
EcalBarrelGeometryRecord
Definition: EcalBarrelGeometryRecord.h:23
EcalTriggerPrimitiveDigi.h
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
towerEner::ieta_
int ieta_
Definition: EcalTPGAnalyzer.h:28
L1GlobalTriggerRecord.h
EcalTPGAnalyzer::~EcalTPGAnalyzer
~EcalTPGAnalyzer() override
Definition: EcalTPGAnalyzer.cc:88
EcalDigiCollections.h
L1GtTriggerMaskAlgoTrigRcd
Definition: L1GtTriggerMaskAlgoTrigRcd.h:39
edm::ESHandle< CaloGeometry >
EcalTPGAnalyzer::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: EcalTPGAnalyzer.cc:94
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
EEDetId
Definition: EEDetId.h:14
CaloGeometryRecord.h
CaloSubdetectorGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
L1GlobalTriggerReadoutSetup.h
L1GtTriggerMask::gtTriggerMask
const std::vector< unsigned int > & gtTriggerMask() const
get the trigger mask
Definition: L1GtTriggerMask.h:47
L1GlobalTriggerReadoutRecord::decisionWord
const DecisionWord & decisionWord(int bxInEventValue) const
Definition: L1GlobalTriggerReadoutRecord.cc:186
edm::get
T const & get(Event const &event, InputTag const &tag) noexcept(false)
Definition: Event.h:679
iEvent
int iEvent
Definition: GenABIO.cc:224
EcalTPGAnalyzer::EcalTPGAnalyzer
EcalTPGAnalyzer(const edm::ParameterSet &)
Definition: EcalTPGAnalyzer.cc:50
EcalTPGAnalyzer::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: EcalTPGAnalyzer.cc:108
edm::EventSetup
Definition: EventSetup.h:58
EcalTrigTowerDetId::ieta
int ieta() const
get the tower ieta
Definition: EcalTrigTowerDetId.h:44
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DecisionWord
std::vector< bool > DecisionWord
typedefs
Definition: L1GlobalTriggerReadoutSetupFwd.h:34
CaloCellGeometry.h
EcalTrigTowerConstituentsMap.h
std
Definition: JetResolutionObject.h:76
towerEner::tpgADC_
int tpgADC_
Definition: EcalTPGAnalyzer.h:27
hgcalPerformanceValidation.df
df
Definition: hgcalPerformanceValidation.py:733
EcalTriggerPrimitiveDigi
Definition: EcalTriggerPrimitiveDigi.h:16
CaloGeometry.h
EventSetup.h
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
ztail.d
d
Definition: ztail.py:151
ParameterSet.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
EEDataFrame
Definition: EEDataFrame.h:12
edm::Event
Definition: Event.h:73
towerEner
Definition: EcalTPGAnalyzer.h:23
edm::InputTag
Definition: InputTag.h:15
L1GlobalTriggerReadoutRecord.h
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
edm::hash_detail::print_
std::ostream & print_(std::ostream &os, value_type const &hash)
Definition: Hash.cc:92
edm::DataFrameContainer::size
size_type size() const
Definition: DataFrameContainer.h:162