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::WatchProcessBlock > 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, edm::WatchProcessBlock >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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 endProcessBlock (const edm::ProcessBlock &) override
 
void endRun (const edm::Run &, const edm::EventSetup &) override
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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_
 
edm::GetterOfProducts< DQMTokenjobmegetter_
 
int nrun_
 
std::string producer_
 
bool runIsComplete_
 
edm::GetterOfProducts< DQMTokenrunmegetter_
 
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 31 of file DQMFileSaver.cc.

Member Typedef Documentation

◆ DQMStore

Definition at line 33 of file DQMFileSaver.cc.

◆ MonitorElement

Definition at line 34 of file DQMFileSaver.cc.

Constructor & Destructor Documentation

◆ DQMFileSaver()

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

Definition at line 142 of file DQMFileSaver.cc.

References edm::one::EDAnalyzerBase::callWhenNewProductsRegistered(), submitPVResolutionJobs::count, dirName_, Exception, fileBaseName_, forceRunNumber_, getAnInt(), edm::ParameterSet::getUntrackedParameter(), jobmegetter_, producer_, runIsComplete_, runmegetter_, alignCSCRings::s, saveAtJobEnd_, saveByRun_, edm_modernize_messagelogger::stat, AlCaHLTBitMon_QueryRunRegistry::string, BeamSplash_cfg::version, version_, and workflow_.

143  :
144 
145  workflow_(""),
146  producer_("DQM"),
147  dirName_("."),
148  child_(""),
149  version_(1),
150  runIsComplete_(false),
151  saveByRun_(-1),
152  saveAtJobEnd_(false),
153  forceRunNumber_(-1),
154  fileBaseName_(""),
156  nrun_(0),
157  irun_(0),
158  // Abuse ProcessMatch as a "match all".
162  this->jobmegetter_(bd);
163  this->runmegetter_(bd);
164  });
165 
167  if (workflow_.empty() || workflow_[0] != '/' || *workflow_.rbegin() == '/' ||
168  std::count(workflow_.begin(), workflow_.end(), '/') != 3 ||
169  workflow_.find_first_not_of("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
170  "abcdefghijklmnopqrstuvwxyz"
171  "0123456789"
172  "-_/") != std::string::npos)
173  throw cms::Exception("DQMFileSaver") << "Invalid 'workflow' parameter '" << workflow_ << "'. Expected '/A/B/C'.";
174 
175  // version number to be used in filename
176  // Note that version *must* always be 1 vor DQMGUI upload.
177  version_ = ps.getUntrackedParameter<int>("version", version_);
178  // flag to signal that file contains data from complete run
179  runIsComplete_ = ps.getUntrackedParameter<bool>("runIsComplete", runIsComplete_);
180 
181  // Get and check the output directory.
182  struct stat s;
184  if (dirName_.empty() || stat(dirName_.c_str(), &s) == -1)
185  throw cms::Exception("DQMFileSaver") << "Invalid 'dirName' parameter '" << dirName_ << "'.";
186 
187  // Find out when and how to save files. The following contraints apply:
188  // - For offline allow files to be saved per run, at job end, and run number to be overridden (for mc data).
189 
190  getAnInt(ps, saveByRun_, "saveByRun");
191  getAnInt(ps, forceRunNumber_, "forceRunNumber");
192  saveAtJobEnd_ = ps.getUntrackedParameter<bool>("saveAtJobEnd", saveAtJobEnd_);
193 
194  // Set up base file name:
195  // - for online and offline, follow the convention <dirName>/<producer>_V<4digits>_
196  char version[8];
197  sprintf(version, "_V%04d_", int(version_));
198  version[7] = '\0';
200 
201  // Log some information what we will do.
202  edm::LogInfo("DQMFileSaver") << "DQM file saving settings:\n"
203  << " using base file name '" << fileBaseName_ << "'\n"
204  << " forcing run number " << forceRunNumber_ << "\n"
205  << " saving every " << saveByRun_ << " run(s)\n"
206  << " saving at job end: " << (saveAtJobEnd_ ? "yes" : "no") << "\n";
207 }
DQMStore * dbe_
Definition: DQMFileSaver.cc:61
std::string dirName_
Definition: DQMFileSaver.cc:50
std::string fileBaseName_
Definition: DQMFileSaver.cc:59
T getUntrackedParameter(std::string const &, T const &) const
static void getAnInt(const edm::ParameterSet &ps, int &value, const std::string &name)
Definition: DQMFileSaver.cc:74
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
bool runIsComplete_
Definition: DQMFileSaver.cc:53
std::string workflow_
Definition: DQMFileSaver.cc:47
Log< level::Info, false > LogInfo
std::string producer_
Definition: DQMFileSaver.cc:48
std::string child_
Definition: DQMFileSaver.cc:51
edm::GetterOfProducts< DQMToken > runmegetter_
Definition: DQMFileSaver.cc:70
bool saveAtJobEnd_
Definition: DQMFileSaver.cc:56
edm::GetterOfProducts< DQMToken > jobmegetter_
Definition: DQMFileSaver.cc:69

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 209 of file DQMFileSaver.cc.

