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

Constructor & Destructor Documentation

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

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

289  :
290  indentation_(iConfig.getUntrackedParameter("indentation", std::string("++"))),
291  verboseIndentation_(iConfig.getUntrackedParameter("verboseIndentation", std::string(" "))),
292  moduleLabels_(iConfig.getUntrackedParameter("verboseForModuleLabels", std::vector<std::string>())),
293  verbose_(iConfig.getUntrackedParameter("verbose", false) || !moduleLabels_.empty()),
294  getModuleLabels_(iConfig.getUntrackedParameter("getDataForModuleLabels", std::vector<std::string>())),
295  getData_(iConfig.getUntrackedParameter("getData", false) || !getModuleLabels_.empty()),
296  evno_(1),
297  listContent_(iConfig.getUntrackedParameter("listContent", true))
298  {
299  //now do what ever initialization is needed
302  if(getData_) {
304  if(getModuleLabels_.empty()) {
305  const std::string kPathStatus("edm::PathStatus");
306  const std::string kEndPathStatus("edm::EndPathStatus");
307  if(iBranch.className() != kPathStatus && iBranch.className() != kEndPathStatus) {
309  edm::InputTag{iBranch.moduleLabel(),iBranch.productInstanceName(),iBranch.processName()});
310  }
311  } else {
312  for (auto const& mod : this->getModuleLabels_) {
313  if (iBranch.moduleLabel() == mod) {
315  edm::InputTag{mod,iBranch.productInstanceName(),iBranch.processName()});
316  break;
317  }
318  }
319  }
320  }
321  );
322  }
323 
324  }
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 326 of file EventContentAnalyzer.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 339 of file EventContentAnalyzer.cc.

References edm::binary_search_all(), className(), cumulates_, evno_, edm::friendlyname::friendlyName(), edm::Event::getAllStableProvenance(), edm::Event::getByLabel(), getData_, getModuleLabels_, cmsBatch::handle, indentation_, MuonErrorMatrixAdjuster_cfi::instanceName, crabWrapper::key, listContent_, moduleLabels_, modifiedElectrons_cfi::processName, AlCaHLTBitMon_QueryRunRegistry::string, verbose_, and verboseIndentation_.

339  {
340  typedef std::vector<StableProvenance const*> Provenances;
341  Provenances provenances;
342 
343  iEvent.getAllStableProvenance(provenances);
344 
345  if(listContent_) {
346  LogAbsolute("EventContent") << "\n" << indentation_ << "Event " << std::setw(5) << evno_ << " contains "
347  << provenances.size() << " product" << (provenances.size() == 1 ? "" : "s")
348  << " with friendlyClassName, moduleLabel, productInstanceName and processName:"
349  << std::endl;
350  }
351 
353  for(auto const& provenance : provenances) {
354  std::string const& className = provenance->className();
355  const std::string kPathStatus("edm::PathStatus");
356  const std::string kEndPathStatus("edm::EndPathStatus");
357  if(className == kPathStatus || className == kEndPathStatus) {
358  continue;
359  }
360  std::string const& friendlyName = provenance->friendlyClassName();
361  //if(friendlyName.empty()) friendlyName = std::string("||");
362 
363  std::string const& modLabel = provenance->moduleLabel();
364  //if(modLabel.empty()) modLabel = std::string("||");
365 
366  std::string const& instanceName = provenance->productInstanceName();
367  //if(instanceName.empty()) instanceName = std::string("||");
368 
369  std::string const& processName = provenance->processName();
370 
371  bool doVerbose = verbose_ && (moduleLabels_.empty() ||
372  binary_search_all(moduleLabels_, modLabel));
373 
374  if(listContent_ || doVerbose) {
375  LogAbsolute("EventContent") << indentation_ << friendlyName
376  << " \"" << modLabel
377  << "\" \"" << instanceName << "\" \""
378  << processName << "\""
379  << " (productId = " << provenance->productID() << ")"
380  << std::endl;
381  }
382 
383  std::string key = friendlyName
384  + std::string(" + \"") + modLabel
385  + std::string("\" + \"") + instanceName + "\" \"" + processName + "\"";
386  ++cumulates_[key];
387 
388  if(doVerbose) {
389  //indent one level before starting to print
390  printObject(iEvent,
391  className,
392  modLabel,
393  instanceName,
394  processName,
395  startIndent,
396  verboseIndentation_);
397  continue;
398  }
399  if(getData_) {
400  std::string class_and_label = friendlyName + "_" + modLabel;
401  if(getModuleLabels_.empty() ||
402  binary_search_all(getModuleLabels_, modLabel) ||
403  binary_search_all(getModuleLabels_, class_and_label)) {
404  try {
405  GenericHandle handle(className);
406  } catch(edm::Exception const&) {
407  LogAbsolute("EventContent") << startIndent << " \"" << className << "\"" << " is an unknown type" << std::endl;
408  return;
409  }
410  GenericHandle handle(className);
411  iEvent.getByLabel(InputTag(modLabel,
412  instanceName,
413  processName),
414  handle);
415  }
416  }
417  }
418  //std::cout << "Mine" << std::endl;
419  ++evno_;
420  }
std::vector< std::string > getModuleLabels_
std::map< std::string, int > cumulates_
int iEvent
Definition: GenABIO.cc:230
std::string friendlyName(std::string const &iFullName)
std::vector< std::string > moduleLabels_
bool binary_search_all(ForwardSequence const &s, Datum const &d)
wrappers for std::binary_search
Definition: Algorithms.h:76
std::string className(const T &t)
Definition: ClassName.h:30
void edm::EventContentAnalyzer::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 424 of file EventContentAnalyzer.cc.

