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 &)
 
virtual void endJob ()
 
 EventContentAnalyzer (ParameterSet const &)
 
 ~EventContentAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) 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
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- 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 261 of file EventContentAnalyzer.cc.

Constructor & Destructor Documentation

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

Definition at line 288 of file EventContentAnalyzer.cc.

References getModuleLabels_, moduleLabels_, and edm::sort_all().

288  :
289  indentation_(iConfig.getUntrackedParameter("indentation", std::string("++"))),
290  verboseIndentation_(iConfig.getUntrackedParameter("verboseIndentation", std::string(" "))),
291  moduleLabels_(iConfig.getUntrackedParameter("verboseForModuleLabels", std::vector<std::string>())),
292  verbose_(iConfig.getUntrackedParameter("verbose", false) || moduleLabels_.size()>0),
293  getModuleLabels_(iConfig.getUntrackedParameter("getDataForModuleLabels", std::vector<std::string>())),
294  getData_(iConfig.getUntrackedParameter("getData", false) || getModuleLabels_.size()>0),
295  evno_(1),
296  listContent_(iConfig.getUntrackedParameter("listContent", true)){
297  //now do what ever initialization is needed
300  }
std::vector< std::string > getModuleLabels_
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:120
std::vector< std::string > moduleLabels_
edm::EventContentAnalyzer::~EventContentAnalyzer ( )

Definition at line 302 of file EventContentAnalyzer.cc.

302  {
303 
304  // do anything here that needs to be done at destruction time
305  // (e.g. close files, deallocate resources etc.)
306 
307  }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 315 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_, combine::key, listContent_, moduleLabels_, AlCaHLTBitMon_QueryRunRegistry::string, verbose_, and verboseIndentation_.

315  {
316  typedef std::vector<Provenance const*> Provenances;
317  Provenances provenances;
318 
319  iEvent.getAllProvenance(provenances);
320 
321  if(listContent_) {
322  LogAbsolute("EventContent") << "\n" << indentation_ << "Event " << std::setw(5) << evno_ << " contains "
323  << provenances.size() << " product" << (provenances.size() == 1 ? "" : "s")
324  << " with friendlyClassName, moduleLabel, productInstanceName and processName:"
325  << std::endl;
326  }
327 
329  for(Provenances::iterator itProv = provenances.begin(), itProvEnd = provenances.end();
330  itProv != itProvEnd;
331  ++itProv) {
332  std::string const& className = (*itProv)->className();
333 
334  std::string const& friendlyName = (*itProv)->friendlyClassName();
335  //if(friendlyName.empty()) friendlyName = std::string("||");
336 
337  std::string const& modLabel = (*itProv)->moduleLabel();
338  //if(modLabel.empty()) modLabel = std::string("||");
339 
340  std::string const& instanceName = (*itProv)->productInstanceName();
341  //if(instanceName.empty()) instanceName = std::string("||");
342 
343  std::string const& processName = (*itProv)->processName();
344 
345  bool doVerbose = verbose_ && (moduleLabels_.empty() ||
346  binary_search_all(moduleLabels_, modLabel));
347 
348  if(listContent_ || doVerbose) {
349  LogAbsolute("EventContent") << indentation_ << friendlyName
350  << " \"" << modLabel
351  << "\" \"" << instanceName << "\" \""
352  << processName << "\""
353  << " (productId = " << (*itProv)->productID() << ")"
354  << std::endl;
355  }
356 
357  std::string key = friendlyName
358  + std::string(" + \"") + modLabel
359  + std::string("\" + \"") + instanceName + "\" \"" + processName + "\"";
360  ++cumulates_[key];
361 
362  if(doVerbose) {
363  //indent one level before starting to print
364  printObject(iEvent,
365  className,
366  modLabel,
367  instanceName,
368  processName,
369  startIndent,
370  verboseIndentation_);
371  continue;
372  }
373  if(getData_) {
374  std::string class_and_label = friendlyName + "_" + modLabel;
375  if(getModuleLabels_.empty() ||
376  binary_search_all(getModuleLabels_, modLabel) ||
377  binary_search_all(getModuleLabels_, class_and_label)) {
378  try {
379  GenericHandle handle(className);
380  } catch(edm::Exception const&) {
381  LogAbsolute("EventContent") << startIndent << " \"" << className << "\"" << " is an unknown type" << std::endl;
382  return;
383  }
384  GenericHandle handle(className);
385  iEvent.getByLabel(InputTag(modLabel,
386  instanceName,
387  processName),
388  handle);
389  }
390  }
391  }
392  //std::cout << "Mine" << std::endl;
393  ++evno_;
394  }
std::vector< std::string > getModuleLabels_
std::map< std::string, int > cumulates_
int iEvent
Definition: GenABIO.cc:243
std::string friendlyName(std::string const &iFullName)
tuple handle
Definition: patZpeak.py:22
std::vector< std::string > moduleLabels_
list key
Definition: combine.py:13
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  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 398 of file EventContentAnalyzer.cc.