209  {
210  //save by event and save by time are not supported
211  //anymore in the threaded framework. please use
212  //savebyLumiSection instead.
213 }

◆ beginRun()

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

Definition at line 38 of file DQMFileSaver.cc.

38 {};

◆ endProcessBlock()

void DQMFileSaver::endProcessBlock ( const edm::ProcessBlock )
overrideprotected

Definition at line 223 of file DQMFileSaver.cc.

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

223  {
224  if (saveAtJobEnd_) {
225  if (forceRunNumber_ > 0)
227  else
229  }
230 }
std::string workflow_
Definition: DQMFileSaver.cc:47
bool saveAtJobEnd_
Definition: DQMFileSaver.cc:56
void saveForOffline(const std::string &workflow, int run, int lumi)
Definition: DQMFileSaver.cc:96

◆ endRun()

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

Definition at line 215 of file DQMFileSaver.cc.

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

215  {
216  int irun = iRun.id().run();
217  irun_ = irun;
218  if (irun > 0 && saveByRun_ > 0 && (nrun_ % saveByRun_) == 0) {
219  saveForOffline(workflow_, irun, 0);
220  }
221 }
std::string workflow_
Definition: DQMFileSaver.cc:47
RunID const & id() const
Definition: RunBase.h:39
void saveForOffline(const std::string &workflow, int run, int lumi)
Definition: DQMFileSaver.cc:96
RunNumber_t run() const
Definition: RunID.h:26

◆ saveForOffline()

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

Definition at line 96 of file DQMFileSaver.cc.

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, makePlotsFromDump::suffix, and AlCaHarvesting_cff::workflow.

Referenced by endProcessBlock(), and endRun().

96  {
97  char suffix[64];
98  sprintf(suffix, "R%09d", run);
99 
101  assert(lumi == 0);
102 
103  // set run end flag
104  dbe_->cd();
105  dbe_->setCurrentFolder("Info/ProvInfo");
106 
107  // do this, because ProvInfo is not yet run in offline DQM
108  MonitorElement *me = dbe_->get("Info/ProvInfo/CMSSW");
109  if (!me)
110  me = dbe_->bookString("CMSSW", edm::getReleaseVersion().c_str());
111 
112  me = dbe_->get("Info/ProvInfo/runIsComplete");
113  if (!me)
114  me = dbe_->bookFloat("runIsComplete");
115 
116  if (me) {
117  if (runIsComplete_)
118  me->Fill(1.);
119  else
120  me->Fill(0.);
121  }
122 
124  h.save(filename, "", run, /* saveall */ true, "RECREATE");
125 
126  // save the JobReport
128 }
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:646
DQMStore * dbe_
Definition: DQMFileSaver.cc:61
assert(be >=bs)
void saveJobReport(const std::string &filename)
std::string fileBaseName_
Definition: DQMFileSaver.cc:59
MonitorElement * bookString(TString const &name, TString const &value, FUNC onbooking=NOOP())
Definition: DQMStore.h:87
bool runIsComplete_
Definition: DQMFileSaver.cc:53
std::string getReleaseVersion()
std::string child_
Definition: DQMFileSaver.cc:51
static std::string onlineOfflineFileName(const std::string &fileBaseName, const std::string &suffix, const std::string &workflow, const std::string &child)
Definition: DQMFileSaver.cc:81
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:712
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ saveJobReport()

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

