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  * $Date: 2010/10/15 22:44:31 $
7  * $Revision: 1.17 $
8  *
9  *
10  * Description: Monitoring of Phi Symmetry Calibration Stream
11 */
12 
17 
19 
20 // DQM include files
21 
23 
24 // work on collections
26 
31 
38 
41 
42 using namespace std;
43 using namespace edm;
44 
45 // ******************************************
46 // constructors
47 // *****************************************
48 
50 eventCounter_(0)
51 {
53  //
54  // Input from configurator file
55  //
56  folderName_ = ps.getUntrackedParameter<string>("FolderName","ALCAStreamHcalPhiSym");
57 
58  hbherecoMB = ps.getParameter<edm::InputTag>("hbheInputMB");
59  horecoMB = ps.getParameter<edm::InputTag>("hoInputMB");
60  hfrecoMB = ps.getParameter<edm::InputTag>("hfInputMB");
61 
62  hbherecoNoise = ps.getParameter<edm::InputTag>("hbheInputNoise");
63  horecoNoise = ps.getParameter<edm::InputTag>("hoInputNoise");
64  hfrecoNoise = ps.getParameter<edm::InputTag>("hfInputNoise");
65 
66  rawInLabel_ = ps.getParameter<edm::InputTag>("rawInputLabel");
67 
68  period_ = ps.getParameter<unsigned int>("period") ;
69 
70  saveToFile_ = ps.getUntrackedParameter<bool>("SaveToFile",false);
71  fileName_ = ps.getUntrackedParameter<string>("FileName","MonitorAlCaHcalPhiSym.root");
72 
73  // histogram parameters
74 
75  // Distribution of rechits in iPhi, iEta
76  hiDistr_y_nbin_ = ps.getUntrackedParameter<int>("hiDistr_y_nbin",72);
77  hiDistr_y_min_ = ps.getUntrackedParameter<double>("hiDistr_y_min",0.5);
78  hiDistr_y_max_ = ps.getUntrackedParameter<double>("hiDistr_y_max",72.5);
79  hiDistr_x_nbin_ = ps.getUntrackedParameter<int>("hiDistr_x_nbin",41);
80  hiDistr_x_min_ = ps.getUntrackedParameter<double>("hiDistr_x_min",0.5);
81  hiDistr_x_max_ = ps.getUntrackedParameter<double>("hiDistr_x_max",41.5);
82  // Check for NZS
83  hiDistr_r_nbin_ = ps.getUntrackedParameter<int>("hiDistr_r_nbin",100);
84  ihbhe_size_ = ps.getUntrackedParameter<double>("ihbhe_size_",5184.);
85  ihf_size_ = ps.getUntrackedParameter<double>("ihf_size_",1728.);
86 
87 }
88 
90 {}
91 
92 //--------------------------------------------------------
94 
95  // create and cd into new folder
97 
98  eventCounter_ = 0;
99 
100  hFEDsize = dbe_->book1D("hFEDsize","HCAL FED size (kB)",200,-0.5,20.5);
101  hFEDsize->setAxisTitle("kB",1);
102 
103  hHcalIsZS = dbe_->book1D("hHcalIsZS", "Hcal Is ZS", 4, -1.5, 2.5);
104  hHcalIsZS->setBinLabel(2, "NZS");
105  hHcalIsZS->setBinLabel(3, "ZS");
106 
107  char hname[50];
108  sprintf(hname, "L1 Event Number %% %i", period_);
109  hL1Id = dbe_->book1D("hL1Id", hname,4200,-99.5,4099.5);
110  hL1Id->setAxisTitle(hname);
111 
112 
113  // book some histograms 1D
114  double xmin = 0.1;
115  double xmax = 1.1;
117  dbe_->book1D("DistrHBHEsize","Size of HBHE Collection",
119  xmin,
120  xmax
121  );
123  dbe_->book1D("DistrHFsize","Size of HF Collection",
125  xmin,
126  xmax
127  );
128 
129 
130  // First moment
131  hiDistrMBPl2D_ =
132  dbe_->book2D("MBdepthPl1", "iphi- +ieta signal distribution at depth1",
139  );
140 
141  hiDistrMBPl2D_->setAxisTitle("i#phi ", 2);
142  hiDistrMBPl2D_->setAxisTitle("i#eta ", 1);
143 
144 
146  dbe_->book2D("NoisedepthPl1", "iphi-ieta noise distribution at depth1",
147  hiDistr_x_nbin_+1,
148  hiDistr_x_min_-1.,
150  hiDistr_y_nbin_+1,
151  hiDistr_y_min_-1.,
153  );
154 
155  hiDistrNoisePl2D_->setAxisTitle("i#phi ", 2);
156  hiDistrNoisePl2D_->setAxisTitle("i#eta ", 1);
157 // Second moment
159  dbe_->book2D("MB2depthPl1", "iphi- +ieta signal distribution at depth1",
166  );
167 
168  hiDistrMB2Pl2D_->setAxisTitle("i#phi ", 2);
169  hiDistrMB2Pl2D_->setAxisTitle("i#eta ", 1);
170 
171 
173  dbe_->book2D("Noise2depthPl1", "iphi-ieta noise distribution at depth1",
180  );
181 
182  hiDistrNoise2Pl2D_->setAxisTitle("i#phi ", 2);
183  hiDistrNoise2Pl2D_->setAxisTitle("i#eta ", 1);
184 
185 // Variance
187  dbe_->book2D("VarMBdepthPl1", "iphi- +ieta signal distribution at depth1",
194  );
195 
196  hiDistrVarMBPl2D_->setAxisTitle("i#phi ", 2);
197  hiDistrVarMBPl2D_->setAxisTitle("i#eta ", 1);
198 
199 
201  dbe_->book2D("VarNoisedepthPl1", "iphi-ieta noise distribution at depth1",
208  );
209 
210  hiDistrVarNoisePl2D_->setAxisTitle("i#phi ", 2);
211  hiDistrVarNoisePl2D_->setAxisTitle("i#eta ", 1);
212 
213 //==================================================================================
214 // First moment
215  hiDistrMBMin2D_ =
216  dbe_->book2D("MBdepthMin1", "iphi- +ieta signal distribution at depth1",
223  );
224 
225  hiDistrMBMin2D_->setAxisTitle("i#phi ", 2);
226  hiDistrMBMin2D_->setAxisTitle("i#eta ", 1);
227 
228 
230  dbe_->book2D("NoisedepthMin1", "iphi-ieta noise distribution at depth1",
237  );
238 
239  hiDistrNoiseMin2D_->setAxisTitle("i#phi ", 2);
240  hiDistrNoiseMin2D_->setAxisTitle("i#eta ", 1);
241 // Second moment
243  dbe_->book2D("MB2depthMin1", "iphi- +ieta signal distribution at depth1",
250  );
251 
252  hiDistrMB2Min2D_->setAxisTitle("i#phi ", 2);
253  hiDistrMB2Min2D_->setAxisTitle("i#eta ", 1);
254 
255 
257  dbe_->book2D("Noise2depthMin1", "iphi-ieta noise distribution at depth1",
264  );
265 
266  hiDistrNoise2Min2D_->setAxisTitle("i#phi ", 2);
267  hiDistrNoise2Min2D_->setAxisTitle("i#eta ", 1);
268 
269 // Variance
271  dbe_->book2D("VarMBdepthMin1", "iphi- +ieta signal distribution at depth1",
278  );
279 
280  hiDistrVarMBMin2D_->setAxisTitle("i#phi ", 2);
281  hiDistrVarMBMin2D_->setAxisTitle("i#eta ", 1);
282 
283 
285  dbe_->book2D("VarNoisedepthMin1", "iphi-ieta noise distribution at depth1",
292  );
293 
294  hiDistrVarNoiseMin2D_->setAxisTitle("i#phi ", 2);
295  hiDistrVarNoiseMin2D_->setAxisTitle("i#eta ", 1);
296 
297 
298 }
299 
300 //--------------------------------------------------------
301 void DQMHcalPhiSymAlCaReco::beginRun(const edm::Run& r, const EventSetup& context) {
302 // eventCounter_ = 0;
303 }
304 
305 //--------------------------------------------------------
307  const EventSetup& context) {
308 
309 }
310 
311 //-------------------------------------------------------------
312 
314  const EventSetup& iSetup ){
315 
316 
317  eventCounter_++;
318 
320  iEvent.getByLabel(rawInLabel_,rawIn);
321 
322  if(!rawIn.isValid()){
323  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
324  return ;
325  }
326 
327  //get HCAL FEDs:
328  std::vector<int> selFEDs;
330  {
331  selFEDs.push_back(i);
332  }
333 
334  // std::cout<<" Size of FED "<<selFEDs.size()<<std::endl;
335 
336  const FEDRawDataCollection *rdc=rawIn.product();
337 
338  bool hcalIsZS = false ;
339  for (unsigned int k=0; k<selFEDs.size(); k++)
340  {
341  const FEDRawData & fedData = rdc->FEDData(selFEDs[k]);
342  // std::cout<<fedData.size()*std::pow(1024.,-1)<<std::endl;
343  hFEDsize->Fill(fedData.size()*std::pow(1024.,-1),1);
344 
345  // get HCAL DCC Header for each FEDRawData
346  const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(fedData.data());
347 
348  if (!dccHeader) continue;
349 
350  // walk through the HTR data...
351  HcalHTRData htr;
352 
353  int nspigot =0;
354  for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {
355  nspigot++;
356 
357  if (!dccHeader->getSpigotPresent(spigot)) continue;
358 
359  // Load the given decoder with the pointer and length from this spigot.
360  dccHeader->getSpigotData(spigot,htr, fedData.size());
361 
362  if(k != 20 && nspigot !=14 ) {
363  if ( !htr.isUnsuppressed() ) { hcalIsZS = true; }
364  }
365  }
366 
367  } // loop over HcalFEDs
368 
369  hHcalIsZS->Fill( hcalIsZS );
370 
371  // get Trigger FED-Id
372  const FEDRawData& fedData = rdc->FEDData(FEDNumbering::MINTriggerGTPFEDID) ;
373  FEDHeader header(fedData.data()) ;
374 
376  hL1Id->Fill( (header.lvl1ID())%period_ );
377 
379  iEvent.getByLabel(hbherecoNoise, hbheNS);
380 
381  if(!hbheNS.isValid()){
382  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
383  return ;
384  }
385 
387  iEvent.getByLabel(hbherecoMB, hbheMB);
388 
389  if(!hbheMB.isValid()){
390  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
391  return ;
392  }
393 
395  iEvent.getByLabel(hfrecoNoise, hfNS);
396 
397  if(!hfNS.isValid()){
398  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
399  return ;
400  }
401 
403  iEvent.getByLabel(hfrecoMB, hfMB);
404 
405  if(!hfMB.isValid()){
406  LogDebug("") << "HcalCalibAlgos: Error! can't get hbhe product!" << std::endl;
407  return ;
408  }
409 
410  const HBHERecHitCollection HithbheNS = *(hbheNS.product());
411 
412  hiDistrHBHEsize1D_->Fill(HithbheNS.size()/ihbhe_size_);
413 
414 
415  for(HBHERecHitCollection::const_iterator hbheItr=HithbheNS.begin(); hbheItr!=HithbheNS.end(); hbheItr++)
416  {
417  DetId id = (*hbheItr).detid();
418  HcalDetId hid=HcalDetId(id);
419 
420  if(hid.depth() == 1) {
421  if( hid.ieta() > 0 ) {
422  hiDistrNoisePl2D_->Fill(hid.ieta(),hid.iphi(),hbheItr->energy());
423  hiDistrNoise2Pl2D_->Fill(hid.ieta(),hid.iphi(),hbheItr->energy()*hbheItr->energy());
424  } else {
425  hiDistrNoiseMin2D_->Fill(fabs(hid.ieta()),hid.iphi(),hbheItr->energy());
426  hiDistrNoise2Min2D_->Fill(fabs(hid.ieta()),hid.iphi(),hbheItr->energy()*hbheItr->energy());
427  }
428  }
429  }
430 
431  const HBHERecHitCollection HithbheMB = *(hbheMB.product());
432 
433  for(HBHERecHitCollection::const_iterator hbheItr=HithbheMB.begin(); hbheItr!=HithbheMB.end(); hbheItr++)
434  {
435  DetId id = (*hbheItr).detid();
436  HcalDetId hid=HcalDetId(id);
437 
438  if(hid.depth() == 1) {
439  if( hid.ieta() > 0 ) {
440  hiDistrMBPl2D_->Fill(hid.ieta(),hid.iphi(),hbheItr->energy());
441  hiDistrMB2Pl2D_->Fill(hid.ieta(),hid.iphi(),hbheItr->energy()*hbheItr->energy());
442  } else {
443  hiDistrMBMin2D_->Fill(fabs(hid.ieta()),hid.iphi(),hbheItr->energy());
444  hiDistrMB2Min2D_->Fill(fabs(hid.ieta()),hid.iphi(),hbheItr->energy()*hbheItr->energy());
445  }
446  }
447 
448  }
449 
450  const HFRecHitCollection HithfNS = *(hfNS.product());
451 
452  hiDistrHFsize1D_->Fill(HithfNS.size()/ihf_size_);
453 
454  for(HFRecHitCollection::const_iterator hbheItr=HithfNS.begin(); hbheItr!=HithfNS.end(); hbheItr++)
455  {
456 
457  DetId id = (*hbheItr).detid();
458  HcalDetId hid=HcalDetId(id);
459 
460  if(hid.depth() == 1) {
461  if( hid.ieta() > 0 ) {
462  hiDistrNoisePl2D_->Fill(hid.ieta(),hid.iphi(),hbheItr->energy());
463  hiDistrNoise2Pl2D_->Fill(hid.ieta(),hid.iphi(),hbheItr->energy()*hbheItr->energy());
464  } else {
465  hiDistrNoiseMin2D_->Fill(fabs(hid.ieta()),hid.iphi(),hbheItr->energy());
466  hiDistrNoise2Min2D_->Fill(fabs(hid.ieta()),hid.iphi(),hbheItr->energy()*hbheItr->energy());
467  }
468  }
469 
470  }
471 
472  const HFRecHitCollection HithfMB = *(hfMB.product());
473 
474  for(HFRecHitCollection::const_iterator hbheItr=HithfMB.begin(); hbheItr!=HithfMB.end(); hbheItr++)
475  {
476  DetId id = (*hbheItr).detid();
477  HcalDetId hid=HcalDetId(id);
478 
479  if(hid.depth() == 1) {
480  if( hid.ieta() > 0 ) {
481  hiDistrMBPl2D_->Fill(hid.ieta(),hid.iphi(),hbheItr->energy());
482  hiDistrMB2Pl2D_->Fill(hid.ieta(),hid.iphi(),hbheItr->energy()*hbheItr->energy());
483  } else {
484  hiDistrMBMin2D_->Fill(fabs(hid.ieta()),hid.iphi(),hbheItr->energy());
485  hiDistrMB2Min2D_->Fill(fabs(hid.ieta()),hid.iphi(),hbheItr->energy()*hbheItr->energy());
486  }
487  }
488  }
489 
490 
491 } //analyze
492 
493 
494 
495 
496 //--------------------------------------------------------
498  const EventSetup& context) {
499 }
500 //--------------------------------------------------------
501 void DQMHcalPhiSymAlCaReco::endRun(const Run& r, const EventSetup& context){
502 // Keep Variances
503  if(eventCounter_ > 0) {
504  for(int k=0; k<=hiDistr_x_nbin_;k++)
505  {
506  for(int j=0; j<=hiDistr_y_nbin_;j++)
507  {
508 // First moment
509  float cc1=hiDistrMBPl2D_->getBinContent(k,j);
510  cc1 = cc1 * 1./eventCounter_;
511  float cc2=hiDistrNoisePl2D_->getBinContent(k,j);
512  cc2 = cc2 * 1./eventCounter_;
513  float cc3=hiDistrMBMin2D_->getBinContent(k,j);
514  cc3 = cc3 * 1./eventCounter_;
515  float cc4=hiDistrNoiseMin2D_->getBinContent(k,j);
516  cc4 = cc4 * 1./eventCounter_;
517 // Second moment
518  float cc11=hiDistrMB2Pl2D_->getBinContent(k,j);
519  cc11 = cc11 * 1./eventCounter_;
520  hiDistrVarMBPl2D_->setBinContent(k,j,cc11-cc1*cc1);
521  float cc22=hiDistrNoise2Pl2D_->getBinContent(k,j);
522  cc22 = cc22 * 1./eventCounter_;
523  hiDistrVarNoisePl2D_->setBinContent(k,j,cc22-cc2*cc2);
524  float cc33=hiDistrMB2Min2D_->getBinContent(k,j);
525  cc33 = cc33 * 1./eventCounter_;
526  hiDistrVarMBMin2D_->setBinContent(k,j,cc33-cc3*cc3);
527  float cc44=hiDistrNoise2Min2D_->getBinContent(k,j);
528  cc44 = cc44 * 1./eventCounter_;
529  hiDistrVarNoiseMin2D_->setBinContent(k,j,cc44-cc4*cc4);
530  }
531  }
532  }
533 }
534 //--------------------------------------------------------
536  if (saveToFile_) {
537 
538  for(int k=0; k<=hiDistr_x_nbin_;k++)
539  {
540  for(int j=0; j<=hiDistr_y_nbin_;j++)
541  {
542 // First moment
543  float cc1=hiDistrMBPl2D_->getBinContent(k,j);
544  cc1 = cc1 * 1./eventCounter_;
546  float cc2=hiDistrNoisePl2D_->getBinContent(k,j);
547  cc2 = cc2 * 1./eventCounter_;
549  float cc3=hiDistrMBMin2D_->getBinContent(k,j);
550  cc3 = cc3 * 1./eventCounter_;
552  float cc4=hiDistrNoiseMin2D_->getBinContent(k,j);
553  cc4 = cc4 * 1./eventCounter_;
555 // Second moment
556  float cc11=hiDistrMB2Pl2D_->getBinContent(k,j);
557  cc11 = cc11 * 1./eventCounter_;
559  hiDistrVarMBPl2D_->setBinContent(k,j,cc11-cc1*cc1);
560  float cc22=hiDistrNoise2Pl2D_->getBinContent(k,j);
561  cc22 = cc22 * 1./eventCounter_;
563  hiDistrVarNoisePl2D_->setBinContent(k,j,cc22-cc2*cc2);
564  float cc33=hiDistrMB2Min2D_->getBinContent(k,j);
565  cc33 = cc33 * 1./eventCounter_;
567  hiDistrVarMBMin2D_->setBinContent(k,j,cc33-cc3*cc3);
568  float cc44=hiDistrNoise2Min2D_->getBinContent(k,j);
569  cc44 = cc44 * 1./eventCounter_;
571  hiDistrVarNoiseMin2D_->setBinContent(k,j,cc44-cc4*cc4);
572  }
573  }
574  dbe_->save(fileName_);
575  }
576 }
577 
578 
#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_
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
DQMHcalPhiSymAlCaReco(const edm::ParameterSet &)
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:2113
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)
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:49
void Fill(long long x)
bool isUnsuppressed() const
Is this event an unsuppresed event?
Definition: HcalHTRData.cc:355
MonitorElement * hiDistrMBPl2D_
MonitorElement * hiDistrHFsize1D_
int depth() const
get the tower depth
Definition: HcalDetId.h:42
int iEvent
Definition: GenABIO.cc:243
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void beginRun(const edm::Run &r, const edm::EventSetup &c)
int ieta() const
get the cell ieta
Definition: HcalDetId.h:38
MonitorElement * hiDistrVarMBMin2D_
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
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
MonitorElement * hiDistrNoise2Min2D_
int k[5][pyjets_maxn]
void analyze(const edm::Event &e, const edm::EventSetup &c)
const_iterator end() const
edm::InputTag hbherecoMB
object to monitor
int iphi() const
get the cell iphi
Definition: HcalDetId.h:40
Definition: DetId.h:20
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &context)
MonitorElement * hiDistrMBMin2D_
T const * product() const
Definition: Handle.h:74
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:21
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:29
MonitorElement * hiDistrNoise2Pl2D_
MonitorElement * hiDistrNoiseMin2D_
std::string fileName_
Output file name if required.
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
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
const_iterator begin() const
Definition: Run.h:33
MonitorElement * hiDistrHBHEsize1D_
MonitorElement * hiDistrMB2Min2D_