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