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