CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes
DQMFileSaver Class Reference

#include <DQMFileSaver.h>

Inheritance diagram for DQMFileSaver:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 DQMFileSaver (const edm::ParameterSet &ps)
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Member Functions

virtual void analyze (const edm::Event &e, const edm::EventSetup &)
 
virtual void beginJob (void)
 
virtual void beginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &)
 
virtual void beginRun (const edm::Run &, const edm::EventSetup &)
 
virtual void endJob (void)
 
virtual void endLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &)
 
virtual void endRun (const edm::Run &, const edm::EventSetup &)
 
virtual void postForkReacquireResources (unsigned int childIndex, unsigned int numberOfChildren)
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Private Types

enum  Convention { Online, Offline }
 

Private Member Functions

void saveForOffline (const std::string &workflow, int run, int lumi)
 
void saveForOnline (const std::string &suffix, const std::string &rewrite)
 
void saveJobReport (const std::string &filename)
 

Private Attributes

std::string child_
 
Convention convention_
 
DQMStoredbe_
 
std::string dirName_
 
std::string fileBaseName_
 
std::string fileUpdate_
 
MonitorElementfileVersion_
 
int forceRunNumber_
 
MonitorElementhostName_
 
int ievent_
 
int ilumi_
 
int ilumiprev_
 
int irun_
 
MonitorElementisComplete_
 The PID associated with this job. More...
 
int nevent_
 
int nlumi_
 
int nrun_
 
int numKeepSavedFiles_
 
std::list< std::string > pastSavedFiles_
 
MonitorElementprocessId_
 Current working directory of the job. More...
 
MonitorElementprocessName_
 Hostname of the local machine. More...
 
std::string producer_
 
bool runIsComplete_
 
bool saveAtJobEnd_
 
int saveByEvent_
 
int saveByLumiSection_
 
int saveByMinute_
 
int saveByRun_
 
int saveByTime_
 
timeval saved_
 
int saveReference_
 
int saveReferenceQMin_
 
timeval start_
 
MonitorElementversCMSSW_
 
MonitorElementversDataset_
 
MonitorElementversGlobaltag_
 
int version_
 
MonitorElementversTaglist_
 
std::string workflow_
 
MonitorElementworkingDir_
 DQM "name" of the job (eg, Hcal or DT) More...
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

Definition at line 10 of file DQMFileSaver.h.

Member Enumeration Documentation

Enumerator
Online 
Offline 

Definition at line 30 of file DQMFileSaver.h.

Constructor & Destructor Documentation

DQMFileSaver::DQMFileSaver ( const edm::ParameterSet ps)

Definition at line 202 of file DQMFileSaver.cc.

References convention_, prof2calltree::count, dirName_, edm::hlt::Exception, fileBaseName_, forceRunNumber_, getAnInt(), edm::ParameterSet::getUntrackedParameter(), numKeepSavedFiles_, Offline, Online, producer_, runIsComplete_, alignCSCRings::s, saveAtJobEnd_, saveByEvent_, saveByLumiSection_, saveByMinute_, saveByRun_, saveByTime_, saved_, saveReference_, saveReferenceQMin_, DQMStore::SaveWithoutReference, DQMStore::SaveWithReference, DQMStore::SaveWithReferenceForQTest, start_, AlCaHLTBitMon_QueryRunRegistry::string, BeamSplash_cfg::version, version_, and workflow_.

