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 > >
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (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

◆ CandidateSummaryTable()

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

Definition at line 96 of file CandidateSummaryTable.cc.

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 }

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

◆ ~CandidateSummaryTable()

pat::CandidateSummaryTable::~CandidateSummaryTable ( )
override

Definition at line 103 of file CandidateSummaryTable.cc.

103 {}

Member Function Documentation

◆ analyze()

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

Implements edm::stream::EDAnalyzerBase.

Definition at line 105 of file CandidateSummaryTable.cc.

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 }

References HLT_2018_cff::candidates, oniaPATMuonsWithTrigger_cff::collections, mps_fire::i, iEvent, and triggerMatcherToHLTDebug_cfi::tags.

◆ globalEndJob()

void pat::CandidateSummaryTable::globalEndJob ( const pathelpers::RecordCache rcd)
static

Definition at line 146 of file CandidateSummaryTable.cc.

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 }

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

◆ initializeGlobalCache()

static std::unique_ptr<pathelpers::RecordCache> pat::CandidateSummaryTable::initializeGlobalCache ( edm::ParameterSet const &  conf)
inlinestatic

Definition at line 83 of file CandidateSummaryTable.cc.

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

Member Data Documentation

◆ srcTokens

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

Definition at line 92 of file CandidateSummaryTable.cc.

Referenced by CandidateSummaryTable().

mps_fire.i
i
Definition: mps_fire.py:355
edm
HLT enums.
Definition: AlignableModifier.h:19
pathelpers::RecordCache::totalEvents_
std::atomic< size_t > totalEvents_
Definition: CandidateSummaryTable.cc:71
edm::LogInfo
Definition: MessageLogger.h:254
pat::CandidateSummaryTable::srcTokens
std::vector< std::pair< edm::InputTag, edm::EDGetTokenT< edm::View< reco::Candidate > > > > srcTokens
Definition: CandidateSummaryTable.cc:92
edm::Handle
Definition: AssociativeIterator.h:50
pathelpers::RecordCache::perJob_
const bool perJob_
Definition: CandidateSummaryTable.cc:68
oniaPATMuonsWithTrigger_cff.collections
collections
Definition: oniaPATMuonsWithTrigger_cff.py:37
edm::View
Definition: CaloClusterFwd.h:14
cand
Definition: decayParser.h:34
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::LogVerbatim
Definition: MessageLogger.h:297
PixelMapPlotter.inputs
inputs
Definition: PixelMapPlotter.py:490
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
pathelpers::RecordCache::self_
const std::string self_
Definition: CandidateSummaryTable.cc:69
HLT_2018_cff.candidates
candidates
Definition: HLT_2018_cff.py:53513
pathelpers::RecordCache::logName_
const std::string logName_
Definition: CandidateSummaryTable.cc:69
triggerMatcherToHLTDebug_cfi.tags
tags
Definition: triggerMatcherToHLTDebug_cfi.py:9
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:126
pathelpers::RecordCache::collections_
std::vector< Record > collections_
Definition: CandidateSummaryTable.cc:72