CMS 3D CMS Logo

NearbyCandCountComputer.cc
Go to the documentation of this file.
1 //
2 //
3 
18 
22 
26 
28 
30 public:
31  explicit NearbyCandCountComputer(const edm::ParameterSet& iConfig);
32  ~NearbyCandCountComputer() override;
33 
34  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
35 
36 private:
39  double deltaR2_;
41  objCut_; // lazy parsing, to allow cutting on variables not in reco::Candidate class
43 };
44 
46  : probesToken_(consumes<edm::View<reco::Candidate>>(iConfig.getParameter<edm::InputTag>("probes"))),
47  objectsToken_(consumes<edm::View<reco::Candidate>>(iConfig.getParameter<edm::InputTag>("objects"))),
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 }
56 
58 
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 }
90 
PATDiObjectProxy.h
resolutioncreator_cfi.object
object
Definition: resolutioncreator_cfi.py:4
configurableAnalysis::Candidate
char Candidate[]
Definition: modules.cc:20
EDProducer.h
sistrip::View
View
Definition: ConstantsForView.h:26
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
objects
Definition: __init__.py:1
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89281
NearbyCandCountComputer::pairCut_
StringCutObjectSelector< pat::DiObjectProxy, true > pairCut_
Definition: NearbyCandCountComputer.cc:42
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
CandidateFwd.h
MakerMacros.h
NearbyCandCountComputer
Count candidates near to another candidate, write result in ValueMap.
Definition: NearbyCandCountComputer.cc:29
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
NearbyCandCountComputer::~NearbyCandCountComputer
~NearbyCandCountComputer() override
Definition: NearbyCandCountComputer.cc:57
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
funct::true
true
Definition: Factorize.h:173
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
deltaR.h
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
edm::EventSetup
Definition: EventSetup.h:58
NearbyCandCountComputer::NearbyCandCountComputer
NearbyCandCountComputer(const edm::ParameterSet &iConfig)
Definition: NearbyCandCountComputer.cc:45
NearbyCandCountComputer::deltaR2_
double deltaR2_
Definition: NearbyCandCountComputer.cc:39
hgcalPerformanceValidation.objects
objects
Definition: hgcalPerformanceValidation.py:791
InputTag.h
ValueMap.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
StringCutObjectSelector.h
HLTMuonOfflineAnalyzer_cfi.deltaR2
deltaR2
Definition: HLTMuonOfflineAnalyzer_cfi.py:105
edm::ValueMap
Definition: ValueMap.h:107
StringCutObjectSelector< reco::Candidate, true >
NearbyCandCountComputer::objCut_
StringCutObjectSelector< reco::Candidate, true > objCut_
Definition: NearbyCandCountComputer.cc:41
edm::EDProducer
Definition: EDProducer.h:35
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
Candidate.h
NearbyCandCountComputer::probesToken_
edm::EDGetTokenT< edm::View< reco::Candidate > > probesToken_
Definition: NearbyCandCountComputer.cc:37
View.h
ParameterSet.h
pat::DiObjectProxy
Definition: PATDiObjectProxy.h:19
edm::Event
Definition: Event.h:73
NearbyCandCountComputer::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: NearbyCandCountComputer.cc:59