CMS 3D CMS Logo

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 () override
 
- Public Member Functions inherited from dqm::DQMFileSaverBase
 DQMFileSaverBase (const edm::ParameterSet &ps)
 
 ~DQMFileSaverBase () override
 
- Public Member Functions inherited from edm::global::EDAnalyzer< edm::RunCache< NoCache >, edm::LuminosityBlockCache< NoCache > >
 EDAnalyzer ()=default
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
static const std::string fillOrigin (const std::string &filename, const std::string &final_filename)
 
- 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
 
void saveLumi (const FileParameters &fp) const override
 
void saveRun (const FileParameters &fp) const override
 
- Protected Member Functions inherited from dqm::DQMFileSaverBase
void analyze (edm::StreamID, const edm::Event &e, const edm::EventSetup &) const final
 
std::shared_ptr< NoCacheglobalBeginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) const final
 
std::shared_ptr< NoCacheglobalBeginRun (const edm::Run &, const edm::EventSetup &) const final
 
void globalEndLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) const final
 
void globalEndRun (const edm::Run &, const edm::EventSetup &) const final
 
virtual void initRun () const
 
void logFileAction (const std::string &msg, const std::string &fileName) const
 
void saveJobReport (const std::string &filename) const
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Protected Attributes

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

Additional Inherited Members

- Public Types inherited from dqm::DQMFileSaverBase
typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 
- Public Types inherited from edm::global::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Protected Member Functions inherited from dqm::DQMFileSaverBase
static const std::string filename (const FileParameters &fp, bool useLumi=false)
 

Detailed Description

Definition at line 15 of file DQMFileSaverOnline.h.

Constructor & Destructor Documentation

◆ DQMFileSaverOnline()

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

Definition at line 31 of file DQMFileSaverOnline.cc.

31  : DQMFileSaverBase(ps) {
32  backupLumiCount_ = ps.getUntrackedParameter<int>("backupLumiCount", 1);
33  keepBackupLumi_ = ps.getUntrackedParameter<bool>("keepBackupLumi", false);
34 }

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

◆ ~DQMFileSaverOnline()

DQMFileSaverOnline::~DQMFileSaverOnline ( )
overridedefault

Member Function Documentation

◆ appendSnapshot()

void DQMFileSaverOnline::appendSnapshot ( SnapshotFiles  new_snap) const
protected

Definition at line 114 of file DQMFileSaverOnline.cc.

114  {
115  std::lock_guard<std::mutex> lock(snapshots_lock_);
116 
117  if (!keepBackupLumi_) {
118  while (!snapshots_.empty()) {
119  SnapshotFiles& x = snapshots_.front();
120 
121  // logFileAction("Deleting old snapshot (origin): ", x.meta);
122  checkError("Unlink failed: ", x.meta, ::unlink(x.meta.c_str()));
123 
124  logFileAction("Deleting old snapshot (root): ", x.data);
125  checkError("Unlink failed: ", x.data, ::unlink(x.data.c_str()));
126 
127  snapshots_.pop_front();
128  }
129  }
130 
131  if (!f.data.empty()) {
132  snapshots_.push_back(f);
133  }
134 }

References checkError(), f, keepBackupLumi_, CommonMethods::lock(), dqm::DQMFileSaverBase::logFileAction(), snapshots_, and snapshots_lock_.

Referenced by makeSnapshot().

◆ checkError()

void DQMFileSaverOnline::checkError ( const char *  msg,
const std::string &  file,
int  status 
) const
protected

Definition at line 136 of file DQMFileSaverOnline.cc.

136  {
137  if (status != 0) {
138  std::string actual_msg = msg;
139  actual_msg += std::strerror(status);
140  logFileAction(actual_msg, file);
141  }
142 }

References FrontierConditions_GlobalTag_cff::file, dqm::DQMFileSaverBase::logFileAction(), mps_check::msg, mps_update::status, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by appendSnapshot(), and makeSnapshot().

◆ fillDescriptions()

void DQMFileSaverOnline::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 164 of file DQMFileSaverOnline.cc.

