Produce a summary table of some candidate collections. More...
Classes | |
struct | Record |
Public Member Functions | |
virtual void | analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup) |
CandidateSummaryTable (const edm::ParameterSet &iConfig) | |
virtual void | endJob () |
~CandidateSummaryTable () | |
Private Attributes | |
std::vector< Record > | collections_ |
bool | dumpItems_ |
std::string | logName_ |
bool | perEvent_ |
bool | perJob_ |
std::string | self_ |
size_t | totalEvents_ |
Produce a summary table of some candidate collections.
FIXME FIXME Move to CandAlgos
Definition at line 27 of file CandidateSummaryTable.cc.
pat::CandidateSummaryTable::CandidateSummaryTable | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 62 of file CandidateSummaryTable.cc.
References collections_, edm::ParameterSet::getParameter(), and SiStripGain_Fake_cff::Record.
: totalEvents_(0), perEvent_(iConfig.getUntrackedParameter<bool>("perEvent", false)), perJob_(iConfig.getUntrackedParameter<bool>("perJob", true)), self_(iConfig.getParameter<std::string>("@module_label")), logName_(iConfig.getUntrackedParameter<std::string>("logName")), dumpItems_(iConfig.getUntrackedParameter<bool>("dumpItems", false)) { std::vector<edm::InputTag> inputs = iConfig.getParameter<std::vector<edm::InputTag> >("candidates"); for (std::vector<edm::InputTag>::const_iterator it = inputs.begin(); it != inputs.end(); ++it) { collections_.push_back(Record(*it)); } }
pat::CandidateSummaryTable::~CandidateSummaryTable | ( | ) |
Definition at line 76 of file CandidateSummaryTable.cc.
{ }
void pat::CandidateSummaryTable::analyze | ( | const edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [virtual] |
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().
{ using namespace edm; using std::setw; using std::left; using std::right; using std::setprecision; Handle<View<reco::Candidate> > candidates; if (perEvent_) { LogInfo(logName_) << "Per Event Table " << logName_ << " (" << self_ << ", run:event " << iEvent.id().run() << ":" << iEvent.id().event() << ")"; } totalEvents_++; for (std::vector<Record>::iterator it = collections_.begin(), ed = collections_.end(); it != ed; ++it) { iEvent.getByLabel(it->src, candidates); if (!candidates.failedToGet()) it->update(*candidates); if (perEvent_) { LogVerbatim(logName_) << " " << setw(30) << left << it->src.encode() << right; if (dumpItems_) { size_t i = 0; std::ostringstream oss; for (View<reco::Candidate>::const_iterator cand = candidates->begin(), endc = candidates->end(); cand != endc; ++cand, ++i) { oss << " [" << setw(3) << i << "]" << " pt " << setw(7) << setprecision(5) << cand->pt() << " eta " << setw(7) << setprecision(5) << cand->eta() << " phi " << setw(7) << setprecision(5) << cand->phi() << " et " << setw(7) << setprecision(5) << cand->et() << " phi " << setw(7) << setprecision(5) << cand->phi() << " charge " << setw(2) << cand->charge() << " id " << setw(7) << cand->pdgId() << " st " << setw(7) << cand->status() << "\n"; } LogVerbatim(logName_) << oss.str(); } } } if (perEvent_) LogInfo(logName_) << "" ; // add an empty line }
void pat::CandidateSummaryTable::endJob | ( | void | ) | [virtual] |
Reimplemented from edm::EDAnalyzer.
Definition at line 118 of file CandidateSummaryTable.cc.
{ using std::setw; using std::left; using std::right; using std::setprecision; if (perJob_) { std::ostringstream oss; oss << "Summary Table " << logName_ << " (" << self_ << ", events total " << totalEvents_ << ")\n"; for (std::vector<Record>::iterator it = collections_.begin(), ed = collections_.end(); it != ed; ++it) { oss << " " << setw(30) << left << it->src.encode() << right << " present " << setw(7) << it->present << " (" << setw(4) << setprecision(3) << (it->present*100.0/totalEvents_) << "%)" << " empty " << setw(7) << it->empty << " (" << setw(4) << setprecision(3) << (it->empty*100.0/totalEvents_) << "%)" << " min " << setw(7) << it->min << " max " << setw(7) << it->max << " total " << setw(7) << it->total << " avg " << setw(5) << setprecision(3) << (it->total/double(totalEvents_)) << "\n"; } oss << "\n"; edm::LogVerbatim(logName_) << oss.str(); } }
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.