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