CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Attributes
EDMtoMEConverter Class Reference

#include <EDMtoMEConverter.h>

Inheritance diagram for EDMtoMEConverter:
edm::EDAnalyzer edm::EDConsumerBase

Classes

class  Tokens
 

Public Types

using TagList = std::vector< uint32_t >
 
- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void beginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) override
 
void beginRun (const edm::Run &, const edm::EventSetup &) override
 
 EDMtoMEConverter (const edm::ParameterSet &)
 
void endJob () override
 
void endLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) override
 
void endRun (const edm::Run &, const edm::EventSetup &) override
 
template<class T >
void getData (T &iGetFrom)
 
void respondToOpenInputFile (const edm::FileBlock &) override
 
 ~EDMtoMEConverter () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

bool convertOnEndLumi
 
bool convertOnEndRun
 
DQMStoredbe
 
int frequency
 
std::map< int, int > iCount
 
unsigned int iCountf
 
std::string name
 
std::tuple< Tokens< TH1F >, Tokens< TH1S >, Tokens< TH1D >, Tokens< TH2F >, Tokens< TH2S >, Tokens< TH2D >, Tokens< TH3F >, Tokens< TProfile >, Tokens< TProfile2D >, Tokens< double >, Tokens< int >, Tokens< long long >, Tokens< TString > > tokens_
 
int verbosity
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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)
 

Detailed Description

Class to take dqm monitor elements and convert into a ROOT dataformat stored in Run tree of edm file

Author
M. Strang SUNY-Buffalo

Definition at line 50 of file EDMtoMEConverter.h.

Member Typedef Documentation

using EDMtoMEConverter::TagList = std::vector<uint32_t>

Definition at line 69 of file EDMtoMEConverter.h.

Constructor & Destructor Documentation

EDMtoMEConverter::EDMtoMEConverter ( const edm::ParameterSet iPSet)
explicit

Definition at line 218 of file EDMtoMEConverter.cc.

References constexpr, edm::EDConsumerBase::consumesCollector(), convertOnEndLumi, convertOnEndRun, dbe, frequency, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), iCount, iCountf, name, Utilities::operator, AlCaHLTBitMon_QueryRunRegistry::string, tokens_, verbosity, and ~EDMtoMEConverter().

218  :
219  verbosity(0), frequency(0)
220 {
221  const edm::InputTag& runInputTag = iPSet.getParameter<edm::InputTag>("runInputTag");
222  const edm::InputTag& lumiInputTag = iPSet.getParameter<edm::InputTag>("lumiInputTag");
224 
225  for_each(tokens_, [&](auto& tok) {
226  tok.set(runInputTag, lumiInputTag, iC);
227  });
228 
229  constexpr char MsgLoggerCat[] = "EDMtoMEConverter_EDMtoMEConverter";
230 
231  // get information from parameter set
232  name = iPSet.getUntrackedParameter<std::string>("Name");
233  verbosity = iPSet.getUntrackedParameter<int>("Verbosity");
234  frequency = iPSet.getUntrackedParameter<int>("Frequency");
235 
236  convertOnEndLumi = iPSet.getUntrackedParameter<bool>("convertOnEndLumi",true);
237  convertOnEndRun = iPSet.getUntrackedParameter<bool>("convertOnEndRun",true);
238 
239  // use value of first digit to determine default output level (inclusive)
240  // 0 is none, 1 is basic, 2 is fill output, 3 is gather output
241  verbosity %= 10;
242 
243  // get dqm info
244  dbe = nullptr;
246 
247  // print out Parameter Set information being used
248  if (verbosity >= 0) {
249  edm::LogInfo(MsgLoggerCat)
250  << "\n===============================\n"
251  << "Initialized as EDAnalyzer with parameter values:\n"
252  << " Name = " << name << "\n"
253  << " Verbosity = " << verbosity << "\n"
254  << " Frequency = " << frequency << "\n"
255  << "===============================\n";
256  }
257 
258  iCountf = 0;
259  iCount.clear();
260 
261  assert(sizeof(int64_t) == sizeof(long long));
262 
263 } // end constructor
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
#define constexpr
std::tuple< Tokens< TH1F >, Tokens< TH1S >, Tokens< TH1D >, Tokens< TH2F >, Tokens< TH2S >, Tokens< TH2D >, Tokens< TH3F >, Tokens< TProfile >, Tokens< TProfile2D >, Tokens< double >, Tokens< int >, Tokens< long long >, Tokens< TString > > tokens_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
unsigned int iCountf
std::map< int, int > iCount
EDMtoMEConverter::~EDMtoMEConverter ( )
overridedefault

