CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
DQMFileSaver Class Reference
Inheritance diagram for DQMFileSaver:
edm::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Types

typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 
- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 DQMFileSaver (const edm::ParameterSet &ps)
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 EDAnalyzer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () 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
 
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)
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &) override
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void endJob () override
 
void endRun (const edm::Run &, const edm::EventSetup &) override
 
- 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>
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<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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)
 

Private Member Functions

void saveForOffline (const std::string &workflow, int run, int lumi)
 
void saveJobReport (const std::string &filename)
 

Private Attributes

std::string child_
 
DQMStoredbe_
 
std::string dirName_
 
std::string fileBaseName_
 
int forceRunNumber_
 
int irun_
 
int nrun_
 
std::string producer_
 
bool runIsComplete_
 
bool saveAtJobEnd_
 
int saveByRun_
 
std::string stream_label_
 
int version_
 
std::string workflow_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Detailed Description

Definition at line 28 of file DQMFileSaver.cc.

Member Typedef Documentation

◆ DQMStore

Definition at line 30 of file DQMFileSaver.cc.

◆ MonitorElement

Definition at line 31 of file DQMFileSaver.cc.

Constructor & Destructor Documentation

◆ DQMFileSaver()

DQMFileSaver::DQMFileSaver ( const edm::ParameterSet ps)

Definition at line 134 of file DQMFileSaver.cc.

135  :
136 
137  workflow_(""),
138  producer_("DQM"),
139  dirName_("."),
140  child_(""),
141  version_(1),
142  runIsComplete_(false),
143  saveByRun_(-1),
144  saveAtJobEnd_(false),
145  forceRunNumber_(-1),
146  fileBaseName_(""),
148  nrun_(0),
149  irun_(0) {
150  // Note: this is insufficient, we also need to enforce running *after* all
151  // DQMEDAnalyzers (a.k.a. EDProducers) in endJob.
152  // This is not supported in edm currently.
153  consumesMany<DQMToken, edm::InRun>();
155  if (workflow_.empty() || workflow_[0] != '/' || *workflow_.rbegin() == '/' ||
156  std::count(workflow_.begin(), workflow_.end(), '/') != 3 ||
157  workflow_.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
158  "abcdefghijklmnopqrstuvwxyz"
159  "0123456789"
160  "-_/") != std::string::npos)
161  throw cms::Exception("DQMFileSaver") << "Invalid 'workflow' parameter '" << workflow_ << "'. Expected '/A/B/C'.";
162 
163  // version number to be used in filename
164  // Note that version *must* always be 1 vor DQMGUI upload.
165  version_ = ps.getUntrackedParameter<int>("version", version_);
166  // flag to signal that file contains data from complete run
167  runIsComplete_ = ps.getUntrackedParameter<bool>("runIsComplete", runIsComplete_);
168 
169  // Get and check the output directory.
170  struct stat s;
172  if (dirName_.empty() || stat(dirName_.c_str(), &s) == -1)
173  throw cms::Exception("DQMFileSaver") << "Invalid 'dirName' parameter '" << dirName_ << "'.";
174 
175  // Find out when and how to save files. The following contraints apply:
176  // - For offline allow files to be saved per run, at job end, and run number to be overridden (for mc data).
177 
178  getAnInt(ps, saveByRun_, "saveByRun");
179  getAnInt(ps, forceRunNumber_, "forceRunNumber");
180  saveAtJobEnd_ = ps.getUntrackedParameter<bool>("saveAtJobEnd", saveAtJobEnd_);
181 
182  // Set up base file name:
183  // - for online and offline, follow the convention <dirName>/<producer>_V<4digits>_
184  char version[8];
185  sprintf(version, "_V%04d_", int(version_));
186  version[7] = '\0';
188 
189  // Log some information what we will do.
190  edm::LogInfo("DQMFileSaver") << "DQM file saving settings:\n"
191  << " using base file name '" << fileBaseName_ << "'\n"
192  << " forcing run number " << forceRunNumber_ << "\n"
193  << " saving every " << saveByRun_ << " run(s)\n"
194  << " saving at job end: " << (saveAtJobEnd_ ? "yes" : "no") << "\n";
195 }

References KineDebug3::count(), dirName_, Exception, fileBaseName_, forceRunNumber_, getAnInt(), edm::ParameterSet::getUntrackedParameter(), producer_, runIsComplete_, alignCSCRings::s, saveAtJobEnd_, saveByRun_, hgcalPlots::stat, AlCaHLTBitMon_QueryRunRegistry::string, BeamSplash_cfg::version, version_, and workflow_.

Member Function Documentation

◆ analyze()

void DQMFileSaver::analyze ( const edm::Event e,
const edm::EventSetup  
)
overrideprotectedvirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 197 of file DQMFileSaver.cc.

