CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
ProbeTreeProducer Class Reference

#include <ProbeTreeProducer.cc>

Inheritance diagram for ProbeTreeProducer:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 ProbeTreeProducer (const edm::ParameterSet &)
 
 ~ProbeTreeProducer () override
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilter () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) 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
 
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
 
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)
 

Private Member Functions

void endJob () override
 
bool filter (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

StringCutObjectSelector< reco::Candidate, true > cut_
 The selector object. More...
 
bool filter_
 Specifies whether this module should filter. More...
 
int32_t maxProbes_
 The number of first probes used to fill the tree. More...
 
std::unique_ptr< tnp::BaseTreeFillerprobeFiller_
 The object that actually computes variables and fills the tree for the probe. More...
 
edm::EDGetTokenT< reco::CandidateViewprobesToken_
 InputTag to the collection of all probes. More...
 
std::string sortDescendingBy_
 Name of the reco::Candidate function used for sorting. More...
 
StringObjectFunction< reco::Candidate, true > sortFunction_
 The StringObjectFunction itself. More...
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- 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 = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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...
 
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

Description: TTree producer based on input probe parameters

Implementation: <Notes on="" implementation>="">

Definition at line 27 of file ProbeTreeProducer.cc.

Constructor & Destructor Documentation

◆ ProbeTreeProducer()

ProbeTreeProducer::ProbeTreeProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 58 of file ProbeTreeProducer.cc.

59  : probesToken_(consumes<reco::CandidateView>(iConfig.getParameter<edm::InputTag>("src"))),
60  cut_(iConfig.existsAs<std::string>("cut") ? iConfig.getParameter<std::string>("cut") : ""),
61  filter_(iConfig.existsAs<bool>("filter") ? iConfig.getParameter<bool>("filter") : false),
62  sortDescendingBy_(iConfig.existsAs<std::string>("sortDescendingBy")
63  ? iConfig.getParameter<std::string>("sortDescendingBy")
64  : ""),
65  sortFunction_(!sortDescendingBy_.empty() ? sortDescendingBy_ : "pt"), //need to pass a valid default
66  maxProbes_(iConfig.existsAs<int32_t>("maxProbes") ? iConfig.getParameter<int32_t>("maxProbes") : -1),
67  probeFiller_(new tnp::BaseTreeFiller("probe_tree", iConfig, consumesCollector())) {}

◆ ~ProbeTreeProducer()

ProbeTreeProducer::~ProbeTreeProducer ( )
override

Definition at line 69 of file ProbeTreeProducer.cc.

69 {}

Member Function Documentation

◆ endJob()

void ProbeTreeProducer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDFilter.

Definition at line 101 of file ProbeTreeProducer.cc.

101  {
102  // ask to write the current PSet info into the TTree header
104 }

References edm::getProcessParameterSetContainingModule(), edm::EDFilter::moduleDescription(), and probeFiller_.

◆ filter()

bool ProbeTreeProducer::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDFilter.

Definition at line 71 of file ProbeTreeProducer.cc.

71  {
72  bool result = !filter_;
74  iEvent.getByToken(probesToken_, probes);
75  if (!probes.isValid())
76  return result;
77  probeFiller_->init(iEvent);
78  // select probes and calculate the sorting value
79  typedef std::pair<reco::CandidateBaseRef, double> Pair;
80  std::vector<Pair> selectedProbes;
81  for (size_t i = 0; i < probes->size(); ++i) {
82  const reco::CandidateBaseRef& probe = probes->refAt(i);
83  if (cut_(*probe)) {
84  selectedProbes.push_back(Pair(probe, sortFunction_(*probe)));
85  }
86  }
87  // sort only if a function was provided
88  if (!sortDescendingBy_.empty())
89  sort(selectedProbes.begin(), selectedProbes.end(), [&](auto& arg1, auto& arg2) {
90  return arg1.second > arg2.second;
91  });
92  // fill the first maxProbes_ into the tree
93  for (size_t i = 0; i < (maxProbes_ < 0 ? selectedProbes.size() : std::min((size_t)maxProbes_, selectedProbes.size()));
94  ++i) {
95  probeFiller_->fill(selectedProbes[i].first);
96  result = true;
97  }
98  return result;
99 }

References cut_, filter_, first, mps_fire::i, iEvent, edm::HandleBase::isValid(), maxProbes_, min(), probeFiller_, probesToken_, edm::View< T >::refAt(), mps_fire::result, edm::View< T >::size(), jetUpdater_cfi::sort, sortDescendingBy_, and sortFunction_.

Member Data Documentation

◆ cut_

StringCutObjectSelector<reco::Candidate, true> ProbeTreeProducer::cut_
private

The selector object.

Definition at line 40 of file ProbeTreeProducer.cc.

Referenced by filter().

◆ filter_

bool ProbeTreeProducer::filter_
private

Specifies whether this module should filter.

Definition at line 43 of file ProbeTreeProducer.cc.

Referenced by filter().

◆ maxProbes_

int32_t ProbeTreeProducer::maxProbes_
private

The number of first probes used to fill the tree.

Definition at line 52 of file ProbeTreeProducer.cc.

Referenced by filter().

◆ probeFiller_

std::unique_ptr<tnp::BaseTreeFiller> ProbeTreeProducer::probeFiller_
private

The object that actually computes variables and fills the tree for the probe.

Definition at line 55 of file ProbeTreeProducer.cc.

Referenced by endJob(), and filter().

◆ probesToken_

edm::EDGetTokenT<reco::CandidateView> ProbeTreeProducer::probesToken_
private

InputTag to the collection of all probes.

Definition at line 37 of file ProbeTreeProducer.cc.

Referenced by filter().

◆ sortDescendingBy_

std::string ProbeTreeProducer::sortDescendingBy_
private

Name of the reco::Candidate function used for sorting.

Definition at line 46 of file ProbeTreeProducer.cc.

Referenced by filter().

◆ sortFunction_

StringObjectFunction<reco::Candidate, true> ProbeTreeProducer::sortFunction_
private

The StringObjectFunction itself.

Definition at line 49 of file ProbeTreeProducer.cc.

Referenced by filter().

ProbeTreeProducer::filter_
bool filter_
Specifies whether this module should filter.
Definition: ProbeTreeProducer.cc:43
mps_fire.i
i
Definition: mps_fire.py:428
edm::EDFilter::moduleDescription
ModuleDescription const & moduleDescription() const
Definition: EDFilter.h:55
min
T min(T a, T b)
Definition: MathUtil.h:58
edm::View::refAt
RefToBase< value_type > refAt(size_type i) const
ProbeTreeProducer::probesToken_
edm::EDGetTokenT< reco::CandidateView > probesToken_
InputTag to the collection of all probes.
Definition: ProbeTreeProducer.cc:37
ProbeTreeProducer::sortFunction_
StringObjectFunction< reco::Candidate, true > sortFunction_
The StringObjectFunction itself.
Definition: ProbeTreeProducer.cc:49
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:47
edm::getProcessParameterSetContainingModule
ParameterSet const & getProcessParameterSetContainingModule(ModuleDescription const &moduleDescription)
Definition: ParameterSet.cc:870
edm::ParameterSet::existsAs
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
edm::Handle
Definition: AssociativeIterator.h:50
ProbeTreeProducer::maxProbes_
int32_t maxProbes_
The number of first probes used to fill the tree.
Definition: ProbeTreeProducer.cc:52
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::View::size
size_type size() const
ProbeTreeProducer::cut_
StringCutObjectSelector< reco::Candidate, true > cut_
The selector object.
Definition: ProbeTreeProducer.cc:40
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
iEvent
int iEvent
Definition: GenABIO.cc:224
ProbeTreeProducer::probeFiller_
std::unique_ptr< tnp::BaseTreeFiller > probeFiller_
The object that actually computes variables and fills the tree for the probe.
Definition: ProbeTreeProducer.cc:55
ProbeTreeProducer::sortDescendingBy_
std::string sortDescendingBy_
Name of the reco::Candidate function used for sorting.
Definition: ProbeTreeProducer.cc:46
tnp::BaseTreeFiller
Definition: BaseTreeFiller.h:139
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::RefToBase< Candidate >
mps_fire.result
result
Definition: mps_fire.py:311
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::InputTag
Definition: InputTag.h:15