CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
pat::CandidateSummaryTable Class Reference

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

Inheritance diagram for pat::CandidateSummaryTable:
edm::stream::EDAnalyzer< edm::GlobalCache< pathelpers::RecordCache > > edm::stream::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 CandidateSummaryTable (const edm::ParameterSet &iConfig, const pathelpers::RecordCache *)
 
 ~CandidateSummaryTable () override
 
- Public Member Functions inherited from edm::stream::EDAnalyzer< edm::GlobalCache< pathelpers::RecordCache > >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void globalEndJob (const pathelpers::RecordCache *)
 
static std::unique_ptr< pathelpers::RecordCacheinitializeGlobalCache (edm::ParameterSet const &conf)
 
- Static Public Member Functions inherited from edm::stream::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

std::vector< std::pair< edm::InputTag, edm::EDGetTokenT< edm::View< reco::Candidate > > > > srcTokens
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDAnalyzer< edm::GlobalCache< pathelpers::RecordCache > >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDAnalyzerBase
typedef EDAnalyzerAdaptorBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 76 of file CandidateSummaryTable.cc.

Constructor & Destructor Documentation

pat::CandidateSummaryTable::CandidateSummaryTable ( const edm::ParameterSet iConfig,
const pathelpers::RecordCache  
)
explicit

Definition at line 94 of file CandidateSummaryTable.cc.

References edm::ParameterSet::getParameter(), and PatBasicFWLiteJetAnalyzer_Selector_cfg::inputs.

94  {
95  const std::vector<edm::InputTag>& inputs = iConfig.getParameter<std::vector<edm::InputTag> >("candidates");
96  for (std::vector<edm::InputTag>::const_iterator it = inputs.begin(); it != inputs.end(); ++it) {
97  srcTokens.emplace_back(*it, consumes<edm::View<reco::Candidate> >(*it));
98  }
99 }
T getParameter(std::string const &) const
std::vector< std::pair< edm::InputTag, edm::EDGetTokenT< edm::View< reco::Candidate > > > > srcTokens
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
pat::CandidateSummaryTable::~CandidateSummaryTable ( )
override

Definition at line 101 of file CandidateSummaryTable.cc.

101  {
102 }

Member Function Documentation

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

Definition at line 105 of file CandidateSummaryTable.cc.

References objects.IsoTrackAnalyzer::candidates, edm::EventID::event(), edm::HandleBase::failedToGet(), edm::Event::getByToken(), mps_fire::i, edm::EventBase::id(), and edm::EventID::run().

105  {
106  using namespace edm;
107  using std::setw; using std::left; using std::right; using std::setprecision;
108 
110  if (globalCache()->perEvent_) {
111  LogInfo(globalCache()->logName_) << "Per Event Table " << globalCache()->logName_
112  << " (" << globalCache()->self_ << ", run:event "
113  << iEvent.id().run() << ":" << iEvent.id().event() << ")";
114  }
115  ++(globalCache()->totalEvents_);
116  auto& collections = globalCache()->collections_;
117  auto tags = srcTokens.cbegin();
118  for (auto it = collections.begin(), ed = collections.end(); it != ed; ++it, ++tags) {
119  iEvent.getByToken(tags->second, candidates);
120  if (!candidates.failedToGet()) it->update(*candidates);
121  if (globalCache()->perEvent_) {
122  LogVerbatim(globalCache()->logName_) << " " << setw(30) << left << it->src.encode() << right;
123  if (globalCache()->dumpItems_) {
124  size_t i = 0;
125  std::ostringstream oss;
126  for (View<reco::Candidate>::const_iterator cand = candidates->begin(), endc = candidates->end(); cand != endc; ++cand, ++i) {
127  oss << " [" << setw(3) << i << "]" <<
128  " pt " << setw(7) << setprecision(5) << cand->pt() <<
129  " eta " << setw(7) << setprecision(5) << cand->eta() <<
130  " phi " << setw(7) << setprecision(5) << cand->phi() <<
131  " et " << setw(7) << setprecision(5) << cand->et() <<
132  " phi " << setw(7) << setprecision(5) << cand->phi() <<
133  " charge " << setw(2) << cand->charge() <<
134  " id " << setw(7) << cand->pdgId() <<
135  " st " << setw(7) << cand->status() << "\n";
136  }
137  LogVerbatim(globalCache()->logName_) << oss.str();
138  }
139  }
140  }
141  if (globalCache()->perEvent_) LogInfo(globalCache()->logName_) << "" ; // add an empty line
142 }
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
std::vector< std::pair< edm::InputTag, edm::EDGetTokenT< edm::View< reco::Candidate > > > > srcTokens
bool failedToGet() const
Definition: HandleBase.h:78
edm::EventID id() const
Definition: EventBase.h:60
HLT enums.
void pat::CandidateSummaryTable::globalEndJob ( const pathelpers::RecordCache rcd)
static

Definition at line 146 of file CandidateSummaryTable.cc.

References pathelpers::RecordCache::collections_, DEFINE_FWK_MODULE, pathelpers::RecordCache::logName_, pathelpers::RecordCache::perJob_, pathelpers::RecordCache::self_, and pathelpers::RecordCache::totalEvents_.

146  {
147  using std::setw; using std::left; using std::right; using std::setprecision;
148  if (rcd->perJob_) {
149  std::ostringstream oss;
150  oss << "Summary Table " << rcd->logName_ << " (" << rcd->self_ << ", events total " << rcd->totalEvents_ << ")\n";
151  for (auto it = rcd->collections_.cbegin(), ed = rcd->collections_.cend(); it != ed; ++it) {
152  oss << " " << setw(30) << left << it->src.encode() << right <<
153  " present " << setw(7) << it->present << " (" << setw(4) << setprecision(3) << (it->present*100.0/rcd->totalEvents_) << "%)" <<
154  " empty " << setw(7) << it->empty << " (" << setw(4) << setprecision(3) << (it->empty*100.0/rcd->totalEvents_) << "%)" <<
155  " min " << setw(7) << it->min <<
156  " max " << setw(7) << it->max <<
157  " total " << setw(7) << it->total <<
158  " avg " << setw(5) << setprecision(3) << (it->total/double(rcd->totalEvents_)) << "\n";
159  }
160  oss << "\n";
161  edm::LogVerbatim(rcd->logName_) << oss.str();
162  }
163 }
std::vector< Record > collections_
std::atomic< size_t > totalEvents_
static std::unique_ptr<pathelpers::RecordCache> pat::CandidateSummaryTable::initializeGlobalCache ( edm::ParameterSet const &  conf)
inlinestatic

Definition at line 81 of file CandidateSummaryTable.cc.

References analyze(), and iEvent.

81  {
82  return std::make_unique<pathelpers::RecordCache>(conf);
83  }

Member Data Documentation

std::vector<std::pair<edm::InputTag,edm::EDGetTokenT<edm::View<reco::Candidate> > > > pat::CandidateSummaryTable::srcTokens
private

Definition at line 90 of file CandidateSummaryTable.cc.