CMS 3D CMS Logo

DQMHcalPhiSymAlCaReco.cc
Go to the documentation of this file.
1 /*
2  * \file DQMHcalPhiSymAlCaReco.cc
3  *
4  * \author Olga Kodolova
5  *
6  *
7  *
8  * Description: Monitoring of Phi Symmetry Calibration Stream
9  */
10 
18 
19 // DQM include files
20 
23 
24 // work on collections
25 
33 
36 
39 
41 public:
43  ~DQMHcalPhiSymAlCaReco() override;
44 
45 protected:
46  // void beginRun(const edm::Run& r, const edm::EventSetup& c);
47  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
48  void analyze(const edm::Event &e, const edm::EventSetup &c) override;
49 
50  void dqmEndRun(const edm::Run &r, const edm::EventSetup &c) override;
51 
52 private:
54 
55  //
56  // Monitor elements
57  //
62 
67 
72 
75 
79 
86 
88  double ihbhe_size_;
89  double ihf_size_;
90 
91  bool perLSsaving_; //to avoid nanoDQMIO crashing, driven by DQMServices/Core/python/DQMStore_cfi.py
92 
94 
98 
102 
104 
107 
110 
111  // period of ZS
112  unsigned int period_;
113 
116 };
117 
118 // ******************************************
119 // constructors
120 // *****************************************
121 
123  //
124  // Input from configurator file
125  //
126  folderName_ = ps.getUntrackedParameter<std::string>("FolderName", "ALCAStreamHcalPhiSym");
127 
128  hbherecoMB = consumes<HBHERecHitCollection>(ps.getParameter<edm::InputTag>("hbheInputMB"));
129  horecoMB = ps.getParameter<edm::InputTag>("hoInputMB");
130  hfrecoMB = consumes<HFRecHitCollection>(ps.getParameter<edm::InputTag>("hfInputMB"));
131 
132  hbherecoNoise = consumes<HBHERecHitCollection>(ps.getParameter<edm::InputTag>("hbheInputNoise"));
133  horecoNoise = ps.getParameter<edm::InputTag>("hoInputNoise");
134  hfrecoNoise = consumes<HFRecHitCollection>(ps.getParameter<edm::InputTag>("hfInputNoise"));
135 
136  rawInLabel_ = consumes<FEDRawDataCollection>(ps.getParameter<edm::InputTag>("rawInputLabel"));
137 
138  period_ = ps.getParameter<unsigned int>("period");
139 
140  saveToFile_ = ps.getUntrackedParameter<bool>("SaveToFile", false);
141  fileName_ = ps.getUntrackedParameter<std::string>("FileName", "MonitorAlCaHcalPhiSym.root");
142 
143  perLSsaving_ = (ps.getUntrackedParameter<bool>("perLSsaving", false));
144 
145  // histogram parameters
146 
147  // Distribution of rechits in iPhi, iEta
148  hiDistr_y_nbin_ = ps.getUntrackedParameter<int>("hiDistr_y_nbin", 72);
149  hiDistr_y_min_ = ps.getUntrackedParameter<double>("hiDistr_y_min", 0.5);
150  hiDistr_y_max_ = ps.getUntrackedParameter<double>("hiDistr_y_max", 72.5);
151  hiDistr_x_nbin_ = ps.getUntrackedParameter<int>("hiDistr_x_nbin", 41);
152  hiDistr_x_min_ = ps.getUntrackedParameter<double>("hiDistr_x_min", 0.5);
153  hiDistr_x_max_ = ps.getUntrackedParameter<double>("hiDistr_x_max", 41.5);
154  // Check for NZS
155  hiDistr_r_nbin_ = ps.getUntrackedParameter<int>("hiDistr_r_nbin", 100);
156  ihbhe_size_ = ps.getUntrackedParameter<double>("ihbhe_size_", 5184.);
157  ihf_size_ = ps.getUntrackedParameter<double>("ihf_size_", 1728.);
158 }
159 
161 
162 //--------------------------------------------------------
164  edm::Run const &irun,
165  edm::EventSetup const &isetup) {
166  // create and cd into new folder
167  ibooker.setCurrentFolder(folderName_);
168 
169  eventCounter_ = 0;
170 
171  hFEDsize = ibooker.book1D("hFEDsize", "HCAL FED size (kB)", 200, -0.5, 20.5);
172  hFEDsize->setAxisTitle("kB", 1);
173 
174  hHcalIsZS = ibooker.book1D("hHcalIsZS", "Hcal Is ZS", 4, -1.5, 2.5);
175  hHcalIsZS->setBinLabel(2, "NZS");
176  hHcalIsZS->setBinLabel(3, "ZS");
177 
178  char hname[50];
179  sprintf(hname, "L1 Event Number %% %i", period_);
180  hL1Id = ibooker.book1D("hL1Id", hname, 4200, -99.5, 4099.5);
181  hL1Id->setAxisTitle(hname);
182 
183  // book some histograms 1D
184  double xmin = 0.1;
185  double xmax = 1.1;
186  hiDistrHBHEsize1D_ = ibooker.book1D("DistrHBHEsize", "Size of HBHE Collection", hiDistr_r_nbin_, xmin, xmax);
187  hiDistrHFsize1D_ = ibooker.book1D("DistrHFsize", "Size of HF Collection", hiDistr_r_nbin_, xmin, xmax);
188 
189  // First moment
190  hiDistrMBPl2D_ = ibooker.book2D("MBdepthPl1",
191  "iphi- +ieta signal distribution at depth1",
198 
199  hiDistrMBPl2D_->setAxisTitle("i#phi ", 2);
200  hiDistrMBPl2D_->setAxisTitle("i#eta ", 1);
201 
202  hiDistrNoisePl2D_ = ibooker.book2D("NoisedepthPl1",
203  "iphi-ieta noise distribution at depth1",
204  hiDistr_x_nbin_ + 1,
205  hiDistr_x_min_ - 1.,
207  hiDistr_y_nbin_ + 1,
208  hiDistr_y_min_ - 1.,
210 
211  hiDistrNoisePl2D_->setAxisTitle("i#phi ", 2);
212  hiDistrNoisePl2D_->setAxisTitle("i#eta ", 1);
213  // Second moment
214  hiDistrMB2Pl2D_ = ibooker.book2D("MB2depthPl1",
215  "iphi- +ieta signal distribution at depth1",
222 
223  hiDistrMB2Pl2D_->setAxisTitle("i#phi ", 2);
224  hiDistrMB2Pl2D_->setAxisTitle("i#eta ", 1);
225 
226  hiDistrNoise2Pl2D_ = ibooker.book2D("Noise2depthPl1",
227  "iphi-ieta noise distribution at depth1",
234 
235  hiDistrNoise2Pl2D_->setAxisTitle("i#phi ", 2);
236  hiDistrNoise2Pl2D_->setAxisTitle("i#eta ", 1);
237 
238  // Variance
239  hiDistrVarMBPl2D_ = ibooker.book2D("VarMBdepthPl1",
240  "iphi- +ieta signal distribution at depth1",
247 
248  hiDistrVarMBPl2D_->setAxisTitle("i#phi ", 2);
249  hiDistrVarMBPl2D_->setAxisTitle("i#eta ", 1);
250 
251  hiDistrVarNoisePl2D_ = ibooker.book2D("VarNoisedepthPl1",
252  "iphi-ieta noise distribution at depth1",
259 
260  hiDistrVarNoisePl2D_->setAxisTitle("i#phi ", 2);
261  hiDistrVarNoisePl2D_->setAxisTitle("i#eta ", 1);
262 
263  //==================================================================================
264  // First moment
265  hiDistrMBMin2D_ = ibooker.book2D("MBdepthMin1",
266  "iphi- +ieta signal distribution at depth1",
273 
274  hiDistrMBMin2D_->setAxisTitle("i#phi ", 2);
275  hiDistrMBMin2D_->setAxisTitle("i#eta ", 1);
276 
277  hiDistrNoiseMin2D_ = ibooker.book2D("NoisedepthMin1",
278  "iphi-ieta noise distribution at depth1",
285 
286  hiDistrNoiseMin2D_->setAxisTitle("i#phi ", 2);
287  hiDistrNoiseMin2D_->setAxisTitle("i#eta ", 1);
288  // Second moment
289  hiDistrMB2Min2D_ = ibooker.book2D("MB2depthMin1",
290  "iphi- +ieta signal distribution at depth1",
297 
298  hiDistrMB2Min2D_->setAxisTitle("i#phi ", 2);
299  hiDistrMB2Min2D_->setAxisTitle("i#eta ", 1);
300 
301  hiDistrNoise2Min2D_ = ibooker.book2D("Noise2depthMin1",
302  "iphi-ieta noise distribution at depth1",
309 
310  hiDistrNoise2Min2D_->setAxisTitle("i#phi ", 2);
311  hiDistrNoise2Min2D_->setAxisTitle("i#eta ", 1);
312 
313  // Variance
314  hiDistrVarMBMin2D_ = ibooker.book2D("VarMBdepthMin1",
315  "iphi- +ieta signal distribution at depth1",
322 
323  hiDistrVarMBMin2D_->setAxisTitle("i#phi ", 2);
324  hiDistrVarMBMin2D_->setAxisTitle("i#eta ", 1);
325 
326  hiDistrVarNoiseMin2D_ = ibooker.book2D("VarNoisedepthMin1",
327  "iphi-ieta noise distribution at depth1",
334 
335  hiDistrVarNoiseMin2D_->setAxisTitle("i#phi ", 2);
336  hiDistrVarNoiseMin2D_->setAxisTitle("i#eta ", 1);
337 }
338 
339 //--------------------------------------------------------
340 // void DQMHcalPhiSymAlCaReco::beginRun(const edm::Run& r, const EventSetup&
341 // context) {
343 //}
344 
345 //--------------------------------------------------------
346 
347 //-------------------------------------------------------------
348 
350  eventCounter_++;
351 
353  iEvent.getByToken(rawInLabel_, rawIn);
354 
355  if (!rawIn.isValid()) {
356  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
357  return;
358  }
359 
360  // get HCAL FEDs:
361  std::vector<int> selFEDs;
363  selFEDs.push_back(i);
364  }
365 
366  // std::cout<<" Size of FED "<<selFEDs.size()<<std::endl;
367 
368  const FEDRawDataCollection *rdc = rawIn.product();
369 
370  bool hcalIsZS = false;
371  int lvl1ID = 0;
372  bool lvl1IDFound = false;
373  for (unsigned int k = 0; k < selFEDs.size(); k++) {
374  const FEDRawData &fedData = rdc->FEDData(selFEDs[k]);
375  // std::cout<<fedData.size()*std::pow(1024.,-1)<<std::endl;
376  hFEDsize->Fill(fedData.size() * std::pow(1024., -1), 1);
377 
378  // get HCAL DCC Header for each FEDRawData
379  const HcalDCCHeader *dccHeader = (const HcalDCCHeader *)(fedData.data());
380  if (dccHeader) {
381  // walk through the HTR data...
382  HcalHTRData htr;
383 
384  int nspigot = 0;
385  for (int spigot = 0; spigot < HcalDCCHeader::SPIGOT_COUNT; spigot++) {
386  nspigot++;
387 
388  if (!dccHeader->getSpigotPresent(spigot))
389  continue;
390 
391  // Load the given decoder with the pointer and length from this spigot.
392  dccHeader->getSpigotData(spigot, htr, fedData.size());
393 
394  if (k != 20 && nspigot != 14) {
395  if (!htr.isUnsuppressed()) {
396  hcalIsZS = true;
397  }
398  }
399  }
400  }
401 
402  // try to get the lvl1ID from the HCAL fed
403  if (!lvl1IDFound && (fedData.size() > 0)) {
404  // get FED Header for FEDRawData
405  FEDHeader fedHeader(fedData.data());
406  lvl1ID = fedHeader.lvl1ID();
407  lvl1IDFound = true;
408  }
409  } // loop over HcalFEDs
410 
411  hHcalIsZS->Fill(hcalIsZS);
412  hL1Id->Fill(lvl1ID % period_);
413 
415  iEvent.getByToken(hbherecoNoise, hbheNS);
416 
417  if (!hbheNS.isValid()) {
418  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
419  return;
420  }
421 
423  iEvent.getByToken(hbherecoMB, hbheMB);
424 
425  if (!hbheMB.isValid()) {
426  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
427  return;
428  }
429 
431  iEvent.getByToken(hfrecoNoise, hfNS);
432 
433  if (!hfNS.isValid()) {
434  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
435  return;
436  }
437 
439  iEvent.getByToken(hfrecoMB, hfMB);
440 
441  if (!hfMB.isValid()) {
442  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
443  return;
444  }
445 
446  const HBHERecHitCollection HithbheNS = *(hbheNS.product());
447 
448  hiDistrHBHEsize1D_->Fill(HithbheNS.size() / ihbhe_size_);
449 
450  for (HBHERecHitCollection::const_iterator hbheItr = HithbheNS.begin(); hbheItr != HithbheNS.end(); hbheItr++) {
451  DetId id = (*hbheItr).detid();
452  HcalDetId hid = HcalDetId(id);
453 
454  if (hid.depth() == 1) {
455  if (hid.ieta() > 0) {
456  hiDistrNoisePl2D_->Fill(hid.ieta(), hid.iphi(), hbheItr->energy());
457  hiDistrNoise2Pl2D_->Fill(hid.ieta(), hid.iphi(), hbheItr->energy() * hbheItr->energy());
458  } else {
459  hiDistrNoiseMin2D_->Fill(fabs(hid.ieta()), hid.iphi(), hbheItr->energy());
460  hiDistrNoise2Min2D_->Fill(fabs(hid.ieta()), hid.iphi(), hbheItr->energy() * hbheItr->energy());
461  }
462  }
463  }
464 
465  const HBHERecHitCollection HithbheMB = *(hbheMB.product());
466 
467  for (HBHERecHitCollection::const_iterator hbheItr = HithbheMB.begin(); hbheItr != HithbheMB.end(); hbheItr++) {
468  DetId id = (*hbheItr).detid();
469  HcalDetId hid = HcalDetId(id);
470 
471  if (hid.depth() == 1) {
472  if (hid.ieta() > 0) {
473  hiDistrMBPl2D_->Fill(hid.ieta(), hid.iphi(), hbheItr->energy());
474  hiDistrMB2Pl2D_->Fill(hid.ieta(), hid.iphi(), hbheItr->energy() * hbheItr->energy());
475  } else {
476  hiDistrMBMin2D_->Fill(fabs(hid.ieta()), hid.iphi(), hbheItr->energy());
477  hiDistrMB2Min2D_->Fill(fabs(hid.ieta()), hid.iphi(), hbheItr->energy() * hbheItr->energy());
478  }
479  }
480  }
481 
482  const HFRecHitCollection HithfNS = *(hfNS.product());
483 
484  hiDistrHFsize1D_->Fill(HithfNS.size() / ihf_size_);
485 
486  for (HFRecHitCollection::const_iterator hbheItr = HithfNS.begin(); hbheItr != HithfNS.end(); hbheItr++) {
487  DetId id = (*hbheItr).detid();
488  HcalDetId hid = HcalDetId(id);
489 
490  if (hid.depth() == 1) {
491  if (hid.ieta() > 0) {
492  hiDistrNoisePl2D_->Fill(hid.ieta(), hid.iphi(), hbheItr->energy());
493  hiDistrNoise2Pl2D_->Fill(hid.ieta(), hid.iphi(), hbheItr->energy() * hbheItr->energy());
494  } else {
495  hiDistrNoiseMin2D_->Fill(fabs(hid.ieta()), hid.iphi(), hbheItr->energy());
496  hiDistrNoise2Min2D_->Fill(fabs(hid.ieta()), hid.iphi(), hbheItr->energy() * hbheItr->energy());
497  }
498  }
499  }
500 
501  const HFRecHitCollection HithfMB = *(hfMB.product());
502 
503  for (HFRecHitCollection::const_iterator hbheItr = HithfMB.begin(); hbheItr != HithfMB.end(); hbheItr++) {
504  DetId id = (*hbheItr).detid();
505  HcalDetId hid = HcalDetId(id);
506 
507  if (hid.depth() == 1) {
508  if (hid.ieta() > 0) {
509  hiDistrMBPl2D_->Fill(hid.ieta(), hid.iphi(), hbheItr->energy());
510  hiDistrMB2Pl2D_->Fill(hid.ieta(), hid.iphi(), hbheItr->energy() * hbheItr->energy());
511  } else {
512  hiDistrMBMin2D_->Fill(fabs(hid.ieta()), hid.iphi(), hbheItr->energy());
513  hiDistrMB2Min2D_->Fill(fabs(hid.ieta()), hid.iphi(), hbheItr->energy() * hbheItr->energy());
514  }
515  }
516  }
517 
518 } // analyze
519 
520 //--------------------------------------------------------
521 //--------------------------------------------------------
523  // Keep Variances
524  if (eventCounter_ > 0 && !perLSsaving_) {
525  for (int k = 0; k <= hiDistr_x_nbin_; k++) {
526  for (int j = 0; j <= hiDistr_y_nbin_; j++) {
527  // First moment
528  float cc1 = hiDistrMBPl2D_->getBinContent(k, j);
529  cc1 = cc1 * 1. / eventCounter_;
530  float cc2 = hiDistrNoisePl2D_->getBinContent(k, j);
531  cc2 = cc2 * 1. / eventCounter_;
532  float cc3 = hiDistrMBMin2D_->getBinContent(k, j);
533  cc3 = cc3 * 1. / eventCounter_;
534  float cc4 = hiDistrNoiseMin2D_->getBinContent(k, j);
535  cc4 = cc4 * 1. / eventCounter_;
536  // Second moment
537  float cc11 = hiDistrMB2Pl2D_->getBinContent(k, j);
538  cc11 = cc11 * 1. / eventCounter_;
539  hiDistrVarMBPl2D_->setBinContent(k, j, cc11 - cc1 * cc1);
540  float cc22 = hiDistrNoise2Pl2D_->getBinContent(k, j);
541  cc22 = cc22 * 1. / eventCounter_;
542  hiDistrVarNoisePl2D_->setBinContent(k, j, cc22 - cc2 * cc2);
543  float cc33 = hiDistrMB2Min2D_->getBinContent(k, j);
544  cc33 = cc33 * 1. / eventCounter_;
545  hiDistrVarMBMin2D_->setBinContent(k, j, cc33 - cc3 * cc3);
546  float cc44 = hiDistrNoise2Min2D_->getBinContent(k, j);
547  cc44 = cc44 * 1. / eventCounter_;
548  hiDistrVarNoiseMin2D_->setBinContent(k, j, cc44 - cc4 * cc4);
549  }
550  }
551  }
552 }
553 
MonitorElement * hiDistrNoisePl2D_
bool saveToFile_
Write to file.
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
int getSpigotData(int nspigot, HcalHTRData &decodeTool, int validSize) const
MonitorElement * hiDistrVarMBPl2D_
MonitorElement * hiDistrVarNoiseMin2D_
DQMHcalPhiSymAlCaReco(const edm::ParameterSet &)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
size_type size() const
edm::EDGetTokenT< HBHERecHitCollection > hbherecoNoise
T const * product() const
Definition: Handle.h:70
std::vector< T >::const_iterator const_iterator
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:45
constexpr int pow(int x)
Definition: conifer.h:24
edm::EDGetTokenT< FEDRawDataCollection > rawInLabel_
void dqmEndRun(const edm::Run &r, const edm::EventSetup &c) override
T getUntrackedParameter(std::string const &, T const &) const
void Fill(long long x)
MonitorElement * hiDistrMBPl2D_
MonitorElement * hiDistrHFsize1D_
edm::EDGetTokenT< HFRecHitCollection > hfrecoNoise
int iEvent
Definition: GenABIO.cc:224
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
MonitorElement * hiDistrVarMBMin2D_
MonitorElement * hiDistrVarNoisePl2D_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const_iterator begin() const
std::string folderName_
DQM folder name.
MonitorElement * hiDistrMB2Pl2D_
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
MonitorElement * hiDistrNoise2Min2D_
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
const_iterator end() const
Definition: DetId.h:17
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * hiDistrMBMin2D_
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
bool isValid() const
Definition: HandleBase.h:70
edm::EDGetTokenT< HFRecHitCollection > hfrecoMB
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:20
MonitorElement * hiDistrNoise2Pl2D_
bool getSpigotPresent(unsigned int nspigot) const
Read the "PRESENT" bit for this spigot.
MonitorElement * hiDistrNoiseMin2D_
std::string fileName_
Output file name if required.
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:24
uint32_t lvl1ID() const
Level-1 event number generated by the TTC system.
Definition: FEDHeader.cc:15
edm::EDGetTokenT< HBHERecHitCollection > hbherecoMB
object to monitor
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
void analyze(const edm::Event &e, const edm::EventSetup &c) override
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: Run.h:45
MonitorElement * hiDistrHBHEsize1D_
MonitorElement * hiDistrMB2Min2D_
#define LogDebug(id)
virtual double getBinContent(int binx) const
get content of bin (1-D)
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:378
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164