CMS 3D CMS Logo

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

Count candidates near to another candidate, write result in ValueMap. More...

Inheritance diagram for NearbyCandCountComputer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 NearbyCandCountComputer (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~NearbyCandCountComputer () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () 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 Attributes

double deltaR2_
 
StringCutObjectSelector< reco::Candidate, true > objCut_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > objectsToken_
 
StringCutObjectSelector< pat::DiObjectProxy, true > pairCut_
 
edm::EDGetTokenT< edm::View< reco::Candidate > > probesToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer 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::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
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

Count candidates near to another candidate, write result in ValueMap.

      Implementation notice: not templated, because we want to allow cuts on the pair through PATDiObjectProxy
Author
Giovanni Petrucciani
Version
Id
NearbyCandCountComputer.cc,v 1.2 2010/07/09 14:03:51 gpetrucc Exp

Definition at line 29 of file NearbyCandCountComputer.cc.

Constructor & Destructor Documentation

◆ NearbyCandCountComputer()

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

Definition at line 45 of file NearbyCandCountComputer.cc.

48  deltaR2_(std::pow(iConfig.getParameter<double>("deltaR"), 2)),
49  objCut_(
50  iConfig.existsAs<std::string>("objectSelection") ? iConfig.getParameter<std::string>("objectSelection") : "",
51  true),
52  pairCut_(iConfig.existsAs<std::string>("pairSelection") ? iConfig.getParameter<std::string>("pairSelection") : "",
53  true) {
54  produces<edm::ValueMap<float>>();
55 }

◆ ~NearbyCandCountComputer()

NearbyCandCountComputer::~NearbyCandCountComputer ( )
override

Definition at line 57 of file NearbyCandCountComputer.cc.

57 {}

Member Function Documentation

◆ produce()

void NearbyCandCountComputer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 59 of file NearbyCandCountComputer.cc.

59  {
60  using namespace edm;
61 
62  // read input
64  iEvent.getByToken(probesToken_, probes);
65  iEvent.getByToken(objectsToken_, objects);
66 
67  // prepare vector for output
68  std::vector<float> values;
69 
70  // fill
71  View<reco::Candidate>::const_iterator probe, endprobes = probes->end();
72  View<reco::Candidate>::const_iterator object, beginobjects = objects->begin(), endobjects = objects->end();
73  for (probe = probes->begin(); probe != endprobes; ++probe) {
74  float count = 0;
75  for (object = beginobjects; object != endobjects; ++object) {
76  if ((deltaR2(*probe, *object) < deltaR2_) && objCut_(*object) && pairCut_(pat::DiObjectProxy(*probe, *object))) {
77  count++;
78  }
79  }
80  values.push_back(count);
81  }
82 
83  // convert into ValueMap and store
84  auto valMap = std::make_unique<ValueMap<float>>();
86  filler.insert(probes, values.begin(), values.end());
87  filler.fill();
88  iEvent.put(std::move(valMap));
89 }

References submitPVResolutionJobs::count, HLTMuonOfflineAnalyzer_cfi::deltaR2, deltaR2_, trigObjTnPSource_cfi::filler, iEvent, eostools::move(), objCut_, resolutioncreator_cfi::object, hgcalPerformanceValidation::objects, objectsToken_, pairCut_, probesToken_, and contentValuesCheck::values.

Member Data Documentation

◆ deltaR2_

double NearbyCandCountComputer::deltaR2_
private

Definition at line 39 of file NearbyCandCountComputer.cc.

Referenced by produce().

◆ objCut_

StringCutObjectSelector<reco::Candidate, true> NearbyCandCountComputer::objCut_
private

Definition at line 41 of file NearbyCandCountComputer.cc.

Referenced by produce().

◆ objectsToken_

edm::EDGetTokenT<edm::View<reco::Candidate> > NearbyCandCountComputer::objectsToken_
private

Definition at line 38 of file NearbyCandCountComputer.cc.

Referenced by produce().

◆ pairCut_

StringCutObjectSelector<pat::DiObjectProxy, true> NearbyCandCountComputer::pairCut_
private

Definition at line 42 of file NearbyCandCountComputer.cc.

Referenced by produce().

◆ probesToken_

edm::EDGetTokenT<edm::View<reco::Candidate> > NearbyCandCountComputer::probesToken_
private

Definition at line 37 of file NearbyCandCountComputer.cc.

Referenced by produce().

resolutioncreator_cfi.object
object
Definition: resolutioncreator_cfi.py:4
edm
HLT enums.
Definition: AlignableModifier.h:19
objects
Definition: __init__.py:1
NearbyCandCountComputer::pairCut_
StringCutObjectSelector< pat::DiObjectProxy, true > pairCut_
Definition: NearbyCandCountComputer.cc:42
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
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::View
Definition: CaloClusterFwd.h:14
NearbyCandCountComputer::objectsToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > objectsToken_
Definition: NearbyCandCountComputer.cc:38
trigObjTnPSource_cfi.filler
filler
Definition: trigObjTnPSource_cfi.py:21
iEvent
int iEvent
Definition: GenABIO.cc:224
NearbyCandCountComputer::deltaR2_
double deltaR2_
Definition: NearbyCandCountComputer.cc:39
hgcalPerformanceValidation.objects
objects
Definition: hgcalPerformanceValidation.py:791
eostools.move
def move(src, dest)
Definition: eostools.py:511
HLTMuonOfflineAnalyzer_cfi.deltaR2
deltaR2
Definition: HLTMuonOfflineAnalyzer_cfi.py:105
edm::ValueMap
Definition: ValueMap.h:107
NearbyCandCountComputer::objCut_
StringCutObjectSelector< reco::Candidate, true > objCut_
Definition: NearbyCandCountComputer.cc:41
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
NearbyCandCountComputer::probesToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > probesToken_
Definition: NearbyCandCountComputer.cc:37
edm::EDConsumerBase::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: EDConsumerBase.h:155
pat::DiObjectProxy
Definition: PATDiObjectProxy.h:19
edm::InputTag
Definition: InputTag.h:15