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: 2013/04/02 09:03:29 $
5  * $Revision: 1.274 $
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(begin_run_ && !end_run_){
947  unsigned iC(0);
948  for(; iC < enabledClients_.size(); iC++){
950 
951  if(name == "Cluster" || name == "Cosmic" || name == "Occupancy" || name == "StatusFlags" || name == "Trend") continue;
952 
953  std::string dir(prefixME_ + "/EE" + name + "Client");
955  std::vector<std::string>::iterator itr(std::find(clientsNames_.begin(), clientsNames_.end(), name));
956  if(itr == clientsNames_.end()) continue; // something seriously wrong, but ignore
957  std::cout << "EE" << name << "Client is missing plots; issuing beginRun" << std::endl;
958 
959  break;
960  }
961  }
962  if(iC != enabledClients_.size()){
963  forced_status_ = false;
964  endRun();
965  beginRun();
966  run_ = l.id().run();
967  evt_ = 0;
968  }
969  }
970 
971  if ( updateTime_ > 0 ) {
972  if ( (current_time_ - last_time_update_) < 60 * updateTime_ ) {
973  return;
974  }
976  }
977 
978  if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
979 
980  forced_update_ = true;
981 
982  this->analyze();
983 
984  }
985 }
986 
988 
989 }
990 
992 
993 }
994 
996 
997  if ( ! enableCleanup_ ) return;
998 
999  if ( cloneME_ ) {
1000  if ( h_ ) delete h_;
1001  }
1002 
1003  h_ = 0;
1004 
1005 }
1006 
1008 
1009  subrun_ = 0;
1010 
1011 #ifdef WITH_ECAL_COND_DB
1012  EcalCondDBInterface* econn;
1013 
1014  econn = 0;
1015 
1016  if ( dbName_.size() != 0 ) {
1017  try {
1018  if ( verbose_ ) std::cout << "Opening DB connection with TNS_ADMIN ..." << std::endl;
1020  if ( verbose_ ) std::cout << "done." << std::endl;
1021  } catch (std::runtime_error &e) {
1022  std::cerr << e.what() << std::endl;
1023  if ( dbHostName_.size() != 0 ) {
1024  try {
1025  if ( verbose_ ) std::cout << "Opening DB connection without TNS_ADMIN ..." << std::endl;
1027  if ( verbose_ ) std::cout << "done." << std::endl;
1028  } catch (std::runtime_error &e) {
1029  std::cerr << e.what() << std::endl;
1030  }
1031  }
1032  }
1033  }
1034 
1035  // create the objects necessary to identify a dataset
1036 
1037  LocationDef locdef;
1038 
1039  locdef.setLocation(location_);
1040 
1041  RunTypeDef rundef;
1042 
1043  rundef.setRunType( this->getRunType() );
1044 
1045  RunTag runtag;
1046 
1047  runtag.setLocationDef(locdef);
1048  runtag.setRunTypeDef(rundef);
1049 
1050  runtag.setGeneralTag( this->getRunType() );
1051 
1052  // fetch the RunIOV from the DB
1053 
1054  bool foundRunIOV = false;
1055 
1056  if ( econn ) {
1057  try {
1058  if ( verbose_ ) std::cout << "Fetching RunIOV ..." << std::endl;
1059 // runiov_ = econn->fetchRunIOV(&runtag, run_);
1060  runiov_ = econn->fetchRunIOV(location_, run_);
1061  if ( verbose_ ) std::cout << "done." << std::endl;
1062  foundRunIOV = true;
1063  } catch (std::runtime_error &e) {
1064  std::cerr << e.what() << std::endl;
1065  foundRunIOV = false;
1066  }
1067  }
1068 
1069  // begin - setup the RunIOV (on behalf of the DAQ)
1070 
1071  if ( ! foundRunIOV ) {
1072 
1073  Tm startRun;
1074 
1075  startRun.setToCurrentGMTime();
1076 
1077  runiov_.setRunNumber(run_);
1078  runiov_.setRunStart(startRun);
1079  runiov_.setRunTag(runtag);
1080 
1081  if ( econn ) {
1082  try {
1083  if ( verbose_ ) std::cout << "Inserting RunIOV ..." << std::endl;
1084  econn->insertRunIOV(&runiov_);
1085 // runiov_ = econn->fetchRunIOV(&runtag, run_);
1086  runiov_ = econn->fetchRunIOV(location_, run_);
1087  if ( verbose_ ) std::cout << "done." << std::endl;
1088  } catch (std::runtime_error &e) {
1089  std::cerr << e.what() << std::endl;
1090  try {
1091  if ( verbose_ ) std::cout << "Fetching RunIOV (again) ..." << std::endl;
1092 // runiov_ = econn->fetchRunIOV(&runtag, run_);
1093  runiov_ = econn->fetchRunIOV(location_, run_);
1094  if ( verbose_ ) std::cout << "done." << std::endl;
1095  foundRunIOV = true;
1096  } catch (std::runtime_error &e) {
1097  std::cerr << e.what() << std::endl;
1098  foundRunIOV = false;
1099  }
1100  }
1101  }
1102 
1103  }
1104 
1105  // end - setup the RunIOV (on behalf of the DAQ)
1106 
1107  if ( verbose_ ) {
1108  std::cout << std::endl;
1109  std::cout << "=============RunIOV:" << std::endl;
1110  std::cout << "Run Number: " << runiov_.getRunNumber() << std::endl;
1111  std::cout << "Run Start: " << runiov_.getRunStart().str() << std::endl;
1112  std::cout << "Run End: " << runiov_.getRunEnd().str() << std::endl;
1113  std::cout << "====================" << std::endl;
1114  std::cout << std::endl;
1115  std::cout << "=============RunTag:" << std::endl;
1116  std::cout << "GeneralTag: " << runiov_.getRunTag().getGeneralTag() << std::endl;
1117  std::cout << "Location: " << runiov_.getRunTag().getLocationDef().getLocation() << std::endl;
1118  std::cout << "Run Type: " << runiov_.getRunTag().getRunTypeDef().getRunType() << std::endl;
1119  std::cout << "====================" << std::endl;
1120  std::cout << std::endl;
1121  }
1122 
1123  std::string rt = runiov_.getRunTag().getRunTypeDef().getRunType();
1124  if ( strcmp(rt.c_str(), "UNKNOWN") == 0 ) {
1125  runType_ = -1;
1126  } else {
1127  for ( unsigned int i = 0; i < runTypes_.size(); i++ ) {
1128  if ( strcmp(rt.c_str(), runTypes_[i].c_str()) == 0 ) {
1129  if ( runType_ != int(i) ) {
1130  if ( verbose_ ) {
1131  std::cout << std::endl;
1132  std::cout << "Fixing Run Type to: " << runTypes_[i] << std::endl;
1133  std::cout << std::endl;
1134  }
1135  runType_ = i;
1136  }
1137  break;
1138  }
1139  }
1140  }
1141 
1142  if ( verbose_ ) std::cout << std::endl;
1143 
1144  if ( econn ) {
1145  try {
1146  if ( verbose_ ) std::cout << "Closing DB connection ..." << std::endl;
1147  delete econn;
1148  econn = 0;
1149  if ( verbose_ ) std::cout << "done." << std::endl;
1150  } catch (std::runtime_error &e) {
1151  std::cerr << e.what() << std::endl;
1152  }
1153  }
1154 #endif
1155 
1156  if ( verbose_ ) std::cout << std::endl;
1157 
1158 }
1159 
1161 
1162  subrun_++;
1163 
1164 #ifdef WITH_ECAL_COND_DB
1165  EcalCondDBInterface* econn;
1166 
1167  econn = 0;
1168 
1169  if ( dbName_.size() != 0 ) {
1170  try {
1171  if ( verbose_ ) std::cout << "Opening DB connection with TNS_ADMIN ..." << std::endl;
1173  if ( verbose_ ) std::cout << "done." << std::endl;
1174  } catch (std::runtime_error &e) {
1175  std::cerr << e.what() << std::endl;
1176  if ( dbHostName_.size() != 0 ) {
1177  try {
1178  if ( verbose_ ) std::cout << "Opening DB connection without TNS_ADMIN ..." << std::endl;
1180  if ( verbose_ ) std::cout << "done." << std::endl;
1181  } catch (std::runtime_error &e) {
1182  std::cerr << e.what() << std::endl;
1183  }
1184  }
1185  }
1186  }
1187 
1188  MonVersionDef monverdef;
1189 
1190  monverdef.setMonitoringVersion("test01");
1191 
1192  MonRunTag montag;
1193 
1194  montag.setMonVersionDef(monverdef);
1195  montag.setGeneralTag(dbTagName_);
1196 
1197  Tm startSubRun;
1198 
1199  startSubRun.setToCurrentGMTime();
1200 
1201  // fetch the MonIOV from the DB
1202 
1203  bool foundMonIOV = false;
1204 
1205  if ( econn ) {
1206  try {
1207  if ( verbose_ ) std::cout << "Fetching MonIOV ..." << std::endl;
1208  RunTag runtag = runiov_.getRunTag();
1209  moniov_ = econn->fetchMonRunIOV(&runtag, &montag, run_, subrun_);
1210  if ( verbose_ ) std::cout << "done." << std::endl;
1211  foundMonIOV = true;
1212  } catch (std::runtime_error &e) {
1213  std::cerr << e.what() << std::endl;
1214  foundMonIOV = false;
1215  }
1216  }
1217 
1218  // begin - setup the MonIOV
1219 
1220  if ( !foundMonIOV ) {
1221 
1222  moniov_.setRunIOV(runiov_);
1223  moniov_.setSubRunNumber(subrun_);
1224 
1225  if ( subrun_ > 1 ) {
1226  moniov_.setSubRunStart(startSubRun);
1227  } else {
1228  moniov_.setSubRunStart(runiov_.getRunStart());
1229  }
1230 
1231  moniov_.setMonRunTag(montag);
1232 
1233  if ( econn ) {
1234  try {
1235  if ( verbose_ ) std::cout << "Inserting MonIOV ..." << std::endl;
1236  econn->insertMonRunIOV(&moniov_);
1237  RunTag runtag = runiov_.getRunTag();
1238  moniov_ = econn->fetchMonRunIOV(&runtag, &montag, run_, subrun_);
1239  if ( verbose_ ) std::cout << "done." << std::endl;
1240  } catch (std::runtime_error &e) {
1241  std::cerr << e.what() << std::endl;
1242  try {
1243  if ( verbose_ ) std::cout << "Fetching MonIOV (again) ..." << std::endl;
1244  RunTag runtag = runiov_.getRunTag();
1245  moniov_ = econn->fetchMonRunIOV(&runtag, &montag, run_, subrun_);
1246  if ( verbose_ ) std::cout << "done." << std::endl;
1247  foundMonIOV = true;
1248  } catch (std::runtime_error &e) {
1249  std::cerr << e.what() << std::endl;
1250  foundMonIOV = false;
1251  }
1252  }
1253  }
1254 
1255  }
1256 
1257  // end - setup the MonIOV
1258 
1259  if ( verbose_ ) {
1260  std::cout << std::endl;
1261  std::cout << "==========MonRunIOV:" << std::endl;
1262  std::cout << "SubRun Number: " << moniov_.getSubRunNumber() << std::endl;
1263  std::cout << "SubRun Start: " << moniov_.getSubRunStart().str() << std::endl;
1264  std::cout << "SubRun End: " << moniov_.getSubRunEnd().str() << std::endl;
1265  std::cout << "====================" << std::endl;
1266  std::cout << std::endl;
1267  std::cout << "==========MonRunTag:" << std::endl;
1268  std::cout << "GeneralTag: " << moniov_.getMonRunTag().getGeneralTag() << std::endl;
1269  std::cout << "Monitoring Ver: " << moniov_.getMonRunTag().getMonVersionDef().getMonitoringVersion() << std::endl;
1270  std::cout << "====================" << std::endl;
1271  std::cout << std::endl;
1272  }
1273 
1274  int taskl = 0x0;
1275  int tasko = 0x0;
1276 
1277  for ( int i=0; i<int(clients_.size()); i++ ) {
1278  bool done = false;
1279  for ( std::multimap<EEClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
1280  if ( h_ && runType_ != -1 && runType_ == (*j).second && !done ) {
1282  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;
1283  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;
1284  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;
1285  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;
1286  done = true;
1287  if ( verbose_ ) {
1288  if ( econn ) {
1289  std::cout << " Writing " << clientsNames_[i] << " results to DB " << std::endl;
1290  std::cout << std::endl;
1291  }
1292  }
1293  bool status;
1294  if ( clients_[i]->writeDb(econn, &runiov_, &moniov_, status) ) {
1295  taskl |= 0x1 << clientsStatus_[clientsNames_[i]];
1296  if ( status ) {
1297  tasko |= 0x1 << clientsStatus_[clientsNames_[i]];
1298  }
1299  } else {
1300  tasko |= 0x1 << clientsStatus_[clientsNames_[i]];
1301  }
1302  }
1303  }
1304  if ( ((taskl >> clientsStatus_[clientsNames_[i]]) & 0x1) ) {
1305  if ( verbose_ ) {
1306  std::cout << " Task output for " << clientsNames_[i] << " = "
1307  << ((tasko >> clientsStatus_[clientsNames_[i]]) & 0x1) << std::endl;
1308  std::cout << std::endl;
1309  }
1310  }
1311  }
1312 
1313  bool status;
1314  if ( summaryClient_ ) summaryClient_->writeDb(econn, &runiov_, &moniov_, status);
1315 
1316  EcalLogicID ecid;
1317  MonRunDat md;
1318  std::map<EcalLogicID, MonRunDat> dataset;
1319 
1320  MonRunOutcomeDef monRunOutcomeDef;
1321 
1322  monRunOutcomeDef.setShortDesc("success");
1323 
1324  float nevt = -1.;
1325 
1326  if ( h_ ) nevt = h_->GetSumOfWeights();
1327 
1328  md.setNumEvents(int(nevt));
1329  md.setMonRunOutcomeDef(monRunOutcomeDef);
1330 
1331 // string fileName = "";
1332 // md.setRootfileName(fileName);
1333 
1334  md.setTaskList(taskl);
1335  md.setTaskOutcome(tasko);
1336 
1337  if ( econn ) {
1338  try {
1339  ecid = LogicID::getEcalLogicID("EE");
1340  dataset[ecid] = md;
1341  } catch (std::runtime_error &e) {
1342  std::cerr << e.what() << std::endl;
1343  }
1344  }
1345 
1346  if ( econn ) {
1347  try {
1348  if ( verbose_ ) std::cout << "Inserting MonRunDat ..." << std::endl;
1349  econn->insertDataSet(&dataset, &moniov_);
1350  if ( verbose_ ) std::cout << "done." << std::endl;
1351  } catch (std::runtime_error &e) {
1352  std::cerr << e.what() << std::endl;
1353  }
1354  }
1355 
1356  if ( econn ) {
1357  try {
1358  if ( verbose_ ) std::cout << "Closing DB connection ..." << std::endl;
1359  delete econn;
1360  econn = 0;
1361  if ( verbose_ ) std::cout << "done." << std::endl;
1362  } catch (std::runtime_error &e) {
1363  std::cerr << e.what() << std::endl;
1364  }
1365  }
1366 #endif
1367 
1368  if ( verbose_ ) std::cout << std::endl;
1369 
1370 }
1371 
1373 
1374 #ifdef WITH_ECAL_COND_DB
1375  EcalCondDBInterface* econn;
1376 
1377  econn = 0;
1378 
1379  if ( dbName_.size() != 0 ) {
1380  try {
1381  if ( verbose_ ) std::cout << "Opening DB connection with TNS_ADMIN ..." << std::endl;
1383  if ( verbose_ ) std::cout << "done." << std::endl;
1384  } catch (std::runtime_error &e) {
1385  std::cerr << e.what() << std::endl;
1386  if ( dbHostName_.size() != 0 ) {
1387  try {
1388  if ( verbose_ ) std::cout << "Opening DB connection without TNS_ADMIN ..." << std::endl;
1390  if ( verbose_ ) std::cout << "done." << std::endl;
1391  } catch (std::runtime_error &e) {
1392  std::cerr << e.what() << std::endl;
1393  }
1394  }
1395  }
1396  }
1397 
1398  EcalLogicID ecid;
1399  RunDat rd;
1400  std::map<EcalLogicID, RunDat> dataset;
1401 
1402  float nevt = -1.;
1403 
1404  if ( h_ ) nevt = h_->GetSumOfWeights();
1405 
1406  rd.setNumEvents(int(nevt));
1407 
1408  // fetch the RunDat from the DB
1409 
1410  bool foundRunDat = false;
1411 
1412  if ( econn ) {
1413  try {
1414  if ( verbose_ ) std::cout << "Fetching RunDat ..." << std::endl;
1415  econn->fetchDataSet(&dataset, &runiov_);
1416  if ( verbose_ ) std::cout << "done." << std::endl;
1417  foundRunDat = true;
1418  } catch (std::runtime_error &e) {
1419  std::cerr << e.what() << std::endl;
1420  foundRunDat = false;
1421  }
1422  }
1423 
1424  // begin - setup the RunDat (on behalf of the DAQ)
1425 
1426  if ( ! foundRunDat ) {
1427 
1428  if ( econn ) {
1429  try {
1430  ecid = LogicID::getEcalLogicID("EE");
1431  dataset[ecid] = rd;
1432  } catch (std::runtime_error &e) {
1433  std::cerr << e.what() << std::endl;
1434  }
1435  }
1436 
1437  if ( econn ) {
1438  try {
1439  if ( verbose_ ) std::cout << "Inserting RunDat ..." << std::endl;
1440  econn->insertDataSet(&dataset, &runiov_);
1441  if ( verbose_ ) std::cout << "done." << std::endl;
1442  } catch (std::runtime_error &e) {
1443  std::cerr << e.what() << std::endl;
1444  }
1445  }
1446 
1447  }
1448 
1449  // end - setup the RunDat (on behalf of the DAQ)
1450 
1451  if ( econn ) {
1452  try {
1453  if ( verbose_ ) std::cout << "Closing DB connection ..." << std::endl;
1454  delete econn;
1455  econn = 0;
1456  if ( verbose_ ) std::cout << "done." << std::endl;
1457  } catch (std::runtime_error &e) {
1458  std::cerr << e.what() << std::endl;
1459  }
1460  }
1461 #endif
1462 
1463 }
1464 
1466 
1467  current_time_ = time(NULL);
1468 
1469  ievt_++;
1470  jevt_++;
1471 
1472  if ( debug_ ) std::cout << "EcalEndcapMonitorClient: ievt/jevt = " << ievt_ << "/" << jevt_ << std::endl;
1473 
1474  MonitorElement* me;
1475  std::string s;
1476 
1477  me = dqmStore_->get(prefixME_ + "/EcalInfo/STATUS");
1478  if ( me ) {
1479  status_ = "unknown";
1480  s = me->valueString();
1481  if ( strcmp(s.c_str(), "i=0") == 0 ) status_ = "begin-of-run";
1482  if ( strcmp(s.c_str(), "i=1") == 0 ) status_ = "running";
1483  if ( strcmp(s.c_str(), "i=2") == 0 ) status_ = "end-of-run";
1484  if ( debug_ ) std::cout << "Found '" << prefixME_ << "/EcalInfo/STATUS'" << std::endl;
1485  }
1486 
1487  if ( inputFile_.size() != 0 ) {
1488  if ( ievt_ == 1 ) {
1489  if ( verbose_ ) {
1490  std::cout << std::endl;
1491  std::cout << " Reading DQM from file, forcing 'begin-of-run'" << std::endl;
1492  std::cout << std::endl;
1493  }
1494  status_ = "begin-of-run";
1495  }
1496  }
1497 
1498  int ecal_run = -1;
1499  me = dqmStore_->get(prefixME_ + "/EcalInfo/RUN");
1500  if ( me ) {
1501  s = me->valueString();
1502  sscanf(s.c_str(), "i=%d", &ecal_run);
1503  if ( debug_ ) std::cout << "Found '" << prefixME_ << "/EcalInfo/RUN'" << std::endl;
1504  }
1505 
1506  int ecal_evt = -1;
1507  me = dqmStore_->get(prefixME_ + "/EcalInfo/EVT");
1508  if ( me ) {
1509  s = me->valueString();
1510  sscanf(s.c_str(), "i=%d", &ecal_evt);
1511  if ( debug_ ) std::cout << "Found '" << prefixME_ << "/EcalInfo/EVT'" << std::endl;
1512  }
1513 
1514  me = dqmStore_->get(prefixME_ + "/EcalInfo/EVTTYPE");
1515  h_ = UtilsClient::getHisto<TH1F*>( me, cloneME_, h_ );
1516 
1517  me = dqmStore_->get(prefixME_ + "/EcalInfo/RUNTYPE");
1518  if ( me ) {
1519  s = me->valueString();
1520  sscanf(s.c_str(), "i=%d", &evtType_);
1521  if ( runType_ == -1 ) runType_ = evtType_;
1522  if ( debug_ ) std::cout << "Found '" << prefixME_ << "/EcalInfo/RUNTYPE' " << s << std::endl;
1523  }
1524 
1525  // if the run number from the Event is less than zero,
1526  // use the run number from the ECAL DCC header
1527  if ( run_ <= 0 ) run_ = ecal_run;
1528 
1529  if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
1530  if ( ! mergeRuns_ && run_ != last_run_ ) forced_update_ = true;
1531  }
1532 
1533  bool update = ( forced_update_ ) ||
1534  ( prescaleFactor_ != 1 ) ||
1535  ( jevt_ < 10 ) ||
1536  ( jevt_ < 100 && jevt_ % 10 == 0 ) ||
1537  ( jevt_ < 1000 && jevt_ % 100 == 0 ) ||
1538  ( jevt_ % 1000 == 0 );
1539 
1540  if ( update || strcmp(status_.c_str(), "begin-of-run") == 0 || strcmp(status_.c_str(), "end-of-run") == 0 ) {
1541 
1542  if ( verbose_ ) {
1543  std::cout << " RUN status = \"" << status_ << "\"" << std::endl;
1544  std::cout << " CMS run/event number = " << run_ << "/" << evt_ << std::endl;
1545  std::cout << " EE run/event number = " << ecal_run << "/" << ecal_evt << std::endl;
1546  std::cout << " EE location = " << location_ << std::endl;
1547  std::cout << " EE run/event type = " << this->getRunType() << "/" << ( evtType_ == -1 ? "UNKNOWN" : runTypes_[evtType_] ) << std::flush;
1548 
1549  if ( h_ ) {
1550  if ( h_->GetSumOfWeights() != 0 ) {
1551  std::cout << " ( " << std::flush;
1552  for ( unsigned int i = 0; i < runTypes_.size(); i++ ) {
1553  if ( strcmp(runTypes_[i].c_str(), "UNKNOWN") != 0 && h_->GetBinContent(2+i) != 0 ) {
1554  std::string s = runTypes_[i];
1555  transform( s.begin(), s.end(), s.begin(), (int(*)(int))tolower );
1556  std::cout << s << " ";
1557  }
1558  }
1559  std::cout << ")" << std::flush;
1560  }
1561  }
1562  std::cout << std::endl;
1563  }
1564 
1565  }
1566 
1567  if ( strcmp(status_.c_str(), "begin-of-run") == 0 ) {
1568 
1569  if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
1570 
1571  if ( ! begin_run_ ) {
1572 
1573  forced_status_ = false;
1574  this->beginRun();
1575 
1576  }
1577 
1578  }
1579 
1580  }
1581 
1582  if ( strcmp(status_.c_str(), "begin-of-run") == 0 || strcmp(status_.c_str(), "running") == 0 || strcmp(status_.c_str(), "end-of-run") == 0 ) {
1583 
1584  if ( begin_run_ && ! end_run_ ) {
1585 
1586  bool update = ( forced_update_ ) ||
1587  ( prescaleFactor_ != 1 ) ||
1588  ( jevt_ < 3 ) ||
1589  ( jevt_ < 1000 && jevt_ % 100 == 0 ) ||
1590  ( jevt_ < 10000 && jevt_ % 1000 == 0 ) ||
1591  ( jevt_ % 10000 == 0 );
1592 
1593  if ( update || strcmp(status_.c_str(), "begin-of-run") == 0 || strcmp(status_.c_str(), "end-of-run") == 0 ) {
1594 
1595  for ( int i=0; i<int(clients_.size()); i++ ) {
1596  bool done = false;
1597  for ( std::multimap<EEClient*,int>::iterator j = clientsRuns_.lower_bound(clients_[i]); j != clientsRuns_.upper_bound(clients_[i]); j++ ) {
1598  if ( runType_ != -1 && runType_ == (*j).second && !done ) {
1599  done = true;
1600  clients_[i]->analyze();
1601  }
1602  }
1603  }
1604 
1606 
1607  }
1608 
1609  forced_update_ = false;
1610 
1611  bool reset = false;
1612 
1613  if ( resetFile_.size() != 0 ) {
1614  if ( access(resetFile_.c_str(), W_OK) == 0 ) {
1615  if ( unlink(resetFile_.c_str()) == 0 ) {
1616  reset |= true;
1617  }
1618  }
1619  }
1620 
1621  if ( dbUpdateTime_ > 0 ) {
1622  reset |= (current_time_ - last_time_reset_) > 60 * dbUpdateTime_;
1623  }
1624 
1625  if ( reset ) {
1633  this->softReset(true);
1635  }
1636 
1637  }
1638 
1639  }
1640 
1641  if ( strcmp(status_.c_str(), "end-of-run") == 0 ) {
1642 
1643  if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
1644 
1645  if ( begin_run_ && ! end_run_ ) {
1646 
1647  forced_status_ = false;
1648  this->endRun();
1649 
1650  }
1651 
1652  }
1653 
1654  }
1655 
1656  // BEGIN: run-time fixes for missing state transitions
1657 
1658  // run number transition
1659 
1660  if ( strcmp(status_.c_str(), "running") == 0 ) {
1661 
1662  if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
1663 
1664  if ( ! mergeRuns_ ) {
1665 
1666  int new_run_ = run_;
1667  int old_run_ = last_run_;
1668 
1669  if ( new_run_ != old_run_ ) {
1670 
1671  if ( begin_run_ && ! end_run_ ) {
1672 
1673  if ( verbose_ ) {
1674  std::cout << std::endl;
1675  std::cout << " Old run has finished, issuing endRun() ... " << std::endl;
1676  std::cout << std::endl;
1677  }
1678 
1679  // end old_run_
1680  run_ = old_run_;
1681 
1682  forced_status_ = false;
1683  this->endRun();
1684 
1685  }
1686 
1687  if ( ! begin_run_ ) {
1688 
1689  if ( verbose_ ) {
1690  std::cout << std::endl;
1691  std::cout << " New run has started, issuing beginRun() ... " << std::endl;
1692  std::cout << std::endl;
1693  }
1694 
1695  // start new_run_
1696  run_ = new_run_;
1697 
1698  forced_status_ = false;
1699  this->beginRun();
1700 
1701  }
1702 
1703  }
1704 
1705  }
1706 
1707  }
1708 
1709  }
1710 
1711  // 'running' state without a previous 'begin-of-run' state
1712 
1713  if ( strcmp(status_.c_str(), "running") == 0 ) {
1714 
1715  if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
1716 
1717  if ( ! forced_status_ ) {
1718 
1719  if ( ! begin_run_ ) {
1720 
1721  if ( verbose_ ) {
1722  std::cout << std::endl;
1723  std::cout << "Forcing beginRun() ... NOW !" << std::endl;
1724  std::cout << std::endl;
1725  }
1726 
1727  forced_status_ = true;
1728  this->beginRun();
1729 
1730  }
1731 
1732  }
1733 
1734  }
1735 
1736  }
1737 
1738  // 'end-of-run' state without a previous 'begin-of-run' or 'running' state
1739 
1740  if ( strcmp(status_.c_str(), "end-of-run") == 0 ) {
1741 
1742  if ( run_ != -1 && evt_ != -1 && runType_ != -1 ) {
1743 
1744  if ( ! forced_status_ ) {
1745 
1746  if ( ! begin_run_ ) {
1747 
1748  if ( verbose_ ) {
1749  std::cout << std::endl;
1750  std::cout << "Forcing beginRun() ... NOW !" << std::endl;
1751  std::cout << std::endl;
1752  }
1753 
1754  forced_status_ = true;
1755  this->beginRun();
1756 
1757  }
1758 
1759  }
1760 
1761  }
1762 
1763  }
1764 
1765  // END: run-time fixes for missing state transitions
1766 
1767 }
1768 
1770 
1771  run_ = e.id().run();
1772  evt_ = e.id().event();
1773 
1774  if ( prescaleFactor_ > 0 ) {
1775  if ( jevt_ % prescaleFactor_ == 0 ){
1776  this->analyze();
1777  }
1778  }
1779 
1780 }
1781 
1783 
1784  std::vector<MonitorElement*> mes = dqmStore_->getAllContents(prefixME_);
1785  std::vector<MonitorElement*>::const_iterator meitr;
1786  for ( meitr=mes.begin(); meitr!=mes.end(); meitr++ ) {
1787  if ( !strncmp((*meitr)->getName().c_str(), "EE", 2)
1788  && strncmp((*meitr)->getName().c_str(), "EETrend", 7)
1789  && strncmp((*meitr)->getName().c_str(), "by lumi", 7) ) {
1790  if ( flag ) {
1791  dqmStore_->softReset(*meitr);
1792  } else {
1793  dqmStore_->disableSoftReset(*meitr);
1794  }
1795  }
1796  }
1797 
1798  MonitorElement* me = dqmStore_->get(prefixME_ + "/EcalInfo/EVTTYPE");
1799  if ( me ) {
1800  if ( flag ) {
1801  dqmStore_->softReset(me);
1802  } else {
1804  }
1805  }
1806 
1807 }
1808 
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
bool containsAnyMonitorable(const std::string &path) const
Definition: DQMStore.cc:1463
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:659
void setShortDesc(std::string desc)
std::vector< MonitorElement * > getAllContents(const std::string &path) const
Definition: DQMStore.cc:1677
void Fill(long long x)
void disableSoftReset(MonitorElement *me)
Definition: DQMStore.cc:2747
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:2577
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:2739
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:1473
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:498
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:2437
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)
dbl *** dir
Definition: mlp_gen.cc:35
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:850
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:434
Definition: Run.h:36
void endJob(void)
EndJob.