13 #include <sys/types.h>
26 if (value < 1 && value != -1)
28 <<
"Invalid '" << name <<
"' parameter '" << value
29 <<
"'. Must be -1 or >= 1.";
37 sprintf(suffix,
"R%09d", run);
41 sprintf(rewrite,
"\\1Run %d/\\2/Run summary", run);
47 wflow.reserve(workflow.size() + 3);
49 while ((pos = wflow.find(
'/', pos)) != std::string::npos)
50 wflow.replace(pos++, 1,
"__");
64 me =
dbe_->
get(
"Info/ProvInfo/runIsComplete");
77 "^(Reference/)?([^/]+)",
87 std::cout <<
" DQMFileSaver: storing EventInfo folders for Run: "
88 <<
irun_ <<
", Lumi Section: " <<
ilumi_ <<
", Subsystems: " ;
90 for (
size_t i = 0,
e = systems.size();
i !=
e; ++
i) {
91 if (systems[
i] !=
"Reference") {
95 systems[
i]+
"/EventInfo",
"^(Reference/)?([^/]+)", rewrite,
117 size_t numKeepSavedFiles,
126 store->
save(filename, directory , rxpat,
127 rewrite, saveref, saveRefQMin);
128 pastSavedFiles.push_back(filename);
129 if (pastSavedFiles.size() > numKeepSavedFiles)
131 remove(pastSavedFiles.front().c_str());
132 pastSavedFiles.pop_front();
141 for (
size_t i = 0,
e = systems.size();
i !=
e; ++
i)
143 if (systems[
i] !=
"Reference")
150 "",
"^(Reference/)?([^/]+)", rewrite,
159 for (
size_t i = 0,
e = systems.size();
i !=
e; ++
i)
160 if (systems[
i] !=
"Reference")
163 std::vector<MonitorElement*> pNamesVector =
dbe_->
getMatchingContents(
"^" + systems[
i] +
"/.*/EventInfo/processName",lat::Regexp::Perl);
164 if (pNamesVector.size() > 0){
167 "",
"^(Reference/)?([^/]+)", rewrite,
170 pNamesVector.clear();
176 for (
size_t i = 0,
e = systems.size();
i !=
e; ++
i)
177 if (systems[
i] !=
"Reference")
180 systems[
i],
"^(Reference/)?([^/]+)", rewrite,
193 std::map<std::string, std::string>
info;
194 info[
"Source"] =
"DQMStore";
195 info[
"FileClass"] =
"DQM";
203 : convention_ (Offline),
209 runIsComplete_ (
false),
210 saveByLumiSection_ (-1),
215 saveAtJobEnd_ (
false),
216 saveReference_ (
DQMStore::SaveWithReference),
217 saveReferenceQMin_ (dqm::qstatus::
STATUS_OK),
218 forceRunNumber_ (-1),
220 fileUpdate_ (
"RECREATE"),
229 numKeepSavedFiles_ (5)
233 if (convention ==
"Offline")
235 else if (convention ==
"Online")
239 <<
"Invalid 'convention' parameter '" << convention <<
"'."
240 <<
" Expected one of 'Online' or 'Offline'.";
250 ||
workflow_.find_first_not_of(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
251 "abcdefghijklmnopqrstuvwxyz"
253 "-_/") != std::string::npos)
255 <<
"Invalid 'workflow' parameter '" <<
workflow_
256 <<
"'. Expected '/A/B/C'.";
260 <<
"The 'workflow' parameter must be empty in 'Online' convention.";
274 <<
"Invalid 'producer' parameter '" <<
producer_
275 <<
"'. Expected 'DQM', 'HLTDQM' or 'Playback'.";
280 <<
"Invalid 'producer' parameter '" <<
producer_
281 <<
"'. Expected 'DQM'.";
291 if (refsave ==
"default")
293 else if (refsave ==
"skip")
298 else if (refsave ==
"all")
303 else if (refsave ==
"qtests")
310 <<
"Invalid 'referenceHandling' parameter '" << refsave
311 <<
"'. Expected 'default', 'skip', 'all' or 'qtests'.";
319 if (dirName_.empty() || stat(dirName_.c_str(), &
s) == -1)
321 <<
"Invalid 'dirName' parameter '" << dirName_ <<
"'.";
349 <<
"If saving at the end of the job, the run number must be"
350 <<
" overridden to a specific value using 'forceRunNumber'.";
355 sprintf(version,
"_V%04d_",
int(
version_));
363 <<
"DQM file saving settings:\n"
369 <<
" saving every 2^n*" <<
saveByTime_ <<
" minutes \n"
370 <<
" saving every " <<
saveByRun_ <<
" run(s)\n"
371 <<
" saving at job end: " << (
saveAtJobEnd_ ?
"yes" :
"no") <<
"\n"
410 <<
"Internal error, can save files by event"
411 <<
" only in Online mode.";
423 <<
"Internal error, can save files by time"
424 <<
" only in Online mode.";
428 gettimeofday(&tv, 0);
430 double totalelapsed = ((tv.tv_sec + tv.tv_usec*1e-6)
432 double elapsed = ((tv.tv_sec + tv.tv_usec*1e-6)
441 sprintf(suffix,
"_R%09d_T%08d",
irun_,
int(totalelapsed));
442 char rewrite[64]; sprintf(rewrite,
"\\1Run %d/\\2/Run summary",
irun_);
456 <<
"Internal error, can save files at end of lumi block"
457 <<
" only in Online or Offline mode.";
482 char rewrite[64]; sprintf(rewrite,
"\\1Run %d/\\2/Run summary",
irun_);
489 <<
"Internal error. Can only save files in endRun()"
490 <<
" in Online and Offline modes.";
505 <<
"Internal error. Can only save files at the end of the"
506 <<
" job in Offline mode with run number overridden.";
515 unsigned int digits = 0;
516 while (numberOfChildren != 0) {
518 numberOfChildren /= 10;
525 char buffer[digits + 2];
526 snprintf(buffer, digits + 2,
"_%0*d", digits, childIndex);
LuminosityBlockID id() const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
DQMFileSaver(const edm::ParameterSet &ps)
std::vector< std::string > getSubdirs(void) const
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
void saveForOnline(const std::string &suffix, const std::string &rewrite)
void cd(void)
go to top directory (ie. root)
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
std::list< std::string > pastSavedFiles_
std::vector< MonitorElement * > getMatchingContents(const std::string &pattern, lat::Regexp::Syntax syntaxType=lat::Regexp::Wildcard) const
void saveJobReport(const std::string &filename)
std::string fileBaseName_
static void doSaveForOnline(std::list< std::string > &pastSavedFiles, size_t numKeepSavedFiles, DQMStore *store, const std::string &filename, const std::string &directory, const std::string &rxpat, const std::string &rewrite, DQMStore::SaveReferenceTag saveref, int saveRefQMin)
MonitorElement * bookFloat(const char *name)
Book float.
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
static void getAnInt(const edm::ParameterSet &ps, int &value, const std::string &name)
MonitorElement * bookString(const char *name, const char *value)
Book string.
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
std::string getReleaseVersion()
LuminosityBlockNumber_t luminosityBlock() const
virtual void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
void saveForOffline(const std::string &workflow, int run, int lumi)
virtual void analyze(const edm::Event &e, const edm::EventSetup &)
static const int STATUS_OK
virtual void postForkReacquireResources(unsigned int childIndex, unsigned int numberOfChildren)
virtual void endRun(const edm::Run &, const edm::EventSetup &)
virtual void beginJob(void)
virtual void endJob(void)
void setCurrentFolder(const std::string &fullpath)