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/)?([^/]+)",
88 std::cout <<
" DQMFileSaver: storing EventInfo folders for Run: "
89 <<
irun_ <<
", Lumi Section: " <<
ilumi_ <<
", Subsystems: " ;
91 for (
size_t i = 0,
e = systems.size();
i !=
e; ++
i) {
92 if (systems[
i] !=
"Reference") {
96 systems[
i]+
"/EventInfo",
"^(Reference/)?([^/]+)",
120 size_t numKeepSavedFiles,
131 store->
save(filename,
138 pastSavedFiles.push_back(filename);
139 if (pastSavedFiles.size() > numKeepSavedFiles)
141 remove(pastSavedFiles.front().c_str());
142 pastSavedFiles.pop_front();
151 for (
size_t i = 0,
e = systems.size();
i !=
e; ++
i)
153 if (systems[
i] !=
"Reference")
160 "",
"^(Reference/)?([^/]+)", rewrite,
169 for (
size_t i = 0,
e = systems.size();
i !=
e; ++
i)
170 if (systems[
i] !=
"Reference")
173 std::vector<MonitorElement*> pNamesVector =
dbe_->
getMatchingContents(
"^" + systems[
i] +
"/.*/EventInfo/processName",lat::Regexp::Perl);
174 if (pNamesVector.size() > 0){
177 "",
"^(Reference/)?([^/]+)", rewrite,
180 pNamesVector.clear();
186 for (
size_t i = 0,
e = systems.size();
i !=
e; ++
i)
187 if (systems[
i] !=
"Reference")
190 systems[
i],
"^(Reference/)?([^/]+)", rewrite,
203 std::map<std::string, std::string>
info;
204 info[
"Source"] =
"DQMStore";
205 info[
"FileClass"] =
"DQM";
213 : convention_ (Offline),
219 runIsComplete_ (
false),
220 enableMultiThread_(ps.getUntrackedParameter<bool>(
"enableMultiThread",
false)),
221 saveByLumiSection_ (-1),
226 saveAtJobEnd_ (
false),
227 saveReference_ (
DQMStore::SaveWithReference),
228 saveReferenceQMin_ (dqm::qstatus::
STATUS_OK),
229 forceRunNumber_ (-1),
231 fileUpdate_ (
"RECREATE"),
240 numKeepSavedFiles_ (5)
244 if (convention ==
"Offline")
246 else if (convention ==
"Online")
250 <<
"Invalid 'convention' parameter '" << convention <<
"'."
251 <<
" Expected one of 'Online' or 'Offline'.";
261 ||
workflow_.find_first_not_of(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
262 "abcdefghijklmnopqrstuvwxyz"
264 "-_/") != std::string::npos)
266 <<
"Invalid 'workflow' parameter '" <<
workflow_
267 <<
"'. Expected '/A/B/C'.";
271 <<
"The 'workflow' parameter must be empty in 'Online' convention.";
285 <<
"Invalid 'producer' parameter '" <<
producer_
286 <<
"'. Expected 'DQM', 'HLTDQM' or 'Playback'.";
291 <<
"Invalid 'producer' parameter '" <<
producer_
292 <<
"'. Expected 'DQM'.";
302 if (refsave ==
"default")
304 else if (refsave ==
"skip")
309 else if (refsave ==
"all")
314 else if (refsave ==
"qtests")
321 <<
"Invalid 'referenceHandling' parameter '" << refsave
322 <<
"'. Expected 'default', 'skip', 'all' or 'qtests'.";
330 if (dirName_.empty() || stat(dirName_.c_str(), &
s) == -1)
332 <<
"Invalid 'dirName' parameter '" << dirName_ <<
"'.";
360 <<
"If saving at the end of the job, the run number must be"
361 <<
" overridden to a specific value using 'forceRunNumber'.";
366 sprintf(version,
"_V%04d_",
int(
version_));
374 <<
"DQM file saving settings:\n"
380 <<
" saving every 2^n*" <<
saveByTime_ <<
" minutes \n"
381 <<
" saving every " <<
saveByRun_ <<
" run(s)\n"
382 <<
" saving at job end: " << (
saveAtJobEnd_ ?
"yes" :
"no") <<
"\n"
421 <<
"Internal error, can save files by event"
422 <<
" only in Online mode.";
434 <<
"Internal error, can save files by time"
435 <<
" only in Online mode.";
439 gettimeofday(&tv, 0);
441 double totalelapsed = ((tv.tv_sec + tv.tv_usec*1e-6)
443 double elapsed = ((tv.tv_sec + tv.tv_usec*1e-6)
452 sprintf(suffix,
"_R%09d_T%08d",
irun_,
int(totalelapsed));
453 char rewrite[64]; sprintf(rewrite,
"\\1Run %d/\\2/Run summary",
irun_);
467 <<
"Internal error, can save files at end of lumi block"
468 <<
" only in Online or Offline mode.";
493 char rewrite[64]; sprintf(rewrite,
"\\1Run %d/\\2/Run summary",
irun_);
500 <<
"Internal error. Can only save files in endRun()"
501 <<
" in Online and Offline modes.";
516 <<
"Internal error. Can only save files at the end of the"
517 <<
" job in Offline mode with run number overridden.";
526 unsigned int digits = 0;
527 while (numberOfChildren != 0) {
529 numberOfChildren /= 10;
536 char buffer[digits + 2];
537 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)
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.
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
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 reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
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 &)
volatile std::atomic< bool > shutdown_flag false
virtual void beginJob(void)
virtual void endJob(void)
void setCurrentFolder(const std::string &fullpath)