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