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

virtual void analyze (Event const &, EventSetup const &) override
 
virtual void endJob () override
 
 EventContentAnalyzer (ParameterSet const &)
 
 ~EventContentAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- 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
 
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 &)
 

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::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_.size()>0),
294  getModuleLabels_(iConfig.getUntrackedParameter("getDataForModuleLabels", std::vector<std::string>())),
295  getData_(iConfig.getUntrackedParameter("getData", false) || getModuleLabels_.size()>0),
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()) {
306  edm::InputTag{iBranch.moduleLabel(),iBranch.productInstanceName(),iBranch.processName()});
307  } else {
308  for (auto const& mod : this->getModuleLabels_) {
309  if (iBranch.moduleLabel() == mod) {
311  edm::InputTag{mod,iBranch.productInstanceName(),iBranch.processName()});
312  break;
313  }
314  }
315  }
316  }
317  );
318  }
319 
320  }
std::vector< std::string > getModuleLabels_
std::string const & processName() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
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:114
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
edm::EventContentAnalyzer::~EventContentAnalyzer ( )

Definition at line 322 of file EventContentAnalyzer.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 335 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_.

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

References cumulates_.

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

Definition at line 433 of file EventContentAnalyzer.cc.

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

433  {
434 
435  descriptions.setComment("This plugin will print a list of all products in the event "
436  "provenance. It also has options to print and/or get each product.");
437 
439 
440  ParameterDescriptionNode* np;
441 
442  std::string defaultString("++");
443  np = desc.addOptionalUntracked<std::string>("indentation", defaultString);
444  np->setComment("This string is printed at the beginning of every line printed during event processing.");
445 
446  np = desc.addOptionalUntracked<bool>("verbose", false);
447  np->setComment("If true, the contents of products are printed.");
448 
449  defaultString = " ";
450  np = desc.addOptionalUntracked<std::string>("verboseIndentation", defaultString);
451  np->setComment("This string is used to further indent lines when printing the contents of products in verbose mode.");
452 
453  std::vector<std::string> defaultVString;
454 
455  np = desc.addOptionalUntracked<std::vector<std::string> >("verboseForModuleLabels", defaultVString);
456  np->setComment("If this vector is not empty, then only products with module labels on this list are printed.");
457 
458  np = desc.addOptionalUntracked<bool>("getData", false);
459  np->setComment("If true the products will be retrieved using getByLabel.");
460 
461  np = desc.addOptionalUntracked<std::vector<std::string> >("getDataForModuleLabels", defaultVString);
462  np->setComment("If this vector is not empty, then only products with module labels on this list are retrieved by getByLabel.");
463 
464  np = desc.addOptionalUntracked<bool>("listContent", true);
465  np->setComment("If true then print a list of all the event content.");
466 
467 
468  descriptions.add("printContent", desc);
469  }
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().