CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TCompare.cc
Go to the documentation of this file.
1 /*
2  * \file L1TCompare.cc
3  * \author P. Wittich
4  * \brief Compare different parts of the trigger chain (e.g., RCT-GCT )
5  *
6  *
7  * organized message logger
8  *
9  * Revision 1.12 2008/03/14 20:35:46 berryhil
10  *
11  *
12  * stripped out obsolete parameter settings
13  *
14  * rpc tpg restored with correct dn access and dbe handling
15  *
16  * Revision 1.11 2008/03/12 17:24:24 berryhil
17  *
18  *
19  * eliminated log files, truncated HCALTPGXana histo output
20  *
21  * Revision 1.10 2008/03/01 00:40:00 lat
22  * DQM core migration.
23  *
24  * Revision 1.9 2008/01/22 18:56:01 muzaffar
25  * include cleanup. Only for cc/cpp files
26  *
27  * Revision 1.8 2007/12/21 20:04:50 wsun
28  * Migrated L1EtMissParticle -> L1EtMissParticleCollection.
29  *
30  * Revision 1.7 2007/12/21 17:41:20 berryhil
31  *
32  *
33  * try/catch removal
34  *
35  * Revision 1.6 2007/11/19 15:08:22 lorenzo
36  * changed top folder name
37  *
38  * Revision 1.5 2007/09/27 22:58:15 ratnik
39  * QA campaign: fixes to compensate includes cleanup in DataFormats/L1Trigger
40  *
41  * Revision 1.4 2007/07/19 18:05:06 berryhil
42  *
43  *
44  * L1CaloRegionDetId dataformat migration for L1TCompare
45  *
46  * Revision 1.3 2007/06/13 11:33:39 wittich
47  * add axis titles
48  *
49  * Revision 1.2 2007/06/08 08:37:43 wittich
50  * Add ECAL TP - RCT comparisons. Lingering problems with
51  * mismatches right now - still needs work.
52  *
53  * Revision 1.1 2007/06/06 14:55:51 wittich
54  * compare within trigger subsystems
55  *
56  */
57 
59 
60 // stl
61 #include <algorithm>
62 
63 using namespace l1extra;
64 using namespace edm;
65 
66 const unsigned int PHIBINS = 18;
67 const float PHIMIN = -0.5;
68 const float PHIMAX = 17.5;
69 
70 // Ranks 6, 10 and 12 bits
71 const unsigned int R6BINS = 64;
72 const float R6MIN = -0.5;
73 const float R6MAX = 63.5;
74 
75 // For GCT this should be 15 bins, -14.5 to 14.5
76 //
77 const unsigned int ETABINS = 22;
78 const float ETAMIN = -0.5;
79 const float ETAMAX = 21.5;
80 
81 // TPG
82 const unsigned int TPPHIBINS = 72;
83 const float TPPHIMIN = 0.5;
84 const float TPPHIMAX = 72.5;
85 
86 const unsigned int TPETABINS = 65;
87 const float TPETAMIN = -32.5;
88 const float TPETAMAX = 32.5;
89 
90 
92  rctSourceEm_token_( consumes<L1CaloEmCollection>(ps.getParameter< InputTag >("rctSource") ))
93  ,rctSourceRctEmRgn_token_( consumes<L1CaloRegionCollection>(ps.getParameter< InputTag >("rctSource") ))
94  ,rctSource_( ps.getParameter< InputTag >("rctSource") )
95  ,gctSource_( ps.getParameter< InputTag >("gctSource") )
96  ,ecalTpgSource_(ps.getParameter<edm::InputTag>("ecalTpgSource"))
97  ,ecalTpgSource_token_(consumes<EcalTrigPrimDigiCollection>(ps.getParameter<edm::InputTag>("ecalTpgSource")))
98 
99 {
100 
101  // verbosity switch
102  verbose_ = ps.getUntrackedParameter < bool > ("verbose", false);
103 
104  if (verbose())
105  std::cout << "L1TCompare: constructor...." << std::endl;
106 
107 
108  dbe = NULL;
109  if (ps.getUntrackedParameter < bool > ("DQMStore", false)) {
111  dbe->setVerbose(0);
112  }
113 
114  outputFile_ =
115  ps.getUntrackedParameter < std::string > ("outputFile", "");
116  if (outputFile_.size() != 0) {
117  std::
118  cout << "L1T Monitoring histograms will be saved to " <<
119  outputFile_.c_str() << std::endl;
120  }
121 
122  bool disable =
123  ps.getUntrackedParameter < bool > ("disableROOToutput", false);
124  if (disable) {
125  outputFile_ = "";
126  }
127 
128 
129  if (dbe != NULL) {
130  dbe->setCurrentFolder("L1T/Compare");
131  }
132 
133  //set Token(-s)
134  edm::InputTag gctCenJetsTag_(gctSource_.label(),"cenJets");
135  edm::InputTag gctIsoEmCandsTag_(gctSource_.label(), "isoEm");
136  edm::InputTag gctNonIsoEmCandsTag_(gctSource_.label(), "nonIsoEm");
137 
138  gctCenJetsToken_ = consumes<L1GctJetCandCollection>(gctCenJetsTag_);
139  gctIsoEmCandsToken_ = consumes<L1GctEmCandCollection>(gctIsoEmCandsTag_);
140  gctNonIsoEmCandsToken_ = consumes<L1GctEmCandCollection>(gctNonIsoEmCandsTag_);
141 }
142 
144 {
145 }
146 
148 {
149  nev_ = 0;
150 }
151 
152 
153 void L1TCompare::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup)
154 {
155  if (dbe) {
156  dbe->setCurrentFolder("L1T/Compare");
157  dbe->rmdir("L1T/Compare");
158  }
159 
160 
161  if (dbe) {
162  dbe->setCurrentFolder("L1T/Compare");
163 
164  // -------------------------------------------
165  // RCT-GCT
166  // -------------------------------------------
167  // Isolated
168  rctGctLeadingIsoEmRank_ = dbe->book2D("rctGctLeadingIsoEmRank",
169  "RCT-GCT: rank", R6BINS, R6MIN, R6MAX,
170  R6BINS, R6MIN, R6MAX);
173  rctGctLeadingIsoEmEta_ = dbe->book2D("rctGctLeadingIsoEmEta",
174  "RCT-GCT: #eta", ETABINS, ETAMIN, ETAMAX,
175  ETABINS, ETAMIN, ETAMAX);
178 
179  rctGctLeadingIsoEmPhi_ = dbe->book2D("rctGctLeadingIsoEmPhi",
180  "RCT-GCT: #phi", PHIBINS, PHIMIN, PHIMAX,
181  PHIBINS, PHIMIN, PHIMAX);
184  // non-Isolated
185  rctGctLeadingNonIsoEmRank_ = dbe->book2D("rctGctLeadingNonIsoEmRank",
186  "RCT-GCT: rank", R6BINS, R6MIN, R6MAX,
187  R6BINS, R6MIN, R6MAX);
190 
191  rctGctLeadingNonIsoEmEta_ = dbe->book2D("rctGctLeadingNonIsoEmEta",
192  "RCT-GCT: #eta", ETABINS, ETAMIN, ETAMAX,
193  ETABINS, ETAMIN, ETAMAX);
196 
197  rctGctLeadingNonIsoEmPhi_ = dbe->book2D("rctGctLeadingNonIsoEmPhi",
198  "RCT-GCT: #phi", PHIBINS, PHIMIN, PHIMAX,
199  PHIBINS, PHIMIN, PHIMAX);
202  // -------------------------------------------
203  // ECAL TPG - RCT
204  // -------------------------------------------
205  ecalTpgRctLeadingEmRank_ = dbe->book2D("ecalTpgRctLeadingEmRank",
206  "ECAL TPG-RCT: rank",
207  R6BINS, R6MIN, R6MAX,
208  R6BINS, R6MIN, R6MAX);
211 
212  ecalTpgRctLeadingEmEta_ = dbe->book2D("ecalTpgRctLeadingEmEta",
213  "ECAL TPG-RCT: #eta",
214  15, -0.5, 14.5,
218  ecalTpgRctLeadingEmEta2_ = dbe->book2D("ecalTpgRctLeadingEmEta2",
219  "ECAL TPG-RCT: #eta (2)",
220  13, -6.5, 6.5,
224  ecalTpgRctLeadingEmPhi_ = dbe->book2D("ecalTpgRctLeadingEmPhi",
225  "ECAL TPG-RCT: #phi",
230  }
231 }
232 
233 
235 {
236  if (verbose())
237  std::cout << "L1TCompare: end job...." << std::endl;
238  LogInfo("EndJob") << "analyzed " << nev_ << " events";
239 
240  if (outputFile_.size() != 0 && dbe)
241  dbe->save(outputFile_);
242 
243  return;
244 }
245 
246 void L1TCompare::analyze(const Event & e, const EventSetup & c)
247 {
248  ++nev_;
249  if (verbose()) {
250  std::cout << "L1TCompare: analyze...." << std::endl;
251  }
252 
253  // L1E
259  // edm::Handle < L1EtMissParticle > l1eEtMiss;
261  // RCT
262  edm::Handle < L1CaloEmCollection > em; // collection of L1CaloEmCands
264 
265  // GCT
268  edm::Handle <L1GctEmCandCollection> gctNonIsoEmCands;
269 
270 
272 
273  if (!em.isValid()) {
274  edm::LogInfo("DataNotFound") << "can't find L1CaloEmCollection with label "
275  << rctSource_.label() ;
276  return;
277  }
278 
279 
281 
282  if (!rctEmRgn.isValid()) {
283  edm::LogInfo("DataNotFound") << "can't find "
284  << "L1CaloRegionCollection with label "
285  << rctSource_.label() ;
286  return;
287  }
288 
289  e.getByToken(gctCenJetsToken_, gctCenJets);
290  e.getByToken(gctIsoEmCandsToken_, gctIsoEmCands);
291  e.getByToken(gctNonIsoEmCandsToken_, gctNonIsoEmCands);
292 
293  if (!gctCenJets.isValid()) {
294  std::cerr << "L1TGCT: could not find one of the classes?" << std::endl;
295  return;
296  }
297  if (!gctIsoEmCands.isValid()) {
298  std::cerr << "L1TGCT: could not find one of the classes?" << std::endl;
299  return;
300  }
301  if (!gctNonIsoEmCands.isValid()) {
302  std::cerr << "L1TGCT: could not find one of the classes?" << std::endl;
303  return;
304  }
305 
306 
307  // GCT
308  if ( verbose() ) {
309  for ( L1GctEmCandCollection::const_iterator iem = gctIsoEmCands->begin();
310  iem != gctIsoEmCands->end(); ++iem) {
311  if ( !iem->empty() )
312  std::cout << "GCT EM: " << iem->rank()
313  << ", "
314  << iem->etaIndex() << "("
315  //<< int(iem->etaIndex()&0x3)*((iem->etaIndex()&0x4)?1:-1)
316  << "), "
317  << iem->phiIndex()
318  << std::endl;
319  }
320  }
321  // rct phi: 0-17
322  // rct eta: 0-21
323 
324 
325  // Fill the RCT histograms
326 
327  // Regions
328  RctObjectCollection rcj, rcj_iso, rcj_non_iso;
329  for (L1CaloEmCollection::const_iterator iem = em->begin();
330  iem != em->end(); ++iem) {
331  // L1CaloRegionDetId id(false, iem->rctCrate(), iem->rctCard(),
332  // iem->rctRegion());
333  L1CaloRegionDetId id(iem->rctCrate(), iem->rctCard(),
334  iem->rctRegion());
335 
336  // RctObject h(id.gctEta(), id.gctPhi(), iem->rank());
337  RctObject h(id.rctEta(), id.rctPhi(), iem->rank());
338  if ( !iem->isolated() )
339  rcj_non_iso.push_back(h);
340  else
341  rcj_iso.push_back(h);
342  rcj.push_back(h);
343  }
344  // not so smart but ...
345  std::sort(rcj.begin(), rcj.end(), RctObjectComp());
346  std::sort(rcj_non_iso.begin(), rcj_non_iso.end(), RctObjectComp());
347  std::sort(rcj_iso.begin(), rcj_iso.end(), RctObjectComp());
348  if ( verbose() ) {
349  for (RctObjectCollection::reverse_iterator ij = rcj_iso.rbegin();
350  ij != rcj_iso.rend() && ij != rcj_iso.rbegin()+8; ++ij) {
351  std::cout << "RCT cj: "
352  << ij->rank_ << ", " << ij->eta_ << ", " << ij->phi_
353  << std::endl;
354  }
355  }
356  L1GctEmCandCollection::const_iterator lead_em = gctIsoEmCands->begin();
357  if ( !lead_em->empty() ) { // equivalent to rank == 0
358  rctGctLeadingIsoEmEta_->Fill(lead_em->etaIndex(), rcj_iso.rbegin()->eta_);
359  rctGctLeadingIsoEmPhi_->Fill(lead_em->phiIndex(), rcj_iso.rbegin()->phi_);
360  rctGctLeadingIsoEmRank_->Fill(lead_em->rank(), rcj_iso.rbegin()->rank_);
361  }
362 
363  // non-isolated
364  if ( verbose() ) {
365  for ( L1GctEmCandCollection::const_iterator iem
366  = gctNonIsoEmCands->begin(); iem != gctNonIsoEmCands->end();
367  ++iem) {
368  if ( ! iem->empty() )
369  std::cout << "GCT EM non: " << iem->rank()
370  << ", "
371  << iem->etaIndex() //<< "("
372  //<< int(iem->etaIndex()&0x3)*((iem->etaIndex()&0x4)?1:-1)
373  //<< ")"
374  << ", "
375  << iem->phiIndex()
376  << std::endl;
377  }
378  }
379  if ( verbose() ) {
380  for (RctObjectCollection::reverse_iterator ij = rcj_non_iso.rbegin();
381  ij != rcj_non_iso.rend() && ij != rcj_non_iso.rbegin()+8; ++ij) {
382  std::cout << "RCT cj non: "
383  << ij->rank_ << ", " << ij->eta_ << ", " << ij->phi_
384  << std::endl;
385  }
386  }
387  lead_em = gctNonIsoEmCands->begin();
388  if ( !lead_em->empty() ) { // equivalent to rank != 0
389  rctGctLeadingNonIsoEmEta_->Fill(lead_em->etaIndex(),
390  rcj_non_iso.rbegin()->eta_);
391  rctGctLeadingNonIsoEmPhi_->Fill(lead_em->phiIndex(),
392  rcj_non_iso.rbegin()->phi_);
393  rctGctLeadingNonIsoEmRank_->Fill(lead_em->rank(),
394  rcj_non_iso.rbegin()->rank_);
395  }
396 
397  // ECAL TPG's to RCT EM
400 
401  if (!eTP.isValid()) {
402  edm::LogInfo("DataNotFound")
403  << "can't find EcalTrigPrimCollection with label "
404  << ecalTpgSource_.label() ;
405  return;
406  }
407  RctObjectCollection ecalobs;
408  for (EcalTrigPrimDigiCollection::const_iterator ieTP = eTP->begin();
409  ieTP != eTP->end(); ieTP++) {
410  ecalobs.push_back(RctObject(ieTP->id().ieta(),
411  ieTP->id().iphi(),
412  ieTP->compressedEt()));
413  }
414  std::sort(ecalobs.begin(), ecalobs.end(), RctObjectComp());
415  if ( verbose() ) {
416  for (RctObjectCollection::reverse_iterator ij = ecalobs.rbegin();
417  ij != ecalobs.rend() && ij != ecalobs.rbegin()+8; ++ij) {
418  std::cout << "ECAL cj : "
419  << ij->rank_ << ", " << ij->eta_ << ", " << ij->phi_
420  << std::endl;
421  }
422  }
423  // abritrary cut
424  if ( rcj.rbegin()->rank_ > 4 ) {
425  ecalTpgRctLeadingEmEta_->Fill(rcj.rbegin()->eta_,
426  ecalobs.rbegin()->eta_);
427  int e2 = (rcj.rbegin()->eta_&0x7UL)* ((rcj.rbegin()->eta_&0x8UL)?1:-1);
428  ecalTpgRctLeadingEmEta2_->Fill(e2, ecalobs.rbegin()->eta_);
429  ecalTpgRctLeadingEmPhi_->Fill(rcj.rbegin()->phi_, ecalobs.rbegin()->phi_);
430  ecalTpgRctLeadingEmRank_->Fill(rcj.rbegin()->rank_,
431  ecalobs.rbegin()->rank_);
432  }
433  if ( verbose() ) {
434  int seta = rcj.rbegin()->eta_;
435  seta = (seta&0x7UL)*(seta&0x8?-1:1);
436  std::cout << "ZZ: "
437  << rcj.rbegin()->eta_ << " "
438  << rcj.rbegin()->phi_ << " "
439  << rcj.rbegin()->rank_ << " "
440  << (++rcj.rbegin())->rank_<< " "
441  << ecalobs.rbegin()->eta_ << " "
442  << ecalobs.rbegin()->phi_ << " "
443  << ecalobs.rbegin()->rank_ << " "
444  << (++ecalobs.rbegin())->rank_<< " "
445  << seta << " "
446  << std::endl;
447  }
448 
449 
450 
451 }
DQMStore * dbe
Definition: L1TCompare.h:94
const unsigned int R6BINS
Definition: L1TCompare.cc:71
edm::EDGetTokenT< L1GctEmCandCollection > gctNonIsoEmCandsToken_
Definition: L1TCompare.h:131
T getUntrackedParameter(std::string const &, T const &) const
#define PHIMAX
edm::EDGetTokenT< L1CaloRegionCollection > rctSourceRctEmRgn_token_
Definition: L1TCompare.h:122
std::vector< L1CaloEmCand > L1CaloEmCollection
MonitorElement * rctGctLeadingIsoEmRank_
Definition: L1TCompare.h:100
bool verbose() const
Definition: L1TCompare.h:117
const float TPETAMIN
Definition: L1TCompare.cc:87
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:3101
L1TCompare(const edm::ParameterSet &ps)
Definition: L1TCompare.cc:91
MonitorElement * rctGctLeadingIsoEmEta_
Definition: L1TCompare.h:98
edm::InputTag rctSource_
Definition: L1TCompare.h:123
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
MonitorElement * ecalTpgRctLeadingEmEta2_
Definition: L1TCompare.h:108
std::vector< EcalTriggerPrimitiveDigi >::const_iterator const_iterator
const unsigned int TPPHIBINS
Definition: L1TCompare.cc:82
#define NULL
Definition: scimark2.h:8
void endJob(void)
Definition: L1TCompare.cc:234
edm::InputTag gctSource_
Definition: L1TCompare.h:124
void Fill(long long x)
MonitorElement * ecalTpgRctLeadingEmRank_
Definition: L1TCompare.h:110
#define ETAMAX
const float TPETAMAX
Definition: L1TCompare.cc:88
const unsigned int TPETABINS
Definition: L1TCompare.cc:86
bool verbose_
Definition: L1TCompare.h:116
MonitorElement * rctGctLeadingNonIsoEmEta_
Definition: L1TCompare.h:102
#define ETAMIN
const float R6MAX
Definition: L1TCompare.cc:73
virtual ~L1TCompare()
Definition: L1TCompare.cc:143
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void setVerbose(unsigned level)
Definition: DQMStore.cc:631
void analyze(const edm::Event &e, const edm::EventSetup &c)
Definition: L1TCompare.cc:246
bool isValid() const
Definition: HandleBase.h:76
#define PHIMIN
edm::EDGetTokenT< L1GctJetCandCollection > gctCenJetsToken_
Definition: L1TCompare.h:129
edm::EDGetTokenT< L1CaloEmCollection > rctSourceEm_token_
Definition: L1TCompare.h:121
const float TPPHIMIN
Definition: L1TCompare.cc:83
const float R6MIN
Definition: L1TCompare.cc:72
const float TPPHIMAX
Definition: L1TCompare.cc:84
MonitorElement * rctGctLeadingIsoEmPhi_
Definition: L1TCompare.h:99
#define ETABINS
std::vector< L1TCompare::RctObject > RctObjectCollection
Definition: L1TCompare.h:143
MonitorElement * ecalTpgRctLeadingEmEta_
Definition: L1TCompare.h:107
edm::InputTag ecalTpgSource_
Definition: L1TCompare.h:125
MonitorElement * rctGctLeadingNonIsoEmPhi_
Definition: L1TCompare.h:103
std::string const & label() const
Definition: InputTag.h:42
edm::EDGetTokenT< L1GctEmCandCollection > gctIsoEmCandsToken_
Definition: L1TCompare.h:130
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
Definition: DQMStore.cc:2540
void beginJob(void)
Definition: L1TCompare.cc:147
std::string outputFile_
Definition: L1TCompare.h:115
#define PHIBINS
edm::EDGetTokenT< EcalTrigPrimDigiCollection > ecalTpgSource_token_
Definition: L1TCompare.h:126
MonitorElement * rctGctLeadingNonIsoEmRank_
Definition: L1TCompare.h:104
tuple cout
Definition: gather_cfg.py:121
std::vector< L1CaloRegion > L1CaloRegionCollection
void beginRun(edm::Run const &iRun, edm::EventSetup const &iSetup)
Definition: L1TCompare.cc:153
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1082
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
Definition: Run.h:41
MonitorElement * ecalTpgRctLeadingEmPhi_
Definition: L1TCompare.h:109