CMS 3D CMS Logo

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