CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
edm::EventContentAnalyzer Class Reference
Inheritance diagram for edm::EventContentAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (Event const &, EventSetup const &) override
 
void endJob () override
 
 EventContentAnalyzer (ParameterSet const &)
 
 ~EventContentAnalyzer () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
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)
 

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- 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 ()
 

Private Attributes

std::map< std::string, int > cumulates_
 
int evno_
 
bool getData_
 
std::vector< std::string > getModuleLabels_
 
std::string indentation_
 
bool listContent_
 
bool listProvenance_
 
std::vector< std::string > moduleLabels_
 
bool verbose_
 
std::string verboseIndentation_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ESProduct , Transition Tr = Transition::Event>
auto esConsumes (eventsetup::EventSetupRecordKey const &, ESInputTag const &tag)
 
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

Definition at line 263 of file EventContentAnalyzer.cc.

Constructor & Destructor Documentation

edm::EventContentAnalyzer::EventContentAnalyzer ( ParameterSet const &  iConfig)
explicit

Definition at line 291 of file EventContentAnalyzer.cc.

References edm::EDAnalyzer::callWhenNewProductsRegistered(), edm::BranchDescription::className(), edm::EDConsumerBase::consumes(), getData_, getModuleLabels_, mod(), edm::BranchDescription::moduleLabel(), moduleLabels_, edm::BranchDescription::processName(), edm::PRODUCT_TYPE, edm::BranchDescription::productInstanceName(), edm::sort_all(), and edm::BranchDescription::unwrappedTypeID().

291  :
292  indentation_(iConfig.getUntrackedParameter("indentation", std::string("++"))),
293  verboseIndentation_(iConfig.getUntrackedParameter("verboseIndentation", std::string(" "))),
294  moduleLabels_(iConfig.getUntrackedParameter("verboseForModuleLabels", std::vector<std::string>())),
295  verbose_(iConfig.getUntrackedParameter("verbose", false) || !moduleLabels_.empty()),
296  getModuleLabels_(iConfig.getUntrackedParameter("getDataForModuleLabels", std::vector<std::string>())),
297  getData_(iConfig.getUntrackedParameter("getData", false) || !getModuleLabels_.empty()),
298  evno_(1),
299  listContent_(iConfig.getUntrackedParameter("listContent", true)),
300  listProvenance_(iConfig.getUntrackedParameter("listProvenance", false))
301  {
302  //now do what ever initialization is needed
305  if(getData_) {
307  if(getModuleLabels_.empty()) {
308  const std::string kPathStatus("edm::PathStatus");
309  const std::string kEndPathStatus("edm::EndPathStatus");
310  if(iBranch.className() != kPathStatus && iBranch.className() != kEndPathStatus) {
312  edm::InputTag{iBranch.moduleLabel(),iBranch.productInstanceName(),iBranch.processName()});
313  }
314  } else {
315  for (auto const& mod : this->getModuleLabels_) {
316  if (iBranch.moduleLabel() == mod) {
318  edm::InputTag{mod,iBranch.productInstanceName(),iBranch.processName()});
319  break;
320  }
321  }
322  }
323  }
324  );
325  }
326 
327  }
std::vector< std::string > getModuleLabels_
std::string const & processName() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::string const & className() const
std::string const & moduleLabel() const
std::string const & productInstanceName() const
TypeID unwrappedTypeID() const
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:120
std::vector< std::string > moduleLabels_
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
Definition: EDAnalyzer.cc:104
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
edm::EventContentAnalyzer::~EventContentAnalyzer ( )
override

Definition at line 329 of file EventContentAnalyzer.cc.

329  {
330 
331  // do anything here that needs to be done at destruction time
332  // (e.g. close files, deallocate resources etc.)
333 
334  }

Member Function Documentation

void edm::EventContentAnalyzer::analyze ( Event const &  iEvent,
EventSetup const &   
)
overridevirtual

Implements edm::EDAnalyzer.

Definition at line 342 of file EventContentAnalyzer.cc.

References edm::binary_search_all(), edm::ProductProvenance::branchID(), className(), cumulates_, evno_, edm::ParameterSet::existsAs(), edm::friendlyname::friendlyName(), edm::Event::getAllStableProvenance(), edm::Event::getByLabel(), getData_, edm::pset::Registry::getMapped(), getModuleLabels_, edm::ParameterSet::getParameterSet(), edm::Event::getProvenance(), cmsBatch::handle, indentation_, edm::pset::Registry::instance(), MuonErrorMatrixAdjuster_cfi::instanceName, crabWrapper::key, listContent_, listProvenance_, moduleLabels_, modifiedElectrons_cfi::processName, edm::Provenance::productProvenance(), AlCaHLTBitMon_QueryRunRegistry::string, verbose_, and verboseIndentation_.

