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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
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
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

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.

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  }

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(), AlCaHLTBitMon_QueryRunRegistry::string, and edm::BranchDescription::unwrappedTypeID().

◆ ~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::EDAnalyzer.

Definition at line 331 of file EventContentAnalyzer.cc.

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  }

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_, HLT_FULL_cff::InputTag, edm::pset::Registry::instance(), MuonErrorMatrixAdjuster_cfi::instanceName, crabWrapper::key, listContent_, listProvenance_, HerwigMaxPtPartonFilter_cfi::moduleLabel, moduleLabels_, SimL1EmulatorRepack_CalouGT_cff::processName, AlCaHLTBitMon_QueryRunRegistry::string, verbose_, and verboseIndentation_.

◆ endJob()

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

Reimplemented from edm::EDAnalyzer.

Definition at line 430 of file EventContentAnalyzer.cc.

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 
440  // Test boost::lexical_cast We don't need this right now so comment it out.
441  // int k = 137;
442  // std::string ktext = boost::lexical_cast<std::string>(k);
443  // std::cout << "\nInteger " << k << " expressed as a string is |" << ktext << "|" << std::endl;
444  }

References cumulates_.

◆ fillDescriptions()

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

Definition at line 446 of file EventContentAnalyzer.cc.

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

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

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().

edm::ParameterSetID
Hash< ParameterSetType > ParameterSetID
Definition: ParameterSetID.h:21
edm::pset::Registry::instance
static Registry * instance()
Definition: Registry.cc:12
edm::BranchDescription::productInstanceName
std::string const & productInstanceName() const
Definition: BranchDescription.h:81
edm::PRODUCT_TYPE
Definition: ProductKindOfType.h:5
edm::sort_all
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
patZpeak.handle
handle
Definition: patZpeak.py:23
ProducerES_cfi.ProcessHistory
ProcessHistory
Definition: ProducerES_cfi.py:14
mod
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
np
int np
Definition: AMPTWrapper.h:43
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::EventContentAnalyzer::listProvenance_
bool listProvenance_
Definition: EventContentAnalyzer.cc:280
edm::EventContentAnalyzer::listContent_
bool listContent_
Definition: EventContentAnalyzer.cc:279
edm::Exception
Definition: EDMException.h:77
edm::BranchDescription::processName
std::string const & processName() const
Definition: BranchDescription.h:73
GenericHandle
edm::BranchDescription::unwrappedTypeID
TypeID unwrappedTypeID() const
Definition: BranchDescription.h:98
edm::binary_search_all
bool binary_search_all(ForwardSequence const &s, Datum const &d)
wrappers for std::binary_search
Definition: Algorithms.h:58
edm::EventContentAnalyzer::indentation_
std::string indentation_
Definition: EventContentAnalyzer.cc:271
ParameterSet
Definition: Functions.h:16
edm::EventContentAnalyzer::cumulates_
std::map< std::string, int > cumulates_
Definition: EventContentAnalyzer.cc:278
edm::friendlyname::friendlyName
std::string friendlyName(std::string const &iFullName)
Definition: FriendlyName.cc:278
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::LogAbsolute
Log< level::System, true > LogAbsolute
Definition: MessageLogger.h:134
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SimL1EmulatorRepack_CalouGT_cff.processName
processName
Definition: SimL1EmulatorRepack_CalouGT_cff.py:17
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
edm::BranchDescription::moduleLabel
std::string const & moduleLabel() const
Definition: BranchDescription.h:72
edm::EDAnalyzer::callWhenNewProductsRegistered
void callWhenNewProductsRegistered(std::function< void(BranchDescription const &)> const &func)
Definition: EDAnalyzer.cc:103
ParameterSetDescription
edm::EventContentAnalyzer::moduleLabels_
std::vector< std::string > moduleLabels_
Definition: EventContentAnalyzer.cc:273
edm::EventContentAnalyzer::evno_
int evno_
Definition: EventContentAnalyzer.cc:277
className
std::string className(const T &t)
Definition: ClassName.h:31
edm::BranchDescription
Definition: BranchDescription.h:32
edm::BranchDescription::className
std::string const & className() const
Definition: BranchDescription.h:79
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:159
edm::EventContentAnalyzer::getModuleLabels_
std::vector< std::string > getModuleLabels_
Definition: EventContentAnalyzer.cc:275
edm::TypeToGet
Definition: TypeToGet.h:32
edm::EventContentAnalyzer::verboseIndentation_
std::string verboseIndentation_
Definition: EventContentAnalyzer.cc:272
MuonErrorMatrixAdjuster_cfi.instanceName
instanceName
Definition: MuonErrorMatrixAdjuster_cfi.py:16
crabWrapper.key
key
Definition: crabWrapper.py:19
edm::InputTag
Definition: InputTag.h:15
edm::EventContentAnalyzer::getData_
bool getData_
Definition: EventContentAnalyzer.cc:276
edm::EventContentAnalyzer::verbose_
bool verbose_
Definition: EventContentAnalyzer.cc:274