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