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)
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
virtual ~NearbyCandCountComputer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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 ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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
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)
 
- 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 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

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 30 of file NearbyCandCountComputer.cc.

Constructor & Destructor Documentation

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

Definition at line 45 of file NearbyCandCountComputer.cc.

45  :
48  deltaR2_(std::pow(iConfig.getParameter<double>("deltaR"), 2)),
49  objCut_(iConfig.existsAs<std::string>("objectSelection") ? iConfig.getParameter<std::string>("objectSelection") : "", true),
50  pairCut_(iConfig.existsAs<std::string>("pairSelection") ? iConfig.getParameter<std::string>("pairSelection") : "", true)
51 {
52  produces<edm::ValueMap<float> >();
53 }
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
StringCutObjectSelector< pat::DiObjectProxy, true > pairCut_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::View< reco::Candidate > > objectsToken_
StringCutObjectSelector< reco::Candidate, true > objCut_
edm::EDGetTokenT< edm::View< reco::Candidate > > probesToken_
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
NearbyCandCountComputer::~NearbyCandCountComputer ( )
virtual

Definition at line 56 of file NearbyCandCountComputer.cc.

57 {
58 }

Member Function Documentation

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

Definition at line 61 of file NearbyCandCountComputer.cc.

References KineDebug3::count(), DEFINE_FWK_MODULE, reco::deltaR2(), deltaR2_, objects.autophobj::filler, edm::Event::getByToken(), eostools::move(), objCut_, resolutioncreator_cfi::object, objectsToken_, pairCut_, probesToken_, edm::Event::put(), and MuonErrorMatrixValues_cff::values.

61  {
62  using namespace edm;
63 
64  // read input
66  iEvent.getByToken(probesToken_, probes);
67  iEvent.getByToken(objectsToken_, objects);
68 
69  // prepare vector for output
70  std::vector<float> values;
71 
72  // fill
73  View<reco::Candidate>::const_iterator probe, endprobes = probes->end();
74  View<reco::Candidate>::const_iterator object, beginobjects = objects->begin(), endobjects = objects->end();
75  for (probe = probes->begin(); probe != endprobes; ++probe) {
76  float count = 0;
77  for (object = beginobjects; object != endobjects; ++object) {
78  if ((deltaR2(*probe, *object) < deltaR2_) &&
79  objCut_(*object) &&
80  pairCut_(pat::DiObjectProxy(*probe, *object))) {
81  count++;
82  }
83  }
84  values.push_back(count);
85  }
86 
87  // convert into ValueMap and store
88  auto valMap = std::make_unique<ValueMap<float>>();
90  filler.insert(probes, values.begin(), values.end());
91  filler.fill();
92  iEvent.put(std::move(valMap));
93 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
StringCutObjectSelector< pat::DiObjectProxy, true > pairCut_
edm::EDGetTokenT< edm::View< reco::Candidate > > objectsToken_
StringCutObjectSelector< reco::Candidate, true > objCut_
edm::EDGetTokenT< edm::View< reco::Candidate > > probesToken_
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
Definition: deltaR.h:36
HLT enums.
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

double NearbyCandCountComputer::deltaR2_
private

Definition at line 40 of file NearbyCandCountComputer.cc.

Referenced by produce().

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

Definition at line 41 of file NearbyCandCountComputer.cc.

Referenced by produce().

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

Definition at line 39 of file NearbyCandCountComputer.cc.

Referenced by produce().

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

Definition at line 42 of file NearbyCandCountComputer.cc.

Referenced by produce().

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

Definition at line 38 of file NearbyCandCountComputer.cc.

Referenced by produce().