CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDetDiagPedestalMonitor.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HcalDetDiagPedestalMonitor
4 // Class: HcalDetDiagPedestalMonitor
5 //
13 //
14 // Original Author: Dmitry Vishnevskiy,591 R-013,+41227674265,
15 // Created: Tue Mar 9 12:59:18 CET 2010
16 // $Id: HcalDetDiagPedestalMonitor.cc,v 1.15 2010/04/08 10:58:55 dma Exp $
17 //
18 //
19 // user include files
24 
28 
31 
32 #include <math.h>
33 // this is to retrieve HCAL digi's
35 // to retrive trigger information (local runs only)
37 
40 
44 
45 #include "TFile.h"
46 #include "TTree.h"
47 #include "TSystem.h"
48 
54 
55 #include <iostream>
56 #include <fstream>
57 
59 public:
61  reset();
62  IsReference=false;
63  status=0;
65  }
66  void reset(){
67  for(int i=0;i<128;i++) adc[i]=0;
68  overflow=0;
69  }
70  void add_statistics(unsigned int val){
71  if(val<25) adc[val&0x7F]++; else overflow++;
72  }
73  void set_reference(float val,float rms){
74  ref_ped=val; ref_rms=rms;
75  IsReference=true;
76  }
77  void change_status(int val){
78  status|=val;
79  }
80  int get_status(){
81  return status;
82  }
83  bool get_reference(double *val,double *rms){
84  *val=ref_ped; *rms=ref_rms;
85  return IsReference;
86  }
87  bool get_average(double *ave,double *rms){
88  double Sum=0,nSum=0;
89  int from,to,max=adc[0],maxi=0;
90  for(int i=1;i<25;i++) if(adc[i]>max){ max=adc[i]; maxi=i;}
91  from=0; to=maxi+6;
92  for(int i=from;i<=to;i++){
93  Sum+=i*adc[i];
94  nSum+=adc[i];
95  }
96  if(nSum>0) *ave=Sum/nSum; else return false;
97  Sum=0;
98  for(int i=from;i<=to;i++) Sum+=adc[i]*(i-*ave)*(i-*ave);
99  *rms=sqrt(Sum/nSum);
100  return true;
101  }
103  int nSum=0;
104  for(int i=0;i<25;i++) nSum+=adc[i];
105  return nSum;
106  }
108  return overflow;
109  }
110  float nChecks;
111  float nMissing;
112  float nUnstable;
113  float nBadPed;
114  float nBadRms;
115 private:
116  int adc[128];
117  int overflow;
119  float ref_ped;
120  float ref_rms;
121  int status;
122 };
123 
124 
126  public:
129 
130 
131  private:
132  void SaveReference();
133  void LoadReference();
134  void CheckStatus();
135  void fillHistos();
136 
140 
141  void beginRun(const edm::Run& run, const edm::EventSetup& c);
142  void endRun(const edm::Run& run, const edm::EventSetup& c);
143  void beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg,const edm::EventSetup& c) ;
144  void endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,const edm::EventSetup& c);
145  void analyze(const edm::Event&, const edm::EventSetup&);
146 
147  int ievt_;
151  bool LocalRun;
152 
161 
162  std::string ReferenceData;
163  std::string ReferenceRun;
164  std::string OutputFilePath;
165  std::string XmlFilePath;
166 
167  std::string prefixME_;
168  bool Online_;
169  bool Overwrite;
170 
178 
188 
193 
200 
205 
210  std::vector<std::string> problemnames_;
211 
216 };
217 
219  ievt_=-1;
220  emap=0;
222  run_number=-1;
223  IsReference=false;
224  LocalRun=false;
225 
226  inputLabelDigi_ = iConfig.getUntrackedParameter<edm::InputTag>("digiLabel");
227  inputLabelRawData_ = iConfig.getUntrackedParameter<edm::InputTag>("rawDataLabel");
228  ReferenceData = iConfig.getUntrackedParameter<std::string>("PedestalReferenceData" ,"");
229  OutputFilePath = iConfig.getUntrackedParameter<std::string>("OutputFilePath", "");
230  XmlFilePath = iConfig.getUntrackedParameter<std::string>("XmlFilePath", "");
231  Online_ = iConfig.getUntrackedParameter<bool> ("online",false);
232  Overwrite = iConfig.getUntrackedParameter<bool> ("Overwrite",true);
233 
234  prefixME_ = iConfig.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
235  if (prefixME_.size()>0 && prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
236  prefixME_.append("/");
237  subdir_ = iConfig.getUntrackedParameter<std::string>("TaskFolder","DetDiagPedestalMonitor_Hcal/");
238  if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
239  subdir_.append("/");
240  subdir_=prefixME_+subdir_;
241 
242  HBMeanTreshold = iConfig.getUntrackedParameter<double>("HBMeanPedestalTreshold" , 0.2);
243  HBRmsTreshold = iConfig.getUntrackedParameter<double>("HBRmsPedestalTreshold" , 0.3);
244  HEMeanTreshold = iConfig.getUntrackedParameter<double>("HEMeanPedestalTreshold" , 0.2);
245  HERmsTreshold = iConfig.getUntrackedParameter<double>("HERmsPedestalTreshold" , 0.3);
246  HOMeanTreshold = iConfig.getUntrackedParameter<double>("HOMeanPedestalTreshold" , 0.2);
247  HORmsTreshold = iConfig.getUntrackedParameter<double>("HORmsPedestalTreshold" , 0.3);
248  HFMeanTreshold = iConfig.getUntrackedParameter<double>("HFMeanPedestalTreshold" , 0.2);
249  HFRmsTreshold = iConfig.getUntrackedParameter<double>("HFRmsPedestalTreshold" , 0.3);
250 }
252 
254  edm::ESHandle<HcalDbService> conditions_;
255  c.get<HcalDbRecord>().get(conditions_);
256  emap=conditions_->getHcalMapping();
257 
259  if (!dbe_) return;
260  std::string name;
261 
263  meEVT_ = dbe_->bookInt("HcalDetDiagPedestalMonitor Event Number");
264  meRUN_ = dbe_->bookInt("HcalDetDiagPedestalMonitor Run Number");
265 
267  ProblemCellsByDepth_missing->setup(dbe_," Problem Missing Channels");
268  for(unsigned int i=0;i<ProblemCellsByDepth_missing->depth.size();i++)
269  problemnames_.push_back(ProblemCellsByDepth_missing->depth[i]->getName());
271  ProblemCellsByDepth_unstable->setup(dbe_," Problem Unstable Channels");
272  for(unsigned int i=0;i<ProblemCellsByDepth_unstable->depth.size();i++)
273  problemnames_.push_back(ProblemCellsByDepth_unstable->depth[i]->getName());
275  ProblemCellsByDepth_badped->setup(dbe_," Problem Bad Pedestal Value");
276  for(unsigned int i=0;i<ProblemCellsByDepth_badped->depth.size();i++)
277  problemnames_.push_back(ProblemCellsByDepth_badped->depth[i]->getName());
279  ProblemCellsByDepth_badrms->setup(dbe_," Problem Bad Rms Value");
280  for(unsigned int i=0;i<ProblemCellsByDepth_badrms->depth.size();i++)
281  problemnames_.push_back(ProblemCellsByDepth_badrms->depth[i]->getName());
282 
283  dbe_->setCurrentFolder(subdir_+"Summary Plots");
284  name="HB Pedestal Distribution (average over 4 caps)"; PedestalsAve4HB = dbe_->book1D(name,name,200,0,6);
285  name="HE Pedestal Distribution (average over 4 caps)"; PedestalsAve4HE = dbe_->book1D(name,name,200,0,6);
286  name="HO Pedestal Distribution (average over 4 caps)"; PedestalsAve4HO = dbe_->book1D(name,name,200,0,6);
287  name="HF Pedestal Distribution (average over 4 caps)"; PedestalsAve4HF = dbe_->book1D(name,name,200,0,6);
288  name="SIPM Pedestal Distribution (average over 4 caps)"; PedestalsAve4Simp = dbe_->book1D(name,name,200,5,15);
289 
290  name="HB Pedestal-Reference Distribution (average over 4 caps)"; PedestalsAve4HBref= dbe_->book1D(name,name,1500,-3,3);
291  name="HE Pedestal-Reference Distribution (average over 4 caps)"; PedestalsAve4HEref= dbe_->book1D(name,name,1500,-3,3);
292  name="HO Pedestal-Reference Distribution (average over 4 caps)"; PedestalsAve4HOref= dbe_->book1D(name,name,1500,-3,3);
293  name="HF Pedestal-Reference Distribution (average over 4 caps)"; PedestalsAve4HFref= dbe_->book1D(name,name,1500,-3,3);
294 
295  name="HB Pedestal RMS Distribution (individual cap)"; PedestalsRmsHB = dbe_->book1D(name,name,200,0,2);
296  name="HE Pedestal RMS Distribution (individual cap)"; PedestalsRmsHE = dbe_->book1D(name,name,200,0,2);
297  name="HO Pedestal RMS Distribution (individual cap)"; PedestalsRmsHO = dbe_->book1D(name,name,200,0,2);
298  name="HF Pedestal RMS Distribution (individual cap)"; PedestalsRmsHF = dbe_->book1D(name,name,200,0,2);
299  name="SIPM Pedestal RMS Distribution (individual cap)"; PedestalsRmsSimp = dbe_->book1D(name,name,200,0,4);
300 
301  name="HB Pedestal_rms-Reference_rms Distribution"; PedestalsRmsHBref = dbe_->book1D(name,name,1500,-3,3);
302  name="HE Pedestal_rms-Reference_rms Distribution"; PedestalsRmsHEref = dbe_->book1D(name,name,1500,-3,3);
303  name="HO Pedestal_rms-Reference_rms Distribution"; PedestalsRmsHOref = dbe_->book1D(name,name,1500,-3,3);
304  name="HF Pedestal_rms-Reference_rms Distribution"; PedestalsRmsHFref = dbe_->book1D(name,name,1500,-3,3);
305 
306  name="HBHEHF pedestal mean map"; Pedestals2DHBHEHF = dbe_->book2D(name,name,87,-43,43,74,0,73);
307  name="HO pedestal mean map"; Pedestals2DHO = dbe_->book2D(name,name,33,-16,16,74,0,73);
308  name="HBHEHF pedestal rms map"; Pedestals2DRmsHBHEHF = dbe_->book2D(name,name,87,-43,43,74,0,73);
309  name="HO pedestal rms map"; Pedestals2DRmsHO = dbe_->book2D(name,name,33,-16,16,74,0,73);
310  name="HBHEHF pedestal problems map"; Pedestals2DErrorHBHEHF = dbe_->book2D(name,name,87,-43,43,74,0,73);
311  name="HO pedestal problems map"; Pedestals2DErrorHO = dbe_->book2D(name,name,33,-16,16,74,0,73);
312 
314  Pedestals2DHO->setAxisRange(1,5,3);
317 
318  Pedestals2DHBHEHF->setAxisTitle("i#eta",1);
319  Pedestals2DHBHEHF->setAxisTitle("i#phi",2);
320  Pedestals2DHO->setAxisTitle("i#eta",1);
321  Pedestals2DHO->setAxisTitle("i#phi",2);
324  Pedestals2DRmsHO->setAxisTitle("i#eta",1);
325  Pedestals2DRmsHO->setAxisTitle("i#phi",2);
328  Pedestals2DErrorHO->setAxisTitle("i#eta",1);
329  Pedestals2DErrorHO->setAxisTitle("i#phi",2);
330  PedestalsAve4HB->setAxisTitle("ADC counts",1);
331  PedestalsAve4HE->setAxisTitle("ADC counts",1);
332  PedestalsAve4HO->setAxisTitle("ADC counts",1);
333  PedestalsAve4HF->setAxisTitle("ADC counts",1);
334  PedestalsAve4Simp->setAxisTitle("ADC counts",1);
335  PedestalsAve4HBref->setAxisTitle("ADC counts",1);
336  PedestalsAve4HEref->setAxisTitle("ADC counts",1);
337  PedestalsAve4HOref->setAxisTitle("ADC counts",1);
338  PedestalsAve4HFref->setAxisTitle("ADC counts",1);
339  PedestalsRmsHB->setAxisTitle("ADC counts",1);
340  PedestalsRmsHE->setAxisTitle("ADC counts",1);
341  PedestalsRmsHO->setAxisTitle("ADC counts",1);
342  PedestalsRmsHF->setAxisTitle("ADC counts",1);
343  PedestalsRmsSimp->setAxisTitle("ADC counts",1);
344  PedestalsRmsHBref->setAxisTitle("ADC counts",1);
345  PedestalsRmsHEref->setAxisTitle("ADC counts",1);
346  PedestalsRmsHOref->setAxisTitle("ADC counts",1);
347  PedestalsRmsHFref->setAxisTitle("ADC counts",1);
348 
349  ReferenceRun="UNKNOWN";
350  LoadReference();
352  RefRun_= dbe_->bookString("HcalDetDiagLaserMonitor Reference Run",ReferenceRun);
353 
354  dbe_->setCurrentFolder(subdir_+"Plots for client");
356  ProblemCellsByDepth_missing_val->setup(dbe_," Missing channels");
358  ProblemCellsByDepth_unstable_val->setup(dbe_," Channel instability value");
360  ProblemCellsByDepth_badped_val->setup(dbe_," Bad Pedestal-Ref Value");
362  ProblemCellsByDepth_badrms_val->setup(dbe_," Bad Rms-ref Value");
363 }
364 
365 
366 
368  HcalBaseDQMonitor::analyze(iEvent, iSetup); // increments counters
369 int eta,phi,depth,nTS;
370 static bool PEDseq;
371 static int lastPEDorbit,nChecksPED;
372  if(ievt_==-1){ ievt_=0; PEDseq=false; lastPEDorbit=-1;nChecksPED=0; }
373  int orbit=iEvent.orbitNumber();
374  meRUN_->Fill(iEvent.id().run());
375 
376  bool PedestalEvent=false;
377 
378  // for local runs
379  edm::Handle<HcalTBTriggerData> trigger_data;
380  iEvent.getByType(trigger_data);
381  if(trigger_data.isValid()){
382  if(trigger_data->triggerWord()==5) PedestalEvent=true;
383  LocalRun=true;
384  }
385  if(LocalRun && !PedestalEvent) return;
386 
387 
388  if(!LocalRun && Online_){
389  if(PEDseq && (orbit-lastPEDorbit)>(11223*10) && ievt_>500){
390  PEDseq=false;
391  fillHistos();
392  CheckStatus();
393  nChecksPED++;
394  if(nChecksPED==1 || (nChecksPED>1 && ((nChecksPED-1)%12)==0)){
395  SaveReference();
396  }
397  for(int i=0;i<85;i++)for(int j=0;j<72;j++)for(int k=0;k<4;k++)for(int l=0;l<4;l++) hb_data[i][j][k][l].reset();
398  for(int i=0;i<85;i++)for(int j=0;j<72;j++)for(int k=0;k<4;k++)for(int l=0;l<4;l++) he_data[i][j][k][l].reset();
399  for(int i=0;i<85;i++)for(int j=0;j<72;j++)for(int k=0;k<4;k++)for(int l=0;l<4;l++) ho_data[i][j][k][l].reset();
400  for(int i=0;i<85;i++)for(int j=0;j<72;j++)for(int k=0;k<4;k++)for(int l=0;l<4;l++) hf_data[i][j][k][l].reset();
401  ievt_=0;
402  }
403  }
404 
405 
406  // Abort Gap pedestals
407  int calibType = -1 ;
408  if(LocalRun==false){
410  iEvent.getByLabel(inputLabelRawData_,rawdata);
411  //checking FEDs for calibration information
413  const FEDRawData& fedData = rawdata->FEDData(i) ;
414  if ( fedData.size() < 24 ) continue ;
415  int value = ((const HcalDCCHeader*)(fedData.data()))->getCalibType() ;
416  if ( calibType < 0 ) calibType = value ;
417  if(value==hc_Pedestal){ PEDseq=true; lastPEDorbit=orbit; break;}
418  }
419  }
420  if(!LocalRun && calibType!=hc_Pedestal) return;
421 
422  ievt_++;
423  meEVT_->Fill(ievt_);
424  run_number=iEvent.id().run();
425 
427  iEvent.getByLabel(inputLabelDigi_,hbhe);
428  if(hbhe.isValid()){
429  if(hbhe->size()<30 && calibType==hc_Pedestal){
430  ievt_--;
431  meEVT_->Fill(ievt_);
432  return;
433  }
434  for(HBHEDigiCollection::const_iterator digi=hbhe->begin();digi!=hbhe->end();digi++){
435  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
436  if(nTS>8) nTS=8;
437  if(nTS<8) continue;
438  if(digi->id().subdet()==HcalBarrel){
439  for(int i=0;i<nTS;i++) hb_data[eta+42][phi-1][depth-1][digi->sample(i).capid()].add_statistics(digi->sample(i).adc());
440  }
441  if(digi->id().subdet()==HcalEndcap){
442  for(int i=0;i<nTS;i++) he_data[eta+42][phi-1][depth-1][digi->sample(i).capid()].add_statistics(digi->sample(i).adc());
443  }
444  }
445  }
447  iEvent.getByLabel(inputLabelDigi_,ho);
448  if(ho.isValid()){
449  for(HODigiCollection::const_iterator digi=ho->begin();digi!=ho->end();digi++){
450  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
451  if(nTS>8) nTS=8;
452  if(nTS<8) continue;
453  for(int i=0;i<nTS;i++) ho_data[eta+42][phi-1][depth-1][digi->sample(i).capid()].add_statistics(digi->sample(i).adc());
454  }
455  }
457  iEvent.getByLabel(inputLabelDigi_,hf);
458  if(hf.isValid()){
459  for(HFDigiCollection::const_iterator digi=hf->begin();digi!=hf->end();digi++){
460  eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
461  if(nTS>8) nTS=8;
462  if(nTS<8) continue;
463  for(int i=0;i<nTS;i++) hf_data[eta+42][phi-1][depth-1][digi->sample(i).capid()].add_statistics(digi->sample(i).adc());
464  }
465  }
466 }
467 
482  Pedestals2DHO->Reset();
483  // HBHEHF summary map
484  for(int eta=-42;eta<=42;eta++) for(int phi=1;phi<=72;phi++){
485  double PED=0,RMS=0,nped=0,nrms=0,ave=0,rms=0;
486  for(int depth=1;depth<=3;depth++){
487  if(hb_data[eta+42][phi-1][depth-1][0].get_statistics()>100){
488  hb_data[eta+42][phi-1][depth-1][0].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
489  hb_data[eta+42][phi-1][depth-1][1].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
490  hb_data[eta+42][phi-1][depth-1][2].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
491  hb_data[eta+42][phi-1][depth-1][3].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
492  }
493  if(he_data[eta+42][phi-1][depth-1][0].get_statistics()>100){
494  he_data[eta+42][phi-1][depth-1][0].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
495  he_data[eta+42][phi-1][depth-1][1].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
496  he_data[eta+42][phi-1][depth-1][2].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
497  he_data[eta+42][phi-1][depth-1][3].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
498  }
499  if(hf_data[eta+42][phi-1][depth-1][0].get_statistics()>100){
500  hf_data[eta+42][phi-1][depth-1][0].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
501  hf_data[eta+42][phi-1][depth-1][1].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
502  hf_data[eta+42][phi-1][depth-1][2].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
503  hf_data[eta+42][phi-1][depth-1][3].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
504  }
505  }
506  if(nped>0) Pedestals2DHBHEHF->Fill(eta,phi,PED/nped);
507  if(nrms>0) Pedestals2DRmsHBHEHF->Fill(eta,phi,RMS/nrms);
508  if(nped>0 && abs(eta)>20) Pedestals2DHBHEHF->Fill(eta,phi+1,PED/nped);
509  if(nrms>0 && abs(eta)>20) Pedestals2DRmsHBHEHF->Fill(eta,phi+1,RMS/nrms);
510  }
511  // HO summary map
512  for(int eta=-42;eta<=42;eta++) for(int phi=1;phi<=72;phi++){
513  double PED=0,RMS=0,nped=0,nrms=0,ave,rms;
514  if(ho_data[eta+42][phi-1][4-1][0].get_statistics()>100){
515  ho_data[eta+42][phi-1][4-1][0].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
516  ho_data[eta+42][phi-1][4-1][1].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
517  ho_data[eta+42][phi-1][4-1][2].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
518  ho_data[eta+42][phi-1][4-1][3].get_average(&ave,&rms); PED+=ave; nped++; RMS+=rms; nrms++;
519  }
520  if(nped>0) Pedestals2DHO->Fill(eta,phi,PED/nped);
521  if(nrms>0) Pedestals2DRmsHO->Fill(eta,phi,RMS/nrms);
522  }
523  // HB histograms
524  for(int eta=-16;eta<=16;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=2;depth++){
525  if(hb_data[eta+42][phi-1][depth-1][0].get_statistics()>100){
526  double ave,rms,sum=0;
527  hb_data[eta+42][phi-1][depth-1][0].get_average(&ave,&rms); sum+=ave; PedestalsRmsHB->Fill(rms);
528  hb_data[eta+42][phi-1][depth-1][1].get_average(&ave,&rms); sum+=ave; PedestalsRmsHB->Fill(rms);
529  hb_data[eta+42][phi-1][depth-1][2].get_average(&ave,&rms); sum+=ave; PedestalsRmsHB->Fill(rms);
530  hb_data[eta+42][phi-1][depth-1][3].get_average(&ave,&rms); sum+=ave; PedestalsRmsHB->Fill(rms);
531  PedestalsAve4HB->Fill(sum/4.0);
532  }
533  }
534  // HE histograms
535  for(int eta=-29;eta<=29;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=3;depth++){
536  if(he_data[eta+42][phi-1][depth-1][0].get_statistics()>100){
537  double ave=0,rms=0,sum=0;
538  he_data[eta+42][phi-1][depth-1][0].get_average(&ave,&rms); sum+=ave; PedestalsRmsHE->Fill(rms);
539  he_data[eta+42][phi-1][depth-1][1].get_average(&ave,&rms); sum+=ave; PedestalsRmsHE->Fill(rms);
540  he_data[eta+42][phi-1][depth-1][2].get_average(&ave,&rms); sum+=ave; PedestalsRmsHE->Fill(rms);
541  he_data[eta+42][phi-1][depth-1][3].get_average(&ave,&rms); sum+=ave; PedestalsRmsHE->Fill(rms);
542  PedestalsAve4HE->Fill(sum/4.0);
543  }
544  }
545  // HO histograms
546  for(int eta=-15;eta<=15;eta++) for(int phi=1;phi<=72;phi++) for(int depth=4;depth<=4;depth++){
547  if(ho_data[eta+42][phi-1][depth-1][0].get_statistics()>100){
548  double ave,rms,sum=0;
549  if((eta>=11 && eta<=15 && phi>=59 && phi<=70) || (eta>=5 && eta<=10 && phi>=47 && phi<=58)){
550  ho_data[eta+42][phi-1][depth-1][0].get_average(&ave,&rms); sum+=ave; PedestalsRmsSimp->Fill(rms);
551  ho_data[eta+42][phi-1][depth-1][1].get_average(&ave,&rms); sum+=ave; PedestalsRmsSimp->Fill(rms);
552  ho_data[eta+42][phi-1][depth-1][2].get_average(&ave,&rms); sum+=ave; PedestalsRmsSimp->Fill(rms);
553  ho_data[eta+42][phi-1][depth-1][3].get_average(&ave,&rms); sum+=ave; PedestalsRmsSimp->Fill(rms);
554  PedestalsAve4Simp->Fill(sum/4.0);
555  }else{
556  ho_data[eta+42][phi-1][depth-1][0].get_average(&ave,&rms); sum+=ave; PedestalsRmsHO->Fill(rms);
557  ho_data[eta+42][phi-1][depth-1][1].get_average(&ave,&rms); sum+=ave; PedestalsRmsHO->Fill(rms);
558  ho_data[eta+42][phi-1][depth-1][2].get_average(&ave,&rms); sum+=ave; PedestalsRmsHO->Fill(rms);
559  ho_data[eta+42][phi-1][depth-1][3].get_average(&ave,&rms); sum+=ave; PedestalsRmsHO->Fill(rms);
560  PedestalsAve4HO->Fill(sum/4.0);
561  }
562  }
563  }
564  // HF histograms
565  for(int eta=-42;eta<=42;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=2;depth++){
566  if(hf_data[eta+42][phi-1][depth-1][0].get_statistics()>100){
567  double ave,rms,sum=0;
568  hf_data[eta+42][phi-1][depth-1][0].get_average(&ave,&rms); sum+=ave; PedestalsRmsHF->Fill(rms);
569  hf_data[eta+42][phi-1][depth-1][1].get_average(&ave,&rms); sum+=ave; PedestalsRmsHF->Fill(rms);
570  hf_data[eta+42][phi-1][depth-1][2].get_average(&ave,&rms); sum+=ave; PedestalsRmsHF->Fill(rms);
571  hf_data[eta+42][phi-1][depth-1][3].get_average(&ave,&rms); sum+=ave; PedestalsRmsHF->Fill(rms);
572  PedestalsAve4HF->Fill(sum/4.0);
573  }
574  }
575 }
577  for(int i=0;i<4;i++){
582  }
591 
594 
595  if(emap==0) return;
596 
597  std::vector <HcalElectronicsId> AllElIds = emap->allElectronicsIdPrecision();
598  for (std::vector <HcalElectronicsId>::iterator eid = AllElIds.begin(); eid != AllElIds.end(); eid++) {
599  DetId detid=emap->lookup(*eid);
600  if (detid.det()!=DetId::Hcal) continue;
601  HcalGenericDetId gid(emap->lookup(*eid));
602  if (gid.null())
603  continue;
604  if (gid.genericSubdet()!=HcalGenericDetId::HcalGenBarrel &&
605  gid.genericSubdet()!=HcalGenericDetId::HcalGenEndcap &&
606  gid.genericSubdet()!=HcalGenericDetId::HcalGenForward &&
607  gid.genericSubdet()!=HcalGenericDetId::HcalGenOuter)
608  continue;
609 
610  int eta=0,phi=0,depth=0;
611 
612  HcalDetId hid(detid);
613  eta=hid.ieta();
614  phi=hid.iphi();
615  depth=hid.depth();
616 
617  int sd=detid.subdetId();
618  if(sd==HcalBarrel){
619  int ovf=hb_data[eta+42][phi-1][depth-1][0].get_overflow();
620  int stat=hb_data[eta+42][phi-1][depth-1][0].get_statistics()+ovf;
621  double status=0;
622  double ped[4],rms[4],ped_ref[4],rms_ref[4];
623  hb_data[eta+42][phi-1][depth-1][0].nChecks++;
624  if(stat==0){
625  status=1;
626  int e=CalcEtaBin(sd,eta,depth)+1;
627  hb_data[eta+42][phi-1][depth-1][0].nMissing++;
628  double val=hb_data[eta+42][phi-1][depth-1][0].nMissing/hb_data[eta+42][phi-1][depth-1][0].nChecks;
629  ProblemCellsByDepth_missing->depth[depth-1]->setBinContent(e,phi,val);
630  ProblemCellsByDepth_missing_val->depth[depth-1]->setBinContent(e,phi,1);
631  }
632  if(status) hb_data[eta+42][phi-1][depth-1][0].change_status(1);
633  if(stat>0 && stat!=(ievt_*2)){ status=(double)stat/(double)(ievt_*2);
634  if(status<0.995){
635  int e=CalcEtaBin(sd,eta,depth)+1;
636  hb_data[eta+42][phi-1][depth-1][0].nUnstable++;
637  double val=hb_data[eta+42][phi-1][depth-1][0].nUnstable/hb_data[eta+42][phi-1][depth-1][0].nChecks;
638  ProblemCellsByDepth_unstable->depth[depth-1]->setBinContent(e,phi,val);
639  ProblemCellsByDepth_unstable_val->depth[depth-1]->setBinContent(e,phi,status);
640  hb_data[eta+42][phi-1][depth-1][0].change_status(2);
641  }
642  }
643  if(hb_data[eta+42][phi-1][depth-1][0].get_reference(&ped_ref[0],&rms_ref[0])
644  && hb_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0])){
645  hb_data[eta+42][phi-1][depth-1][1].get_reference(&ped_ref[1],&rms_ref[1]);
646  hb_data[eta+42][phi-1][depth-1][2].get_reference(&ped_ref[2],&rms_ref[2]);
647  hb_data[eta+42][phi-1][depth-1][3].get_reference(&ped_ref[3],&rms_ref[3]);
648  hb_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
649  hb_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
650  hb_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
651  double ave=(ped[0]+ped[1]+ped[2]+ped[3])/4.0;
652  double ave_ref=(ped_ref[0]+ped_ref[1]+ped_ref[2]+ped_ref[3])/4.0;
653  double deltaPed=ave-ave_ref; PedestalsAve4HBref->Fill(deltaPed); if(deltaPed<0) deltaPed=-deltaPed;
654  double deltaRms=rms[0]-rms_ref[0]; PedestalsRmsHBref->Fill(deltaRms); if(deltaRms<0) deltaRms=-deltaRms;
655  for(int i=1;i<4;i++){
656  double tmp=rms[i]-rms_ref[i]; PedestalsRmsHBref->Fill(tmp);
657  if(fabs(tmp)>fabs(deltaRms)) deltaRms=tmp;
658  }
659  if(deltaPed>HBMeanTreshold){
660  int e=CalcEtaBin(sd,eta,depth)+1;
661  hb_data[eta+42][phi-1][depth-1][0].nBadPed++;
662  double val=hb_data[eta+42][phi-1][depth-1][0].nBadPed/hb_data[eta+42][phi-1][depth-1][0].nChecks;
663  ProblemCellsByDepth_badped_val->depth[depth-1]->setBinContent(e,phi,ave-ave_ref);
664  ProblemCellsByDepth_badped->depth[depth-1]->setBinContent(e,phi,val);
666  }
667  if(deltaRms>HBRmsTreshold){
668  int e=CalcEtaBin(sd,eta,depth)+1;
669  hb_data[eta+42][phi-1][depth-1][0].nBadRms++;
670  double val=hb_data[eta+42][phi-1][depth-1][0].nBadRms/hb_data[eta+42][phi-1][depth-1][0].nChecks;
671  ProblemCellsByDepth_badrms->depth[depth-1]->setBinContent(e,phi,val);
672  ProblemCellsByDepth_badrms_val->depth[depth-1]->setBinContent(e,phi,deltaRms);
674  }
675  }
676  }
677  if(sd==HcalEndcap){
678  int ovf=he_data[eta+42][phi-1][depth-1][0].get_overflow();
679  int stat=he_data[eta+42][phi-1][depth-1][0].get_statistics()+ovf;
680  double status=0;
681  double ped[4],rms[4],ped_ref[4],rms_ref[4];
682  he_data[eta+42][phi-1][depth-1][0].nChecks++;
683  if(stat==0){
684  status=1;
685  int e=CalcEtaBin(sd,eta,depth)+1;
686  he_data[eta+42][phi-1][depth-1][0].nMissing++;
687  double val=he_data[eta+42][phi-1][depth-1][0].nMissing/he_data[eta+42][phi-1][depth-1][0].nChecks;
688  ProblemCellsByDepth_missing->depth[depth-1]->setBinContent(e,phi,val);
689  ProblemCellsByDepth_missing_val->depth[depth-1]->setBinContent(e,phi,1);
690  }
691  if(status) he_data[eta+42][phi-1][depth-1][0].change_status(1);
692  if(stat>0 && stat!=(ievt_*2)){ status=(double)stat/(double)(ievt_*2);
693  if(status<0.995){
694  int e=CalcEtaBin(sd,eta,depth)+1;
695  he_data[eta+42][phi-1][depth-1][0].nUnstable++;
696  double val=he_data[eta+42][phi-1][depth-1][0].nUnstable/he_data[eta+42][phi-1][depth-1][0].nChecks;
697  ProblemCellsByDepth_unstable->depth[depth-1]->setBinContent(e,phi,val);
698  ProblemCellsByDepth_unstable_val->depth[depth-1]->setBinContent(e,phi,status);
699  he_data[eta+42][phi-1][depth-1][0].change_status(2);
700  }
701  }
702  if(he_data[eta+42][phi-1][depth-1][0].get_reference(&ped_ref[0],&rms_ref[0])
703  && he_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0])){
704  he_data[eta+42][phi-1][depth-1][1].get_reference(&ped_ref[1],&rms_ref[1]);
705  he_data[eta+42][phi-1][depth-1][2].get_reference(&ped_ref[2],&rms_ref[2]);
706  he_data[eta+42][phi-1][depth-1][3].get_reference(&ped_ref[3],&rms_ref[3]);
707  he_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
708  he_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
709  he_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
710  double ave=(ped[0]+ped[1]+ped[2]+ped[3])/4.0;
711  double ave_ref=(ped_ref[0]+ped_ref[1]+ped_ref[2]+ped_ref[3])/4.0;
712  double deltaPed=ave-ave_ref; PedestalsAve4HEref->Fill(deltaPed); if(deltaPed<0) deltaPed=-deltaPed;
713  double deltaRms=rms[0]-rms_ref[0]; PedestalsRmsHEref->Fill(deltaRms); if(deltaRms<0) deltaRms=-deltaRms;
714  for(int i=1;i<4;i++){
715  double tmp=rms[i]-rms_ref[i]; PedestalsRmsHEref->Fill(tmp);
716  if(fabs(tmp)>fabs(deltaRms)) deltaRms=tmp;
717  }
718  if(deltaPed>HEMeanTreshold){
719  int e=CalcEtaBin(sd,eta,depth)+1;
720  he_data[eta+42][phi-1][depth-1][0].nBadPed++;
721  double val=he_data[eta+42][phi-1][depth-1][0].nBadPed/he_data[eta+42][phi-1][depth-1][0].nChecks;
722  ProblemCellsByDepth_badped->depth[depth-1]->setBinContent(e,phi,val);
723  ProblemCellsByDepth_badped_val->depth[depth-1]->setBinContent(e,phi,ave-ave_ref);
725  }
726  if(deltaRms>HERmsTreshold){
727  int e=CalcEtaBin(sd,eta,depth)+1;
728  he_data[eta+42][phi-1][depth-1][0].nBadRms++;
729  double val=he_data[eta+42][phi-1][depth-1][0].nBadRms/he_data[eta+42][phi-1][depth-1][0].nChecks;
730  ProblemCellsByDepth_badrms->depth[depth-1]->setBinContent(e,phi,val);
731  ProblemCellsByDepth_badrms_val->depth[depth-1]->setBinContent(e,phi,deltaRms);
733  }
734  }
735  }
736  if(sd==HcalOuter){
737  int ovf=ho_data[eta+42][phi-1][depth-1][0].get_overflow();
738  int stat=ho_data[eta+42][phi-1][depth-1][0].get_statistics()+ovf;
739  double status=0;
740  double ped[4],rms[4],ped_ref[4],rms_ref[4];
741  ho_data[eta+42][phi-1][depth-1][0].nChecks++;
742  if(stat==0){
743  status=1;
744  int e=CalcEtaBin(sd,eta,depth)+1;
745  ho_data[eta+42][phi-1][depth-1][0].nMissing++;
746  double val=ho_data[eta+42][phi-1][depth-1][0].nMissing/ho_data[eta+42][phi-1][depth-1][0].nChecks;
747  ProblemCellsByDepth_missing->depth[depth-1]->setBinContent(e,phi,val);
748  ProblemCellsByDepth_missing_val->depth[depth-1]->setBinContent(e,phi,1);
749  }
750  if(status) ho_data[eta+42][phi-1][depth-1][0].change_status(1);
751  if(stat>0 && stat!=(ievt_*2)){ status=(double)stat/(double)(ievt_*2);
752  if(status<0.995){
753  int e=CalcEtaBin(sd,eta,depth)+1;
754  ho_data[eta+42][phi-1][depth-1][0].nUnstable++;
755  double val=ho_data[eta+42][phi-1][depth-1][0].nUnstable/ho_data[eta+42][phi-1][depth-1][0].nChecks;
756  ProblemCellsByDepth_unstable->depth[depth-1]->setBinContent(e,phi,val);
757  ProblemCellsByDepth_unstable_val->depth[depth-1]->setBinContent(e,phi,status);
758  ho_data[eta+42][phi-1][depth-1][0].change_status(2);
759  }
760  }
761  if(ho_data[eta+42][phi-1][depth-1][0].get_reference(&ped_ref[0],&rms_ref[0])
762  && ho_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0])){
763  ho_data[eta+42][phi-1][depth-1][1].get_reference(&ped_ref[1],&rms_ref[1]);
764  ho_data[eta+42][phi-1][depth-1][2].get_reference(&ped_ref[2],&rms_ref[2]);
765  ho_data[eta+42][phi-1][depth-1][3].get_reference(&ped_ref[3],&rms_ref[3]);
766  ho_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
767  ho_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
768  ho_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
769 
770  double THRESTHOLD=HORmsTreshold;
771  if((eta>=11 && eta<=15 && phi>=59 && phi<=70) || (eta>=5 && eta<=10 && phi>=47 && phi<=58))THRESTHOLD*=2;
772  double ave=(ped[0]+ped[1]+ped[2]+ped[3])/4.0;
773  double ave_ref=(ped_ref[0]+ped_ref[1]+ped_ref[2]+ped_ref[3])/4.0;
774  double deltaPed=ave-ave_ref; PedestalsAve4HOref->Fill(deltaPed);if(deltaPed<0) deltaPed=-deltaPed;
775  double deltaRms=rms[0]-rms_ref[0]; PedestalsRmsHOref->Fill(deltaRms); if(deltaRms<0) deltaRms=-deltaRms;
776  for(int i=1;i<4;i++){
777  double tmp=rms[i]-rms_ref[i]; PedestalsRmsHOref->Fill(tmp);
778  if(fabs(tmp)>fabs(deltaRms)) deltaRms=tmp;
779  }
780  if(deltaPed>HOMeanTreshold){
781  int e=CalcEtaBin(sd,eta,depth)+1;
782  ho_data[eta+42][phi-1][depth-1][0].nBadPed++;
783  double val=ho_data[eta+42][phi-1][depth-1][0].nBadPed/ho_data[eta+42][phi-1][depth-1][0].nChecks;
784  ProblemCellsByDepth_badped->depth[depth-1]->setBinContent(e,phi,val);
785  ProblemCellsByDepth_badped_val->depth[depth-1]->setBinContent(e,phi,ave-ave_ref);
786  Pedestals2DErrorHO->Fill(eta,phi,1);
787  }
788  if(deltaRms>THRESTHOLD){
789  int e=CalcEtaBin(sd,eta,depth)+1;
790  ho_data[eta+42][phi-1][depth-1][0].nBadRms++;
791  double val=ho_data[eta+42][phi-1][depth-1][0].nBadRms/ho_data[eta+42][phi-1][depth-1][0].nChecks;
792  ProblemCellsByDepth_badrms->depth[depth-1]->setBinContent(e,phi,val);
793  ProblemCellsByDepth_badrms_val->depth[depth-1]->setBinContent(e,phi,deltaRms);
794  Pedestals2DErrorHO->Fill(eta,phi,1);
795  }
796  }
797  }
798  if(sd==HcalForward){
799  int ovf=hf_data[eta+42][phi-1][depth-1][0].get_overflow();
800  int stat=hf_data[eta+42][phi-1][depth-1][0].get_statistics()+ovf;
801  double status=0;
802  double ped[4],rms[4],ped_ref[4],rms_ref[4];
803  hf_data[eta+42][phi-1][depth-1][0].nChecks++;
804  if(stat==0){
805  status=1;
806  int e=CalcEtaBin(sd,eta,depth)+1;
807  hf_data[eta+42][phi-1][depth-1][0].nMissing++;
808  double val=hf_data[eta+42][phi-1][depth-1][0].nMissing/hf_data[eta+42][phi-1][depth-1][0].nChecks;
809  ProblemCellsByDepth_missing->depth[depth-1]->setBinContent(e,phi,val);
810  ProblemCellsByDepth_missing_val->depth[depth-1]->setBinContent(e,phi,1);
811  }
812  if(status) hf_data[eta+42][phi-1][depth-1][0].change_status(1);
813  if(stat>0 && stat!=(ievt_*2)){ status=(double)stat/(double)(ievt_*2);
814  if(status<0.995){
815  int e=CalcEtaBin(sd,eta,depth)+1;
816  hf_data[eta+42][phi-1][depth-1][0].nUnstable++;
817  double val=hf_data[eta+42][phi-1][depth-1][0].nUnstable/hf_data[eta+42][phi-1][depth-1][0].nChecks;
818  ProblemCellsByDepth_unstable->depth[depth-1]->setBinContent(e,phi,val);
819  ProblemCellsByDepth_unstable_val->depth[depth-1]->setBinContent(e,phi,status);
820  hf_data[eta+42][phi-1][depth-1][0].change_status(2);
821  }
822  }
823  if(hf_data[eta+42][phi-1][depth-1][0].get_reference(&ped_ref[0],&rms_ref[0])
824  && hf_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0])){
825  hf_data[eta+42][phi-1][depth-1][1].get_reference(&ped_ref[1],&rms_ref[1]);
826  hf_data[eta+42][phi-1][depth-1][2].get_reference(&ped_ref[2],&rms_ref[2]);
827  hf_data[eta+42][phi-1][depth-1][3].get_reference(&ped_ref[3],&rms_ref[3]);
828  hf_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
829  hf_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
830  hf_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
831  double ave=(ped[0]+ped[1]+ped[2]+ped[3])/4.0;
832  double ave_ref=(ped_ref[0]+ped_ref[1]+ped_ref[2]+ped_ref[3])/4.0;
833  double deltaPed=ave-ave_ref; PedestalsAve4HFref->Fill(deltaPed); if(deltaPed<0) deltaPed=-deltaPed;
834  double deltaRms=rms[0]-rms_ref[0]; PedestalsRmsHFref->Fill(deltaRms); if(deltaRms<0) deltaRms=-deltaRms;
835  for(int i=1;i<4;i++){
836  double tmp=rms[i]-rms_ref[i]; PedestalsRmsHFref->Fill(tmp);
837  if(fabs(tmp)>fabs(deltaRms)) deltaRms=tmp;
838  }
839  if(deltaPed>HFMeanTreshold){
840  int e=CalcEtaBin(sd,eta,depth)+1;
841  hf_data[eta+42][phi-1][depth-1][0].nBadPed++;
842  double val=hf_data[eta+42][phi-1][depth-1][0].nBadPed/hf_data[eta+42][phi-1][depth-1][0].nChecks;
843  ProblemCellsByDepth_badped->depth[depth-1]->setBinContent(e,phi,val);
844  ProblemCellsByDepth_badped_val->depth[depth-1]->setBinContent(e,phi,ave-ave_ref);
846  }
847  if(deltaRms>HFRmsTreshold){
848  int e=CalcEtaBin(sd,eta,depth)+1;
849  hf_data[eta+42][phi-1][depth-1][0].nBadRms++;
850  double val=hf_data[eta+42][phi-1][depth-1][0].nBadRms/hf_data[eta+42][phi-1][depth-1][0].nChecks;
851  ProblemCellsByDepth_badrms->depth[depth-1]->setBinContent(e,phi,val);
852  ProblemCellsByDepth_badrms_val->depth[depth-1]->setBinContent(e,phi,deltaRms);
854  }
855  }
856  }
857  }
858 }
859 
861  if((LocalRun || !Online_) && ievt_>=100){
862  fillHistos();
863  CheckStatus();
864  SaveReference();
865  }
866 }
867 
869 double ped[4],rms[4];
870 int Eta,Phi,Depth,Statistic,Status=0;
871 char Subdet[10],str[500];
872  if(OutputFilePath.size()>0){
873  if(!Overwrite){
874  sprintf(str,"%sHcalDetDiagPedestalData_run%06i_%i.root",OutputFilePath.c_str(),run_number,dataset_seq_number);
875  }else{
876  sprintf(str,"%sHcalDetDiagPedestalData.root",OutputFilePath.c_str());
877  }
878  TFile *theFile = new TFile(str, "RECREATE");
879  if(!theFile->IsOpen()) return;
880  theFile->cd();
881  sprintf(str,"%d",run_number); TObjString run(str); run.Write("run number");
882  sprintf(str,"%d",ievt_); TObjString events(str); events.Write("Total events processed");
883  sprintf(str,"%d",dataset_seq_number); TObjString dsnum(str); dsnum.Write("Dataset number");
884  Long_t t; t=time(0); strftime(str,30,"%F %T",localtime(&t)); TObjString tm(str); tm.Write("Dataset creation time");
885 
886  TTree *tree =new TTree("HCAL Pedestal data","HCAL Pedestal data");
887  if(tree==0) return;
888  tree->Branch("Subdet", &Subdet, "Subdet/C");
889  tree->Branch("eta", &Eta, "Eta/I");
890  tree->Branch("phi", &Phi, "Phi/I");
891  tree->Branch("depth", &Depth, "Depth/I");
892  tree->Branch("statistic",&Statistic, "Statistic/I");
893  tree->Branch("status", &Status, "Status/I");
894  tree->Branch("cap0_ped", &ped[0], "cap0_ped/D");
895  tree->Branch("cap0_rms", &rms[0], "cap0_rms/D");
896  tree->Branch("cap1_ped", &ped[1], "cap1_ped/D");
897  tree->Branch("cap1_rms", &rms[1], "cap1_rms/D");
898  tree->Branch("cap2_ped", &ped[2], "cap2_ped/D");
899  tree->Branch("cap2_rms", &rms[2], "cap2_rms/D");
900  tree->Branch("cap3_ped", &ped[3], "cap3_ped/D");
901  tree->Branch("cap3_rms", &rms[3], "cap3_rms/D");
902  sprintf(Subdet,"HB");
903  for(int eta=-16;eta<=16;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=2;depth++){
904  if((Statistic=hb_data[eta+42][phi-1][depth-1][0].get_statistics())>100){
905  Eta=eta; Phi=phi; Depth=depth;
906  Status=hb_data[eta+42][phi-1][depth-1][0].get_status();
907  hb_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0]);
908  hb_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
909  hb_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
910  hb_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
911  tree->Fill();
912  }
913  }
914  sprintf(Subdet,"HE");
915  for(int eta=-29;eta<=29;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=3;depth++){
916  if((Statistic=he_data[eta+42][phi-1][depth-1][0].get_statistics())>100){
917  Eta=eta; Phi=phi; Depth=depth;
918  Status=he_data[eta+42][phi-1][depth-1][0].get_status();
919  he_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0]);
920  he_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
921  he_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
922  he_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
923  tree->Fill();
924  }
925  }
926  sprintf(Subdet,"HO");
927  for(int eta=-15;eta<=15;eta++) for(int phi=1;phi<=72;phi++) for(int depth=4;depth<=4;depth++){
928  if((Statistic=ho_data[eta+42][phi-1][depth-1][0].get_statistics())>100){
929  Eta=eta; Phi=phi; Depth=depth;
930  Status=ho_data[eta+42][phi-1][depth-1][0].get_status();
931  ho_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0]);
932  ho_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
933  ho_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
934  ho_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
935  tree->Fill();
936  }
937  }
938  sprintf(Subdet,"HF");
939  for(int eta=-42;eta<=42;eta++) for(int phi=1;phi<=72;phi++) for(int depth=1;depth<=2;depth++){
940  if((Statistic=hf_data[eta+42][phi-1][depth-1][0].get_statistics())>100){
941  Eta=eta; Phi=phi; Depth=depth;
942  Status=hf_data[eta+42][phi-1][depth-1][0].get_status();
943  hf_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0]);
944  hf_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
945  hf_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
946  hf_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
947  tree->Fill();
948  }
949  }
950  theFile->Write();
951  theFile->Close();
952  }
953  if(XmlFilePath.size()>0){
954  //create XML file
955  if(!Overwrite){
956  sprintf(str,"HcalDetDiagPedestals_%i_%i.xml",run_number,dataset_seq_number);
957  }else{
958  sprintf(str,"HcalDetDiagPedestals.xml");
959  }
960  std::string xmlName=str;
961  ofstream xmlFile;
962  xmlFile.open(xmlName.c_str());
963 
964  xmlFile<<"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
965  xmlFile<<"<ROOT>\n";
966  xmlFile<<" <HEADER>\n";
967  xmlFile<<" <HINTS mode='only-det-root'/>\n";
968  xmlFile<<" <TYPE>\n";
969  xmlFile<<" <EXTENSION_TABLE_NAME>HCAL_DETMON_PEDESTALS_V1</EXTENSION_TABLE_NAME>\n";
970  xmlFile<<" <NAME>HCAL Pedestals [abort gap global]</NAME>\n";
971  xmlFile<<" </TYPE>\n";
972  xmlFile<<" <!-- run details -->\n";
973  xmlFile<<" <RUN>\n";
974  xmlFile<<" <RUN_TYPE>GLOBAL-RUN</RUN_TYPE>\n";
975  xmlFile<<" <RUN_NUMBER>"<<run_number<<"</RUN_NUMBER>\n";
976  xmlFile<<" <RUN_BEGIN_TIMESTAMP>2009-01-01 00:00:00</RUN_BEGIN_TIMESTAMP>\n";
977  xmlFile<<" <COMMENT_DESCRIPTION>hcal ped data</COMMENT_DESCRIPTION>\n";
978  xmlFile<<" <LOCATION>P5</LOCATION>\n";
979  xmlFile<<" <INITIATED_BY_USER>dma</INITIATED_BY_USER>\n";
980  xmlFile<<" </RUN>\n";
981  xmlFile<<" </HEADER>\n";
982  xmlFile<<" <DATA_SET>\n";
983  xmlFile<<" <!-- optional dataset metadata -->\n\n";
984  xmlFile<<" <SET_NUMBER>"<<dataset_seq_number<<"</SET_NUMBER>\n";
985  xmlFile<<" <SET_BEGIN_TIMESTAMP>2009-01-01 00:00:00</SET_BEGIN_TIMESTAMP>\n";
986  xmlFile<<" <SET_END_TIMESTAMP>2009-01-01 00:00:00</SET_END_TIMESTAMP>\n";
987  xmlFile<<" <NUMBER_OF_EVENTS_IN_SET>"<<ievt_<<"</NUMBER_OF_EVENTS_IN_SET>\n";
988  xmlFile<<" <COMMENT_DESCRIPTION>Automatic DQM output</COMMENT_DESCRIPTION>\n";
989  xmlFile<<" <DATA_FILE_NAME>"<< xmlName <<"</DATA_FILE_NAME>\n";
990  xmlFile<<" <IMAGE_FILE_NAME>data plot url or file path</IMAGE_FILE_NAME>\n";
991  xmlFile<<" <!-- who and when created this dataset-->\n\n";
992  Long_t t; t=time(0); strftime(str,30,"%F %T",localtime(&t));
993  xmlFile<<" <CREATE_TIMESTAMP>"<<str<<"</CREATE_TIMESTAMP>\n";
994  xmlFile<<" <CREATED_BY_USER>dma</CREATED_BY_USER>\n";
995  xmlFile<<" <!-- version (string) and subversion (number) -->\n";
996  xmlFile<<" <!-- fields are used to read data back from the database -->\n\n";
997  xmlFile<<" <VERSION>"<<run_number<<dataset_seq_number<<"</VERSION>\n";
998  xmlFile<<" <SUBVERSION>1</SUBVERSION>\n";
999  xmlFile<<" <!-- Assign predefined dataset attributes -->\n\n";
1000  xmlFile<<" <PREDEFINED_ATTRIBUTES>\n";
1001  xmlFile<<" <ATTRIBUTE>\n";
1002  xmlFile<<" <NAME>HCAL Dataset Status</NAME>\n";
1003  xmlFile<<" <VALUE>VALID</VALUE>\n";
1004  xmlFile<<" </ATTRIBUTE>\n";
1005  xmlFile<<" </PREDEFINED_ATTRIBUTES>\n";
1006  xmlFile<<" <!-- multiple data block records -->\n\n";
1007 
1008  std::vector <HcalElectronicsId> AllElIds = emap->allElectronicsIdPrecision();
1009  for(std::vector <HcalElectronicsId>::iterator eid = AllElIds.begin(); eid != AllElIds.end(); eid++){
1010  DetId detid=emap->lookup(*eid);
1011  if (detid.det()!=DetId::Hcal) continue;
1012  HcalGenericDetId gid(emap->lookup(*eid));
1013  if (gid.null())
1014  continue;
1015  if (gid.genericSubdet()!=HcalGenericDetId::HcalGenBarrel &&
1016  gid.genericSubdet()!=HcalGenericDetId::HcalGenEndcap &&
1017  gid.genericSubdet()!=HcalGenericDetId::HcalGenForward &&
1018  gid.genericSubdet()!=HcalGenericDetId::HcalGenOuter)
1019  continue;
1020 
1021  int eta,phi,depth;
1022  std::string subdet="";
1023  HcalDetId hid(detid);
1024  eta=hid.ieta();
1025  phi=hid.iphi();
1026  depth=hid.depth();
1027 
1028  double ped[4]={0,0,0,0},rms[4]={0,0,0,0};
1029  if(detid.subdetId()==HcalBarrel){
1030  subdet="HB";
1031  Statistic=hb_data[eta+42][phi-1][depth-1][0].get_statistics();
1032  Status =hb_data[eta+42][phi-1][depth-1][0].get_status();
1033  hb_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0]);
1034  hb_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
1035  hb_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
1036  hb_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
1037  }else if(detid.subdetId()==HcalEndcap){
1038  subdet="HE";
1039  he_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0]);
1040  he_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
1041  he_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
1042  he_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
1043  Statistic=he_data[eta+42][phi-1][depth-1][0].get_statistics();
1044  Status =he_data[eta+42][phi-1][depth-1][0].get_status();
1045  }else if(detid.subdetId()==HcalForward){
1046  subdet="HF";
1047  hf_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0]);
1048  hf_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
1049  hf_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
1050  hf_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
1051  Statistic=hf_data[eta+42][phi-1][depth-1][0].get_statistics();
1052  Status =hf_data[eta+42][phi-1][depth-1][0].get_status();
1053  }else if(detid.subdetId()==HcalOuter){
1054  subdet="HO";
1055  ho_data[eta+42][phi-1][depth-1][0].get_average(&ped[0],&rms[0]);
1056  ho_data[eta+42][phi-1][depth-1][1].get_average(&ped[1],&rms[1]);
1057  ho_data[eta+42][phi-1][depth-1][2].get_average(&ped[2],&rms[2]);
1058  ho_data[eta+42][phi-1][depth-1][3].get_average(&ped[3],&rms[3]);
1059  Statistic=ho_data[eta+42][phi-1][depth-1][0].get_statistics();
1060  Status =ho_data[eta+42][phi-1][depth-1][0].get_status();
1061  }else continue;
1062  xmlFile<<" <DATA>\n";
1063  xmlFile<<" <NUMBER_OF_EVENTS_USED>"<<Statistic<<"</NUMBER_OF_EVENTS_USED>\n";
1064  xmlFile<<" <MEAN0>"<<ped[0]<<"</MEAN0>\n";
1065  xmlFile<<" <MEAN1>"<<ped[1]<<"</MEAN1>\n";
1066  xmlFile<<" <MEAN2>"<<ped[2]<<"</MEAN2>\n";
1067  xmlFile<<" <MEAN3>"<<ped[3]<<"</MEAN3>\n";
1068  xmlFile<<" <RMS0>"<<rms[0]<<"</RMS0>\n";
1069  xmlFile<<" <RMS1>"<<rms[1]<<"</RMS1>\n";
1070  xmlFile<<" <RMS2>"<<rms[2]<<"</RMS2>\n";
1071  xmlFile<<" <RMS3>"<<rms[3]<<"</RMS3>\n";
1072  xmlFile<<" <CHANNEL_STATUS_WORD>"<<Status<<"</CHANNEL_STATUS_WORD>\n";
1073  xmlFile<<" <CHANNEL_OBJECTNAME>HcalDetId</CHANNEL_OBJECTNAME>\n";
1074  xmlFile<<" <SUBDET>"<<subdet<<"</SUBDET>\n";
1075  xmlFile<<" <IETA>"<<eta<<"</IETA>\n";
1076  xmlFile<<" <IPHI>"<<phi<<"</IPHI>\n";
1077  xmlFile<<" <DEPTH>"<<depth<<"</DEPTH>\n";
1078  xmlFile<<" <TYPE>0</TYPE>\n";
1079  xmlFile<<" </DATA>\n";
1080  }
1082  xmlFile<<" </DATA_SET>\n";
1083  xmlFile<<"</ROOT>\n";
1084  xmlFile.close();
1085  sprintf(str,"zip %s.zip %s",xmlName.c_str(),xmlName.c_str());
1086  system(str);
1087  sprintf(str,"rm -f %s",xmlName.c_str());
1088  system(str);
1089  sprintf(str,"mv -f %s.zip %s",xmlName.c_str(),XmlFilePath.c_str());
1090  system(str);
1091  }
1093 }
1094 
1096  double ped[4],rms[4];
1097  int Eta,Phi,Depth;
1098  char subdet[10];
1099  TFile *f;
1100  if(gSystem->AccessPathName(ReferenceData.c_str())) return;
1101  f = new TFile(ReferenceData.c_str(),"READ");
1102  if(!f->IsOpen()) return ;
1103  TObjString *STR=(TObjString *)f->Get("run number");
1104 
1105  if(STR){ std::string Ref(STR->String()); ReferenceRun=Ref;}
1106 
1107  TTree* t=(TTree*)f->Get("HCAL Pedestal data");
1108  if(!t) return;
1109  t->SetBranchAddress("Subdet", subdet);
1110  t->SetBranchAddress("eta", &Eta);
1111  t->SetBranchAddress("phi", &Phi);
1112  t->SetBranchAddress("depth", &Depth);
1113  t->SetBranchAddress("cap0_ped", &ped[0]);
1114  t->SetBranchAddress("cap0_rms", &rms[0]);
1115  t->SetBranchAddress("cap1_ped", &ped[1]);
1116  t->SetBranchAddress("cap1_rms", &rms[1]);
1117  t->SetBranchAddress("cap2_ped", &ped[2]);
1118  t->SetBranchAddress("cap2_rms", &rms[2]);
1119  t->SetBranchAddress("cap3_ped", &ped[3]);
1120  t->SetBranchAddress("cap3_rms", &rms[3]);
1121  for(int ievt=0;ievt<t->GetEntries();ievt++){
1122  t->GetEntry(ievt);
1123  if(strcmp(subdet,"HB")==0){
1124  hb_data[Eta+42][Phi-1][Depth-1][0].set_reference(ped[0],rms[0]);
1125  hb_data[Eta+42][Phi-1][Depth-1][1].set_reference(ped[1],rms[1]);
1126  hb_data[Eta+42][Phi-1][Depth-1][2].set_reference(ped[2],rms[2]);
1127  hb_data[Eta+42][Phi-1][Depth-1][3].set_reference(ped[3],rms[3]);
1128  }
1129  if(strcmp(subdet,"HE")==0){
1130  he_data[Eta+42][Phi-1][Depth-1][0].set_reference(ped[0],rms[0]);
1131  he_data[Eta+42][Phi-1][Depth-1][1].set_reference(ped[1],rms[1]);
1132  he_data[Eta+42][Phi-1][Depth-1][2].set_reference(ped[2],rms[2]);
1133  he_data[Eta+42][Phi-1][Depth-1][3].set_reference(ped[3],rms[3]);
1134  }
1135  if(strcmp(subdet,"HO")==0){
1136  ho_data[Eta+42][Phi-1][Depth-1][0].set_reference(ped[0],rms[0]);
1137  ho_data[Eta+42][Phi-1][Depth-1][1].set_reference(ped[1],rms[1]);
1138  ho_data[Eta+42][Phi-1][Depth-1][2].set_reference(ped[2],rms[2]);
1139  ho_data[Eta+42][Phi-1][Depth-1][3].set_reference(ped[3],rms[3]);
1140  }
1141  if(strcmp(subdet,"HF")==0){
1142  hf_data[Eta+42][Phi-1][Depth-1][0].set_reference(ped[0],rms[0]);
1143  hf_data[Eta+42][Phi-1][Depth-1][1].set_reference(ped[1],rms[1]);
1144  hf_data[Eta+42][Phi-1][Depth-1][2].set_reference(ped[2],rms[2]);
1145  hf_data[Eta+42][Phi-1][Depth-1][3].set_reference(ped[3],rms[3]);
1146  }
1147  }
1148  f->Close();
1149  IsReference=true;
1150 }
1151 
1154 
1155 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:42
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< HcalElectronicsId > allElectronicsIdPrecision() const
void beginRun(const edm::Run &run, const edm::EventSetup &c)
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:519
void setAxisRange(double xmin, double xmax, int axis=1)
set x-, y- or z-axis range (axis=1, 2, 3 respectively)
std::vector< std::string > problemnames_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
HcalDetDiagPedestalData ho_data[85][72][4][4]
tuple calibType
Definition: diJetCalib.py:20
std::vector< T >::const_iterator const_iterator
void setup(DQMStore *&m_dbe, std::string Name, std::string Units="")
#define abs(x)
Definition: mlp_lapack.h:159
bool getByType(Handle< PROD > &result) const
Definition: Event.h:403
HcalDetDiagPedestalData he_data[85][72][4][4]
bool get_average(double *ave, double *rms)
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
T eta() const
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
void Fill(long long x)
void analyze(const edm::Event &, const edm::EventSetup &)
bool get_reference(double *val, double *rms)
int depth() const
get the tower depth
Definition: HcalDetId.h:42
int iEvent
Definition: GenABIO.cc:243
std::vector< MonitorElement * > depth
const T & max(const T &a, const T &b)
MonitorElement * bookString(const char *name, const char *value)
Book string.
Definition: DQMStore.cc:485
T sqrt(T t)
Definition: SSEVec.h:28
HcalDetDiagPedestalData hb_data[85][72][4][4]
HcalDetDiagPedestalMonitor(const edm::ParameterSet &)
int ieta() const
get the cell ieta
Definition: HcalDetId.h:38
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
int j
Definition: DBlmapReader.cc:9
double f[11][100]
int orbitNumber() const
Definition: EventBase.h:63
void add_statistics(unsigned int val)
bool isValid() const
Definition: HandleBase.h:76
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
int k[5][pyjets_maxn]
static std::string from(" from ")
int iphi() const
get the cell iphi
Definition: HcalDetId.h:40
Definition: DetId.h:20
const T & get() const
Definition: EventSetup.h:55
virtual void reset(void)
bool xmlFile(const std::string fParam)
int CalcEtaBin(int subdet, int ieta, int depth)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
edm::EventID id() const
Definition: EventBase.h:56
void set_reference(float val, float rms)
tuple events
Definition: patZpeak.py:19
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:29
void endRun(const edm::Run &run, const edm::EventSetup &c)
tuple status
Definition: ntuplemaker.py:245
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:426
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:647
virtual void setup(void)
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
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)
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237
Definition: Run.h:31
HcalDetDiagPedestalData hf_data[85][72][4][4]
Definition: DDAxes.h:10