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