CMS 3D CMS Logo

DQMFileSaver.cc
Go to the documentation of this file.
1 #include "DQMFileSaver.h"
13 
16 
17 #include <sys/stat.h>
18 #include <sys/types.h>
19 #include <unistd.h>
20 #include <iostream>
21 #include <vector>
22 #include <string>
23 #include <fstream>
24 #include <utility>
25 #include <TString.h>
26 #include <TSystem.h>
27 
28 #include <boost/property_tree/json_parser.hpp>
29 #include <boost/property_tree/ptree.hpp>
30 #include <boost/filesystem.hpp>
31 #include <boost/format.hpp>
32 
33 //--------------------------------------------------------
35 const std::string DQMFileSaver::streamSuffix_("Histograms");
36 
37 //--------------------------------------------------------
38 static void
40 {
41  value = ps.getUntrackedParameter<int>(name, value);
42  if (value < 1 && value != -1)
43  throw cms::Exception("DQMFileSaver")
44  << "Invalid '" << name << "' parameter '" << value
45  << "'. Must be -1 or >= 1.";
46 }
47 
48 static std::string
50 {
52  if (fileFormat == DQMFileSaver::ROOT)
53  extension = ".root";
54  else if (fileFormat == DQMFileSaver::PB)
55  extension = ".pb";
56  return extension;
57 }
58 
59 static std::string
60 onlineOfflineFileName(const std::string &fileBaseName,
61  const std::string &suffix,
62  const std::string &workflow,
63  const std::string &child,
64  DQMFileSaver::FileFormat fileFormat)
65 {
66  size_t pos = 0;
67  std::string wflow;
68  wflow.reserve(workflow.size() + 3);
69  wflow = workflow;
70  while ((pos = wflow.find('/', pos)) != std::string::npos)
71  wflow.replace(pos++, 1, "__");
72 
73  std::string filename = fileBaseName + suffix + wflow + child + dataFileExtension(fileFormat);
74  return filename;
75 }
76 
77 void
79 {
80  char suffix[64];
81  sprintf(suffix, "R%09d", run);
83  dbe_->savePB(filename, filterName_);
84 }
85 
86 void
88 {
89  char suffix[64];
90  sprintf(suffix, "R%09d", run);
91 
92  char rewrite[128];
93  if (lumi == 0) // save for run
94  sprintf(rewrite, "\\1Run %d/\\2/Run summary", run);
95  else
96  sprintf(rewrite, "\\1Run %d/\\2/By Lumi Section %d-%d", run, lumi, lumi);
97 
99 
100  if (lumi == 0) // save for run
101  {
102  // set run end flag
103  dbe_->cd();
104  dbe_->setCurrentFolder("Info/ProvInfo");
105 
106  // do this, because ProvInfo is not yet run in offline DQM
107  MonitorElement* me = dbe_->get("Info/ProvInfo/CMSSW");
108  if (!me) me = dbe_->bookString("CMSSW", edm::getReleaseVersion().c_str() );
109 
110  me = dbe_->get("Info/ProvInfo/runIsComplete");
111  if (!me) me = dbe_->bookFloat("runIsComplete");
112 
113  if (me)
114  {
115  if (runIsComplete_)
116  me->Fill(1.);
117  else
118  me->Fill(0.);
119  }
120 
121  dbe_->save(filename,
122  "",
123  "^(Reference/)?([^/]+)",
124  rewrite,
125  enableMultiThread_ ? run : 0,
126  lumi,
129  fileUpdate_ ? "UPDATE" : "RECREATE");
130 
131  // save the JobReport
132  saveJobReport(filename);
133  }
134  else // save EventInfo folders for luminosity sections
135  {
136  std::vector<std::string> systems = (dbe_->cd(), dbe_->getSubdirs());
137 
138  edm::LogAbsolute msg("fileAction");
139  msg << "DQMFileSaver: storing EventInfo folders for Run: "
140  << run << ", Lumi Section: " << lumi << ", Subsystems: " ;
141 
142  for (size_t i = 0, e = systems.size(); i != e; ++i) {
143  if (systems[i] != "Reference") {
144  dbe_->cd();
145  msg << systems[i] << " " ;
146 
147  dbe_->save(filename,
148  systems[i]+"/EventInfo", "^(Reference/)?([^/]+)",
149  rewrite,
150  enableMultiThread_ ? run : 0,
151  lumi,
154  fileUpdate_ ? "UPDATE" : "RECREATE");
155 
156  // from now on update newly created file
157  if (fileUpdate_.load() == 0) fileUpdate_ = 1;
158  }
159  }
160  }
161 
162 }
163 
164 static void
166  int run,
167  bool enableMultiThread,
168  const std::string &filename,
169  const std::string &directory,
170  const std::string &rxpat,
171  const std::string &rewrite,
173  int saveRefQMin,
174  const std::string &filterName,
175  DQMFileSaver::FileFormat fileFormat)
176 {
177  // TODO(rovere): fix the online case. so far we simply rely on the
178  // fact that we assume we will not run multithreaded in online.
179  if (fileFormat == DQMFileSaver::ROOT)
180  store->save(filename,
181  directory,
182  rxpat,
183  rewrite,
184  enableMultiThread ? run : 0,
185  0,
186  saveref,
187  saveRefQMin);
188  else if (fileFormat == DQMFileSaver::PB)
189  store->savePB(filename,
190  filterName,
191  enableMultiThread ? run : 0);
192 }
193 
194 void
196 {
197  // The file name contains the Online workflow name,
198  // as we do not want to look inside the DQMStore,
199  // and the @a suffix, defined in the run/lumi transitions.
200  // TODO(diguida): add the possibility to change the dir structure with rewrite.
203  filename,
204  "", "^(Reference/)?([^/]+)", "\\1\\2",
207  filterName_,
208  PB);
209 }
210 
211 void
213 {
214  std::vector<std::string> systems = (dbe_->cd(), dbe_->getSubdirs());
215 
216  for (size_t i = 0, e = systems.size(); i != e; ++i)
217  {
218  if (systems[i] != "Reference")
219  {
220  dbe_->cd();
221  if (MonitorElement* me = dbe_->get(systems[i] + "/EventInfo/processName"))
222  {
224  fileBaseName_ + me->getStringValue() + suffix + child_ + ".root",
225  "", "^(Reference/)?([^/]+)", rewrite,
228  "", ROOT);
229  return;
230  }
231  }
232  }
233 
234  // look for EventInfo folder in an unorthodox location
235  for (size_t i = 0, e = systems.size(); i != e; ++i)
236  if (systems[i] != "Reference")
237  {
238  dbe_->cd();
239  std::vector<MonitorElement*> pNamesVector = dbe_->getMatchingContents("^" + systems[i] + "/.*/EventInfo/processName",lat::Regexp::Perl);
240  if (!pNamesVector.empty()){
242  fileBaseName_ + systems[i] + suffix + child_ + ".root",
243  "", "^(Reference/)?([^/]+)", rewrite,
246  "", ROOT);
247  pNamesVector.clear();
248  return;
249  }
250  }
251 
252  // if no EventInfo Folder is found, then store subsystem wise
253  for (size_t i = 0, e = systems.size(); i != e; ++i)
254  if (systems[i] != "Reference")
256  fileBaseName_ + systems[i] + suffix + child_ + ".root",
257  systems[i], "^(Reference/)?([^/]+)", rewrite,
260  "", ROOT);
261 }
262 
263 
264 boost::property_tree::ptree
265 DQMFileSaver::fillJson(int run, int lumi, const std::string& dataFilePathName, const std::string& transferDestinationStr, const std::string& mergeTypeStr, evf::FastMonitoringService *fms)
266 {
267  return dqmfilesaver::fillJson(run, lumi, dataFilePathName, transferDestinationStr, mergeTypeStr, fms);
268 }
269 
270 void
271 DQMFileSaver::saveForFilterUnit(const std::string& rewrite, int run, int lumi, const DQMFileSaver::FileFormat fileFormat) const
272 {
273  // get from DAQ2 services where to store the files according to their format
274  namespace bpt = boost::property_tree;
275 
276  std::string openJsonFilePathName;
277  std::string jsonFilePathName;
278  std::string openHistoFilePathName;
279  std::string histoFilePathName;
280 
281  // create the files names
282  if (fakeFilterUnitMode_) {
283  std::string runDir = str(boost::format("%s/run%06d") % dirName_ % run);
284  std::string baseName = str(boost::format("%s/run%06d_ls%04d_%s") % runDir % run % lumi % stream_label_ );
285 
286  boost::filesystem::create_directories(runDir);
287 
288  jsonFilePathName = baseName + ".jsn";
289  openJsonFilePathName = jsonFilePathName + ".open";
290 
291  histoFilePathName = baseName + dataFileExtension(fileFormat);
292  openHistoFilePathName = histoFilePathName + ".open";
293  } else {
294  openJsonFilePathName = edm::Service<evf::EvFDaqDirector>()->getOpenOutputJsonFilePath(lumi, stream_label_);
295  jsonFilePathName = edm::Service<evf::EvFDaqDirector>()->getOutputJsonFilePath(lumi, stream_label_);
296 
297  if (fileFormat == ROOT) {
298  openHistoFilePathName = edm::Service<evf::EvFDaqDirector>()->getOpenRootHistogramFilePath(lumi, stream_label_);
299  histoFilePathName = edm::Service<evf::EvFDaqDirector>()->getRootHistogramFilePath(lumi, stream_label_);
300  } else if (fileFormat == PB) {
301  openHistoFilePathName = edm::Service<evf::EvFDaqDirector>()->getOpenProtocolBufferHistogramFilePath(lumi, stream_label_);
302  histoFilePathName = edm::Service<evf::EvFDaqDirector>()->getProtocolBufferHistogramFilePath(lumi, stream_label_);
303  }
304  }
305 
306  if (fms_ ? fms_->getEventsProcessedForLumi(lumi) : true) {
307  if (fileFormat == ROOT)
308  {
309  // Save the file with the full directory tree,
310  // modifying it according to @a rewrite,
311  // but not looking for MEs inside the DQMStore, as in the online case,
312  // nor filling new MEs, as in the offline case.
313  dbe_->save(openHistoFilePathName,
314  "",
315  "^(Reference/)?([^/]+)",
316  rewrite,
317  enableMultiThread_ ? run : 0,
318  lumi,
321  fileUpdate_ ? "UPDATE" : "RECREATE");
322  }
323  else if (fileFormat == PB)
324  {
325  // Save the file in the open directory.
326  dbe_->savePB(openHistoFilePathName,
327  filterName_,
328  enableMultiThread_ ? run : 0,
329  lumi);
330  }
331  else
332  throw cms::Exception("DQMFileSaver")
333  << "Internal error, can save files"
334  << " only in ROOT or ProtocolBuffer format.";
335 
336  // Now move the the data and json files into the output directory.
337  rename(openHistoFilePathName.c_str(), histoFilePathName.c_str());
338  }
339 
340  // Write the json file in the open directory.
341  bpt::ptree pt = fillJson(run, lumi, histoFilePathName, transferDestination_, mergeType_, fms_);
342  write_json(openJsonFilePathName, pt);
343  rename(openJsonFilePathName.c_str(), jsonFilePathName.c_str());
344 }
345 
346 void
348 {
349 
350  // Report the file to job report service.
352  if (jr.isAvailable())
353  {
354  std::map<std::string, std::string> info;
355  info["Source"] = "DQMStore";
356  info["FileClass"] = "DQM";
357  jr->reportAnalysisFile(filename, info);
358  }
359 
360 }
361 
362 //--------------------------------------------------------
364  : convention_ (Offline),
365  fileFormat_(ROOT),
366  workflow_ (""),
367  producer_ ("DQM"),
368  stream_label_ (""),
369  dirName_ ("."),
370  child_ (""),
371  filterName_(""),
372  version_ (1),
375  saveByLumiSection_ (-1),
376  saveByRun_ (-1),
378  saveReference_ (DQMStore::SaveWithReference),
379  saveReferenceQMin_ (dqm::qstatus::STATUS_OK),
380  forceRunNumber_ (-1),
381  fileBaseName_ (""),
382  fileUpdate_ (0),
383  dbe_ (&*edm::Service<DQMStore>()),
384  nrun_ (0),
385  nlumi_ (0),
386  irun_ (0),
387  fms_(nullptr)
388 {
389  // Determine the file saving convention, and adjust defaults accordingly.
390  std::string convention = ps.getUntrackedParameter<std::string>("convention", "Offline");
391  fakeFilterUnitMode_ = ps.getUntrackedParameter<bool>("fakeFilterUnitMode", false);
392 
393  if (convention == "Offline")
395  else if (convention == "Online")
397  else if (convention == "FilterUnit")
399  else
400  throw cms::Exception("DQMFileSaver")
401  << "Invalid 'convention' parameter '" << convention << "'."
402  << " Expected one of 'Online' or 'Offline' or 'FilterUnit'.";
403 
404  // If this is neither online nor FU convention, check workflow.
405  // In this way, FU is treated as online, so we cannot specify a workflow. TBC
407  {
409  if (workflow_.empty()
410  || workflow_[0] != '/'
411  || *workflow_.rbegin() == '/'
412  || std::count(workflow_.begin(), workflow_.end(), '/') != 3
413  || workflow_.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
414  "abcdefghijklmnopqrstuvwxyz"
415  "0123456789"
416  "-_/") != std::string::npos)
417  throw cms::Exception("DQMFileSaver")
418  << "Invalid 'workflow' parameter '" << workflow_
419  << "'. Expected '/A/B/C'.";
420  }
421  else if (! ps.getUntrackedParameter<std::string>("workflow", "").empty())
422  throw cms::Exception("DQMFileSaver")
423  << "The 'workflow' parameter must be empty in 'Online' and 'FilterUnit' conventions.";
424  else // for online set parameters
425  {
426  workflow_="/Global/Online/P5";
427  }
428 
429  // Determine the file format, and adjust defaults accordingly.
430  std::string fileFormat = ps.getUntrackedParameter<std::string>("fileFormat", "ROOT");
431  if (fileFormat == "ROOT")
432  fileFormat_ = ROOT;
433  else if (fileFormat == "PB")
434  fileFormat_ = PB;
435  else
436  throw cms::Exception("DQMFileSaver")
437  << "Invalid 'fileFormat' parameter '" << fileFormat << "'."
438  << " Expected one of 'ROOT' or 'PB'.";
439 
440  // Allow file producer to be set to specific values in certain conditions.
442  // Setting the same constraints on file producer both for online and FilterUnit conventions
443  // TODO(diguida): limit the producer for FilterUnit to be 'DQM' or 'HLTDQM'?
444  // TODO(diguida): how to handle histograms produced in the playback for the FU case?
446  && producer_ != "DQM"
447  && producer_ != "HLTDQM"
448  && producer_ != "Playback")
449  {
450  throw cms::Exception("DQMFileSaver")
451  << "Invalid 'producer' parameter '" << producer_
452  << "'. Expected 'DQM', 'HLTDQM' or 'Playback'.";
453  }
454  else if (convention_ != Online
455  && convention != FilterUnit
456  && producer_ != "DQM")
457  {
458  throw cms::Exception("DQMFileSaver")
459  << "Invalid 'producer' parameter '" << producer_
460  << "'. Expected 'DQM'.";
461  }
462 
464 
465  // version number to be used in filename
466  version_ = ps.getUntrackedParameter<int>("version", version_);
467  // flag to signal that file contains data from complete run
468  runIsComplete_ = ps.getUntrackedParameter<bool>("runIsComplete", runIsComplete_);
469 
470  // Check how we should save the references.
471  std::string refsave = ps.getUntrackedParameter<std::string>("referenceHandling", "default");
472  if (refsave == "default")
473  ;
474  else if (refsave == "skip")
475  {
477  // std::cout << "skip saving all references" << std::endl;
478  }
479  else if (refsave == "all")
480  {
482  // std::cout << "saving all references" << std::endl;
483  }
484  else if (refsave == "qtests")
485  {
487  // std::cout << "saving qtest references" << std::endl;
488  }
489  else
490  throw cms::Exception("DQMFileSaver")
491  << "Invalid 'referenceHandling' parameter '" << refsave
492  << "'. Expected 'default', 'skip', 'all' or 'qtests'.";
493 
494  // Check minimum required quality test result for which reference is saved.
495  saveReferenceQMin_ = ps.getUntrackedParameter<int>("referenceRequireStatus", saveReferenceQMin_);
496 
497  // Get and check the output directory.
498  struct stat s;
500  if (dirName_.empty() || stat(dirName_.c_str(), &s) == -1)
501  throw cms::Exception("DQMFileSaver")
502  << "Invalid 'dirName' parameter '" << dirName_ << "'.";
503 
505  // Find out when and how to save files. The following contraints apply:
506  // - For online, filter unit, and offline, allow files to be saved per lumi
507  // - For online, allow files to be saved per run, at event and time intervals.
508  // - For offline allow files to be saved per run, at job end, and run number to be overridden (for mc data).
510  {
511  getAnInt(ps, saveByLumiSection_, "saveByLumiSection");
512  }
513 
514  if (convention_ == Online)
515  {
516  getAnInt(ps, saveByRun_, "saveByRun");
517  }
518 
519  if (convention_ == Offline)
520  {
521  getAnInt(ps, saveByRun_, "saveByRun");
522  getAnInt(ps, forceRunNumber_, "forceRunNumber");
523  saveAtJobEnd_ = ps.getUntrackedParameter<bool>("saveAtJobEnd", saveAtJobEnd_);
524  }
525 
526  // Set up base file name:
527  // - for online and offline, follow the convention <dirName>/<producer>_V<4digits>_
528  // - for FilterUnit, we need to follow the DAQ2 convention, so we need the run and lumisection:
529  // the path is provided by the DAQ director service.
530  if (convention_ != FilterUnit)
531  {
532  char version[8];
533  sprintf(version, "_V%04d_", int(version_));
534  version[7]='\0';
535  fileBaseName_ = dirName_ + "/" + producer_ + version;
536  }
537  else if (fakeFilterUnitMode_)
538  {
539  edm::LogInfo("DQMFileSaver")
540  << "Fake FU mode, files are saved under <dirname>/runXXXXXX/runXXXXXX_lsXXXX_<stream_Label>.pb.\n";
541  }
542  else
543  {
544  // For FU, dirName_ will not be considered at all
545  edm::LogInfo("DQMFileSaver")
546  << "The base dir provided in the configuration '" << dirName_ << "'\n"
547  << " will not be considered: for FU, the DAQ2 services will handle directories\n";
548  //check that DAQ2 services are available: throw if not
551 
552  if (!(fms_ && daqDirector))
553  throw cms::Exception("DQMFileSaver")
554  << "Internal error, cannot initialize DAQ services.";
555  }
556 
557  // Log some information what we will do.
558  edm::LogInfo("DQMFileSaver")
559  << "DQM file saving settings:\n"
560  << " using base file name '" << fileBaseName_ << "'\n"
561  << " forcing run number " << forceRunNumber_ << "\n"
562  << " saving every " << saveByLumiSection_ << " lumi section(s)\n"
563  << " saving every " << saveByRun_ << " run(s)\n"
564  << " saving at job end: " << (saveAtJobEnd_ ? "yes" : "no") << "\n";
565 }
566 
567 //--------------------------------------------------------
568 void
570 {
571  nrun_ = nlumi_ = irun_ = 0;
572 
573  // Determine if we are running multithreading asking to the DQMStore. Not to be moved in the ctor
575 
577  {
580  }
581 }
582 
583 std::shared_ptr<saverDetails::NoCache>
585 {
586  ++nrun_;
587 
588  // For Filter Unit, create an empty ini file:
589  // it is needed by the HLT deamon in order to start merging
590  // The run number is established in the service
591  // TODO(diguida): check that they are the same?
593  {
595  const std::string initFileName = daqDirector->getInitFilePath(stream_label_);
596  std::ofstream file(initFileName);
597  file.close();
598  }
599 
600  return nullptr;
601 }
602 
603 std::shared_ptr<saverDetails::NoCache>
605 {
606  ++nlumi_;
607  return nullptr;
608 }
609 
611 {
612  //save by event and save by time are not supported
613  //anymore in the threaded framework. please use
614  //savebyLumiSection instead.
615 }
616 
617 void
619 {
620  int ilumi = iLS.id().luminosityBlock();
621  int irun = iLS.id().run();
622  if (ilumi > 0 && saveByLumiSection_ > 0 )
623  {
625  throw cms::Exception("DQMFileSaver")
626  << "Internal error, can save files at end of lumi block"
627  << " only in Online, FilterUnit or Offline mode.";
628 
629  if (convention_ == Online && (nlumi_ % saveByLumiSection_) == 0) // insist on lumi section ordering
630  {
631  char suffix[64];
632  char rewrite[128];
633  sprintf(suffix, "_R%09d_L%06d", irun, ilumi);
634  sprintf(rewrite, "\\1Run %d/\\2/By Lumi Section %d-%d", irun, ilumi-nlumi_, ilumi);
635  if (fileFormat_ == ROOT)
636  saveForOnline(irun, suffix, rewrite);
637  else if (fileFormat_ == PB)
638  saveForOnlinePB(irun, suffix);
639  else
640  throw cms::Exception("DQMFileSaver")
641  << "Internal error, can save files"
642  << " only in ROOT or ProtocolBuffer format.";
643  }
644 
645  // Store at every lumi section end only if some events have been processed.
646  // Caveat: if faking FilterUnit, i.e. not accessing DAQ2 services,
647  // we cannot ask FastMonitoringService the processed events, so we are forced
648  // to save the file at every lumisection, even with no statistics.
649  // Here, we protect the call to get the processed events in a lumi section
650  // by testing the pointer to FastMonitoringService: if not null, i.e. in real FU mode,
651  // we check that the events are not 0; otherwise, we skip the test, so we store at every lumi transition.
652  // TODO(diguida): allow fake FU mode to skip file creation at empty lumi sections.
653  if (convention_ == FilterUnit && (fms_ ? fms_->shouldWriteFiles(ilumi) : !fms_))
654  {
655  char rewrite[128];
656  sprintf(rewrite, "\\1Run %d/\\2/By Lumi Section %d-%d", irun, ilumi, ilumi);
657  saveForFilterUnit(rewrite, irun, ilumi, fileFormat_);
658  }
659  if (convention_ == Offline)
660  {
661  if (fileFormat_ == ROOT)
662  saveForOffline(workflow_, irun, ilumi);
663  else
664  // TODO(diguida): do we need to support lumisection saving in Offline for PB?
665  // In this case, for ROOT, we only save EventInfo folders: we can filter them...
666  throw cms::Exception("DQMFileSaver")
667  << "Internal error, can save files"
668  << " only in ROOT format.";
669  }
670 
671  // after saving per LS, delete the old LS global histograms.
673  }
674 }
675 
676 void
678 {
679  int irun = iRun.id().run();
680  irun_ = irun;
681  if (irun > 0 && saveByRun_ > 0 && (nrun_ % saveByRun_) == 0)
682  {
683  if (convention_ == Online)
684  {
685  char suffix[64];
686  sprintf(suffix, "_R%09d", irun);
687  char rewrite[64];
688  sprintf(rewrite, "\\1Run %d/\\2/Run summary", irun);
689  if (fileFormat_ == ROOT)
690  saveForOnline(irun, suffix, rewrite);
691  else if (fileFormat_ == PB)
692  saveForOnlinePB(irun, suffix);
693  else
694  throw cms::Exception("DQMFileSaver")
695  << "Internal error, can save files"
696  << " only in ROOT or ProtocolBuffer format.";
697  }
698  else if (convention_ == Offline && fileFormat_ == ROOT)
699  saveForOffline(workflow_, irun, 0);
700  else if (convention_ == Offline && fileFormat_ == PB)
702  else
703  throw cms::Exception("DQMFileSaver")
704  << "Internal error. Can only save files in endRun()"
705  << " in Online and Offline modes.";
706  }
707 
708  // create a fake EoR file for testing purposes.
709  if (fakeFilterUnitMode_) {
710  edm::LogInfo("DQMFileSaver")
711  << "Producing fake EoR file.\n";
712 
713  std::string runDir = str(boost::format("%s/run%06d") % dirName_ % irun);
714  std::string jsonFilePathName = str(boost::format("%s/run%06d_ls0000_EoR.jsn") % runDir % irun);
715  std::string openJsonFilePathName = jsonFilePathName + ".open";
716 
717  boost::filesystem::create_directories(runDir);
718 
719  using namespace boost::property_tree;
720  ptree pt;
721  ptree data;
722 
723  ptree child1, child2, child3;
724 
725  child1.put("", -1); // Processed
726  child2.put("", -1); // Accepted
727  child3.put("", nlumi_); // number of lumi
728 
729  data.push_back(std::make_pair("", child1));
730  data.push_back(std::make_pair("", child2));
731  data.push_back(std::make_pair("", child3));
732 
733  pt.add_child("data", data);
734  pt.put("definition", "/non-existant/");
735  pt.put("source", "--hostname--");
736 
737  std::ofstream file(jsonFilePathName);
738  write_json(file, pt, true);
739  file.close();
740 
741  rename(openJsonFilePathName.c_str(), jsonFilePathName.c_str());
742  }
743 }
744 
745 void
747 {
748  if (saveAtJobEnd_)
749  {
750  if (convention_ == Offline && forceRunNumber_ > 0)
752  else if (convention_ == Offline)
754  else
755  throw cms::Exception("DQMFileSaver")
756  << "Internal error. Can only save files at the end of the"
757  << " job in Offline mode.";
758  }
759 }
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
DQMFileSaver(const edm::ParameterSet &ps)
unsigned int getEventsProcessedForLumi(unsigned int lumi, bool *abortFlag=0)
int forceRunNumber_
Definition: DQMFileSaver.h:77
int saveReferenceQMin_
Definition: DQMFileSaver.h:76
std::shared_ptr< saverDetails::NoCache > globalBeginRun(const edm::Run &, const edm::EventSetup &) const override
static const TGPicture * info(bool iBackgroundIsBlack)
RunID const & id() const
Definition: RunBase.h:39
void saveForOffline(const std::string &workflow, int run, int lumi) const
Definition: DQMFileSaver.cc:87
Definition: rename.py:1
void savePB(std::string const &filename, std::string const &path="", uint32_t run=0, uint32_t lumi=0)
Definition: DQMStore.cc:2650
void globalEndRun(const edm::Run &, const edm::EventSetup &) const override
RunNumber_t run() const
Definition: RunID.h:39
static std::string dataFileExtension(DQMFileSaver::FileFormat fileFormat)
Definition: DQMFileSaver.cc:49
Convention convention_
Definition: DQMFileSaver.h:59
std::string getInitFilePath(std::string const &stream) const
std::vector< MonitorElement * > getMatchingContents(std::string const &pattern, lat::Regexp::Syntax syntaxType=lat::Regexp::Wildcard) const
Definition: DQMStore.cc:1813
evf::FastMonitoringService * fms_
Definition: DQMFileSaver.h:90
#define nullptr
bool shouldWriteFiles(unsigned int lumi, unsigned int *proc=0)
DQMStore * dbe_
Definition: DQMFileSaver.h:82
std::atomic< int > nlumi_
Definition: DQMFileSaver.h:84
std::string dirName_
Definition: DQMFileSaver.h:64
std::string fileBaseName_
Definition: DQMFileSaver.h:79
MonitorElement * bookFloat(char_string const &name)
Book float.
Definition: DQMStore.cc:1048
SaveReferenceTag
Definition: DQMStore.h:78
void Fill(long long x)
int saveByLumiSection_
Definition: DQMFileSaver.h:72
bool enableMultiThread_
Definition: DQMFileSaver.h:69
std::string transferDestination_
Definition: DQMFileSaver.h:94
void saveJobReport(const std::string &filename) const
void deleteUnusedLumiHistograms(uint32_t run, uint32_t lumi)
Definition: DQMStore.cc:2005
static void getAnInt(const edm::ParameterSet &ps, int &value, const std::string &name)
Definition: DQMFileSaver.cc:39
MonitorElement * get(std::string const &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
Definition: DQMStore.cc:1613
bool isAvailable() const
Definition: Service.h:40
RunNumber_t run() const
static std::string onlineOfflineFileName(const std::string &fileBaseName, const std::string &suffix, const std::string &workflow, const std::string &child, DQMFileSaver::FileFormat fileFormat)
Definition: DQMFileSaver.cc:60
void saveForOnline(int run, const std::string &suffix, const std::string &rewrite) const
bool fakeFilterUnitMode_
Definition: DQMFileSaver.h:70
std::shared_ptr< saverDetails::NoCache > globalBeginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) const override
bool runIsComplete_
Definition: DQMFileSaver.h:68
void endJob() override
format
Some error handling for the usage.
Definition: value.py:1
std::string stream_label_
Definition: DQMFileSaver.h:63
std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:1564
MonitorElement * bookString(char_string const &name, char_string const &value)
Book string.
Definition: DQMStore.cc:1069
static const std::string streamPrefix_
Definition: DQMFileSaver.h:92
std::string workflow_
Definition: DQMFileSaver.h:61
std::string getReleaseVersion()
std::string producer_
Definition: DQMFileSaver.h:62
std::string child_
Definition: DQMFileSaver.h:65
int saveReference_
Definition: DQMFileSaver.h:75
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:571
void saveForOnlinePB(int run, const std::string &suffix) const
void cd()
go to top directory (ie. root)
Definition: DQMStore.cc:546
std::string filterName_
Definition: DQMFileSaver.h:66
std::atomic< int > fileUpdate_
Definition: DQMFileSaver.h:80
FileFormat fileFormat_
Definition: DQMFileSaver.h:60
LuminosityBlockNumber_t luminosityBlock() const
tuple msg
Definition: mps_check.py:279
static boost::property_tree::ptree fillJson(int run, int lumi, const std::string &dataFilePathName, const std::string &transferDestinationStr, const std::string &mergeTypeStr, evf::FastMonitoringService *fms)
void save(std::string const &filename, std::string const &path="", std::string const &pattern="", std::string const &rewrite="", uint32_t run=0, uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, std::string const &fileupdate="RECREATE")
Definition: DQMStore.cc:2465
std::atomic< int > irun_
Definition: DQMFileSaver.h:87
void globalEndLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) const override
void saveForOfflinePB(const std::string &workflow, int run) const
Definition: DQMFileSaver.cc:78
bool saveAtJobEnd_
Definition: DQMFileSaver.h:74
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:473
std::atomic< int > nrun_
Definition: DQMFileSaver.h:83
std::string mergeType_
Definition: DQMFileSaver.h:95
static void doSaveForOnline(DQMStore *store, int run, bool enableMultiThread, const std::string &filename, const std::string &directory, const std::string &rxpat, const std::string &rewrite, DQMStore::SaveReferenceTag saveref, int saveRefQMin, const std::string &filterName, DQMFileSaver::FileFormat fileFormat)
static const int STATUS_OK
void beginJob() override
#define str(s)
void analyze(edm::StreamID, const edm::Event &e, const edm::EventSetup &) const override
static const std::string streamSuffix_
Definition: DQMFileSaver.h:93
Definition: Run.h:45
boost::property_tree::ptree fillJson(int run, int lumi, const std::string &dataFilePathName, const std::string &transferDestinationStr, const std::string &mergeTypeStr, evf::FastMonitoringService *fms)
Definition: fillJson.cc:30
void saveForFilterUnit(const std::string &rewrite, int run, int lumi, const FileFormat fileFormat) const
bool enableMultiThread_
Definition: DQMStore.h:637