203  : convention_ (Offline),
204  workflow_ (""),
205  producer_ ("DQM"),
206  dirName_ ("."),
207  child_ (""),
208  version_ (1),
209  runIsComplete_ (false),
210  saveByLumiSection_ (-1),
211  saveByEvent_ (-1),
212  saveByMinute_ (-1),
213  saveByTime_ (-1),
214  saveByRun_ (1),
215  saveAtJobEnd_ (false),
218  forceRunNumber_ (-1),
219  fileBaseName_ (""),
220  fileUpdate_ ("RECREATE"),
222  irun_ (-1),
223  ilumi_ (-1),
224  ilumiprev_ (-1),
225  ievent_ (-1),
226  nrun_ (0),
227  nlumi_ (0),
228  nevent_ (0),
230 {
231  // Determine the file saving convention, and adjust defaults accordingly.
232  std::string convention = ps.getUntrackedParameter<std::string>("convention", "Offline");
233  if (convention == "Offline")
235  else if (convention == "Online")
237  else
238  throw cms::Exception("DQMFileSaver")
239  << "Invalid 'convention' parameter '" << convention << "'."
240  << " Expected one of 'Online' or 'Offline'.";
241 
242  // If this isn't online convention, check workflow.
243  if (convention_ != Online)
244  {
246  if (workflow_.empty()
247  || workflow_[0] != '/'
248  || *workflow_.rbegin() == '/'
249  || std::count(workflow_.begin(), workflow_.end(), '/') != 3
250  || workflow_.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
251  "abcdefghijklmnopqrstuvwxyz"
252  "0123456789"
253  "-_/") != std::string::npos)
254  throw cms::Exception("DQMFileSaver")
255  << "Invalid 'workflow' parameter '" << workflow_
256  << "'. Expected '/A/B/C'.";
257  }
258  else if (! ps.getUntrackedParameter<std::string>("workflow", "").empty())
259  throw cms::Exception("DQMFileSaver")
260  << "The 'workflow' parameter must be empty in 'Online' convention.";
261  else // for online set parameters
262  {
263  workflow_="/Global/Online/P5";
264  }
265 
266  // Allow file producer to be set to specific values in certain conditions.
268  if (convention_ == Online
269  && producer_ != "DQM"
270  && producer_ != "HLTDQM"
271  && producer_ != "Playback")
272  {
273  throw cms::Exception("DQMFileSaver")
274  << "Invalid 'producer' parameter '" << producer_
275  << "'. Expected 'DQM', 'HLTDQM' or 'Playback'.";
276  }
277  else if (convention_ != Online && producer_ != "DQM")
278  {
279  throw cms::Exception("DQMFileSaver")
280  << "Invalid 'producer' parameter '" << producer_
281  << "'. Expected 'DQM'.";
282  }
283 
284  // version number to be used in filename
285  version_ = ps.getUntrackedParameter<int>("version", version_);
286  // flag to signal that file contains data from complete run
287  runIsComplete_ = ps.getUntrackedParameter<bool>("runIsComplete", runIsComplete_);
288 
289  // Check how we should save the references.
290  std::string refsave = ps.getUntrackedParameter<std::string>("referenceHandling", "default");
291  if (refsave == "default")
292  ;
293  else if (refsave == "skip")
294  {
296  // std::cout << "skip saving all references" << std::endl;
297  }
298  else if (refsave == "all")
299  {
301  // std::cout << "saving all references" << std::endl;
302  }
303  else if (refsave == "qtests")
304  {
306  // std::cout << "saving qtest references" << std::endl;
307  }
308  else
309  throw cms::Exception("DQMFileSaver")
310  << "Invalid 'referenceHandling' parameter '" << refsave
311  << "'. Expected 'default', 'skip', 'all' or 'qtests'.";
312 
313  // Check minimum required quality test result for which reference is saved.
314  saveReferenceQMin_ = ps.getUntrackedParameter<int>("referenceRequireStatus", saveReferenceQMin_);
315 
316  // Get and check the output directory.
317  struct stat s;
319  if (dirName_.empty() || stat(dirName_.c_str(), &s) == -1)
320  throw cms::Exception("DQMFileSaver")
321  << "Invalid 'dirName' parameter '" << dirName_ << "'.";
322 
323  // Find out when and how to save files. The following contraints apply:
324  // - For online, allow files to be saved at event and time intervals.
325  // - For online and offline, allow files to be saved per run, lumi and job end
326  // - For offline allow run number to be overridden (for mc data).
327  if (convention_ == Online)
328  {
329  getAnInt(ps, saveByEvent_, "saveByEvent");
330  getAnInt(ps, saveByMinute_, "saveByMinute");
331  getAnInt(ps, saveByTime_, "saveByTime");
332  getAnInt(ps, numKeepSavedFiles_, "maxSavedFilesCount");
333  }
334 
335  if (convention_ == Online || convention_ == Offline)
336  {
337  getAnInt(ps, saveByRun_, "saveByRun");
338  getAnInt(ps, saveByLumiSection_, "saveByLumiSection");
339  }
340 
341  if (convention_ != Online)
342  {
343  getAnInt(ps, forceRunNumber_, "forceRunNumber");
344  saveAtJobEnd_ = ps.getUntrackedParameter<bool>("saveAtJobEnd", saveAtJobEnd_);
345  }
346 
347  if (saveAtJobEnd_ && forceRunNumber_ < 1)
348  throw cms::Exception("DQMFileSaver")
349  << "If saving at the end of the job, the run number must be"
350  << " overridden to a specific value using 'forceRunNumber'.";
351 
352 
353  // Set up base file name and determine the start time.
354  char version[8];
355  sprintf(version, "_V%04d_", int(version_));
356  version[7]='\0';
357  fileBaseName_ = dirName_ + "/" + producer_ + version;
358  gettimeofday(&start_, 0);
359  saved_ = start_;
360 
361  // Log some information what we will do.
362  edm::LogInfo("DQMFileSaver")
363  << "DQM file saving settings:\n"
364  << " using base file name '" << fileBaseName_ << "'\n"
365  << " forcing run number " << forceRunNumber_ << "\n"
366  << " saving every " << saveByLumiSection_ << " lumi section(s)\n"
367  << " saving every " << saveByEvent_ << " event(s)\n"
368  << " saving every " << saveByMinute_ << " minute(s)\n"
369  << " saving every 2^n*" << saveByTime_ << " minutes \n"
370  << " saving every " << saveByRun_ << " run(s)\n"
371  << " saving at job end: " << (saveAtJobEnd_ ? "yes" : "no") << "\n"
372  << " keeping at most " << numKeepSavedFiles_ << " files\n";
373 }
T getUntrackedParameter(std::string const &, T const &) const
int forceRunNumber_
Definition: DQMFileSaver.h:52
int saveReferenceQMin_
Definition: DQMFileSaver.h:51
std::string fileUpdate_
Definition: DQMFileSaver.h:55
Convention convention_
Definition: DQMFileSaver.h:36
DQMStore * dbe_
Definition: DQMFileSaver.h:57
std::string dirName_
Definition: DQMFileSaver.h:39
std::string fileBaseName_
Definition: DQMFileSaver.h:54
int saveByLumiSection_
Definition: DQMFileSaver.h:44
static void getAnInt(const edm::ParameterSet &ps, int &value, const std::string &name)
Definition: DQMFileSaver.cc:23
bool runIsComplete_
Definition: DQMFileSaver.h:42
timeval start_
Definition: DQMFileSaver.h:66
std::string workflow_
Definition: DQMFileSaver.h:37
std::string producer_
Definition: DQMFileSaver.h:38
std::string child_
Definition: DQMFileSaver.h:40
int saveReference_
Definition: DQMFileSaver.h:50
bool saveAtJobEnd_
Definition: DQMFileSaver.h:49
timeval saved_
Definition: DQMFileSaver.h:67
static const int STATUS_OK
int numKeepSavedFiles_
Definition: DQMFileSaver.h:69

