CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
- Public Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
 EDAnalyzerBase (const EDAnalyzerBase &)=delete
 
ModuleDescription const & moduleDescription () const
 
const EDAnalyzerBaseoperator= (const EDAnalyzerBase &)=delete
 
 ~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
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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::RecordCache
initializeGlobalCache (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 > >
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::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)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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::EDConsumerBase::consumes(), edm::ParameterSet::getParameter(), PixelMapPlotter::inputs, and srcTokens.

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 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::vector< std::pair< edm::InputTag, edm::EDGetTokenT< edm::View< reco::Candidate > > > > srcTokens
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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 
)
overridevirtual

Implements edm::stream::EDAnalyzerBase.

Definition at line 105 of file CandidateSummaryTable.cc.

References HLT_FULL_cff::candidates, edm::EventID::event(), edm::Event::getByToken(), mps_fire::i, edm::EventBase::id(), edm::EventID::run(), and getPayloadData::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
Log< level::Info, true > LogVerbatim
EventNumber_t event() const
Definition: EventID.h:40
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::vector< std::pair< edm::InputTag, edm::EDGetTokenT< edm::View< reco::Candidate > > > > srcTokens
Log< level::Info, false > LogInfo
edm::EventID id() const
Definition: EventBase.h:59
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_, 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_
Log< level::Info, true > LogVerbatim
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.

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.

Referenced by CandidateSummaryTable().