342  {
343  typedef std::vector<StableProvenance const*> Provenances;
344  Provenances provenances;
345 
346  iEvent.getAllStableProvenance(provenances);
347 
348  if(listContent_) {
349  LogAbsolute("EventContent") << "\n" << indentation_ << "Event " << std::setw(5) << evno_ << " contains "
350  << provenances.size() << " product" << (provenances.size() == 1 ? "" : "s")
351  << " with friendlyClassName, moduleLabel, productInstanceName and processName:"
352  << std::endl;
353  }
354 
356  for(auto const& provenance : provenances) {
357  std::string const& className = provenance->className();
358  const std::string kPathStatus("edm::PathStatus");
359  const std::string kEndPathStatus("edm::EndPathStatus");
360  if(className == kPathStatus || className == kEndPathStatus) {
361  continue;
362  }
363  std::string const& friendlyName = provenance->friendlyClassName();
364  //if(friendlyName.empty()) friendlyName = std::string("||");
365 
366  std::string const& modLabel = provenance->moduleLabel();
367  //if(modLabel.empty()) modLabel = std::string("||");
368 
369  std::string const& instanceName = provenance->productInstanceName();
370  //if(instanceName.empty()) instanceName = std::string("||");
371 
372  std::string const& processName = provenance->processName();
373 
374  bool doVerbose = verbose_ && (moduleLabels_.empty() ||
375  binary_search_all(moduleLabels_, modLabel));
376 
377  if(listContent_ || doVerbose) {
378  LogAbsolute("EventContent") << indentation_ << friendlyName
379  << " \"" << modLabel
380  << "\" \"" << instanceName << "\" \""
381  << processName << "\""
382  << " (productId = " << provenance->productID() << ")"
383  << std::endl;
384 
385  if(listProvenance_) {
386  auto const& prov = iEvent.getProvenance(provenance->branchID());
387  auto const *productProvenance = prov.productProvenance();
388  if(productProvenance) {
389  const bool isAlias = productProvenance->branchID() != provenance->branchID();
390  std::string aliasForModLabel;
391  LogAbsolute("EventContent") << prov;
392  if(isAlias) {
393  aliasForModLabel = iEvent.getProvenance(productProvenance->branchID()).moduleLabel();
394  LogAbsolute("EventContent") << "Is an alias for " << aliasForModLabel;
395  }
396  ProcessHistory const *processHistory = prov.processHistoryPtr();
397  if(processHistory) {
398  for(ProcessConfiguration const& pc: *processHistory) {
399  if(pc.processName() == prov.processName()) {
400  ParameterSetID const& psetID = pc.parameterSetID();
401  pset::Registry const* psetRegistry = pset::Registry::instance();
402  ParameterSet const* processPset = psetRegistry->getMapped(psetID);
403  if (processPset) {
404  if(processPset->existsAs<ParameterSet>(modLabel)) {
405  if(isAlias) {
406  LogAbsolute("EventContent") << "Alias PSet";
407  }
408  LogAbsolute("EventContent") << processPset->getParameterSet(modLabel);
409  }
410  if(isAlias and processPset->existsAs<ParameterSet>(aliasForModLabel)) {
411  LogAbsolute("EventContent") << processPset->getParameterSet(aliasForModLabel);
412  }
413  }
414  }
415  }
416  }
417  }
418  }
419  }
420  std::string key = friendlyName
421  + std::string(" + \"") + modLabel
422  + std::string("\" + \"") + instanceName + "\" \"" + processName + "\"";
423  ++cumulates_[key];
424 
425  if(doVerbose) {
426  //indent one level before starting to print
427  printObject(iEvent,
428  className,
429  modLabel,
430  instanceName,
431  processName,
432  startIndent,
433  verboseIndentation_);
434  continue;
435  }
436  if(getData_) {
437  std::string class_and_label = friendlyName + "_" + modLabel;
438  if(getModuleLabels_.empty() ||
439  binary_search_all(getModuleLabels_, modLabel) ||
440  binary_search_all(getModuleLabels_, class_and_label)) {
441  try {
442  GenericHandle handle(className);
443  } catch(edm::Exception const&) {
444  LogAbsolute("EventContent") << startIndent << " \"" << className << "\"" << " is an unknown type" << std::endl;
445  return;
446  }
447  GenericHandle handle(className);
448  iEvent.getByLabel(InputTag(modLabel,
449  instanceName,
450  processName),
451  handle);
452  }
453  }
454  }
455  //std::cout << "Mine" << std::endl;
456  ++evno_;
457  }
std::vector< std::string > getModuleLabels_
std::map< std::string, int > cumulates_
int iEvent
Definition: GenABIO.cc:230
std::string friendlyName(std::string const &iFullName)
Hash< ParameterSetType > ParameterSetID
std::vector< std::string > moduleLabels_
bool binary_search_all(ForwardSequence const &s, Datum const &d)
wrappers for std::binary_search
Definition: Algorithms.h:76
static Registry * instance()
Definition: Registry.cc:13
std::string className(const T &t)
Definition: ClassName.h:30
void edm::EventContentAnalyzer::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 461 of file EventContentAnalyzer.cc.

