CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Attributes
pat::CandidateSummaryTable Class Reference

Produce a summary table of some candidate collections. More...

Inheritance diagram for pat::CandidateSummaryTable:
edm::EDAnalyzer edm::EDConsumerBase

Classes

struct  Record
 

Public Member Functions

virtual void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 CandidateSummaryTable (const edm::ParameterSet &iConfig)
 
virtual void endJob () override
 
 ~CandidateSummaryTable ()
 
- 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
 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 (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

std::vector< Recordcollections_
 
bool dumpItems_
 
std::string logName_
 
bool perEvent_
 
bool perJob_
 
std::string self_
 
size_t totalEvents_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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

Produce a summary table of some candidate collections.

FIXME FIXME Move to CandAlgos

Author
Giovanni Petrucciani
Version
Id:
CandidateSummaryTable.cc,v 1.4 2010/02/20 21:00:15 wmtan Exp

Definition at line 27 of file CandidateSummaryTable.cc.

Constructor & Destructor Documentation

pat::CandidateSummaryTable::CandidateSummaryTable ( const edm::ParameterSet iConfig)
explicit

Definition at line 63 of file CandidateSummaryTable.cc.

References collections_, edm::EDConsumerBase::consumesCollector(), edm::ParameterSet::getParameter(), SiPixelRawToDigiRegional_cfi::inputs, and SiStripGain_Fake_cff::Record.

63  :
64  totalEvents_(0),
65  perEvent_(iConfig.getUntrackedParameter<bool>("perEvent", false)),
66  perJob_(iConfig.getUntrackedParameter<bool>("perJob", true)),
67  self_(iConfig.getParameter<std::string>("@module_label")),
68  logName_(iConfig.getUntrackedParameter<std::string>("logName")),
69  dumpItems_(iConfig.getUntrackedParameter<bool>("dumpItems", false))
70 {
71  std::vector<edm::InputTag> inputs = iConfig.getParameter<std::vector<edm::InputTag> >("candidates");
72  for (std::vector<edm::InputTag>::const_iterator it = inputs.begin(); it != inputs.end(); ++it) {
73  collections_.push_back(Record(*it, consumesCollector()));
74  }
75 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
std::vector< Record > collections_
pat::CandidateSummaryTable::~CandidateSummaryTable ( )

Definition at line 77 of file CandidateSummaryTable.cc.

77  {
78 }

Member Function Documentation

void pat::CandidateSummaryTable::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDAnalyzer.

Definition at line 81 of file CandidateSummaryTable.cc.

References edm::View< T >::begin(), edm::EventID::event(), edm::Event::getByToken(), i, edm::EventBase::id(), and edm::EventID::run().

81  {
82  using namespace edm;
83  using std::setw; using std::left; using std::right; using std::setprecision;
84 
85  Handle<View<reco::Candidate> > candidates;
86  if (perEvent_) {
87  LogInfo(logName_) << "Per Event Table " << logName_ <<
88  " (" << self_ << ", run:event " << iEvent.id().run() << ":" << iEvent.id().event() << ")";
89  }
90  totalEvents_++;
91  for (std::vector<Record>::iterator it = collections_.begin(), ed = collections_.end(); it != ed; ++it) {
92  iEvent.getByToken(it->srcToken, candidates);
93  if (!candidates.failedToGet()) it->update(*candidates);
94  if (perEvent_) {
95  LogVerbatim(logName_) << " " << setw(30) << left << it->src.encode() << right;
96  if (dumpItems_) {
97  size_t i = 0;
98  std::ostringstream oss;
99  for (View<reco::Candidate>::const_iterator cand = candidates->begin(), endc = candidates->end(); cand != endc; ++cand, ++i) {
100  oss << " [" << setw(3) << i << "]" <<
101  " pt " << setw(7) << setprecision(5) << cand->pt() <<
102  " eta " << setw(7) << setprecision(5) << cand->eta() <<
103  " phi " << setw(7) << setprecision(5) << cand->phi() <<
104  " et " << setw(7) << setprecision(5) << cand->et() <<
105  " phi " << setw(7) << setprecision(5) << cand->phi() <<
106  " charge " << setw(2) << cand->charge() <<
107  " id " << setw(7) << cand->pdgId() <<
108  " st " << setw(7) << cand->status() << "\n";
109  }
110  LogVerbatim(logName_) << oss.str();
111  }
112  }
113  }
114  if (perEvent_) LogInfo(logName_) << "" ; // add an empty line
115 }
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::EventID id() const
Definition: EventBase.h:56
const_iterator begin() const
std::vector< Record > collections_
void pat::CandidateSummaryTable::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 119 of file CandidateSummaryTable.cc.

119  {
120  using std::setw; using std::left; using std::right; using std::setprecision;
121  if (perJob_) {
122  std::ostringstream oss;
123  oss << "Summary Table " << logName_ << " (" << self_ << ", events total " << totalEvents_ << ")\n";
124  for (std::vector<Record>::iterator it = collections_.begin(), ed = collections_.end(); it != ed; ++it) {
125  oss << " " << setw(30) << left << it->src.encode() << right <<
126  " present " << setw(7) << it->present << " (" << setw(4) << setprecision(3) << (it->present*100.0/totalEvents_) << "%)" <<
127  " empty " << setw(7) << it->empty << " (" << setw(4) << setprecision(3) << (it->empty*100.0/totalEvents_) << "%)" <<
128  " min " << setw(7) << it->min <<
129  " max " << setw(7) << it->max <<
130  " total " << setw(7) << it->total <<
131  " avg " << setw(5) << setprecision(3) << (it->total/double(totalEvents_)) << "\n";
132  }
133  oss << "\n";
134  edm::LogVerbatim(logName_) << oss.str();
135  }
136 }
std::vector< Record > collections_

Member Data Documentation

std::vector<Record> pat::CandidateSummaryTable::collections_
private

Definition at line 54 of file CandidateSummaryTable.cc.

Referenced by CandidateSummaryTable().

bool pat::CandidateSummaryTable::dumpItems_
private

Definition at line 58 of file CandidateSummaryTable.cc.

std::string pat::CandidateSummaryTable::logName_
private

Definition at line 57 of file CandidateSummaryTable.cc.

bool pat::CandidateSummaryTable::perEvent_
private

Definition at line 56 of file CandidateSummaryTable.cc.

bool pat::CandidateSummaryTable::perJob_
private

Definition at line 56 of file CandidateSummaryTable.cc.

std::string pat::CandidateSummaryTable::self_
private

Definition at line 57 of file CandidateSummaryTable.cc.

size_t pat::CandidateSummaryTable::totalEvents_
private

Definition at line 55 of file CandidateSummaryTable.cc.