CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 eventCounter_(0)
47 {
48  //
49  // Input from configurator file
50  //
51  folderName_ = ps.getUntrackedParameter<string>("FolderName","ALCAStreamHcalPhiSym");
52 
53  hbherecoMB = consumes<HBHERecHitCollection>(ps.getParameter<edm::InputTag>("hbheInputMB"));
54  horecoMB = ps.getParameter<edm::InputTag>("hoInputMB");
55  hfrecoMB = consumes<HFRecHitCollection>(ps.getParameter<edm::InputTag>("hfInputMB"));
56 
57  hbherecoNoise = consumes<HBHERecHitCollection>(ps.getParameter<edm::InputTag>("hbheInputNoise"));
58  horecoNoise = ps.getParameter<edm::InputTag>("hoInputNoise");
59  hfrecoNoise = consumes<HFRecHitCollection>(ps.getParameter<edm::InputTag>("hfInputNoise"));
60 
61  rawInLabel_ = consumes<FEDRawDataCollection>(ps.getParameter<edm::InputTag>("rawInputLabel"));
62 
63  period_ = ps.getParameter<unsigned int>("period") ;
64 
65  saveToFile_ = ps.getUntrackedParameter<bool>("SaveToFile",false);
66  fileName_ = ps.getUntrackedParameter<string>("FileName","MonitorAlCaHcalPhiSym.root");
67 
68  // histogram parameters
69 
70  // Distribution of rechits in iPhi, iEta
71  hiDistr_y_nbin_ = ps.getUntrackedParameter<int>("hiDistr_y_nbin",72);
72  hiDistr_y_min_ = ps.getUntrackedParameter<double>("hiDistr_y_min",0.5);
73  hiDistr_y_max_ = ps.getUntrackedParameter<double>("hiDistr_y_max",72.5);
74  hiDistr_x_nbin_ = ps.getUntrackedParameter<int>("hiDistr_x_nbin",41);
75  hiDistr_x_min_ = ps.getUntrackedParameter<double>("hiDistr_x_min",0.5);
76  hiDistr_x_max_ = ps.getUntrackedParameter<double>("hiDistr_x_max",41.5);
77  // Check for NZS
78  hiDistr_r_nbin_ = ps.getUntrackedParameter<int>("hiDistr_r_nbin",100);
79  ihbhe_size_ = ps.getUntrackedParameter<double>("ihbhe_size_",5184.);
80  ihf_size_ = ps.getUntrackedParameter<double>("ihf_size_",1728.);
81 
82 }
83 
85 {}
86 
87 //--------------------------------------------------------
89 
90  // create and cd into new folder
92 
93  eventCounter_ = 0;
94 
95  hFEDsize = ibooker.book1D("hFEDsize","HCAL FED size (kB)",200,-0.5,20.5);
96  hFEDsize->setAxisTitle("kB",1);
97 
98  hHcalIsZS = ibooker.book1D("hHcalIsZS", "Hcal Is ZS", 4, -1.5, 2.5);
99  hHcalIsZS->setBinLabel(2, "NZS");
100  hHcalIsZS->setBinLabel(3, "ZS");
101 
102  char hname[50];
103  sprintf(hname, "L1 Event Number %% %i", period_);
104  hL1Id = ibooker.book1D("hL1Id", hname,4200,-99.5,4099.5);
105  hL1Id->setAxisTitle(hname);
106 
107 
108  // book some histograms 1D
109  double xmin = 0.1;
110  double xmax = 1.1;
112  ibooker.book1D("DistrHBHEsize","Size of HBHE Collection",
114  xmin,
115  xmax
116  );
118  ibooker.book1D("DistrHFsize","Size of HF Collection",
120  xmin,
121  xmax
122  );
123 
124 
125  // First moment
126  hiDistrMBPl2D_ =
127  ibooker.book2D("MBdepthPl1", "iphi- +ieta signal distribution at depth1",
134  );
135 
136  hiDistrMBPl2D_->setAxisTitle("i#phi ", 2);
137  hiDistrMBPl2D_->setAxisTitle("i#eta ", 1);
138 
139 
141  ibooker.book2D("NoisedepthPl1", "iphi-ieta noise distribution at depth1",
142  hiDistr_x_nbin_+1,
143  hiDistr_x_min_-1.,
145  hiDistr_y_nbin_+1,
146  hiDistr_y_min_-1.,
148  );
149 
150  hiDistrNoisePl2D_->setAxisTitle("i#phi ", 2);
151  hiDistrNoisePl2D_->setAxisTitle("i#eta ", 1);
152 // Second moment
154  ibooker.book2D("MB2depthPl1", "iphi- +ieta signal distribution at depth1",
161  );
162 
163  hiDistrMB2Pl2D_->setAxisTitle("i#phi ", 2);
164  hiDistrMB2Pl2D_->setAxisTitle("i#eta ", 1);
165 
166 
168  ibooker.book2D("Noise2depthPl1", "iphi-ieta noise distribution at depth1",
175  );
176 
177  hiDistrNoise2Pl2D_->setAxisTitle("i#phi ", 2);
178  hiDistrNoise2Pl2D_->setAxisTitle("i#eta ", 1);
179 
180 // Variance
182  ibooker.book2D("VarMBdepthPl1", "iphi- +ieta signal distribution at depth1",
189  );
190 
191  hiDistrVarMBPl2D_->setAxisTitle("i#phi ", 2);
192  hiDistrVarMBPl2D_->setAxisTitle("i#eta ", 1);
193 
194 
196  ibooker.book2D("VarNoisedepthPl1", "iphi-ieta noise distribution at depth1",
203  );
204 
205  hiDistrVarNoisePl2D_->setAxisTitle("i#phi ", 2);
206  hiDistrVarNoisePl2D_->setAxisTitle("i#eta ", 1);
207 
208 //==================================================================================
209 // First moment
210  hiDistrMBMin2D_ =
211  ibooker.book2D("MBdepthMin1", "iphi- +ieta signal distribution at depth1",
218  );
219 
220  hiDistrMBMin2D_->setAxisTitle("i#phi ", 2);
221  hiDistrMBMin2D_->setAxisTitle("i#eta ", 1);
222 
223 
225  ibooker.book2D("NoisedepthMin1", "iphi-ieta noise distribution at depth1",
232  );
233 
234  hiDistrNoiseMin2D_->setAxisTitle("i#phi ", 2);
235  hiDistrNoiseMin2D_->setAxisTitle("i#eta ", 1);
236 // Second moment
238  ibooker.book2D("MB2depthMin1", "iphi- +ieta signal distribution at depth1",
245  );
246 
247  hiDistrMB2Min2D_->setAxisTitle("i#phi ", 2);
248  hiDistrMB2Min2D_->setAxisTitle("i#eta ", 1);
249 
250 
252  ibooker.book2D("Noise2depthMin1", "iphi-ieta noise distribution at depth1",
259  );
260 
261  hiDistrNoise2Min2D_->setAxisTitle("i#phi ", 2);
262  hiDistrNoise2Min2D_->setAxisTitle("i#eta ", 1);
263 
264 // Variance
266  ibooker.book2D("VarMBdepthMin1", "iphi- +ieta signal distribution at depth1",
273  );
274 
275  hiDistrVarMBMin2D_->setAxisTitle("i#phi ", 2);
276  hiDistrVarMBMin2D_->setAxisTitle("i#eta ", 1);
277 
278 
280  ibooker.book2D("VarNoisedepthMin1", "iphi-ieta noise distribution at depth1",
287  );
288 
289  hiDistrVarNoiseMin2D_->setAxisTitle("i#phi ", 2);
290  hiDistrVarNoiseMin2D_->setAxisTitle("i#eta ", 1);
291 
292 
293 }
294 
295 //--------------------------------------------------------
296 //void DQMHcalPhiSymAlCaReco::beginRun(const edm::Run& r, const EventSetup& context) {
298 //}
299 
300 //--------------------------------------------------------
302  const EventSetup& context) {
303 
304 }
305 
306 //-------------------------------------------------------------
307 
309  const EventSetup& iSetup ){
310 
311 
312  eventCounter_++;
313 
315  iEvent.getByToken(rawInLabel_,rawIn);
316 
317  if(!rawIn.isValid()){
318  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
319  return ;
320  }
321 
322  //get HCAL FEDs:
323  std::vector<int> selFEDs;
325  {
326  selFEDs.push_back(i);
327  }
328 
329  // std::cout<<" Size of FED "<<selFEDs.size()<<std::endl;
330 
331  const FEDRawDataCollection *rdc=rawIn.product();
332 
333  bool hcalIsZS = false ;
334  for (unsigned int k=0; k<selFEDs.size(); k++)
335  {
336  const FEDRawData & fedData = rdc->FEDData(selFEDs[k]);
337  // std::cout<<fedData.size()*std::pow(1024.,-1)<<std::endl;
338  hFEDsize->Fill(fedData.size()*std::pow(1024.,-1),1);
339 
340  // get HCAL DCC Header for each FEDRawData
341  const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(fedData.data());
342 
343  if (!dccHeader) continue;
344 
345  // walk through the HTR data...
346  HcalHTRData htr;
347 
348  int nspigot =0;
349  for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {
350  nspigot++;
351 
352  if (!dccHeader->getSpigotPresent(spigot)) continue;
353 
354  // Load the given decoder with the pointer and length from this spigot.
355  dccHeader->getSpigotData(spigot,htr, fedData.size());
356 
357  if(k != 20 && nspigot !=14 ) {
358  if ( !htr.isUnsuppressed() ) { hcalIsZS = true; }
359  }
360  }
361 
362  } // loop over HcalFEDs
363 
364  hHcalIsZS->Fill( hcalIsZS );
365 
366  // get Trigger FED-Id
367  const FEDRawData& fedData = rdc->FEDData(FEDNumbering::MINTriggerGTPFEDID) ;
368  FEDHeader header(fedData.data()) ;
369 
371  hL1Id->Fill( (header.lvl1ID())%period_ );
372 
374  iEvent.getByToken(hbherecoNoise, hbheNS);
375 
376  if(!hbheNS.isValid()){
377  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
378  return ;
379  }
380 
382  iEvent.getByToken(hbherecoMB, hbheMB);
383 
384  if(!hbheMB.isValid()){
385  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
386  return ;
387  }
388 
390  iEvent.getByToken(hfrecoNoise, hfNS);
391 
392  if(!hfNS.isValid()){
393  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
394  return ;
395  }
396 
398  iEvent.getByToken(hfrecoMB, hfMB);
399 
400  if(!hfMB.isValid()){
401  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
402  return ;
403  }
404 
405  const HBHERecHitCollection HithbheNS = *(hbheNS.product());
406 
407  hiDistrHBHEsize1D_->Fill(HithbheNS.size()/ihbhe_size_);
408 
409 
410  for(HBHERecHitCollection::const_iterator hbheItr=HithbheNS.begin(); hbheItr!=HithbheNS.end(); hbheItr++)
411  {
412  DetId id = (*hbheItr).detid();
413  HcalDetId hid=HcalDetId(id);
414 
415  if(hid.depth() == 1) {
416  if( hid.ieta() > 0 ) {
417  hiDistrNoisePl2D_->Fill(hid.ieta(),hid.iphi(),hbheItr->energy());
418  hiDistrNoise2Pl2D_->Fill(hid.ieta(),hid.iphi(),hbheItr->energy()*hbheItr->energy());
419  } else {
420  hiDistrNoiseMin2D_->Fill(fabs(hid.ieta()),hid.iphi(),hbheItr->energy());
421  hiDistrNoise2Min2D_->Fill(fabs(hid.ieta()),hid.iphi(),hbheItr->energy()*hbheItr->energy());
422  }
423  }
424  }
425 
426  const HBHERecHitCollection HithbheMB = *(hbheMB.product());
427 
428  for(HBHERecHitCollection::const_iterator hbheItr=HithbheMB.begin(); hbheItr!=HithbheMB.end(); hbheItr++)
429  {
430  DetId id = (*hbheItr).detid();
431  HcalDetId hid=HcalDetId(id);
432 
433  if(hid.depth() == 1) {
434  if( hid.ieta() > 0 ) {
435  hiDistrMBPl2D_->Fill(hid.ieta(),hid.iphi(),hbheItr->energy());
436  hiDistrMB2Pl2D_->Fill(hid.ieta(),hid.iphi(),hbheItr->energy()*hbheItr->energy());
437  } else {
438  hiDistrMBMin2D_->Fill(fabs(hid.ieta()),hid.iphi(),hbheItr->energy());
439  hiDistrMB2Min2D_->Fill(fabs(hid.ieta()),hid.iphi(),hbheItr->energy()*hbheItr->energy());
440  }
441  }
442 
443  }
444 
445  const HFRecHitCollection HithfNS = *(hfNS.product());
446 
447  hiDistrHFsize1D_->Fill(HithfNS.size()/ihf_size_);
448 
449  for(HFRecHitCollection::const_iterator hbheItr=HithfNS.begin(); hbheItr!=HithfNS.end(); hbheItr++)
450  {
451 
452  DetId id = (*hbheItr).detid();
453  HcalDetId hid=HcalDetId(id);
454 
455  if(hid.depth() == 1) {
456  if( hid.ieta() > 0 ) {
457  hiDistrNoisePl2D_->Fill(hid.ieta(),hid.iphi(),hbheItr->energy());
458  hiDistrNoise2Pl2D_->Fill(hid.ieta(),hid.iphi(),hbheItr->energy()*hbheItr->energy());
459  } else {
460  hiDistrNoiseMin2D_->Fill(fabs(hid.ieta()),hid.iphi(),hbheItr->energy());
461  hiDistrNoise2Min2D_->Fill(fabs(hid.ieta()),hid.iphi(),hbheItr->energy()*hbheItr->energy());
462  }
463  }
464 
465  }
466 
467  const HFRecHitCollection HithfMB = *(hfMB.product());
468 
469  for(HFRecHitCollection::const_iterator hbheItr=HithfMB.begin(); hbheItr!=HithfMB.end(); hbheItr++)
470  {
471  DetId id = (*hbheItr).detid();
472  HcalDetId hid=HcalDetId(id);
473 
474  if(hid.depth() == 1) {
475  if( hid.ieta() > 0 ) {
476  hiDistrMBPl2D_->Fill(hid.ieta(),hid.iphi(),hbheItr->energy());
477  hiDistrMB2Pl2D_->Fill(hid.ieta(),hid.iphi(),hbheItr->energy()*hbheItr->energy());
478  } else {
479  hiDistrMBMin2D_->Fill(fabs(hid.ieta()),hid.iphi(),hbheItr->energy());
480  hiDistrMB2Min2D_->Fill(fabs(hid.ieta()),hid.iphi(),hbheItr->energy()*hbheItr->energy());
481  }
482  }
483  }
484 
485 
486 } //analyze
487 
488 
489 
490 
491 //--------------------------------------------------------
493  const EventSetup& context) {
494 }
495 //--------------------------------------------------------
496 void DQMHcalPhiSymAlCaReco::endRun(const Run& r, const EventSetup& context){
497 // Keep Variances
498  if(eventCounter_ > 0) {
499  for(int k=0; k<=hiDistr_x_nbin_;k++)
500  {
501  for(int j=0; j<=hiDistr_y_nbin_;j++)
502  {
503 // First moment
504  float cc1=hiDistrMBPl2D_->getBinContent(k,j);
505  cc1 = cc1 * 1./eventCounter_;
506  float cc2=hiDistrNoisePl2D_->getBinContent(k,j);
507  cc2 = cc2 * 1./eventCounter_;
508  float cc3=hiDistrMBMin2D_->getBinContent(k,j);
509  cc3 = cc3 * 1./eventCounter_;
510  float cc4=hiDistrNoiseMin2D_->getBinContent(k,j);
511  cc4 = cc4 * 1./eventCounter_;
512 // Second moment
513  float cc11=hiDistrMB2Pl2D_->getBinContent(k,j);
514  cc11 = cc11 * 1./eventCounter_;
515  hiDistrVarMBPl2D_->setBinContent(k,j,cc11-cc1*cc1);
516  float cc22=hiDistrNoise2Pl2D_->getBinContent(k,j);
517  cc22 = cc22 * 1./eventCounter_;
518  hiDistrVarNoisePl2D_->setBinContent(k,j,cc22-cc2*cc2);
519  float cc33=hiDistrMB2Min2D_->getBinContent(k,j);
520  cc33 = cc33 * 1./eventCounter_;
521  hiDistrVarMBMin2D_->setBinContent(k,j,cc33-cc3*cc3);
522  float cc44=hiDistrNoise2Min2D_->getBinContent(k,j);
523  cc44 = cc44 * 1./eventCounter_;
524  hiDistrVarNoiseMin2D_->setBinContent(k,j,cc44-cc4*cc4);
525  }
526  }
527  }
528 }
529 
530 
#define LogDebug(id)
T getParameter(std::string const &) const
MonitorElement * hiDistrNoisePl2D_
T getUntrackedParameter(std::string const &, T const &) const
bool saveToFile_
Write to file.
int i
Definition: DBlmapReader.cc:9
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:446
edm::EDGetTokenT< HBHERecHitCollection > hbherecoNoise
std::vector< HBHERecHit >::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_
void endRun(const edm::Run &r, const edm::EventSetup &c)
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:353
MonitorElement * hiDistrMBPl2D_
MonitorElement * hiDistrHFsize1D_
int depth() const
get the tower depth
Definition: HcalDetId.h:40
edm::EDGetTokenT< HFRecHitCollection > hfrecoNoise
int iEvent
Definition: GenABIO.cc:230
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
int ieta() const
get the cell ieta
Definition: HcalDetId.h:36
MonitorElement * hiDistrVarMBMin2D_
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
int j
Definition: DBlmapReader.cc:9
MonitorElement * hiDistrVarNoisePl2D_
bool getSpigotPresent(unsigned int nspigot) const
Read the &quot;PRESENT&quot; bit for this spigot.
std::string folderName_
DQM folder name.
MonitorElement * hiDistrMB2Pl2D_
bool isValid() const
Definition: HandleBase.h:76
MonitorElement * hiDistrNoise2Min2D_
int k[5][pyjets_maxn]
void analyze(const edm::Event &e, const edm::EventSetup &c)
const_iterator end() const
int iphi() const
get the cell iphi
Definition: HcalDetId.h:38
Definition: DetId.h:18
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
T const * product() const
Definition: Handle.h:81
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
MonitorElement * hiDistrMBMin2D_
return(e1-e2)*(e1-e2)+dp *dp
edm::EDGetTokenT< HFRecHitCollection > hfrecoMB
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:19
double getBinContent(int binx) const
get content of bin (1-D)
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
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.
volatile std::atomic< bool > shutdown_flag false
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)
virtual 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
const_iterator begin() const
Definition: Run.h:41
MonitorElement * hiDistrHBHEsize1D_
MonitorElement * hiDistrMB2Min2D_