Definition at line 130 of file DQMFileSaver.cc.

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

Referenced by saveForOffline().

130  {
131  // Report the file to job report service.
133  if (jr.isAvailable()) {
134  std::map<std::string, std::string> info;
135  info["Source"] = "DQMStore";
136  info["FileClass"] = "DQM";
138  }
139 }
static const TGPicture * info(bool iBackgroundIsBlack)
void reportAnalysisFile(std::string const &fileName, std::map< std::string, std::string > const &fileData)
Definition: JobReport.cc:509
bool isAvailable() const
Definition: Service.h:40

Member Data Documentation

◆ child_

std::string DQMFileSaver::child_
private

Definition at line 51 of file DQMFileSaver.cc.

Referenced by saveForOffline().

◆ dbe_

DQMStore* DQMFileSaver::dbe_
private

Definition at line 61 of file DQMFileSaver.cc.

Referenced by saveForOffline().

◆ dirName_

std::string DQMFileSaver::dirName_
private

Definition at line 50 of file DQMFileSaver.cc.

Referenced by DQMFileSaver().

◆ fileBaseName_

std::string DQMFileSaver::fileBaseName_
private

Definition at line 59 of file DQMFileSaver.cc.

Referenced by DQMFileSaver(), and saveForOffline().

◆ forceRunNumber_

int DQMFileSaver::forceRunNumber_
private

Definition at line 57 of file DQMFileSaver.cc.

Referenced by DQMFileSaver(), and endProcessBlock().

◆ irun_

int DQMFileSaver::irun_
private

Definition at line 65 of file DQMFileSaver.cc.

Referenced by endProcessBlock(), and endRun().

◆ jobmegetter_

edm::GetterOfProducts<DQMToken> DQMFileSaver::jobmegetter_
private

Definition at line 69 of file DQMFileSaver.cc.

Referenced by DQMFileSaver().

◆ nrun_

int DQMFileSaver::nrun_
private

Definition at line 62 of file DQMFileSaver.cc.

Referenced by endRun().

◆ producer_

std::string DQMFileSaver::producer_
private

Definition at line 48 of file DQMFileSaver.cc.

Referenced by DQMFileSaver().

◆ runIsComplete_

bool DQMFileSaver::runIsComplete_
private

Definition at line 53 of file DQMFileSaver.cc.

Referenced by DQMFileSaver(), and saveForOffline().

◆ runmegetter_

edm::GetterOfProducts<DQMToken> DQMFileSaver::runmegetter_
private

Definition at line 70 of file DQMFileSaver.cc.

Referenced by DQMFileSaver().

◆ saveAtJobEnd_

bool DQMFileSaver::saveAtJobEnd_
private

Definition at line 56 of file DQMFileSaver.cc.

Referenced by DQMFileSaver(), and endProcessBlock().

◆ saveByRun_

int DQMFileSaver::saveByRun_
private

Definition at line 55 of file DQMFileSaver.cc.

Referenced by DQMFileSaver(), and endRun().

◆ stream_label_

std::string DQMFileSaver::stream_label_
private

Definition at line 49 of file DQMFileSaver.cc.

◆ version_

int DQMFileSaver::version_
private

Definition at line 52 of file DQMFileSaver.cc.

Referenced by DQMFileSaver().

◆ workflow_

std::string DQMFileSaver::workflow_
private

Definition at line 47 of file DQMFileSaver.cc.

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