164  {
166  desc.setComment("Saves histograms from DQM store, online workflow.");
167 
168  desc.addUntracked<int>("backupLumiCount", 10)
169  ->setComment(
170  "How often the backup file will be generated, in lumisections (-1 "
171  "disables).");
172 
173  desc.addUntracked<bool>("keepBackupLumi", false)
174  ->setComment(
175  "Usually the backup old backup is deleted once the new file is "
176  "available. Setting this to true ensures that no backup files are "
177  "ever deleted. Useful for ML applications, which use backups as a "
178  "'history' of what happened during the run.");
179 
181 
182  // Changed to use addDefault instead of add here because previously
183  // DQMFileSaverOnline and DQMFileSaverPB both used the module label
184  // "saver" which caused conflicting cfi filenames to be generated.
185  // add could be used if unique module labels were given.
186  descriptions.addDefault(desc);
187 }

References edm::ConfigurationDescriptions::addDefault(), submitPVResolutionJobs::desc, and dqm::DQMFileSaverBase::fillDescription().

◆ fillOrigin()

const std::string DQMFileSaverOnline::fillOrigin ( const std::string &  filename,
const std::string &  final_filename 
)
static

Definition at line 144 of file DQMFileSaverOnline.cc.

144  {
145  // format.origin (one line):
146  // md5:d566a34b27f48d507150a332b189398b 294835 final_filename.root
147 
148  unsigned char md5[MD5_DIGEST_LENGTH];
149 
150  boost::iostreams::mapped_file_source fp(filename);
151 
152  MD5((unsigned char*)fp.data(), fp.size(), md5);
153 
154  std::ostringstream hash;
155  for (unsigned char& i : md5) {
156  hash << std::hex << std::setfill('0') << std::setw(2) << (int)i;
157  }
158 
159  std::ostringstream out;
160  out << "md5:" << hash.str() << " " << fp.size() << " " << final_filename;
161  return out.str();
162 }

References dqm::DQMFileSaverBase::filename(), personalPlayback::fp, cond::hash, mps_fire::i, createfilelist::int, and MillePedeFileConverter_cfg::out.

Referenced by makeSnapshot().

◆ makeSnapshot()

void DQMFileSaverOnline::makeSnapshot ( const FileParameters fp,
bool  final 
) const
protected

Definition at line 49 of file DQMFileSaverOnline.cc.

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  // TODO: some parameters prepared here are now unused, and the code should
89  // eventually be removed.
90  LegacyIOHelper h(&*store);
91  h.save(tmp_root_fp, "", fp.run_, /* saveall */ true, "RECREATE");
92 
93  // write metadata
94  // format.origin: md5:d566a34b27f48d507150a332b189398b 294835
95  // /home/dqmprolocal/output/DQM_V0001_FED_R000194224.root
96  std::ofstream meta_fd(tmp_meta_fp);
97  meta_fd << fillOrigin(tmp_root_fp, root_fp);
98  meta_fd.close();
99 
100  checkError("Rename failed: ", root_fp, ::rename(tmp_root_fp.c_str(), root_fp.c_str()));
101  checkError("Rename failed: ", meta_fp, ::rename(tmp_meta_fp.c_str(), meta_fp.c_str()));
102 
103  SnapshotFiles files = {root_fp, meta_fp};
104  if (final) {
105  // final will never be cleared
106  appendSnapshot(SnapshotFiles{});
107 
108  saveJobReport(root_fp);
109  } else {
110  appendSnapshot(SnapshotFiles{root_fp, meta_fp});
111  }
112 }

References appendSnapshot(), checkError(), dqm::DQMFileSaverBase::filename(), submitPVResolutionJobs::files, fillOrigin(), personalPlayback::fp, h, dqm::DQMFileSaverBase::logFileAction(), ZMuMuAnalysisNtupler_cff::prefix, dqm::DQMFileSaverBase::saveJobReport(), AlCaHLTBitMon_QueryRunRegistry::string, and createPayload::suffix.

Referenced by saveLumi(), and saveRun().

◆ saveLumi()

void DQMFileSaverOnline::saveLumi ( const FileParameters fp) const
overrideprotectedvirtual

Reimplemented from dqm::DQMFileSaverBase.

Definition at line 38 of file DQMFileSaverOnline.cc.

