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::stream::EDProducer<>

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::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

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.

46  : probesToken_(consumes<edm::View<reco::Candidate>>(iConfig.getParameter<edm::InputTag>("probes"))),
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 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:172
edm::EDGetTokenT< edm::View< reco::Candidate > > objectsToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > probesToken_
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
StringCutObjectSelector< pat::DiObjectProxy, true > pairCut_
StringCutObjectSelector< reco::Candidate, true > objCut_

◆ ~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 
)
override

Definition at line 59 of file NearbyCandCountComputer.cc.

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

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 }
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< edm::View< reco::Candidate > > objectsToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > probesToken_
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
def move(src, dest)
Definition: eostools.py:511
StringCutObjectSelector< pat::DiObjectProxy, true > pairCut_
StringCutObjectSelector< reco::Candidate, true > objCut_

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