CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorMonitorModule.cc
Go to the documentation of this file.
6 
7 //**************************************************************//
8 //***************** CastorMonitorModule ******************//
9 //***************** Author: Dmytro Volyanskyy ******************//
10 //***************** Date : 22.11.2008 (first version) *********//
11 //**************************************************************//
17 
18 //==================================================================//
19 //======================= Constructor ==============================//
20 //==================================================================//
22  {
23 
24 
26  inputLabelRaw_ = ps.getParameter<edm::InputTag>("rawLabel");
27  inputLabelReport_ = ps.getParameter<edm::InputTag>("unpackerReportLabel");
28  inputLabelDigi_ = ps.getParameter<edm::InputTag>("digiLabel");
29  inputLabelRecHitCASTOR_ = ps.getParameter<edm::InputTag>("CastorRecHitLabel");
30  inputLabelCastorTowers_ = ps.getParameter<edm::InputTag>("CastorTowerLabel");
31  fVerbosity = ps.getUntrackedParameter<int>("debug", 0); //-- show debug
32  showTiming_ = ps.getUntrackedParameter<bool>("showTiming", false); //-- show CPU time
33  dump2database_ = ps.getUntrackedParameter<bool>("dump2database",false); //-- dumps output to database file
34 
35  if(fVerbosity>0) std::cout << "CastorMonitorModule Constructor (start)" << std::endl;
36 
38  irun_=0;
39  ilumisec_=0;
40  ievent_=0;
41  itime_=0;
42  ibunch_=0;
43  actonLS_=false;
44 
45  meStatus_=0; meRunType_=0;
46  meEvtMask_=0; meFEDS_=0;
47  // meLatency_=0; // PK: eliminate - proposed change from reproducibility tests; is it needed?
48  meQuality_=0;
49  fedsListed_ = false;
50 
51  DigiMon_ = NULL;
52  RecHitMon_ = NULL;
53  CQMon_ = NULL;
54  HIMon_ = NULL;
55  PSMon_ = NULL;
56  //I think Event products is done by default
58  DataIntMon_ = NULL;
59 
60  LedMon_ = NULL; //not used for the time being
61 
64 
67 
68  //set Tokens
69  inputLabelRawToken_ = consumes<FEDRawDataCollection>(ps.getParameter<edm::InputTag>("rawLabel"));
70  inputLabelReportToken_ = consumes<HcalUnpackerReport>(ps.getParameter<edm::InputTag>("unpackerReportLabel"));
71  inputLabelDigiToken_ = consumes<CastorDigiCollection>(ps.getParameter<edm::InputTag>("digiLabel"));
72  inputLabelRecHitCASTORToken_ = consumes<CastorRecHitCollection>(ps.getParameter<edm::InputTag>("CastorRecHitLabel"));
73 
74  //---------------------- DigiMonitor ----------------------//
75  if ( ps.getUntrackedParameter<bool>("DigiMonitor", false) ) {
76  if(fVerbosity>0) std::cout << "CastorMonitorModule: Digi monitor flag is on...." << std::endl;
78  DigiMon_->setup(ps, dbe_);
79  }
80  //------------------------------------------------------------//
81 
83  if ( ps.getUntrackedParameter<bool>("RecHitMonitor", false) ) {
84  if(fVerbosity>0) std::cout << "CastorMonitorModule: RecHit monitor flag is on...." << std::endl;
86  RecHitMon_->setup(ps, dbe_);
87  }
88  //-------------------------------------------------------------//
89 
91  if ( ps.getUntrackedParameter<bool>("ChannelQualityMonitor", false) ) {
92  if(fVerbosity>0) std::cout << "CastorChannelQualityMonitor: CQ monitor flag is on...." << std::endl;
94  CQMon_->setup(ps, dbe_);
95  }
96  //-------------------------------------------------------------//
97 
99  if ( ps.getUntrackedParameter<bool>("HIMonitor", false) ) {
100  if(fVerbosity>0) std::cout << "CastorMonitorModule: HI monitor flag is on...." << std::endl;
101  HIMon_ = new CastorHIMonitor();
102  HIMon_->setup(ps, dbe_);
103  }
104  //-------------------------------------------------------------//
105 
106  //---------------------- PSMonitor ----------------------//
107  if ( ps.getUntrackedParameter<bool>("PSMonitor", false) ) {
108  if(fVerbosity>0) std::cout << "CastorMonitorModule: PS monitor flag is on...." << std::endl;
109  PSMon_ = new CastorPSMonitor();
110  PSMon_->setup(ps, dbe_);
111  }
112  //------------------------------------------------------------//
113 
114 
115  //---------------------- Tower Jet Monitor --------------------//
116  if ( ps.getUntrackedParameter<bool>("TowerJetMonitor", false) ) {
117  if(fVerbosity>0) std::cout << "CastorMonitorModule: Tower Jet monitor flag is on...." << std::endl;
119  TowerJetMon_->setup(ps, dbe_);
120  }
121  //------------------------------------------------------------//
122 
123 //---------------------- Data Integrity Monitor ----------------------//
124  if ( ps.getUntrackedParameter<bool>("DataIntMonitor", false) ) {
125  if(fVerbosity>0) std::cout << "CastorMonitorModule: Data Integrity Monitor flag is on...." << std::endl;
127  DataIntMon_->setup(ps, dbe_);
128  }
129  //------------------------------------------------------------//
130 
131  // take it away for the time being
133  if ( ps.getUntrackedParameter<bool>("LEDMonitor", false) ) {
134  if(fVerbosity>0) std::cout << "CastorMonitorModule: LED monitor flag is on...." << std::endl;
135  LedMon_ = new CastorLEDMonitor();
136  LedMon_->setup(ps, dbe_);
137  }
138  //-------------------------------------------------------------//
139 
140 
141 
143 
145  prescaleEvt_ = ps.getUntrackedParameter<int>("diagnosticPrescaleEvt", -1);
146  if(fVerbosity>1) std::cout << "===>CastorMonitor event prescale = " << prescaleEvt_ << " event(s)"<< std::endl;
147 
148  prescaleLS_ = ps.getUntrackedParameter<int>("diagnosticPrescaleLS", -1);
149  if(fVerbosity>1) std::cout << "===>CastorMonitor lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< std::endl;
150  if (prescaleLS_>0) actonLS_=true;
151 
152  prescaleUpdate_ = ps.getUntrackedParameter<int>("diagnosticPrescaleUpdate", -1);
153  if(fVerbosity>1) std::cout << "===>CastorMonitor update prescale = " << prescaleUpdate_ << " update(s)"<< std::endl;
154 
155  prescaleTime_ = ps.getUntrackedParameter<int>("diagnosticPrescaleTime", -1);
156  if(fVerbosity>1) std::cout << "===>CastorMonitor time prescale = " << prescaleTime_ << " minute(s)"<< std::endl;
157 
159  std::string subsystemname = ps.getUntrackedParameter<std::string>("subSystemFolder", "Castor") ;
160  if(fVerbosity>1) std::cout << "===>CastorMonitor name = " << subsystemname << std::endl;
161  rootFolder_ = subsystemname + "/";
162 
163  if ( dbe_ != NULL ){
165  }
166 
167 
168  gettimeofday(&psTime_.updateTV,NULL);
170  psTime_.updateTime = (psTime_.updateTV.tv_sec*1000.0+psTime_.updateTV.tv_usec/1000.0);
171  psTime_.updateTime /= 1000.0;
172  psTime_.elapsedTime=0;
173  psTime_.vetoTime=psTime_.updateTime;
174 
175  if(fVerbosity>0) std::cout << "CastorMonitorModule Constructor (end)" << std::endl;
176 
177 }
178 
179 
180 //==================================================================//
181 //======================= Destructor ===============================//
182 //==================================================================//
184 
185 // if (dbe_){
186 // if(DigiMon_!=NULL) { DigiMon_->clearME();}
187 // if(RecHitMon_!=NULL) { RecHitMon_->clearME();}
188 // if(LedMon_!=NULL) { LedMon_->clearME();}
189 // if(PSMon_!=NULL) { LedMon_->clearME();}
190 // if(HIMon_!=NULL) { HIMon_->clearME();}
191 // dbe_->setCurrentFolder(rootFolder_);
192 // dbe_->removeContents();
193 // }
194 //
195 // if(DigiMon_!=NULL) { delete DigiMon_; DigiMon_=NULL; }
196 // if(RecHitMon_!=NULL) { delete RecHitMon_; RecHitMon_=NULL; }
197 // if(HIMon_!=NULL) { delete HIMon_; HIMon_=NULL; }
198 // if(LedMon_!=NULL) { delete LedMon_; LedMon_=NULL; }
199 // delete evtSel_; evtSel_ = NULL;
200 
201 }
202 
203 
204 //=================================================================//
205 //========================== beginJob =============================//
206 //================================================================//
208  {
209  if (fVerbosity>0) std::cout << " " << std::endl;
210  if (fVerbosity>0) std::cout << "CastorMonitorModule::beginJob (start)" << std::endl;
211 
212  ievt_ = 0;
213  ievt_pre_=0;
214 
215  if (fVerbosity>0) std::cout << "CastorMonitorModule::beginJob (end)" << std::endl;
216 
217  return;
218 }
219 
220 
221 //=================================================================//
222 //========================== beginRun =============================//
223 //================================================================//
225  {
226  if (fVerbosity>0) std::cout <<" "<<std::endl;
227  if (fVerbosity>0) std::cout << "CastorMonitorModule::beginRun (start)" << std::endl;
228 
229  fedsListed_ = false;
230  reset();
231 
232  if ( dbe_ != NULL )
233  {
234 
236  dbe_->setCurrentFolder(rootFolder_+"CastorEventProducts");
237  meEVT_ = dbe_->bookInt("Event Number");
238  CastorEventProduct =dbe_->book2D("CastorEventProduct","CastorEventProduct",3,0,3,1,0,1);
239  TH2F* hCastorEventProduct =CastorEventProduct->getTH2F();
240  hCastorEventProduct->GetXaxis()->SetBinLabel(1,"RawData");
241  hCastorEventProduct->GetXaxis()->SetBinLabel(2,"CastorDigi");
242  hCastorEventProduct->GetXaxis()->SetBinLabel(3,"CastorRecHits");
243  hCastorEventProduct->GetYaxis()->SetBinLabel(1,"Status");
244  hCastorEventProduct->SetBinContent(1,1,-1);
245  hCastorEventProduct->SetBinContent(2,1,-1);
246  hCastorEventProduct->SetBinContent(3,1,-1);
247  hCastorEventProduct->SetOption("textcolz");
248 
249  dbe_->setCurrentFolder(rootFolder_+"DQM Job Status" );
250  meStatus_ = dbe_->bookInt("STATUS");
251  meRunType_ = dbe_->bookInt("RUN TYPE");
252  meEvtMask_ = dbe_->bookInt("EVT MASK");
253  meFEDS_ = dbe_->book1D("FEDs Unpacked","FEDs Unpacked",100,660,759);
254  meCASTOR_ = dbe_->bookInt("CASTORpresent");
256  // meLatency_ = dbe_->book1D("Process Latency","Process Latency",2000,0,10); // PK: eliminate
257  meQuality_ = dbe_->book1D("Quality Status","Quality Status",100,0,1);
258  meStatus_->Fill(0);
259  meRunType_->Fill(-1);
260  meEvtMask_->Fill(-1);
262  meCASTOR_->Fill(0);
263  }
264  else{
265  if(fVerbosity>0) std::cout << "CastorMonitorModule::beginRun - NO DQMStore service" << std::endl;
266  }
267 
268 
269 // beginRun initiations for all modules
270  if (DigiMon_ != NULL) { DigiMon_->beginRun(iSetup); }
271  if (RecHitMon_ != NULL) { RecHitMon_->beginRun(iSetup); }
272  if (CQMon_ != NULL) { CQMon_->beginRun(iRun, iSetup); }
273  if (HIMon_ != NULL) { HIMon_->beginRun(iSetup); }
274  if (PSMon_ != NULL) { PSMon_->beginRun(iRun, iSetup); }
275  if (TowerJetMon_!= NULL) { TowerJetMon_->beginRun(iRun, iSetup); }
276  if (DataIntMon_ != NULL) { DataIntMon_->beginRun(iSetup); }
277 
278  if (LedMon_ != NULL) { LedMon_->beginRun(iSetup); }
279 
281  iSetup.get<CastorDbRecord>().get(conditions_);
282 
284  iSetup.get<CastorPedestalsRcd>().get(dbPedestals);
285  if(!dbPedestals.isValid() && fVerbosity>0) std::cout << "CASTOR has no CastorPedestals in the CondDB !!!" << std::endl;
286 
288  float sigma_averaged;
289  unsigned int iChannel = 0;
290  std::vector<DetId> channels = dbPedestals->getAllChannels();
291 
293  for (std::vector<DetId>::iterator ch=channels.begin(); ch!=channels.end(); ch++) {
294  const CastorPedestal * pedestals_mean = dbPedestals->getValues(*ch);
295  sigma_averaged = 0.;
296 
298  for (short unsigned int iCapId = 0; iCapId < 4; iCapId++){
299  sigma_averaged += sqrt(pedestals_mean->getWidth(iCapId));
300  };
301 
303  fPedestalNSigmaAverage[HcalCastorDetId(*ch).module()-1][HcalCastorDetId(*ch).sector()-1] = sigma_averaged/4;
304  iChannel++;
305  };
306 
307  if(iChannel<224 && fVerbosity>0) std::cout << "There are less that 224 channels in CastorPedestalsRcd record !!!" << std::endl;
308 
309  if(fVerbosity>0) std::cout << "CastorMonitorModule::beginRun (end)" << std::endl;
310 
311  return;
312 }
313 
314 //=================================================================//
315 //========================== beginLuminosityBlock ================//
316 //================================================================//
318  const edm::EventSetup& context) {
319 
320  if(actonLS_ && !prescale()){
322  }
323 }
324 
325 
326 //================================================================//
327 //========================== endLuminosityBlock ==================//
328 //================================================================//
330  const edm::EventSetup& context) {
331  if(actonLS_ && !prescale()){
333  }
334 }
335 
336 //=================================================================//
337 //========================== endRun ===============================//
338 //=================================================================//
340 {
341  if (fVerbosity>0) std::cout <<" "<<std::endl;
342  if (fVerbosity>0) std::cout <<"CastorMonitorModule::endRun (start)"<<std::endl;
343 
345  if (DigiMon_!=NULL) //************ DigiMon_->fillPedestalHistos(); //FIX
346 
347  if (fVerbosity>0) std::cout <<"CastorMonitorModule::endRun (end)"<<std::endl;
348 
349  return;
350 }
351 
352 //=================================================================//
353 //========================== endJob ===============================//
354 //=================================================================//
356  {
357  if (fVerbosity>0) std::cout <<"CastorMonitorModule::endJob (start)"<<std::endl;
358 
359  //if ( meStatus_ ) meStatus_->Fill(2);
360 
361  if(DigiMon_!=NULL) DigiMon_->done();
362  if(RecHitMon_!=NULL) RecHitMon_->done();
363  if(CQMon_!=NULL) CQMon_->done();
364  if(HIMon_!=NULL) HIMon_->done();
365  if(PSMon_!=NULL) PSMon_->done();
367  if(DataIntMon_!=NULL) DataIntMon_ ->done();
368 
369  if(LedMon_!=NULL) LedMon_->done();
370 
371  /* LEAVE IT OUT FOR THE MOMENT
372  // TO DUMP THE OUTPUT TO DATABASE FILE
373  if (dump2database_){
374 
375  }
376  */
377 
378  if (fVerbosity>0) std::cout <<"CastorMonitorModule::endJob (end)"<<std::endl;
379 
380  return;
381 }
382 
383 
384 //=================================================================//
385 //========================== reset ===============================//
386 //=================================================================//
388  {
389  if (fVerbosity>0) std::cout <<" "<<std::endl;
390  if (fVerbosity>0) std::cout <<"CastorMonitorModule::reset (start)"<<std::endl;
391 
392  if(DigiMon_!=NULL) DigiMon_->reset();
394  if(CQMon_!=NULL) CQMon_->reset();
395  if(HIMon_!=NULL) HIMon_->reset();
396  if(PSMon_!=NULL) PSMon_->reset();
399 
400  if(LedMon_!=NULL) LedMon_->reset();
401 
402  if (fVerbosity>0) std::cout <<"CastorMonitorModule::reset (end)"<<std::endl;
403  }
404 
405 
406 //=================================================================//
407 //========================== analyze ===============================//
408 //=================================================================//
410  {
411  if (fVerbosity>0) std::cout <<" "<<std::endl;
412  if (fVerbosity>0) std::cout <<"CastorMonitorModule::analyze (start)"<<std::endl;
413 
414  using namespace edm;
415 
416 
418  irun_ = iEvent.id().run();
419  ilumisec_ = iEvent.luminosityBlock();
420  ievent_ = iEvent.id().event();
421  itime_ = iEvent.time().value();
422  ibunch_ = iEvent.bunchCrossing();
423 
424 
425  if (fVerbosity>1) {
426  std::cout << "==> CastorMonitorModule: evts: "<< nevt_ << ", run: " << irun_ << ", LS: " << ilumisec_ << std::endl;
427  std::cout << " evt: " << ievent_ << ", time: " << itime_ <<"\t counter = "<< ievt_pre_<< "\t total count = "<<ievt_<<std::endl;
428  }
429 
431  ievt_++;
432 
434  ievt_pre_++; // need to increment counter before calling prescale
435  if(prescale()) return;
436 
437 
438  // meLatency_->Fill(psTime_.elapsedTime);
439 
440 
442  // add in DO_HCAL_TPMON, DO_HCAL_CTMON ?(in CastorMonitorSelector.h)
443  /* FIX
444  // int trigMask=0;
445  if(mtccMon_==NULL){
446  evtSel_->processEvent(e);
447  evtMask = evtSel_->getEventMask();
448  // trigMask = evtSel_->getTriggerMask();
449  }
450  */
451  if ( dbe_ ){
452  meStatus_->Fill(1);
453  meEvtMask_->Fill(evtMask);
454  }
455 
457  bool rawOK_ = true;
458  bool digiOK_ = true;
459  bool rechitOK_ = true;
460 
461  //-- TAKE IT AWAY for the time being
464  iEvent.getByToken(inputLabelRawToken_, RawData);
465  if (!RawData.isValid()) {
466  rawOK_=false;
467  if (fVerbosity>0) std::cout << "RAW DATA NOT FOUND!" << std::endl;
468  }
469 
470 
473  if (!report.isValid()) {
474  rawOK_=false;
475  if (fVerbosity>0) std::cout << "UNPACK REPORT HAS FAILED!" << std::endl;
476  }
477  else
478  {
479  if(!fedsListed_){
480  const std::vector<int> feds = (*report).getFedsUnpacked();
481  for(unsigned int f=0; f<feds.size(); f++){
482  meFEDS_->Fill(feds[f]);
483  }
484  fedsListed_ = true;
485  }
486  }
487 
488  //---------------------------------------------------------------//
489  //------------------- try to get digis ------------------------//
490  //---------------------------------------------------------------//
491 
493  iEvent.getByToken(inputLabelDigiToken_, CastorDigi);
494  if (!CastorDigi.isValid()) {
495  digiOK_=false;
496  if (fVerbosity>0) std::cout << "DIGI DATA NOT FOUND!" << std::endl;
497  }
498 
499 
500 
503  //if ( checkCASTOR_ )
504  // CheckCastorStatus(*RawData,*report,*readoutMap_,*CastorDigi);
505 
506 
507  //---------------------------------------------------------------//
508  //------------------- try to get RecHits ------------------------//
509  //---------------------------------------------------------------//
511  iEvent.getByToken(inputLabelRecHitCASTORToken_, CastorHits);
512  if (!CastorHits.isValid()) {
513  rechitOK_ = false;
514  if (fVerbosity>0) std::cout << "RECO DATA NOT FOUND!" << std::endl;
515  }
516 
517 
519  if(ievt_%10 == 0) {
520 
521  TH2F* hCastorEventProduct=CastorEventProduct->getTH2F();
522  hCastorEventProduct->SetBinContent(1,1,int(rawOK_));
523  hCastorEventProduct->SetBinContent(2,1,int(digiOK_));
524  hCastorEventProduct->SetBinContent(3,1,int(rechitOK_));
525 
526  if(fVerbosity>1) {
527  std::cout << " RAW Data ==> " << rawOK_<< std::endl;
528  std::cout << " Digis ==> " << digiOK_<< std::endl;
529  std::cout << " RecHits ==> " << rechitOK_<< std::endl;
530  }
531 
532  }
533 
534  //------------------------------------------------------------//
535  //---------------- Run the configured tasks ------------------//
536  //-------------- protect against missing products -----------//
537  //-----------------------------------------------------------//
538 
539  if (showTiming_){
541  }
542 
543  //----------------- Digi monitor task ------------------//
544  // if((DigiMon_!=NULL) && (evtMask&DO_CASTOR_PED_CALIBMON) && digiOK_)
545  if(digiOK_) DigiMon_->processEvent(*CastorDigi,*conditions_);
546  if (showTiming_){
547  cpu_timer.stop();
548  if (DigiMon_!=NULL) std::cout <<"TIMER:: DIGI MONITOR ->"<<cpu_timer.cpuTime()<<std::endl;
550  }
551 
552 
553  //----------------- Rec Hit monitor task -------------------------//
554  // if((RecHitMon_ != NULL) && (evtMask&DO_CASTOR_RECHITMON) && rechitOK_)
555  if(rechitOK_) RecHitMon_->processEvent(*CastorHits);
556  if (showTiming_){
557  cpu_timer.stop();
558  if (RecHitMon_!=NULL) std::cout <<"TIMER:: RECHIT MONITOR ->"<<cpu_timer.cpuTime()<<std::endl;
560  }
561 
562  //----------------- Channel Quality Monitor task -------------------------//
563  if(rechitOK_) CQMon_->processEvent(*CastorHits);
564  if (showTiming_){
565  cpu_timer.stop();
566  if (CQMon_!=NULL) std::cout <<"TIMER:: CHANNELQUALITY MONITOR ->"<<cpu_timer.cpuTime()<<std::endl;
568  }
569 
571 
573  eventSetup.get<CastorElectronicsMapRcd>().get(refEMap);
574  const CastorElectronicsMap* myRefEMap = refEMap.product();
575  listEMap = myRefEMap->allPrecisionId();
576 
577 //----------------- Heavy Ion monitor task -------------------------//
578  if(rechitOK_ && digiOK_ ) HIMon_->processEvent(*CastorHits, *CastorDigi, *conditions_);
579  if (showTiming_){
580  cpu_timer.stop();
581  if (HIMon_!=NULL) std::cout <<"TIMER:: HI MONITOR ->"<<cpu_timer.cpuTime()<<std::endl;
583  }
584 
585 //----------------- PS monitor task -------------------------//
587  if (showTiming_) {
588  cpu_timer.stop();
589  if (PSMon_!=NULL) std::cout <<"TIMER:: PULSE SHAPE ->"<<cpu_timer.cpuTime()<<std::endl;
591  }
592 
593 //----------------- PS monitor task -------------------------//
594 // if(rechitOK_ && digiOK_ ) PSMon_->processEvent(*CastorDigi, *conditions_, listEMap, ibunch_, fPedestalNSigmaAverage);
595 
596 
597 //----------------- Tower Jet monitor task -------------------------//
598 
599  if(rechitOK_)
600  {
601  if (showTiming_){
602  cpu_timer.stop();
603  if (TowerJetMon_!=NULL) std::cout <<"TIMER:: TOWER JET MONITOR ->"<<cpu_timer.cpuTime()<<std::endl;
605  }
606  }
607 
608 
609 
610 
611 //----------------- Data Integrity monitor task -------------------------//
612  if(rechitOK_ && digiOK_ ) DataIntMon_->processEvent(*RawData, *report, *myRefEMap);
613  if (showTiming_){
614  cpu_timer.stop();
615  if (DataIntMon_!=NULL) std::cout <<"TIMER:: DATA INTEGRITY MONITOR ->"<<cpu_timer.cpuTime()<<std::endl;
617  }
618 
619 
621 
622  //---------------- LED monitor task ------------------------//
623  // if((LedMon_!=NULL) && (evtMask&DO_HCAL_LED_CALIBMON) && digiOK_)
624  if(digiOK_) LedMon_->processEvent(*CastorDigi,*conditions_);
625  if (showTiming_){
626  cpu_timer.stop();
627  if (LedMon_!=NULL) std::cout <<"TIMER:: LED MONITOR ->"<<cpu_timer.cpuTime()<<std::endl;
629  }
630 
631  //---------------- Pulse Shape monitor task ------------------------//
632 
633  if(fVerbosity>1 && ievt_%100 == 0)
634  std::cout << "CastorMonitorModule: processed " << ievt_ << " events" << std::endl;
635 
636 
638  meEVT_->Fill(ievt_);
639 
640  if (fVerbosity>0) std::cout <<"CastorMonitorModule::analyze (end)"<<std::endl;
641 
642  return;
643  }
644 
645 
646 
647 
648 //=====================================================================//
649 //========================== prescale ===============================//
650 //===================================================================//
654  {
655  if (fVerbosity>0) std::cout <<"CastorMonitorModule::prescale (start)"<<std::endl;
656 
657  gettimeofday(&psTime_.updateTV,NULL);
658  double time = (psTime_.updateTV.tv_sec*1000.0+psTime_.updateTV.tv_usec/1000.0);
659  time/= (1000.0);
660  psTime_.elapsedTime = time - psTime_.updateTime;
661  psTime_.updateTime = time;
663  bool evtPS = prescaleEvt_>0;
664  bool lsPS = prescaleLS_>0;
665  bool timePS = prescaleTime_>0;
666  bool updatePS = prescaleUpdate_>0;
667 
669  if(!evtPS && !lsPS && !timePS && !updatePS)
670  {
671  if (fVerbosity>0) std::cout <<"CastorMonitorModule::prescale (end - permature but fine!)"<<std::endl;
672  return false;
673  }
675  if(lsPS && (ilumisec_%prescaleLS_)!=0) lsPS = false; //-- LS veto
676  //if(evtPS && (ievent_%prescaleEvt_)!=0) evtPS = false; //evt # veto
677  if (evtPS && (ievt_pre_%prescaleEvt_)!=0) evtPS = false;
678  if(timePS)
679  {
680  double elapsed = (psTime_.updateTime - psTime_.vetoTime)/60.0;
681  if(elapsed<prescaleTime_){
682  timePS = false; //-- timestamp veto
683  psTime_.vetoTime = psTime_.updateTime;
684  }
685  }
686 
687  // if(prescaleUpdate_>0 && (nupdates_%prescaleUpdate_)==0) updatePS=false; ///need to define what "updates" means
688 
689  if (fVerbosity>1)
690  {
691  std::cout<<"CastorMonitorModule::prescale evt: "<<ievent_<<"/"<<evtPS<<", ";
692  std::cout <<"ls: "<<ilumisec_<<"/"<<lsPS<<",";
693  std::cout <<"time: "<<psTime_.updateTime - psTime_.vetoTime<<"/"<<timePS<<std::endl;
694  }
695 
696  if (fVerbosity>0) std::cout <<"CastorMonitorModule::prescale (end)"<<std::endl;
697 
699  if(evtPS || lsPS || timePS) return false;
700  return true;
701 }
702 
703 
704 
705 //====================================================================//
706 //=================== CheckCastorStatus =============================//
707 //====================================================================//
710 
712  const HcalUnpackerReport& report,
713  const CastorElectronicsMap& emap,
714  const CastorDigiCollection& CastorDigi
715  )
716 {
717 
719  //vector<int> fedUnpackList;
721  // for (int i=FEDNumbering::getHcalFEDIds().first; i<=FEDNumbering::getHcalFEDIds().second; i++)
722  // {
723  // fedUnpackList.push_back(i);
724  // }
725  // for (std::vector<int>::const_iterator i=fedUnpackList.begin(); i!=fedUnpackList.end();++i)
726  // {
727  // const FEDRawData& fed = RawData.FEDData(*i);
728  // if (fed.size()<12) continue; //-- Was 16 !
730  // const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(fed.data());
731  // if (!dccHeader) return;
732  // int dccid=dccHeader->getSourceId();
733 
735  // ////---- Castor FED numbering of DCCs= [690 -693]
736  // if (dccid >= 690 && dccid <=693){
737  // if ( CastorDigi.size()>0){
738  // meCASTOR_->Fill(1);
739  // }
740  // else {meCASTOR_->Fill(0); }
741  // }
742  // else{ meCASTOR_->Fill(-1); }
743  // }
744  return;
745 }
746 
750 
RunNumber_t run() const
Definition: EventID.h:42
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * meCASTOR_
MonitorElement * meQuality_
void processEvent(const CastorRecHitCollection &castorHits, const CastorDigiCollection &cast, const CastorDbService &cond)
void endRun(const edm::Run &run, const edm::EventSetup &eventSetup)
void start()
Definition: CPUTimer.cc:74
int sector() const
get the sector (1-16)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:928
void beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup)
void analyze(const edm::Event &iEvent, const edm::EventSetup &eventSetup)
void beginRun(const edm::EventSetup &iSetup)
edm::InputTag inputLabelCastorTowers_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
void setup(const edm::ParameterSet &ps, DQMStore *dbe)
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &eventSetup)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void processEvent(const CastorDigiCollection &castorDigis, const CastorDbService &conditions, const std::vector< HcalGenericDetId > &listEMap, int iBunch, float PedSigmaInChannel[14][16])
edm::EDGetTokenT< CastorRecHitCollection > inputLabelRecHitCASTORToken_
edm::ESHandle< CastorDbService > conditions_
int bunchCrossing() const
Definition: EventBase.h:62
void beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup)
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
CastorLEDMonitor * LedMon_
void reset()
Definition: CPUTimer.cc:107
#define NULL
Definition: scimark2.h:8
void beginRun(const edm::Run &iRun, const edm::EventSetup &eventSetup)
MonitorElement * meRunType_
void setup(const edm::ParameterSet &ps, DQMStore *dbe)
int module() const
get the module (1-2 for EM, 1-12 for HAD)
edm::ESHandle< CastorPedestals > dbPedestals
float getWidth(int fCapId) const
get width for capId = 0..3
void beginRun(const edm::EventSetup &iSetup)
void beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup)
void Fill(long long x)
edm::InputTag inputLabelRaw_
tuple report
Definition: zeeHLT_cff.py:9
static const int DO_CASTOR_RECHITMON
edm::InputTag inputLabelDigi_
int iEvent
Definition: GenABIO.cc:230
CastorTowerJetMonitor * TowerJetMon_
std::vector< HcalGenericDetId > listEMap
CastorMonitorModule(const edm::ParameterSet &ps)
edm::InputTag inputLabelRecHitCASTOR_
T sqrt(T t)
Definition: SSEVec.h:48
void processEvent(const CastorDigiCollection &cast, const CastorDbService &cond)
void setup(const edm::ParameterSet &ps, DQMStore *dbe)
edm::InputTag inputLabelReport_
double f[11][100]
CastorMonitorSelector * evtSel_
CastorDigiMonitor * DigiMon_
Times stop()
Definition: CPUTimer.cc:94
void setup(const edm::ParameterSet &ps, DQMStore *dbe)
MonitorElement * meFEDS_
edm::EDGetTokenT< CastorDigiCollection > inputLabelDigiToken_
MonitorElement * meEvtMask_
struct CastorMonitorModule::@255 psTime_
void setup(const edm::ParameterSet &ps, DQMStore *dbe)
void setup(const edm::ParameterSet &ps, DQMStore *dbe)
void CheckCastorStatus(const FEDRawDataCollection &rawraw, const HcalUnpackerReport &report, const CastorElectronicsMap &emap, const CastorDigiCollection &castordigi)
void beginRun(const edm::EventSetup &iSetup)
MonitorElement * meStatus_
double cpuTime() const
Definition: CPUTimer.cc:158
CastorDataIntegrityMonitor * DataIntMon_
void processEvent(const CastorRecHitCollection &castorHits)
const T & get() const
Definition: EventSetup.h:55
edm::EDGetTokenT< FEDRawDataCollection > inputLabelRawToken_
void beginRun(const edm::EventSetup &iSetup)
void processEvent(const FEDRawDataCollection &RawData, const HcalUnpackerReport &report, const CastorElectronicsMap &emap)
void setup(const edm::ParameterSet &ps, DQMStore *dbe)
static const int DO_CASTOR_PED_CALIBMON
MonitorElement * CastorEventProduct
edm::EventID id() const
Definition: EventBase.h:56
CastorPSMonitor * PSMon_
CastorChannelQualityMonitor * CQMon_
void beginRun(const edm::EventSetup &iSetup)
void processEvent(const CastorDigiCollection &cast, const CastorDbService &cond)
float fPedestalNSigmaAverage[14][16]
void setup(const edm::ParameterSet &ps, DQMStore *dbe)
CastorRecHitMonitor * RecHitMon_
tuple cout
Definition: gather_cfg.py:121
void processEvent(const CastorRecHitCollection &castorHits)
virtual void done()
TH2F * getTH2F(void) const
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &eventSetup)
bool isValid() const
Definition: ESHandle.h:37
MonitorElement * bookInt(const char *name)
Book int.
Definition: DQMStore.cc:835
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:1056
CastorHIMonitor * HIMon_
TimeValue_t value() const
Definition: Timestamp.h:56
edm::Timestamp time() const
Definition: EventBase.h:57
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:639
Definition: Run.h:41
MonitorElement * meEVT_
edm::EDGetTokenT< HcalUnpackerReport > inputLabelReportToken_