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 <TString.h>
24 #include <TSystem.h>
25 
26 using namespace dqm;
27 
30 
31  fp.path_ = ps.getUntrackedParameter<std::string>("path");
32  fp.producer_ = ps.getUntrackedParameter<std::string>("producer");
33  fp.run_ = 0;
34  fp.tag_ = ps.getUntrackedParameter<std::string>("tag");
35  fp.lumi_ = 0;
36  fp.version_ = 1;
37  fp.child_ = "";
38 
39  std::unique_lock<std::mutex> lck(initial_fp_lock_);
40  initial_fp_ = fp;
41 
42  runNumber_ = ps.getUntrackedParameter<int>("runNumber", 111);
43 
44  // This makes sure a file saver runs in a very end
45  consumesMany<DQMToken, edm::InLumi>();
46  consumesMany<DQMToken, edm::InRun>();
47 }
48 
50 
51 std::shared_ptr<NoCache> DQMFileSaverBase::globalBeginRun(const edm::Run &r, const edm::EventSetup &) const {
52  this->initRun();
53 
54  return nullptr;
55 }
56 
58  const edm::EventSetup &) const {
59  return nullptr;
60 }
61 
63  // not supported
64 }
65 
67  int ilumi = iLS.id().luminosityBlock();
68  int irun = iLS.id().run();
69 
70  std::unique_lock<std::mutex> lck(initial_fp_lock_);
72  lck.unlock();
73 
74  fp.lumi_ = ilumi;
75  fp.run_ = runNumber_ == 111 ? irun : runNumber_;
76 
77  this->saveLumi(fp);
78 }
79 
80 void DQMFileSaverBase::globalEndRun(const edm::Run &iRun, const edm::EventSetup &) const {
81  std::unique_lock<std::mutex> lck(initial_fp_lock_);
83  lck.unlock();
84 
85  fp.run_ = runNumber_ == 111 ? iRun.id().run() : runNumber_;
86 
87  // empty
88  this->saveRun(fp);
89 }
90 
92  char buf[256];
93  if (useLumi) {
94  snprintf(buf,
95  256,
96  "%s_V%04d_%s_R%09ld_L%09ld%s",
97  fp.producer_.c_str(),
98  fp.version_,
99  fp.tag_.c_str(),
100  fp.run_,
101  fp.lumi_,
102  fp.child_.c_str());
103  } else {
104  snprintf(buf,
105  256,
106  "%s_V%04d_%s_R%09ld%s",
107  fp.producer_.c_str(),
108  fp.version_,
109  fp.tag_.c_str(),
110  fp.run_,
111  fp.child_.c_str());
112  }
113  buf[255] = 0;
114 
115  namespace fs = boost::filesystem;
116  fs::path path(fp.path_);
117  fs::path file(buf);
118 
119  return (path / file).string();
120 }
121 
123  // Report the file to job report service.
125  if (jr.isAvailable()) {
126  std::map<std::string, std::string> info;
127  info["Source"] = "DQMStore";
128  info["FileClass"] = "DQM";
130  }
131 }
132 
134  edm::LogAbsolute("fileAction") << std::setprecision(0) << edm::TimeOfDay() << " " << msg << fileName;
136 }
137 
139  desc.addUntracked<std::string>("tag", "UNKNOWN")->setComment("File tag, DQM_V000_<TAG>*, usually a subsytem name.");
140 
141  desc.addUntracked<std::string>("producer", "DQM")
142  ->setComment("Base prefix for files, <BASE>_V000_**, either 'DQM' or 'Playback'.");
143 
144  desc.addUntracked<std::string>("referenceHandling", "all")->setComment("saveReference_, passed to the DQMStore");
145 
146  desc.addUntracked<int>("referenceRequireStatus", dqm::qstatus::STATUS_OK)
147  ->setComment("saveReference_, passed to the DQMStore");
148 
149  desc.addUntracked<std::string>("path", "./")->setComment("Output path prefix.");
150 
151  desc.addUntracked<int>("runNumber", 111)
152  ->setComment("Run number passed in the configuration. Will appear in output file names.");
153 }
DQMFileSaverBase.h
edm::LogAbsolute
Definition: MessageLogger.h:469
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:66
edm::TimeOfDay
Definition: TimeOfDay.h:9
dqm::DQMFileSaverBase::logFileAction
void logFileAction(const std::string &msg, const std::string &fileName) const
Definition: DQMFileSaverBase.cc:133
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:91
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:62
DQMStore.h
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
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:122
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:57
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:100
edm::FlushMessageLog
void FlushMessageLog()
Definition: MessageLogger.cc:94
edm::ParameterSet
Definition: ParameterSet.h:36
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::EventSetup
Definition: EventSetup.h:57
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
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:51
dqm::DQMFileSaverBase::globalEndRun
void globalEndRun(const edm::Run &, const edm::EventSetup &) const final
Definition: DQMFileSaverBase.cc:80
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:28
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:138
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