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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 78 of file CandidateSummaryTable.cc.

Constructor & Destructor Documentation

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

Definition at line 96 of file CandidateSummaryTable.cc.

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

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

Definition at line 103 of file CandidateSummaryTable.cc.

103 {}

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 HLT_2018_cff::candidates, oniaPATMuonsWithTrigger_cff::collections, edm::EventID::event(), edm::HandleBase::failedToGet(), edm::Event::getByToken(), mps_fire::i, edm::EventBase::id(), edm::EventID::run(), and triggerMatcherToHLTDebug_cfi::tags.

105  {
106  using namespace edm;
107  using std::left;
108  using std::right;
109  using std::setprecision;
110  using std::setw;
111 
113  if (globalCache()->perEvent_) {
114  LogInfo(globalCache()->logName_) << "Per Event Table " << globalCache()->logName_ << " (" << globalCache()->self_
115  << ", run:event " << iEvent.id().run() << ":" << iEvent.id().event() << ")";
116  }
117  ++(globalCache()->totalEvents_);
118  auto& collections = globalCache()->collections_;
119  auto tags = srcTokens.cbegin();
120  for (auto it = collections.begin(), ed = collections.end(); it != ed; ++it, ++tags) {
121  iEvent.getByToken(tags->second, candidates);
122  if (!candidates.failedToGet())
123  it->update(*candidates);
124  if (globalCache()->perEvent_) {
125  LogVerbatim(globalCache()->logName_) << " " << setw(30) << left << it->src.encode() << right;
126  if (globalCache()->dumpItems_) {
127  size_t i = 0;
128  std::ostringstream oss;
129  for (View<reco::Candidate>::const_iterator cand = candidates->begin(), endc = candidates->end(); cand != endc;
130  ++cand, ++i) {
131  oss << " [" << setw(3) << i << "]"
132  << " pt " << setw(7) << setprecision(5) << cand->pt() << " eta " << setw(7) << setprecision(5)
133  << cand->eta() << " phi " << setw(7) << setprecision(5) << cand->phi() << " et " << setw(7)
134  << setprecision(5) << cand->et() << " phi " << setw(7) << setprecision(5) << cand->phi() << " charge "
135  << setw(2) << cand->charge() << " id " << setw(7) << cand->pdgId() << " st " << setw(7)
136  << cand->status() << "\n";
137  }
138  LogVerbatim(globalCache()->logName_) << oss.str();
139  }
140  }
141  }
142  if (globalCache()->perEvent_)
143  LogInfo(globalCache()->logName_) << ""; // add an empty line
144 }
RunNumber_t run() const
Definition: EventID.h:38
EventNumber_t event() const
Definition: EventID.h:40
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::vector< std::pair< edm::InputTag, edm::EDGetTokenT< edm::View< reco::Candidate > > > > srcTokens
bool failedToGet() const
Definition: HandleBase.h:72
edm::EventID id() const
Definition: EventBase.h:59
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
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::left;
148  using std::right;
149  using std::setprecision;
150  using std::setw;
151  if (rcd->perJob_) {
152  std::ostringstream oss;
153  oss << "Summary Table " << rcd->logName_ << " (" << rcd->self_ << ", events total " << rcd->totalEvents_ << ")\n";
154  for (auto it = rcd->collections_.cbegin(), ed = rcd->collections_.cend(); it != ed; ++it) {
155  oss << " " << setw(30) << left << it->src.encode() << right << " present " << setw(7) << it->present << " ("
156  << setw(4) << setprecision(3) << (it->present * 100.0 / rcd->totalEvents_) << "%)"
157  << " empty " << setw(7) << it->empty << " (" << setw(4) << setprecision(3)
158  << (it->empty * 100.0 / rcd->totalEvents_) << "%)"
159  << " min " << setw(7) << it->min << " max " << setw(7) << it->max << " total " << setw(7) << it->total
160  << " avg " << setw(5) << setprecision(3) << (it->total / double(rcd->totalEvents_)) << "\n";
161  }
162  oss << "\n";
163  edm::LogVerbatim(rcd->logName_) << oss.str();
164  }
165 }
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 83 of file CandidateSummaryTable.cc.

References analyze(), and iEvent.

83  {
84  return std::make_unique<pathelpers::RecordCache>(conf);
85  }

Member Data Documentation

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

Definition at line 92 of file CandidateSummaryTable.cc.