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)
 
virtual ~NearbyCandCountComputer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
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 ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

double deltaR2_
 
StringCutObjectSelector
< reco::Candidate, true > 
objCut_
 
edm::InputTag objects_
 
StringCutObjectSelector
< pat::DiObjectProxy, true > 
pairCut_
 
edm::InputTag probes_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- 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.3 2010/10/05 15:05:10 gpetrucc Exp

Definition at line 31 of file NearbyCandCountComputer.cc.

Constructor & Destructor Documentation

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

Definition at line 46 of file NearbyCandCountComputer.cc.

46  :
47  probes_(iConfig.getParameter<edm::InputTag>("probes")),
48  objects_(iConfig.getParameter<edm::InputTag>("objects")),
49  deltaR2_(std::pow(iConfig.getParameter<double>("deltaR"), 2)),
50  objCut_(iConfig.existsAs<std::string>("objectSelection") ? iConfig.getParameter<std::string>("objectSelection") : "", true),
51  pairCut_(iConfig.existsAs<std::string>("pairSelection") ? iConfig.getParameter<std::string>("pairSelection") : "", true)
52 {
53  produces<edm::ValueMap<float> >();
54 }
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:187
StringCutObjectSelector< pat::DiObjectProxy, true > pairCut_
StringCutObjectSelector< reco::Candidate, true > objCut_
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
NearbyCandCountComputer::~NearbyCandCountComputer ( )
virtual

Definition at line 57 of file NearbyCandCountComputer.cc.

58 {
59 }

Member Function Documentation

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

Implements edm::EDProducer.

Definition at line 62 of file NearbyCandCountComputer.cc.

References prof2calltree::count, Geom::deltaR2(), deltaR2_, edm::Event::getByLabel(), objCut_, dbtoconf::object, objects_, pairCut_, probes_, edm::Event::put(), and makeHLTPrescaleTable::values.

62  {
63  using namespace edm;
64 
65  // read input
66  Handle<View<reco::Candidate> > probes, objects;
67  iEvent.getByLabel(probes_, probes);
68  iEvent.getByLabel(objects_, objects);
69 
70  // prepare vector for output
71  std::vector<float> values;
72 
73  // fill
74  View<reco::Candidate>::const_iterator probe, endprobes = probes->end();
75  View<reco::Candidate>::const_iterator object, beginobjects = objects->begin(), endobjects = objects->end();
76  for (probe = probes->begin(); probe != endprobes; ++probe) {
77  float count = 0;
78  for (object = beginobjects; object != endobjects; ++object) {
79  if ((deltaR2(*probe, *object) >= deltaR2_) &&
80  objCut_(*object) &&
81  pairCut_(pat::DiObjectProxy(*probe, *object))) {
82  count++;
83  }
84  }
85  values.push_back(count);
86  }
87 
88  // convert into ValueMap and store
89  std::auto_ptr<ValueMap<float> > valMap(new ValueMap<float>());
90  ValueMap<float>::Filler filler(*valMap);
91  filler.insert(probes, values.begin(), values.end());
92  filler.fill();
93  iEvent.put(valMap);
94 }
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
StringCutObjectSelector< pat::DiObjectProxy, true > pairCut_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
StringCutObjectSelector< reco::Candidate, true > objCut_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
double deltaR2(const Vector1 &v1, const Vector2 &v2)
Definition: VectorUtil.h:78
list object
Definition: dbtoconf.py:77

Member Data Documentation

double NearbyCandCountComputer::deltaR2_
private

Definition at line 41 of file NearbyCandCountComputer.cc.

Referenced by produce().

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

Definition at line 42 of file NearbyCandCountComputer.cc.

Referenced by produce().

edm::InputTag NearbyCandCountComputer::objects_
private

Definition at line 40 of file NearbyCandCountComputer.cc.

Referenced by produce().

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

Definition at line 43 of file NearbyCandCountComputer.cc.

Referenced by produce().

edm::InputTag NearbyCandCountComputer::probes_
private

Definition at line 39 of file NearbyCandCountComputer.cc.

Referenced by produce().