Member Function Documentation

void DQMFileSaver::analyze ( const edm::Event e,
const edm::EventSetup  
)
protectedvirtual

Implements edm::EDAnalyzer.

Definition at line 398 of file DQMFileSaver.cc.

References convention_, edm::EventID::event(), edm::hlt::Exception, edm::EventBase::id(), ievent_, irun_, nevent_, Online, saveByEvent_, saveByMinute_, saveByTime_, saved_, saveForOnline(), start_, and createPayload::suffix.

399 {
400  ++nevent_;
401 
402  ievent_ = e.id().event();
403 
404  // Check if we should save for this event.
405  char suffix[64];
406  if (ievent_ > 0 && saveByEvent_ > 0 && nevent_ == saveByEvent_)
407  {
408  if (convention_ != Online)
409  throw cms::Exception("DQMFileSaver")
410  << "Internal error, can save files by event"
411  << " only in Online mode.";
412 
413  sprintf(suffix, "_R%09d_E%08d", irun_, ievent_);
414  saveForOnline(suffix, "\\1\\2");
415  nevent_ = 0;
416  }
417 
418  // Check if we should save due to elapsed time.
419  if ( ievent_ > 0 && ( saveByMinute_ > 0 || saveByTime_ > 0 ) )
420  {
421  if (convention_ != Online)
422  throw cms::Exception("DQMFileSaver")
423  << "Internal error, can save files by time"
424  << " only in Online mode.";
425 
426  // Compute elapsed time in minutes.
427  struct timeval tv;
428  gettimeofday(&tv, 0);
429 
430  double totalelapsed = ((tv.tv_sec + tv.tv_usec*1e-6)
431  - (start_.tv_sec + start_.tv_usec*1e-6)) / 60;
432  double elapsed = ((tv.tv_sec + tv.tv_usec*1e-6)
433  - (saved_.tv_sec + saved_.tv_usec*1e-6)) / 60;
434 
435  // Save if enough time has elapsed since the last save.
436  if ( (saveByMinute_ > 0 && elapsed > saveByMinute_ ) ||
437  (saveByTime_ > 0 && totalelapsed > saveByTime_ ) )
438  {
439  if ( saveByTime_ > 0 ) saveByTime_ *= 2;
440  saved_ = tv;
441  sprintf(suffix, "_R%09d_T%08d", irun_, int(totalelapsed));
442  char rewrite[64]; sprintf(rewrite, "\\1Run %d/\\2/Run summary", irun_);
443  saveForOnline(suffix, rewrite);
444  }
445  }
446 }
EventNumber_t event() const
Definition: EventID.h:44
void saveForOnline(const std::string &suffix, const std::string &rewrite)
Convention convention_
Definition: DQMFileSaver.h:36
timeval start_
Definition: DQMFileSaver.h:66
edm::EventID id() const
Definition: EventBase.h:56
timeval saved_
Definition: DQMFileSaver.h:67
void DQMFileSaver::beginJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 377 of file DQMFileSaver.cc.

