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::vector< ModuleDescription const * > &modules, 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
 
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  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 = iEvent.processHistory();
383  for (ProcessConfiguration const& pc : processHistory) {
384  if (pc.processName() == prov.processName()) {
385  ParameterSetID const& psetID = pc.parameterSetID();
386  pset::Registry const* psetRegistry = pset::Registry::instance();
387  ParameterSet const* processPset = psetRegistry->getMapped(psetID);
388  if (processPset) {
389  if (processPset->existsAs<ParameterSet>(modLabel)) {
390  if (isAlias) {
391  LogAbsolute("EventContent") << "Alias PSet";
392  }
393  LogAbsolute("EventContent") << processPset->getParameterSet(modLabel);
394  }
395  if (isAlias and processPset->existsAs<ParameterSet>(aliasForModLabel)) {
396  LogAbsolute("EventContent") << processPset->getParameterSet(aliasForModLabel);
397  }
398  }
399  }
400  }
401  }
402  }
403  }
404  std::string key = friendlyName + std::string(" + \"") + modLabel + std::string("\" + \"") + instanceName +
405  "\" \"" + processName + "\"";
406  ++cumulates_[key];
407 
408  if (doVerbose) {
409  //indent one level before starting to print
410  printObject(iEvent, className, modLabel, instanceName, processName, startIndent, verboseIndentation_);
411  continue;
412  }
413  if (getData_) {
414  std::string class_and_label = friendlyName + "_" + modLabel;
415  if (getModuleLabels_.empty() || binary_search_all(getModuleLabels_, modLabel) ||
416  binary_search_all(getModuleLabels_, class_and_label)) {
417  try {
419  } catch (edm::Exception const&) {
420  LogAbsolute("EventContent") << startIndent << " \"" << className << "\""
421  << " is an unknown type" << std::endl;
422  return;
423  }
425  iEvent.getByLabel(InputTag(modLabel, instanceName, processName), handle);
426  }
427  }
428  }
429  //std::cout << "Mine" << std::endl;
430  ++evno_;
431  }

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 434 of file EventContentAnalyzer.cc.

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

References cumulates_.

◆ fillDescriptions()

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

Definition at line 450 of file EventContentAnalyzer.cc.

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

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:89287
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:97
edm::binary_search_all
bool binary_search_all(ForwardSequence const &s, Datum const &d)
wrappers for std::binary_search
Definition: Algorithms.h:58
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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
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:94
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:153
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