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::one::EDAnalyzer<> edm::one::EDAnalyzerBase 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::one::EDAnalyzer<>
 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)
 

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

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::one::EDAnalyzerBase
typedef EDAnalyzerBase 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)
 
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)
 

Detailed Description

Definition at line 259 of file EventContentAnalyzer.cc.

Constructor & Destructor Documentation

◆ EventContentAnalyzer()

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

Definition at line 286 of file EventContentAnalyzer.cc.

References edm::one::EDAnalyzerBase::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(), AlCaHLTBitMon_QueryRunRegistry::string, 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_
TypeID unwrappedTypeID() const
std::string const & processName() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::string const & className() const
std::string const & productInstanceName() const
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
std::vector< std::string > moduleLabels_
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
std::string const & moduleLabel() const

◆ ~EventContentAnalyzer()

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

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 331 of file EventContentAnalyzer.cc.

References edm::binary_search_all(), className(), cumulates_, evno_, edm::ParameterSet::existsAs(), edm::friendlyname::friendlyName(), getData_, edm::pset::Registry::getMapped(), getModuleLabels_, edm::ParameterSet::getParameterSet(), patZpeak::handle, iEvent, indentation_, ProducerED_cfi::InputTag, edm::pset::Registry::instance(), crabWrapper::key, listContent_, listProvenance_, HerwigMaxPtPartonFilter_cfi::moduleLabel, moduleLabels_, SimL1EmulatorRepack_CalouGT_cff::processName, crab_script::provenance, 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  const bool isAlias = provenance->branchDescription().isAlias();
373  std::string aliasForModLabel;
374  LogAbsolute("EventContent") << *provenance;
375  if (isAlias) {
376  aliasForModLabel = iEvent.getStableProvenance(provenance->originalBranchID()).moduleLabel();
377  LogAbsolute("EventContent") << "Is an alias for " << aliasForModLabel;
378  }
379  ProcessHistory const& processHistory = iEvent.processHistory();
380  for (ProcessConfiguration const& pc : processHistory) {
381  if (pc.processName() == provenance->processName()) {
382  ParameterSetID const& psetID = pc.parameterSetID();
383  pset::Registry const* psetRegistry = pset::Registry::instance();
384  ParameterSet const* processPset = psetRegistry->getMapped(psetID);
385  if (processPset) {
386  if (processPset->existsAs<ParameterSet>(modLabel)) {
387  if (isAlias) {
388  LogAbsolute("EventContent") << "Alias PSet";
389  }
390  LogAbsolute("EventContent") << processPset->getParameterSet(modLabel);
391  }
392  if (isAlias and processPset->existsAs<ParameterSet>(aliasForModLabel)) {
393  LogAbsolute("EventContent") << processPset->getParameterSet(aliasForModLabel);
394  }
395  }
396  }
397  }
398  }
399  }
400  std::string key = friendlyName + std::string(" + \"") + modLabel + std::string("\" + \"") + instanceName +
401  "\" \"" + processName + "\"";
402  ++cumulates_[key];
403 
404  if (doVerbose) {
405  //indent one level before starting to print
406  printObject(iEvent, className, modLabel, instanceName, processName, startIndent, verboseIndentation_);
407  continue;
408  }
409  if (getData_) {
410  std::string class_and_label = friendlyName + "_" + modLabel;
411  if (getModuleLabels_.empty() || binary_search_all(getModuleLabels_, modLabel) ||
412  binary_search_all(getModuleLabels_, class_and_label)) {
413  try {
415  } catch (edm::Exception const&) {
416  LogAbsolute("EventContent") << startIndent << " \"" << className << "\""
417  << " is an unknown type" << std::endl;
418  return;
419  }
421  iEvent.getByLabel(InputTag(modLabel, instanceName, processName), handle);
422  }
423  }
424  }
425  //std::cout << "Mine" << std::endl;
426  ++evno_;
427  }
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
Log< level::System, true > LogAbsolute
static Registry * instance()
Definition: Registry.cc:12
std::string className(const T &t)
Definition: ClassName.h:31

◆ endJob()

void edm::EventContentAnalyzer::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 430 of file EventContentAnalyzer.cc.

References cumulates_.

430  {
431  typedef std::map<std::string, int> nameMap;
432 
433  LogAbsolute("EventContent") << "\nSummary for key being the concatenation of friendlyClassName, moduleLabel, "
434  "productInstanceName and processName"
435  << std::endl;
436  for (nameMap::const_iterator it = cumulates_.begin(), itEnd = cumulates_.end(); it != itEnd; ++it) {
437  LogAbsolute("EventContent") << std::setw(6) << it->second << " occurrences of key " << it->first << std::endl;
438  }
439  }
std::map< std::string, int > cumulates_
Log< level::System, true > LogAbsolute

◆ fillDescriptions()

void edm::EventContentAnalyzer::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 441 of file EventContentAnalyzer.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, np, edm::ConfigurationDescriptions::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

Member Data Documentation

◆ cumulates_

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

Definition at line 278 of file EventContentAnalyzer.cc.

Referenced by analyze(), and endJob().

◆ evno_

int edm::EventContentAnalyzer::evno_
private

Definition at line 277 of file EventContentAnalyzer.cc.

Referenced by analyze().

◆ getData_

bool edm::EventContentAnalyzer::getData_
private

Definition at line 276 of file EventContentAnalyzer.cc.

Referenced by analyze(), and EventContentAnalyzer().

◆ getModuleLabels_

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

Definition at line 275 of file EventContentAnalyzer.cc.

Referenced by analyze(), and EventContentAnalyzer().

◆ indentation_

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

Definition at line 271 of file EventContentAnalyzer.cc.

Referenced by analyze().

◆ listContent_

bool edm::EventContentAnalyzer::listContent_
private

Definition at line 279 of file EventContentAnalyzer.cc.

Referenced by analyze().

◆ listProvenance_

bool edm::EventContentAnalyzer::listProvenance_
private

Definition at line 280 of file EventContentAnalyzer.cc.

Referenced by analyze().

◆ moduleLabels_

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

Definition at line 273 of file EventContentAnalyzer.cc.

Referenced by analyze(), and EventContentAnalyzer().

◆ verbose_

bool edm::EventContentAnalyzer::verbose_
private

Definition at line 274 of file EventContentAnalyzer.cc.

Referenced by analyze().

◆ verboseIndentation_

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

Definition at line 272 of file EventContentAnalyzer.cc.

Referenced by analyze().