CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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:118
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::getAllProvenance(), edm::Event::getByLabel(), getData_, getModuleLabels_, patZpeak::handle, indentation_, HLT_25ns10e33_v2_cff::InputTag, relval_steps::key, listContent_, moduleLabels_, FSQHLTOfflineSource_cfi::processName, AlCaHLTBitMon_QueryRunRegistry::string, verbose_, and verboseIndentation_.

335  {
336  typedef std::vector<Provenance const*> Provenances;
337  Provenances provenances;
338 
339  iEvent.getAllProvenance(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(Provenances::iterator itProv = provenances.begin(), itProvEnd = provenances.end();
350  itProv != itProvEnd;
351  ++itProv) {
352  std::string const& className = (*itProv)->className();
353 
354  std::string const& friendlyName = (*itProv)->friendlyClassName();
355  //if(friendlyName.empty()) friendlyName = std::string("||");
356 
357  std::string const& modLabel = (*itProv)->moduleLabel();
358  //if(modLabel.empty()) modLabel = std::string("||");
359 
360  std::string const& instanceName = (*itProv)->productInstanceName();
361  //if(instanceName.empty()) instanceName = std::string("||");
362 
363  std::string const& processName = (*itProv)->processName();
364 
365  bool doVerbose = verbose_ && (moduleLabels_.empty() ||
366  binary_search_all(moduleLabels_, modLabel));
367 
368  if(listContent_ || doVerbose) {
369  LogAbsolute("EventContent") << indentation_ << friendlyName
370  << " \"" << modLabel
371  << "\" \"" << instanceName << "\" \""
372  << processName << "\""
373  << " (productId = " << (*itProv)->productID() << ")"
374  << std::endl;
375  }
376 
377  std::string key = friendlyName
378  + std::string(" + \"") + modLabel
379  + std::string("\" + \"") + instanceName + "\" \"" + processName + "\"";
380  ++cumulates_[key];
381 
382  if(doVerbose) {
383  //indent one level before starting to print
384  printObject(iEvent,
385  className,
386  modLabel,
387  instanceName,
388  processName,
389  startIndent,
390  verboseIndentation_);
391  continue;
392  }
393  if(getData_) {
394  std::string class_and_label = friendlyName + "_" + modLabel;
395  if(getModuleLabels_.empty() ||
396  binary_search_all(getModuleLabels_, modLabel) ||
397  binary_search_all(getModuleLabels_, class_and_label)) {
398  try {
399  GenericHandle handle(className);
400  } catch(edm::Exception const&) {
401  LogAbsolute("EventContent") << startIndent << " \"" << className << "\"" << " is an unknown type" << std::endl;
402  return;
403  }
404  GenericHandle handle(className);
405  iEvent.getByLabel(InputTag(modLabel,
406  instanceName,
407  processName),
408  handle);
409  }
410  }
411  }
412  //std::cout << "Mine" << std::endl;
413  ++evno_;
414  }
std::vector< std::string > getModuleLabels_
std::map< std::string, int > cumulates_
int iEvent
Definition: GenABIO.cc:230
std::string friendlyName(std::string const &iFullName)
tuple handle
Definition: patZpeak.py:22
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
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 418 of file EventContentAnalyzer.cc.

References cumulates_.

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

Definition at line 435 of file EventContentAnalyzer.cc.

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

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