References ievent_, ilumi_, ilumiprev_, irun_, nevent_, nlumi_, and nrun_.

378 {
379  irun_ = ilumi_ = ilumiprev_ = ievent_ = -1;
380  nrun_ = nlumi_ = nevent_ = 0;
381 }
void DQMFileSaver::beginLuminosityBlock ( const edm::LuminosityBlock l,
const edm::EventSetup  
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 391 of file DQMFileSaver.cc.

References edm::LuminosityBlockBase::id(), ilumi_, ilumiprev_, edm::LuminosityBlockID::luminosityBlock(), and nlumi_.

392 {
393  ilumi_ = l.id().luminosityBlock();
394  if (ilumiprev_ == -1) ilumiprev_ = ilumi_;
395  ++nlumi_;
396 }
LuminosityBlockID id() const
LuminosityBlockNumber_t luminosityBlock() const
void DQMFileSaver::beginRun ( const edm::Run r,
const edm::EventSetup  
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 384 of file DQMFileSaver.cc.

References forceRunNumber_, edm::RunBase::id(), irun_, nrun_, and edm::RunID::run().

385 {
386  irun_ = (forceRunNumber_ == -1 ? r.id().run() : forceRunNumber_);
387  ++nrun_;
388 }
int forceRunNumber_
Definition: DQMFileSaver.h:52
RunID const & id() const
Definition: RunBase.h:41
RunNumber_t run() const
Definition: RunID.h:44
void DQMFileSaver::endJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 497 of file DQMFileSaver.cc.

References convention_, edm::hlt::Exception, forceRunNumber_, Offline, saveAtJobEnd_, saveForOffline(), and workflow_.

498 {
499  if (saveAtJobEnd_)
500  {
501  if (convention_ == Offline && forceRunNumber_ > 0)
503  else
504  throw cms::Exception("DQMFileSaver")
505  << "Internal error. Can only save files at the end of the"
506  << " job in Offline mode with run number overridden.";
507  }
508 
509 }
int forceRunNumber_
Definition: DQMFileSaver.h:52
Convention convention_
Definition: DQMFileSaver.h:36
std::string workflow_
Definition: DQMFileSaver.h:37
bool saveAtJobEnd_
Definition: DQMFileSaver.h:49
void saveForOffline(const std::string &workflow, int run, int lumi)
Definition: DQMFileSaver.cc:33
void DQMFileSaver::endLuminosityBlock ( const edm::LuminosityBlock ,
const edm::EventSetup  
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 449 of file DQMFileSaver.cc.

References convention_, edm::hlt::Exception, ilumi_, ilumiprev_, irun_, nlumi_, Offline, Online, saveByLumiSection_, saveForOffline(), saveForOnline(), createPayload::suffix, and workflow_.

450 {
451 
452  if (ilumi_ > 0 && saveByLumiSection_ > 0 )
453  {
454  if (convention_ != Online && convention_ != Offline )
455  throw cms::Exception("DQMFileSaver")
456  << "Internal error, can save files at end of lumi block"
457  << " only in Online or Offline mode.";
458 
459  if (convention_ == Online && nlumi_ == saveByLumiSection_) // insist on lumi section ordering
460  {
461  char suffix[64];
462  char rewrite[128];
463  sprintf(suffix, "_R%09d_L%06d", irun_, ilumi_);
464  sprintf(rewrite, "\\1Run %d/\\2/By Lumi Section %d-%d", irun_, ilumiprev_, ilumi_);
465  saveForOnline(suffix, rewrite);
466  ilumiprev_ = -1;
467  nlumi_ = 0;
468  }
469  if (convention_ == Offline)
471  }
472 }
void saveForOnline(const std::string &suffix, const std::string &rewrite)
Convention convention_
Definition: DQMFileSaver.h:36
int saveByLumiSection_
Definition: DQMFileSaver.h:44
std::string workflow_
Definition: DQMFileSaver.h:37
void saveForOffline(const std::string &workflow, int run, int lumi)
Definition: DQMFileSaver.cc:33
void DQMFileSaver::endRun ( const edm::Run ,
const edm::EventSetup  
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 475 of file DQMFileSaver.cc.

References convention_, edm::hlt::Exception, irun_, nrun_, Offline, Online, saveByRun_, saveForOffline(), saveForOnline(), createPayload::suffix, and workflow_.

476 {
477  if (irun_ > 0 && saveByRun_ > 0 && nrun_ == saveByRun_)
478  {
479  if (convention_ == Online)
480  {
481  char suffix[64]; sprintf(suffix, "_R%09d", irun_);
482  char rewrite[64]; sprintf(rewrite, "\\1Run %d/\\2/Run summary", irun_);
483  saveForOnline(suffix, rewrite);
484  }
485  else if (convention_ == Offline)
487  else
488  throw cms::Exception("DQMFileSaver")
489  << "Internal error. Can only save files in endRun()"
490  << " in Online and Offline modes.";
491 
492  nrun_ = 0;
493  }
494 }
void saveForOnline(const std::string &suffix, const std::string &rewrite)
Convention convention_
Definition: DQMFileSaver.h:36
std::string workflow_
Definition: DQMFileSaver.h:37
void saveForOffline(const std::string &workflow, int run, int lumi)
Definition: DQMFileSaver.cc:33
void DQMFileSaver::postForkReacquireResources ( unsigned int  childIndex,
unsigned int  numberOfChildren 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 512 of file DQMFileSaver.cc.

References child_, and AlCaHLTBitMon_QueryRunRegistry::string.

513 {
514  // this is copied from IOPool/Output/src/PoolOutputModule.cc, for consistency
515  unsigned int digits = 0;
516  while (numberOfChildren != 0) {
517  ++digits;
518  numberOfChildren /= 10;
519  }
520  // protect against zero numberOfChildren
521  if (digits == 0) {
522  digits = 3;
523  }
524 
525  char buffer[digits + 2];
526  snprintf(buffer, digits + 2, "_%0*d", digits, childIndex);
527  child_ = std::string(buffer);
528 }
std::string child_
Definition: DQMFileSaver.h:40
void DQMFileSaver::saveForOffline ( const std::string &  workflow,
int  run,
int  lumi 
)
private

Definition at line 33 of file DQMFileSaver.cc.

References DQMStore::bookFloat(), DQMStore::bookString(), DQMStore::cd(), child_, gather_cfg::cout, dbe_, alignCSCRings::e, fileBaseName_, lut2db_cfg::filename, fileUpdate_, MonitorElement::Fill(), DQMStore::get(), edm::getReleaseVersion(), DQMStore::getSubdirs(), i, ilumi_, irun_, pastSavedFiles_, pos, runIsComplete_, DQMStore::save(), saveJobReport(), saveReference_, saveReferenceQMin_, DQMStore::SaveWithoutReference, DQMStore::setCurrentFolder(), dqm::qstatus::STATUS_OK, AlCaHLTBitMon_QueryRunRegistry::string, createPayload::suffix, and reco_calib_source_client_cfg::workflow.

Referenced by endJob(), endLuminosityBlock(), and endRun().

34 {
35 
36  char suffix[64];
37  sprintf(suffix, "R%09d", run);
38 
39  char rewrite[128];
40  if (lumi == 0) // save for run
41  sprintf(rewrite, "\\1Run %d/\\2/Run summary", run);
42  else
43  sprintf(rewrite, "\\1Run %d/\\2/By Lumi Section %d-%d", irun_, ilumi_, ilumi_);
44 
45  size_t pos = 0;
46  std::string wflow;
47  wflow.reserve(workflow.size() + 3);
48  wflow = workflow;
49  while ((pos = wflow.find('/', pos)) != std::string::npos)
50  wflow.replace(pos++, 1, "__");
51 
52  std::string filename = fileBaseName_ + suffix + wflow + child_ + ".root";
53 
54  if (lumi == 0) // save for run
55  {
56  // set run end flag
57  dbe_->cd();
58  dbe_->setCurrentFolder("Info/ProvInfo");
59 
60  // do this, because ProvInfo is not yet run in offline DQM
61  MonitorElement* me = dbe_->get("Info/ProvInfo/CMSSW");
62  if (!me) me = dbe_->bookString("CMSSW",edm::getReleaseVersion().c_str() );
63 
64  me = dbe_->get("Info/ProvInfo/runIsComplete");
65  if (!me) me = dbe_->bookFloat("runIsComplete");
66 
67  if (me)
68  {
69  if (runIsComplete_)
70  me->Fill(1.);
71  else
72  me->Fill(0.);
73  }
74 
75  dbe_->save(filename,
76  "",
77  "^(Reference/)?([^/]+)",
78  rewrite,
81  fileUpdate_);
82  }
83  else // save EventInfo folders for luminosity sections
84  {
85  std::vector<std::string> systems = (dbe_->cd(), dbe_->getSubdirs());
86 
87  std::cout << " DQMFileSaver: storing EventInfo folders for Run: "
88  << irun_ << ", Lumi Section: " << ilumi_ << ", Subsystems: " ;
89 
90  for (size_t i = 0, e = systems.size(); i != e; ++i) {
91  if (systems[i] != "Reference") {
92  dbe_->cd();
93  std::cout << systems[i] << " " ;
94  dbe_->save(filename,
95  systems[i]+"/EventInfo", "^(Reference/)?([^/]+)", rewrite,
98  fileUpdate_);
99  // from now on update newly created file
100  if (fileUpdate_=="RECREATE") fileUpdate_="UPDATE";
101  }
102  }
103  std::cout << "\n";
104  }
105 
106  if (pastSavedFiles_.size() == 0)
107  {
108  // save JobReport upon creation of file (once per job)
109  saveJobReport(filename);
110  pastSavedFiles_.push_back(filename);
111  }
112 
113 }
int i
Definition: DBlmapReader.cc:9
int saveReferenceQMin_
Definition: DQMFileSaver.h:51
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1424
std::string fileUpdate_
Definition: DQMFileSaver.h:55
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:411
tuple lumi
Definition: fjr2json.py:35
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2118
std::list< std::string > pastSavedFiles_
Definition: DQMFileSaver.h:70
DQMStore * dbe_
Definition: DQMFileSaver.h:57
void saveJobReport(const std::string &filename)
std::string fileBaseName_
Definition: DQMFileSaver.h:54
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:659
SaveReferenceTag
Definition: DQMStore.h:70
void Fill(long long x)
MonitorElement * bookString(const char *name, const char *value)
Book string.
Definition: DQMStore.cc:688
bool runIsComplete_
Definition: DQMFileSaver.h:42
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
std::string getReleaseVersion()
std::string child_
Definition: DQMFileSaver.h:40
int saveReference_
Definition: DQMFileSaver.h:50
tuple filename
Definition: lut2db_cfg.py:20
static const int STATUS_OK
tuple cout
Definition: gather_cfg.py:121
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
void DQMFileSaver::saveForOnline ( const std::string &  suffix,
const std::string &  rewrite 
)
private

Definition at line 137 of file DQMFileSaver.cc.

References DQMStore::cd(), child_, dbe_, doSaveForOnline(), alignCSCRings::e, fileBaseName_, DQMStore::get(), DQMStore::getMatchingContents(), DQMStore::getSubdirs(), i, numKeepSavedFiles_, pastSavedFiles_, saveReference_, and saveReferenceQMin_.

Referenced by analyze(), endLuminosityBlock(), and endRun().

138 {
139  std::vector<std::string> systems = (dbe_->cd(), dbe_->getSubdirs());
140 
141  for (size_t i = 0, e = systems.size(); i != e; ++i)
142  {
143  if (systems[i] != "Reference")
144  {
145  dbe_->cd();
146  if (MonitorElement* me = dbe_->get(systems[i] + "/EventInfo/processName"))
147  {
149  fileBaseName_ + me->getStringValue() + suffix + child_ + ".root",
150  "", "^(Reference/)?([^/]+)", rewrite,
153  return;
154  }
155  }
156  }
157 
158  // look for EventInfo folder in an unorthodox location
159  for (size_t i = 0, e = systems.size(); i != e; ++i)
160  if (systems[i] != "Reference")
161  {
162  dbe_->cd();
163  std::vector<MonitorElement*> pNamesVector = dbe_->getMatchingContents("^" + systems[i] + "/.*/EventInfo/processName",lat::Regexp::Perl);
164  if (pNamesVector.size() > 0){
166  fileBaseName_ + systems[i] + suffix + child_ + ".root",
167  "", "^(Reference/)?([^/]+)", rewrite,
170  pNamesVector.clear();
171  return;
172  }
173  }
174 
175  // if no EventInfo Folder is found, then store subsystem wise
176  for (size_t i = 0, e = systems.size(); i != e; ++i)
177  if (systems[i] != "Reference")
179  fileBaseName_ + systems[i] + suffix + child_ + ".root",
180  systems[i], "^(Reference/)?([^/]+)", rewrite,
183 }
int i
Definition: DBlmapReader.cc:9
int saveReferenceQMin_
Definition: DQMFileSaver.h:51
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1424
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:411
std::list< std::string > pastSavedFiles_
Definition: DQMFileSaver.h:70
std::vector< MonitorElement * > getMatchingContents(const std::string &pattern, lat::Regexp::Syntax syntaxType=lat::Regexp::Wildcard) const
Definition: DQMStore.cc:1696
DQMStore * dbe_
Definition: DQMFileSaver.h:57
std::string fileBaseName_
Definition: DQMFileSaver.h:54
static void doSaveForOnline(std::list< std::string > &pastSavedFiles, size_t numKeepSavedFiles, DQMStore *store, const std::string &filename, const std::string &directory, const std::string &rxpat, const std::string &rewrite, DQMStore::SaveReferenceTag saveref, int saveRefQMin)
SaveReferenceTag
Definition: DQMStore.h:70
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
std::string child_
Definition: DQMFileSaver.h:40
int saveReference_
Definition: DQMFileSaver.h:50
int numKeepSavedFiles_
Definition: DQMFileSaver.h:69
void DQMFileSaver::saveJobReport ( const std::string &  filename)
private

Definition at line 186 of file DQMFileSaver.cc.

References info, edm::Service< T >::isAvailable(), and edm::JobReport::reportAnalysisFile().

Referenced by saveForOffline().

187 {
188 
189  // Report the file to job report service.
191  if (jr.isAvailable())
192  {
193  std::map<std::string, std::string> info;
194  info["Source"] = "DQMStore";
195  info["FileClass"] = "DQM";
196  jr->reportAnalysisFile(filename, info);
197  }
198 
199 }
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:685
bool isAvailable() const
Definition: Service.h:47
tuple filename
Definition: lut2db_cfg.py:20

Member Data Documentation

std::string DQMFileSaver::child_
private

Definition at line 40 of file DQMFileSaver.h.

Referenced by postForkReacquireResources(), saveForOffline(), and saveForOnline().

Convention DQMFileSaver::convention_
private

Definition at line 36 of file DQMFileSaver.h.

Referenced by analyze(), DQMFileSaver(), endJob(), endLuminosityBlock(), and endRun().

DQMStore* DQMFileSaver::dbe_
private

Definition at line 57 of file DQMFileSaver.h.

Referenced by saveForOffline(), and saveForOnline().

std::string DQMFileSaver::dirName_
private

Definition at line 39 of file DQMFileSaver.h.

Referenced by DQMFileSaver().

std::string DQMFileSaver::fileBaseName_
private

Definition at line 54 of file DQMFileSaver.h.

Referenced by DQMFileSaver(), saveForOffline(), and saveForOnline().

std::string DQMFileSaver::fileUpdate_
private

Definition at line 55 of file DQMFileSaver.h.

Referenced by saveForOffline().

MonitorElement* DQMFileSaver::fileVersion_
private

Definition at line 81 of file DQMFileSaver.h.

int DQMFileSaver::forceRunNumber_
private

Definition at line 52 of file DQMFileSaver.h.

Referenced by beginRun(), DQMFileSaver(), and endJob().

MonitorElement* DQMFileSaver::hostName_
private

Definition at line 76 of file DQMFileSaver.h.

int DQMFileSaver::ievent_
private

Definition at line 62 of file DQMFileSaver.h.

Referenced by analyze(), and beginJob().

int DQMFileSaver::ilumi_
private

Definition at line 60 of file DQMFileSaver.h.

Referenced by beginJob(), beginLuminosityBlock(), endLuminosityBlock(), and saveForOffline().

int DQMFileSaver::ilumiprev_
private

Definition at line 61 of file DQMFileSaver.h.

Referenced by beginJob(), beginLuminosityBlock(), and endLuminosityBlock().

int DQMFileSaver::irun_
private

Definition at line 59 of file DQMFileSaver.h.

Referenced by analyze(), beginJob(), beginRun(), endLuminosityBlock(), endRun(), and saveForOffline().

MonitorElement* DQMFileSaver::isComplete_
private

The PID associated with this job.

Definition at line 80 of file DQMFileSaver.h.

int DQMFileSaver::nevent_
private

Definition at line 65 of file DQMFileSaver.h.

Referenced by analyze(), and beginJob().

int DQMFileSaver::nlumi_
private

Definition at line 64 of file DQMFileSaver.h.

Referenced by beginJob(), beginLuminosityBlock(), and endLuminosityBlock().

int DQMFileSaver::nrun_
private

Definition at line 63 of file DQMFileSaver.h.

Referenced by beginJob(), beginRun(), and endRun().

int DQMFileSaver::numKeepSavedFiles_
private

Definition at line 69 of file DQMFileSaver.h.

Referenced by DQMFileSaver(), and saveForOnline().

std::list<std::string> DQMFileSaver::pastSavedFiles_
private

Definition at line 70 of file DQMFileSaver.h.

Referenced by saveForOffline(), and saveForOnline().

MonitorElement* DQMFileSaver::processId_
private

Current working directory of the job.

Definition at line 79 of file DQMFileSaver.h.

MonitorElement* DQMFileSaver::processName_
private

Hostname of the local machine.

Definition at line 77 of file DQMFileSaver.h.

std::string DQMFileSaver::producer_
private

Definition at line 38 of file DQMFileSaver.h.

Referenced by DQMFileSaver().

bool DQMFileSaver::runIsComplete_
private

Definition at line 42 of file DQMFileSaver.h.

Referenced by DQMFileSaver(), and saveForOffline().

bool DQMFileSaver::saveAtJobEnd_
private

Definition at line 49 of file DQMFileSaver.h.

Referenced by DQMFileSaver(), and endJob().

int DQMFileSaver::saveByEvent_
private

Definition at line 45 of file DQMFileSaver.h.

Referenced by analyze(), and DQMFileSaver().

int DQMFileSaver::saveByLumiSection_
private

Definition at line 44 of file DQMFileSaver.h.

Referenced by DQMFileSaver(), and endLuminosityBlock().

int DQMFileSaver::saveByMinute_
private

Definition at line 46 of file DQMFileSaver.h.

Referenced by analyze(), and DQMFileSaver().

int DQMFileSaver::saveByRun_
private

Definition at line 48 of file DQMFileSaver.h.

Referenced by DQMFileSaver(), and endRun().

int DQMFileSaver::saveByTime_
private

Definition at line 47 of file DQMFileSaver.h.

Referenced by analyze(), and DQMFileSaver().

timeval DQMFileSaver::saved_
private

Definition at line 67 of file DQMFileSaver.h.

Referenced by analyze(), and DQMFileSaver().

int DQMFileSaver::saveReference_
private

Definition at line 50 of file DQMFileSaver.h.

Referenced by DQMFileSaver(), saveForOffline(), and saveForOnline().

int DQMFileSaver::saveReferenceQMin_
private

Definition at line 51 of file DQMFileSaver.h.

Referenced by DQMFileSaver(), saveForOffline(), and saveForOnline().

timeval DQMFileSaver::start_
private

Definition at line 66 of file DQMFileSaver.h.

Referenced by analyze(), and DQMFileSaver().

MonitorElement* DQMFileSaver::versCMSSW_
private

Definition at line 72 of file DQMFileSaver.h.

MonitorElement* DQMFileSaver::versDataset_
private

Definition at line 73 of file DQMFileSaver.h.

MonitorElement* DQMFileSaver::versGlobaltag_
private

Definition at line 75 of file DQMFileSaver.h.

int DQMFileSaver::version_
private

Definition at line 41 of file DQMFileSaver.h.

Referenced by DQMFileSaver().

MonitorElement* DQMFileSaver::versTaglist_
private

Definition at line 74 of file DQMFileSaver.h.

std::string DQMFileSaver::workflow_
private

Definition at line 37 of file DQMFileSaver.h.

Referenced by DQMFileSaver(), endJob(), endLuminosityBlock(), and endRun().

MonitorElement* DQMFileSaver::workingDir_
private

DQM "name" of the job (eg, Hcal or DT)

Definition at line 78 of file DQMFileSaver.h.