CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
dqm::DQMFileSaverOnline Class Reference

#include <DQMFileSaverOnline.h>

Inheritance diagram for dqm::DQMFileSaverOnline:
dqm::DQMFileSaverBase edm::global::EDAnalyzer< edm::RunCache< NoCache >, edm::LuminosityBlockCache< NoCache > > edm::global::EDAnalyzerBase edm::EDConsumerBase

Classes

struct  SnapshotFiles
 

Public Member Functions

 DQMFileSaverOnline (const edm::ParameterSet &ps)
 
 ~DQMFileSaverOnline ()
 
- Public Member Functions inherited from dqm::DQMFileSaverBase
 DQMFileSaverBase (const edm::ParameterSet &ps)
 
 ~DQMFileSaverBase ()
 
- Public Member Functions inherited from edm::global::EDAnalyzer< edm::RunCache< NoCache >, edm::LuminosityBlockCache< NoCache > >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::global::EDAnalyzerBase
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from dqm::DQMFileSaverBase
static void fillDescription (edm::ParameterSetDescription &d)
 
- Static Public Member Functions inherited from edm::global::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Protected Member Functions

void appendSnapshot (SnapshotFiles new_snap) const
 
void checkError (const char *msg, const std::string file, int status) const
 
void makeSnapshot (const FileParameters &fp, bool final) const
 
virtual void saveLumi (FileParameters fp) const
 
virtual void saveRun (FileParameters fp) const
 
- Protected Member Functions inherited from dqm::DQMFileSaverBase
virtual void analyze (edm::StreamID, const edm::Event &e, const edm::EventSetup &) const
 
virtual void beginJob (void)
 
virtual void endJob (void)
 
virtual std::shared_ptr< NoCacheglobalBeginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) const
 
virtual std::shared_ptr< NoCacheglobalBeginRun (const edm::Run &, const edm::EventSetup &) const
 
virtual void globalEndLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) const
 
virtual void globalEndRun (const edm::Run &, const edm::EventSetup &) const
 
void logFileAction (const std::string &msg, const std::string &fileName) const
 
virtual void postForkReacquireResources (unsigned int childIndex, unsigned int numberOfChildren)
 
void saveJobReport (const std::string &filename) const
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Protected Attributes

int backupLumiCount_
 
std::list< SnapshotFilessnapshots_
 
std::mutex snapshots_lock_
 
- Protected Attributes inherited from dqm::DQMFileSaverBase
FileParameters initial_fp_
 
std::mutex initial_fp_lock_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Static Protected Member Functions inherited from dqm::DQMFileSaverBase
static const std::string filename (FileParameters fp, bool useLumi=false)
 
static boost::property_tree::ptree fillJson (int run, int lumi, const std::string &dataFilePathName, const std::string transferDestinationStr, evf::FastMonitoringService *fms)
 
static const std::string fillOrigin (const std::string filename, const std::string final_filename)
 

Detailed Description

Definition at line 15 of file DQMFileSaverOnline.h.

Constructor & Destructor Documentation

DQMFileSaverOnline::DQMFileSaverOnline ( const edm::ParameterSet ps)

Definition at line 27 of file DQMFileSaverOnline.cc.

References backupLumiCount_, and edm::ParameterSet::getUntrackedParameter().

28  : DQMFileSaverBase(ps) {
29 
30  backupLumiCount_ = ps.getUntrackedParameter<int>("backupLumiCount", 1);
31 }
DQMFileSaverBase(const edm::ParameterSet &ps)
T getUntrackedParameter(std::string const &, T const &) const
DQMFileSaverOnline::~DQMFileSaverOnline ( )

Definition at line 33 of file DQMFileSaverOnline.cc.

33 {}

Member Function Documentation

void DQMFileSaverOnline::appendSnapshot ( SnapshotFiles  new_snap) const
protected

Definition at line 111 of file DQMFileSaverOnline.cc.

