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 char histo[200];
00688
00689 MonitorElement* me;
00690
00691 dqmStore_->setCurrentFolder( prefixME_ + "/EventInfo" );
00692
00693 sprintf(histo, "reportSummary");
00694 me = dqmStore_->get(prefixME_ + "/EventInfo/" + histo);
00695 if ( me ) {
00696 dqmStore_->removeElement(me->getName());
00697 }
00698 me = dqmStore_->bookFloat(histo);
00699 me->Fill(-1.0);
00700
00701 dqmStore_->setCurrentFolder( prefixME_ + "/EventInfo/reportSummaryContents" );
00702
00703 for (int i = 0; i < 18; i++) {
00704 sprintf(histo, "EcalEndcap_%s", Numbers::sEE(i+1).c_str());
00705 me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryContents/" + histo);
00706 if ( me ) {
00707 dqmStore_->removeElement(me->getName());
00708 }
00709 me = dqmStore_->bookFloat(histo);
00710 me->Fill(-1.0);
00711 }
00712
00713 dqmStore_->setCurrentFolder( prefixME_ + "/EventInfo" );
00714
00715 sprintf(histo, "reportSummaryMap");
00716 me = dqmStore_->get(prefixME_ + "/EventInfo/" + histo);
00717 if ( me ) {
00718 dqmStore_->removeElement(me->getName());
00719 }
00720 me = dqmStore_->book2D(histo, histo, 200, 0., 200., 100, 0., 100);
00721 for ( int jx = 1; jx <= 200; jx++ ) {
00722 for ( int jy = 1; jy <= 100; jy++ ) {
00723 me->setBinContent( jx, jy, -1.0 );
00724 }
00725 }
00726 me->setAxisTitle("ix / ix+100", 1);
00727 me->setAxisTitle("iy", 2);
00728
00729 }
00730
00731 void EcalEndcapMonitorClient::beginRun(void) {
00732
00733 begin_run_ = true;
00734 end_run_ = false;
00735
00736 last_run_ = run_;
00737
00738 if ( debug_ ) std::cout << "EcalEndcapMonitorClient: beginRun" << std::endl;
00739
00740 jevt_ = 0;
00741
00742 current_time_ = time(NULL);
00743 last_time_update_ = current_time_;
00744 last_time_reset_ = current_time_;
00745
00746 this->setup();
00747
00748 this->beginRunDb();
00749
00750 for ( int i=0; i<int(clients_.size()); i++ ) {
00751 clients_[i]->cleanup();
00752 bool done = false;
00753 for ( std::multimap<EEClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
00754 if ( runType_ != -1 && runType_ == (*j).second && !done ) {
00755 done = true;
00756 clients_[i]->beginRun();
00757 }
00758 }
00759 }
00760
00761 if ( summaryClient_ ) summaryClient_->beginRun();
00762
00763 }
00764
00765 void EcalEndcapMonitorClient::beginRun(const edm::Run& r, const edm::EventSetup& c) {
00766
00767 Numbers::initGeometry(c, verbose_);
00768
00769 if ( verbose_ ) std::cout << std::endl;
00770
00771 Masks::initMasking(c, verbose_);
00772
00773 if ( verbose_ ) {
00774 std::cout << std::endl;
00775 std::cout << "Standard beginRun() for run " << r.id().run() << std::endl;
00776 std::cout << std::endl;
00777 }
00778
00779 run_ = r.id().run();
00780 evt_ = 0;
00781
00782 jevt_ = 0;
00783
00784 }
00785
00786 void EcalEndcapMonitorClient::endJob(void) {
00787
00788 if ( ! end_run_ ) {
00789
00790 if ( verbose_ ) {
00791 std::cout << std::endl;
00792 std::cout << "Checking last event at endJob() ... " << std::endl;
00793 std::cout << std::endl;
00794 }
00795
00796 forced_update_ = true;
00797 this->analyze();
00798
00799 if ( begin_run_ && ! end_run_ ) {
00800
00801 if ( verbose_ ) {
00802 std::cout << std::endl;
00803 std::cout << "Forcing endRun() ... " << std::endl;
00804 std::cout << std::endl;
00805 }
00806
00807 forced_status_ = true;
00808 this->analyze();
00809 this->endRun();
00810
00811 }
00812
00813 }
00814
00815 if ( debug_ ) std::cout << "EcalEndcapMonitorClient: endJob, ievt = " << ievt_ << std::endl;
00816
00817 this->cleanup();
00818
00819 for ( unsigned int i=0; i<clients_.size(); i++ ) {
00820 clients_[i]->endJob();
00821 }
00822
00823 if ( summaryClient_ ) summaryClient_->endJob();
00824
00825 }
00826
00827 void EcalEndcapMonitorClient::endRun(void) {
00828
00829 begin_run_ = false;
00830 end_run_ = true;
00831
00832 if ( debug_ ) std::cout << "EcalEndcapMonitorClient: endRun, jevt = " << jevt_ << std::endl;
00833
00834 if ( subrun_ != -1 ) {
00835
00836 this->writeDb();
00837
00838 this->endRunDb();
00839
00840 }
00841
00842 if ( resetFile_.size() != 0 || dbUpdateTime_ > 0 ) {
00843
00844 this->softReset(false);
00845
00846 for ( int i=0; i<int(clients_.size()); i++ ) {
00847 bool done = false;
00848 for ( std::multimap<EEClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
00849 if ( runType_ != -1 && runType_ == (*j).second && !done ) {
00850 done = true;
00851 clients_[i]->analyze();
00852 }
00853 }
00854 }
00855
00856 if ( summaryClient_ ) summaryClient_->analyze();
00857
00858 }
00859
00860 for ( int i=0; i<int(clients_.size()); i++ ) {
00861 bool done = false;
00862 for ( std::multimap<EEClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
00863 if ( runType_ != -1 && runType_ == (*j).second && !done ) {
00864 done = true;
00865 clients_[i]->endRun();
00866 }
00867 }
00868 }
00869
00870 if ( summaryClient_ ) summaryClient_->endRun();
00871
00872 this->cleanup();
00873
00874 status_ = "unknown";
00875
00876 run_ = -1;
00877 evt_ = -1;
00878
00879 runType_ = -1;
00880 evtType_ = -1;
00881
00882 subrun_ = -1;
00883
00884 }
00885
00886 void EcalEndcapMonitorClient::endRun(const edm::Run& r, const edm::EventSetup& c) {
00887
00888 if ( verbose_ ) {
00889 std::cout << std::endl;
00890 std::cout << "Standard endRun() for run " << r.id().run() << std::endl;
00891 std::cout << std::endl;
00892 }
00893
00894 this->analyze();
00895
00896 if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
00897
00898 forced_update_ = true;
00899 this->analyze();
00900
00901 if ( ! mergeRuns_ ) {
00902
00903 if ( begin_run_ && ! end_run_ ) {
00904
00905 forced_status_ = false;
00906 this->endRun();
00907
00908 }
00909
00910 }
00911
00912 }
00913
00914
00915
00916 if ( run_ != -1 && evt_ != -1 && runType_ == -1 ) {
00917
00918 char histo[200];
00919
00920 MonitorElement* me;
00921
00922 sprintf(histo, "reportSummary");
00923 me = dqmStore_->get(prefixME_ + "/EventInfo/" + histo);
00924 if ( me ) me->Fill(-1.0);
00925
00926 for (int i = 0; i < 18; i++) {
00927 sprintf(histo, "EcalEndcap_%s", Numbers::sEE(i+1).c_str());
00928 me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryContents/" + histo);
00929 if ( me ) me->Fill(-1.0);
00930 }
00931
00932 sprintf(histo, "reportSummaryMap");
00933 me = dqmStore_->get(prefixME_ + "/EventInfo/" + histo);
00934 for ( int jx = 1; jx <= 200; jx++ ) {
00935 for ( int jy = 1; jy <= 100; jy++ ) {
00936 if ( me ) me->setBinContent( jx, jy, -1.0 );
00937 }
00938 }
00939
00940 }
00941
00942 }
00943
00944 void EcalEndcapMonitorClient::beginLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& c) {
00945
00946 if ( verbose_ ) {
00947 std::cout << std::endl;
00948 std::cout << "Standard beginLuminosityBlock() for luminosity block " << l.id().luminosityBlock() << " of run " << l.id().run() << std::endl;
00949 std::cout << std::endl;
00950 }
00951
00952 }
00953
00954 void EcalEndcapMonitorClient::endLuminosityBlock(const edm::LuminosityBlock& l, const edm::EventSetup& c) {
00955
00956 current_time_ = time(NULL);
00957
00958 if ( verbose_ ) {
00959 std::cout << std::endl;
00960 std::cout << "Standard endLuminosityBlock() for luminosity block " << l.id().luminosityBlock() << " of run " << l.id().run() << std::endl;
00961 std::cout << std::endl;
00962 }
00963
00964 if ( updateTime_ > 0 ) {
00965 if ( (current_time_ - last_time_update_) < 60 * updateTime_ ) {
00966 return;
00967 }
00968 last_time_update_ = current_time_;
00969 }
00970
00971 if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
00972
00973 forced_update_ = true;
00974 this->analyze();
00975
00976 }
00977
00978 }
00979
00980 void EcalEndcapMonitorClient::reset(void) {
00981
00982 }
00983
00984 void EcalEndcapMonitorClient::setup(void) {
00985
00986 }
00987
00988 void EcalEndcapMonitorClient::cleanup(void) {
00989
00990 if ( ! enableCleanup_ ) return;
00991
00992 if ( cloneME_ ) {
00993 if ( h_ ) delete h_;
00994 }
00995
00996 h_ = 0;
00997
00998 }
00999
01000 void EcalEndcapMonitorClient::beginRunDb(void) {
01001
01002 subrun_ = 0;
01003
01004 #ifdef WITH_ECAL_COND_DB
01005 EcalCondDBInterface* econn;
01006
01007 econn = 0;
01008
01009 if ( dbName_.size() != 0 ) {
01010 try {
01011 if ( verbose_ ) std::cout << "Opening DB connection with TNS_ADMIN ..." << std::endl;
01012 econn = new EcalCondDBInterface(dbName_, dbUserName_, dbPassword_);
01013 if ( verbose_ ) std::cout << "done." << std::endl;
01014 } catch (std::runtime_error &e) {
01015 std::cerr << e.what() << std::endl;
01016 if ( dbHostName_.size() != 0 ) {
01017 try {
01018 if ( verbose_ ) std::cout << "Opening DB connection without TNS_ADMIN ..." << std::endl;
01019 econn = new EcalCondDBInterface(dbHostName_, dbName_, dbUserName_, dbPassword_, dbHostPort_);
01020 if ( verbose_ ) std::cout << "done." << std::endl;
01021 } catch (std::runtime_error &e) {
01022 std::cerr << e.what() << std::endl;
01023 }
01024 }
01025 }
01026 }
01027
01028
01029
01030 LocationDef locdef;
01031
01032 locdef.setLocation(location_);
01033
01034 RunTypeDef rundef;
01035
01036 rundef.setRunType( this->getRunType() );
01037
01038 RunTag runtag;
01039
01040 runtag.setLocationDef(locdef);
01041 runtag.setRunTypeDef(rundef);
01042
01043 runtag.setGeneralTag( this->getRunType() );
01044
01045
01046
01047 bool foundRunIOV = false;
01048
01049 if ( econn ) {
01050 try {
01051 if ( verbose_ ) std::cout << "Fetching RunIOV ..." << std::endl;
01052
01053 runiov_ = econn->fetchRunIOV(location_, run_);
01054 if ( verbose_ ) std::cout << "done." << std::endl;
01055 foundRunIOV = true;
01056 } catch (std::runtime_error &e) {
01057 std::cerr << e.what() << std::endl;
01058 foundRunIOV = false;
01059 }
01060 }
01061
01062
01063
01064 if ( ! foundRunIOV ) {
01065
01066 Tm startRun;
01067
01068 startRun.setToCurrentGMTime();
01069
01070 runiov_.setRunNumber(run_);
01071 runiov_.setRunStart(startRun);
01072 runiov_.setRunTag(runtag);
01073
01074 if ( econn ) {
01075 try {
01076 if ( verbose_ ) std::cout << "Inserting RunIOV ..." << std::endl;
01077 econn->insertRunIOV(&runiov_);
01078
01079 runiov_ = econn->fetchRunIOV(location_, run_);
01080 if ( verbose_ ) std::cout << "done." << std::endl;
01081 } catch (std::runtime_error &e) {
01082 std::cerr << e.what() << std::endl;
01083 try {
01084 if ( verbose_ ) std::cout << "Fetching RunIOV (again) ..." << std::endl;
01085
01086 runiov_ = econn->fetchRunIOV(location_, run_);
01087 if ( verbose_ ) std::cout << "done." << std::endl;
01088 foundRunIOV = true;
01089 } catch (std::runtime_error &e) {
01090 std::cerr << e.what() << std::endl;
01091 foundRunIOV = false;
01092 }
01093 }
01094 }
01095
01096 }
01097
01098
01099
01100 if ( verbose_ ) {
01101 std::cout << std::endl;
01102 std::cout << "=============RunIOV:" << std::endl;
01103 std::cout << "Run Number: " << runiov_.getRunNumber() << std::endl;
01104 std::cout << "Run Start: " << runiov_.getRunStart().str() << std::endl;
01105 std::cout << "Run End: " << runiov_.getRunEnd().str() << std::endl;
01106 std::cout << "====================" << std::endl;
01107 std::cout << std::endl;
01108 std::cout << "=============RunTag:" << std::endl;
01109 std::cout << "GeneralTag: " << runiov_.getRunTag().getGeneralTag() << std::endl;
01110 std::cout << "Location: " << runiov_.getRunTag().getLocationDef().getLocation() << std::endl;
01111 std::cout << "Run Type: " << runiov_.getRunTag().getRunTypeDef().getRunType() << std::endl;
01112 std::cout << "====================" << std::endl;
01113 std::cout << std::endl;
01114 }
01115
01116 std::string rt = runiov_.getRunTag().getRunTypeDef().getRunType();
01117 if ( strcmp(rt.c_str(), "UNKNOWN") == 0 ) {
01118 runType_ = -1;
01119 } else {
01120 for ( unsigned int i = 0; i < runTypes_.size(); i++ ) {
01121 if ( strcmp(rt.c_str(), runTypes_[i].c_str()) == 0 ) {
01122 if ( runType_ != int(i) ) {
01123 if ( verbose_ ) {
01124 std::cout << std::endl;
01125 std::cout << "Fixing Run Type to: " << runTypes_[i] << std::endl;
01126 std::cout << std::endl;
01127 }
01128 runType_ = i;
01129 }
01130 break;
01131 }
01132 }
01133 }
01134
01135 if ( verbose_ ) std::cout << std::endl;
01136
01137 if ( econn ) {
01138 try {
01139 if ( verbose_ ) std::cout << "Closing DB connection ..." << std::endl;
01140 delete econn;
01141 econn = 0;
01142 if ( verbose_ ) std::cout << "done." << std::endl;
01143 } catch (std::runtime_error &e) {
01144 std::cerr << e.what() << std::endl;
01145 }
01146 }
01147 #endif
01148
01149 if ( verbose_ ) std::cout << std::endl;
01150
01151 }
01152
01153 void EcalEndcapMonitorClient::writeDb(void) {
01154
01155 subrun_++;
01156
01157 #ifdef WITH_ECAL_COND_DB
01158 EcalCondDBInterface* econn;
01159
01160 econn = 0;
01161
01162 if ( dbName_.size() != 0 ) {
01163 try {
01164 if ( verbose_ ) std::cout << "Opening DB connection with TNS_ADMIN ..." << std::endl;
01165 econn = new EcalCondDBInterface(dbName_, dbUserName_, dbPassword_);
01166 if ( verbose_ ) std::cout << "done." << std::endl;
01167 } catch (std::runtime_error &e) {
01168 std::cerr << e.what() << std::endl;
01169 if ( dbHostName_.size() != 0 ) {
01170 try {
01171 if ( verbose_ ) std::cout << "Opening DB connection without TNS_ADMIN ..." << std::endl;
01172 econn = new EcalCondDBInterface(dbHostName_, dbName_, dbUserName_, dbPassword_, dbHostPort_);
01173 if ( verbose_ ) std::cout << "done." << std::endl;
01174 } catch (std::runtime_error &e) {
01175 std::cerr << e.what() << std::endl;
01176 }
01177 }
01178 }
01179 }
01180
01181 MonVersionDef monverdef;
01182
01183 monverdef.setMonitoringVersion("test01");
01184
01185 MonRunTag montag;
01186
01187 montag.setMonVersionDef(monverdef);
01188 montag.setGeneralTag(dbTagName_);
01189
01190 Tm startSubRun;
01191
01192 startSubRun.setToCurrentGMTime();
01193
01194
01195
01196 bool foundMonIOV = false;
01197
01198 if ( econn ) {
01199 try {
01200 if ( verbose_ ) std::cout << "Fetching MonIOV ..." << std::endl;
01201 RunTag runtag = runiov_.getRunTag();
01202 moniov_ = econn->fetchMonRunIOV(&runtag, &montag, run_, subrun_);
01203 if ( verbose_ ) std::cout << "done." << std::endl;
01204 foundMonIOV = true;
01205 } catch (std::runtime_error &e) {
01206 std::cerr << e.what() << std::endl;
01207 foundMonIOV = false;
01208 }
01209 }
01210
01211
01212
01213 if ( !foundMonIOV ) {
01214
01215 moniov_.setRunIOV(runiov_);
01216 moniov_.setSubRunNumber(subrun_);
01217
01218 if ( subrun_ > 1 ) {
01219 moniov_.setSubRunStart(startSubRun);
01220 } else {
01221 moniov_.setSubRunStart(runiov_.getRunStart());
01222 }
01223
01224 moniov_.setMonRunTag(montag);
01225
01226 if ( econn ) {
01227 try {
01228 if ( verbose_ ) std::cout << "Inserting MonIOV ..." << std::endl;
01229 econn->insertMonRunIOV(&moniov_);
01230 RunTag runtag = runiov_.getRunTag();
01231 moniov_ = econn->fetchMonRunIOV(&runtag, &montag, run_, subrun_);
01232 if ( verbose_ ) std::cout << "done." << std::endl;
01233 } catch (std::runtime_error &e) {
01234 std::cerr << e.what() << std::endl;
01235 try {
01236 if ( verbose_ ) std::cout << "Fetching MonIOV (again) ..." << std::endl;
01237 RunTag runtag = runiov_.getRunTag();
01238 moniov_ = econn->fetchMonRunIOV(&runtag, &montag, run_, subrun_);
01239 if ( verbose_ ) std::cout << "done." << std::endl;
01240 foundMonIOV = true;
01241 } catch (std::runtime_error &e) {
01242 std::cerr << e.what() << std::endl;
01243 foundMonIOV = false;
01244 }
01245 }
01246 }
01247
01248 }
01249
01250
01251
01252 if ( verbose_ ) {
01253 std::cout << std::endl;
01254 std::cout << "==========MonRunIOV:" << std::endl;
01255 std::cout << "SubRun Number: " << moniov_.getSubRunNumber() << std::endl;
01256 std::cout << "SubRun Start: " << moniov_.getSubRunStart().str() << std::endl;
01257 std::cout << "SubRun End: " << moniov_.getSubRunEnd().str() << std::endl;
01258 std::cout << "====================" << std::endl;
01259 std::cout << std::endl;
01260 std::cout << "==========MonRunTag:" << std::endl;
01261 std::cout << "GeneralTag: " << moniov_.getMonRunTag().getGeneralTag() << std::endl;
01262 std::cout << "Monitoring Ver: " << moniov_.getMonRunTag().getMonVersionDef().getMonitoringVersion() << std::endl;
01263 std::cout << "====================" << std::endl;
01264 std::cout << std::endl;
01265 }
01266
01267 int taskl = 0x0;
01268 int tasko = 0x0;
01269
01270 for ( int i=0; i<int(clients_.size()); i++ ) {
01271 bool done = false;
01272 for ( std::multimap<EEClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
01273 if ( h_ && runType_ != -1 && runType_ == (*j).second && !done ) {
01274 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;
01275 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;
01276 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;
01277 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;
01278 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;
01279 done = true;
01280 if ( verbose_ ) {
01281 if ( econn ) {
01282 std::cout << " Writing " << clientsNames_[i] << " results to DB " << std::endl;
01283 std::cout << std::endl;
01284 }
01285 }
01286 bool status;
01287 if ( clients_[i]->writeDb(econn, &runiov_, &moniov_, status) ) {
01288 taskl |= 0x1 << clientsStatus_[clientsNames_[i]];
01289 if ( status ) {
01290 tasko |= 0x1 << clientsStatus_[clientsNames_[i]];
01291 }
01292 } else {
01293 tasko |= 0x1 << clientsStatus_[clientsNames_[i]];
01294 }
01295 }
01296 }
01297 if ( ((taskl >> clientsStatus_[clientsNames_[i]]) & 0x1) ) {
01298 if ( verbose_ ) {
01299 std::cout << " Task output for " << clientsNames_[i] << " = "
01300 << ((tasko >> clientsStatus_[clientsNames_[i]]) & 0x1) << std::endl;
01301 std::cout << std::endl;
01302 }
01303 }
01304 }
01305
01306 bool status;
01307 if ( summaryClient_ ) summaryClient_->writeDb(econn, &runiov_, &moniov_, status);
01308
01309 EcalLogicID ecid;
01310 MonRunDat md;
01311 std::map<EcalLogicID, MonRunDat> dataset;
01312
01313 MonRunOutcomeDef monRunOutcomeDef;
01314
01315 monRunOutcomeDef.setShortDesc("success");
01316
01317 float nevt = -1.;
01318
01319 if ( h_ ) nevt = h_->GetSumOfWeights();
01320
01321 md.setNumEvents(int(nevt));
01322 md.setMonRunOutcomeDef(monRunOutcomeDef);
01323
01324
01325
01326
01327 md.setTaskList(taskl);
01328 md.setTaskOutcome(tasko);
01329
01330 if ( econn ) {
01331 try {
01332 ecid = LogicID::getEcalLogicID("EE");
01333 dataset[ecid] = md;
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 << "Inserting MonRunDat ..." << std::endl;
01342 econn->insertDataSet(&dataset, &moniov_);
01343 if ( verbose_ ) std::cout << "done." << std::endl;
01344 } catch (std::runtime_error &e) {
01345 std::cerr << e.what() << std::endl;
01346 }
01347 }
01348
01349 if ( econn ) {
01350 try {
01351 if ( verbose_ ) std::cout << "Closing DB connection ..." << std::endl;
01352 delete econn;
01353 econn = 0;
01354 if ( verbose_ ) std::cout << "done." << std::endl;
01355 } catch (std::runtime_error &e) {
01356 std::cerr << e.what() << std::endl;
01357 }
01358 }
01359 #endif
01360
01361 if ( verbose_ ) std::cout << std::endl;
01362
01363 }
01364
01365 void EcalEndcapMonitorClient::endRunDb(void) {
01366
01367 #ifdef WITH_ECAL_COND_DB
01368 EcalCondDBInterface* econn;
01369
01370 econn = 0;
01371
01372 if ( dbName_.size() != 0 ) {
01373 try {
01374 if ( verbose_ ) std::cout << "Opening DB connection with TNS_ADMIN ..." << std::endl;
01375 econn = new EcalCondDBInterface(dbName_, dbUserName_, dbPassword_);
01376 if ( verbose_ ) std::cout << "done." << std::endl;
01377 } catch (std::runtime_error &e) {
01378 std::cerr << e.what() << std::endl;
01379 if ( dbHostName_.size() != 0 ) {
01380 try {
01381 if ( verbose_ ) std::cout << "Opening DB connection without TNS_ADMIN ..." << std::endl;
01382 econn = new EcalCondDBInterface(dbHostName_, dbName_, dbUserName_, dbPassword_, dbHostPort_);
01383 if ( verbose_ ) std::cout << "done." << std::endl;
01384 } catch (std::runtime_error &e) {
01385 std::cerr << e.what() << std::endl;
01386 }
01387 }
01388 }
01389 }
01390
01391 EcalLogicID ecid;
01392 RunDat rd;
01393 std::map<EcalLogicID, RunDat> dataset;
01394
01395 float nevt = -1.;
01396
01397 if ( h_ ) nevt = h_->GetSumOfWeights();
01398
01399 rd.setNumEvents(int(nevt));
01400
01401
01402
01403 bool foundRunDat = false;
01404
01405 if ( econn ) {
01406 try {
01407 if ( verbose_ ) std::cout << "Fetching RunDat ..." << std::endl;
01408 econn->fetchDataSet(&dataset, &runiov_);
01409 if ( verbose_ ) std::cout << "done." << std::endl;
01410 foundRunDat = true;
01411 } catch (std::runtime_error &e) {
01412 std::cerr << e.what() << std::endl;
01413 foundRunDat = false;
01414 }
01415 }
01416
01417
01418
01419 if ( ! foundRunDat ) {
01420
01421 if ( econn ) {
01422 try {
01423 ecid = LogicID::getEcalLogicID("EE");
01424 dataset[ecid] = rd;
01425 } catch (std::runtime_error &e) {
01426 std::cerr << e.what() << std::endl;
01427 }
01428 }
01429
01430 if ( econn ) {
01431 try {
01432 if ( verbose_ ) std::cout << "Inserting RunDat ..." << std::endl;
01433 econn->insertDataSet(&dataset, &runiov_);
01434 if ( verbose_ ) std::cout << "done." << std::endl;
01435 } catch (std::runtime_error &e) {
01436 std::cerr << e.what() << std::endl;
01437 }
01438 }
01439
01440 }
01441
01442
01443
01444 if ( econn ) {
01445 try {
01446 if ( verbose_ ) std::cout << "Closing DB connection ..." << std::endl;
01447 delete econn;
01448 econn = 0;
01449 if ( verbose_ ) std::cout << "done." << std::endl;
01450 } catch (std::runtime_error &e) {
01451 std::cerr << e.what() << std::endl;
01452 }
01453 }
01454 #endif
01455
01456 }
01457
01458 void EcalEndcapMonitorClient::analyze(void) {
01459
01460 current_time_ = time(NULL);
01461
01462 ievt_++;
01463 jevt_++;
01464
01465 if ( debug_ ) std::cout << "EcalEndcapMonitorClient: ievt/jevt = " << ievt_ << "/" << jevt_ << std::endl;
01466
01467 MonitorElement* me;
01468 std::string s;
01469
01470 me = dqmStore_->get(prefixME_ + "/EcalInfo/STATUS");
01471 if ( me ) {
01472 status_ = "unknown";
01473 s = me->valueString();
01474 if ( strcmp(s.c_str(), "i=0") == 0 ) status_ = "begin-of-run";
01475 if ( strcmp(s.c_str(), "i=1") == 0 ) status_ = "running";
01476 if ( strcmp(s.c_str(), "i=2") == 0 ) status_ = "end-of-run";
01477 if ( debug_ ) std::cout << "Found '" << prefixME_ << "/EcalInfo/STATUS'" << std::endl;
01478 }
01479
01480 if ( inputFile_.size() != 0 ) {
01481 if ( ievt_ == 1 ) {
01482 if ( verbose_ ) {
01483 std::cout << std::endl;
01484 std::cout << " Reading DQM from file, forcing 'begin-of-run'" << std::endl;
01485 std::cout << std::endl;
01486 }
01487 status_ = "begin-of-run";
01488 }
01489 }
01490
01491 int ecal_run = -1;
01492 me = dqmStore_->get(prefixME_ + "/EcalInfo/RUN");
01493 if ( me ) {
01494 s = me->valueString();
01495 sscanf(s.c_str(), "i=%d", &ecal_run);
01496 if ( debug_ ) std::cout << "Found '" << prefixME_ << "/EcalInfo/RUN'" << std::endl;
01497 }
01498
01499 int ecal_evt = -1;
01500 me = dqmStore_->get(prefixME_ + "/EcalInfo/EVT");
01501 if ( me ) {
01502 s = me->valueString();
01503 sscanf(s.c_str(), "i=%d", &ecal_evt);
01504 if ( debug_ ) std::cout << "Found '" << prefixME_ << "/EcalInfo/EVT'" << std::endl;
01505 }
01506
01507 me = dqmStore_->get(prefixME_ + "/EcalInfo/EVTTYPE");
01508 h_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, h_ );
01509
01510 me = dqmStore_->get(prefixME_ + "/EcalInfo/RUNTYPE");
01511 if ( me ) {
01512 s = me->valueString();
01513 sscanf(s.c_str(), "i=%d", &evtType_);
01514 if ( runType_ == -1 ) runType_ = evtType_;
01515 if ( debug_ ) std::cout << "Found '" << prefixME_ << "/EcalInfo/RUNTYPE'" << std::endl;
01516 }
01517
01518
01519
01520 if ( run_ <= 0 ) run_ = ecal_run;
01521
01522 if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
01523 if ( ! mergeRuns_ && run_ != last_run_ ) forced_update_ = true;
01524 }
01525
01526 bool update = ( forced_update_ ) ||
01527 ( prescaleFactor_ != 1 ) ||
01528 ( jevt_ < 10 ) ||
01529 ( jevt_ < 100 && jevt_ % 10 == 0 ) ||
01530 ( jevt_ < 1000 && jevt_ % 100 == 0 ) ||
01531 ( jevt_ % 1000 == 0 );
01532
01533 if ( update || strcmp(status_.c_str(), "begin-of-run") == 0 || strcmp(status_.c_str(), "end-of-run") == 0 ) {
01534
01535 if ( verbose_ ) {
01536 std::cout << " RUN status = \"" << status_ << "\"" << std::endl;
01537 std::cout << " CMS run/event number = " << run_ << "/" << evt_ << std::endl;
01538 std::cout << " EE run/event number = " << ecal_run << "/" << ecal_evt << std::endl;
01539 std::cout << " EE location = " << location_ << std::endl;
01540 std::cout << " EE run/event type = " << this->getRunType() << "/" << ( evtType_ == -1 ? "UNKNOWN" : runTypes_[evtType_] ) << std::flush;
01541
01542 if ( h_ ) {
01543 if ( h_->GetSumOfWeights() != 0 ) {
01544 std::cout << " ( " << std::flush;
01545 for ( unsigned int i = 0; i < runTypes_.size(); i++ ) {
01546 if ( strcmp(runTypes_[i].c_str(), "UNKNOWN") != 0 && h_->GetBinContent(2+i) != 0 ) {
01547 std::string s = runTypes_[i];
01548 transform( s.begin(), s.end(), s.begin(), (int(*)(int))tolower );
01549 std::cout << s << " ";
01550 }
01551 }
01552 std::cout << ")" << std::flush;
01553 }
01554 }
01555 std::cout << std::endl;
01556 }
01557
01558 }
01559
01560 if ( strcmp(status_.c_str(), "begin-of-run") == 0 ) {
01561
01562 if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
01563
01564 if ( ! begin_run_ ) {
01565
01566 forced_status_ = false;
01567 this->beginRun();
01568
01569 }
01570
01571 }
01572
01573 }
01574
01575 if ( strcmp(status_.c_str(), "begin-of-run") == 0 || strcmp(status_.c_str(), "running") == 0 || strcmp(status_.c_str(), "end-of-run") == 0 ) {
01576
01577 if ( begin_run_ && ! end_run_ ) {
01578
01579 bool update = ( forced_update_ ) ||
01580 ( prescaleFactor_ != 1 ) ||
01581 ( jevt_ < 3 ) ||
01582 ( jevt_ < 1000 && jevt_ % 100 == 0 ) ||
01583 ( jevt_ < 10000 && jevt_ % 1000 == 0 ) ||
01584 ( jevt_ % 10000 == 0 );
01585
01586 if ( update || strcmp(status_.c_str(), "begin-of-run") == 0 || strcmp(status_.c_str(), "end-of-run") == 0 ) {
01587
01588 for ( int i=0; i<int(clients_.size()); i++ ) {
01589 bool done = false;
01590 for ( std::multimap<EEClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
01591 if ( runType_ != -1 && runType_ == (*j).second && !done ) {
01592 done = true;
01593 clients_[i]->analyze();
01594 }
01595 }
01596 }
01597
01598 if ( summaryClient_ ) summaryClient_->analyze();
01599
01600 }
01601
01602 forced_update_ = false;
01603
01604 bool reset = false;
01605
01606 if ( resetFile_.size() != 0 ) {
01607 if ( access(resetFile_.c_str(), W_OK) == 0 ) {
01608 if ( unlink(resetFile_.c_str()) == 0 ) {
01609 reset |= true;
01610 }
01611 }
01612 }
01613
01614 if ( dbUpdateTime_ > 0 ) {
01615 reset |= (current_time_ - last_time_reset_) > 60 * dbUpdateTime_;
01616 }
01617
01618 if ( reset ) {
01619 if ( runType_ == EcalDCCHeaderBlock::COSMIC ||
01620 runType_ == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
01621 runType_ == EcalDCCHeaderBlock::PHYSICS_GLOBAL ||
01622 runType_ == EcalDCCHeaderBlock::COSMICS_LOCAL ||
01623 runType_ == EcalDCCHeaderBlock::PHYSICS_LOCAL ||
01624 runType_ == EcalDCCHeaderBlock::BEAMH2 ||
01625 runType_ == EcalDCCHeaderBlock::BEAMH4 ) this->writeDb();
01626 this->softReset(true);
01627 last_time_reset_ = current_time_;
01628 }
01629
01630 }
01631
01632 }
01633
01634 if ( strcmp(status_.c_str(), "end-of-run") == 0 ) {
01635
01636 if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
01637
01638 if ( begin_run_ && ! end_run_ ) {
01639
01640 forced_status_ = false;
01641 this->endRun();
01642
01643 }
01644
01645 }
01646
01647 }
01648
01649
01650
01651
01652
01653 if ( strcmp(status_.c_str(), "running") == 0 ) {
01654
01655 if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
01656
01657 if ( ! mergeRuns_ ) {
01658
01659 int new_run_ = run_;
01660 int old_run_ = last_run_;
01661
01662 if ( new_run_ != old_run_ ) {
01663
01664 if ( begin_run_ && ! end_run_ ) {
01665
01666 if ( verbose_ ) {
01667 std::cout << std::endl;
01668 std::cout << " Old run has finished, issuing endRun() ... " << std::endl;
01669 std::cout << std::endl;
01670 }
01671
01672
01673 run_ = old_run_;
01674
01675 forced_status_ = false;
01676 this->endRun();
01677
01678 }
01679
01680 if ( ! begin_run_ ) {
01681
01682 if ( verbose_ ) {
01683 std::cout << std::endl;
01684 std::cout << " New run has started, issuing beginRun() ... " << std::endl;
01685 std::cout << std::endl;
01686 }
01687
01688
01689 run_ = new_run_;
01690
01691 forced_status_ = false;
01692 this->beginRun();
01693
01694 }
01695
01696 }
01697
01698 }
01699
01700 }
01701
01702 }
01703
01704
01705
01706 if ( strcmp(status_.c_str(), "running") == 0 ) {
01707
01708 if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
01709
01710 if ( ! forced_status_ ) {
01711
01712 if ( ! begin_run_ ) {
01713
01714 if ( verbose_ ) {
01715 std::cout << std::endl;
01716 std::cout << "Forcing beginRun() ... NOW !" << std::endl;
01717 std::cout << std::endl;
01718 }
01719
01720 forced_status_ = true;
01721 this->beginRun();
01722
01723 }
01724
01725 }
01726
01727 }
01728
01729 }
01730
01731
01732
01733 if ( strcmp(status_.c_str(), "end-of-run") == 0 ) {
01734
01735 if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
01736
01737 if ( ! forced_status_ ) {
01738
01739 if ( ! begin_run_ ) {
01740
01741 if ( verbose_ ) {
01742 std::cout << std::endl;
01743 std::cout << "Forcing beginRun() ... NOW !" << std::endl;
01744 std::cout << std::endl;
01745 }
01746
01747 forced_status_ = true;
01748 this->beginRun();
01749
01750 }
01751
01752 }
01753
01754 }
01755
01756 }
01757
01758
01759
01760 }
01761
01762 void EcalEndcapMonitorClient::analyze(const edm::Event& e, const edm::EventSetup& c) {
01763
01764 run_ = e.id().run();
01765 evt_ = e.id().event();
01766
01767 if ( prescaleFactor_ > 0 ) {
01768 if ( jevt_ % prescaleFactor_ == 0 ) this->analyze();
01769 }
01770
01771 }
01772
01773 void EcalEndcapMonitorClient::softReset(bool flag) {
01774
01775 std::vector<MonitorElement*> mes = dqmStore_->getAllContents(prefixME_);
01776 std::vector<MonitorElement*>::const_iterator meitr;
01777 for ( meitr=mes.begin(); meitr!=mes.end(); meitr++ ) {
01778 if ( !strncmp((*meitr)->getName().c_str(), "EE", 2)
01779 && strncmp((*meitr)->getName().c_str(), "EETrend", 7)
01780 && strncmp((*meitr)->getName().c_str(), "by lumi", 7) ) {
01781 if ( flag ) {
01782 dqmStore_->softReset(*meitr);
01783 } else {
01784 dqmStore_->disableSoftReset(*meitr);
01785 }
01786 }
01787 }
01788
01789 MonitorElement* me = dqmStore_->get(prefixME_ + "/EcalInfo/EVTTYPE");
01790 if ( me ) {
01791 if ( flag ) {
01792 dqmStore_->softReset(me);
01793 } else {
01794 dqmStore_->disableSoftReset(me);
01795 }
01796 }
01797
01798 }
01799