References cumulates_.

424  {
425  typedef std::map<std::string, int> nameMap;
426 
427  LogAbsolute("EventContent") << "\nSummary for key being the concatenation of friendlyClassName, moduleLabel, productInstanceName and processName" << std::endl;
428  for(nameMap::const_iterator it = cumulates_.begin(), itEnd = cumulates_.end();
429  it != itEnd;
430  ++it) {
431  LogAbsolute("EventContent") << std::setw(6) << it->second << " occurrences of key " << it->first << std::endl;
432  }
433 
434  // Test boost::lexical_cast We don't need this right now so comment it out.
435  // int k = 137;
436  // std::string ktext = boost::lexical_cast<std::string>(k);
437  // std::cout << "\nInteger " << k << " expressed as a string is |" << ktext << "|" << std::endl;
438  }
std::map< std::string, int > cumulates_
void edm::EventContentAnalyzer::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 441 of file EventContentAnalyzer.cc.

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

441  {
442 
443  descriptions.setComment("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("This string is used to further indent lines when printing the contents of products in verbose mode.");
460 
461  std::vector<std::string> defaultVString;
462 
463  np = desc.addOptionalUntracked<std::vector<std::string> >("verboseForModuleLabels", defaultVString);
464  np->setComment("If this vector is not empty, then only products with module labels on this list are printed.");
465 
466  np = desc.addOptionalUntracked<bool>("getData", false);
467  np->setComment("If true the products will be retrieved using getByLabel.");
468 
469  np = desc.addOptionalUntracked<std::vector<std::string> >("getDataForModuleLabels", defaultVString);
470  np->setComment("If this vector is not empty, then only products with module labels on this list are retrieved by getByLabel.");
471 
472  np = desc.addOptionalUntracked<bool>("listContent", true);
473  np->setComment("If true then print a list of all the event content.");
474 
475 
476  descriptions.add("printContent", desc);
477  }
int np
Definition: AMPTWrapper.h:33

Member Data Documentation

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

Definition at line 282 of file EventContentAnalyzer.cc.

Referenced by analyze(), and endJob().

int edm::EventContentAnalyzer::evno_
private

Definition at line 281 of file EventContentAnalyzer.cc.

Referenced by analyze().

bool edm::EventContentAnalyzer::getData_
private

Definition at line 280 of file EventContentAnalyzer.cc.

Referenced by analyze(), and EventContentAnalyzer().

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

Definition at line 279 of file EventContentAnalyzer.cc.

Referenced by analyze(), and EventContentAnalyzer().

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

Definition at line 275 of file EventContentAnalyzer.cc.

Referenced by analyze().

bool edm::EventContentAnalyzer::listContent_
private

Definition at line 283 of file EventContentAnalyzer.cc.

Referenced by analyze().

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

Definition at line 277 of file EventContentAnalyzer.cc.

Referenced by analyze(), and EventContentAnalyzer().

bool edm::EventContentAnalyzer::verbose_
private

Definition at line 278 of file EventContentAnalyzer.cc.

Referenced by analyze().

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

Definition at line 276 of file EventContentAnalyzer.cc.

Referenced by analyze().