References checkError(), dqm::DQMFileSaverOnline::SnapshotFiles::data, CommonMethods::lock(), dqm::DQMFileSaverBase::logFileAction(), dqm::DQMFileSaverOnline::SnapshotFiles::meta, snapshots_, snapshots_lock_, and x.

Referenced by makeSnapshot().

111  {
112  std::lock_guard<std::mutex> lock(snapshots_lock_);
113 
114  while (! snapshots_.empty()) {
115  SnapshotFiles& x = snapshots_.front();
116 
117  //logFileAction("Deleting old snapshot (origin): ", x.meta);
118  checkError("Unlink failed: ", x.meta, ::unlink(x.meta.c_str()));
119 
120  logFileAction("Deleting old snapshot (root): ", x.data);
121  checkError("Unlink failed: ", x.data, ::unlink(x.data.c_str()));
122 
123  snapshots_.pop_front();
124  }
125 
126  if (! f.data.empty()) {
127  snapshots_.push_back(f);
128  }
129 }
void checkError(const char *msg, const std::string file, int status) const
double f[11][100]
void logFileAction(const std::string &msg, const std::string &fileName) const
std::list< SnapshotFiles > snapshots_
Definition: DDAxes.h:10
void DQMFileSaverOnline::checkError ( const char *  msg,
const std::string  file,
int  status 
) const
protected

Definition at line 131 of file DQMFileSaverOnline.cc.

References dqm::DQMFileSaverBase::logFileAction(), visualization-live-secondInstance_cfg::msg, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by appendSnapshot(), and makeSnapshot().

131  {
132  if (status != 0) {
133  std::string actual_msg = msg;
134  actual_msg += std::strerror(status);
135  logFileAction(actual_msg, file);
136  }
137 }
void logFileAction(const std::string &msg, const std::string &fileName) const
tuple status
Definition: ntuplemaker.py:245
void DQMFileSaverOnline::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 139 of file DQMFileSaverOnline.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), dqm::DQMFileSaverBase::fillDescription(), and edm::ParameterSetDescription::setComment().

