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 noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept 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 noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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 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 140 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_.

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

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 207 of file DQMFileSaver.cc.

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

◆ 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 221 of file DQMFileSaver.cc.

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

221  {
222  if (saveAtJobEnd_) {
223  if (forceRunNumber_ > 0)
225  else
227  }
228 }
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:94

◆ endRun()

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

Definition at line 213 of file DQMFileSaver.cc.

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

213  {
214  int irun = iRun.id().run();
215  irun_ = irun;
216  if (irun > 0 && saveByRun_ > 0 && (nrun_ % saveByRun_) == 0) {
217  saveForOffline(workflow_, irun, 0);
218  }
219 }
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:94
RunNumber_t run() const
Definition: RunID.h:26

◆ saveForOffline()

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

Definition at line 94 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().

94  {
95  char suffix[64];
96  sprintf(suffix, "R%09d", run);
97 
99  assert(lumi == 0);
100 
101  // set run end flag
102  dbe_->cd();
103  dbe_->setCurrentFolder("Info/ProvInfo");
104 
105  // do this, because ProvInfo is not yet run in offline DQM
106  MonitorElement *me = dbe_->get("Info/ProvInfo/CMSSW");
107  if (!me)
108  me = dbe_->bookString("CMSSW", edm::getReleaseVersion().c_str());
109 
110  me = dbe_->get("Info/ProvInfo/runIsComplete");
111  if (!me)
112  me = dbe_->bookFloat("runIsComplete");
113 
114  if (me) {
115  if (runIsComplete_)
116  me->Fill(1.);
117  else
118  me->Fill(0.);
119  }
120 
122  h.save(filename, "", run, /* saveall */ true, "RECREATE");
123 
124  // save the JobReport
126 }
MonitorElement * bookFloat(TString const &name, FUNC onbooking=NOOP())
Definition: DQMStore.h:80
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:656
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:79
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 128 of file DQMFileSaver.cc.

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

Referenced by saveForOffline().

128  {
129  // Report the file to job report service.
131  if (jr.isAvailable()) {
132  std::map<std::string, std::string> info;
133  info["Source"] = "DQMStore";
134  info["FileClass"] = "DQM";
136  }
137 }
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 67 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 68 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().