CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EBOccupancyTask.cc
Go to the documentation of this file.
1 /*
2  * \file EBOccupancyTask.cc
3  *
4  * $Date: 2012/04/27 13:46:02 $
5  * $Revision: 1.101 $
6  * \author G. Della Ricca
7  * \author G. Franzoni
8  *
9 */
10 
11 #include <iostream>
12 #include <fstream>
13 
17 
19 
21 
29 
32 
34 
36 
38 
39  init_ = false;
40 
42 
43  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
44 
45  subfolder_ = ps.getUntrackedParameter<std::string>("subfolder", "");
46 
47  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
48 
49  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
50 
51  EcalRawDataCollection_ = ps.getParameter<edm::InputTag>("EcalRawDataCollection");
52  EBDigiCollection_ = ps.getParameter<edm::InputTag>("EBDigiCollection");
53  EcalPnDiodeDigiCollection_ = ps.getParameter<edm::InputTag>("EcalPnDiodeDigiCollection");
54  EcalRecHitCollection_ = ps.getParameter<edm::InputTag>("EcalRecHitCollection");
55  EcalTrigPrimDigiCollection_ = ps.getParameter<edm::InputTag>("EcalTrigPrimDigiCollection");
56 
57  for (int i = 0; i < 36; i++) {
58  meOccupancy_[i] = 0;
59  meOccupancyMem_[i] = 0;
60  meEBRecHitEnergy_[i] = 0;
61  meSpectrum_[i] = 0;
62  }
63 
65 
69 
73 
77 
81 
85 
89 
90  recHitEnergyMin_ = 0.300; // GeV
91  trigPrimEtMin_ = 4.; // 4 ADCs == 1 GeV
92 
93 }
94 
96 
97 }
98 
100 
101  ievt_ = 0;
102 
103  if ( dqmStore_ ) {
104  dqmStore_->setCurrentFolder(prefixME_ + "/EBOccupancyTask");
105  if(subfolder_.size())
106  dqmStore_->setCurrentFolder(prefixME_ + "/EBOccupancyTask/" + subfolder_);
107  dqmStore_->rmdir(prefixME_ + "/EBOccupancyTask");
108  }
109 
110 }
111 
113 
114  Numbers::initGeometry(c, false);
115 
116  if ( ! mergeRuns_ ) this->reset();
117 
118 }
119 
121 
122 }
123 
125 
126  for (int i = 0; i < 36; i++) {
127  if ( meOccupancy_[i] ) meOccupancy_[i]->Reset();
128  if ( meOccupancyMem_[i] ) meOccupancyMem_[i]->Reset();
130  if ( meSpectrum_[i] ) meSpectrum_[i]->Reset();
131  }
132 
134 
138 
142 
146 
150 
154 
158 
159 }
160 
162 
163  init_ = true;
164 
165  std::string name;
166 
167  if ( dqmStore_ ) {
168  dqmStore_->setCurrentFolder(prefixME_ + "/EBOccupancyTask");
169  if(subfolder_.size())
170  dqmStore_->setCurrentFolder(prefixME_ + "/EBOccupancyTask/" + subfolder_);
171 
172  for (int i = 0; i < 36; i++) {
173  name = "EBOT digi occupancy " + Numbers::sEB(i+1);
174  meOccupancy_[i] = dqmStore_->book2D(name, name, 85, 0., 85., 20, 0., 20.);
175  meOccupancy_[i]->setAxisTitle("ieta", 1);
176  meOccupancy_[i]->setAxisTitle("iphi", 2);
177  dqmStore_->tag(meOccupancy_[i], i+1);
178 
179  name = "EBOT MEM digi occupancy " + Numbers::sEB(i+1);
180  meOccupancyMem_[i] = dqmStore_->book2D(name, name, 10, 0., 10., 5, 0., 5.);
181  meOccupancyMem_[i]->setAxisTitle("pseudo-strip", 1);
182  meOccupancyMem_[i]->setAxisTitle("channel", 2);
183  dqmStore_->tag(meOccupancyMem_[i], i+1);
184 
185  name = "EBOT rec hit energy " + Numbers::sEB(i+1);
186  meEBRecHitEnergy_[i] = dqmStore_->bookProfile2D(name, name, 85, 0., 85., 20, 0., 20., 100, 0., 100., "s");
187  meEBRecHitEnergy_[i]->setAxisTitle("ieta", 1);
188  meEBRecHitEnergy_[i]->setAxisTitle("iphi", 2);
189  meEBRecHitEnergy_[i]->setAxisTitle("energy (GeV)", 3);
190  dqmStore_->tag(meEBRecHitEnergy_[i], i+1);
191 
192  name = "EBOT energy spectrum " + Numbers::sEB(i+1);
193  meSpectrum_[i] = dqmStore_->book1D(name, name, 100, 0., 1.5);
194  meSpectrum_[i]->setAxisTitle("energy (GeV)", 1);
195  dqmStore_->tag(meSpectrum_[i], i+1);
196  }
197 
198  name = "EBOT rec hit spectrum";
199  meEBRecHitSpectrum_ = dqmStore_->book1D(name, name, 100, 0., 10.);
200  meEBRecHitSpectrum_->setAxisTitle("energy (GeV)", 1);
201 
202  name = "EBOT digi occupancy";
203  meEBDigiOccupancy_ = dqmStore_->book2D(name, name, 72, 0., 360., 34, -85., 85.);
204  meEBDigiOccupancy_->setAxisTitle("jphi", 1);
205  meEBDigiOccupancy_->setAxisTitle("jeta", 2);
206  name = "EBOT digi occupancy projection eta";
207  meEBDigiOccupancyProjEta_ = dqmStore_->book1DD(name, name, 34, -85., 85.);
209  meEBDigiOccupancyProjEta_->setAxisTitle("number of digis", 2);
210  name = "EBOT digi occupancy projection phi";
211  meEBDigiOccupancyProjPhi_ = dqmStore_->book1DD(name, name, 72, 0., 360.);
213  meEBDigiOccupancyProjPhi_->setAxisTitle("number of digis", 2);
214 
215  name = "EBOT rec hit occupancy";
216  meEBRecHitOccupancy_ = dqmStore_->book2D(name, name, 72, 0., 360., 34, -85., 85.);
219  name = "EBOT rec hit occupancy projection eta";
220  meEBRecHitOccupancyProjEta_ = dqmStore_->book1DD(name, name, 34, -85., 85.);
222  meEBRecHitOccupancyProjEta_->setAxisTitle("number of hits", 2);
223  name = "EBOT rec hit occupancy projection phi";
224  meEBRecHitOccupancyProjPhi_ = dqmStore_->book1DD(name, name, 72, 0., 360.);
226  meEBRecHitOccupancyProjPhi_->setAxisTitle("number of hits", 2);
227 
228  name = "EBOT rec hit thr occupancy";
229  meEBRecHitOccupancyThr_ = dqmStore_->book2D(name, name, 72, 0., 360., 34, -85., 85.);
232  name = "EBOT rec hit thr occupancy projection eta";
233  meEBRecHitOccupancyProjEtaThr_ = dqmStore_->book1DD(name, name, 34, -85., 85.);
235  meEBRecHitOccupancyProjEtaThr_->setAxisTitle("number of hits", 2);
236  name = "EBOT rec hit thr occupancy projection phi";
237  meEBRecHitOccupancyProjPhiThr_ = dqmStore_->book1DD(name, name, 72, 0., 360.);
239  meEBRecHitOccupancyProjPhiThr_->setAxisTitle("number of hits", 2);
240 
241  name = "EBOT TP digi occupancy";
242  meEBTrigPrimDigiOccupancy_ = dqmStore_->book2D(name, name, 72, 0., 72., 34, -17., 17.);
245  name = "EBOT TP digi occupancy projection eta";
246  meEBTrigPrimDigiOccupancyProjEta_ = dqmStore_->book1DD(name, name, 34, -17., 17.);
248  meEBTrigPrimDigiOccupancyProjEta_->setAxisTitle("number of TP digis", 2);
249  name = "EBOT TP digi occupancy projection phi";
250  meEBTrigPrimDigiOccupancyProjPhi_ = dqmStore_->book1DD(name, name, 72, 0., 72.);
252  meEBTrigPrimDigiOccupancyProjPhi_->setAxisTitle("number of TP digis", 2);
253 
254  name = "EBOT TP digi thr occupancy";
255  meEBTrigPrimDigiOccupancyThr_ = dqmStore_->book2D(name, name, 72, 0., 72., 34, -17., 17.);
258  name = "EBOT TP digi thr occupancy projection eta";
259  meEBTrigPrimDigiOccupancyProjEtaThr_ = dqmStore_->book1DD(name, name, 34, -17., 17.);
261  meEBTrigPrimDigiOccupancyProjEtaThr_->setAxisTitle("number of TP digis", 2);
262  name = "EBOT TP digi thr occupancy projection phi";
263  meEBTrigPrimDigiOccupancyProjPhiThr_ = dqmStore_->book1DD(name, name, 72, 0., 72.);
265  meEBTrigPrimDigiOccupancyProjPhiThr_->setAxisTitle("number of TP digis", 2);
266 
267  name = "EBOT test pulse digi occupancy";
268  meEBTestPulseDigiOccupancy_ = dqmStore_->book2D(name, name, 72, 0., 360., 34, -85., 85.);
271 
272  name = "EBOT laser digi occupancy";
273  meEBLaserDigiOccupancy_ = dqmStore_->book2D(name, name, 72, 0., 360., 34, -85., 85.);
276 
277  name = "EBOT pedestal digi occupancy";
278  meEBPedestalDigiOccupancy_ = dqmStore_->book2D(name, name, 72, 0., 360., 34, -85., 85.);
281 
282  }
283 
284 }
285 
287 
288  if ( ! init_ ) return;
289 
290  if ( dqmStore_ ) {
291  dqmStore_->setCurrentFolder(prefixME_ + "/EBOccupancyTask");
292  if(subfolder_.size())
293  dqmStore_->setCurrentFolder(prefixME_ + "/EBOccupancyTask/" + subfolder_);
294 
295  for (int i = 0; i < 36; i++) {
297  meOccupancy_[i] = 0;
299  meOccupancyMem_[i] = 0;
301  meEBRecHitEnergy_[i] = 0;
303  meSpectrum_[i] = 0;
304  }
305 
308 
310  meEBDigiOccupancy_ = 0;
315 
322 
329 
336 
343 
346 
349 
352 
353  }
354 
355  init_ = false;
356 
357 }
358 
360 
361  edm::LogInfo("EBOccupancyTask") << "analyzed " << ievt_ << " events";
362 
363  if ( enableCleanup_ ) this->cleanup();
364 
365 }
366 
368 
369  if ( ! init_ ) this->setup();
370 
371  ievt_++;
372 
373  int runType[36] = { notdata };
374 
376 
377  if ( e.getByLabel(EcalRawDataCollection_, dcchs) ) {
378 
379  for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
380 
381  if ( Numbers::subDet( *dcchItr ) != EcalBarrel ) continue;
382 
383  int ism = Numbers::iSM( *dcchItr, EcalBarrel );
384 
385  int runtype = dcchItr->getRunType();
386 
387  if ( runtype == EcalDCCHeaderBlock::COSMIC ||
388  runtype == EcalDCCHeaderBlock::MTCC ||
392  runtype == EcalDCCHeaderBlock::PHYSICS_LOCAL ) runType[ism-1] = physics;
393  if ( runtype == EcalDCCHeaderBlock::TESTPULSE_MGPA ||
394  runtype == EcalDCCHeaderBlock::TESTPULSE_GAP ) runType[ism-1] = testpulse;
395  if ( runtype == EcalDCCHeaderBlock::LASER_STD ||
396  runtype == EcalDCCHeaderBlock::LASER_GAP ) runType[ism-1] = laser;
397  if ( runtype == EcalDCCHeaderBlock::PEDESTAL_STD ||
398  runtype == EcalDCCHeaderBlock::PEDESTAL_GAP ) runType[ism-1] = pedestal;
399 
400  }
401 
402  } else {
403  edm::LogWarning("EBOccupancyTask") << EcalRawDataCollection_ << " not available";
404  }
405 
407 
408  if ( e.getByLabel(EBDigiCollection_, digis) ) {
409 
410  int nebd = digis->size();
411  LogDebug("EBOccupancyTask") << "event " << ievt_ << " digi collection size " << nebd;
412 
413  for ( EBDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr ) {
414 
415  EBDetId id = digiItr->id();
416 
417  int ic = id.ic();
418  int ie = (ic-1)/20 + 1;
419  int ip = (ic-1)%20 + 1;
420 
421  int ism = Numbers::iSM( id );
422 
423  float xie = ie - 0.5;
424  float xip = ip - 0.5;
425 
426  if ( xie <= 0. || xie >= 85. || xip <= 0. || xip >= 20. ) {
427  edm::LogWarning("EBOccupancyTask") << " det id = " << id;
428  edm::LogWarning("EBOccupancyTask") << " sm, ieta, iphi " << ism << " " << ie << " " << ip;
429  edm::LogWarning("EBOccupancyTask") << " xie, xip " << xie << " " << xip;
430  }
431 
432  if ( meOccupancy_[ism-1] ) meOccupancy_[ism-1]->Fill(xie, xip);
433 
434  int ebeta = id.ieta();
435  int ebphi = id.iphi();
436 
437  float xebeta = ebeta - 0.5*id.zside();
438  float xebphi = ebphi - 0.5;
439 
440  if ( runType[ism-1] == physics || runType[ism-1] == notdata ) {
441 
442  if ( meEBDigiOccupancy_ ) meEBDigiOccupancy_->Fill( xebphi, xebeta );
445 
446  }
447 
448  if ( runType[ism-1] == testpulse ) {
449 
451 
452  }
453 
454  if ( runType[ism-1] == laser ) {
455 
456  if ( meEBLaserDigiOccupancy_ ) meEBLaserDigiOccupancy_->Fill( xebphi, xebeta );
457 
458  }
459 
460  if ( runType[ism-1] == pedestal ) {
461 
463 
464  }
465 
466  }
467 
468  } else {
469 
470  edm::LogWarning("EBOccupancyTask") << EBDigiCollection_ << " not available";
471 
472  }
473 
475 
476  if ( e.getByLabel(EcalPnDiodeDigiCollection_, PNs) ) {
477 
478  // filling mem occupancy only for the 5 channels belonging
479  // to a fully reconstructed PN's
480 
481  for ( EcalPnDiodeDigiCollection::const_iterator pnItr = PNs->begin(); pnItr != PNs->end(); ++pnItr ) {
482 
483  if ( Numbers::subDet( pnItr->id() ) != EcalBarrel ) continue;
484 
485  int ism = Numbers::iSM( pnItr->id() );
486 
487  float PnId = pnItr->id().iPnId();
488 
489  PnId = PnId - 0.5;
490  float st = 0.0;
491 
492  for (int chInStrip = 1; chInStrip <= 5; chInStrip++){
493  if ( meOccupancyMem_[ism-1] ) {
494  st = chInStrip - 0.5;
495  meOccupancyMem_[ism-1]->Fill(PnId, st);
496  }
497  }
498 
499  }
500 
501  } else {
502 
503  edm::LogWarning("EBOccupancyTask") << EcalPnDiodeDigiCollection_ << " not available";
504 
505  }
506 
508  c.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
509 
511 
512  if ( e.getByLabel(EcalRecHitCollection_, rechits) ) {
513 
514  int nebrh = rechits->size();
515  LogDebug("EBOccupancyTask") << "event " << ievt_ << " rec hits collection size " << nebrh;
516 
517  for ( EcalRecHitCollection::const_iterator rechitItr = rechits->begin(); rechitItr != rechits->end(); ++rechitItr ) {
518 
519  EBDetId id = rechitItr->id();
520 
521  // global coordinates
522  int ebeta = id.ieta();
523  int ebphi = id.iphi();
524 
525  float xebeta = ebeta - 0.5*id.zside();
526  float xebphi = ebphi - 0.5;
527 
528  int ism = Numbers::iSM( id );
529 
530  // local coordinates
531  int ic = id.ic();
532  int ie = (ic-1)/20 + 1;
533  int ip = (ic-1)%20 + 1;
534 
535  float xie = ie - 0.5;
536  float xip = ip - 0.5;
537 
538  if ( runType[ism-1] == physics || runType[ism-1] == notdata ) {
539 
540  if ( meEBRecHitOccupancy_ ) meEBRecHitOccupancy_->Fill( xebphi, xebeta );
543 
544  uint32_t flag = rechitItr->recoFlag();
545 
546  uint32_t sev = sevlv->severityLevel( id, *rechits);
547 
548  if ( rechitItr->energy() > recHitEnergyMin_ && flag == EcalRecHit::kGood && sev == EcalSeverityLevel::kGood ) {
549 
550  if ( meEBRecHitOccupancyThr_ ) meEBRecHitOccupancyThr_->Fill( xebphi, xebeta );
553 
554  }
555 
556  if ( flag == EcalRecHit::kGood && sev == EcalSeverityLevel::kGood ) {
557  if ( meEBRecHitEnergy_[ism-1] ) meEBRecHitEnergy_[ism-1]->Fill( xie, xip, rechitItr->energy() );
558  if ( meSpectrum_[ism-1] ) meSpectrum_[ism-1]->Fill( rechitItr->energy() );
559  if ( meEBRecHitSpectrum_ ) meEBRecHitSpectrum_->Fill( rechitItr->energy() );
560  }
561 
562  }
563  }
564 
565  } else {
566 
567  edm::LogWarning("EBOccupancyTask") << EcalRecHitCollection_ << " not available";
568 
569  }
570 
572 
573  if ( e.getByLabel(EcalTrigPrimDigiCollection_, trigPrimDigis) ) {
574 
575  int nebtpg = trigPrimDigis->size();
576  LogDebug("EBOccupancyTask") << "event " << ievt_ << " trigger primitives digis collection size " << nebtpg;
577 
578  for ( EcalTrigPrimDigiCollection::const_iterator tpdigiItr = trigPrimDigis->begin(); tpdigiItr != trigPrimDigis->end(); ++tpdigiItr ) {
579 
580  if ( Numbers::subDet( tpdigiItr->id() ) != EcalBarrel ) continue;
581 
582  int ebeta = tpdigiItr->id().ieta();
583  int ebphi = tpdigiItr->id().iphi();
584 
585  // phi_tower: change the range from global to SM-local
586  // phi==0 is in the middle of a SM
587  ebphi = ebphi + 2;
588  if ( ebphi > 72 ) ebphi = ebphi - 72;
589 
590  float xebeta = ebeta-0.5*tpdigiItr->id().zside();
591  float xebphi = ebphi-0.5;
592 
593  int ism = Numbers::iSM( tpdigiItr->id() );
594 
595  if ( runType[ism-1] == physics || runType[ism-1] == notdata ) {
596 
600 
601  if ( tpdigiItr->compressedEt() > trigPrimEtMin_ ) {
602 
606 
607  }
608  }
609  }
610 
611  } else {
612 
613  edm::LogWarning("EBOccupancyTask") << EcalTrigPrimDigiCollection_ << " not available";
614 
615  }
616 
617 }
618 
#define LogDebug(id)
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
virtual ~EBOccupancyTask()
Destructor.
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
int i
Definition: DBlmapReader.cc:9
MonitorElement * meEBTestPulseDigiOccupancy_
long int flag
Definition: mlp_lapack.h:47
MonitorElement * meEBTrigPrimDigiOccupancyProjEtaThr_
MonitorElement * meEBTrigPrimDigiOccupancy_
MonitorElement * meEBRecHitOccupancyProjEta_
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
MonitorElement * meOccupancy_[36]
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
std::string prefixME_
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2530
MonitorElement * meEBTrigPrimDigiOccupancyProjPhi_
Some &quot;id&quot; conversions.
void beginJob(void)
BeginJob.
MonitorElement * meEBDigiOccupancy_
static std::string sEB(const unsigned ism)
Definition: Numbers.cc:94
std::vector< T >::const_iterator const_iterator
edm::InputTag EBDigiCollection_
DQMStore * dqmStore_
MonitorElement * meEBLaserDigiOccupancy_
MonitorElement * book1DD(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1S histogram.
Definition: DQMStore.cc:749
MonitorElement * meEBRecHitOccupancyThr_
MonitorElement * meEBRecHitEnergy_[36]
MonitorElement * meEBRecHitSpectrum_
MonitorElement * meOccupancyMem_[36]
MonitorElement * meEBTrigPrimDigiOccupancyProjEta_
MonitorElement * meEBTrigPrimDigiOccupancyThr_
void Fill(long long x)
void tag(MonitorElement *me, unsigned int myTag)
Definition: DQMStore.cc:1354
edm::InputTag EcalRecHitCollection_
void reset(void)
Reset.
void cleanup(void)
Cleanup.
MonitorElement * meEBRecHitOccupancyProjPhi_
std::string subfolder_
void removeElement(const std::string &name)
Definition: DQMStore.cc:2572
MonitorElement * meSpectrum_[36]
int ieta() const
get the crystal ieta
Definition: EBDetId.h:44
std::string getName(Reflex::Type &cc)
Definition: ClassFiller.cc:18
MonitorElement * meEBRecHitOccupancyProjPhiThr_
void endRun(const edm::Run &r, const edm::EventSetup &c)
EndRun.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:94
MonitorElement * meEBDigiOccupancyProjEta_
static void initGeometry(const edm::EventSetup &setup, bool verbose=false)
Definition: Numbers.cc:50
MonitorElement * meEBPedestalDigiOccupancy_
edm::InputTag EcalPnDiodeDigiCollection_
MonitorElement * meEBDigiOccupancyProjPhi_
const T & get() const
Definition: EventSetup.h:55
MonitorElement * meEBTrigPrimDigiOccupancyProjPhiThr_
static unsigned iSM(const unsigned ism, const EcalSubdetector subdet)
Definition: Numbers.cc:246
MonitorElement * meEBRecHitOccupancyProjEtaThr_
edm::InputTag EcalRawDataCollection_
static EcalSubdetector subDet(const EBDetId &id)
Definition: Numbers.cc:145
void endJob(void)
EndJob.
EBOccupancyTask(const edm::ParameterSet &ps)
Constructor.
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
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
edm::InputTag EcalTrigPrimDigiCollection_
MonitorElement * meEBRecHitOccupancy_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33
void beginRun(const edm::Run &r, const edm::EventSetup &c)
BeginRun.
void setup(void)
Setup.
MonitorElement * bookProfile2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int nchZ, double lowZ, double highZ, const char *option="s")
Definition: DQMStore.cc:1175