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