38  {
39  if (backupLumiCount_ > 0) {
40  if (fp.lumi_ % backupLumiCount_ == 0) {
41  // actual saving is done here
42  makeSnapshot(fp, false);
43  }
44  }
45 }

References backupLumiCount_, personalPlayback::fp, and makeSnapshot().

◆ saveRun()

void DQMFileSaverOnline::saveRun ( const FileParameters fp) const
overrideprotectedvirtual

Reimplemented from dqm::DQMFileSaverBase.

Definition at line 47 of file DQMFileSaverOnline.cc.

47 { makeSnapshot(fp, true); }

References personalPlayback::fp, and makeSnapshot().

Member Data Documentation

◆ backupLumiCount_

int dqm::DQMFileSaverOnline::backupLumiCount_
protected

Definition at line 27 of file DQMFileSaverOnline.h.

Referenced by DQMFileSaverOnline(), and saveLumi().

◆ keepBackupLumi_

bool dqm::DQMFileSaverOnline::keepBackupLumi_
protected

Definition at line 28 of file DQMFileSaverOnline.h.

Referenced by appendSnapshot(), and DQMFileSaverOnline().

◆ snapshots_

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

Definition at line 40 of file DQMFileSaverOnline.h.

Referenced by appendSnapshot().

◆ snapshots_lock_

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

Definition at line 39 of file DQMFileSaverOnline.h.

Referenced by appendSnapshot().

LegacyIOHelper
Definition: LegacyIOHelper.h:14
dqm::DQMFileSaverOnline::fillOrigin
static const std::string fillOrigin(const std::string &filename, const std::string &final_filename)
Definition: DQMFileSaverOnline.cc:144
mps_fire.i
i
Definition: mps_fire.py:428
dqm::DQMFileSaverBase::logFileAction
void logFileAction(const std::string &msg, const std::string &fileName) const
Definition: DQMFileSaverBase.cc:134
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
mps_update.status
status
Definition: mps_update.py:69
cond::hash
Definition: Time.h:19
dqm::DQMFileSaverBase::filename
static const std::string filename(const FileParameters &fp, bool useLumi=false)
Definition: DQMFileSaverBase.cc:92
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
dqm::DQMFileSaverOnline::makeSnapshot
void makeSnapshot(const FileParameters &fp, bool final) const
Definition: DQMFileSaverOnline.cc:49
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
dqm::DQMFileSaverOnline::keepBackupLumi_
bool keepBackupLumi_
Definition: DQMFileSaverOnline.h:28
DDAxes::x
rename
Definition: rename.py:1
dqm::DQMFileSaverOnline::checkError
void checkError(const char *msg, const std::string &file, int status) const
Definition: DQMFileSaverOnline.cc:136
dqm::DQMFileSaverOnline::appendSnapshot
void appendSnapshot(SnapshotFiles new_snap) const
Definition: DQMFileSaverOnline.cc:114
createPayload.suffix
suffix
Definition: createPayload.py:281
dqm::DQMFileSaverOnline::snapshots_
std::list< SnapshotFiles > snapshots_
Definition: DQMFileSaverOnline.h:40
h
submitPVResolutionJobs.files
files
Definition: submitPVResolutionJobs.py:373
dqm::DQMFileSaverBase::saveJobReport
void saveJobReport(const std::string &filename) const
Definition: DQMFileSaverBase.cc:123
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CommonMethods.lock
def lock()
Definition: CommonMethods.py:82
edm::Service
Definition: Service.h:30
createfilelist.int
int
Definition: createfilelist.py:10
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
dqm::DQMFileSaverOnline::backupLumiCount_
int backupLumiCount_
Definition: DQMFileSaverOnline.h:27
dqm::DQMFileSaverBase::DQMFileSaverBase
DQMFileSaverBase(const edm::ParameterSet &ps)
Definition: DQMFileSaverBase.cc:29
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
dqm::DQMFileSaverOnline::snapshots_lock_
std::mutex snapshots_lock_
Definition: DQMFileSaverOnline.h:39
dqm::DQMFileSaverBase::fillDescription
static void fillDescription(edm::ParameterSetDescription &d)
Definition: DQMFileSaverBase.cc:139
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
ZMuMuAnalysisNtupler_cff.prefix
prefix
Definition: ZMuMuAnalysisNtupler_cff.py:14