00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <memory>
00012 #include <iostream>
00013 #include <iomanip>
00014 #include <fstream>
00015 #include <algorithm>
00016
00017 #include "FWCore/Framework/interface/Run.h"
00018 #include "FWCore/Framework/interface/LuminosityBlock.h"
00019 #include "FWCore/Framework/interface/Event.h"
00020 #include "FWCore/Framework/interface/MakerMacros.h"
00021 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00022
00023 #include "FWCore/ServiceRegistry/interface/Service.h"
00024
00025 #include "DQMServices/Core/interface/MonitorElement.h"
00026
00027 #include "DQMServices/Core/interface/DQMOldReceiver.h"
00028 #include "DQMServices/Core/interface/DQMStore.h"
00029
00030 #include "DataFormats/EcalRawData/interface/EcalDCCHeaderBlock.h"
00031
00032 #include "OnlineDB/EcalCondDB/interface/EcalCondDBInterface.h"
00033 #include "OnlineDB/EcalCondDB/interface/RunTag.h"
00034 #include "OnlineDB/EcalCondDB/interface/RunDat.h"
00035 #include "OnlineDB/EcalCondDB/interface/MonRunDat.h"
00036
00037 #include "DQM/EcalCommon/interface/ColorPalette.h"
00038 #include "DQM/EcalCommon/interface/EcalErrorMask.h"
00039 #include <DQM/EcalCommon/interface/UtilsClient.h>
00040 #include <DQM/EcalCommon/interface/Numbers.h>
00041 #include <DQM/EcalCommon/interface/LogicID.h>
00042
00043 #include <DQM/EcalBarrelMonitorClient/interface/EcalBarrelMonitorClient.h>
00044
00045 #include <DQM/EcalBarrelMonitorClient/interface/EBIntegrityClient.h>
00046 #include <DQM/EcalBarrelMonitorClient/interface/EBStatusFlagsClient.h>
00047 #include <DQM/EcalBarrelMonitorClient/interface/EBOccupancyClient.h>
00048 #include <DQM/EcalBarrelMonitorClient/interface/EBCosmicClient.h>
00049 #include <DQM/EcalBarrelMonitorClient/interface/EBLaserClient.h>
00050 #include <DQM/EcalBarrelMonitorClient/interface/EBPedestalClient.h>
00051 #include <DQM/EcalBarrelMonitorClient/interface/EBPedestalOnlineClient.h>
00052 #include <DQM/EcalBarrelMonitorClient/interface/EBTestPulseClient.h>
00053 #include <DQM/EcalBarrelMonitorClient/interface/EBBeamCaloClient.h>
00054 #include <DQM/EcalBarrelMonitorClient/interface/EBBeamHodoClient.h>
00055 #include <DQM/EcalBarrelMonitorClient/interface/EBTriggerTowerClient.h>
00056 #include <DQM/EcalBarrelMonitorClient/interface/EBClusterClient.h>
00057 #include <DQM/EcalBarrelMonitorClient/interface/EBTimingClient.h>
00058
00059 #include "xgi/Method.h"
00060 #include "xgi/Utils.h"
00061
00062 #include "cgicc/Cgicc.h"
00063 #include "cgicc/FormEntry.h"
00064 #include "cgicc/HTMLClasses.h"
00065
00066 #include "TStyle.h"
00067 #include "TGaxis.h"
00068 #include "TColor.h"
00069
00070 using namespace cms;
00071 using namespace edm;
00072 using namespace std;
00073
00074 EcalBarrelMonitorClient::EcalBarrelMonitorClient(const ParameterSet& ps) : ModuleWeb("EcalBarrelMonitorClient") {
00075
00076
00077
00078 verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
00079
00080 if ( verbose_ ) {
00081 cout << endl;
00082 cout << " *** Ecal Barrel Generic Monitor Client ***" << endl;
00083 cout << endl;
00084 }
00085
00086
00087
00088 inputFile_ = ps.getUntrackedParameter<string>("inputFile", "");
00089
00090 if ( verbose_ ) {
00091 if ( inputFile_.size() != 0 ) {
00092 cout << " Reading DQM data from inputFile = '" << inputFile_ << "'" << endl;
00093 }
00094 }
00095
00096
00097
00098 dbName_ = ps.getUntrackedParameter<string>("dbName", "");
00099 dbHostName_ = ps.getUntrackedParameter<string>("dbHostName", "");
00100 dbHostPort_ = ps.getUntrackedParameter<int>("dbHostPort", 1521);
00101 dbUserName_ = ps.getUntrackedParameter<string>("dbUserName", "");
00102 dbPassword_ = ps.getUntrackedParameter<string>("dbPassword", "");
00103
00104 dbTagName_ = ps.getUntrackedParameter<string>("dbTagName", "CMSSW");
00105
00106 if ( verbose_ ) {
00107 if ( dbName_.size() != 0 ) {
00108 cout << " Using Ecal Cond DB: " << endl;
00109 cout << " dbName = '" << dbName_ << "'" << endl;
00110 cout << " dbUserName = '" << dbUserName_ << "'" << endl;
00111 if ( dbHostName_.size() != 0 ) {
00112 cout << " dbHostName = '" << dbHostName_ << "'" << endl;
00113 cout << " dbHostPort = '" << dbHostPort_ << "'" << endl;
00114 }
00115 cout << " dbTagName = '" << dbTagName_ << "'" << endl;
00116 } else {
00117 cout << " Ecal Cond DB is OFF" << endl;
00118 }
00119 }
00120
00121
00122
00123 maskFile_ = ps.getUntrackedParameter<string>("maskFile", "");
00124
00125 if ( verbose_ ) {
00126 if ( maskFile_.size() != 0 ) {
00127 cout << " Using maskFile = '" << maskFile_ << "'" << endl;
00128 }
00129 }
00130
00131
00132
00133 mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
00134
00135 if ( verbose_ ) {
00136 if ( mergeRuns_ ) {
00137 cout << " mergeRuns switch is ON" << endl;
00138 } else {
00139 cout << " mergeRuns switch is OFF" << endl;
00140 }
00141 }
00142
00143
00144
00145 updateTime_ = ps.getUntrackedParameter<int>("updateTime", 0);
00146
00147 if ( verbose_ ) {
00148 cout << " updateTime is " << updateTime_ << " minute(s)" << endl;
00149 }
00150
00151
00152
00153 dbUpdateTime_ = ps.getUntrackedParameter<int>("dbUpdateTime", 0);
00154
00155 if ( verbose_ ) {
00156 cout << " dbUpdateTime is " << dbUpdateTime_ << " minute(s)" << endl;
00157 }
00158
00159
00160
00161 htmlUpdateTime_ = ps.getUntrackedParameter<int>("htmlUpdateTime", 0);
00162
00163 if ( verbose_ ) {
00164 cout << " htmlUpdateTime is " << htmlUpdateTime_ << " minute(s)" << endl;
00165 }
00166
00167
00168
00169 location_ = ps.getUntrackedParameter<string>("location", "H4");
00170
00171 if ( verbose_ ) {
00172 cout << " location is '" << location_ << "'" << endl;
00173 }
00174
00175
00176
00177 baseHtmlDir_ = ps.getUntrackedParameter<string>("baseHtmlDir", "");
00178
00179 if ( verbose_ ) {
00180 if ( baseHtmlDir_.size() != 0 ) {
00181 cout << " HTML output will go to"
00182 << " baseHtmlDir = '" << baseHtmlDir_ << "'" << endl;
00183 } else {
00184 cout << " HTML output is OFF" << endl;
00185 }
00186 }
00187
00188
00189
00190 cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
00191
00192 if ( verbose_ ) {
00193 if ( cloneME_ ) {
00194 cout << " cloneME switch is ON" << endl;
00195 } else {
00196 cout << " cloneME switch is OFF" << endl;
00197 }
00198 }
00199
00200
00201
00202 debug_ = ps.getUntrackedParameter<bool>("debug", false);
00203
00204 if ( verbose_ ) {
00205 if ( debug_ ) {
00206 cout << " debug switch is ON" << endl;
00207 } else {
00208 cout << " debug switch is OFF" << endl;
00209 }
00210 }
00211
00212
00213
00214 prescaleFactor_ = ps.getUntrackedParameter<int>("prescaleFactor", 1);
00215
00216 if ( verbose_ ) {
00217 cout << " prescaleFactor = " << prescaleFactor_ << endl;
00218 }
00219
00220
00221
00222 enableMonitorDaemon_ = ps.getUntrackedParameter<bool>("enableMonitorDaemon", false);
00223
00224 if ( verbose_ ) {
00225 if ( enableMonitorDaemon_ ) {
00226 cout << " enableMonitorDaemon switch is ON" << endl;
00227 } else {
00228 cout << " enableMonitorDaemon switch is OFF" << endl;
00229 }
00230 }
00231
00232
00233
00234 prefixME_ = ps.getUntrackedParameter<string>("prefixME", "");
00235
00236 if ( verbose_ ) {
00237 cout << " prefixME path is '" << prefixME_ << "'" << endl;
00238 }
00239
00240
00241
00242 enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
00243
00244 if ( verbose_ ) {
00245 if ( enableCleanup_ ) {
00246 cout << " enableCleanup switch is ON" << endl;
00247 } else {
00248 cout << " enableCleanup switch is OFF" << endl;
00249 }
00250 }
00251
00252
00253
00254 enableUpdate_ = ps.getUntrackedParameter<bool>("enableUpdate", false);
00255
00256 if ( verbose_ ) {
00257 if ( enableUpdate_ ) {
00258 cout << " enableUpdate switch is ON" << endl;
00259 } else {
00260 cout << " enableUpdate switch is OFF" << endl;
00261 }
00262 }
00263
00264
00265
00266 clientName_ = ps.getUntrackedParameter<string>("clientName", "EcalBarrelMonitorClient");
00267
00268 if ( enableMonitorDaemon_ ) {
00269
00270
00271
00272 hostName_ = ps.getUntrackedParameter<string>("hostName", "localhost");
00273
00274
00275
00276 hostPort_ = ps.getUntrackedParameter<int>("hostPort", 9090);
00277
00278 if ( verbose_ ) {
00279 cout << " Client '" << clientName_ << "' " << endl
00280 << " Collector on host '" << hostName_ << "'"
00281 << " on port '" << hostPort_ << "'" << endl;
00282 }
00283
00284 }
00285
00286
00287
00288 superModules_.reserve(36);
00289 for ( unsigned int i = 1; i <= 36; i++ ) superModules_.push_back(i);
00290
00291 superModules_ = ps.getUntrackedParameter<vector<int> >("superModules", superModules_);
00292
00293 if ( verbose_ ) {
00294 cout << " Selected SMs:" << endl;
00295 for ( unsigned int i = 0; i < superModules_.size(); i++ ) {
00296 cout << " " << setw(2) << setfill('0') << superModules_[i];
00297 }
00298 cout << endl;
00299 }
00300
00301
00302
00303 enabledClients_.push_back("Integrity");
00304 enabledClients_.push_back("StatusFlags");
00305 enabledClients_.push_back("PedestalOnline");
00306 enabledClients_.push_back("Summary");
00307
00308 enabledClients_ = ps.getUntrackedParameter<vector<string> >("enabledClients", enabledClients_);
00309
00310 if ( verbose_ ) {
00311 cout << " Enabled Clients:" << endl;
00312 for ( unsigned int i = 0; i < enabledClients_.size(); i++ ) {
00313 cout << " " << enabledClients_[i];
00314 }
00315 cout << endl;
00316 }
00317
00318
00319
00320 gStyle->Reset("Default");
00321
00322 gStyle->SetCanvasColor(10);
00323 gStyle->SetPadColor(10);
00324 gStyle->SetFillColor(10);
00325 gStyle->SetStatColor(10);
00326 gStyle->SetTitleFillColor(10);
00327
00328 TGaxis::SetMaxDigits(4);
00329
00330 gStyle->SetOptTitle(kTRUE);
00331 gStyle->SetTitleX(0.01);
00332 gStyle->SetTitleY(1.00);
00333 gStyle->SetTitleW(0.00);
00334 gStyle->SetTitleH(0.05);
00335 gStyle->SetTitleBorderSize(0);
00336 gStyle->SetTitleFont(43, "c");
00337 gStyle->SetTitleFontSize(11);
00338
00339 gStyle->SetOptStat(kFALSE);
00340 gStyle->SetStatX(0.99);
00341 gStyle->SetStatY(0.99);
00342 gStyle->SetStatW(0.25);
00343 gStyle->SetStatH(0.20);
00344 gStyle->SetStatBorderSize(1);
00345 gStyle->SetStatFont(43);
00346 gStyle->SetStatFontSize(10);
00347
00348 gStyle->SetOptFit(kFALSE);
00349
00350 gROOT->ForceStyle();
00351
00352
00353
00354 for( int i=0; i<6; i++ ) {
00355 TColor* color = gROOT->GetColor( 301+i );
00356 if ( ! color ) color = new TColor( 301+i, 0, 0, 0, "");
00357 color->SetRGB( ecdqm::rgb[i][0], ecdqm::rgb[i][1], ecdqm::rgb[i][2] );
00358 }
00359
00360 for( int i=0; i<10; i++ ) {
00361 TColor* color = gROOT->GetColor( 401+i );
00362 if ( ! color ) color = new TColor( 401+i, 0, 0, 0, "");
00363 color->SetRGB( ecdqm::rgb2[i][0], ecdqm::rgb2[i][1], ecdqm::rgb2[i][2] );
00364 }
00365
00366 for( int i=0; i<10; i++ ) {
00367 TColor* color = gROOT->GetColor( 501+i );
00368 if ( ! color ) color = new TColor( 501+i, 0, 0, 0, "");
00369 color->SetRGB( ecdqm::rgb2[i][1], 0, 0 );
00370 }
00371
00372
00373
00374 runTypes_.resize(30);
00375 for ( unsigned int i = 0; i < runTypes_.size(); i++ ) runTypes_[i] = "UNKNOWN";
00376
00377 runTypes_[EcalDCCHeaderBlock::COSMIC] = "COSMIC";
00378 runTypes_[EcalDCCHeaderBlock::BEAMH4] = "BEAM";
00379 runTypes_[EcalDCCHeaderBlock::BEAMH2] = "BEAM";
00380 runTypes_[EcalDCCHeaderBlock::MTCC] = "PHYSICS";
00381 runTypes_[EcalDCCHeaderBlock::LASER_STD] = "LASER";
00382 runTypes_[EcalDCCHeaderBlock::LED_STD] = "LED";
00383 runTypes_[EcalDCCHeaderBlock::TESTPULSE_MGPA] = "TEST_PULSE";
00384 runTypes_[EcalDCCHeaderBlock::PEDESTAL_STD] = "PEDESTAL";
00385 runTypes_[EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN] = "PEDESTAL-OFFSET";
00386
00387 runTypes_[EcalDCCHeaderBlock::COSMICS_GLOBAL] = "COSMIC";
00388 runTypes_[EcalDCCHeaderBlock::PHYSICS_GLOBAL] = "PHYSICS";
00389 runTypes_[EcalDCCHeaderBlock::HALO_GLOBAL] = "HALO";
00390 runTypes_[EcalDCCHeaderBlock::COSMICS_LOCAL] = "COSMIC";
00391 runTypes_[EcalDCCHeaderBlock::PHYSICS_LOCAL] = "PHYSICS";
00392 runTypes_[EcalDCCHeaderBlock::HALO_LOCAL] = "HALO";
00393
00394 runTypes_[EcalDCCHeaderBlock::LASER_GAP] = "LASER";
00395 runTypes_[EcalDCCHeaderBlock::LED_GAP] = "LED";
00396 runTypes_[EcalDCCHeaderBlock::TESTPULSE_GAP] = "TEST_PULSE";
00397 runTypes_[EcalDCCHeaderBlock::PEDESTAL_GAP] = "PEDESTAL";
00398
00399 runTypes_[EcalDCCHeaderBlock::CALIB_LOCAL] = "CALIB";
00400
00401
00402
00403 clients_.reserve(12);
00404 clientsNames_.reserve(12);
00405
00406 if ( find(enabledClients_.begin(), enabledClients_.end(), "Integrity" ) != enabledClients_.end() ) {
00407
00408 clients_.push_back( new EBIntegrityClient(ps) );
00409 clientsNames_.push_back( "Integrity" );
00410
00411 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
00412 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
00413 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
00414 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN ));
00415 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
00416 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
00417 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
00418 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
00419
00420 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
00421 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
00422 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
00423 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
00424 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
00425 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
00426 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
00427
00428 }
00429
00430 if ( find(enabledClients_.begin(), enabledClients_.end(), "StatusFlags" ) != enabledClients_.end() ) {
00431
00432 clients_.push_back( new EBStatusFlagsClient(ps) );
00433 clientsNames_.push_back( "StatusFlags" );
00434
00435 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
00436 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
00437 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
00438 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN ));
00439 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
00440 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
00441 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
00442 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
00443
00444 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
00445 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
00446 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
00447 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
00448 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
00449 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
00450 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
00451
00452 }
00453
00454 if ( find(enabledClients_.begin(), enabledClients_.end(), "Occupancy" ) != enabledClients_.end() ) {
00455
00456 clients_.push_back( new EBOccupancyClient(ps) );
00457 clientsNames_.push_back( "Occupancy" );
00458
00459 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
00460 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
00461 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
00462 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN ));
00463 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
00464 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
00465 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
00466 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
00467
00468 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
00469 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
00470 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
00471 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
00472 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
00473 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
00474 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
00475
00476 }
00477
00478 if ( find(enabledClients_.begin(), enabledClients_.end(), "Cosmic" ) != enabledClients_.end() ) {
00479
00480 clients_.push_back( new EBCosmicClient(ps) );
00481 clientsNames_.push_back( "Cosmic" );
00482
00483 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
00484 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
00485 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
00486 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
00487 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
00488
00489 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
00490 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
00491 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
00492 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
00493 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
00494 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
00495 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
00496
00497 }
00498
00499 if ( find(enabledClients_.begin(), enabledClients_.end(), "Laser" ) != enabledClients_.end() ) {
00500
00501 clients_.push_back( new EBLaserClient(ps) );
00502 clientsNames_.push_back( "Laser" );
00503
00504 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
00505 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
00506 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
00507 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
00508 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
00509 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
00510
00511 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
00512 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
00513 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
00514 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
00515 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
00516 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
00517 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
00518
00519 }
00520
00521 if ( find(enabledClients_.begin(), enabledClients_.end(), "Pedestal" ) != enabledClients_.end() ) {
00522
00523 clients_.push_back( new EBPedestalClient(ps) );
00524 clientsNames_.push_back( "Pedestal" );
00525
00526 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
00527 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
00528 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
00529 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
00530
00531 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
00532 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
00533 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
00534 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
00535 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
00536 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
00537 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
00538
00539 }
00540
00541 if ( find(enabledClients_.begin(), enabledClients_.end(), "PedestalOnline" ) != enabledClients_.end() ) {
00542
00543 clients_.push_back( new EBPedestalOnlineClient(ps) );
00544 clientsNames_.push_back( "PedestalOnline" );
00545
00546 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
00547 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
00548 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
00549 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
00550 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
00551 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
00552 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
00553
00554 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
00555 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
00556 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
00557 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
00558 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
00559 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
00560 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
00561
00562 }
00563
00564 if ( find(enabledClients_.begin(), enabledClients_.end(), "TestPulse" ) != enabledClients_.end() ) {
00565
00566 clients_.push_back( new EBTestPulseClient(ps) );
00567 clientsNames_.push_back( "TestPulse" );
00568
00569 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
00570 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
00571 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
00572 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
00573
00574 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
00575 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
00576 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
00577 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
00578 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
00579 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
00580 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
00581
00582 }
00583
00584 if ( find(enabledClients_.begin(), enabledClients_.end(), "BeamCalo" ) != enabledClients_.end() ) {
00585
00586 clients_.push_back( new EBBeamCaloClient(ps) );
00587 clientsNames_.push_back( "BeamCalo" );
00588
00589 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
00590 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
00591
00592 }
00593
00594 if ( find(enabledClients_.begin(), enabledClients_.end(), "BeamHodo" ) != enabledClients_.end() ) {
00595
00596 clients_.push_back( new EBBeamHodoClient(ps) );
00597 clientsNames_.push_back( "BeamHodo" );
00598
00599 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
00600 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
00601
00602 }
00603
00604 if ( find(enabledClients_.begin(), enabledClients_.end(), "TriggerTower" ) != enabledClients_.end() ) {
00605
00606 clients_.push_back( new EBTriggerTowerClient(ps) );
00607 clientsNames_.push_back( "TriggerTower" );
00608
00609 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
00610 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
00611 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
00612 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
00613
00614 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
00615 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
00616 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
00617 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
00618
00619 }
00620
00621 if ( find(enabledClients_.begin(), enabledClients_.end(), "Cluster" ) != enabledClients_.end() ) {
00622
00623 clients_.push_back( new EBClusterClient(ps) );
00624 clientsNames_.push_back( "Cluster" );
00625
00626 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
00627 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
00628 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
00629 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
00630
00631 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
00632 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
00633 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
00634 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
00635
00636 }
00637
00638 if ( find(enabledClients_.begin(), enabledClients_.end(), "Timing" ) != enabledClients_.end() ) {
00639
00640 clients_.push_back( new EBTimingClient(ps) );
00641 clientsNames_.push_back( "Timing" );
00642
00643 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
00644 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
00645
00646 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
00647 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
00648 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
00649 clientsRuns_.insert(pair<EBClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
00650
00651 }
00652
00653
00654
00655 clientsStatus_.insert(pair<string,int>( "Integrity", 0 ));
00656 clientsStatus_.insert(pair<string,int>( "Cosmic", 1 ));
00657 clientsStatus_.insert(pair<string,int>( "Laser", 2 ));
00658 clientsStatus_.insert(pair<string,int>( "Pedestal", 3 ));
00659 clientsStatus_.insert(pair<string,int>( "PedestalOnline", 4 ));
00660 clientsStatus_.insert(pair<string,int>( "TestPulse", 5 ));
00661 clientsStatus_.insert(pair<string,int>( "BeamCalo", 6 ));
00662 clientsStatus_.insert(pair<string,int>( "BeamHodo", 7 ));
00663 clientsStatus_.insert(pair<string,int>( "TriggerTower", 8 ));
00664 clientsStatus_.insert(pair<string,int>( "Cluster", 9 ));
00665 clientsStatus_.insert(pair<string,int>( "Timing", 10 ));
00666 clientsStatus_.insert(pair<string,int>( "Led", 11 ));
00667 clientsStatus_.insert(pair<string,int>( "StatusFlags", 12 ));
00668 clientsStatus_.insert(pair<string,int>( "Occupancy", 13 ));
00669
00670 if ( find(enabledClients_.begin(), enabledClients_.end(), "Summary" ) != enabledClients_.end() ) {
00671
00672 summaryClient_ = new EBSummaryClient(ps);
00673
00674 }
00675
00676 if ( summaryClient_ ) summaryClient_->setFriends(clients_);
00677
00678 if ( verbose_ ) cout << endl;
00679
00680 }
00681
00682 EcalBarrelMonitorClient::~EcalBarrelMonitorClient() {
00683
00684 if ( verbose_ ) cout << "Exit ..." << endl;
00685
00686 for ( unsigned int i=0; i<clients_.size(); i++ ) {
00687 delete clients_[i];
00688 }
00689
00690 if ( summaryClient_ ) delete summaryClient_;
00691
00692 if ( enableMonitorDaemon_ ) delete mui_;
00693
00694 }
00695
00696 void EcalBarrelMonitorClient::beginJob(const EventSetup &c) {
00697
00698 begin_run_ = false;
00699 end_run_ = false;
00700
00701 forced_status_ = false;
00702 forced_update_ = false;
00703
00704 h_ = 0;
00705
00706 status_ = "unknown";
00707
00708 run_ = -1;
00709 evt_ = -1;
00710
00711 runType_ = -1;
00712 evtType_ = -1;
00713
00714 last_run_ = -1;
00715
00716 subrun_ = -1;
00717
00718 if ( debug_ ) cout << "EcalBarrelMonitorClient: beginJob" << endl;
00719
00720 ievt_ = 0;
00721 jevt_ = 0;
00722
00723 current_time_ = time(NULL);
00724 last_time_update_ = current_time_;
00725 last_time_db_ = current_time_;
00726 last_time_html_ = current_time_;
00727
00728 if ( enableMonitorDaemon_ ) {
00729
00730
00731
00732
00733 mui_ = new DQMOldReceiver(hostName_, hostPort_, clientName_, 5);
00734 dqmStore_ = mui_->getBEInterface();
00735
00736 } else {
00737
00738
00739
00740 mui_ = 0;
00741 dqmStore_ = Service<DQMStore>().operator->();
00742
00743 }
00744
00745 if ( ! enableMonitorDaemon_ ) {
00746 if ( inputFile_.size() != 0 ) {
00747 if ( dqmStore_ ) {
00748 dqmStore_->open(inputFile_);
00749 }
00750 }
00751 }
00752
00753 for ( unsigned int i=0; i<clients_.size(); i++ ) {
00754 clients_[i]->beginJob(dqmStore_);
00755 }
00756
00757 if ( summaryClient_ ) summaryClient_->beginJob(dqmStore_);
00758
00759 Numbers::initGeometry(c, verbose_);
00760
00761 }
00762
00763 void EcalBarrelMonitorClient::beginRun(void) {
00764
00765 begin_run_ = true;
00766 end_run_ = false;
00767
00768 last_run_ = run_;
00769
00770 if ( debug_ ) cout << "EcalBarrelMonitorClient: beginRun" << endl;
00771
00772 jevt_ = 0;
00773
00774 current_time_ = time(NULL);
00775 last_time_update_ = current_time_;
00776 last_time_db_ = current_time_;
00777 last_time_html_ = current_time_;
00778
00779 this->setup();
00780
00781 this->beginRunDb();
00782
00783 for ( int i=0; i<int(clients_.size()); i++ ) {
00784 clients_[i]->cleanup();
00785 bool done = false;
00786 for ( multimap<EBClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
00787 if ( runType_ != -1 && runType_ == (*j).second && !done ) {
00788 done = true;
00789 clients_[i]->beginRun();
00790 }
00791 }
00792 }
00793
00794 if ( summaryClient_ ) summaryClient_->beginRun();
00795
00796 }
00797
00798 void EcalBarrelMonitorClient::beginRun(const Run& r, const EventSetup& c) {
00799
00800 if ( verbose_ ) {
00801 cout << endl;
00802 cout << "Standard beginRun() for run " << r.id().run() << endl;
00803 cout << endl;
00804 }
00805
00806 run_ = r.id().run();
00807 evt_ = 0;
00808
00809 jevt_ = 0;
00810
00811 }
00812
00813 void EcalBarrelMonitorClient::endJob(void) {
00814
00815 if ( ! end_run_ ) {
00816
00817 if ( verbose_ ) {
00818 cout << endl;
00819 cout << "Checking last event at endJob() ... " << endl;
00820 cout << endl;
00821 }
00822
00823 forced_update_ = true;
00824 this->analyze();
00825
00826 if ( begin_run_ && ! end_run_ ) {
00827
00828 if ( verbose_ ) {
00829 cout << endl;
00830 cout << "Forcing endRun() ... " << endl;
00831 cout << endl;
00832 }
00833
00834 forced_status_ = true;
00835 this->analyze();
00836 this->endRun();
00837
00838 }
00839
00840 }
00841
00842 if ( debug_ ) cout << "EcalBarrelMonitorClient: endJob, ievt = " << ievt_ << endl;
00843
00844 this->cleanup();
00845
00846 for ( unsigned int i=0; i<clients_.size(); i++ ) {
00847 clients_[i]->endJob();
00848 }
00849
00850 if ( summaryClient_ ) summaryClient_->endJob();
00851
00852 }
00853
00854 void EcalBarrelMonitorClient::endRun(void) {
00855
00856 begin_run_ = false;
00857 end_run_ = true;
00858
00859 if ( debug_ ) cout << "EcalBarrelMonitorClient: endRun, jevt = " << jevt_ << endl;
00860
00861 if ( baseHtmlDir_.size() != 0 ) this->htmlOutput();
00862
00863 if ( subrun_ != -1 ) {
00864
00865 this->writeDb(true);
00866
00867 this->endRunDb();
00868
00869 }
00870
00871 for ( int i=0; i<int(clients_.size()); i++ ) {
00872 bool done = false;
00873 for ( multimap<EBClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
00874 if ( runType_ != -1 && runType_ == (*j).second && !done ) {
00875 done = true;
00876 clients_[i]->endRun();
00877 }
00878 }
00879 }
00880
00881 if ( summaryClient_ ) summaryClient_->endRun();
00882
00883 this->cleanup();
00884
00885 status_ = "unknown";
00886
00887 run_ = -1;
00888 evt_ = -1;
00889
00890 runType_ = -1;
00891 evtType_ = -1;
00892
00893 subrun_ = -1;
00894
00895 }
00896
00897 void EcalBarrelMonitorClient::endRun(const Run& r, const EventSetup& c) {
00898
00899 if ( verbose_ ) {
00900 cout << endl;
00901 cout << "Standard endRun() for run " << r.id().run() << endl;
00902 cout << endl;
00903 }
00904
00905 this->analyze();
00906
00907 if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
00908
00909 forced_update_ = true;
00910 this->analyze();
00911
00912 if ( ! mergeRuns_ ) {
00913
00914 if ( begin_run_ && ! end_run_ ) {
00915
00916 forced_status_ = false;
00917 this->endRun();
00918
00919 }
00920
00921 }
00922
00923 }
00924
00925 }
00926
00927 void EcalBarrelMonitorClient::beginLuminosityBlock(const LuminosityBlock &l, const EventSetup &c) {
00928
00929 if ( verbose_ ) {
00930 cout << endl;
00931 cout << "Standard beginLuminosityBlock() for run " << l.id().run() << endl;
00932 cout << endl;
00933 }
00934
00935 }
00936
00937 void EcalBarrelMonitorClient::endLuminosityBlock(const LuminosityBlock &l, const EventSetup &c) {
00938
00939 current_time_ = time(NULL);
00940
00941 if ( verbose_ ) {
00942 cout << endl;
00943 cout << "Standard endLuminosityBlock() for run " << l.id().run() << endl;
00944 cout << endl;
00945 }
00946
00947 if ( updateTime_ > 0 ) {
00948 if ( (current_time_ - last_time_update_) < 60 * updateTime_ ) {
00949 return;
00950 }
00951 last_time_update_ = current_time_;
00952 }
00953
00954 if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
00955
00956 forced_update_ = true;
00957 this->analyze();
00958
00959 }
00960
00961 }
00962
00963 void EcalBarrelMonitorClient::reset(void) {
00964
00965 }
00966
00967 void EcalBarrelMonitorClient::setup(void) {
00968
00969 }
00970
00971 void EcalBarrelMonitorClient::cleanup(void) {
00972
00973 if ( ! enableCleanup_ ) return;
00974
00975 if ( cloneME_ ) {
00976 if ( h_ ) delete h_;
00977 }
00978
00979 h_ = 0;
00980
00981 }
00982
00983 void EcalBarrelMonitorClient::beginRunDb(void) {
00984
00985 subrun_ = 0;
00986
00987 EcalCondDBInterface* econn;
00988
00989 econn = 0;
00990
00991 if ( dbName_.size() != 0 ) {
00992 try {
00993 if ( verbose_ ) cout << "Opening DB connection with TNS_ADMIN ..." << endl;
00994 econn = new EcalCondDBInterface(dbName_, dbUserName_, dbPassword_);
00995 if ( verbose_ ) cout << "done." << endl;
00996 } catch (runtime_error &e) {
00997 cerr << e.what() << endl;
00998 if ( dbHostName_.size() != 0 ) {
00999 try {
01000 if ( verbose_ ) cout << "Opening DB connection without TNS_ADMIN ..." << endl;
01001 econn = new EcalCondDBInterface(dbHostName_, dbName_, dbUserName_, dbPassword_, dbHostPort_);
01002 if ( verbose_ ) cout << "done." << endl;
01003 } catch (runtime_error &e) {
01004 cerr << e.what() << endl;
01005 }
01006 }
01007 }
01008 }
01009
01010
01011
01012 LocationDef locdef;
01013
01014 locdef.setLocation(location_);
01015
01016 RunTypeDef rundef;
01017
01018 rundef.setRunType( this->getRunType() );
01019
01020 RunTag runtag;
01021
01022 runtag.setLocationDef(locdef);
01023 runtag.setRunTypeDef(rundef);
01024
01025 runtag.setGeneralTag( this->getRunType() );
01026
01027
01028
01029 bool foundRunIOV = false;
01030
01031 if ( econn ) {
01032 try {
01033 if ( verbose_ ) cout << "Fetching RunIOV ..." << endl;
01034
01035 runiov_ = econn->fetchRunIOV(location_, run_);
01036 if ( verbose_ ) cout << "done." << endl;
01037 foundRunIOV = true;
01038 } catch (runtime_error &e) {
01039 cerr << e.what() << endl;
01040 foundRunIOV = false;
01041 }
01042 }
01043
01044
01045
01046 if ( ! foundRunIOV ) {
01047
01048 Tm startRun;
01049
01050 startRun.setToCurrentGMTime();
01051
01052 runiov_.setRunNumber(run_);
01053 runiov_.setRunStart(startRun);
01054 runiov_.setRunTag(runtag);
01055
01056 if ( econn ) {
01057 try {
01058 if ( verbose_ ) cout << "Inserting RunIOV ..." << endl;
01059 econn->insertRunIOV(&runiov_);
01060
01061 runiov_ = econn->fetchRunIOV(location_, run_);
01062 if ( verbose_ ) cout << "done." << endl;
01063 } catch (runtime_error &e) {
01064 cerr << e.what() << endl;
01065 try {
01066 if ( verbose_ ) cout << "Fetching RunIOV (again) ..." << endl;
01067
01068 runiov_ = econn->fetchRunIOV(location_, run_);
01069 if ( verbose_ ) cout << "done." << endl;
01070 foundRunIOV = true;
01071 } catch (runtime_error &e) {
01072 cerr << e.what() << endl;
01073 foundRunIOV = false;
01074 }
01075 }
01076 }
01077
01078 }
01079
01080
01081
01082 if ( verbose_ ) {
01083 cout << endl;
01084 cout << "=============RunIOV:" << endl;
01085 cout << "Run Number: " << runiov_.getRunNumber() << endl;
01086 cout << "Run Start: " << runiov_.getRunStart().str() << endl;
01087 cout << "Run End: " << runiov_.getRunEnd().str() << endl;
01088 cout << "====================" << endl;
01089 cout << endl;
01090 cout << "=============RunTag:" << endl;
01091 cout << "GeneralTag: " << runiov_.getRunTag().getGeneralTag() << endl;
01092 cout << "Location: " << runiov_.getRunTag().getLocationDef().getLocation() << endl;
01093 cout << "Run Type: " << runiov_.getRunTag().getRunTypeDef().getRunType() << endl;
01094 cout << "====================" << endl;
01095 cout << endl;
01096 }
01097
01098 string rt = runiov_.getRunTag().getRunTypeDef().getRunType();
01099 if ( strcmp(rt.c_str(), "UNKNOWN") == 0 ) {
01100 runType_ = -1;
01101 } else {
01102 for ( unsigned int i = 0; i < runTypes_.size(); i++ ) {
01103 if ( strcmp(rt.c_str(), runTypes_[i].c_str()) == 0 ) {
01104 if ( runType_ != int(i) ) {
01105 if ( verbose_ ) {
01106 cout << endl;
01107 cout << "Fixing Run Type to: " << runTypes_[i] << endl;
01108 cout << endl;
01109 }
01110 runType_ = i;
01111 }
01112 break;
01113 }
01114 }
01115 }
01116
01117 if ( maskFile_.size() != 0 ) {
01118 try {
01119 if ( verbose_ ) cout << "Fetching masked channels from file ..." << endl;
01120 EcalErrorMask::readFile(maskFile_, debug_);
01121 if ( verbose_ ) cout << "done." << endl;
01122 } catch (runtime_error &e) {
01123 cerr << e.what() << endl;
01124 }
01125 } else {
01126 if ( econn ) {
01127 try {
01128 if ( verbose_ ) cout << "Fetching masked channels from DB ..." << endl;
01129 EcalErrorMask::readDB(econn, &runiov_);
01130 if ( verbose_ ) cout << "done." << endl;
01131 } catch (runtime_error &e) {
01132 cerr << e.what() << endl;
01133 }
01134 }
01135 }
01136
01137 cout << endl;
01138
01139 if ( econn ) {
01140 try {
01141 if ( verbose_ ) cout << "Closing DB connection ..." << endl;
01142 delete econn;
01143 econn = 0;
01144 if ( verbose_ ) cout << "done." << endl;
01145 } catch (runtime_error &e) {
01146 cerr << e.what() << endl;
01147 }
01148 }
01149
01150 if ( verbose_ ) cout << endl;
01151
01152 }
01153
01154 void EcalBarrelMonitorClient::writeDb(bool flag) {
01155
01156 subrun_++;
01157
01158 EcalCondDBInterface* econn;
01159
01160 econn = 0;
01161
01162 if ( dbName_.size() != 0 ) {
01163 try {
01164 if ( verbose_ ) cout << "Opening DB connection with TNS_ADMIN ..." << endl;
01165 econn = new EcalCondDBInterface(dbName_, dbUserName_, dbPassword_);
01166 if ( verbose_ ) cout << "done." << endl;
01167 } catch (runtime_error &e) {
01168 cerr << e.what() << endl;
01169 if ( dbHostName_.size() != 0 ) {
01170 try {
01171 if ( verbose_ ) cout << "Opening DB connection without TNS_ADMIN ..." << endl;
01172 econn = new EcalCondDBInterface(dbHostName_, dbName_, dbUserName_, dbPassword_, dbHostPort_);
01173 if ( verbose_ ) cout << "done." << endl;
01174 } catch (runtime_error &e) {
01175 cerr << e.what() << endl;
01176 }
01177 }
01178 }
01179 }
01180
01181 MonVersionDef monverdef;
01182
01183 monverdef.setMonitoringVersion("test01");
01184
01185 MonRunTag montag;
01186
01187 montag.setMonVersionDef(monverdef);
01188 montag.setGeneralTag(dbTagName_);
01189
01190 Tm startSubRun;
01191
01192 startSubRun.setToCurrentGMTime();
01193
01194
01195
01196 moniov_.setRunIOV(runiov_);
01197 moniov_.setSubRunNumber(subrun_);
01198
01199 if ( enableMonitorDaemon_ ) {
01200 moniov_.setSubRunStart(startSubRun);
01201 } else {
01202 moniov_.setSubRunStart(runiov_.getRunStart());
01203 }
01204
01205 moniov_.setMonRunTag(montag);
01206
01207 if ( verbose_ ) {
01208 cout << endl;
01209 cout << "==========MonRunIOV:" << endl;
01210 cout << "SubRun Number: " << moniov_.getSubRunNumber() << endl;
01211 cout << "SubRun Start: " << moniov_.getSubRunStart().str() << endl;
01212 cout << "SubRun End: " << moniov_.getSubRunEnd().str() << endl;
01213 cout << "====================" << endl;
01214 cout << endl;
01215 cout << "==========MonRunTag:" << endl;
01216 cout << "GeneralTag: " << moniov_.getMonRunTag().getGeneralTag() << endl;
01217 cout << "Monitoring Ver: " << moniov_.getMonRunTag().getMonVersionDef().getMonitoringVersion() << endl;
01218 cout << "====================" << endl;
01219 cout << endl;
01220 }
01221
01222 int taskl = 0x0;
01223 int tasko = 0x0;
01224
01225 for ( int i=0; i<int(clients_.size()); i++ ) {
01226 bool done = false;
01227 for ( multimap<EBClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
01228 if ( h_ && runType_ != -1 && runType_ == (*j).second && !done ) {
01229 if ( strcmp(clientsNames_[i].c_str(), "Cosmic") == 0 && runType_ != EcalDCCHeaderBlock::COSMIC && runType_ != EcalDCCHeaderBlock::COSMICS_LOCAL && runType_ != EcalDCCHeaderBlock::COSMICS_GLOBAL && runType_ != EcalDCCHeaderBlock::PHYSICS_GLOBAL && runType_ != EcalDCCHeaderBlock::PHYSICS_LOCAL && h_->GetBinContent(2+EcalDCCHeaderBlock::COSMIC) == 0 && h_->GetBinContent(2+EcalDCCHeaderBlock::COSMICS_LOCAL) == 0 && h_->GetBinContent(2+EcalDCCHeaderBlock::COSMICS_GLOBAL) == 0 && h_->GetBinContent(2+EcalDCCHeaderBlock::PHYSICS_GLOBAL) == 0 && h_->GetBinContent(2+EcalDCCHeaderBlock::PHYSICS_LOCAL) == 0 ) continue;
01230 if ( strcmp(clientsNames_[i].c_str(), "Laser") == 0 && runType_ != EcalDCCHeaderBlock::LASER_STD && runType_ != EcalDCCHeaderBlock::LASER_GAP && h_->GetBinContent(2+EcalDCCHeaderBlock::LASER_STD) == 0 && h_->GetBinContent(2+EcalDCCHeaderBlock::LASER_GAP) == 0 ) continue;
01231 if ( strcmp(clientsNames_[i].c_str(), "Pedestal") == 0 && runType_ != EcalDCCHeaderBlock::PEDESTAL_STD && runType_ != EcalDCCHeaderBlock::PEDESTAL_GAP && h_->GetBinContent(2+EcalDCCHeaderBlock::PEDESTAL_STD) == 0 && h_->GetBinContent(2+EcalDCCHeaderBlock::PEDESTAL_GAP) == 0 ) continue;
01232 if ( strcmp(clientsNames_[i].c_str(), "TestPulse") == 0 && runType_ != EcalDCCHeaderBlock::TESTPULSE_MGPA && runType_ != EcalDCCHeaderBlock::TESTPULSE_GAP && h_->GetBinContent(2+EcalDCCHeaderBlock::TESTPULSE_MGPA) == 0 && h_->GetBinContent(2+EcalDCCHeaderBlock::TESTPULSE_GAP) == 0 ) continue;
01233 done = true;
01234 if ( verbose_ ) {
01235 if ( econn ) {
01236 cout << " Writing " << clientsNames_[i] << " results to DB " << endl;
01237 cout << endl;
01238 }
01239 }
01240 bool status;
01241 if ( clients_[i]->writeDb(econn, &runiov_, &moniov_, status, flag) ) {
01242 taskl |= 0x1 << clientsStatus_[clientsNames_[i]];
01243 if ( status ) {
01244 tasko |= 0x1 << clientsStatus_[clientsNames_[i]];
01245 }
01246 } else {
01247 tasko |= 0x1 << clientsStatus_[clientsNames_[i]];
01248 }
01249 }
01250 }
01251 if ( ((taskl >> clientsStatus_[clientsNames_[i]]) & 0x1) ) {
01252 if ( verbose_ ) {
01253 cout << " Task output for " << clientsNames_[i] << " = "
01254 << ((tasko >> clientsStatus_[clientsNames_[i]]) & 0x1) << endl;
01255 cout << endl;
01256 }
01257 }
01258 }
01259
01260 bool status;
01261 if ( summaryClient_ ) summaryClient_->writeDb(econn, &runiov_, &moniov_, status, flag);
01262
01263 EcalLogicID ecid;
01264 MonRunDat md;
01265 map<EcalLogicID, MonRunDat> dataset;
01266
01267 MonRunOutcomeDef monRunOutcomeDef;
01268
01269 monRunOutcomeDef.setShortDesc("success");
01270
01271 float nevt = -1.;
01272
01273 if ( h_ ) nevt = h_->GetEntries();
01274
01275 md.setNumEvents(int(nevt));
01276 md.setMonRunOutcomeDef(monRunOutcomeDef);
01277
01278
01279
01280
01281 md.setTaskList(taskl);
01282 md.setTaskOutcome(tasko);
01283
01284 if ( econn ) {
01285 try {
01286 ecid = LogicID::getEcalLogicID("EB");
01287 dataset[ecid] = md;
01288 } catch (runtime_error &e) {
01289 cerr << e.what() << endl;
01290 }
01291 }
01292
01293 if ( econn ) {
01294 try {
01295 if ( verbose_ ) cout << "Inserting MonRunDat ..." << endl;
01296 econn->insertDataSet(&dataset, &moniov_);
01297 if ( verbose_ ) cout << "done." << endl;
01298 } catch (runtime_error &e) {
01299 cerr << e.what() << endl;
01300 }
01301 }
01302
01303 if ( econn ) {
01304 try {
01305 if ( verbose_ ) cout << "Closing DB connection ..." << endl;
01306 delete econn;
01307 econn = 0;
01308 if ( verbose_ ) cout << "done." << endl;
01309 } catch (runtime_error &e) {
01310 cerr << e.what() << endl;
01311 }
01312 }
01313
01314 cout << endl;
01315
01316 }
01317
01318 void EcalBarrelMonitorClient::endRunDb(void) {
01319
01320 EcalCondDBInterface* econn;
01321
01322 econn = 0;
01323
01324 if ( dbName_.size() != 0 ) {
01325 try {
01326 if ( verbose_ ) cout << "Opening DB connection with TNS_ADMIN ..." << endl;
01327 econn = new EcalCondDBInterface(dbName_, dbUserName_, dbPassword_);
01328 if ( verbose_ ) cout << "done." << endl;
01329 } catch (runtime_error &e) {
01330 cerr << e.what() << endl;
01331 if ( dbHostName_.size() != 0 ) {
01332 try {
01333 if ( verbose_ ) cout << "Opening DB connection without TNS_ADMIN ..." << endl;
01334 econn = new EcalCondDBInterface(dbHostName_, dbName_, dbUserName_, dbPassword_, dbHostPort_);
01335 if ( verbose_ ) cout << "done." << endl;
01336 } catch (runtime_error &e) {
01337 cerr << e.what() << endl;
01338 }
01339 }
01340 }
01341 }
01342
01343 EcalLogicID ecid;
01344 RunDat rd;
01345 map<EcalLogicID, RunDat> dataset;
01346
01347 float nevt = -1.;
01348
01349 if ( h_ ) nevt = h_->GetEntries();
01350
01351 rd.setNumEvents(int(nevt));
01352
01353
01354
01355 bool foundRunDat = false;
01356
01357 if ( econn ) {
01358 try {
01359 if ( verbose_ ) cout << "Fetching RunDat ..." << endl;
01360 econn->fetchDataSet(&dataset, &runiov_);
01361 if ( verbose_ ) cout << "done." << endl;
01362 foundRunDat = true;
01363 } catch (runtime_error &e) {
01364 cerr << e.what() << endl;
01365 foundRunDat = false;
01366 }
01367 }
01368
01369
01370
01371 if ( ! foundRunDat ) {
01372
01373 if ( econn ) {
01374 try {
01375 ecid = LogicID::getEcalLogicID("EB");
01376 dataset[ecid] = rd;
01377 } catch (runtime_error &e) {
01378 cerr << e.what() << endl;
01379 }
01380 }
01381
01382 if ( econn ) {
01383 try {
01384 if ( verbose_ ) cout << "Inserting RunDat ..." << endl;
01385 econn->insertDataSet(&dataset, &runiov_);
01386 if ( verbose_ ) cout << "done." << endl;
01387 } catch (runtime_error &e) {
01388 cerr << e.what() << endl;
01389 }
01390 }
01391
01392 }
01393
01394
01395
01396 if ( econn ) {
01397 try {
01398 if ( verbose_ ) cout << "Closing DB connection ..." << endl;
01399 delete econn;
01400 econn = 0;
01401 if ( verbose_ ) cout << "done." << endl;
01402 } catch (runtime_error &e) {
01403 cerr << e.what() << endl;
01404 }
01405 }
01406
01407 }
01408
01409 void EcalBarrelMonitorClient::analyze(void) {
01410
01411 current_time_ = time(NULL);
01412
01413 ievt_++;
01414 jevt_++;
01415
01416 if ( debug_ ) cout << "EcalBarrelMonitorClient: ievt/jevt = " << ievt_ << "/" << jevt_ << endl;
01417
01418
01419 if ( enableUpdate_ ) {
01420 if ( enableMonitorDaemon_ ) mui_->doMonitoring();
01421 }
01422
01423 MonitorElement* me;
01424 string s;
01425
01426 me = dqmStore_->get(prefixME_ + "/EcalInfo/STATUS");
01427 if ( me ) {
01428 status_ = "unknown";
01429 s = me->valueString();
01430 if ( strcmp(s.c_str(), "i=0") == 0 ) status_ = "begin-of-run";
01431 if ( strcmp(s.c_str(), "i=1") == 0 ) status_ = "running";
01432 if ( strcmp(s.c_str(), "i=2") == 0 ) status_ = "end-of-run";
01433 if ( debug_ ) cout << "Found '" << prefixME_ << "/EcalInfo/STATUS'" << endl;
01434 }
01435
01436 if ( inputFile_.size() != 0 ) {
01437 if ( ievt_ == 1 ) {
01438 if ( verbose_ ) {
01439 cout << endl;
01440 cout << " Reading DQM from file, forcing 'begin-of-run'" << endl;
01441 cout << endl;
01442 }
01443 status_ = "begin-of-run";
01444 }
01445 }
01446
01447 int ecal_run = -1;
01448 me = dqmStore_->get(prefixME_ + "/EcalInfo/RUN");
01449 if ( me ) {
01450 s = me->valueString();
01451 sscanf(s.c_str(), "i=%d", &ecal_run);
01452 if ( debug_ ) cout << "Found '" << prefixME_ << "/EcalInfo/RUN'" << endl;
01453 }
01454
01455 int ecal_evt = -1;
01456 me = dqmStore_->get(prefixME_ + "/EcalInfo/EVT");
01457 if ( me ) {
01458 s = me->valueString();
01459 sscanf(s.c_str(), "i=%d", &ecal_evt);
01460 if ( debug_ ) cout << "Found '" << prefixME_ << "/EcalInfo/EVT'" << endl;
01461 }
01462
01463 me = dqmStore_->get(prefixME_ + "/EcalInfo/EVTTYPE");
01464 h_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, h_ );
01465
01466 me = dqmStore_->get(prefixME_ + "/EcalInfo/RUNTYPE");
01467 if ( me ) {
01468 s = me->valueString();
01469 sscanf(s.c_str(), "i=%d", &evtType_);
01470 if ( runType_ == -1 ) runType_ = evtType_;
01471 if ( debug_ ) cout << "Found '" << prefixME_ << "/EcalInfo/RUNTYPE'" << endl;
01472 }
01473
01474
01475
01476 if ( run_ <= 0 ) run_ = ecal_run;
01477
01478 if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
01479 if ( ! mergeRuns_ && run_ != last_run_ ) forced_update_ = true;
01480 }
01481
01482 bool update = ( prescaleFactor_ != 1 ) ||
01483 ( jevt_ < 10 ) ||
01484 ( jevt_ < 100 && jevt_ % 10 == 0 ) ||
01485 ( jevt_ < 1000 && jevt_ % 100 == 0 ) ||
01486 ( jevt_ % 1000 == 0 );
01487
01488 if ( update || strcmp(status_.c_str(), "begin-of-run") == 0 || strcmp(status_.c_str(), "end-of-run") == 0 || forced_update_ ) {
01489
01490 if ( verbose_ ) {
01491 cout << " RUN status = \"" << status_ << "\"" << endl;
01492 cout << " CMS run/event number = " << run_ << "/" << evt_ << endl;
01493 cout << " EB run/event number = " << ecal_run << "/" << ecal_evt << endl;
01494 cout << " EB location = " << location_ << endl;
01495 cout << " EB run/event type = " << this->getRunType() << "/" << ( evtType_ == -1 ? "UNKNOWN" : runTypes_[evtType_] ) << flush;
01496
01497 if ( h_ ) {
01498 if ( h_->GetEntries() != 0 ) {
01499 cout << " ( " << flush;
01500 for ( unsigned int i = 0; i < runTypes_.size(); i++ ) {
01501 if ( strcmp(runTypes_[i].c_str(), "UNKNOWN") != 0 && h_->GetBinContent(2+i) != 0 ) {
01502 string s = runTypes_[i];
01503 transform( s.begin(), s.end(), s.begin(), (int(*)(int))tolower );
01504 cout << s << " ";
01505 }
01506 }
01507 cout << ")" << flush;
01508 }
01509 }
01510 cout << endl;
01511 }
01512
01513 }
01514
01515 if ( strcmp(status_.c_str(), "begin-of-run") == 0 ) {
01516
01517 if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
01518
01519 if ( ! begin_run_ ) {
01520
01521 forced_status_ = false;
01522 this->beginRun();
01523
01524 }
01525
01526 }
01527
01528 }
01529
01530 if ( strcmp(status_.c_str(), "begin-of-run") == 0 || strcmp(status_.c_str(), "running") == 0 || strcmp(status_.c_str(), "end-of-run") == 0 ) {
01531
01532 if ( begin_run_ && ! end_run_ ) {
01533
01534 bool update = ( prescaleFactor_ != 1 || jevt_ < 3 || jevt_ % 1000 == 0 );
01535
01536 if ( update || strcmp(status_.c_str(), "begin-of-run") == 0 || strcmp(status_.c_str(), "end-of-run") == 0 || forced_update_ ) {
01537
01538 for ( int i=0; i<int(clients_.size()); i++ ) {
01539 bool done = false;
01540 for ( multimap<EBClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
01541 if ( runType_ != -1 && runType_ == (*j).second && !done ) {
01542 done = true;
01543 clients_[i]->analyze();
01544 }
01545 }
01546 }
01547
01548 if ( summaryClient_ ) summaryClient_->analyze();
01549
01550 }
01551
01552 forced_update_ = false;
01553
01554 if ( htmlUpdateTime_ > 0 ) {
01555 if ( (current_time_ - last_time_html_) > 60 * htmlUpdateTime_ ) {
01556 last_time_html_ = current_time_;
01557 this->htmlOutput( true );
01558 }
01559 }
01560
01561 if ( dbUpdateTime_ > 0 ) {
01562 if ( (current_time_ - last_time_db_) > 60 * dbUpdateTime_ ) {
01563 if ( runType_ == EcalDCCHeaderBlock::COSMIC ||
01564 runType_ == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
01565 runType_ == EcalDCCHeaderBlock::PHYSICS_GLOBAL ||
01566 runType_ == EcalDCCHeaderBlock::COSMICS_LOCAL ||
01567 runType_ == EcalDCCHeaderBlock::PHYSICS_LOCAL ||
01568 runType_ == EcalDCCHeaderBlock::BEAMH2 ||
01569 runType_ == EcalDCCHeaderBlock::BEAMH4 ) this->writeDb(false);
01570 last_time_db_ = current_time_;
01571 }
01572 }
01573
01574 }
01575
01576 }
01577
01578 if ( strcmp(status_.c_str(), "end-of-run") == 0 ) {
01579
01580 if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
01581
01582 if ( begin_run_ && ! end_run_ ) {
01583
01584 forced_status_ = false;
01585 this->endRun();
01586
01587 }
01588
01589 }
01590
01591 }
01592
01593
01594
01595
01596
01597 if ( strcmp(status_.c_str(), "running") == 0 ) {
01598
01599 if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
01600
01601 if ( ! mergeRuns_ ) {
01602
01603 int new_run_ = run_;
01604 int old_run_ = last_run_;
01605
01606 if ( new_run_ != old_run_ ) {
01607
01608 if ( begin_run_ && ! end_run_ ) {
01609
01610 if ( verbose_ ) {
01611 cout << endl;
01612 cout << " Old run has finished, issuing endRun() ... " << endl;
01613 cout << endl;
01614 }
01615
01616
01617 run_ = old_run_;
01618
01619 forced_status_ = false;
01620 this->endRun();
01621
01622 }
01623
01624 if ( ! begin_run_ ) {
01625
01626 if ( verbose_ ) {
01627 cout << endl;
01628 cout << " New run has started, issuing beginRun() ... " << endl;
01629 cout << endl;
01630 }
01631
01632
01633 run_ = new_run_;
01634
01635 forced_status_ = false;
01636 this->beginRun();
01637
01638 }
01639
01640 }
01641
01642 }
01643
01644 }
01645
01646 }
01647
01648
01649
01650 if ( strcmp(status_.c_str(), "running") == 0 ) {
01651
01652 if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
01653
01654 if ( ! forced_status_ ) {
01655
01656 if ( ! begin_run_ ) {
01657
01658 if ( verbose_ ) {
01659 cout << endl;
01660 cout << "Forcing beginRun() ... NOW !" << endl;
01661 cout << endl;
01662 }
01663
01664 forced_status_ = true;
01665 this->beginRun();
01666
01667 }
01668
01669 }
01670
01671 }
01672
01673 }
01674
01675
01676
01677 }
01678
01679 void EcalBarrelMonitorClient::analyze(const Event &e, const EventSetup &c) {
01680
01681 run_ = e.id().run();
01682 evt_ = e.id().event();
01683
01684 if ( prescaleFactor_ > 0 ) {
01685 if ( jevt_ % prescaleFactor_ == 0 ) this->analyze();
01686 }
01687
01688 }
01689
01690 void EcalBarrelMonitorClient::softReset(bool flag) {
01691
01692 for ( int i=0; i<int(clients_.size()); i++ ) {
01693 bool done = false;
01694 for ( multimap<EBClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
01695 if ( runType_ != -1 && runType_ == (*j).second && !done ) {
01696 done = true;
01697 clients_[i]->softReset(flag);
01698 }
01699 }
01700 }
01701
01702 summaryClient_->softReset(flag);
01703
01704 }
01705
01706 void EcalBarrelMonitorClient::htmlOutput( bool current ) {
01707
01708 time_t start = time(NULL);
01709
01710 if ( verbose_ ) {
01711 cout << endl;
01712 cout << "Preparing EcalBarrelMonitorClient html output ..." << endl;
01713 }
01714
01715 char tmp[10];
01716
01717 sprintf(tmp, "%09d", run_);
01718
01719 string htmlDir;
01720 if( current ) {
01721 htmlDir = baseHtmlDir_ + "/current/";
01722 }
01723 else {
01724 htmlDir = baseHtmlDir_ + "/" + tmp + "/";
01725 }
01726
01727 system(("/bin/mkdir -p " + htmlDir).c_str());
01728
01729 ofstream htmlFile;
01730
01731 htmlFile.open((htmlDir + "index.html").c_str());
01732
01733
01734 htmlFile << "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"> " << endl;
01735 htmlFile << "<html> " << endl;
01736 htmlFile << "<head> " << endl;
01737 htmlFile << " <meta content=\"text/html; charset=ISO-8859-1\" " << endl;
01738 htmlFile << " https-equiv=\"content-type\"> " << endl;
01739 htmlFile << " <title>Monitor:Executed Tasks index</title> " << endl;
01740 htmlFile << "</head> " << endl;
01741 htmlFile << "<body> " << endl;
01742 htmlFile << "<br> " << endl;
01743 htmlFile << "<h2>Executed tasks for run:   " << endl;
01744 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << run_ <<"</span></h2> " << endl;
01745 htmlFile << "<h2>Run Type:   " << endl;
01746 htmlFile << "<span style=\"color: rgb(0, 0, 153);\">" << this->getRunType() <<"</span></h2> " << endl;
01747 htmlFile << "<hr>" << endl;
01748
01749 htmlFile << "<ul>" << endl;
01750
01751 string htmlName;
01752
01753 for ( int i=0; i<int(clients_.size()); i++ ) {
01754 bool done = false;
01755 for ( multimap<EBClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
01756 if ( h_ && runType_ != -1 && runType_ == (*j).second && !done ) {
01757 if ( strcmp(clientsNames_[i].c_str(), "Cosmic") == 0 && runType_ != EcalDCCHeaderBlock::COSMIC && runType_ != EcalDCCHeaderBlock::COSMICS_LOCAL && runType_ != EcalDCCHeaderBlock::COSMICS_GLOBAL && runType_ != EcalDCCHeaderBlock::PHYSICS_GLOBAL && runType_ != EcalDCCHeaderBlock::PHYSICS_LOCAL && h_->GetBinContent(2+EcalDCCHeaderBlock::COSMIC) == 0 && h_->GetBinContent(2+EcalDCCHeaderBlock::COSMICS_LOCAL) == 0 && h_->GetBinContent(2+EcalDCCHeaderBlock::COSMICS_GLOBAL) == 0 && h_->GetBinContent(2+EcalDCCHeaderBlock::PHYSICS_GLOBAL) == 0 && h_->GetBinContent(2+EcalDCCHeaderBlock::PHYSICS_LOCAL) == 0 ) continue;
01758 if ( strcmp(clientsNames_[i].c_str(), "Laser") == 0 && runType_ != EcalDCCHeaderBlock::LASER_STD && runType_ != EcalDCCHeaderBlock::LASER_GAP && h_->GetBinContent(2+EcalDCCHeaderBlock::LASER_STD) == 0 && h_->GetBinContent(2+EcalDCCHeaderBlock::LASER_GAP) == 0 ) continue;
01759 if ( strcmp(clientsNames_[i].c_str(), "Pedestal") == 0 && runType_ != EcalDCCHeaderBlock::PEDESTAL_STD && runType_ != EcalDCCHeaderBlock::PEDESTAL_GAP && h_->GetBinContent(2+EcalDCCHeaderBlock::PEDESTAL_STD) == 0 && h_->GetBinContent(2+EcalDCCHeaderBlock::PEDESTAL_GAP) == 0 ) continue;
01760 if ( strcmp(clientsNames_[i].c_str(), "TestPulse") == 0 && runType_ != EcalDCCHeaderBlock::TESTPULSE_MGPA && runType_ != EcalDCCHeaderBlock::TESTPULSE_GAP && h_->GetBinContent(2+EcalDCCHeaderBlock::TESTPULSE_MGPA) == 0 && h_->GetBinContent(2+EcalDCCHeaderBlock::TESTPULSE_GAP) == 0 ) continue;
01761 done = true;
01762 htmlName = "EB" + clientsNames_[i] + "Client.html";
01763 clients_[i]->htmlOutput(run_, htmlDir, htmlName);
01764 htmlFile << "<li><a href=\"" << htmlName << "\">Data " << clientsNames_[i] << "</a></li>" << endl;
01765 }
01766 }
01767 }
01768
01769 if ( summaryClient_ ) {
01770
01771 htmlName = "EBSummaryClient.html";
01772 summaryClient_->htmlOutput(run_, htmlDir, htmlName);
01773 htmlFile << "<li><a href=\"" << htmlName << "\">Data " << "Summary" << "</a></li>" << endl;
01774
01775 htmlFile << "<br>" << endl;
01776
01777 htmlFile << "<table border=\"0\" cellspacing=\"0\" " << endl;
01778 htmlFile << "cellpadding=\"10\" align=\"center\"> " << endl;
01779 htmlFile << "<tr align=\"center\">" << endl;
01780
01781 htmlFile << "<td><img src=\"EB_global_summary.png\" border=0></td>" << endl;
01782
01783 htmlFile << "</tr>" << endl;
01784 htmlFile << "</table>" << endl;
01785 htmlFile << "<br>" << endl;
01786
01787 }
01788
01789 htmlFile << "</ul>" << endl;
01790
01791
01792 htmlFile << "</body> " << endl;
01793 htmlFile << "</html> " << endl;
01794
01795 htmlFile.close();
01796
01797 if ( verbose_ ) cout << endl;
01798
01799 if( current ) {
01800 time_t elapsed = time(NULL) - start;
01801 if ( verbose_ ) cout << "==========> htmlOutput Elapsed Time: " << elapsed << endl;
01802 }
01803
01804 }
01805
01806 void EcalBarrelMonitorClient::defaultWebPage(xgi::Input *in, xgi::Output *out) {
01807
01808 string path;
01809 string mname;
01810
01811 static bool autorefresh_ = false;
01812
01813 try {
01814
01815 cgicc::Cgicc cgi(in);
01816
01817 if ( xgi::Utils::hasFormElement(cgi,"autorefresh") ) {
01818 autorefresh_ = xgi::Utils::getFormElement(cgi, "autorefresh")->getIntegerValue() != 0;
01819 }
01820
01821 if ( xgi::Utils::hasFormElement(cgi,"module") ) {
01822 mname = xgi::Utils::getFormElement(cgi, "module")->getValue();
01823 }
01824
01825 cgicc::CgiEnvironment cgie(in);
01826 path = cgie.getPathInfo() + "?" + cgie.getQueryString();
01827
01828 } catch (exception &e) {
01829
01830 cerr << "Standard C++ exception : " << e.what() << endl;
01831
01832 }
01833
01834 *out << cgicc::HTMLDoctype(cgicc::HTMLDoctype::eStrict) << endl;
01835 *out << cgicc::html().set("lang", "en").set("dir","ltr") << endl;
01836
01837 *out << "<html>" << endl;
01838
01839 *out << "<head>" << endl;
01840
01841 *out << "<title>" << typeid(EcalBarrelMonitorClient).name()
01842 << " MAIN</title>" << endl;
01843
01844 if ( autorefresh_ ) {
01845 *out << "<meta https-equiv=\"refresh\" content=\"3\">" << endl;
01846 }
01847
01848 *out << "</head>" << endl;
01849
01850 *out << "<body>" << endl;
01851
01852 *out << cgicc::form().set("method","GET").set("action", path )
01853 << endl;
01854 *out << cgicc::input().set("type","hidden").set("name","module").set("value", mname)
01855 << endl;
01856 *out << cgicc::input().set("type","hidden").set("name","autorefresh").set("value", autorefresh_?"0":"1")
01857 << endl;
01858 *out << cgicc::input().set("type","submit").set("value",autorefresh_?"Toggle AutoRefresh OFF":"Toggle AutoRefresh ON")
01859 << endl;
01860 *out << cgicc::form() << endl;
01861
01862 *out << cgicc::h3( "EcalBarrelMonitorClient Status" ).set( "style", "font-family:arial" ) << endl;
01863
01864 *out << "<table style=\"font-family: arial\"><tr><td>" << endl;
01865
01866 *out << "<p style=\"font-family: arial\">"
01867 << "<table border=1>"
01868 << "<tr><th>Cycle</th><td align=right>" << ievt_;
01869 int nevt = 0;
01870 if ( h_ != 0 ) nevt = int( h_->GetEntries());
01871 *out << "<tr><th>Event</th><td align=right>" << nevt
01872 << "</td><tr><th>Run</th><td align=right>" << run_
01873 << "</td><tr><th>Run Type</th><td align=right> " << this->getRunType()
01874 << "</td></table></p>" << endl;
01875
01876 *out << "</td><td>" << endl;
01877
01878 *out << "<p style=\"font-family: arial\">"
01879 << "<table border=1>"
01880 << "<tr><th>Evt Type</th><th>Evt/Run</th><th>Evt Type</th><th>Evt/Run</th>" << endl;
01881 for( unsigned int i = 0, j = 0; i < runTypes_.size(); i++ ) {
01882 if ( strcmp(runTypes_[i].c_str(), "UNKNOWN") != 0 ) {
01883 if ( j++%2 == 0 ) *out << "<tr>";
01884 nevt = 0;
01885 if ( h_ != 0 ) nevt = int( h_->GetBinContent(i+1) );
01886 *out << "<td>" << runTypes_[i]
01887 << "</td><td align=right>" << nevt << endl;
01888 }
01889 }
01890 *out << "</td></table></p>" << endl;
01891
01892 *out << "</td><tr><td colspan=2>" << endl;
01893
01894 *out << "<p style=\"font-family: arial\">"
01895 << "<table border=1>"
01896 << "<tr><th>Client</th><th>Cyc/Job</th><th>Cyc/Run</th><th>Client</th><th>Cyc/Job</th><th>Cyc/Run</th>" << endl;
01897 for( unsigned int i = 0; i < clients_.size(); i++ ) {
01898 if ( clients_[i] != 0 ) {
01899 if ( i%2 == 0 ) *out << "<tr>";
01900 *out << "<td>" << clientsNames_[i]
01901 << "</td><td align=right>" << clients_[i]->getEvtPerJob()
01902 << "</td><td align=right>" << clients_[i]->getEvtPerRun() << endl;
01903 }
01904 }
01905 *out << "</td></table></p>" << endl;
01906
01907 *out << "</td><tr><td>" << endl;
01908
01909
01910 *out << "<p style=\"font-family: arial\">"
01911 << "<table border=1>"
01912 << "<tr><th colspan=2>RunIOV</th>"
01913 << "<tr><td>Run Number</td><td align=right> " << runiov_.getRunNumber()
01914 << "</td><tr><td>Run Start</td><td align=right> " << runiov_.getRunStart().str()
01915 << "</td><tr><td>Run End</td><td align=right> " << runiov_.getRunEnd().str()
01916 << "</td></table></p>" << endl;
01917
01918 *out << "</td><td colsapn=2>" << endl;
01919
01920 *out << "<p style=\"font-family: arial\">"
01921 << "<table border=1>"
01922 << "<tr><th colspan=2>RunTag</th>"
01923 << "<tr><td>GeneralTag</td><td align=right> " << runiov_.getRunTag().getGeneralTag()
01924 << "</td><tr><td>Location</td><td align=right> " << runiov_.getRunTag().getLocationDef().getLocation()
01925 << "</td><tr><td>Run Type</td><td align=right> " << runiov_.getRunTag().getRunTypeDef().getRunType()
01926 << "</td></table></p>" << endl;
01927
01928 *out << "</td><tr><td>" << endl;
01929
01930 *out << "<p style=\"font-family: arial\">"
01931 << "<table border=1>"
01932 << "<tr><th colspan=2>MonRunIOV</th>"
01933 << "<tr><td>SubRun Number</td><td align=right> " << moniov_.getSubRunNumber()
01934 << "</td><tr><td>SubRun Start</td><td align=right> " << moniov_.getSubRunStart().str()
01935 << "</td><tr><td>SubRun End</td><td align=right> " << moniov_.getSubRunEnd().str()
01936 << "</td></table></p>" << endl;
01937
01938 *out << "</td><td colspan=2>" << endl;
01939
01940 *out << "<p style=\"font-family: arial\">"
01941 << "<table border=1>"
01942 << "<tr><th colspan=2>MonRunTag</th>"
01943 << "<tr><td>GeneralTag</td><td align=right> " << moniov_.getMonRunTag().getGeneralTag()
01944 << "</td><tr><td>Monitoring Version</td><td align=right> " << moniov_.getMonRunTag().getMonVersionDef().getMonitoringVersion()
01945 << "</td></table></p>" << endl;
01946
01947 *out << "</td><table>" << endl;
01948
01949
01950 *out << "</body>" << endl;
01951
01952 *out << "</html>" << endl;
01953
01954 }
01955