CMS 3D CMS Logo

DQMFileSaverBase.cc
Go to the documentation of this file.
11 
12 #include "DQMFileSaverBase.h"
13 
14 #include <sys/stat.h>
15 #include <sys/types.h>
16 #include <unistd.h>
17 #include <iostream>
18 #include <vector>
19 #include <string>
20 #include <fstream>
21 #include <utility>
22 #include <TString.h>
23 #include <TSystem.h>
24 
25 using namespace dqm;
26 
28  FileParameters fp;
29 
30  fp.path_ = ps.getUntrackedParameter<std::string>("path");
31  fp.producer_ = ps.getUntrackedParameter<std::string>("producer");
32  fp.run_ = 0;
33  fp.tag_ = ps.getUntrackedParameter<std::string>("tag");
34  fp.lumi_ = 0;
35  fp.version_ = 1;
36  fp.child_ = "";
37 
39  // Check how we should save the references.
40  std::string refsave = ps.getUntrackedParameter<std::string>("referenceHandling", "all");
41  if (refsave == "skip")
42  {
44  }
45  else if (refsave == "all")
46  {
48  }
49  else if (refsave == "qtests")
50  {
52  }
53  else {
54  //edm::LogInfo("DQMFileSaverBase")
55  std::cerr
56  << "Invalid 'referenceHandling' parameter '" << refsave
57  << "'. Expected 'skip', 'all' or 'qtests'.";
58 
59  }
60 
61  // Check minimum required quality test result for which reference is saved.
62  fp.saveReferenceQMin_ = ps.getUntrackedParameter<int>("referenceRequireStatus", dqm::qstatus::STATUS_OK);
63 
64  std::unique_lock<std::mutex> lck(initial_fp_lock_);
65  initial_fp_ = fp;
66 }
67 
69 
70 std::shared_ptr<NoCache> DQMFileSaverBase::globalBeginRun(
71  const edm::Run &r, const edm::EventSetup &) const {
72 
73  this->initRun();
74 
75  return nullptr;
76 }
77 
79  const edm::LuminosityBlock &l, const edm::EventSetup &) const {
80 
81  return nullptr;
82 }
83 
85  const edm::EventSetup &) const {
86  // not supported
87 }
88 
90  const edm::EventSetup &) const {
91  int ilumi = iLS.id().luminosityBlock();
92  int irun = iLS.id().run();
93 
94  std::unique_lock<std::mutex> lck(initial_fp_lock_);
96  lck.unlock();
97 
98  fp.lumi_ = ilumi;
99  fp.run_ = irun;
100 
101  this->saveLumi(fp);
102 
104  store->deleteUnusedLumiHistograms(store->mtEnabled() ? irun : 0, ilumi);
105 }
106 
108  const edm::EventSetup &) const {
109 
110  std::unique_lock<std::mutex> lck(initial_fp_lock_);
112  lck.unlock();
113 
114  fp.run_ = iRun.id().run();
115 
116  // empty
117  this->saveRun(fp);
118 }
119 
120 const std::string DQMFileSaverBase::filename(const FileParameters& fp, bool useLumi) {
121  char buf[256];
122  if (useLumi) {
123  snprintf(buf, 256, "%s_V%04d_%s_R%09ld_L%09ld%s", fp.producer_.c_str(),
124  fp.version_, fp.tag_.c_str(), fp.run_, fp.lumi_,
125  fp.child_.c_str());
126  } else {
127  snprintf(buf, 256, "%s_V%04d_%s_R%09ld%s", fp.producer_.c_str(), fp.version_,
128  fp.tag_.c_str(), fp.run_, fp.child_.c_str());
129  }
130  buf[255] = 0;
131 
132  namespace fs = boost::filesystem;
133  fs::path path(fp.path_);
134  fs::path file(buf);
135 
136  return (path / file).string();
137 }
138 
140 {
141  // Report the file to job report service.
143  if (jr.isAvailable())
144  {
145  std::map<std::string, std::string> info;
146  info["Source"] = "DQMStore";
147  info["FileClass"] = "DQM";
148  jr->reportAnalysisFile(filename, info);
149  }
150 
151 }
152 
154  edm::LogAbsolute("fileAction") << std::setprecision(0) << edm::TimeOfDay()
155  << " " << msg << fileName;
157 }
158 
160  desc.addUntracked<std::string>("tag", "UNKNOWN")
161  ->setComment("File tag, DQM_V000_<TAG>*, usually a subsytem name.");
162 
163  desc.addUntracked<std::string>("producer", "DQM")
164  ->setComment("Base prefix for files, <BASE>_V000_**, either 'DQM' or 'Playback'.");
165 
166  desc.addUntracked<std::string>("referenceHandling", "all")
167  ->setComment("saveReference_, passed to the DQMStore");
168 
169  desc.addUntracked<int>("referenceRequireStatus", dqm::qstatus::STATUS_OK)
170  ->setComment("saveReference_, passed to the DQMStore");
171 
172  desc.addUntracked<std::string>("path", "./")->setComment(
173  "Output path prefix.");
174 }
DQMFileSaverBase(const edm::ParameterSet &ps)
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
static const TGPicture * info(bool iBackgroundIsBlack)
void saveJobReport(const std::string &filename) const
RunID const & id() const
Definition: RunBase.h:39
virtual void saveRun(const FileParameters &fp) const
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
RunNumber_t run() const
Definition: RunID.h:39
void FlushMessageLog()
~DQMFileSaverBase() override
static const std::string filename(const FileParameters &fp, bool useLumi=false)
virtual void saveLumi(const FileParameters &fp) const
virtual void initRun() const
bool isAvailable() const
Definition: Service.h:46
std::shared_ptr< NoCache > globalBeginRun(const edm::Run &, const edm::EventSetup &) const final
RunNumber_t run() const
void analyze(edm::StreamID, const edm::Event &e, const edm::EventSetup &) const final
std::shared_ptr< NoCache > globalBeginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) const final
void logFileAction(const std::string &msg, const std::string &fileName) const
void globalEndRun(const edm::Run &, const edm::EventSetup &) const final
DQMStore::SaveReferenceTag saveReference_
LuminosityBlockNumber_t luminosityBlock() const
tuple msg
Definition: mps_check.py:278
FileParameters initial_fp_
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:507
static const int STATUS_OK
static void fillDescription(edm::ParameterSetDescription &d)
void globalEndLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) const final
Definition: Run.h:44