References cumulates_.

461  {
462  typedef std::map<std::string, int> nameMap;
463 
464  LogAbsolute("EventContent") << "\nSummary for key being the concatenation of friendlyClassName, moduleLabel, productInstanceName and processName" << std::endl;
465  for(nameMap::const_iterator it = cumulates_.begin(), itEnd = cumulates_.end();
466  it != itEnd;
467  ++it) {
468  LogAbsolute("EventContent") << std::setw(6) << it->second << " occurrences of key " << it->first << std::endl;
469  }
470 
471  // Test boost::lexical_cast We don't need this right now so comment it out.
472  // int k = 137;
473  // std::string ktext = boost::lexical_cast<std::string>(k);
474  // std::cout << "\nInteger " << k << " expressed as a string is |" << ktext << "|" << std::endl;
475  }
std::map< std::string, int > cumulates_
void edm::EventContentAnalyzer::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 478 of file EventContentAnalyzer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addOptionalUntracked(), DEFINE_FWK_MODULE, np, edm::ConfigurationDescriptions::setComment(), and edm::ParameterDescriptionNode::setComment().

478  {
479 
480  descriptions.setComment("This plugin will print a list of all products in the event "
481  "provenance. It also has options to print and/or get each product.");
482 
484 
485  ParameterDescriptionNode* np;
486 
487  std::string defaultString("++");
488  np = desc.addOptionalUntracked<std::string>("indentation", defaultString);
489  np->setComment("This string is printed at the beginning of every line printed during event processing.");
490 
491  np = desc.addOptionalUntracked<bool>("verbose", false);
492  np->setComment("If true, the contents of products are printed.");
493 
494  defaultString = " ";
495  np = desc.addOptionalUntracked<std::string>("verboseIndentation", defaultString);
496  np->setComment("This string is used to further indent lines when printing the contents of products in verbose mode.");
497 
498  std::vector<std::string> defaultVString;
499 
500  np = desc.addOptionalUntracked<std::vector<std::string> >("verboseForModuleLabels", defaultVString);
501  np->setComment("If this vector is not empty, then only products with module labels on this list are printed.");
502 
503  np = desc.addOptionalUntracked<bool>("getData", false);
504  np->setComment("If true the products will be retrieved using getByLabel.");
505 
506  np = desc.addOptionalUntracked<std::vector<std::string> >("getDataForModuleLabels", defaultVString);
507  np->setComment("If this vector is not empty, then only products with module labels on this list are retrieved by getByLabel.");
508 
509  np = desc.addOptionalUntracked<bool>("listContent", true);
510  np->setComment("If true then print a list of all the event content.");
511 
512  np = desc.addOptionalUntracked<bool>("listProvenance", false);
513  np->setComment("If true, and if listContent or verbose is true, print provenance information for each product");
514 
515  descriptions.add("printContent", desc);
516  }
int np
Definition: AMPTWrapper.h:33

Member Data Documentation

std::map<std::string, int> edm::EventContentAnalyzer::cumulates_
private

Definition at line 283 of file EventContentAnalyzer.cc.

Referenced by analyze(), and endJob().

int edm::EventContentAnalyzer::evno_
private

Definition at line 282 of file EventContentAnalyzer.cc.

Referenced by analyze().

bool edm::EventContentAnalyzer::getData_
private

Definition at line 281 of file EventContentAnalyzer.cc.

Referenced by analyze(), and EventContentAnalyzer().

std::vector<std::string> edm::EventContentAnalyzer::getModuleLabels_
private

Definition at line 280 of file EventContentAnalyzer.cc.

Referenced by analyze(), and EventContentAnalyzer().

std::string edm::EventContentAnalyzer::indentation_
private

Definition at line 276 of file EventContentAnalyzer.cc.

Referenced by analyze().

bool edm::EventContentAnalyzer::listContent_
private

Definition at line 284 of file EventContentAnalyzer.cc.

Referenced by analyze().

bool edm::EventContentAnalyzer::listProvenance_
private

Definition at line 285 of file EventContentAnalyzer.cc.

Referenced by analyze().

std::vector<std::string> edm::EventContentAnalyzer::moduleLabels_
private

Definition at line 278 of file EventContentAnalyzer.cc.

Referenced by analyze(), and EventContentAnalyzer().

bool edm::EventContentAnalyzer::verbose_
private

Definition at line 279 of file EventContentAnalyzer.cc.

Referenced by analyze().

std::string edm::EventContentAnalyzer::verboseIndentation_
private

Definition at line 277 of file EventContentAnalyzer.cc.

Referenced by analyze().