CMS 3D CMS Logo

DQMFileSaverBase.cc
Go to the documentation of this file.
12 
13 #include "DQMFileSaverBase.h"
14 
15 #include <sys/stat.h>
16 #include <sys/types.h>
17 #include <unistd.h>
18 #include <iostream>
19 #include <vector>
20 #include <string>
21 #include <fstream>
22 #include <utility>
23 #include <filesystem>
24 #include <TString.h>
25 #include <TSystem.h>
26 
27 using namespace dqm;
28 
31 
32  fp.path_ = ps.getUntrackedParameter<std::string>("path");
33  fp.producer_ = ps.getUntrackedParameter<std::string>("producer");
34  fp.run_ = 0;
35  fp.tag_ = ps.getUntrackedParameter<std::string>("tag");
36  fp.lumi_ = 0;
37  fp.version_ = 1;
38  fp.child_ = "";
39 
40  std::unique_lock<std::mutex> lck(initial_fp_lock_);
41  initial_fp_ = fp;
42 
43  runNumber_ = ps.getUntrackedParameter<int>("runNumber", 111);
44 
45  // This makes sure a file saver runs in a very end
46  consumesMany<DQMToken, edm::InLumi>();
47  consumesMany<DQMToken, edm::InRun>();
48 }
49 
51 
52 std::shared_ptr<NoCache> DQMFileSaverBase::globalBeginRun(const edm::Run &r, const edm::EventSetup &) const {
53  this->initRun();
54 
55  return nullptr;
56 }
57 
59  const edm::EventSetup &) const {
60  return nullptr;
61 }
62 
64  // not supported
65 }
66 
68  int ilumi = iLS.id().luminosityBlock();
69  int irun = iLS.id().run();
70 
71  std::unique_lock<std::mutex> lck(initial_fp_lock_);
73  lck.unlock();
74 
75  fp.lumi_ = ilumi;
76  fp.run_ = runNumber_ == 111 ? irun : runNumber_;
77 
78  this->saveLumi(fp);
79 }
80 
81 void DQMFileSaverBase::globalEndRun(const edm::Run &iRun, const edm::EventSetup &) const {
82  std::unique_lock<std::mutex> lck(initial_fp_lock_);
84  lck.unlock();
85 
86  fp.run_ = runNumber_ == 111 ? iRun.id().run() : runNumber_;
87 
88  // empty
89  this->saveRun(fp);
90 }
91 
93  char buf[256];
94  if (useLumi) {
95  snprintf(buf,
96  256,
97  "%s_V%04d_%s_R%09ld_L%09ld%s",
98  fp.producer_.c_str(),
99  fp.version_,
100  fp.tag_.c_str(),
101  fp.run_,
102  fp.lumi_,
103  fp.child_.c_str());
104  } else {
105  snprintf(buf,
106  256,
107  "%s_V%04d_%s_R%09ld%s",
108  fp.producer_.c_str(),
109  fp.version_,
110  fp.tag_.c_str(),
111  fp.run_,
112  fp.child_.c_str());
113  }
114  buf[255] = 0;
115 
116  namespace fs = std::filesystem;
117  fs::path path(fp.path_);
118  fs::path file(buf);
119 
120  return (path / file).string();
121 }
122 
124  // Report the file to job report service.
126  if (jr.isAvailable()) {
127  std::map<std::string, std::string> info;
128  info["Source"] = "DQMStore";
129  info["FileClass"] = "DQM";
131  }
132 }
133 
135  edm::LogAbsolute("fileAction") << std::setprecision(0) << edm::TimeOfDay() << " " << msg << fileName;
137 }
138 
140  desc.addUntracked<std::string>("tag", "UNKNOWN")->setComment("File tag, DQM_V000_<TAG>*, usually a subsytem name.");
141 
142  desc.addUntracked<std::string>("producer", "DQM")
143  ->setComment("Base prefix for files, <BASE>_V000_**, either 'DQM' or 'Playback'.");
144 
145  desc.addUntracked<std::string>("referenceHandling", "all")->setComment("saveReference_, passed to the DQMStore");
146 
147  desc.addUntracked<int>("referenceRequireStatus", dqm::qstatus::STATUS_OK)
148  ->setComment("saveReference_, passed to the DQMStore");
149 
150  desc.addUntracked<std::string>("path", "./")->setComment("Output path prefix.");
151 
152  desc.addUntracked<int>("runNumber", 111)
153  ->setComment("Run number passed in the configuration. Will appear in output file names.");
154 }
DQMFileSaverBase.h
edm::StreamID
Definition: StreamID.h:30
dqm::DQMFileSaverBase::FileParameters
Definition: DQMFileSaverBase.h:33
MessageLogger.h
dqm::DQMFileSaverBase::globalEndLuminosityBlock
void globalEndLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) const final
Definition: DQMFileSaverBase.cc:67
edm::TimeOfDay
Definition: TimeOfDay.h:9
dqm::DQMFileSaverBase::logFileAction
void logFileAction(const std::string &msg, const std::string &fileName) const
Definition: DQMFileSaverBase.cc:134
dqm::DQMFileSaverBase::saveLumi
virtual void saveLumi(const FileParameters &fp) const
Definition: DQMFileSaverBase.h:60
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::RunID::run
RunNumber_t run() const
Definition: RunID.h:36
edm::Run
Definition: Run.h:45
LuminosityBlock.h
dqm::DQMFileSaverBase::filename
static const std::string filename(const FileParameters &fp, bool useLumi=false)
Definition: DQMFileSaverBase.cc:92
edm::JobReport::reportAnalysisFile
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:473
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
dqm::DQMFileSaverBase::analyze
void analyze(edm::StreamID, const edm::Event &e, const edm::EventSetup &) const final
Definition: DQMFileSaverBase.cc:63
DQMStore.h
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
personalPlayback.fp
fp
Definition: personalPlayback.py:523
mps_check.msg
tuple msg
Definition: mps_check.py:285
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
MillePedeFileConverter_cfg.fileName
fileName
Definition: MillePedeFileConverter_cfg.py:32
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
dqm::DQMFileSaverBase::~DQMFileSaverBase
~DQMFileSaverBase() override
dqm::DQMFileSaverBase::initRun
virtual void initRun() const
Definition: DQMFileSaverBase.h:59
dqm::DQMFileSaverBase::initial_fp_lock_
std::mutex initial_fp_lock_
Definition: DQMFileSaverBase.h:70
dqm::DQMFileSaverBase::saveRun
virtual void saveRun(const FileParameters &fp) const
Definition: DQMFileSaverBase.h:61
DQMToken.h
Service.h
Run.h
dqm::DQMFileSaverBase::runNumber_
int runNumber_
Definition: DQMFileSaverBase.h:72
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
dqm::DQMFileSaverBase::saveJobReport
void saveJobReport(const std::string &filename) const
Definition: DQMFileSaverBase.cc:123
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
dqm::DQMFileSaverBase::globalBeginLuminosityBlock
std::shared_ptr< NoCache > globalBeginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) const final
Definition: DQMFileSaverBase.cc:58
edm::FlushMessageLog
void FlushMessageLog()
Definition: MessageLogger.cc:34
edm::ParameterSet
Definition: ParameterSet.h:47
GetReleaseVersion.h
Event.h
dqm::DQMFileSaverBase::initial_fp_
FileParameters initial_fp_
Definition: DQMFileSaverBase.h:71
edm::Service
Definition: Service.h:30
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
edm::LuminosityBlockID::luminosityBlock
LuminosityBlockNumber_t luminosityBlock() const
Definition: LuminosityBlockID.h:42
edm::LuminosityBlockBase::id
LuminosityBlockID id() const
Definition: LuminosityBlockBase.h:44
edm::LogAbsolute
Log< level::System, true > LogAbsolute
Definition: MessageLogger.h:134
edm::EventSetup
Definition: EventSetup.h:57
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
alignCSCRings.r
r
Definition: alignCSCRings.py:93
dqm::DQMFileSaverBase::globalBeginRun
std::shared_ptr< NoCache > globalBeginRun(const edm::Run &, const edm::EventSetup &) const final
Definition: DQMFileSaverBase.cc:52
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
dqm::DQMFileSaverBase::globalEndRun
void globalEndRun(const edm::Run &, const edm::EventSetup &) const final
Definition: DQMFileSaverBase.cc:81
dqm::qstatus::STATUS_OK
static const int STATUS_OK
Definition: MonitorElement.h:52
edm::LuminosityBlockID::run
RunNumber_t run() const
Definition: LuminosityBlockID.h:41
dqm::DQMFileSaverBase::DQMFileSaverBase
DQMFileSaverBase(const edm::ParameterSet &ps)
Definition: DQMFileSaverBase.cc:29
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
dqm
Definition: DQMStore.h:18
JobReport.h
ParameterSet.h
TimeOfDay.h
dqm::DQMFileSaverBase::fillDescription
static void fillDescription(edm::ParameterSetDescription &d)
Definition: DQMFileSaverBase.cc:139
edm::Event
Definition: Event.h:73
edm::RunBase::id
RunID const & id() const
Definition: RunBase.h:39
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37