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
 
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
 
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)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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 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 259 of file EventContentAnalyzer.cc.

Constructor & Destructor Documentation

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

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

287  : indentation_(iConfig.getUntrackedParameter("indentation", std::string("++"))),
288  verboseIndentation_(iConfig.getUntrackedParameter("verboseIndentation", std::string(" "))),
289  moduleLabels_(iConfig.getUntrackedParameter("verboseForModuleLabels", std::vector<std::string>())),
290  verbose_(iConfig.getUntrackedParameter("verbose", false) || !moduleLabels_.empty()),
291  getModuleLabels_(iConfig.getUntrackedParameter("getDataForModuleLabels", std::vector<std::string>())),
292  getData_(iConfig.getUntrackedParameter("getData", false) || !getModuleLabels_.empty()),
293  evno_(1),
294  listContent_(iConfig.getUntrackedParameter("listContent", true)),
295  listProvenance_(iConfig.getUntrackedParameter("listProvenance", false)) {
296  //now do what ever initialization is needed
299  if (getData_) {
301  if (getModuleLabels_.empty()) {
302  const std::string kPathStatus("edm::PathStatus");
303  const std::string kEndPathStatus("edm::EndPathStatus");
304  if (iBranch.className() != kPathStatus && iBranch.className() != kEndPathStatus) {
306  edm::InputTag{iBranch.moduleLabel(), iBranch.productInstanceName(), iBranch.processName()});
307  }
308  } else {
309  for (auto const& mod : this->getModuleLabels_) {
310  if (iBranch.moduleLabel() == mod) {
312  edm::InputTag{mod, iBranch.productInstanceName(), iBranch.processName()});
313  break;
314  }
315  }
316  }
317  });
318  }
319  }
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:92
std::vector< std::string > moduleLabels_
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
Definition: EDAnalyzer.cc:99
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
edm::EventContentAnalyzer::~EventContentAnalyzer ( )
override

Definition at line 321 of file EventContentAnalyzer.cc.

321  {
322  // do anything here that needs to be done at destruction time
323  // (e.g. close files, deallocate resources etc.)
324  }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 331 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(), patZpeak::handle, indentation_, HLT_2018_cff::InputTag, edm::pset::Registry::instance(), MuonErrorMatrixAdjuster_cfi::instanceName, crabWrapper::key, listContent_, listProvenance_, HerwigMaxPtPartonFilter_cfi::moduleLabel, moduleLabels_, SimL1EmulatorRepack_CalouGT_cff::processName, edm::Provenance::productProvenance(), AlCaHLTBitMon_QueryRunRegistry::string, verbose_, and verboseIndentation_.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 436 of file EventContentAnalyzer.cc.

References cumulates_.

436  {
437  typedef std::map<std::string, int> nameMap;
438 
439  LogAbsolute("EventContent") << "\nSummary for key being the concatenation of friendlyClassName, moduleLabel, "
440  "productInstanceName and processName"
441  << std::endl;
442  for (nameMap::const_iterator it = cumulates_.begin(), itEnd = cumulates_.end(); it != itEnd; ++it) {
443  LogAbsolute("EventContent") << std::setw(6) << it->second << " occurrences of key " << it->first << std::endl;
444  }
445 
446  // Test boost::lexical_cast We don't need this right now so comment it out.
447  // int k = 137;
448  // std::string ktext = boost::lexical_cast<std::string>(k);
449  // std::cout << "\nInteger " << k << " expressed as a string is |" << ktext << "|" << std::endl;
450  }
std::map< std::string, int > cumulates_
void edm::EventContentAnalyzer::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 452 of file EventContentAnalyzer.cc.

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

452  {
453  descriptions.setComment(
454  "This plugin will print a list of all products in the event "
455  "provenance. It also has options to print and/or get each product.");
456 
458 
459  ParameterDescriptionNode* np;
460 
461  std::string defaultString("++");
462  np = desc.addOptionalUntracked<std::string>("indentation", defaultString);
463  np->setComment("This string is printed at the beginning of every line printed during event processing.");
464 
465  np = desc.addOptionalUntracked<bool>("verbose", false);
466  np->setComment("If true, the contents of products are printed.");
467 
468  defaultString = " ";
469  np = desc.addOptionalUntracked<std::string>("verboseIndentation", defaultString);
470  np->setComment(
471  "This string is used to further indent lines when printing the contents of products in verbose mode.");
472 
473  std::vector<std::string> defaultVString;
474 
475  np = desc.addOptionalUntracked<std::vector<std::string> >("verboseForModuleLabels", defaultVString);
476  np->setComment("If this vector is not empty, then only products with module labels on this list are printed.");
477 
478  np = desc.addOptionalUntracked<bool>("getData", false);
479  np->setComment("If true the products will be retrieved using getByLabel.");
480 
481  np = desc.addOptionalUntracked<std::vector<std::string> >("getDataForModuleLabels", defaultVString);
482  np->setComment(
483  "If this vector is not empty, then only products with module labels on this list are retrieved by getByLabel.");
484 
485  np = desc.addOptionalUntracked<bool>("listContent", true);
486  np->setComment("If true then print a list of all the event content.");
487 
488  np = desc.addOptionalUntracked<bool>("listProvenance", false);
489  np->setComment("If true, and if listContent or verbose is true, print provenance information for each product");
490 
491  descriptions.add("printContent", desc);
492  }
int np
Definition: AMPTWrapper.h:43

Member Data Documentation

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

Definition at line 278 of file EventContentAnalyzer.cc.

Referenced by analyze(), and endJob().

int edm::EventContentAnalyzer::evno_
private

Definition at line 277 of file EventContentAnalyzer.cc.

Referenced by analyze().

bool edm::EventContentAnalyzer::getData_
private

Definition at line 276 of file EventContentAnalyzer.cc.

Referenced by analyze(), and EventContentAnalyzer().

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

Definition at line 275 of file EventContentAnalyzer.cc.

Referenced by analyze(), and EventContentAnalyzer().

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

Definition at line 271 of file EventContentAnalyzer.cc.

Referenced by analyze().

bool edm::EventContentAnalyzer::listContent_
private

Definition at line 279 of file EventContentAnalyzer.cc.

Referenced by analyze().

bool edm::EventContentAnalyzer::listProvenance_
private

Definition at line 280 of file EventContentAnalyzer.cc.

Referenced by analyze().

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

Definition at line 273 of file EventContentAnalyzer.cc.

Referenced by analyze(), and EventContentAnalyzer().

bool edm::EventContentAnalyzer::verbose_
private

Definition at line 274 of file EventContentAnalyzer.cc.

Referenced by analyze().

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

Definition at line 272 of file EventContentAnalyzer.cc.

Referenced by analyze().