CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDetDiagNoiseMonitor.cc
Go to the documentation of this file.
7 
8 #include "TFile.h"
9 #include "TTree.h"
10 #include <TVector2.h>
11 #include <TVector3.h>
12 
14 
17 
36 // #include "DataFormats/L1Trigger/interface/L1ParticleMap.h"
41 //#include "DataFormats/L1GlobalTrigger/interface/L1GtLogicParser.h"
55 
56 // this is to retrieve HCAL LogicalMap
58 
59 
60 #include <math.h>
61 
62 using namespace reco;
63 
65 constexpr float adc2fC[128]={-0.5,0.5,1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5, 10.5,11.5,12.5,
66  13.5,15.,17.,19.,21.,23.,25.,27.,29.5,32.5,35.5,38.5,42.,46.,50.,54.5,59.5,
67  64.5,59.5,64.5,69.5,74.5,79.5,84.5,89.5,94.5,99.5,104.5,109.5,114.5,119.5,
68  124.5,129.5,137.,147.,157.,167.,177.,187.,197.,209.5,224.5,239.5,254.5,272.,
69  292.,312.,334.5,359.5,384.5,359.5,384.5,409.5,434.5,459.5,484.5,509.5,534.5,
70  559.5,584.5,609.5,634.5,659.5,684.5,709.5,747.,797.,847.,897.,947.,997.,
71  1047.,1109.5,1184.5,1259.5,1334.5,1422.,1522.,1622.,1734.5,1859.5,1984.5,
72  1859.5,1984.5,2109.5,2234.5,2359.5,2484.5,2609.5,2734.5,2859.5,2984.5,
73  3109.5,3234.5,3359.5,3484.5,3609.5,3797.,4047.,4297.,4547.,4797.,5047.,
74  5297.,5609.5,5984.5,6359.5,6734.5,7172.,7672.,8172.,8734.5,9359.5,9984.5};
76 constexpr char const *subdets[11]={"HBM","HBP","HEM","HEP","HO1M","HO0","HO1P","HO2M","HO2P","HFM","HFP"};
77 constexpr char const *HB_RBX[36]={
78 "HBM01","HBM02","HBM03","HBM04","HBM05","HBM06","HBM07","HBM08","HBM09","HBM10","HBM11","HBM12","HBM13","HBM14","HBM15","HBM16","HBM17","HBM18",
79 "HBP01","HBP02","HBP03","HBP04","HBP05","HBP06","HBP07","HBP08","HBP09","HBP10","HBP11","HBP12","HBP13","HBP14","HBP15","HBP16","HBP17","HBP18"};
80 constexpr char const *HE_RBX[36]={
81 "HEM01","HEM02","HEM03","HEM04","HEM05","HEM06","HEM07","HEM08","HEM09","HEM10","HEM11","HEM12","HEM13","HEM14","HEM15","HEM16","HEM17","HEM18",
82 "HEP01","HEP02","HEP03","HEP04","HEP05","HEP06","HEP07","HEP08","HEP09","HEP10","HEP11","HEP12","HEP13","HEP14","HEP15","HEP16","HEP17","HEP18"};
83 constexpr char const *HO_RBX[36]={
84 "HO2M02","HO2M04","HO2M06","HO2M08","HO2M10","HO2M12","HO1M02","HO1M04","HO1M06","HO1M08","HO1M10","HO1M12",
85 "HO001","HO002","HO003","HO004","HO005","HO006","HO007","HO008","HO009","HO010","HO011","HO012",
86 "HO1P02","HO1P04","HO1P06","HO1P08","HO1P10","HO1P12","HO2P02","HO2P04","HO2P06","HO2P08","HO2P10","HO2P12",
87 };
88 
89 
91 public:
93  reset();
94  reset_LS();
95  };
96  void reset(){
97  n_th_hi=n_th_300=n_pix_1=n_pix_8=pix=n_pix=0;
98  }
99  void reset_LS(){
100  n_th_hi_LS=n_th_300_LS=0;
101  }
102  int n_th_hi;
103  int n_th_300;
104  int n_pix_1;
105  int n_pix_8;
106  int pix;
107  int n_pix;
110 };
112 public:
114  reset();
115  }
116  void reset(){
117  n_pix_hi=n_pix_lo=energy=n_zero=0;
118  }
119  int n_pix_hi;
120  int n_pix_lo;
121  int n_zero;
122  float energy;
123 };
124 
126 public:
128  reset();
129  }
130  void reset(){
131  for(int i=0;i<HcalFrontEndId::maxRmIndex;i++) rm[i].reset();
132  }
133  void reset_LS(){
134  for(int i=0;i<HcalFrontEndId::maxRmIndex;i++) rm[i].reset_LS();
135  }
136  int GetRMindex(const std::string& rbx,int rm){
137  if(rbx.substr(0,3)=="HO0"){
138  int sect=atoi(rbx.substr(3,2).c_str());
139  if(sect>12) return -1;
140  if(rm==1 && (sect==2 || sect==3 || sect==6 || sect==7 || sect==10 || sect==11)) return -1;
141  if(rm==4 && (sect==12 || sect==1 || sect==4 || sect==5 || sect==8 || sect==9 )) return -1;
142  }
143  if(rbx.substr(0,3)=="HO1" || rbx.substr(0,3)=="HO2"){
144  int sect=atoi(rbx.substr(4,2).c_str());
145  if(sect>12) return -1;
146  if(sect==1 || sect==3 || sect==5 || sect==7 || sect==9 || sect==11) return -1;
147  }
148  HcalFrontEndId id(rbx,rm,1,1,1,1,1);
149  if(id.rawId()==0) return -1;
150  return id.rmIndex();
151  }
153 };
154 
156 
157  tok_tb_ = consumes<HcalTBTriggerData>(ps.getParameter<edm::InputTag>("hcalTBTriggerDataTag"));
158 
159  ievt_=0;
160  run_number=-1;
161  NoisyEvents=0;
162  LocalRun=false;
163  dataset_seq_number=1;
164  FirstOrbit=FirstOrbitLS=0xFFFFFFFF;
165  LastOrbit=LastOrbitLS=0;
166 
167  Online_ = ps.getUntrackedParameter<bool>("online",false);
168  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns",false);
169  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup",false);
170  debug_ = ps.getUntrackedParameter<int>("debug",0);
171  prefixME_ = ps.getUntrackedParameter<std::string>("subSystemFolder","Hcal/");
172  if (prefixME_.substr(prefixME_.size()-1,prefixME_.size())!="/")
173  prefixME_.append("/");
174  subdir_ = ps.getUntrackedParameter<std::string>("TaskFolder","DetDiagNoiseMonitor_Hcal");
175  if (subdir_.size()>0 && subdir_.substr(subdir_.size()-1,subdir_.size())!="/")
176  subdir_.append("/");
177  subdir_=prefixME_+subdir_;
178  AllowedCalibTypes_ = ps.getUntrackedParameter<std::vector<int> > ("AllowedCalibTypes");
179  skipOutOfOrderLS_ = ps.getUntrackedParameter<bool>("skipOutOfOrderLS",false);
180  NLumiBlocks_ = ps.getUntrackedParameter<int>("NLumiBlocks",4000);
181  makeDiagnostics_ = ps.getUntrackedParameter<bool>("makeDiagnostics",false);
182 
183  UseDB = ps.getUntrackedParameter<bool> ("UseDB" , false);
184  OutputFilePath = ps.getUntrackedParameter<std::string>("OutputFilePath", "");
185  HPDthresholdHi = ps.getUntrackedParameter<double>("NoiseThresholdHPDhi",49.0);
186  HPDthresholdLo = ps.getUntrackedParameter<double>("NoiseThresholdHPDlo",10.0);
187  SpikeThreshold = ps.getUntrackedParameter<double>("NoiseSpikeThreshold",0.5);
188  Overwrite = ps.getUntrackedParameter<bool> ("Overwrite",true);
189 
190  tok_raw_ = consumes<FEDRawDataCollection>(ps.getUntrackedParameter<edm::InputTag>("RawDataLabel",edm::InputTag("source","")));
191  digiLabel_ = ps.getUntrackedParameter<edm::InputTag>("digiLabel",edm::InputTag("hcalDigis"));
192  tok_l1_ = consumes<L1GlobalTriggerReadoutRecord>(ps.getUntrackedParameter<edm::InputTag>("gtLabel"));
193 
194 
195  tok_hbhe_ = consumes<HBHEDigiCollection>(digiLabel_);
196  tok_ho_ = consumes<HODigiCollection>(digiLabel_);
197 
198  RMSummary = 0;
199  needLogicalMap_=true;
200  setupDone_ = false;
201 }
202 
204  if(dbe_){
205  dbe_->setCurrentFolder(subdir_);
206  dbe_->removeContents();
207  dbe_ = 0;
208  }
209 }
211 
212 
214 {
215  if (debug_>1) std::cout <<"HcalDetDiagNoiseMonitor::beginRun"<<std::endl;
217 
218  if (tevt_==0) this->setup(); // set up histograms if they have not been created before
219  if (mergeRuns_==false)
220  this->reset();
221 
222  return;
223 
224 }
225 
227  if (setupDone_)
228  return;
229  setupDone_ = true;
230  // Call base class setup
232  if (!dbe_) return;
233  RMSummary = new HcalDetDiagNoiseRMSummary();
234 
236  if(dbe_!=NULL){
237  dbe_->setCurrentFolder(subdir_);
238  meEVT_ = dbe_->bookInt("HcalNoiseMonitor Event Number");
239  dbe_->setCurrentFolder(subdir_+"Common Plots");
240 
241  name="RBX Pixel multiplicity"; PixelMult = dbe_->book1D(name,name,73,0,73);
242  name="HPD energy"; HPDEnergy = dbe_->book1D(name,name,200,0,2500);
243  name="RBX energy"; RBXEnergy = dbe_->book1D(name,name,200,0,3500);
244  name="Number of zero TS per RBX"; NZeroes = dbe_->book1D(name,name,100,0,100);
245  name="Trigger BX Tbit11"; TriggerBx11 = dbe_->book1D(name,name,4000,0,4000);
246  name="Trigger BX Tbit12"; TriggerBx12 = dbe_->book1D(name,name,4000,0,4000);
247 
248  dbe_->setCurrentFolder(subdir_+"HBHE Plots");
249  name="HBP HPD Noise Rate Pixel above 50fC"; HBP_Rate50 = dbe_->book1D(name,name,73,0,73);
250  name="HBM HPD Noise Rate Pixel above 50fC"; HBM_Rate50 = dbe_->book1D(name,name,73,0,73);
251  name="HEP HPD Noise Rate Pixel above 50fC"; HEP_Rate50 = dbe_->book1D(name,name,73,0,73);
252  name="HEM HPD Noise Rate Pixel above 50fC"; HEM_Rate50 = dbe_->book1D(name,name,73,0,73);
253  name="HBP HPD Noise Rate HPD above 300fC"; HBP_Rate300 = dbe_->book1D(name,name,73,0,73);
254  name="HBM HPD Noise Rate HPD above 300fC"; HBM_Rate300 = dbe_->book1D(name,name,73,0,73);
255  name="HEP HPD Noise Rate HPD above 300fC"; HEP_Rate300 = dbe_->book1D(name,name,73,0,73);
256  name="HEM HPD Noise Rate HPD above 300fC"; HEM_Rate300 = dbe_->book1D(name,name,73,0,73);
257 
258  dbe_->setCurrentFolder(subdir_+"HO Plots");
259  name="HO0 HPD Noise Rate Pixel above 50fC"; HO0_Rate50 = dbe_->book1D(name,name,49,0,49);
260  name="HO1P HPD Noise Rate Pixel above 50fC"; HO1P_Rate50 = dbe_->book1D(name,name,48,0,48);
261  name="HO1M HPD Noise Rate Pixel above 50fC"; HO1M_Rate50 = dbe_->book1D(name,name,48,0,48);
262  name="HO0 HPD Noise Rate HPD above 300fC"; HO0_Rate300 = dbe_->book1D(name,name,48,0,48);
263  name="HO1P HPD Noise Rate HPD abGetRMindexove 300fC"; HO1P_Rate300 = dbe_->book1D(name,name,48,0,48);
264  name="HO1M HPD Noise Rate HPD above 300fC"; HO1M_Rate300 = dbe_->book1D(name,name,48,0,48);
265 
266 
267  dbe_->setCurrentFolder(subdir_+"Noise Spike Plots");
268 
269  name="HB RM Spike Map"; HB_RBXmapSpikeCnt= dbe_->book2D(name,name,4,0.5,4.5,36,0.5,36.5);
270  name="HE RM Spike Map"; HE_RBXmapSpikeCnt= dbe_->book2D(name,name,4,0.5,4.5,36,0.5,36.5);
271  name="HO RM Spike Map"; HO_RBXmapSpikeCnt= dbe_->book2D(name,name,4,0.5,4.5,36,0.5,36.5);
272 
273  std::string title="RM";
274  HB_RBXmapSpikeCnt->setAxisTitle(title);
275  HE_RBXmapSpikeCnt->setAxisTitle(title);
276  HO_RBXmapSpikeCnt->setAxisTitle(title);
277 
278  for(int i=0;i<36;i++){
279  HB_RBXmapSpikeCnt->setBinLabel(i+1,HB_RBX[i],2);
280  HE_RBXmapSpikeCnt->setBinLabel(i+1,HE_RBX[i],2);
281  HO_RBXmapSpikeCnt->setBinLabel(i+1,HO_RBX[i],2);
282  }
283  }
284 
285 
286  return;
287 }
288 
290  getLogicalMap(iSetup);
291  if (!IsAllowedCalibType()) return;
292  if (LumiInOrder(iEvent.luminosityBlock())==false) return;
293  HcalBaseDQMonitor::analyze(iEvent, iSetup);
294  bool isNoiseEvent=false;
295  if(!dbe_) return;
296  int orbit=-1111;
297  int bx=-1111;
298 
299  // for local runs
300  edm::Handle<HcalTBTriggerData> trigger_data;
301  iEvent.getByToken(tok_tb_, trigger_data);
302  if(trigger_data.isValid()){
303  if(trigger_data->triggerWord()>1000) isNoiseEvent=true;
304  LocalRun=true;
305  }
306 
307  // We do not want to look at Abort Gap events
309  iEvent.getByToken(tok_raw_,rawdata);
310  //checking FEDs for calibration information
312  const FEDRawData& fedData = rawdata->FEDData(i) ;
313  if ( fedData.size() < 24 ) continue ;
314  orbit= ((const HcalDCCHeader*)(fedData.data()))->getOrbitNumber();
315  bx=((const HcalDCCHeader*)(fedData.data()))->getBunchId();
316  if(((const HcalDCCHeader*)(fedData.data()))->getCalibType()!=hc_Null) return;
317  }
318 
319  // Check GCT trigger bits
321  iEvent.getByToken(tok_l1_, gtRecord);
322  if(gtRecord.isValid()){
323  const TechnicalTriggerWord tWord = gtRecord->technicalTriggerWord();
324  if(tWord.at(11) || tWord.at(12)) isNoiseEvent=true;
325  if(tWord.at(11)){ TriggerBx11->Fill(bx);}
326  if(tWord.at(12)){ TriggerBx12->Fill(bx);}
327  }
328 
329  if(!isNoiseEvent) return;
330  if(ievt_==0){ FirstOrbit=orbit; FirstOrbitLS=orbit; newLS=true;}
331  if(LastOrbit <orbit) LastOrbit=orbit;
332  if(FirstOrbit>orbit) FirstOrbit=orbit;
333  if(LastOrbitLS <orbit) LastOrbitLS=orbit;
334  if(FirstOrbitLS>orbit) FirstOrbitLS=orbit;
335  if(newLS){
336  FirstOrbitLS=orbit;
337  newLS=false;
338  }
339 
340  if(!LocalRun){
341  double TIME=(double)(LastOrbit-FirstOrbit)/11223.0;
342  if(TIME>1800.0){
343  UpdateHistos();
344  SaveRates();
345  RMSummary->reset();
346  FirstOrbit=orbit;
347  }
348  }
349 
350  meEVT_->Fill(++ievt_);
351 
352  run_number=iEvent.id().run();
353 
355 
357  iEvent.getByToken(tok_hbhe_,hbhe);
358  for(HBHEDigiCollection::const_iterator digi=hbhe->begin();digi!=hbhe->end();digi++){
359  double max=-100/*,sum*/,energy=0; int n_zero=0;
360  for(int i=0;i<digi->size();i++){
361  // sum=adc2fC[digi->sample(i).adc()&0xff];
362  if(max<adc2fC[digi->sample(i).adc()&0xff]) max=adc2fC[digi->sample(i).adc()&0xff];
363  if(adc2fC[digi->sample(i).adc()&0xff]==0) n_zero++;
364  }
365  HcalFrontEndId lmap_entry=logicalMap_->getHcalFrontEndId(digi->id());
366  int index=lmap_entry.rmIndex(); if(index>=HcalFrontEndId::maxRmIndex) continue;
367  RMs[index].n_zero++;
368  if(max>HPDthresholdLo){
369  for(int i=0;i<digi->size();i++) energy+=adc2fC[digi->sample(i).adc()&0xff]-2.5;
370  RMs[index].n_pix_lo++;
371  if(max>HPDthresholdHi){ RMs[index].n_pix_hi++; isNoiseEvent=true;}
372  RMs[index].energy+=energy;
373  }
374  }
375 
377  iEvent.getByToken(tok_ho_,ho);
378  for(HODigiCollection::const_iterator digi=ho->begin();digi!=ho->end();digi++){
379  double max=-100,energy=0; int Eta=digi->id().ieta(); int Phi=digi->id().iphi(); int n_zero=0;
380  for(int i=0;i<digi->size()-1;i++){
381  if(max<adc2fC[digi->sample(i).adc()&0xff]) max=adc2fC[digi->sample(i).adc()&0xff];
382  if(adc2fC[digi->sample(i).adc()&0xff]==0) n_zero++;
383  }
384  if((Eta>=11 && Eta<=15 && Phi>=59 && Phi<=70) || (Eta>=5 && Eta<=10 && Phi>=47 && Phi<=58)){
385  continue; // ignory SiPMs
386  }else{
387  HcalFrontEndId lmap_entry=logicalMap_->getHcalFrontEndId(digi->id());
388  int index=lmap_entry.rmIndex(); if(index>=HcalFrontEndId::maxRmIndex) continue;
389  RMs[index].n_zero++;
390  if(max>HPDthresholdLo){
391  for(int i=0;i<digi->size();i++) energy+=adc2fC[digi->sample(i).adc()&0xff]-2.5;
392  RMs[index].n_pix_lo++;
393  if(max>HPDthresholdHi){ RMs[index].n_pix_hi++; isNoiseEvent=true;}
394  RMs[index].energy+=energy;
395  }
396  }
397  }
398 
399  NoisyEvents++;
400 
401  // RMs loop
402  for(int i=0;i<HcalFrontEndId::maxRmIndex;i++){
403  if(RMs[i].n_pix_hi>0){
404  HPDEnergy->Fill(RMs[i].energy);
405  RMSummary->rm[i].n_th_hi++;
406  RMSummary->rm[i].n_th_hi_LS++;
407  if(RMs[i].energy>300) RMSummary->rm[i].n_th_300++;
408  if(RMs[i].energy>300) RMSummary->rm[i].n_th_300_LS++;
409  if(RMs[i].n_pix_lo>1) RMSummary->rm[i].n_pix_1++;
410  if(RMs[i].n_pix_lo>8) RMSummary->rm[i].n_pix_8++;
411  RMSummary->rm[i].pix+=RMs[i].n_pix_lo;
412  RMSummary->rm[i].n_pix++;
413  }
414  }
415 
416  // RBX loop
417  for(int sd=0;sd<7;sd++) for(int sect=1;sect<=18;sect++){
418  std::stringstream tempss;
419  tempss << std::setw(2) << std::setfill('0') << sect;
420  std::string rbx= subdets[sd]+tempss.str();
421 
422  double rbx_energy=0;int pix_mult=0; int n_zero=0; bool isValidRBX=false;
423  for(int rm=1;rm<=4;rm++){
424  int index=RMSummary->GetRMindex(rbx,rm);
425  if(index>0 && index<HcalFrontEndId::maxRmIndex){
426  rbx_energy+=RMs[index].energy;
427  pix_mult+=RMs[index].n_pix_lo;
428  n_zero+=RMs[index].n_zero;
429  isValidRBX=true;
430  }
431  }
432  if(isValidRBX){
433  PixelMult->Fill(pix_mult);
434  RBXEnergy->Fill(rbx_energy);
435  NZeroes->Fill(n_zero);
436  }
437  }
438 
439  if((ievt_%100)==0 && debug_>0)
440  std::cout <<ievt_<<"\t"<<NoisyEvents<<std::endl;
441  return;
442 }
443 
445 int first_rbx=0,last_rbx=0;
446  //double TIME=(double)(LastOrbitLS-FirstOrbitLS)/11223.0;
447  double TIME=23.0;
448  newLS=true;
449  if(TIME==0) return;
450 
451  for(int sd=0;sd<9;sd++){
452  if(sd==0){ first_rbx=0; last_rbx=18;} //HBM
453  if(sd==1){ first_rbx=18; last_rbx=36;} //HBP
454  if(sd==0 || sd==1){ // update HB plots
455  for(int rbx=first_rbx;rbx<last_rbx;rbx++)for(int rm=1;rm<=4;rm++){
456  int index=RMSummary->GetRMindex(HB_RBX[rbx],rm);
457  if(index<0 || index>=HcalFrontEndId::maxRmIndex) continue;
458  double val=RMSummary->rm[index].n_th_hi_LS/TIME;
459  if(val>SpikeThreshold){
460  HB_RBXmapSpikeCnt->Fill(rm,rbx+1,1);
461  //printf("%s %i %f (%f)\n",HO_RBX[rbx].c_str(),rm,RMSummary->rm[index].n_th_hi_LS/TIME,TIME);
462  }
463  RMSummary->rm[index].reset_LS();
464  }
465  }
466  if(sd==2){ first_rbx=0; last_rbx=18;} //HEM
467  if(sd==3){ first_rbx=18; last_rbx=36;} //HEP
468  if(sd==2 || sd==3){ // update HB plots
469  for(int rbx=first_rbx;rbx<last_rbx;rbx++)for(int rm=1;rm<=4;rm++){
470  int index=RMSummary->GetRMindex(HE_RBX[rbx],rm);
471  if(index<0 || index>=HcalFrontEndId::maxRmIndex) continue;
472  double val=RMSummary->rm[index].n_th_hi_LS/TIME;
473  if(val>SpikeThreshold){
474  HE_RBXmapSpikeCnt->Fill(rm,rbx+1,1);
475  //printf("%s %i %f (%f)\n",HO_RBX[rbx].c_str(),rm,RMSummary->rm[index].n_th_hi_LS/TIME,TIME);
476  }
477  RMSummary->rm[index].reset_LS();
478  }
479  }
480  if(sd==4){ first_rbx=6; last_rbx=12;} //HO1M
481  if(sd==5){ first_rbx=12; last_rbx=24;} //HO0
482  if(sd==6){ first_rbx=24; last_rbx=30;} //HO1P
483  if(sd>3){
484  for(int rbx=first_rbx;rbx<last_rbx;rbx++)for(int rm=1;rm<=4;rm++){
485  int index=RMSummary->GetRMindex(HO_RBX[rbx],rm);
486  if(index<0 || index>=HcalFrontEndId::maxRmIndex) continue;
487  double val=RMSummary->rm[index].n_th_hi_LS/TIME;
488  if(val>SpikeThreshold){
489  HO_RBXmapSpikeCnt->Fill(rm,rbx+1,1);
490  //printf("%s %i %f (%f)\n",HO_RBX[rbx].c_str(),rm,RMSummary->rm[index].n_th_hi_LS/TIME,TIME);
491  }
492  RMSummary->rm[index].reset_LS();
493  }
494  }
495  } //sd=0;sd<9
496 }
497 
499  int first_rbx=0;
500  double TIME=(double)(LastOrbit-FirstOrbit)/11223.0;
501  if(TIME==0) return;
502  for(int sd=0;sd<9;sd++){
503  if(sd==0){ first_rbx=0; } //HBM
504  if(sd==1){ first_rbx=18;} //HBP
505  if(sd==0 || sd==1){ // update HB plots
506  for(int rbx=0;rbx<18;rbx++)for(int rm=1;rm<=4;rm++){
507  int index=RMSummary->GetRMindex(HB_RBX[rbx+first_rbx],rm);
508  if(index<0 || index>=HcalFrontEndId::maxRmIndex) continue;
509  if(sd==0){
510  HBM_Rate50->setBinContent(rbx*4+rm,RMSummary->rm[index].n_th_hi/TIME);
511  HBM_Rate300->setBinContent(rbx*4+rm,RMSummary->rm[index].n_th_300/TIME);
512  }
513  if(sd==1){
514  HBP_Rate50->setBinContent(rbx*4+rm,RMSummary->rm[index].n_th_hi/TIME);
515  HBP_Rate300->setBinContent(rbx*4+rm,RMSummary->rm[index].n_th_300/TIME);
516  }
517  }
518  }
519  if(sd==2){ first_rbx=0;} //HEM
520  if(sd==3){ first_rbx=18;} //HEP
521  if(sd==2 || sd==3){ // update HB plots
522  for(int rbx=0;rbx<18;rbx++)for(int rm=1;rm<=4;rm++){
523  int index=RMSummary->GetRMindex(HE_RBX[rbx+first_rbx],rm);
524  if(index<0 || index>=HcalFrontEndId::maxRmIndex) continue;
525  if(sd==2){
526  HEM_Rate50->setBinContent(rbx*4+rm,RMSummary->rm[index].n_th_hi/TIME);
527  HEM_Rate300->setBinContent(rbx*4+rm,RMSummary->rm[index].n_th_300/TIME);
528  }
529  if(sd==3){
530  HEP_Rate50->setBinContent(rbx*4+rm,RMSummary->rm[index].n_th_hi/TIME);
531  HEP_Rate300->setBinContent(rbx*4+rm,RMSummary->rm[index].n_th_300/TIME);
532  }
533  }
534  }
535  int n=0;
536  if(sd==4){ first_rbx=6; n=6;} //HO1M
537  if(sd==5){ first_rbx=12;n=12;} //HO0
538  if(sd==6){ first_rbx=24;n=6;} //HO1P
539  if(sd>3){ // update HO plots
540  for(int rbx=0;rbx<n;rbx++)for(int rm=1;rm<=4;rm++){
541  int index=RMSummary->GetRMindex(HO_RBX[rbx+first_rbx],rm);
542  if(index<0 || index>=HcalFrontEndId::maxRmIndex) continue;
543  if(sd==4){
544  HO1M_Rate50->setBinContent(rbx*4*2+rm,RMSummary->rm[index].n_th_hi/TIME);
545  HO1M_Rate300->setBinContent(rbx*4*2+rm,RMSummary->rm[index].n_th_300/TIME);
546  }
547  if(sd==5){
548  HO0_Rate50->setBinContent(rbx*4+rm,RMSummary->rm[index].n_th_hi/TIME);
549  HO0_Rate300->setBinContent(rbx*4+rm,RMSummary->rm[index].n_th_300/TIME);
550  }
551  if(sd==5){
552  HO1P_Rate50->setBinContent(rbx*4*2+rm,RMSummary->rm[index].n_th_hi/TIME);
553  HO1P_Rate300->setBinContent(rbx*4+rm,RMSummary->rm[index].n_th_300/TIME);
554  }
555  }
556  }
557  } //sd=0;sd<9
558 }
559 
561 char RBX[20];
562 int RM;
563 float VAL1,VAL2,VAL3,VAL4,VAL5;
564 char str[500];
565  double TIME=(double)(LastOrbit-FirstOrbit)/11223.0;
566  if(TIME==0) return;
567  if(OutputFilePath.size()>0){
568  if(!Overwrite){
569  sprintf(str,"%sHcalDetDiagNoiseData_run%06i_%i.root",OutputFilePath.c_str(),run_number,dataset_seq_number);
570  }else{
571  sprintf(str,"%sHcalDetDiagNoiseData.root",OutputFilePath.c_str());
572  }
573  TFile *theFile = new TFile(str, "RECREATE");
574  if(!theFile->IsOpen()) return;
575  theFile->cd();
576  sprintf(str,"%d",run_number); TObjString run(str); run.Write("run number");
577  sprintf(str,"%d",ievt_); TObjString events(str); events.Write("Total events processed");
578  sprintf(str,"%d",dataset_seq_number); TObjString dsnum(str); dsnum.Write("Dataset number");
579  Long_t t; t=time(0); strftime(str,30,"%F %T",localtime(&t)); TObjString tm(str); tm.Write("Dataset creation time");
580 
581  TTree *tree =new TTree("HCAL Noise data","HCAL Noise data");
582  if(tree==0) return;
583  tree->Branch("RBX", &RBX, "RBX/C");
584  tree->Branch("rm", &RM, "rm/I");
585  tree->Branch("RATE_50", &VAL1, "RATE_50");
586  tree->Branch("RATE_300", &VAL2, "RATE_300");
587  tree->Branch("RATE_PIX1", &VAL3, "RATE_PIX1");
588  tree->Branch("RATE_PIX8", &VAL4, "RATE_PIX8");
589  tree->Branch("RATE_PIXMEAN", &VAL5, "RATE_PIXMEAN");
590  for(int rbx=0;rbx<36;rbx++) for(int rm=1;rm<=4;rm++){
591  int index=RMSummary->GetRMindex(HB_RBX[rbx],rm);
592  if(index<0 || index>=HcalFrontEndId::maxRmIndex) continue;
593  sprintf(RBX,"%s",HB_RBX[rbx]);
594  RM=rm;
595  VAL1=RMSummary->rm[index].n_th_hi/TIME;
596  VAL2=RMSummary->rm[index].n_th_300/TIME;
597  VAL3=RMSummary->rm[index].n_pix_1/TIME;
598  VAL4=RMSummary->rm[index].n_pix_8/TIME;
599  if(RMSummary->rm[index].n_pix>0)VAL5=RMSummary->rm[index].pix/RMSummary->rm[index].n_pix; else VAL5=0;
600  tree->Fill();
601  }
602  for(int rbx=0;rbx<36;rbx++) for(int rm=1;rm<=4;rm++){
603  int index=RMSummary->GetRMindex(HE_RBX[rbx],rm);
604  if(index<0 || index>=HcalFrontEndId::maxRmIndex) continue;
605  sprintf(RBX,"%s",HE_RBX[rbx]);
606  RM=rm;
607  VAL1=RMSummary->rm[index].n_th_hi/TIME;
608  VAL2=RMSummary->rm[index].n_th_300/TIME;
609  VAL3=RMSummary->rm[index].n_pix_1/TIME;
610  VAL4=RMSummary->rm[index].n_pix_8/TIME;
611  if(RMSummary->rm[index].n_pix>0)VAL5=RMSummary->rm[index].pix/RMSummary->rm[index].n_pix; else VAL5=0;
612  tree->Fill();
613  }
614  for(int rbx=0;rbx<36;rbx++) for(int rm=1;rm<=4;rm++){
615  int index=RMSummary->GetRMindex(HO_RBX[rbx],rm);
616  if(index<0 || index>=HcalFrontEndId::maxRmIndex) continue;
617  sprintf(RBX,"%s",HO_RBX[rbx]);
618  RM=rm;
619  VAL1=RMSummary->rm[index].n_th_hi/TIME;
620  VAL2=RMSummary->rm[index].n_th_300/TIME;
621  VAL3=RMSummary->rm[index].n_pix_1/TIME;
622  VAL4=RMSummary->rm[index].n_pix_8/TIME;
623  if(RMSummary->rm[index].n_pix>0)VAL5=RMSummary->rm[index].pix/RMSummary->rm[index].n_pix; else VAL5=0;
624  tree->Fill();
625  }
626  theFile->Write();
627  theFile->Close();
628  dataset_seq_number++;
629 
630  }
631 }
632 
633 
635 
636 HcalDetDiagNoiseMonitor::~HcalDetDiagNoiseMonitor(){if(LocalRun) UpdateHistos(); SaveRates(); }
637 
RunNumber_t run() const
Definition: EventID.h:42
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
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:872
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
std::vector< HBHEDataFrame >::const_iterator const_iterator
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
#define NULL
Definition: scimark2.h:8
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
int iEvent
Definition: GenABIO.cc:243
void analyze(edm::Event const &e, edm::EventSetup const &s)
virtual void beginRun(const edm::Run &run, const edm::EventSetup &c)
int GetRMindex(const std::string &rbx, int rm)
void removeContents(void)
erase all monitoring elements in current directory (not including subfolders);
Definition: DQMStore.cc:2764
const T & max(const T &a, const T &b)
int rmIndex() const
constexpr char const * HB_RBX[36]
constexpr char const * HO_RBX[36]
string rm
Definition: submit.py:76
static const int maxRmIndex
std::vector< bool > TechnicalTriggerWord
technical trigger bits (64 bits)
bool isValid() const
Definition: HandleBase.h:76
DQMStore * dbe_
DEFINE_FWK_MODULE(CosmicTrackingParticleSelector)
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
double sd
constexpr char const * subdets[11]
constexpr float adc2fC[128]
edm::EventID id() const
Definition: EventBase.h:56
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:28
tuple cout
Definition: gather_cfg.py:121
dictionary rawdata
Definition: lumiPlot.py:393
HcalDetDiagNoiseMonitor(const edm::ParameterSet &ps)
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:779
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:1000
virtual void setup(void)
void reset(double vett[256])
Definition: TPedValues.cc:11
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
#define constexpr
void beginRun(const edm::Run &run, const edm::EventSetup &c)
Definition: Run.h:41
constexpr char const * HE_RBX[36]