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)
 

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

Constructor & Destructor Documentation

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

Definition at line 289 of file EventContentAnalyzer.cc.

References moduleLabels_, and edm::sort_all().

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  //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_, 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 
328  std::string startIndent = indentation_+verboseIndentation_;
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  if(getModuleLabels_.empty() ||
375  binary_search_all(getModuleLabels_, modLabel)) {
376  try {
377  GenericHandle handle(className);
378  } catch(edm::Exception const&) {
379  LogAbsolute("EventContent") << startIndent << " \"" << className << "\"" << " is an unknown type" << std::endl;
380  return;
381  }
382  GenericHandle handle(className);
383  iEvent.getByLabel(InputTag(modLabel,
384  instanceName,
385  processName),
386  handle);
387  }
388  }
389  }
390  //std::cout << "Mine" << std::endl;
391  ++evno_;
392  }
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 396 of file EventContentAnalyzer.cc.

References cumulates_.

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

Definition at line 413 of file EventContentAnalyzer.cc.

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

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

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

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

Definition at line 279 of file EventContentAnalyzer.cc.

Referenced by analyze().

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