CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
- 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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:184
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

Implements edm::EDProducer.

Definition at line 61 of file NearbyCandCountComputer.cc.

References prof2calltree::count, Geom::deltaR2(), deltaR2_, edm::Event::getByToken(), objCut_, dbtoconf::object, objectsToken_, pairCut_, probesToken_, edm::Event::put(), and makeHLTPrescaleTable::values.

61  {
62  using namespace edm;
63 
64  // read input
65  Handle<View<reco::Candidate> > probes, objects;
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  std::auto_ptr<ValueMap<float> > valMap(new ValueMap<float>());
89  ValueMap<float>::Filler filler(*valMap);
90  filler.insert(probes, values.begin(), values.end());
91  filler.fill();
92  iEvent.put(valMap);
93 }
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
StringCutObjectSelector< pat::DiObjectProxy, true > pairCut_
edm::EDGetTokenT< edm::View< reco::Candidate > > objectsToken_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
StringCutObjectSelector< reco::Candidate, true > objCut_
double deltaR2(const Vector1 &v1, const Vector2 &v2)
Definition: VectorUtil.h:78
edm::EDGetTokenT< edm::View< reco::Candidate > > probesToken_
list object
Definition: dbtoconf.py:77
const_iterator end() const

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().