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 
15 
17 
18 // DQM include files
19 
21 
22 // work on collections
23 
28 
34 
37 
38 using namespace std;
39 using namespace edm;
40 
41 // ******************************************
42 // constructors
43 // *****************************************
44 
46  //
47  // Input from configurator file
48  //
49  folderName_ = ps.getUntrackedParameter<string>("FolderName", "ALCAStreamHcalPhiSym");
50 
51  hbherecoMB = consumes<HBHERecHitCollection>(ps.getParameter<edm::InputTag>("hbheInputMB"));
52  horecoMB = ps.getParameter<edm::InputTag>("hoInputMB");
53  hfrecoMB = consumes<HFRecHitCollection>(ps.getParameter<edm::InputTag>("hfInputMB"));
54 
55  hbherecoNoise = consumes<HBHERecHitCollection>(ps.getParameter<edm::InputTag>("hbheInputNoise"));
56  horecoNoise = ps.getParameter<edm::InputTag>("hoInputNoise");
57  hfrecoNoise = consumes<HFRecHitCollection>(ps.getParameter<edm::InputTag>("hfInputNoise"));
58 
59  rawInLabel_ = consumes<FEDRawDataCollection>(ps.getParameter<edm::InputTag>("rawInputLabel"));
60 
61  period_ = ps.getParameter<unsigned int>("period");
62 
63  saveToFile_ = ps.getUntrackedParameter<bool>("SaveToFile", false);
64  fileName_ = ps.getUntrackedParameter<string>("FileName", "MonitorAlCaHcalPhiSym.root");
65 
66  // histogram parameters
67 
68  // Distribution of rechits in iPhi, iEta
69  hiDistr_y_nbin_ = ps.getUntrackedParameter<int>("hiDistr_y_nbin", 72);
70  hiDistr_y_min_ = ps.getUntrackedParameter<double>("hiDistr_y_min", 0.5);
71  hiDistr_y_max_ = ps.getUntrackedParameter<double>("hiDistr_y_max", 72.5);
72  hiDistr_x_nbin_ = ps.getUntrackedParameter<int>("hiDistr_x_nbin", 41);
73  hiDistr_x_min_ = ps.getUntrackedParameter<double>("hiDistr_x_min", 0.5);
74  hiDistr_x_max_ = ps.getUntrackedParameter<double>("hiDistr_x_max", 41.5);
75  // Check for NZS
76  hiDistr_r_nbin_ = ps.getUntrackedParameter<int>("hiDistr_r_nbin", 100);
77  ihbhe_size_ = ps.getUntrackedParameter<double>("ihbhe_size_", 5184.);
78  ihf_size_ = ps.getUntrackedParameter<double>("ihf_size_", 1728.);
79 }
80 
82 
83 //--------------------------------------------------------
85  edm::Run const &irun,
86  edm::EventSetup const &isetup) {
87  // create and cd into new folder
89 
90  eventCounter_ = 0;
91 
92  hFEDsize = ibooker.book1D("hFEDsize", "HCAL FED size (kB)", 200, -0.5, 20.5);
93  hFEDsize->setAxisTitle("kB", 1);
94 
95  hHcalIsZS = ibooker.book1D("hHcalIsZS", "Hcal Is ZS", 4, -1.5, 2.5);
96  hHcalIsZS->setBinLabel(2, "NZS");
97  hHcalIsZS->setBinLabel(3, "ZS");
98 
99  char hname[50];
100  sprintf(hname, "L1 Event Number %% %i", period_);
101  hL1Id = ibooker.book1D("hL1Id", hname, 4200, -99.5, 4099.5);
102  hL1Id->setAxisTitle(hname);
103 
104  // book some histograms 1D
105  double xmin = 0.1;
106  double xmax = 1.1;
107  hiDistrHBHEsize1D_ = ibooker.book1D("DistrHBHEsize", "Size of HBHE Collection", hiDistr_r_nbin_, xmin, xmax);
108  hiDistrHFsize1D_ = ibooker.book1D("DistrHFsize", "Size of HF Collection", hiDistr_r_nbin_, xmin, xmax);
109 
110  // First moment
111  hiDistrMBPl2D_ = ibooker.book2D("MBdepthPl1",
112  "iphi- +ieta signal distribution at depth1",
119 
120  hiDistrMBPl2D_->setAxisTitle("i#phi ", 2);
121  hiDistrMBPl2D_->setAxisTitle("i#eta ", 1);
122 
123  hiDistrNoisePl2D_ = ibooker.book2D("NoisedepthPl1",
124  "iphi-ieta noise distribution at depth1",
125  hiDistr_x_nbin_ + 1,
126  hiDistr_x_min_ - 1.,
128  hiDistr_y_nbin_ + 1,
129  hiDistr_y_min_ - 1.,
131 
132  hiDistrNoisePl2D_->setAxisTitle("i#phi ", 2);
133  hiDistrNoisePl2D_->setAxisTitle("i#eta ", 1);
134  // Second moment
135  hiDistrMB2Pl2D_ = ibooker.book2D("MB2depthPl1",
136  "iphi- +ieta signal distribution at depth1",
143 
144  hiDistrMB2Pl2D_->setAxisTitle("i#phi ", 2);
145  hiDistrMB2Pl2D_->setAxisTitle("i#eta ", 1);
146 
147  hiDistrNoise2Pl2D_ = ibooker.book2D("Noise2depthPl1",
148  "iphi-ieta noise distribution at depth1",
155 
156  hiDistrNoise2Pl2D_->setAxisTitle("i#phi ", 2);
157  hiDistrNoise2Pl2D_->setAxisTitle("i#eta ", 1);
158 
159  // Variance
160  hiDistrVarMBPl2D_ = ibooker.book2D("VarMBdepthPl1",
161  "iphi- +ieta signal distribution at depth1",
168 
169  hiDistrVarMBPl2D_->setAxisTitle("i#phi ", 2);
170  hiDistrVarMBPl2D_->setAxisTitle("i#eta ", 1);
171 
172  hiDistrVarNoisePl2D_ = ibooker.book2D("VarNoisedepthPl1",
173  "iphi-ieta noise distribution at depth1",
180 
181  hiDistrVarNoisePl2D_->setAxisTitle("i#phi ", 2);
182  hiDistrVarNoisePl2D_->setAxisTitle("i#eta ", 1);
183 
184  //==================================================================================
185  // First moment
186  hiDistrMBMin2D_ = ibooker.book2D("MBdepthMin1",
187  "iphi- +ieta signal distribution at depth1",
194 
195  hiDistrMBMin2D_->setAxisTitle("i#phi ", 2);
196  hiDistrMBMin2D_->setAxisTitle("i#eta ", 1);
197 
198  hiDistrNoiseMin2D_ = ibooker.book2D("NoisedepthMin1",
199  "iphi-ieta noise distribution at depth1",
206 
207  hiDistrNoiseMin2D_->setAxisTitle("i#phi ", 2);
208  hiDistrNoiseMin2D_->setAxisTitle("i#eta ", 1);
209  // Second moment
210  hiDistrMB2Min2D_ = ibooker.book2D("MB2depthMin1",
211  "iphi- +ieta signal distribution at depth1",
218 
219  hiDistrMB2Min2D_->setAxisTitle("i#phi ", 2);
220  hiDistrMB2Min2D_->setAxisTitle("i#eta ", 1);
221 
222  hiDistrNoise2Min2D_ = ibooker.book2D("Noise2depthMin1",
223  "iphi-ieta noise distribution at depth1",
230 
231  hiDistrNoise2Min2D_->setAxisTitle("i#phi ", 2);
232  hiDistrNoise2Min2D_->setAxisTitle("i#eta ", 1);
233 
234  // Variance
235  hiDistrVarMBMin2D_ = ibooker.book2D("VarMBdepthMin1",
236  "iphi- +ieta signal distribution at depth1",
243 
244  hiDistrVarMBMin2D_->setAxisTitle("i#phi ", 2);
245  hiDistrVarMBMin2D_->setAxisTitle("i#eta ", 1);
246 
247  hiDistrVarNoiseMin2D_ = ibooker.book2D("VarNoisedepthMin1",
248  "iphi-ieta noise distribution at depth1",
255 
256  hiDistrVarNoiseMin2D_->setAxisTitle("i#phi ", 2);
257  hiDistrVarNoiseMin2D_->setAxisTitle("i#eta ", 1);
258 }
259 
260 //--------------------------------------------------------
261 // void DQMHcalPhiSymAlCaReco::beginRun(const edm::Run& r, const EventSetup&
262 // context) {
264 //}
265 
266 //--------------------------------------------------------
267 
268 //-------------------------------------------------------------
269 
271  eventCounter_++;
272 
274  iEvent.getByToken(rawInLabel_, rawIn);
275 
276  if (!rawIn.isValid()) {
277  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
278  return;
279  }
280 
281  // get HCAL FEDs:
282  std::vector<int> selFEDs;
284  selFEDs.push_back(i);
285  }
286 
287  // std::cout<<" Size of FED "<<selFEDs.size()<<std::endl;
288 
289  const FEDRawDataCollection *rdc = rawIn.product();
290 
291  bool hcalIsZS = false;
292  int lvl1ID = 0;
293  bool lvl1IDFound = false;
294  for (unsigned int k = 0; k < selFEDs.size(); k++) {
295  const FEDRawData &fedData = rdc->FEDData(selFEDs[k]);
296  // std::cout<<fedData.size()*std::pow(1024.,-1)<<std::endl;
297  hFEDsize->Fill(fedData.size() * std::pow(1024., -1), 1);
298 
299  // get HCAL DCC Header for each FEDRawData
300  const HcalDCCHeader *dccHeader = (const HcalDCCHeader *)(fedData.data());
301  if (dccHeader) {
302  // walk through the HTR data...
303  HcalHTRData htr;
304 
305  int nspigot = 0;
306  for (int spigot = 0; spigot < HcalDCCHeader::SPIGOT_COUNT; spigot++) {
307  nspigot++;
308 
309  if (!dccHeader->getSpigotPresent(spigot))
310  continue;
311 
312  // Load the given decoder with the pointer and length from this spigot.
313  dccHeader->getSpigotData(spigot, htr, fedData.size());
314 
315  if (k != 20 && nspigot != 14) {
316  if (!htr.isUnsuppressed()) {
317  hcalIsZS = true;
318  }
319  }
320  }
321  }
322 
323  // try to get the lvl1ID from the HCAL fed
324  if (!lvl1IDFound && (fedData.size() > 0)) {
325  // get FED Header for FEDRawData
326  FEDHeader fedHeader(fedData.data());
327  lvl1ID = fedHeader.lvl1ID();
328  lvl1IDFound = true;
329  }
330  } // loop over HcalFEDs
331 
332  hHcalIsZS->Fill(hcalIsZS);
333  hL1Id->Fill(lvl1ID % period_);
334 
336  iEvent.getByToken(hbherecoNoise, hbheNS);
337 
338  if (!hbheNS.isValid()) {
339  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
340  return;
341  }
342 
344  iEvent.getByToken(hbherecoMB, hbheMB);
345 
346  if (!hbheMB.isValid()) {
347  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
348  return;
349  }
350 
352  iEvent.getByToken(hfrecoNoise, hfNS);
353 
354  if (!hfNS.isValid()) {
355  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
356  return;
357  }
358 
360  iEvent.getByToken(hfrecoMB, hfMB);
361 
362  if (!hfMB.isValid()) {
363  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
364  return;
365  }
366 
367  const HBHERecHitCollection HithbheNS = *(hbheNS.product());
368 
369  hiDistrHBHEsize1D_->Fill(HithbheNS.size() / ihbhe_size_);
370 
371  for (HBHERecHitCollection::const_iterator hbheItr = HithbheNS.begin(); hbheItr != HithbheNS.end(); hbheItr++) {
372  DetId id = (*hbheItr).detid();
373  HcalDetId hid = HcalDetId(id);
374 
375  if (hid.depth() == 1) {
376  if (hid.ieta() > 0) {
377  hiDistrNoisePl2D_->Fill(hid.ieta(), hid.iphi(), hbheItr->energy());
378  hiDistrNoise2Pl2D_->Fill(hid.ieta(), hid.iphi(), hbheItr->energy() * hbheItr->energy());
379  } else {
380  hiDistrNoiseMin2D_->Fill(fabs(hid.ieta()), hid.iphi(), hbheItr->energy());
381  hiDistrNoise2Min2D_->Fill(fabs(hid.ieta()), hid.iphi(), hbheItr->energy() * hbheItr->energy());
382  }
383  }
384  }
385 
386  const HBHERecHitCollection HithbheMB = *(hbheMB.product());
387 
388  for (HBHERecHitCollection::const_iterator hbheItr = HithbheMB.begin(); hbheItr != HithbheMB.end(); hbheItr++) {
389  DetId id = (*hbheItr).detid();
390  HcalDetId hid = HcalDetId(id);
391 
392  if (hid.depth() == 1) {
393  if (hid.ieta() > 0) {
394  hiDistrMBPl2D_->Fill(hid.ieta(), hid.iphi(), hbheItr->energy());
395  hiDistrMB2Pl2D_->Fill(hid.ieta(), hid.iphi(), hbheItr->energy() * hbheItr->energy());
396  } else {
397  hiDistrMBMin2D_->Fill(fabs(hid.ieta()), hid.iphi(), hbheItr->energy());
398  hiDistrMB2Min2D_->Fill(fabs(hid.ieta()), hid.iphi(), hbheItr->energy() * hbheItr->energy());
399  }
400  }
401  }
402 
403  const HFRecHitCollection HithfNS = *(hfNS.product());
404 
405  hiDistrHFsize1D_->Fill(HithfNS.size() / ihf_size_);
406 
407  for (HFRecHitCollection::const_iterator hbheItr = HithfNS.begin(); hbheItr != HithfNS.end(); hbheItr++) {
408  DetId id = (*hbheItr).detid();
409  HcalDetId hid = HcalDetId(id);
410 
411  if (hid.depth() == 1) {
412  if (hid.ieta() > 0) {
413  hiDistrNoisePl2D_->Fill(hid.ieta(), hid.iphi(), hbheItr->energy());
414  hiDistrNoise2Pl2D_->Fill(hid.ieta(), hid.iphi(), hbheItr->energy() * hbheItr->energy());
415  } else {
416  hiDistrNoiseMin2D_->Fill(fabs(hid.ieta()), hid.iphi(), hbheItr->energy());
417  hiDistrNoise2Min2D_->Fill(fabs(hid.ieta()), hid.iphi(), hbheItr->energy() * hbheItr->energy());
418  }
419  }
420  }
421 
422  const HFRecHitCollection HithfMB = *(hfMB.product());
423 
424  for (HFRecHitCollection::const_iterator hbheItr = HithfMB.begin(); hbheItr != HithfMB.end(); hbheItr++) {
425  DetId id = (*hbheItr).detid();
426  HcalDetId hid = HcalDetId(id);
427 
428  if (hid.depth() == 1) {
429  if (hid.ieta() > 0) {
430  hiDistrMBPl2D_->Fill(hid.ieta(), hid.iphi(), hbheItr->energy());
431  hiDistrMB2Pl2D_->Fill(hid.ieta(), hid.iphi(), hbheItr->energy() * hbheItr->energy());
432  } else {
433  hiDistrMBMin2D_->Fill(fabs(hid.ieta()), hid.iphi(), hbheItr->energy());
434  hiDistrMB2Min2D_->Fill(fabs(hid.ieta()), hid.iphi(), hbheItr->energy() * hbheItr->energy());
435  }
436  }
437  }
438 
439 } // analyze
440 
441 //--------------------------------------------------------
442 //--------------------------------------------------------
443 void DQMHcalPhiSymAlCaReco::endRun(const Run &r, const EventSetup &context) {
444  // Keep Variances
445  if (eventCounter_ > 0) {
446  for (int k = 0; k <= hiDistr_x_nbin_; k++) {
447  for (int j = 0; j <= hiDistr_y_nbin_; j++) {
448  // First moment
449  float cc1 = hiDistrMBPl2D_->getBinContent(k, j);
450  cc1 = cc1 * 1. / eventCounter_;
451  float cc2 = hiDistrNoisePl2D_->getBinContent(k, j);
452  cc2 = cc2 * 1. / eventCounter_;
453  float cc3 = hiDistrMBMin2D_->getBinContent(k, j);
454  cc3 = cc3 * 1. / eventCounter_;
455  float cc4 = hiDistrNoiseMin2D_->getBinContent(k, j);
456  cc4 = cc4 * 1. / eventCounter_;
457  // Second moment
458  float cc11 = hiDistrMB2Pl2D_->getBinContent(k, j);
459  cc11 = cc11 * 1. / eventCounter_;
460  hiDistrVarMBPl2D_->setBinContent(k, j, cc11 - cc1 * cc1);
461  float cc22 = hiDistrNoise2Pl2D_->getBinContent(k, j);
462  cc22 = cc22 * 1. / eventCounter_;
463  hiDistrVarNoisePl2D_->setBinContent(k, j, cc22 - cc2 * cc2);
464  float cc33 = hiDistrMB2Min2D_->getBinContent(k, j);
465  cc33 = cc33 * 1. / eventCounter_;
466  hiDistrVarMBMin2D_->setBinContent(k, j, cc33 - cc3 * cc3);
467  float cc44 = hiDistrNoise2Min2D_->getBinContent(k, j);
468  cc44 = cc44 * 1. / eventCounter_;
469  hiDistrVarNoiseMin2D_->setBinContent(k, j, cc44 - cc4 * cc4);
470  }
471  }
472  }
473 }
#define LogDebug(id)
T getParameter(std::string const &) const
MonitorElement * hiDistrNoisePl2D_
T getUntrackedParameter(std::string const &, T const &) const
bool saveToFile_
Write to file.
void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * hiDistrVarMBPl2D_
MonitorElement * hiDistrVarNoiseMin2D_
DQMHcalPhiSymAlCaReco(const edm::ParameterSet &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< HBHERecHitCollection > hbherecoNoise
std::vector< T >::const_iterator const_iterator
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)
edm::EDGetTokenT< FEDRawDataCollection > rawInLabel_
int getSpigotData(int nspigot, HcalHTRData &decodeTool, int validSize) const
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
void Fill(long long x)
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:354
MonitorElement * hiDistrMBPl2D_
MonitorElement * hiDistrHFsize1D_
int depth() const
get the tower depth
Definition: HcalDetId.h:166
edm::EDGetTokenT< HFRecHitCollection > hfrecoNoise
int iEvent
Definition: GenABIO.cc:224
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
int ieta() const
get the cell ieta
Definition: HcalDetId.h:159
MonitorElement * hiDistrVarMBMin2D_
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
MonitorElement * hiDistrVarNoisePl2D_
bool getSpigotPresent(unsigned int nspigot) const
Read the "PRESENT" bit for this spigot.
std::string folderName_
DQM folder name.
MonitorElement * hiDistrMB2Pl2D_
bool isValid() const
Definition: HandleBase.h:74
MonitorElement * hiDistrNoise2Min2D_
int k[5][pyjets_maxn]
const_iterator end() const
int iphi() const
get the cell iphi
Definition: HcalDetId.h:161
Definition: DetId.h:18
T const * product() const
Definition: Handle.h:74
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
MonitorElement * hiDistrMBMin2D_
edm::EDGetTokenT< HFRecHitCollection > hfrecoMB
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:19
double getBinContent(int binx) const
get content of bin (1-D)
HLT enums.
size_type size() const
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
MonitorElement * hiDistrNoise2Pl2D_
MonitorElement * hiDistrNoiseMin2D_
std::string fileName_
Output file name if required.
uint32_t lvl1ID() const
Level-1 event number generated by the TTC system.
Definition: FEDHeader.cc:22
edm::EDGetTokenT< HBHERecHitCollection > hbherecoMB
object to monitor
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void analyze(const edm::Event &e, const edm::EventSetup &c) override
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void endRun(const edm::Run &r, const edm::EventSetup &c) override
const_iterator begin() const
Definition: Run.h:45
MonitorElement * hiDistrHBHEsize1D_
MonitorElement * hiDistrMB2Min2D_