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

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 ()
 

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
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 263 of file EventContentAnalyzer.cc.

Constructor & Destructor Documentation

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

Definition at line 290 of file EventContentAnalyzer.cc.

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

290  :
291  indentation_(iConfig.getUntrackedParameter("indentation", std::string("++"))),
292  verboseIndentation_(iConfig.getUntrackedParameter("verboseIndentation", std::string(" "))),
293  moduleLabels_(iConfig.getUntrackedParameter("verboseForModuleLabels", std::vector<std::string>())),
294  verbose_(iConfig.getUntrackedParameter("verbose", false) || moduleLabels_.size()>0),
295  getModuleLabels_(iConfig.getUntrackedParameter("getDataForModuleLabels", std::vector<std::string>())),
296  getData_(iConfig.getUntrackedParameter("getData", false) || getModuleLabels_.size()>0),
297  evno_(1),
298  listContent_(iConfig.getUntrackedParameter("listContent", true)){
299  //now do what ever initialization is needed
302  }
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 304 of file EventContentAnalyzer.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 317 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_, verbose_, and verboseIndentation_.

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

References cumulates_.

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

Definition at line 417 of file EventContentAnalyzer.cc.

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

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

Member Data Documentation

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

Definition at line 283 of file EventContentAnalyzer.cc.

Referenced by analyze(), and endJob().

int edm::EventContentAnalyzer::evno_
private

Definition at line 282 of file EventContentAnalyzer.cc.

Referenced by analyze().

bool edm::EventContentAnalyzer::getData_
private

Definition at line 281 of file EventContentAnalyzer.cc.

Referenced by analyze().

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

Definition at line 280 of file EventContentAnalyzer.cc.

Referenced by analyze(), and EventContentAnalyzer().

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

Definition at line 276 of file EventContentAnalyzer.cc.

Referenced by analyze().

bool edm::EventContentAnalyzer::listContent_
private

Definition at line 284 of file EventContentAnalyzer.cc.

Referenced by analyze().

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

Definition at line 278 of file EventContentAnalyzer.cc.

Referenced by analyze(), and EventContentAnalyzer().

bool edm::EventContentAnalyzer::verbose_
private

Definition at line 279 of file EventContentAnalyzer.cc.

Referenced by analyze().

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

Definition at line 277 of file EventContentAnalyzer.cc.

Referenced by analyze().