References cumulates_.

398  {
399  typedef std::map<std::string, int> nameMap;
400 
401  LogAbsolute("EventContent") << "\nSummary for key being the concatenation of friendlyClassName, moduleLabel, productInstanceName and processName" << std::endl;
402  for(nameMap::const_iterator it = cumulates_.begin(), itEnd = cumulates_.end();
403  it != itEnd;
404  ++it) {
405  LogAbsolute("EventContent") << std::setw(6) << it->second << " occurrences of key " << it->first << std::endl;
406  }
407 
408  // Test boost::lexical_cast We don't need this right now so comment it out.
409  // int k = 137;
410  // std::string ktext = boost::lexical_cast<std::string>(k);
411  // std::cout << "\nInteger " << k << " expressed as a string is |" << ktext << "|" << std::endl;
412  }
std::map< std::string, int > cumulates_
void edm::EventContentAnalyzer::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 415 of file EventContentAnalyzer.cc.

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

415  {
416 
417  descriptions.setComment("This plugin will print a list of all products in the event "
418  "provenance. It also has options to print and/or get each product.");
419 
421 
422  ParameterDescriptionNode* np;
423 
424  std::string defaultString("++");
425  np = desc.addOptionalUntracked<std::string>("indentation", defaultString);
426  np->setComment("This string is printed at the beginning of every line printed during event processing.");
427 
428  np = desc.addOptionalUntracked<bool>("verbose", false);
429  np->setComment("If true, the contents of products are printed.");
430 
431  defaultString = " ";
432  np = desc.addOptionalUntracked<std::string>("verboseIndentation", defaultString);
433  np->setComment("This string is used to further indent lines when printing the contents of products in verbose mode.");
434 
435  std::vector<std::string> defaultVString;
436 
437  np = desc.addOptionalUntracked<std::vector<std::string> >("verboseForModuleLabels", defaultVString);
438  np->setComment("If this vector is not empty, then only products with module labels on this list are printed.");
439 
440  np = desc.addOptionalUntracked<bool>("getData", false);
441  np->setComment("If true the products will be retrieved using getByLabel.");
442 
443  np = desc.addOptionalUntracked<std::vector<std::string> >("getDataForModuleLabels", defaultVString);
444  np->setComment("If this vector is not empty, then only products with module labels on this list are retrieved by getByLabel.");
445 
446  np = desc.addOptionalUntracked<bool>("listContent", true);
447  np->setComment("If true then print a list of all the event content.");
448 
449 
450  descriptions.add("printContent", desc);
451  }
int np
Definition: AMPTWrapper.h:33

Member Data Documentation

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

Definition at line 281 of file EventContentAnalyzer.cc.

Referenced by analyze(), and endJob().

int edm::EventContentAnalyzer::evno_
private

Definition at line 280 of file EventContentAnalyzer.cc.

Referenced by analyze().

bool edm::EventContentAnalyzer::getData_
private

Definition at line 279 of file EventContentAnalyzer.cc.

Referenced by analyze().

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

Definition at line 278 of file EventContentAnalyzer.cc.

Referenced by analyze(), and EventContentAnalyzer().

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

Definition at line 274 of file EventContentAnalyzer.cc.

Referenced by analyze().

bool edm::EventContentAnalyzer::listContent_
private

Definition at line 282 of file EventContentAnalyzer.cc.

Referenced by analyze().

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

Definition at line 276 of file EventContentAnalyzer.cc.

Referenced by analyze(), and EventContentAnalyzer().

bool edm::EventContentAnalyzer::verbose_
private

Definition at line 277 of file EventContentAnalyzer.cc.

Referenced by analyze().

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

Definition at line 275 of file EventContentAnalyzer.cc.

Referenced by analyze().