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

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
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::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

Produce a summary table of some candidate collections.

FIXME FIXME Move to CandAlgos

Author
Giovanni Petrucciani
Version
Id:
CandidateSummaryTable.cc,v 1.5 2013/02/27 23:26:56 wmtan Exp

Definition at line 27 of file CandidateSummaryTable.cc.

Constructor & Destructor Documentation

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

Definition at line 62 of file CandidateSummaryTable.cc.

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

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

Definition at line 76 of file CandidateSummaryTable.cc.

76  {
77 }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 80 of file CandidateSummaryTable.cc.

References edm::EventID::event(), edm::Event::getByLabel(), i, edm::EventBase::id(), and edm::EventID::run().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 118 of file CandidateSummaryTable.cc.

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

Member Data Documentation

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

Definition at line 53 of file CandidateSummaryTable.cc.

Referenced by CandidateSummaryTable().

bool pat::CandidateSummaryTable::dumpItems_
private

Definition at line 57 of file CandidateSummaryTable.cc.

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

Definition at line 56 of file CandidateSummaryTable.cc.

bool pat::CandidateSummaryTable::perEvent_
private

Definition at line 55 of file CandidateSummaryTable.cc.

bool pat::CandidateSummaryTable::perJob_
private

Definition at line 55 of file CandidateSummaryTable.cc.

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

Definition at line 56 of file CandidateSummaryTable.cc.

size_t pat::CandidateSummaryTable::totalEvents_
private

Definition at line 54 of file CandidateSummaryTable.cc.