Referenced by EDMtoMEConverter().

Member Function Documentation

void EDMtoMEConverter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 325 of file EDMtoMEConverter.cc.

326 {
327 }
void EDMtoMEConverter::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 267 of file EDMtoMEConverter.cc.

268 {
269 }
void EDMtoMEConverter::beginLuminosityBlock ( const edm::LuminosityBlock iLumi,
const edm::EventSetup iSetup 
)
override

Definition at line 314 of file EDMtoMEConverter.cc.

315 {
316 }
void EDMtoMEConverter::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
override

Definition at line 287 of file EDMtoMEConverter.cc.

References constexpr, frequency, iCount, edm::RunBase::run(), and verbosity.

288 {
289  constexpr char MsgLoggerCat[] = "EDMtoMEConverter_beginRun";
290 
291  int nrun = iRun.run();
292 
293  // keep track of number of unique runs processed
294  ++iCount[nrun];
295 
296  if (verbosity > 0) {
297  edm::LogInfo(MsgLoggerCat)
298  << "Processing run " << nrun << " (" << iCount.size() << " runs total)";
299  } else if (verbosity == 0) {
300  if (nrun%frequency == 0 || iCount.size() == 1) {
301  edm::LogInfo(MsgLoggerCat)
302  << "Processing run " << nrun << " (" << iCount.size() << " runs total)";
303  }
304  }
305 }
RunNumber_t run() const
Definition: RunBase.h:40
#define constexpr
std::map< int, int > iCount
void EDMtoMEConverter::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 271 of file EDMtoMEConverter.cc.

References constexpr, iCount, iCountf, and verbosity.

272 {
273  constexpr char MsgLoggerCat[] = "EDMtoMEConverter_endJob";
274  if (verbosity >= 0)
275  edm::LogInfo(MsgLoggerCat)
276  << "Terminating having processed " << iCount.size() << " runs across "
277  << iCountf << " files.";
278  return;
279 }
#define constexpr
unsigned int iCountf
std::map< int, int > iCount
void EDMtoMEConverter::endLuminosityBlock ( const edm::LuminosityBlock iLumi,
const edm::EventSetup iSetup 
)
override

Definition at line 318 of file EDMtoMEConverter.cc.

References convertOnEndLumi, and getData().

319 {
320  if (convertOnEndLumi) {
321  getData(iLumi);
322  }
323 }
void getData(T &iGetFrom)
void EDMtoMEConverter::endRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
override

Definition at line 307 of file EDMtoMEConverter.cc.

References convertOnEndRun, and getData().

308 {
309  if (convertOnEndRun) {
310  getData(iRun);
311  }
312 }
void getData(T &iGetFrom)
template<class T >
void EDMtoMEConverter::getData ( T iGetFrom)

Definition at line 331 of file EDMtoMEConverter.cc.

References constexpr, gather_cfg::cout, dbe, dir, MonitorElement::getFullname(), mps_fire::i, edm::HandleBase::isValid(), name, split, AlCaHLTBitMon_QueryRunRegistry::string, GlobalPosition_Frontier_DevDB_cff::tag, tokens_, and verbosity.

Referenced by endLuminosityBlock(), and endRun().