140  {
141 
143  desc.setComment("Saves histograms from DQM store, online workflow.");
144 
145  desc.addUntracked<int>("backupLumiCount", 10)->setComment(
146  "How often the backup file will be generated, in lumisections (-1 disables).");
147 
149 
150  descriptions.add("saver", desc);
151 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void setComment(std::string const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescription(edm::ParameterSetDescription &d)
void DQMFileSaverOnline::makeSnapshot ( const FileParameters fp,
bool  final 
) const
protected

Definition at line 49 of file DQMFileSaverOnline.cc.

References appendSnapshot(), checkError(), dqm::DQMFileSaverBase::filename(), MainPageGenerator::files, dqm::DQMFileSaverBase::fillOrigin(), dqm::DQMFileSaverBase::logFileAction(), dqm::DQMFileSaverBase::FileParameters::lumi_, sysUtil::pid, prof2calltree::prefix, dqm::DQMFileSaverBase::FileParameters::run_, dqm::DQMFileSaverBase::saveJobReport(), dqm::DQMFileSaverBase::FileParameters::saveReference_, dqm::DQMFileSaverBase::FileParameters::saveReferenceQMin_, AlCaHLTBitMon_QueryRunRegistry::string, and createPayload::suffix.

Referenced by saveLumi(), and saveRun().

49  {
50  int pid = getpid();
51  char hostname[64];
52  gethostname(hostname, 64);
53  hostname[63] = 0;
54 
55  char suffix[128];
56  if (!final) {
57  snprintf(suffix, 127, ".ls%08ld_host%s_pid%08d", fp.lumi_, hostname, pid);
58  } else {
59  suffix[0] = 0;
60  }
61 
62  std::string prefix = filename(fp, false);
63 
64  std::string root_fp = prefix + ".root" + suffix;
65  std::string meta_fp = prefix + ".root.origin" + suffix;
66 
67  std::string tmp_root_fp = root_fp + ".tmp";
68  std::string tmp_meta_fp = meta_fp + ".tmp";
69 
70  // run_ and lumi_ are ignored if dqmstore is not in multithread mode
72 
73  logFileAction("Writing DQM Root file: ", root_fp);
74  //logFileAction("Writing DQM Origin file: ", meta_fp);
75 
76  char rewrite[128];
77  snprintf(rewrite, 128, "\\1Run %ld/\\2/Run summary", fp.run_);
78 
79  store->save(tmp_root_fp, /* filename */
80  "", /* path */
81  "^(Reference/)?([^/]+)", /* pattern */
82  rewrite, /* rewrite */
83  store->mtEnabled() ? fp.run_ : 0, /* run */
84  0, /* lumi */
85  fp.saveReference_, /* ref */
86  fp.saveReferenceQMin_, /* ref minStatus */
87  "RECREATE", /* fileupdate */
88  false /* resetMEs */
89  );
90 
91  // write metadata
92  // format.origin: md5:d566a34b27f48d507150a332b189398b 294835 /home/dqmprolocal/output/DQM_V0001_FED_R000194224.root
93  std::ofstream meta_fd(tmp_meta_fp);
94  meta_fd << this->fillOrigin(tmp_root_fp, root_fp);
95  meta_fd.close();
96 
97  checkError("Rename failed: ", root_fp, ::rename(tmp_root_fp.c_str(), root_fp.c_str()));
98  checkError("Rename failed: ", meta_fp, ::rename(tmp_meta_fp.c_str(), meta_fp.c_str()));
99 
100  SnapshotFiles files = { root_fp, meta_fp };
101  if (final) {
102  // final will never be cleared
103  appendSnapshot(SnapshotFiles{});
104 
105  saveJobReport(root_fp);
106  } else {
107  appendSnapshot(SnapshotFiles{ root_fp, meta_fp });
108  }
109 }
void saveJobReport(const std::string &filename) const
static const std::string fillOrigin(const std::string filename, const std::string final_filename)
static const std::string filename(FileParameters fp, bool useLumi=false)
void appendSnapshot(SnapshotFiles new_snap) const
void checkError(const char *msg, const std::string file, int status) const
void logFileAction(const std::string &msg, const std::string &fileName) const
tuple pid
Definition: sysUtil.py:22
void DQMFileSaverOnline::saveLumi ( FileParameters  fp) const
protectedvirtual

Reimplemented from dqm::DQMFileSaverBase.

Definition at line 35 of file DQMFileSaverOnline.cc.

References backupLumiCount_, dqm::DQMFileSaverBase::FileParameters::lumi_, and makeSnapshot().

35  {
36  if (backupLumiCount_ > 0) {
37  if (fp.lumi_ % backupLumiCount_ == 0) {
38 
39  // actual saving is done here
40  makeSnapshot(fp, false);
41  }
42  }
43 }
void makeSnapshot(const FileParameters &fp, bool final) const
void DQMFileSaverOnline::saveRun ( FileParameters  fp) const
protectedvirtual

Reimplemented from dqm::DQMFileSaverBase.

Definition at line 45 of file DQMFileSaverOnline.cc.

References makeSnapshot().

45  {
46  makeSnapshot(fp, true);
47 }
void makeSnapshot(const FileParameters &fp, bool final) const

Member Data Documentation

int dqm::DQMFileSaverOnline::backupLumiCount_
protected

Definition at line 25 of file DQMFileSaverOnline.h.

Referenced by DQMFileSaverOnline(), and saveLumi().

std::list<SnapshotFiles> dqm::DQMFileSaverOnline::snapshots_
mutableprotected

Definition at line 37 of file DQMFileSaverOnline.h.

Referenced by appendSnapshot().

std::mutex dqm::DQMFileSaverOnline::snapshots_lock_
mutableprotected

Definition at line 36 of file DQMFileSaverOnline.h.

Referenced by appendSnapshot().