197  {
198  //save by event and save by time are not supported
199  //anymore in the threaded framework. please use
200  //savebyLumiSection instead.
201 }

◆ beginRun()

void DQMFileSaver::beginRun ( edm::Run const &  ,
edm::EventSetup const &   
)
inlineoverrideprotected

Definition at line 35 of file DQMFileSaver.cc.

35 {};

◆ endJob()

void DQMFileSaver::endJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 211 of file DQMFileSaver.cc.

211  {
212  if (saveAtJobEnd_) {
213  if (forceRunNumber_ > 0)
215  else
217  }
218 }

References forceRunNumber_, irun_, saveAtJobEnd_, saveForOffline(), and workflow_.

◆ endRun()

void DQMFileSaver::endRun ( const edm::Run iRun,
const edm::EventSetup  
)
overrideprotected

Definition at line 203 of file DQMFileSaver.cc.

203  {
204  int irun = iRun.id().run();
205  irun_ = irun;
206  if (irun > 0 && saveByRun_ > 0 && (nrun_ % saveByRun_) == 0) {
207  saveForOffline(workflow_, irun, 0);
208  }
209 }

References edm::RunBase::id(), irun_, nrun_, edm::RunID::run(), saveByRun_, saveForOffline(), and workflow_.

◆ saveForOffline()

void DQMFileSaver::saveForOffline ( const std::string &  workflow,
int  run,
int  lumi 
)
private

Definition at line 88 of file DQMFileSaver.cc.

88  {
89  char suffix[64];
90  sprintf(suffix, "R%09d", run);
91 
93  assert(lumi == 0);
94 
95  // set run end flag
96  dbe_->cd();
97  dbe_->setCurrentFolder("Info/ProvInfo");
98 
99  // do this, because ProvInfo is not yet run in offline DQM
100  MonitorElement *me = dbe_->get("Info/ProvInfo/CMSSW");
101  if (!me)
102  me = dbe_->bookString("CMSSW", edm::getReleaseVersion().c_str());
103 
104  me = dbe_->get("Info/ProvInfo/runIsComplete");
105  if (!me)
106  me = dbe_->bookFloat("runIsComplete");
107 
108  if (me) {
109  if (runIsComplete_)
110  me->Fill(1.);
111  else
112  me->Fill(0.);
113  }
114 
116  h.save(filename, "", run, /* saveall */ true, "RECREATE");
117 
118  // save the JobReport
120 }

References cms::cuda::assert(), dqm::implementation::IBooker::bookFloat(), dqm::implementation::IBooker::bookString(), dqm::implementation::DQMStore::cd(), child_, dbe_, fileBaseName_, corrVsCorr::filename, dqm::implementation::IGetter::get(), edm::getReleaseVersion(), h, hlt_dqm_clientPB-live_cfg::me, onlineOfflineFileName(), writedatasetfile::run, runIsComplete_, saveJobReport(), dqm::implementation::DQMStore::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, createPayload::suffix, and AlCaHarvesting_cff::workflow.

Referenced by endJob(), and endRun().

◆ saveJobReport()

void DQMFileSaver::saveJobReport ( const std::string &  filename)
private

Definition at line 122 of file DQMFileSaver.cc.

122  {
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 }

References corrVsCorr::filename, info(), edm::Service< T >::isAvailable(), and edm::JobReport::reportAnalysisFile().

Referenced by saveForOffline().

Member Data Documentation

◆ child_

std::string DQMFileSaver::child_
private

Definition at line 48 of file DQMFileSaver.cc.

Referenced by saveForOffline().

◆ dbe_

DQMStore* DQMFileSaver::dbe_
private

Definition at line 58 of file DQMFileSaver.cc.

Referenced by saveForOffline().

◆ dirName_

std::string DQMFileSaver::dirName_
private

Definition at line 47 of file DQMFileSaver.cc.

Referenced by DQMFileSaver().

◆ fileBaseName_

std::string DQMFileSaver::fileBaseName_
private

Definition at line 56 of file DQMFileSaver.cc.

Referenced by DQMFileSaver(), and saveForOffline().

◆ forceRunNumber_

int DQMFileSaver::forceRunNumber_
private

Definition at line 54 of file DQMFileSaver.cc.

Referenced by DQMFileSaver(), and endJob().

◆ irun_

int DQMFileSaver::irun_
private

Definition at line 62 of file DQMFileSaver.cc.

Referenced by endJob(), and endRun().

◆ nrun_

int DQMFileSaver::nrun_
private

Definition at line 59 of file DQMFileSaver.cc.

Referenced by endRun().

◆ producer_

std::string DQMFileSaver::producer_
private

Definition at line 45 of file DQMFileSaver.cc.

Referenced by DQMFileSaver().