332 {
333  constexpr char MsgLoggerCat[] = "EDMtoMEConverter_getData";
334 
335  if (verbosity >= 0)
336  edm::LogInfo (MsgLoggerCat) << "\nRestoring MonitorElements.";
337 
338  for_each(tokens_, [&](const auto& tok) {
339  using Tokens_T = typename std::decay<decltype(tok)>::type;
340  using METype = typename Tokens_T::type;
341  using MEtoEDM_T = typename Tokens_T::Product;
342  edm::Handle<MEtoEDM_T> metoedm;
343  tok.getData(iGetFrom, metoedm);
344  if(!metoedm.isValid()) {
345  //edm::LogWarning(MsgLoggerCat)
346  // << "MEtoEDM<TH1F> doesn't exist in run";
347  return;
348  }
349 
350  std::vector<typename MEtoEDM_T::MEtoEDMObject> metoedmobject =
351  metoedm->getMEtoEdmObject();
352 
353  for (unsigned int i = 0; i < metoedmobject.size(); ++i) {
354  // get full path of monitor element
355  const std::string& pathname = metoedmobject[i].name;
356  if (verbosity > 0) std::cout << pathname << std::endl;
357 
359 
360  // deconstruct path from fullpath
361  StringList fulldir = StringOps::split(pathname,"/");
362  std::string name = *(fulldir.end() - 1);
363 
364  for (unsigned j = 0; j < fulldir.size() - 1; ++j) {
365  dir += fulldir[j];
366  if (j != fulldir.size() - 2) dir += "/";
367  }
368 
369  // define new monitor element
370  MonitorElement *me = AddMonitorElement<METype>::call(dbe, &metoedmobject[i].object, dir, name, iGetFrom);
371  maybeSetLumiFlag(me, iGetFrom);
372 
373  // attach taglist
374  for(const auto& tag: metoedmobject[i].tags) {
375  dbe->tag(me->getFullname(), tag);
376  }
377  } // end loop thorugh metoedmobject
378  });
379 
380  // verify tags stored properly
381  if (verbosity > 0) {
382  std::vector<std::string> stags;
383  dbe->getAllTags(stags);
384  for (auto const & stag : stags) {
385  std::cout << "Tags: " << stag << std::endl;
386  }
387  }
388 }
type
Definition: HCALResponse.h:21
#define constexpr
std::tuple< Tokens< TH1F >, Tokens< TH1S >, Tokens< TH1D >, Tokens< TH2F >, Tokens< TH2S >, Tokens< TH2D >, Tokens< TH3F >, Tokens< TProfile >, Tokens< TProfile2D >, Tokens< double >, Tokens< int >, Tokens< long long >, Tokens< TString > > tokens_
bool isValid() const
Definition: HandleBase.h:74
const std::string getFullname() const
get full name of ME including Pathname
dbl *** dir
Definition: mlp_gen.cc:35
double split
Definition: MVATrainer.cc:139
void EDMtoMEConverter::respondToOpenInputFile ( const edm::FileBlock iFb)
override

Definition at line 281 of file EDMtoMEConverter.cc.

References iCountf.

282 {
283  ++iCountf;
284  return;
285 }
unsigned int iCountf

Member Data Documentation

bool EDMtoMEConverter::convertOnEndLumi
private

Definition at line 77 of file EDMtoMEConverter.h.

Referenced by EDMtoMEConverter(), and endLuminosityBlock().

bool EDMtoMEConverter::convertOnEndRun
private

Definition at line 78 of file EDMtoMEConverter.h.

Referenced by EDMtoMEConverter(), and endRun().

DQMStore* EDMtoMEConverter::dbe
private

Definition at line 80 of file EDMtoMEConverter.h.

Referenced by EDMtoMEConverter(), and getData().

int EDMtoMEConverter::frequency
private

Definition at line 75 of file EDMtoMEConverter.h.

Referenced by beginRun(), and EDMtoMEConverter().

