CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalEndcapMonitorClient.cc
Go to the documentation of this file.
1 /*
2  * \file EcalEndcapMonitorClient.cc
3  *
4  * $Date: 2012/06/28 12:14:29 $
5  * $Revision: 1.271 $
6  * \author G. Della Ricca
7  * \author F. Cossutti
8  *
9 */
10 
11 #include <memory>
12 #include <iostream>
13 #include <iomanip>
14 #include <fstream>
15 #include <algorithm>
16 #include <unistd.h>
17 
24 
26 
28 
30 
32 
33 #ifdef WITH_ECAL_COND_DB
39 #endif
40 
42 
45 
47 
60 
62 {
63  // verbose switch
64 
65  verbose_ = ps.getUntrackedParameter<bool>("verbose", true);
66 
67  if ( verbose_ ) {
68  std::cout << std::endl;
69  std::cout << " *** Ecal Endcap Generic Monitor Client ***" << std::endl;
70  std::cout << std::endl;
71  }
72 
73  // DQM ROOT input file
74 
75  inputFile_ = ps.getUntrackedParameter<std::string>("inputFile", "");
76 
77  if ( verbose_ ) {
78  if ( inputFile_.size() != 0 ) {
79  std::cout << " Reading DQM data from inputFile '" << inputFile_ << "'" << std::endl;
80  }
81  }
82 
83  // Ecal Cond DB
84 
85  dbName_ = ps.getUntrackedParameter<std::string>("dbName", "");
86  dbHostName_ = ps.getUntrackedParameter<std::string>("dbHostName", "");
87  dbHostPort_ = ps.getUntrackedParameter<int>("dbHostPort", 1521);
88  dbUserName_ = ps.getUntrackedParameter<std::string>("dbUserName", "");
89  dbPassword_ = ps.getUntrackedParameter<std::string>("dbPassword", "");
90 
91  dbTagName_ = ps.getUntrackedParameter<std::string>("dbTagName", "CMSSW");
92 
93  if ( verbose_ ) {
94  if ( dbName_.size() != 0 ) {
95  std::cout << " Ecal Cond DB: " << std::endl;
96  std::cout << " dbName = '" << dbName_ << "'" << std::endl;
97  std::cout << " dbUserName = '" << dbUserName_ << "'" << std::endl;
98  if ( dbHostName_.size() != 0 ) {
99  std::cout << " dbHostName = '" << dbHostName_ << "'" << std::endl;
100  std::cout << " dbHostPort = '" << dbHostPort_ << "'" << std::endl;
101  }
102  std::cout << " dbTagName = '" << dbTagName_ << "'" << std::endl;
103 #ifndef WITH_ECAL_COND_DB
104  std::cout << std::endl;
105  std::cout << "WARNING: DB access is NOT available" << std::endl;
106  std::cout << std::endl;
107 #endif
108  } else {
109  std::cout << " Ecal Cond DB is OFF" << std::endl;
110  }
111  }
112 
113  // mergeRuns switch
114 
115  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
116 
117  if ( verbose_ ) {
118  if ( mergeRuns_ ) {
119  std::cout << " mergeRuns switch is ON" << std::endl;
120  } else {
121  std::cout << " mergeRuns switch is OFF" << std::endl;
122  }
123  }
124 
125  // resetFile
126 
127  resetFile_ = ps.getUntrackedParameter<std::string>("resetFile", "");
128 
129  if ( verbose_ ) {
130  if ( resetFile_.size() != 0 ) {
131  std::cout << " resetFile is '" << resetFile_ << "'" << std::endl;
132  }
133  }
134 
135  // updateTime
136 
137  updateTime_ = ps.getUntrackedParameter<int>("updateTime", 0);
138 
139  if ( verbose_ ) {
140  std::cout << " updateTime is " << updateTime_ << " minute(s)" << std::endl;
141  }
142 
143  // dbUpdateTime
144 
145  dbUpdateTime_ = ps.getUntrackedParameter<int>("dbUpdateTime", 0);
146 
147  if ( verbose_ ) {
148  std::cout << " dbUpdateTime is " << dbUpdateTime_ << " minute(s)" << std::endl;
149  }
150 
151  // location
152 
153  location_ = ps.getUntrackedParameter<std::string>("location", "H4");
154 
155  if ( verbose_ ) {
156  std::cout << " location is '" << location_ << "'" << std::endl;
157  }
158 
159  // cloneME switch
160 
161  cloneME_ = ps.getUntrackedParameter<bool>("cloneME", true);
162 
163  if ( verbose_ ) {
164  if ( cloneME_ ) {
165  std::cout << " cloneME switch is ON" << std::endl;
166  } else {
167  std::cout << " cloneME switch is OFF" << std::endl;
168  }
169  }
170 
171  // debug switch
172 
173  debug_ = ps.getUntrackedParameter<bool>("debug", false);
174 
175  if ( verbose_ ) {
176  if ( debug_ ) {
177  std::cout << " debug switch is ON" << std::endl;
178  } else {
179  std::cout << " debug switch is OFF" << std::endl;
180  }
181  }
182 
183  // prescaleFactor
184 
185  prescaleFactor_ = ps.getUntrackedParameter<int>("prescaleFactor", 1);
186 
187  if ( verbose_ ) {
188  std::cout << " prescaleFactor is " << prescaleFactor_ << std::endl;
189  }
190 
191  // prefixME path
192 
193  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
194 
195  if ( verbose_ ) {
196  std::cout << " prefixME path is '" << prefixME_ << "'" << std::endl;
197  }
198 
199  produceReports_ = ps.getUntrackedParameter<bool>("produceReports", true);
200 
201  if (produceReports_){
202  std::cout << " producing reportSummaries" << std::endl;
203  }
204 
205  // enableCleanup switch
206 
207  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
208 
209  if ( verbose_ ) {
210  if ( enableCleanup_ ) {
211  std::cout << " enableCleanup switch is ON" << std::endl;
212  } else {
213  std::cout << " enableCleanup switch is OFF" << std::endl;
214  }
215  }
216 
217  // vector of selected Super Modules (Defaults to all 18).
218 
219  superModules_.reserve(18);
220  for ( unsigned int i = 1; i <= 18; i++ ) superModules_.push_back(i);
221 
222  superModules_ = ps.getUntrackedParameter<std::vector<int> >("superModules", superModules_);
223 
224  if ( verbose_ ) {
225  std::cout << " Selected SMs:" << std::endl;
226  for ( unsigned int i = 0; i < superModules_.size(); i++ ) {
227  std::cout << " " << std::setw(2) << std::setfill('0') << superModules_[i];
228  }
229  std::cout << std::endl;
230  }
231 
232  // vector of enabled Clients (defaults)
233 
234  enabledClients_.push_back("Integrity");
235  enabledClients_.push_back("StatusFlags");
236  enabledClients_.push_back("PedestalOnline");
237  enabledClients_.push_back("Summary");
238 
239  enabledClients_ = ps.getUntrackedParameter<std::vector<std::string> >("enabledClients", enabledClients_);
240 
241  if ( verbose_ ) {
242  std::cout << " Enabled Clients:" << std::endl;
243  for ( unsigned int i = 0; i < enabledClients_.size(); i++ ) {
244  std::cout << " " << enabledClients_[i];
245  }
246  std::cout << std::endl;
247  }
248 
249  // set runTypes (use resize() on purpose!)
250 
251  runTypes_.resize(30);
252  for ( unsigned int i = 0; i < runTypes_.size(); i++ ) runTypes_[i] = "UNKNOWN";
253 
263 
270 
275 
277 
278  // clients' constructors
279 
280  clients_.reserve(12);
281  clientsNames_.reserve(12);
282 
283  if ( find(enabledClients_.begin(), enabledClients_.end(), "Integrity" ) != enabledClients_.end() ) {
284 
285  clients_.push_back( new EEIntegrityClient(ps) );
286  clientsNames_.push_back( "Integrity" );
287 
288  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
289  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
290  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_STD ));
291  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
292  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN ));
293  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
294  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
295  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
296  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
297 
298  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
299  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
300  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
301  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
302  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
303  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_GAP ));
304  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
305  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
306 
307  }
308 
309  if ( find(enabledClients_.begin(), enabledClients_.end(), "StatusFlags" ) != enabledClients_.end() ) {
310 
311  clients_.push_back( new EEStatusFlagsClient(ps) );
312  clientsNames_.push_back( "StatusFlags" );
313 
314  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
315  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
316  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_STD ));
317  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
318  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN ));
319  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
320  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
321  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
322  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
323 
324  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
325  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
326  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
327  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
328  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
329  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_GAP ));
330  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
331  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
332 
333  }
334 
335  if ( find(enabledClients_.begin(), enabledClients_.end(), "Occupancy" ) != enabledClients_.end() ) {
336 
337  clients_.push_back( new EEOccupancyClient(ps) );
338  clientsNames_.push_back( "Occupancy" );
339 
340  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
341  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
342  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_STD ));
343  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
344  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_OFFSET_SCAN ));
345  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
346  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
347  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
348  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
349 
350  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
351  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
352  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
353  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
354  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
355  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_GAP ));
356  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
357  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
358 
359  }
360 
361  if ( find(enabledClients_.begin(), enabledClients_.end(), "Cosmic" ) != enabledClients_.end() ) {
362 
363  clients_.push_back( new EECosmicClient(ps) );
364  clientsNames_.push_back( "Cosmic" );
365 
366  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
367  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
368  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_STD ));
369  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
370  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
371  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
372 
373  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
374  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
375  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
376  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
377  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
378  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_GAP ));
379  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
380  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
381 
382  }
383 
384  if ( find(enabledClients_.begin(), enabledClients_.end(), "Laser" ) != enabledClients_.end() ) {
385 
386  clients_.push_back( new EELaserClient(ps) );
387  clientsNames_.push_back( "Laser" );
388 
389  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
390  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
391  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_STD ));
392  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
393  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
394  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
395  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
396  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
397 
398  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
399  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
400  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
401  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
402  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
403  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_GAP ));
404  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
405  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
406 
407  }
408 
409  if ( find(enabledClients_.begin(), enabledClients_.end(), "Pedestal" ) != enabledClients_.end() ) {
410 
411  clients_.push_back( new EEPedestalClient(ps) );
412  clientsNames_.push_back( "Pedestal" );
413 
414  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
415  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
416  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_STD ));
417  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
418  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
419  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
420  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
421  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
422 
423  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
424  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
425  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
426  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
427  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
428  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_GAP ));
429  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
430  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
431 
432  }
433 
434  if ( find(enabledClients_.begin(), enabledClients_.end(), "PedestalOnline" ) != enabledClients_.end() ) {
435 
436  clients_.push_back( new EEPedestalOnlineClient(ps) );
437  clientsNames_.push_back( "PedestalOnline" );
438 
439  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
440  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
441  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_STD ));
442  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
443  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
444  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
445  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
446  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
447 
448  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
449  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
450  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
451  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
452  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
453  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_GAP ));
454  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
455  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
456 
457  }
458 
459  if ( find(enabledClients_.begin(), enabledClients_.end(), "TestPulse" ) != enabledClients_.end() ) {
460 
461  clients_.push_back( new EETestPulseClient(ps) );
462  clientsNames_.push_back( "TestPulse" );
463 
464  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
465  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
466  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_STD ));
467  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
468  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
469  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
470  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
471  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
472 
473  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
474  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
475  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
476  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
477  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
478  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_GAP ));
479  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
480  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
481 
482  }
483 
484  if ( find(enabledClients_.begin(), enabledClients_.end(), "TriggerTower" ) != enabledClients_.end() ) {
485 
486  clients_.push_back( new EETriggerTowerClient(ps) );
487  clientsNames_.push_back( "TriggerTower" );
488 
489  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
490  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
491  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_STD ));
492  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
493  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
494  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
495  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
496  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
497 
498  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
499  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
500  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
501  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
502  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
503  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_GAP ));
504  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
505  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
506 
507  }
508 
509  if ( find(enabledClients_.begin(), enabledClients_.end(), "Cluster" ) != enabledClients_.end() ) {
510 
511  clients_.push_back( new EEClusterClient(ps) );
512  clientsNames_.push_back( "Cluster" );
513 
514  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
515  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
516  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_STD ));
517  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
518  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
519  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
520  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
521  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
522 
523  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
524  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
525  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
526  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
527  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
528  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_GAP ));
529  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
530  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
531 
532  }
533 
534  if ( find(enabledClients_.begin(), enabledClients_.end(), "Timing" ) != enabledClients_.end() ) {
535 
536  clients_.push_back( new EETimingClient(ps) );
537  clientsNames_.push_back( "Timing" );
538 
539  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
540  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
541  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_STD ));
542  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
543  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
544  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
545  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
546  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
547 
548  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_GLOBAL ));
549  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
550  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMICS_LOCAL ));
551  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
552  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
553  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_GAP ));
554  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
555  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
556 
557  }
558 
559  if ( find(enabledClients_.begin(), enabledClients_.end(), "Led" ) != enabledClients_.end() ) {
560 
561  clients_.push_back( new EELedClient(ps) );
562  clientsNames_.push_back( "Led" );
563 
564  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::COSMIC ));
565  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_STD ));
566  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_STD ));
567  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_STD ));
568  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_MGPA ));
569  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH4 ));
570  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::BEAMH2 ));
571  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::MTCC ));
572 
573  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_GLOBAL ));
574  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PHYSICS_LOCAL ));
575  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LASER_GAP ));
576  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::LED_GAP ));
577  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::TESTPULSE_GAP ));
578  clientsRuns_.insert(std::pair<EEClient*,int>( clients_.back(), EcalDCCHeaderBlock::PEDESTAL_GAP ));
579 
580  }
581 
582  // define status bits
583 
584  clientsStatus_.insert(std::pair<std::string,int>( "Integrity", 0 ));
585  clientsStatus_.insert(std::pair<std::string,int>( "Cosmic", 1 ));
586  clientsStatus_.insert(std::pair<std::string,int>( "Laser", 2 ));
587  clientsStatus_.insert(std::pair<std::string,int>( "Pedestal", 3 ));
588  clientsStatus_.insert(std::pair<std::string,int>( "PedestalOnline", 4 ));
589  clientsStatus_.insert(std::pair<std::string,int>( "TestPulse", 5 ));
590  clientsStatus_.insert(std::pair<std::string,int>( "TriggerTower", 8 ));
591  clientsStatus_.insert(std::pair<std::string,int>( "Cluster", 9 ));
592  clientsStatus_.insert(std::pair<std::string,int>( "Timing", 10 ));
593  clientsStatus_.insert(std::pair<std::string,int>( "Led", 11 ));
594  clientsStatus_.insert(std::pair<std::string,int>( "StatusFlags", 12 ));
595  clientsStatus_.insert(std::pair<std::string,int>( "Occupancy", 13 ));
596 
597  summaryClient_ = 0;
598 
599  if ( find(enabledClients_.begin(), enabledClients_.end(), "Summary" ) != enabledClients_.end() ) {
600 
602 
603  }
604 
606 
607  if ( verbose_ ) std::cout << std::endl;
608 
609 }
610 
612 
613  if ( verbose_ ) std::cout << "Exit ..." << std::endl;
614 
615  for ( unsigned int i=0; i<clients_.size(); i++ ) {
616  delete clients_[i];
617  }
618 
619  if ( summaryClient_ ) delete summaryClient_;
620 
621 }
622 
624 
625  begin_run_ = false;
626  end_run_ = false;
627 
628  forced_status_ = false;
629  forced_update_ = false;
630 
631  h_ = 0;
632 
633  status_ = "unknown";
634 
635  run_ = -1;
636  evt_ = -1;
637 
638  runType_ = -1;
639  evtType_ = -1;
640 
641  last_run_ = -1;
642 
643  subrun_ = -1;
644 
645  if ( debug_ ) std::cout << "EcalEndcapMonitorClient: beginJob" << std::endl;
646 
647  ievt_ = 0;
648  jevt_ = 0;
649 
653 
654  // get hold of back-end interface
656 
657  if ( inputFile_.size() != 0 ) {
658  if ( dqmStore_ ) {
660  }
661  }
662 
663  for ( unsigned int i=0; i<clients_.size(); i++ ) {
664  clients_[i]->beginJob();
665  }
666 
668 
669 }
670 
672 
673  begin_run_ = true;
674  end_run_ = false;
675 
676  last_run_ = run_;
677 
678  if ( debug_ ) std::cout << "EcalEndcapMonitorClient: beginRun" << std::endl;
679 
680  jevt_ = 0;
681 
685 
686  this->setup();
687 
688  this->beginRunDb();
689 
690  for ( int i=0; i<int(clients_.size()); i++ ) {
691  clients_[i]->cleanup();
692  bool done = false;
693  for ( std::multimap<EEClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
694  if ( runType_ != -1 && runType_ == (*j).second && !done ) {
695  done = true;
696  clients_[i]->beginRun();
697  }
698  }
699  }
700 
702 
703 }
704 
706 
708 
709  if ( verbose_ ) std::cout << std::endl;
710 
712 
713  if ( verbose_ ) {
714  std::cout << std::endl;
715  std::cout << "Standard beginRun() for run " << r.id().run() << std::endl;
716  std::cout << std::endl;
717  }
718 
719  // summary for DQM GUI
720 
721  if(produceReports_){
722 
723  MonitorElement* me;
724 
725  dqmStore_->setCurrentFolder( prefixME_ + "/EventInfo" );
726 
727  me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummary");
728  if ( me ) {
730  }
731  me = dqmStore_->bookFloat("reportSummary");
732  me->Fill(-1.0);
733 
734  dqmStore_->setCurrentFolder( prefixME_ + "/EventInfo/reportSummaryContents" );
735 
736  for (int i = 0; i < 18; i++) {
737  me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryContents/EcalEndcap_" + Numbers::sEE(i+1) );
738  if ( me ) {
740  }
741  me = dqmStore_->bookFloat("EcalEndcap_" + Numbers::sEE(i+1));
742  me->Fill(-1.0);
743  }
744 
745  dqmStore_->setCurrentFolder( prefixME_ + "/EventInfo" );
746 
747  me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryMap");
748  if ( me ) {
750  }
751 
752  me = dqmStore_->book2D("reportSummaryMap", "EcalEndcap Report Summary Map", 40, 0., 200., 20, 0., 100);
753  for ( int jx = 1; jx <= 40; jx++ ) {
754  for ( int jy = 1; jy <= 20; jy++ ) {
755  me->setBinContent( jx, jy, -1.0 );
756  }
757  }
758  me->setAxisTitle("ix / ix+100", 1);
759  me->setAxisTitle("iy", 2);
760  }
761 
762  run_ = r.id().run();
763  evt_ = 0;
764 
765  jevt_ = 0;
766 
767 }
768 
770 
771  if ( ! end_run_ ) {
772 
773  if ( verbose_ ) {
774  std::cout << std::endl;
775  std::cout << "Checking last event at endJob() ... " << std::endl;
776  std::cout << std::endl;
777  }
778 
779  forced_update_ = true;
780 
781  this->analyze();
782 
783  if ( begin_run_ && ! end_run_ ) {
784 
785  if ( verbose_ ) {
786  std::cout << std::endl;
787  std::cout << "Forcing endRun() ... " << std::endl;
788  std::cout << std::endl;
789  }
790 
791  forced_status_ = true;
792 
793  this->analyze();
794  this->endRun();
795 
796  }
797 
798  }
799 
800  if ( debug_ ) std::cout << "EcalEndcapMonitorClient: endJob, ievt = " << ievt_ << std::endl;
801 
802  this->cleanup();
803 
804  for ( unsigned int i=0; i<clients_.size(); i++ ) {
805  clients_[i]->endJob();
806  }
807 
809 
810 }
811 
813 
814  begin_run_ = false;
815  end_run_ = true;
816 
817  if ( debug_ ) std::cout << "EcalEndcapMonitorClient: endRun, jevt = " << jevt_ << std::endl;
818 
819  if ( subrun_ != -1 ) {
820 
821  this->writeDb();
822 
823  this->endRunDb();
824 
825  }
826 
827  if ( resetFile_.size() != 0 || dbUpdateTime_ > 0 ) {
828 
829  this->softReset(false);
830 
831  for ( int i=0; i<int(clients_.size()); i++ ) {
832  bool done = false;
833  for ( std::multimap<EEClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
834  if ( runType_ != -1 && runType_ == (*j).second && !done ) {
835  done = true;
836  clients_[i]->analyze();
837  }
838  }
839  }
840 
842 
843  }
844 
845  for ( int i=0; i<int(clients_.size()); i++ ) {
846  bool done = false;
847  for ( std::multimap<EEClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
848  if ( runType_ != -1 && runType_ == (*j).second && !done ) {
849  done = true;
850  clients_[i]->endRun();
851  }
852  }
853  }
854 
856 
857  this->cleanup();
858 
859  status_ = "unknown";
860 
861  run_ = -1;
862  evt_ = -1;
863 
864  runType_ = -1;
865  evtType_ = -1;
866 
867  subrun_ = -1;
868 
869 }
870 
872 
873  if ( verbose_ ) {
874  std::cout << std::endl;
875  std::cout << "Standard endRun() for run " << r.id().run() << std::endl;
876  std::cout << std::endl;
877  }
878 
879 
880  this->analyze();
881 
882  if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
883 
884  forced_update_ = true;
885 
886  this->analyze();
887 
888  if ( ! mergeRuns_ ) {
889 
890  if ( begin_run_ && ! end_run_ ) {
891 
892  forced_status_ = false;
893  this->endRun();
894 
895  }
896 
897  }
898 
899  }
900 
901  // summary for DQM GUI
902 
903  if ( run_ != -1 && evt_ != -1 && runType_ == -1 ) {
904 
905  MonitorElement* me;
906 
907  me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummary");
908  if ( me ) me->Fill(-1.0);
909 
910  for (int i = 0; i < 18; i++) {
911  me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryContents/EcalEndcap_" + Numbers::sEE(i+1));
912  if ( me ) me->Fill(-1.0);
913  }
914 
915  me = dqmStore_->get(prefixME_ + "/EventInfo/reportSummaryMap");
916  for ( int jx = 1; jx <= 40; jx++ ) {
917  for ( int jy = 1; jy <= 20; jy++ ) {
918  if ( me ) me->setBinContent( jx, jy, -1.0 );
919  }
920  }
921 
922  }
923 
924 }
925 
927 
928  if ( verbose_ ) {
929  std::cout << std::endl;
930  std::cout << "Standard beginLuminosityBlock() for luminosity block " << l.id().luminosityBlock() << " of run " << l.id().run() << std::endl;
931  std::cout << std::endl;
932  }
933 
934 }
935 
937 
939 
940  if ( verbose_ ) {
941  std::cout << std::endl;
942  std::cout << "Standard endLuminosityBlock() for luminosity block " << l.id().luminosityBlock() << " of run " << l.id().run() << std::endl;
943  std::cout << std::endl;
944  }
945 
946  if ( updateTime_ > 0 ) {
947  if ( (current_time_ - last_time_update_) < 60 * updateTime_ ) {
948  return;
949  }
951  }
952 
953  if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
954 
955  forced_update_ = true;
956 
957  this->analyze();
958 
959  }
960 
961  for(unsigned iC(0); iC < enabledClients_.size(); iC++){
962  std::string& name(enabledClients_[iC]);
963 
964  if(name == "Cluster" || name == "Cosmic" || name == "Occupancy" || name == "StatusFlags" || name == "Trend") continue;
965 
966  if(!dqmStore_->dirExists(prefixME_ + "/EE" + name + "Client")){
967  std::vector<std::string>::iterator itr(std::find(clientsNames_.begin(), clientsNames_.end(), name));
968  if(itr == clientsNames_.end()) continue; // something seriously wrong, but ignore
969 
970  std::cout << "EE" << name << "Client is missing plots; resetting now" << std::endl;
971 
972  EEClient* client(clients_[itr - clientsNames_.begin()]);
973 
974  client->cleanup();
975  client->setup();
976  }
977  }
978 
979 }
980 
982 
983 }
984 
986 
987 }
988 
990 
991  if ( ! enableCleanup_ ) return;
992 
993  if ( cloneME_ ) {
994  if ( h_ ) delete h_;
995  }
996 
997  h_ = 0;
998 
999 }
1000 
1002 
1003  subrun_ = 0;
1004 
1005 #ifdef WITH_ECAL_COND_DB
1006  EcalCondDBInterface* econn;
1007 
1008  econn = 0;
1009 
1010  if ( dbName_.size() != 0 ) {
1011  try {
1012  if ( verbose_ ) std::cout << "Opening DB connection with TNS_ADMIN ..." << std::endl;
1014  if ( verbose_ ) std::cout << "done." << std::endl;
1015  } catch (std::runtime_error &e) {
1016  std::cerr << e.what() << std::endl;
1017  if ( dbHostName_.size() != 0 ) {
1018  try {
1019  if ( verbose_ ) std::cout << "Opening DB connection without TNS_ADMIN ..." << std::endl;
1021  if ( verbose_ ) std::cout << "done." << std::endl;
1022  } catch (std::runtime_error &e) {
1023  std::cerr << e.what() << std::endl;
1024  }
1025  }
1026  }
1027  }
1028 
1029  // create the objects necessary to identify a dataset
1030 
1031  LocationDef locdef;
1032 
1033  locdef.setLocation(location_);
1034 
1035  RunTypeDef rundef;
1036 
1037  rundef.setRunType( this->getRunType() );
1038 
1039  RunTag runtag;
1040 
1041  runtag.setLocationDef(locdef);
1042  runtag.setRunTypeDef(rundef);
1043 
1044  runtag.setGeneralTag( this->getRunType() );
1045 
1046  // fetch the RunIOV from the DB
1047 
1048  bool foundRunIOV = false;
1049 
1050  if ( econn ) {
1051  try {
1052  if ( verbose_ ) std::cout << "Fetching RunIOV ..." << std::endl;
1053 // runiov_ = econn->fetchRunIOV(&runtag, run_);
1054  runiov_ = econn->fetchRunIOV(location_, run_);
1055  if ( verbose_ ) std::cout << "done." << std::endl;
1056  foundRunIOV = true;
1057  } catch (std::runtime_error &e) {
1058  std::cerr << e.what() << std::endl;
1059  foundRunIOV = false;
1060  }
1061  }
1062 
1063  // begin - setup the RunIOV (on behalf of the DAQ)
1064 
1065  if ( ! foundRunIOV ) {
1066 
1067  Tm startRun;
1068 
1069  startRun.setToCurrentGMTime();
1070 
1071  runiov_.setRunNumber(run_);
1072  runiov_.setRunStart(startRun);
1073  runiov_.setRunTag(runtag);
1074 
1075  if ( econn ) {
1076  try {
1077  if ( verbose_ ) std::cout << "Inserting RunIOV ..." << std::endl;
1078  econn->insertRunIOV(&runiov_);
1079 // runiov_ = econn->fetchRunIOV(&runtag, run_);
1080  runiov_ = econn->fetchRunIOV(location_, run_);
1081  if ( verbose_ ) std::cout << "done." << std::endl;
1082  } catch (std::runtime_error &e) {
1083  std::cerr << e.what() << std::endl;
1084  try {
1085  if ( verbose_ ) std::cout << "Fetching RunIOV (again) ..." << std::endl;
1086 // runiov_ = econn->fetchRunIOV(&runtag, run_);
1087  runiov_ = econn->fetchRunIOV(location_, run_);
1088  if ( verbose_ ) std::cout << "done." << std::endl;
1089  foundRunIOV = true;
1090  } catch (std::runtime_error &e) {
1091  std::cerr << e.what() << std::endl;
1092  foundRunIOV = false;
1093  }
1094  }
1095  }
1096 
1097  }
1098 
1099  // end - setup the RunIOV (on behalf of the DAQ)
1100 
1101  if ( verbose_ ) {
1102  std::cout << std::endl;
1103  std::cout << "=============RunIOV:" << std::endl;
1104  std::cout << "Run Number: " << runiov_.getRunNumber() << std::endl;
1105  std::cout << "Run Start: " << runiov_.getRunStart().str() << std::endl;
1106  std::cout << "Run End: " << runiov_.getRunEnd().str() << std::endl;
1107  std::cout << "====================" << std::endl;
1108  std::cout << std::endl;
1109  std::cout << "=============RunTag:" << std::endl;
1110  std::cout << "GeneralTag: " << runiov_.getRunTag().getGeneralTag() << std::endl;
1111  std::cout << "Location: " << runiov_.getRunTag().getLocationDef().getLocation() << std::endl;
1112  std::cout << "Run Type: " << runiov_.getRunTag().getRunTypeDef().getRunType() << std::endl;
1113  std::cout << "====================" << std::endl;
1114  std::cout << std::endl;
1115  }
1116 
1117  std::string rt = runiov_.getRunTag().getRunTypeDef().getRunType();
1118  if ( strcmp(rt.c_str(), "UNKNOWN") == 0 ) {
1119  runType_ = -1;
1120  } else {
1121  for ( unsigned int i = 0; i < runTypes_.size(); i++ ) {
1122  if ( strcmp(rt.c_str(), runTypes_[i].c_str()) == 0 ) {
1123  if ( runType_ != int(i) ) {
1124  if ( verbose_ ) {
1125  std::cout << std::endl;
1126  std::cout << "Fixing Run Type to: " << runTypes_[i] << std::endl;
1127  std::cout << std::endl;
1128  }
1129  runType_ = i;
1130  }
1131  break;
1132  }
1133  }
1134  }
1135 
1136  if ( verbose_ ) std::cout << std::endl;
1137 
1138  if ( econn ) {
1139  try {
1140  if ( verbose_ ) std::cout << "Closing DB connection ..." << std::endl;
1141  delete econn;
1142  econn = 0;
1143  if ( verbose_ ) std::cout << "done." << std::endl;
1144  } catch (std::runtime_error &e) {
1145  std::cerr << e.what() << std::endl;
1146  }
1147  }
1148 #endif
1149 
1150  if ( verbose_ ) std::cout << std::endl;
1151 
1152 }
1153 
1155 
1156  subrun_++;
1157 
1158 #ifdef WITH_ECAL_COND_DB
1159  EcalCondDBInterface* econn;
1160 
1161  econn = 0;
1162 
1163  if ( dbName_.size() != 0 ) {
1164  try {
1165  if ( verbose_ ) std::cout << "Opening DB connection with TNS_ADMIN ..." << std::endl;
1167  if ( verbose_ ) std::cout << "done." << std::endl;
1168  } catch (std::runtime_error &e) {
1169  std::cerr << e.what() << std::endl;
1170  if ( dbHostName_.size() != 0 ) {
1171  try {
1172  if ( verbose_ ) std::cout << "Opening DB connection without TNS_ADMIN ..." << std::endl;
1174  if ( verbose_ ) std::cout << "done." << std::endl;
1175  } catch (std::runtime_error &e) {
1176  std::cerr << e.what() << std::endl;
1177  }
1178  }
1179  }
1180  }
1181 
1182  MonVersionDef monverdef;
1183 
1184  monverdef.setMonitoringVersion("test01");
1185 
1186  MonRunTag montag;
1187 
1188  montag.setMonVersionDef(monverdef);
1189  montag.setGeneralTag(dbTagName_);
1190 
1191  Tm startSubRun;
1192 
1193  startSubRun.setToCurrentGMTime();
1194 
1195  // fetch the MonIOV from the DB
1196 
1197  bool foundMonIOV = false;
1198 
1199  if ( econn ) {
1200  try {
1201  if ( verbose_ ) std::cout << "Fetching MonIOV ..." << std::endl;
1202  RunTag runtag = runiov_.getRunTag();
1203  moniov_ = econn->fetchMonRunIOV(&runtag, &montag, run_, subrun_);
1204  if ( verbose_ ) std::cout << "done." << std::endl;
1205  foundMonIOV = true;
1206  } catch (std::runtime_error &e) {
1207  std::cerr << e.what() << std::endl;
1208  foundMonIOV = false;
1209  }
1210  }
1211 
1212  // begin - setup the MonIOV
1213 
1214  if ( !foundMonIOV ) {
1215 
1216  moniov_.setRunIOV(runiov_);
1217  moniov_.setSubRunNumber(subrun_);
1218 
1219  if ( subrun_ > 1 ) {
1220  moniov_.setSubRunStart(startSubRun);
1221  } else {
1222  moniov_.setSubRunStart(runiov_.getRunStart());
1223  }
1224 
1225  moniov_.setMonRunTag(montag);
1226 
1227  if ( econn ) {
1228  try {
1229  if ( verbose_ ) std::cout << "Inserting MonIOV ..." << std::endl;
1230  econn->insertMonRunIOV(&moniov_);
1231  RunTag runtag = runiov_.getRunTag();
1232  moniov_ = econn->fetchMonRunIOV(&runtag, &montag, run_, subrun_);
1233  if ( verbose_ ) std::cout << "done." << std::endl;
1234  } catch (std::runtime_error &e) {
1235  std::cerr << e.what() << std::endl;
1236  try {
1237  if ( verbose_ ) std::cout << "Fetching MonIOV (again) ..." << std::endl;
1238  RunTag runtag = runiov_.getRunTag();
1239  moniov_ = econn->fetchMonRunIOV(&runtag, &montag, run_, subrun_);
1240  if ( verbose_ ) std::cout << "done." << std::endl;
1241  foundMonIOV = true;
1242  } catch (std::runtime_error &e) {
1243  std::cerr << e.what() << std::endl;
1244  foundMonIOV = false;
1245  }
1246  }
1247  }
1248 
1249  }
1250 
1251  // end - setup the MonIOV
1252 
1253  if ( verbose_ ) {
1254  std::cout << std::endl;
1255  std::cout << "==========MonRunIOV:" << std::endl;
1256  std::cout << "SubRun Number: " << moniov_.getSubRunNumber() << std::endl;
1257  std::cout << "SubRun Start: " << moniov_.getSubRunStart().str() << std::endl;
1258  std::cout << "SubRun End: " << moniov_.getSubRunEnd().str() << std::endl;
1259  std::cout << "====================" << std::endl;
1260  std::cout << std::endl;
1261  std::cout << "==========MonRunTag:" << std::endl;
1262  std::cout << "GeneralTag: " << moniov_.getMonRunTag().getGeneralTag() << std::endl;
1263  std::cout << "Monitoring Ver: " << moniov_.getMonRunTag().getMonVersionDef().getMonitoringVersion() << std::endl;
1264  std::cout << "====================" << std::endl;
1265  std::cout << std::endl;
1266  }
1267 
1268  int taskl = 0x0;
1269  int tasko = 0x0;
1270 
1271  for ( int i=0; i<int(clients_.size()); i++ ) {
1272  bool done = false;
1273  for ( std::multimap<EEClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
1274  if ( h_ && runType_ != -1 && runType_ == (*j).second && !done ) {
1276  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;
1277  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;
1278  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;
1279  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;
1280  done = true;
1281  if ( verbose_ ) {
1282  if ( econn ) {
1283  std::cout << " Writing " << clientsNames_[i] << " results to DB " << std::endl;
1284  std::cout << std::endl;
1285  }
1286  }
1287  bool status;
1288  if ( clients_[i]->writeDb(econn, &runiov_, &moniov_, status) ) {
1289  taskl |= 0x1 << clientsStatus_[clientsNames_[i]];
1290  if ( status ) {
1291  tasko |= 0x1 << clientsStatus_[clientsNames_[i]];
1292  }
1293  } else {
1294  tasko |= 0x1 << clientsStatus_[clientsNames_[i]];
1295  }
1296  }
1297  }
1298  if ( ((taskl >> clientsStatus_[clientsNames_[i]]) & 0x1) ) {
1299  if ( verbose_ ) {
1300  std::cout << " Task output for " << clientsNames_[i] << " = "
1301  << ((tasko >> clientsStatus_[clientsNames_[i]]) & 0x1) << std::endl;
1302  std::cout << std::endl;
1303  }
1304  }
1305  }
1306 
1307  bool status;
1308  if ( summaryClient_ ) summaryClient_->writeDb(econn, &runiov_, &moniov_, status);
1309 
1310  EcalLogicID ecid;
1311  MonRunDat md;
1312  std::map<EcalLogicID, MonRunDat> dataset;
1313 
1314  MonRunOutcomeDef monRunOutcomeDef;
1315 
1316  monRunOutcomeDef.setShortDesc("success");
1317 
1318  float nevt = -1.;
1319 
1320  if ( h_ ) nevt = h_->GetSumOfWeights();
1321 
1322  md.setNumEvents(int(nevt));
1323  md.setMonRunOutcomeDef(monRunOutcomeDef);
1324 
1325 // string fileName = "";
1326 // md.setRootfileName(fileName);
1327 
1328  md.setTaskList(taskl);
1329  md.setTaskOutcome(tasko);
1330 
1331  if ( econn ) {
1332  try {
1333  ecid = LogicID::getEcalLogicID("EE");
1334  dataset[ecid] = md;
1335  } catch (std::runtime_error &e) {
1336  std::cerr << e.what() << std::endl;
1337  }
1338  }
1339 
1340  if ( econn ) {
1341  try {
1342  if ( verbose_ ) std::cout << "Inserting MonRunDat ..." << std::endl;
1343  econn->insertDataSet(&dataset, &moniov_);
1344  if ( verbose_ ) std::cout << "done." << std::endl;
1345  } catch (std::runtime_error &e) {
1346  std::cerr << e.what() << std::endl;
1347  }
1348  }
1349 
1350  if ( econn ) {
1351  try {
1352  if ( verbose_ ) std::cout << "Closing DB connection ..." << std::endl;
1353  delete econn;
1354  econn = 0;
1355  if ( verbose_ ) std::cout << "done." << std::endl;
1356  } catch (std::runtime_error &e) {
1357  std::cerr << e.what() << std::endl;
1358  }
1359  }
1360 #endif
1361 
1362  if ( verbose_ ) std::cout << std::endl;
1363 
1364 }
1365 
1367 
1368 #ifdef WITH_ECAL_COND_DB
1369  EcalCondDBInterface* econn;
1370 
1371  econn = 0;
1372 
1373  if ( dbName_.size() != 0 ) {
1374  try {
1375  if ( verbose_ ) std::cout << "Opening DB connection with TNS_ADMIN ..." << std::endl;
1377  if ( verbose_ ) std::cout << "done." << std::endl;
1378  } catch (std::runtime_error &e) {
1379  std::cerr << e.what() << std::endl;
1380  if ( dbHostName_.size() != 0 ) {
1381  try {
1382  if ( verbose_ ) std::cout << "Opening DB connection without TNS_ADMIN ..." << std::endl;
1384  if ( verbose_ ) std::cout << "done." << std::endl;
1385  } catch (std::runtime_error &e) {
1386  std::cerr << e.what() << std::endl;
1387  }
1388  }
1389  }
1390  }
1391 
1392  EcalLogicID ecid;
1393  RunDat rd;
1394  std::map<EcalLogicID, RunDat> dataset;
1395 
1396  float nevt = -1.;
1397 
1398  if ( h_ ) nevt = h_->GetSumOfWeights();
1399 
1400  rd.setNumEvents(int(nevt));
1401 
1402  // fetch the RunDat from the DB
1403 
1404  bool foundRunDat = false;
1405 
1406  if ( econn ) {
1407  try {
1408  if ( verbose_ ) std::cout << "Fetching RunDat ..." << std::endl;
1409  econn->fetchDataSet(&dataset, &runiov_);
1410  if ( verbose_ ) std::cout << "done." << std::endl;
1411  foundRunDat = true;
1412  } catch (std::runtime_error &e) {
1413  std::cerr << e.what() << std::endl;
1414  foundRunDat = false;
1415  }
1416  }
1417 
1418  // begin - setup the RunDat (on behalf of the DAQ)
1419 
1420  if ( ! foundRunDat ) {
1421 
1422  if ( econn ) {
1423  try {
1424  ecid = LogicID::getEcalLogicID("EE");
1425  dataset[ecid] = rd;
1426  } catch (std::runtime_error &e) {
1427  std::cerr << e.what() << std::endl;
1428  }
1429  }
1430 
1431  if ( econn ) {
1432  try {
1433  if ( verbose_ ) std::cout << "Inserting RunDat ..." << std::endl;
1434  econn->insertDataSet(&dataset, &runiov_);
1435  if ( verbose_ ) std::cout << "done." << std::endl;
1436  } catch (std::runtime_error &e) {
1437  std::cerr << e.what() << std::endl;
1438  }
1439  }
1440 
1441  }
1442 
1443  // end - setup the RunDat (on behalf of the DAQ)
1444 
1445  if ( econn ) {
1446  try {
1447  if ( verbose_ ) std::cout << "Closing DB connection ..." << std::endl;
1448  delete econn;
1449  econn = 0;
1450  if ( verbose_ ) std::cout << "done." << std::endl;
1451  } catch (std::runtime_error &e) {
1452  std::cerr << e.what() << std::endl;
1453  }
1454  }
1455 #endif
1456 
1457 }
1458 
1460 
1461  current_time_ = time(NULL);
1462 
1463  ievt_++;
1464  jevt_++;
1465 
1466  if ( debug_ ) std::cout << "EcalEndcapMonitorClient: ievt/jevt = " << ievt_ << "/" << jevt_ << std::endl;
1467 
1468  MonitorElement* me;
1469  std::string s;
1470 
1471  me = dqmStore_->get(prefixME_ + "/EcalInfo/STATUS");
1472  if ( me ) {
1473  status_ = "unknown";
1474  s = me->valueString();
1475  if ( strcmp(s.c_str(), "i=0") == 0 ) status_ = "begin-of-run";
1476  if ( strcmp(s.c_str(), "i=1") == 0 ) status_ = "running";
1477  if ( strcmp(s.c_str(), "i=2") == 0 ) status_ = "end-of-run";
1478  if ( debug_ ) std::cout << "Found '" << prefixME_ << "/EcalInfo/STATUS'" << std::endl;
1479  }
1480 
1481  if ( inputFile_.size() != 0 ) {
1482  if ( ievt_ == 1 ) {
1483  if ( verbose_ ) {
1484  std::cout << std::endl;
1485  std::cout << " Reading DQM from file, forcing 'begin-of-run'" << std::endl;
1486  std::cout << std::endl;
1487  }
1488  status_ = "begin-of-run";
1489  }
1490  }
1491 
1492  int ecal_run = -1;
1493  me = dqmStore_->get(prefixME_ + "/EcalInfo/RUN");
1494  if ( me ) {
1495  s = me->valueString();
1496  sscanf(s.c_str(), "i=%d", &ecal_run);
1497  if ( debug_ ) std::cout << "Found '" << prefixME_ << "/EcalInfo/RUN'" << std::endl;
1498  }
1499 
1500  int ecal_evt = -1;
1501  me = dqmStore_->get(prefixME_ + "/EcalInfo/EVT");
1502  if ( me ) {
1503  s = me->valueString();
1504  sscanf(s.c_str(), "i=%d", &ecal_evt);
1505  if ( debug_ ) std::cout << "Found '" << prefixME_ << "/EcalInfo/EVT'" << std::endl;
1506  }
1507 
1508  me = dqmStore_->get(prefixME_ + "/EcalInfo/EVTTYPE");
1509  h_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, h_ );
1510 
1511  me = dqmStore_->get(prefixME_ + "/EcalInfo/RUNTYPE");
1512  if ( me ) {
1513  s = me->valueString();
1514  sscanf(s.c_str(), "i=%d", &evtType_);
1515  if ( runType_ == -1 ) runType_ = evtType_;
1516  if ( debug_ ) std::cout << "Found '" << prefixME_ << "/EcalInfo/RUNTYPE'" << std::endl;
1517  }
1518 
1519  // if the run number from the Event is less than zero,
1520  // use the run number from the ECAL DCC header
1521  if ( run_ <= 0 ) run_ = ecal_run;
1522 
1523  if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
1524  if ( ! mergeRuns_ && run_ != last_run_ ) forced_update_ = true;
1525  }
1526 
1527  bool update = ( forced_update_ ) ||
1528  ( prescaleFactor_ != 1 ) ||
1529  ( jevt_ < 10 ) ||
1530  ( jevt_ < 100 && jevt_ % 10 == 0 ) ||
1531  ( jevt_ < 1000 && jevt_ % 100 == 0 ) ||
1532  ( jevt_ % 1000 == 0 );
1533 
1534  if ( update || strcmp(status_.c_str(), "begin-of-run") == 0 || strcmp(status_.c_str(), "end-of-run") == 0 ) {
1535 
1536  if ( verbose_ ) {
1537  std::cout << " RUN status = \"" << status_ << "\"" << std::endl;
1538  std::cout << " CMS run/event number = " << run_ << "/" << evt_ << std::endl;
1539  std::cout << " EE run/event number = " << ecal_run << "/" << ecal_evt << std::endl;
1540  std::cout << " EE location = " << location_ << std::endl;
1541  std::cout << " EE run/event type = " << this->getRunType() << "/" << ( evtType_ == -1 ? "UNKNOWN" : runTypes_[evtType_] ) << std::flush;
1542 
1543  if ( h_ ) {
1544  if ( h_->GetSumOfWeights() != 0 ) {
1545  std::cout << " ( " << std::flush;
1546  for ( unsigned int i = 0; i < runTypes_.size(); i++ ) {
1547  if ( strcmp(runTypes_[i].c_str(), "UNKNOWN") != 0 && h_->GetBinContent(2+i) != 0 ) {
1548  std::string s = runTypes_[i];
1549  transform( s.begin(), s.end(), s.begin(), (int(*)(int))tolower );
1550  std::cout << s << " ";
1551  }
1552  }
1553  std::cout << ")" << std::flush;
1554  }
1555  }
1556  std::cout << std::endl;
1557  }
1558 
1559  }
1560 
1561  if ( strcmp(status_.c_str(), "begin-of-run") == 0 ) {
1562 
1563  if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
1564 
1565  if ( ! begin_run_ ) {
1566 
1567  forced_status_ = false;
1568  this->beginRun();
1569 
1570  }
1571 
1572  }
1573 
1574  }
1575 
1576  if ( strcmp(status_.c_str(), "begin-of-run") == 0 || strcmp(status_.c_str(), "running") == 0 || strcmp(status_.c_str(), "end-of-run") == 0 ) {
1577 
1578  if ( begin_run_ && ! end_run_ ) {
1579 
1580  bool update = ( forced_update_ ) ||
1581  ( prescaleFactor_ != 1 ) ||
1582  ( jevt_ < 3 ) ||
1583  ( jevt_ < 1000 && jevt_ % 100 == 0 ) ||
1584  ( jevt_ < 10000 && jevt_ % 1000 == 0 ) ||
1585  ( jevt_ % 10000 == 0 );
1586 
1587  if ( update || strcmp(status_.c_str(), "begin-of-run") == 0 || strcmp(status_.c_str(), "end-of-run") == 0 ) {
1588 
1589  for ( int i=0; i<int(clients_.size()); i++ ) {
1590  bool done = false;
1591  for ( std::multimap<EEClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
1592  if ( runType_ != -1 && runType_ == (*j).second && !done ) {
1593  done = true;
1594  clients_[i]->analyze();
1595  }
1596  }
1597  }
1598 
1600 
1601  }
1602 
1603  forced_update_ = false;
1604 
1605  bool reset = false;
1606 
1607  if ( resetFile_.size() != 0 ) {
1608  if ( access(resetFile_.c_str(), W_OK) == 0 ) {
1609  if ( unlink(resetFile_.c_str()) == 0 ) {
1610  reset |= true;
1611  }
1612  }
1613  }
1614 
1615  if ( dbUpdateTime_ > 0 ) {
1616  reset |= (current_time_ - last_time_reset_) > 60 * dbUpdateTime_;
1617  }
1618 
1619  if ( reset ) {
1627  this->softReset(true);
1629  }
1630 
1631  }
1632 
1633  }
1634 
1635  if ( strcmp(status_.c_str(), "end-of-run") == 0 ) {
1636 
1637  if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
1638 
1639  if ( begin_run_ && ! end_run_ ) {
1640 
1641  forced_status_ = false;
1642  this->endRun();
1643 
1644  }
1645 
1646  }
1647 
1648  }
1649 
1650  // BEGIN: run-time fixes for missing state transitions
1651 
1652  // run number transition
1653 
1654  if ( strcmp(status_.c_str(), "running") == 0 ) {
1655 
1656  if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
1657 
1658  if ( ! mergeRuns_ ) {
1659 
1660  int new_run_ = run_;
1661  int old_run_ = last_run_;
1662 
1663  if ( new_run_ != old_run_ ) {
1664 
1665  if ( begin_run_ && ! end_run_ ) {
1666 
1667  if ( verbose_ ) {
1668  std::cout << std::endl;
1669  std::cout << " Old run has finished, issuing endRun() ... " << std::endl;
1670  std::cout << std::endl;
1671  }
1672 
1673  // end old_run_
1674  run_ = old_run_;
1675 
1676  forced_status_ = false;
1677  this->endRun();
1678 
1679  }
1680 
1681  if ( ! begin_run_ ) {
1682 
1683  if ( verbose_ ) {
1684  std::cout << std::endl;
1685  std::cout << " New run has started, issuing beginRun() ... " << std::endl;
1686  std::cout << std::endl;
1687  }
1688 
1689  // start new_run_
1690  run_ = new_run_;
1691 
1692  forced_status_ = false;
1693  this->beginRun();
1694 
1695  }
1696 
1697  }
1698 
1699  }
1700 
1701  }
1702 
1703  }
1704 
1705  // 'running' state without a previous 'begin-of-run' state
1706 
1707  if ( strcmp(status_.c_str(), "running") == 0 ) {
1708 
1709  if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
1710 
1711  if ( ! forced_status_ ) {
1712 
1713  if ( ! begin_run_ ) {
1714 
1715  if ( verbose_ ) {
1716  std::cout << std::endl;
1717  std::cout << "Forcing beginRun() ... NOW !" << std::endl;
1718  std::cout << std::endl;
1719  }
1720 
1721  forced_status_ = true;
1722  this->beginRun();
1723 
1724  }
1725 
1726  }
1727 
1728  }
1729 
1730  }
1731 
1732  // 'end-of-run' state without a previous 'begin-of-run' or 'running' state
1733 
1734  if ( strcmp(status_.c_str(), "end-of-run") == 0 ) {
1735 
1736  if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
1737 
1738  if ( ! forced_status_ ) {
1739 
1740  if ( ! begin_run_ ) {
1741 
1742  if ( verbose_ ) {
1743  std::cout << std::endl;
1744  std::cout << "Forcing beginRun() ... NOW !" << std::endl;
1745  std::cout << std::endl;
1746  }
1747 
1748  forced_status_ = true;
1749  this->beginRun();
1750 
1751  }
1752 
1753  }
1754 
1755  }
1756 
1757  }
1758 
1759  // END: run-time fixes for missing state transitions
1760 
1761 }
1762 
1764 
1765  run_ = e.id().run();
1766  evt_ = e.id().event();
1767 
1768  if ( prescaleFactor_ > 0 ) {
1769  if ( jevt_ % prescaleFactor_ == 0 ){
1770  this->analyze();
1771  }
1772  }
1773 
1774 }
1775 
1777 
1778  std::vector<MonitorElement*> mes = dqmStore_->getAllContents(prefixME_);
1779  std::vector<MonitorElement*>::const_iterator meitr;
1780  for ( meitr=mes.begin(); meitr!=mes.end(); meitr++ ) {
1781  if ( !strncmp((*meitr)->getName().c_str(), "EE", 2)
1782  && strncmp((*meitr)->getName().c_str(), "EETrend", 7)
1783  && strncmp((*meitr)->getName().c_str(), "by lumi", 7) ) {
1784  if ( flag ) {
1785  dqmStore_->softReset(*meitr);
1786  } else {
1787  dqmStore_->disableSoftReset(*meitr);
1788  }
1789  }
1790  }
1791 
1792  MonitorElement* me = dqmStore_->get(prefixME_ + "/EcalInfo/EVTTYPE");
1793  if ( me ) {
1794  if ( flag ) {
1795  dqmStore_->softReset(me);
1796  } else {
1798  }
1799  }
1800 
1801 }
1802 
RunNumber_t run() const
Definition: EventID.h:42
void beginJob(void)
BeginJob.
LuminosityBlockID id() const
Cache logicID vector from database.
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
static std::string sEE(const unsigned ism)
Definition: Numbers.cc:226
int i
Definition: DBlmapReader.cc:9
void setTaskList(int list)
Definition: MonRunDat.h:30
void setNumEvents(int num)
Definition: MonRunDat.h:21
void setBinContent(int binx, double content)
set content of bin (1-D)
long int flag
Definition: mlp_lapack.h:47
void setLocationDef(const LocationDef locDef)
Definition: RunTag.cc:53
RunID const & id() const
Definition: RunBase.h:41
void insertRunIOV(RunIOV *iov)
virtual ~EcalEndcapMonitorClient()
Destructor.
std::vector< std::string > runTypes_
RunNumber_t run() const
Definition: RunID.h:44
void analyze(void)
Analyze.
Some &quot;id&quot; conversions.
Definition: RunTag.h:13
RunIOV fetchRunIOV(RunTag *tag, run_t run)
#define NULL
Definition: scimark2.h:8
void setFriends(const std::vector< EEClient * > &clients)
Set Clients.
std::map< std::string, int > clientsStatus_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
void setToCurrentGMTime()
Definition: Tm.cc:177
void setGeneralTag(std::string tag)
Definition: MonRunTag.cc:33
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:654
void setShortDesc(std::string desc)
std::vector< MonitorElement * > getAllContents(const std::string &path) const
Definition: DQMStore.cc:1672
void Fill(long long x)
void disableSoftReset(MonitorElement *me)
Definition: DQMStore.cc:2742
EcalEndcapMonitorClient(const edm::ParameterSet &ps)
Constructor.
std::vector< std::string > clientsNames_
void beginRunDb(void)
BeginRunDB.
void beginRun(void)
BeginRun.
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov)
void setRunTypeDef(const RunTypeDef runTypeDef)
Definition: RunTag.cc:70
void removeElement(const std::string &name)
Definition: DQMStore.cc:2572
channel masking
void setNumEvents(int num)
Definition: RunDat.h:20
RunNumber_t run() const
int j
Definition: DBlmapReader.cc:9
void softReset(MonitorElement *me)
Definition: DQMStore.cc:2734
void setMonVersionDef(MonVersionDef ver)
Definition: MonRunTag.cc:49
void setTaskOutcome(int outcome)
Definition: MonRunDat.h:33
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1468
static void initMasking(const edm::EventSetup &setup, bool verbose=false)
Definition: Masks.cc:34
void endRun(void)
EndRun.
void beginLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &c)
BeginLumiBlock.
std::string valueString(void) const
void softReset(bool flag)
SoftReset.
bool dirExists(const std::string &path) const
true if directory exists
Definition: DQMStore.cc:493
Ecal Monitor Utils for Client.
void setMonRunOutcomeDef(MonRunOutcomeDef outcomeDef)
Definition: MonRunDat.h:24
std::vector< EEClient * > clients_
std::vector< std::string > enabledClients_
static void initGeometry(const edm::EventSetup &setup, bool verbose=false)
Definition: Numbers.cc:50
void setRunType(std::string runtype)
Definition: RunTypeDef.cc:33
std::multimap< EEClient *, int > clientsRuns_
tuple dataset
Definition: dataset.py:393
LuminosityBlockNumber_t luminosityBlock() const
MonRunIOV fetchMonRunIOV(RunTag *runtag, MonRunTag *montag, run_t run, subrun_t monrun)
Definition: RunDat.h:11
void setMonitoringVersion(std::string ver)
edm::EventID id() const
Definition: EventBase.h:56
void insertMonRunIOV(MonRunIOV *iov)
#define update(a, b)
bool open(const std::string &filename, bool overwrite=false, const std::string &path="", const std::string &prepend="", OpenRunDirs stripdirs=KeepRunDirs, bool fileMustExist=true)
Definition: DQMStore.cc:2432
void setLocation(std::string loc)
Definition: LocationDef.cc:33
tuple cout
Definition: gather_cfg.py:121
void insertDataSet(const std::map< EcalLogicID, DATT > *data, IOVT *iov)
tuple status
Definition: ntuplemaker.py:245
void setGeneralTag(std::string tag)
Definition: RunTag.cc:36
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:845
static EcalLogicID getEcalLogicID(const char *name, const int id1=EcalLogicID::NULLID, const int id2=EcalLogicID::NULLID, const int id3=EcalLogicID::NULLID)
Definition: LogicID.h:31
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Definition: Tm.h:14
void endLuminosityBlock(const edm::LuminosityBlock &l, const edm::EventSetup &c)
EndLumiBlock.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33
void endJob(void)
EndJob.