◆ runIsComplete_

bool DQMFileSaver::runIsComplete_
private

Definition at line 50 of file DQMFileSaver.cc.

Referenced by DQMFileSaver(), and saveForOffline().

◆ saveAtJobEnd_

bool DQMFileSaver::saveAtJobEnd_
private

Definition at line 53 of file DQMFileSaver.cc.

Referenced by DQMFileSaver(), and endJob().

◆ saveByRun_

int DQMFileSaver::saveByRun_
private

Definition at line 52 of file DQMFileSaver.cc.

Referenced by DQMFileSaver(), and endRun().

◆ stream_label_

std::string DQMFileSaver::stream_label_
private

Definition at line 46 of file DQMFileSaver.cc.

◆ version_

int DQMFileSaver::version_
private

Definition at line 49 of file DQMFileSaver.cc.

Referenced by DQMFileSaver().

◆ workflow_

std::string DQMFileSaver::workflow_
private

Definition at line 44 of file DQMFileSaver.cc.

Referenced by DQMFileSaver(), endJob(), and endRun().

LegacyIOHelper
Definition: LegacyIOHelper.h:14
getAnInt
static void getAnInt(const edm::ParameterSet &ps, int &value, const std::string &name)
Definition: DQMFileSaver.cc:66
DQMFileSaver::runIsComplete_
bool runIsComplete_
Definition: DQMFileSaver.cc:50
DQMFileSaver::saveForOffline
void saveForOffline(const std::string &workflow, int run, int lumi)
Definition: DQMFileSaver.cc:88
DQMFileSaver::version_
int version_
Definition: DQMFileSaver.cc:49
dqm::implementation::IBooker::bookFloat
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
edm::RunID::run
RunNumber_t run() const
Definition: RunID.h:36
DQMFileSaver::saveAtJobEnd_
bool saveAtJobEnd_
Definition: DQMFileSaver.cc:53
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
edm::JobReport::reportAnalysisFile
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:473
edm::LogInfo
Definition: MessageLogger.h:254
cms::cuda::assert
assert(be >=bs)
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DQMFileSaver::producer_
std::string producer_
Definition: DQMFileSaver.cc:45
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
createPayload.suffix
suffix
Definition: createPayload.py:281
alignCSCRings.s
s
Definition: alignCSCRings.py:92
hgcalPlots.stat
stat
Definition: hgcalPlots.py:1111
DQMFileSaver::saveByRun_
int saveByRun_
Definition: DQMFileSaver.cc:52
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
dqm::implementation::DQMStore::setCurrentFolder
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DQMFileSaver::dbe_
DQMStore * dbe_
Definition: DQMFileSaver.cc:58
dqm::implementation::IBooker::bookString
MonitorElement * bookString(TString const &name, TString const &value, FUNC onbooking=NOOP())
Definition: DQMStore.h:87
KineDebug3::count
void count()
Definition: KinematicConstrainedVertexUpdatorT.h:21
edm::Service
Definition: Service.h:30
DQMFileSaver::saveJobReport
void saveJobReport(const std::string &filename)
Definition: DQMFileSaver.cc:122
onlineOfflineFileName
static std::string onlineOfflineFileName(const std::string &fileBaseName, const std::string &suffix, const std::string &workflow, const std::string &child)
Definition: DQMFileSaver.cc:73
AlCaHarvesting_cff.workflow
workflow
Definition: AlCaHarvesting_cff.py:30
writedatasetfile.run
run
Definition: writedatasetfile.py:27
DQMFileSaver::workflow_
std::string workflow_
Definition: DQMFileSaver.cc:44
DQMFileSaver::nrun_
int nrun_
Definition: DQMFileSaver.cc:59
edm::getReleaseVersion
std::string getReleaseVersion()
Definition: GetReleaseVersion.cc:7
Exception
Definition: hltDiff.cc:246
DQMFileSaver::fileBaseName_
std::string fileBaseName_
Definition: DQMFileSaver.cc:56
DQMFileSaver::dirName_
std::string dirName_
Definition: DQMFileSaver.cc:47
dqm::implementation::IGetter::get
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:651
DQMFileSaver::child_
std::string child_
Definition: DQMFileSaver.cc:48
cms::Exception
Definition: Exception.h:70
DQMFileSaver::irun_
int irun_
Definition: DQMFileSaver.cc:62
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:56
lumi
Definition: LumiSectionData.h:20
BeamSplash_cfg.version
version
Definition: BeamSplash_cfg.py:45
edm::RunBase::id
RunID const & id() const
Definition: RunBase.h:39
DQMFileSaver::forceRunNumber_
int forceRunNumber_
Definition: DQMFileSaver.cc:54
dqm::implementation::DQMStore::cd
void cd() override
Definition: DQMStore.h:564