std::map<int,int> EDMtoMEConverter::iCount
private

Definition at line 84 of file EDMtoMEConverter.h.

Referenced by beginRun(), EDMtoMEConverter(), and endJob().

unsigned int EDMtoMEConverter::iCountf
private

Definition at line 83 of file EDMtoMEConverter.h.

Referenced by EDMtoMEConverter(), endJob(), and respondToOpenInputFile().

std::string EDMtoMEConverter::name
private

Definition at line 73 of file EDMtoMEConverter.h.

Referenced by ElectronMVAID.ElectronMVAID::__call__(), dirstructure.Directory::__create_pie_image(), DisplayManager.DisplayManager::__del__(), dqm_interfaces.DirID::__eq__(), dirstructure.Directory::__get_full_path(), dirstructure.Comparison::__get_img_name(), dataset.Dataset::__getDataType(), dataset.Dataset::__getFileInfoList(), dirstructure.Comparison::__make_image(), core.autovars.NTupleVariable::__repr__(), core.autovars.NTupleObjectType::__repr__(), core.autovars.NTupleObject::__repr__(), core.autovars.NTupleCollection::__repr__(), dirstructure.Directory::__repr__(), dqm_interfaces.DirID::__repr__(), dirstructure.Comparison::__repr__(), config.Service::__setattr__(), config.CFG::__str__(), counter.Counter::__str__(), average.Average::__str__(), core.autovars.NTupleObjectType::addSubObjects(), core.autovars.NTupleObjectType::addVariables(), core.autovars.NTupleObjectType::allVars(), dirstructure.Directory::calcStats(), validation.Sample::digest(), python.rootplot.utilities.Hist::divide(), python.rootplot.utilities.Hist::divide_wilson(), DisplayManager.DisplayManager::Draw(), TreeCrawler.Package::dump(), EDMtoMEConverter(), core.autovars.NTupleVariable::fillBranch(), core.autovars.NTupleObject::fillBranches(), core.autovars.NTupleCollection::fillBranchesScalar(), core.autovars.NTupleCollection::fillBranchesVector(), core.autovars.NTupleCollection::get_cpp_declaration(), core.autovars.NTupleCollection::get_cpp_wrapper_class(), core.autovars.NTupleCollection::get_py_wrapper_class(), utils.StatisticalTest::get_status(), getData(), production_tasks.Task::getname(), dataset.CMSDataset::getPrimaryDatasetEntries(), dataset.PrivateDataset::getPrimaryDatasetEntries(), VIDSelectorBase.VIDSelectorBase::initialize(), personalPlayback.Applet::log(), core.autovars.NTupleVariable::makeBranch(), core.autovars.NTupleObject::makeBranches(), core.autovars.NTupleCollection::makeBranchesScalar(), core.autovars.NTupleCollection::makeBranchesVector(), dirstructure.Directory::print_report(), dataset.BaseDataset::printInfo(), dataset.Dataset::printInfo(), production_tasks.MonitorJobs::run(), python.rootplot.utilities.Hist::TGraph(), python.rootplot.utilities.Hist::TH1F(), Vispa.Views.PropertyView.Property::valueChanged(), counter.Counter::write(), and average.Average::write().

std::tuple< Tokens<TH1F>, Tokens<TH1S>, Tokens<TH1D>, Tokens<TH2F>, Tokens<TH2S>, Tokens<TH2D>, Tokens<TH3F>, Tokens<TProfile>, Tokens<TProfile2D>, Tokens<double>, Tokens<int>, Tokens<long long>, Tokens<TString> > EDMtoMEConverter::tokens_
private

Definition at line 118 of file EDMtoMEConverter.h.

Referenced by EDMtoMEConverter(), and getData().

int EDMtoMEConverter::verbosity
private

Definition at line 74 of file EDMtoMEConverter.h.

Referenced by beginRun(), EDMtoMEConverter(), endJob(), and getData().