00001 #include <DQM/HcalMonitorClient/interface/HcalMonitorClient.h>
00002 #include "FWCore/ServiceRegistry/interface/Service.h"
00003 #include "FWCore/Framework/interface/MakerMacros.h"
00004 #include <DQM/HcalMonitorClient/interface/HcalMonitorClient.h>
00005 #include "DQMServices/Core/interface/MonitorElement.h"
00006
00007
00008 HcalMonitorClient::HcalMonitorClient(const ParameterSet& ps){
00009 initialize(ps);
00010 }
00011
00012 HcalMonitorClient::HcalMonitorClient(){}
00013
00014
00015 HcalMonitorClient::~HcalMonitorClient(){
00016
00017 if (debug_>0) cout << "HcalMonitorClient: Exit ..." << endl;
00018 if( summary_client_ ) delete summary_client_;
00019 if( dataformat_client_ ) delete dataformat_client_;
00020 if( digi_client_ ) delete digi_client_;
00021 if( rechit_client_ ) delete rechit_client_;
00022 if( pedestal_client_ ) delete pedestal_client_;
00023 if( led_client_ ) delete led_client_;
00024 if( laser_client_ ) delete laser_client_;
00025 if( hot_client_ ) delete hot_client_;
00026 if( dead_client_ ) delete dead_client_;
00027 if( tp_client_ ) delete tp_client_;
00028 if( ct_client_ ) delete ct_client_;
00029 if( beam_client_) delete beam_client_;
00030 if (dqm_db_) delete dqm_db_;
00031
00032 if( mui_ ) delete mui_;
00033
00034 if (debug_>1) cout <<"HcalMonitorClient: Finished destructor..."<<endl;
00035 }
00036
00037
00038 void HcalMonitorClient::initialize(const ParameterSet& ps){
00039
00040 irun_=0; ilumisec_=0; ievent_=0; itime_=0;
00041
00042 maxlumisec_=0; minlumisec_=0;
00043
00044 actonLS_=false;
00045
00046 summary_client_ = 0;
00047 dataformat_client_ = 0; digi_client_ = 0;
00048 rechit_client_ = 0; pedestal_client_ = 0;
00049 led_client_ = 0; laser_client_ = 0; hot_client_ = 0; dead_client_=0;
00050 tp_client_=0;
00051 ct_client_=0;
00052 beam_client_=0;
00053 lastResetTime_=0;
00054
00055 debug_ = ps.getUntrackedParameter<int>("debug", 0);
00056 if (debug_>0)
00057 cout << endl<<" *** Hcal Monitor Client ***" << endl<<endl;
00058
00059 if(debug_>1) cout << "HcalMonitorClient: constructor...." << endl;
00060
00061
00062 showTiming_ = ps.getUntrackedParameter<bool>("showTiming",false);
00063
00064
00065 enableMonitorDaemon_ = ps.getUntrackedParameter<bool>("enableMonitorDaemon", true);
00066 if (debug_>0)
00067 {
00068 if ( enableMonitorDaemon_ ) cout << "-->enableMonitorDaemon switch is ON" << endl;
00069 else cout << "-->enableMonitorDaemon switch is OFF" << endl;
00070 }
00071
00072 mui_ = new DQMOldReceiver();
00073 dbe_ = mui_->getBEInterface();
00074
00075
00076 inputFile_ = ps.getUntrackedParameter<string>("inputFile", "");
00077 if(inputFile_.size()!=0 && debug_>0) cout << "-->reading DQM input from " << inputFile_ << endl;
00078
00079 if( ! enableMonitorDaemon_ ) {
00080 if( inputFile_.size() != 0 && dbe_!=NULL){
00081 dbe_->open(inputFile_);
00082 dbe_->showDirStructure();
00083 }
00084 }
00085
00086
00087 resetUpdate_ = ps.getUntrackedParameter<int>("resetFreqUpdates",-1);
00088 if(resetUpdate_!=-1 && debug_>0) cout << "-->Will reset histograms every " << resetUpdate_ <<" collector updates." << endl;
00089 resetEvents_ = ps.getUntrackedParameter<int>("resetFreqEvents",-1);
00090 if(resetEvents_!=-1 && debug_>0) cout << "-->Will reset histograms every " << resetEvents_ <<" events." << endl;
00091 resetTime_ = ps.getUntrackedParameter<int>("resetFreqTime",-1);
00092 if(resetTime_!=-1 && debug_>0) cout << "-->Will reset histograms every " << resetTime_ <<" minutes." << endl;
00093 resetLS_ = ps.getUntrackedParameter<int>("resetFreqLS",-1);
00094 if(resetLS_!=-1 && debug_>0) cout << "-->Will reset histograms every " << resetLS_ <<" lumi sections." << endl;
00095
00096
00097 baseHtmlDir_ = ps.getUntrackedParameter<string>("baseHtmlDir", "");
00098 if (debug_>0)
00099 {
00100 if( baseHtmlDir_.size() != 0)
00101 cout << "-->HTML output will go to baseHtmlDir = '" << baseHtmlDir_ << "'" << endl;
00102 else cout << "-->HTML output is disabled" << endl;
00103 }
00104
00105
00106 enableExit_ = ps.getUntrackedParameter<bool>("enableExit", true);
00107 if (debug_>1)
00108 {
00109 if( enableExit_ ) cout << "-->enableExit switch is ON" << endl;
00110 else cout << "-->enableExit switch is OFF" << endl;
00111 }
00112
00113 runningStandalone_ = ps.getUntrackedParameter<bool>("runningStandalone", false);
00114 if (debug_>1)
00115 {
00116 if( runningStandalone_ ) cout << "-->standAlone switch is ON" << endl;
00117 else cout << "-->standAlone switch is OFF" << endl;
00118 }
00119
00120 gStyle->Reset("Default");
00121 gStyle->SetCanvasColor(0);
00122 gStyle->SetPadColor(0);
00123 gStyle->SetFillColor(0);
00124 gStyle->SetTitleFillColor(10);
00125
00126 gStyle->SetOptStat("ouemr");
00127 gStyle->SetPalette(1);
00128
00129
00130 if( ps.getUntrackedParameter<bool>("SummaryClient", true) )
00131 {
00132 if(debug_>0)
00133 cout << "===>DQM Summary Client is ON" << endl;
00134 summary_client_ = new HcalSummaryClient();
00135 summary_client_->init(ps, dbe_,"SummaryClient");
00136 }
00137 if( ps.getUntrackedParameter<bool>("DataFormatClient", false) ){
00138 if(debug_>0) cout << "===>DQM DataFormat Client is ON" << endl;
00139 dataformat_client_ = new HcalDataFormatClient();
00140 dataformat_client_->init(ps, dbe_,"DataFormatClient");
00141 }
00142 if( ps.getUntrackedParameter<bool>("DigiClient", false) ){
00143 if(debug_>0)
00144 cout << "===>DQM Digi Client is ON" << endl;
00145 digi_client_ = new HcalDigiClient();
00146 digi_client_->init(ps, dbe_,"DigiClient");
00147 }
00148 if( ps.getUntrackedParameter<bool>("RecHitClient", false) ){
00149 if(debug_>0) cout << "===>DQM RecHit Client is ON" << endl;
00150 rechit_client_ = new HcalRecHitClient();
00151 rechit_client_->init(ps, dbe_,"RecHitClient");
00152 }
00153 if( ps.getUntrackedParameter<bool>("PedestalClient", false) ){
00154 if(debug_>0) cout << "===>DQM Pedestal Client is ON" << endl;
00155 pedestal_client_ = new HcalPedestalClient();
00156 pedestal_client_->init(ps, dbe_,"PedestalClient");
00157 }
00158 if( ps.getUntrackedParameter<bool>("LEDClient", false) ){
00159 if(debug_>0) cout << "===>DQM LED Client is ON" << endl;
00160 led_client_ = new HcalLEDClient();
00161 led_client_->init(ps, dbe_,"LEDClient");
00162 }
00163 if( ps.getUntrackedParameter<bool>("LaserClient", false) ){
00164 if(debug_>0) cout << "===>DQM Laser Client is ON" << endl;
00165 laser_client_ = new HcalLaserClient();
00166 laser_client_->init(ps, dbe_,"LaserClient");
00167 }
00168 if( ps.getUntrackedParameter<bool>("HotCellClient", false) ){
00169 if(debug_>0) cout << "===>DQM HotCell Client is ON" << endl;
00170 hot_client_ = new HcalHotCellClient();
00171 hot_client_->init(ps, dbe_,"HotCellClient");
00172 }
00173 if( ps.getUntrackedParameter<bool>("DeadCellClient", false) ){
00174 if(debug_>0) cout << "===>DQM DeadCell Client is ON" << endl;
00175 dead_client_ = new HcalDeadCellClient();
00176 dead_client_->init(ps, dbe_,"DeadCellClient");
00177 }
00178 if( ps.getUntrackedParameter<bool>("TrigPrimClient", false) ){
00179 if(debug_>0) cout << "===>DQM TrigPrim Client is ON" << endl;
00180 tp_client_ = new HcalTrigPrimClient();
00181 tp_client_->init(ps, dbe_,"TrigPrimClient");
00182 }
00183 if( ps.getUntrackedParameter<bool>("CaloTowerClient", false) ){
00184 if(debug_>0) cout << "===>DQM CaloTower Client is ON" << endl;
00185 ct_client_ = new HcalCaloTowerClient();
00186 ct_client_->init(ps, dbe_,"CaloTowerClient");
00187 }
00188 if( ps.getUntrackedParameter<bool>("BeamClient", false) ){
00189 if(debug_>0) cout << "===>DQM Beam Client is ON" << endl;
00190 beam_client_ = new HcalBeamClient();
00191 beam_client_->init(ps, dbe_,"BeamClient");
00192 }
00193 dqm_db_ = new HcalHotCellDbInterface();
00194
00195
00196
00197 prescaleEvt_ = ps.getUntrackedParameter<int>("diagnosticPrescaleEvt", -1);
00198 if (debug_>0)
00199 cout << "===>DQM event prescale = " << prescaleEvt_ << " event(s)"<< endl;
00200
00201 prescaleLS_ = ps.getUntrackedParameter<int>("diagnosticPrescaleLS", -1);
00202 if (debug_>0) cout << "===>DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< endl;
00203 if (prescaleLS_>0) actonLS_=true;
00204
00205 prescaleUpdate_ = ps.getUntrackedParameter<int>("diagnosticPrescaleUpdate", -1);
00206 if (debug_>0) cout << "===>DQM update prescale = " << prescaleUpdate_ << " update(s)"<< endl;
00207
00208 prescaleTime_ = ps.getUntrackedParameter<int>("diagnosticPrescaleTime", -1);
00209 if (debug_>0) cout << "===>DQM time prescale = " << prescaleTime_ << " minute(s)"<< endl;
00210
00211
00212
00213 string subsystemname = ps.getUntrackedParameter<string>("subSystemFolder", "Hcal") ;
00214 if (debug_>0) cout << "===>HcalMonitor name = " << subsystemname << endl;
00215 rootFolder_ = subsystemname + "/";
00216
00217
00218 gettimeofday(&psTime_.startTV,NULL);
00220 psTime_.startTime = (psTime_.startTV.tv_sec*1000.0+psTime_.startTV.tv_usec/1000.0);
00221 psTime_.startTime /= (60.0*1000.0);
00222 psTime_.elapsedTime=0;
00223 psTime_.updateTime=0;
00224
00225 return;
00226 }
00227
00228
00229
00230 void HcalMonitorClient::removeAllME(){
00231 if (debug_>0) cout <<"<HcalMonitorClient>removeAllME()"<<endl;
00232 if(dbe_==NULL) return;
00233
00234
00235 dbe_->cd();
00236
00237 dbe_->removeContents();
00238
00239 if(dbe_->dirExists("Collector"))
00240 dbe_->rmdir("Collector");
00241 if(dbe_->dirExists("Summary"))
00242 dbe_->rmdir("Summary");
00243 return;
00244 }
00245
00246
00248 void HcalMonitorClient::resetAllME() {
00249 if (debug_>0) cout <<"<HcalMonitorClient> resetAllME()"<<endl;
00250 if( dataformat_client_ ) dataformat_client_->resetAllME();
00251 if( digi_client_ ) digi_client_->resetAllME();
00252 if( rechit_client_ ) rechit_client_->resetAllME();
00253 if( pedestal_client_ ) pedestal_client_->resetAllME();
00254 if( led_client_ ) led_client_->resetAllME();
00255 if( laser_client_ ) laser_client_->resetAllME();
00256 if( hot_client_ ) hot_client_->resetAllME();
00257 if( dead_client_ ) dead_client_->resetAllME();
00258 if( tp_client_ ) tp_client_->resetAllME();
00259 if( ct_client_ ) ct_client_->resetAllME();
00260 if( beam_client_ ) beam_client_->resetAllME();
00261 return;
00262 }
00263
00264
00265 void HcalMonitorClient::beginJob(const EventSetup& c){
00266
00267 if( debug_>0 ) cout << "HcalMonitorClient: beginJob" << endl;
00268
00269 ievt_ = 0;
00270 if( summary_client_ ) summary_client_->beginJob(dbe_);
00271 if( dataformat_client_ ) dataformat_client_->beginJob();
00272 if( digi_client_ ) digi_client_->beginJob();
00273 if( rechit_client_ ) rechit_client_->beginJob();
00274 if( pedestal_client_ ) pedestal_client_->beginJob(c);
00275 if( led_client_ ) led_client_->beginJob(c);
00276 if( laser_client_ ) laser_client_->beginJob(c);
00277 if( hot_client_ ) hot_client_->beginJob(c);
00278 if( dead_client_ ) dead_client_->beginJob(c);
00279 if( tp_client_ ) tp_client_->beginJob();
00280 if( ct_client_ ) ct_client_->beginJob();
00281 if( beam_client_ ) beam_client_->beginJob();
00282 return;
00283 }
00284
00285
00286 void HcalMonitorClient::beginRun(const Run& r, const EventSetup& c) {
00287
00288 if (debug_>0)
00289 cout << endl<<"HcalMonitorClient: Standard beginRun() for run " << r.id().run() << endl<<endl;
00290
00291 if( summary_client_ ) summary_client_->beginRun();
00292 if( dataformat_client_ ) dataformat_client_->beginRun();
00293 if( digi_client_ ) digi_client_->beginRun();
00294 if( rechit_client_ ) rechit_client_->beginRun();
00295 if( pedestal_client_ ) pedestal_client_->beginRun();
00296 if( led_client_ ) led_client_->beginRun();
00297 if( laser_client_ ) laser_client_->beginRun();
00298 if( hot_client_ ) hot_client_->beginRun();
00299 if( dead_client_ ) dead_client_->beginRun();
00300 if( tp_client_ ) tp_client_->beginRun();
00301 if( ct_client_ ) ct_client_->beginRun();
00302 if( beam_client_ ) beam_client_->beginRun();
00303 return;
00304 }
00305
00306
00307 void HcalMonitorClient::endJob(void) {
00308
00309 if( debug_>0 ) cout << "HcalMonitorClient: endJob, ievt = " << ievt_ << endl;
00310
00311 if (summary_client_) summary_client_->endJob();
00312 if( dataformat_client_ ) dataformat_client_->endJob();
00313 if( digi_client_ ) digi_client_->endJob();
00314 if( rechit_client_ ) rechit_client_->endJob();
00315 if( hot_client_ ) hot_client_->endJob();
00316 if( dead_client_ ) dead_client_->endJob();
00317 if( pedestal_client_ ) pedestal_client_->endJob();
00318 if( led_client_ ) led_client_->endJob();
00319 if( laser_client_ ) laser_client_->endJob();
00320 if( tp_client_ ) tp_client_->endJob();
00321 if( ct_client_ ) ct_client_->endJob();
00322 if( beam_client_ ) beam_client_->endJob();
00323
00324
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382 return;
00383 }
00384
00385
00386 void HcalMonitorClient::endRun(const Run& r, const EventSetup& c) {
00387
00388 if (debug_>0)
00389 cout << endl<<"<HcalMonitorClient> Standard endRun() for run " << r.id().run() << endl<<endl;
00390
00391
00392 if( debug_ >0) cout <<"HcalMonitorClient: processed events: "<<ievt_<<endl;
00393
00394 if (debug_>0) cout <<"==>Creating report after run end condition"<<endl;
00395 if(irun_>1){
00396 if(inputFile_.size()!=0) report(true);
00397 else report(false);
00398 }
00399
00400 if( summary_client_) summary_client_->endRun();
00401 if( hot_client_ ) hot_client_->endRun();
00402 if( dead_client_ ) dead_client_->endRun();
00403 if( dataformat_client_ ) dataformat_client_->endRun();
00404 if( digi_client_ ) digi_client_->endRun();
00405 if( rechit_client_ ) rechit_client_->endRun();
00406 if( pedestal_client_ ) pedestal_client_->endRun();
00407 if( led_client_ ) led_client_->endRun();
00408 if( laser_client_ ) laser_client_->endRun();
00409 if( tp_client_ ) tp_client_->endRun();
00410 if( ct_client_ ) ct_client_->endRun();
00411 if( beam_client_ ) beam_client_->endRun();
00412
00413
00414 if( enableExit_ ) {
00415 if (debug_>0) cout << endl << ">>> exit after End-Of-Run <<<" << endl <<endl;
00416
00417 endJob();
00418 throw cms::Exception("End of Job")
00419 << "HcalMonitorClient: Done processing...\n";
00420 }
00421 }
00422
00423
00424 void HcalMonitorClient::beginLuminosityBlock(const LuminosityBlock &l, const EventSetup &c)
00425 {
00426 if( debug_>0 ) cout << "HcalMonitorClient: beginLuminosityBlock" << endl;
00427 if(actonLS_ && !prescale()){
00428
00429 }
00430
00431 }
00432
00433
00434 void HcalMonitorClient::endLuminosityBlock(const LuminosityBlock &l, const EventSetup &c) {
00435
00436 if( debug_>0 ) cout << "HcalMonitorClient: endLuminosityBlock" << endl;
00437 if(actonLS_ && !prescale()){
00438
00439 analyze();
00440 }
00441
00442 return;
00443 }
00444
00445
00446 void HcalMonitorClient::analyze(const Event& e, const edm::EventSetup& eventSetup){
00447
00448 if (debug_>0)
00449 cout <<"Entered HcalMonitorClient::analyze(const Evt...)"<<endl;
00450
00451 if(resetEvents_>0 && (ievent_%resetEvents_)==0) resetAllME();
00452 if(resetLS_>0 && (ilumisec_%resetLS_)==0) resetAllME();
00453 int deltaT = itime_-lastResetTime_;
00454 if(resetTime_>0 && (deltaT>resetTime_)){
00455 resetAllME();
00456 lastResetTime_ = itime_;
00457 }
00458
00459
00460
00461 irun_ = e.id().run();
00462 ilumisec_ = e.luminosityBlock();
00463 ievent_ = e.id().event();
00464 itime_ = e.time().value();
00465 mytime_ = (e.time().value())>>32;
00466
00467 if (minlumisec_==0)
00468 minlumisec_=ilumisec_;
00469 minlumisec_=min(minlumisec_,ilumisec_);
00470 maxlumisec_=max(maxlumisec_,ilumisec_);
00471
00472 if (debug_>1)
00473 cout << "HcalMonitorClient: evts: "<< ievt_ << ", run: " << irun_ << ", LS: " << ilumisec_ << ", evt: " << ievent_ << ", time: " << itime_ << endl;
00474
00475 ievt_++;
00476
00477
00478
00479 if( summary_client_ ) {
00480 summary_client_->incrementCounters();
00481 if (ievt_ ==1) {
00482 summary_client_->analyze();}}
00483 if ( runningStandalone_ || prescale()) return;
00484
00485 else analyze();
00486 }
00487
00488
00489
00490 void HcalMonitorClient::analyze(){
00491 if (debug_>0)
00492 cout <<"<HcalMonitorClient> Entered HcalMonitorClient::analyze()"<<endl;
00493
00494
00495 if(debug_>1) cout<<"\nHcal Monitor Client heartbeat...."<<endl;
00496
00497 createTests();
00498 mui_->doMonitoring();
00499 dbe_->runQTests();
00500
00501 if (showTiming_)
00502 {
00503 cpu_timer.reset(); cpu_timer.start();
00504 }
00505 if( dataformat_client_ ) dataformat_client_->analyze();
00506 if (showTiming_)
00507 {
00508 cpu_timer.stop();
00509 if (dataformat_client_) cout <<"TIMER:: DATAFORMAT CLIENT ->"<<cpu_timer.cpuTime()<<endl;
00510 cpu_timer.reset(); cpu_timer.start();
00511 }
00512
00513 if( digi_client_) digi_client_->analyze();
00514 if (showTiming_)
00515 {
00516 cpu_timer.stop();
00517 if (digi_client_) cout <<"TIMER:: DIGI CLIENT ->"<<cpu_timer.cpuTime()<<endl;
00518 cpu_timer.reset(); cpu_timer.start();
00519 }
00520
00521 if( rechit_client_ ) rechit_client_->analyze();
00522 if (showTiming_)
00523 {
00524 cpu_timer.stop();
00525 if (rechit_client_) cout <<"TIMER:: RECHIT CLIENT ->"<<cpu_timer.cpuTime()<<endl;
00526 cpu_timer.reset(); cpu_timer.start();
00527 }
00528
00529 if( pedestal_client_ ) pedestal_client_->analyze();
00530 if (showTiming_)
00531 {
00532 cpu_timer.stop();
00533 if (pedestal_client_) cout <<"TIMER:: PEDESTAL CLIENT ->"<<cpu_timer.cpuTime()<<endl;
00534 cpu_timer.reset(); cpu_timer.start();
00535 }
00536
00537 if( led_client_ ) led_client_->analyze();
00538 if (showTiming_)
00539 {
00540 cpu_timer.stop();
00541 if (led_client_) cout <<"TIMER:: LED CLIENT ->"<<cpu_timer.cpuTime()<<endl;
00542 cpu_timer.reset(); cpu_timer.start();
00543 }
00544
00545 if( laser_client_ ) laser_client_->analyze();
00546 if (showTiming_)
00547 {
00548 cpu_timer.stop();
00549 if (laser_client_) cout <<"TIMER:: LASER CLIENT ->"<<cpu_timer.cpuTime()<<endl;
00550 cpu_timer.reset(); cpu_timer.start();
00551 }
00552
00553 if( hot_client_ ) hot_client_->analyze();
00554 if (showTiming_)
00555 {
00556 cpu_timer.stop();
00557 if (hot_client_) cout <<"TIMER:: HOT CLIENT ->"<<cpu_timer.cpuTime()<<endl;
00558 cpu_timer.reset(); cpu_timer.start();
00559 }
00560
00561 if( dead_client_ ) dead_client_->analyze();
00562 if (showTiming_)
00563 {
00564 cpu_timer.stop();
00565 if (dead_client_) cout <<"TIMER:: DEAD CLIENT ->"<<cpu_timer.cpuTime()<<endl;
00566 cpu_timer.reset(); cpu_timer.start();
00567 }
00568
00569 if( tp_client_ ) tp_client_->analyze();
00570 if (showTiming_)
00571 {
00572 cpu_timer.stop();
00573 if (tp_client_) cout <<"TIMER:: TP CLIENT ->"<<cpu_timer.cpuTime()<<endl;
00574 cpu_timer.reset(); cpu_timer.start();
00575 }
00576
00577 if( ct_client_ ) ct_client_->analyze();
00578 if (showTiming_)
00579 {
00580 cpu_timer.stop();
00581 if (ct_client_) cout <<"TIMER:: CT CLIENT ->"<<cpu_timer.cpuTime()<<endl;
00582 cpu_timer.reset(); cpu_timer.start();
00583 }
00584 if( beam_client_ ) beam_client_->analyze();
00585 if (showTiming_)
00586 {
00587 cpu_timer.stop();
00588 if (beam_client_) cout <<"TIMER:: BEAM CLIENT ->"<<cpu_timer.cpuTime()<<endl;
00589 cpu_timer.reset(); cpu_timer.start();
00590 }
00591
00592 if (showTiming_)
00593 {
00594 cpu_timer.stop();
00595 if (beam_client_) cout <<"TIMER:: BEAM CLIENT ->"<<cpu_timer.cpuTime()<<endl;
00596 cpu_timer.reset(); cpu_timer.start();
00597 }
00598
00599 if (summary_client_ ) summary_client_->analyze();
00600 if (showTiming_)
00601 {
00602 cpu_timer.stop();
00603 if (summary_client_) cout <<"TIMER:: SUMMARY CLIENT ->"<<cpu_timer.cpuTime()<<endl;
00604 }
00605
00606 errorSummary();
00607
00608 return;
00609 }
00610
00611
00612 void HcalMonitorClient::createTests(void){
00613
00614 if( debug_>0 ) cout << "HcalMonitorClient: creating all tests" << endl;
00615
00616 if( dataformat_client_ ) dataformat_client_->createTests();
00617 if( digi_client_ ) digi_client_->createTests();
00618 if( rechit_client_ ) rechit_client_->createTests();
00619 if( pedestal_client_ ) pedestal_client_->createTests();
00620 if( led_client_ ) led_client_->createTests();
00621 if( laser_client_ ) laser_client_->createTests();
00622 if( hot_client_ ) hot_client_->createTests();
00623 if( dead_client_ ) dead_client_->createTests();
00624 if( tp_client_ ) tp_client_->createTests();
00625 if( ct_client_ ) ct_client_->createTests();
00626 if( beam_client_ ) beam_client_->createTests();
00627 return;
00628 }
00629
00630
00631 void HcalMonitorClient::report(bool doUpdate) {
00632
00633 if( debug_>0 )
00634 cout << "HcalMonitorClient: creating report, ievt = " << ievt_ << endl;
00635
00636 if(doUpdate){
00637 createTests();
00638 dbe_->runQTests();
00639 }
00640
00641 if( dataformat_client_ ) dataformat_client_->report();
00642 if( digi_client_ ) digi_client_->report();
00643 if( led_client_ ) led_client_->report();
00644 if( laser_client_ ) laser_client_->report();
00645 if( pedestal_client_ ) pedestal_client_->report();
00646 if( rechit_client_ ) rechit_client_->report();
00647 if( hot_client_ ) hot_client_->report();
00648 if( dead_client_ ) dead_client_->report();
00649 if( tp_client_ ) tp_client_->report();
00650 if( ct_client_ ) ct_client_->report();
00651 if( beam_client_ ) beam_client_->report();
00652 errorSummary();
00653
00654
00655 if( baseHtmlDir_.size() != 0 && ievt_>0) htmlOutput();
00656 return;
00657 }
00658
00659 void HcalMonitorClient::errorSummary(){
00660
00662 int nTests=0;
00663 map<string, vector<QReport*> > errE, errW, errO;
00664 if( hot_client_ ) hot_client_->getTestResults(nTests,errE,errW,errO);
00665 if( dead_client_ ) dead_client_->getTestResults(nTests,errE,errW,errO);
00666 if( led_client_ ) led_client_->getTestResults(nTests,errE,errW,errO);
00667 if( laser_client_ ) laser_client_->getTestResults(nTests,errE,errW,errO);
00668 if( tp_client_ ) tp_client_->getTestResults(nTests,errE,errW,errO);
00669 if( pedestal_client_ ) pedestal_client_->getTestResults(nTests,errE,errW,errO);
00670 if( digi_client_ ) digi_client_->getTestResults(nTests,errE,errW,errO);
00671 if( rechit_client_ ) rechit_client_->getTestResults(nTests,errE,errW,errO);
00672 if( dataformat_client_ ) dataformat_client_->getTestResults(nTests,errE,errW,errO);
00673 if( ct_client_ ) ct_client_->getTestResults(nTests,errE,errW,errO);
00674 if( beam_client_ ) beam_client_->getTestResults(nTests,errE,errW,errO);
00675
00676 float errorSummary = 1.0;
00677 if(nTests>0) errorSummary = 1.0 - (float(errE.size())+float(errW.size()))/float(nTests);
00678
00679 if (debug_>0) cout << "Hcal DQM Error Summary ("<< errorSummary <<"): "<< nTests << " tests, "<<errE.size() << " errors, " <<errW.size() << " warnings, "<< errO.size() << " others" << endl;
00680
00681 char meTitle[256];
00682 sprintf(meTitle,"%sEventInfo/errorSummary",rootFolder_.c_str() );
00683 MonitorElement* me = dbe_->get(meTitle);
00684 if(me) me->Fill(errorSummary);
00685
00686 return;
00687 }
00688
00689
00690 void HcalMonitorClient::htmlOutput(void){
00691
00692 if (debug_>0) cout << "Preparing HcalMonitorClient html output ..." << endl;
00693
00694 char tmp[10];
00695 if(irun_!=-1) sprintf(tmp, "DQM_Hcal_R%09d", irun_);
00696 else sprintf(tmp, "DQM_Hcal_R%09d", 0);
00697 string htmlDir = baseHtmlDir_ + "/" + tmp + "/";
00698 system(("/bin/mkdir -p " + htmlDir).c_str());
00699
00700 ofstream htmlFile;
00701 htmlFile.open((htmlDir + "index.html").c_str());
00702
00703
00704 htmlFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> " << endl;
00705 htmlFile << "<html> " << endl;
00706 htmlFile << "<head> " << endl;
00707 htmlFile << " <meta content=\"text/html; charset=ISO-8859-1\" " << endl;
00708 htmlFile << " https-equiv=\"content-type\"> " << endl;
00709 htmlFile << " <title>Hcal Data Quality Monitor</title> " << endl;
00710 htmlFile << "</head> " << endl;
00711 htmlFile << "<body> " << endl;
00712 htmlFile << "<br> " << endl;
00713 htmlFile << "<center><h1>Hcal Data Quality Monitor</h1></center>" << endl;
00714 htmlFile << "<h2>Run Number: " << endl;
00715 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << irun_ <<"</span></h2> " << endl;
00716 htmlFile << "<h2>Events processed: " << endl;
00717 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << ievt_ <<"</span></h2> " << endl;
00718 htmlFile << "<hr>" << endl;
00719 htmlFile << "<ul>" << endl;
00720
00721 string htmlName;
00722 if( dataformat_client_ ) {
00723 htmlName = "HcalDataFormatClient.html";
00724 dataformat_client_->htmlOutput(irun_, htmlDir, htmlName);
00725 htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << endl;
00726 htmlFile << "<td WIDTH=\"35%\"><a href=\"" << htmlName << "\">Data Format Monitor</a></td>" << endl;
00727 if(dataformat_client_->hasErrors()) htmlFile << "<td bgcolor=red align=center>This monitor task has errors.</td>" << endl;
00728 else if(dataformat_client_->hasWarnings()) htmlFile << "<td bgcolor=yellow align=center>This monitor task has warnings.</td>" << endl;
00729 else if(dataformat_client_->hasOther()) htmlFile << "<td bgcolor=aqua align=center>This monitor task has messages.</td>" << endl;
00730 else htmlFile << "<td bgcolor=lime align=center>This monitor task has no problems</td>" << endl;
00731 htmlFile << "</tr></table>" << endl;
00732 }
00733 if( digi_client_ ) {
00734 htmlName = "HcalDigiClient.html";
00735 digi_client_->htmlOutput(irun_, htmlDir, htmlName);
00736 htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << endl;
00737 htmlFile << "<td WIDTH=\"35%\"><a href=\"" << htmlName << "\">Digi Monitor</a></td>" << endl;
00738 if(digi_client_->hasErrors()) htmlFile << "<td bgcolor=red align=center>This monitor task has errors.</td>" << endl;
00739 else if(digi_client_->hasWarnings()) htmlFile << "<td bgcolor=yellow align=center>This monitor task has warnings.</td>" << endl;
00740 else if(digi_client_->hasOther()) htmlFile << "<td bgcolor=aqua align=center>This monitor task has messages.</td>" << endl;
00741 else htmlFile << "<td bgcolor=lime align=center>This monitor task has no problems</td>" << endl;
00742 htmlFile << "</tr></table>" << endl;
00743 }
00744 if( tp_client_ ) {
00745 htmlName = "HcalTrigPrimClient.html";
00746 tp_client_->htmlOutput(irun_, htmlDir, htmlName);
00747 htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << endl;
00748 htmlFile << "<td WIDTH=\"35%\"><a href=\"" << htmlName << "\">TrigPrim Monitor</a></td>" << endl;
00749 if(tp_client_->hasErrors()) htmlFile << "<td bgcolor=red align=center>This monitor task has errors.</td>" << endl;
00750 else if(tp_client_->hasWarnings()) htmlFile << "<td bgcolor=yellow align=center>This monitor task has warnings.</td>" << endl;
00751 else if(tp_client_->hasOther()) htmlFile << "<td bgcolor=aqua align=center>This monitor task has messages.</td>" << endl;
00752 else htmlFile << "<td bgcolor=lime align=center>This monitor task has no problems</td>" << endl;
00753 htmlFile << "</tr></table>" << endl;
00754 }
00755 if( rechit_client_ ) {
00756 htmlName = "HcalRecHitClient.html";
00757 rechit_client_->htmlOutput(irun_, htmlDir, htmlName);
00758 htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << endl;
00759 htmlFile << "<td WIDTH=\"35%\"><a href=\"" << htmlName << "\">RecHit Monitor</a></td>" << endl;
00760 if(rechit_client_->hasErrors()) htmlFile << "<td bgcolor=red align=center>This monitor task has errors.</td>" << endl;
00761 else if(rechit_client_->hasWarnings()) htmlFile << "<td bgcolor=yellow align=center>This monitor task has warnings.</td>" << endl;
00762 else if(rechit_client_->hasOther()) htmlFile << "<td bgcolor=aqua align=center>This monitor task has messages.</td>" << endl;
00763 else htmlFile << "<td bgcolor=lime align=center>This monitor task has no problems</td>" << endl;
00764 htmlFile << "</tr></table>" << endl;
00765 }
00766 if( ct_client_ ) {
00767 htmlName = "HcalCaloTowerClient.html";
00768 ct_client_->htmlOutput(irun_, htmlDir, htmlName);
00769 htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << endl;
00770 htmlFile << "<td WIDTH=\"35%\"><a href=\"" << htmlName << "\">CaloTower Monitor</a></td>" << endl;
00771 if(ct_client_->hasErrors()) htmlFile << "<td bgcolor=red align=center>This monitor task has errors.</td>" << endl;
00772 else if(ct_client_->hasWarnings()) htmlFile << "<td bgcolor=yellow align=center>This monitor task has warnings.</td>" << endl;
00773 else if(ct_client_->hasOther()) htmlFile << "<td bgcolor=aqua align=center>This monitor task has messages.</td>" << endl;
00774 else htmlFile << "<td bgcolor=lime align=center>This monitor task has no problems</td>" << endl;
00775 htmlFile << "</tr></table>" << endl;
00776 }
00777 if( hot_client_ ) {
00778 htmlName = "HcalHotCellClient.html";
00779 hot_client_->htmlOutput(irun_, htmlDir, htmlName);
00780 htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << endl;
00781 htmlFile << "<td WIDTH=\"35%\"><a href=\"" << htmlName << "\">Hot Cell Monitor</a></td>" << endl;
00782 if(hot_client_->hasErrors()) htmlFile << "<td bgcolor=red align=center>This monitor task has errors.</td>" << endl;
00783 else if(hot_client_->hasWarnings()) htmlFile << "<td bgcolor=yellow align=center>This monitor task has warnings.</td>" << endl;
00784 else if(hot_client_->hasOther()) htmlFile << "<td bgcolor=aqua align=center>This monitor task has messages.</td>" << endl;
00785 else htmlFile << "<td bgcolor=lime align=center>This monitor task has no problems</td>" << endl;
00786 htmlFile << "</tr></table>" << endl;
00787 }
00788
00789 if( dead_client_) {
00790 htmlName = "HcalDeadCellClient.html";
00791 dead_client_->htmlOutput(irun_, htmlDir, htmlName);
00792 htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << endl;
00793 htmlFile << "<td WIDTH=\"35%\"><a href=\"" << htmlName << "\">Dead Cell Monitor</a></td>" << endl;
00794 if(dead_client_->hasErrors()) htmlFile << "<td bgcolor=red align=center>This monitor task has errors.</td>" << endl;
00795 else if(dead_client_->hasWarnings()) htmlFile << "<td bgcolor=yellow align=center>This monitor task has warnings.</td>" << endl;
00796 else if(dead_client_->hasOther()) htmlFile << "<td bgcolor=aqua align=center>This monitor task has messages.</td>" << endl;
00797 else htmlFile << "<td bgcolor=lime align=center>This monitor task has no problems</td>" << endl;
00798 htmlFile << "</tr></table>" << endl;
00799 }
00800 if( pedestal_client_) {
00801 htmlName = "HcalPedestalClient.html";
00802 pedestal_client_->htmlOutput(irun_, htmlDir, htmlName);
00803 htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << endl;
00804 htmlFile << "<td WIDTH=\"35%\"><a href=\"" << htmlName << "\">Pedestal Monitor</a></td>" << endl;
00805
00806 if(pedestal_client_->hasErrors()) htmlFile << "<td bgcolor=red align=center>This monitor task has errors.</td>" << endl;
00807 else if(pedestal_client_->hasWarnings()) htmlFile << "<td bgcolor=yellow align=center>This monitor task has warnings.</td>" << endl;
00808 else if(pedestal_client_->hasOther()) htmlFile << "<td bgcolor=aqua align=center>This monitor task has messages.</td>" << endl;
00809 else htmlFile << "<td bgcolor=lime align=center>This monitor task has no problems</td>" << endl;
00810
00811 htmlFile << "</tr></table>" << endl;
00812 }
00813
00814 if( led_client_) {
00815 htmlName = "HcalLEDClient.html";
00816 led_client_->htmlOutput(irun_, htmlDir, htmlName);
00817 htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << endl;
00818 htmlFile << "<td WIDTH=\"35%\"><a href=\"" << htmlName << "\">LED Monitor</a></td>" << endl;
00819
00820 if(led_client_->hasErrors()) htmlFile << "<td bgcolor=red align=center>This monitor task has errors.</td>" << endl;
00821 else if(led_client_->hasWarnings()) htmlFile << "<td bgcolor=yellow align=center>This monitor task has warnings.</td>" << endl;
00822 else if(led_client_->hasOther()) htmlFile << "<td bgcolor=aqua align=center>This monitor task has messages.</td>" << endl;
00823 else htmlFile << "<td bgcolor=lime align=center>This monitor task has no problems</td>" << endl;
00824
00825 htmlFile << "</tr></table>" << endl;
00826 }
00827
00828 if( laser_client_) {
00829 htmlName = "HcalLaserClient.html";
00830 laser_client_->htmlOutput(irun_, htmlDir, htmlName);
00831 htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << endl;
00832 htmlFile << "<td WIDTH=\"35%\"><a href=\"" << htmlName << "\">Laser Monitor</a></td>" << endl;
00833
00834 if(laser_client_->hasErrors()) htmlFile << "<td bgcolor=red align=center>This monitor task has errors.</td>" << endl;
00835 else if(laser_client_->hasWarnings()) htmlFile << "<td bgcolor=yellow align=center>This monitor task has warnings.</td>" << endl;
00836 else if(laser_client_->hasOther()) htmlFile << "<td bgcolor=aqua align=center>This monitor task has messages.</td>" << endl;
00837 else htmlFile << "<td bgcolor=lime align=center>This monitor task has no problems</td>" << endl;
00838
00839 htmlFile << "</tr></table>" << endl;
00840 }
00841
00842 if( beam_client_) {
00843 htmlName = "HcalBeamClient.html";
00844 beam_client_->htmlOutput(irun_, htmlDir, htmlName);
00845 htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << endl;
00846 htmlFile << "<td WIDTH=\"35%\"><a href=\"" << htmlName << "\">Beam Monitor</a></td>" << endl;
00847
00848 if(beam_client_->hasErrors()) htmlFile << "<td bgcolor=red align=center>This monitor task has errors.</td>" << endl;
00849 else if(beam_client_->hasWarnings()) htmlFile << "<td bgcolor=yellow align=center>This monitor task has warnings.</td>" << endl;
00850 else if(beam_client_->hasOther()) htmlFile << "<td bgcolor=aqua align=center>This monitor task has messages.</td>" << endl;
00851 else htmlFile << "<td bgcolor=lime align=center>This monitor task has no problems</td>" << endl;
00852
00853 htmlFile << "</tr></table>" << endl;
00854 }
00855 if( summary_client_) {
00856
00857 htmlName = "HcalSummaryCellClient.html";
00858
00859 summary_client_->htmlOutput(irun_, mytime_, minlumisec_, maxlumisec_, htmlDir, htmlName);
00860 htmlFile << "<table border=0 WIDTH=\"50%\"><tr>" << endl;
00861 htmlFile << "<td WIDTH=\"35%\"><a href=\"" << htmlName << "\">Summary Monitor</a></td>" << endl;
00862
00863
00864
00865
00866 htmlFile << "<td bgcolor=lime align=center>This monitor task has no problems</td>" << endl;
00867 htmlFile << "</tr></table>" << endl;
00868 }
00869
00870 htmlFile << "</ul>" << endl;
00871
00872
00873
00874 htmlFile << "</body> " << endl;
00875 htmlFile << "</html> " << endl;
00876
00877 htmlFile.close();
00878 if (debug_>0) cout << "HcalMonitorClient html output done..." << endl;
00879
00880 return;
00881 }
00882
00883 void HcalMonitorClient::offlineSetup(){
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908 return;
00909 }
00910
00911 void HcalMonitorClient::loadHistograms(TFile* infile, const char* fname){
00912
00913 if(!infile){
00914 throw cms::Exception("Incomplete configuration") <<
00915 "HcalMonitorClient: this histogram file is bad! " <<endl;
00916 return;
00917 }
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960 return;
00961
00962 }
00963
00964
00965 void HcalMonitorClient::dumpHistograms(int& runNum, vector<TH1F*> &hist1d,vector<TH2F*> &hist2d){
00966
00967 hist1d.clear();
00968 hist2d.clear();
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981 return;
00982 }
00983
00984
00985 bool HcalMonitorClient::prescale(){
00988 if (debug_>1) cout <<"HcalMonitorClient::prescale"<<endl;
00989
00990
00991 bool evtPS = prescaleEvt_>0;
00992 bool lsPS = prescaleLS_>0;
00993 bool timePS = prescaleTime_>0;
00994 bool updatePS = prescaleUpdate_>0;
00995
00996
00997 if(!evtPS && !lsPS && !timePS && !updatePS) return false;
00998
00999
01000 if(lsPS && (ilumisec_%prescaleLS_)!=0) lsPS = false;
01001
01002
01003 if (evtPS && (ievt_%prescaleEvt_)!=0) evtPS = false;
01004 if(timePS){
01005 float time = psTime_.elapsedTime - psTime_.updateTime;
01006 if(time<prescaleTime_){
01007 timePS = false;
01008 psTime_.updateTime = psTime_.elapsedTime;
01009 }
01010 }
01011
01012
01013 if (debug_>1)
01014 cout<<"HcalMonitor::prescale evt: "<<ievent_<<"/"<<evtPS<<", ls: "<<ilumisec_<<"/"<<lsPS<<", time: "<<(psTime_.elapsedTime - psTime_.updateTime)<<"/"<<timePS<<endl;
01015
01016
01017
01018
01019
01020
01021
01022
01023 if(evtPS || lsPS || timePS) return false;
01024 return true;
01025 }
01026
01027
01028 DEFINE_FWK_MODULE(HcalMonitorClient);