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