CMS 3D CMS Logo

IsolatedPFCandidateSelectorDefinition.h
Go to the documentation of this file.
1 #ifndef CommonTools_ParticleFlow_IsolatedPFCandidateSelectorDefinition
2 #define CommonTools_ParticleFlow_IsolatedPFCandidateSelectorDefinition
3 
13 
14 namespace pf2pat {
15 
17  public:
19 
22  edm::vector_transform(cfg.getParameter<std::vector<edm::InputTag> >("isolationValueMapsCharged"),
23  [&](edm::InputTag const& tag) { return iC.consumes<IsoMap>(tag); })),
25  edm::vector_transform(cfg.getParameter<std::vector<edm::InputTag> >("isolationValueMapsNeutral"),
26  [&](edm::InputTag const& tag) { return iC.consumes<IsoMap>(tag); })),
27  doDeltaBetaCorrection_(cfg.getParameter<bool>("doDeltaBetaCorrection")),
29  iC.mayConsume<IsoMap>(cfg.getParameter<edm::InputTag>("deltaBetaIsolationValueMap"))),
30  deltaBetaFactor_(cfg.getParameter<double>("deltaBetaFactor")),
31  isRelative_(cfg.getParameter<bool>("isRelative")),
32  isolationCut_(cfg.getParameter<double>("isolationCut")) {}
33 
34  void select(const HandleToCollection& hc, const edm::Event& e, const edm::EventSetup& s) {
35  selected_.clear();
36 
37  // read all charged isolation value maps
38  std::vector<edm::Handle<IsoMap> > isoMapsCharged(isolationValueMapChargedTokens_.size());
39  for (unsigned iMap = 0; iMap < isolationValueMapChargedTokens_.size(); ++iMap) {
40  e.getByToken(isolationValueMapChargedTokens_[iMap], isoMapsCharged[iMap]);
41  }
42 
43  // read all neutral isolation value maps
44  std::vector<edm::Handle<IsoMap> > isoMapsNeutral(isolationValueMapNeutralTokens_.size());
45  for (unsigned iMap = 0; iMap < isolationValueMapNeutralTokens_.size(); ++iMap) {
46  e.getByToken(isolationValueMapNeutralTokens_[iMap], isoMapsNeutral[iMap]);
47  }
48 
49  edm::Handle<IsoMap> dBetaH;
51  e.getByToken(deltaBetaIsolationValueMapToken_, dBetaH);
52  }
53 
54  unsigned key = 0;
55  for (collection::const_iterator pfc = hc->begin(); pfc != hc->end(); ++pfc, ++key) {
56  reco::PFCandidateRef candidate(hc, key);
57 
58  bool passed = true;
59  double isoSumCharged = 0.0;
60  double isoSumNeutral = 0.0;
61 
62  for (unsigned iMap = 0; iMap < isoMapsCharged.size(); ++iMap) {
63  const IsoMap& isoMap = *(isoMapsCharged[iMap]);
64  double val = isoMap[candidate];
65  isoSumCharged += val;
66  }
67 
68  for (unsigned iMap = 0; iMap < isoMapsNeutral.size(); ++iMap) {
69  const IsoMap& isoMap = *(isoMapsNeutral[iMap]);
70  double val = isoMap[candidate];
71  isoSumNeutral += val;
72  }
73 
75  const IsoMap& isoMap = *dBetaH;
76  double dBetaVal = isoMap[candidate];
77  double dBetaCorIsoSumNeutral = isoSumNeutral + deltaBetaFactor_ * dBetaVal;
78  isoSumNeutral = dBetaCorIsoSumNeutral > 0 ? dBetaCorIsoSumNeutral : 0; //follow muon POG definition in 2012
79  }
80 
81  double isoSum = isoSumCharged + isoSumNeutral;
82 
83  if (isRelative_) {
84  isoSum /= candidate->pt();
85  }
86 
87  if (isoSum > isolationCut_) {
88  passed = false;
89  }
90 
91  if (passed) {
92  // passed all cuts, selected
93  selected_.push_back(reco::PFCandidate(*pfc));
94  reco::PFCandidatePtr ptrToMother(hc, key);
95  selected_.back().setSourceCandidatePtr(ptrToMother);
96  }
97  }
98  }
99 
100  private:
101  std::vector<edm::EDGetTokenT<IsoMap> > isolationValueMapChargedTokens_;
102  std::vector<edm::EDGetTokenT<IsoMap> > isolationValueMapNeutralTokens_;
108  };
109 
110 } // namespace pf2pat
111 
112 #endif
PFCandidate.h
pf2pat
Definition: ElectronIDPFCandidateSelectorDefinition.h:22
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
pf2pat::IsolatedPFCandidateSelectorDefinition::IsolatedPFCandidateSelectorDefinition
IsolatedPFCandidateSelectorDefinition(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
Definition: IsolatedPFCandidateSelectorDefinition.h:20
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
pf2pat::IsolatedPFCandidateSelectorDefinition::isolationValueMapNeutralTokens_
std::vector< edm::EDGetTokenT< IsoMap > > isolationValueMapNeutralTokens_
Definition: IsolatedPFCandidateSelectorDefinition.h:102
pf2pat::IsolatedPFCandidateSelectorDefinition::isolationCut_
double isolationCut_
Definition: IsolatedPFCandidateSelectorDefinition.h:107
watchdog.const
const
Definition: watchdog.py:83
edm::Handle
Definition: AssociativeIterator.h:50
edm::Ref< PFCandidateCollection >
alignCSCRings.s
s
Definition: alignCSCRings.py:92
pf2pat::IsolatedPFCandidateSelectorDefinition::deltaBetaFactor_
double deltaBetaFactor_
Definition: IsolatedPFCandidateSelectorDefinition.h:105
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
pf2pat::PFCandidateSelectorDefinition::selected_
container selected_
Definition: PFCandidateSelectorDefinition.h:33
PFCandidateSelectorDefinition.h
pf2pat::IsolatedPFCandidateSelectorDefinition::deltaBetaIsolationValueMapToken_
edm::EDGetTokenT< IsoMap > deltaBetaIsolationValueMapToken_
Definition: IsolatedPFCandidateSelectorDefinition.h:104
edm::vector_transform
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
pf2pat::IsolatedPFCandidateSelectorDefinition::select
void select(const HandleToCollection &hc, const edm::Event &e, const edm::EventSetup &s)
Definition: IsolatedPFCandidateSelectorDefinition.h:34
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:58
pf2pat::IsolatedPFCandidateSelectorDefinition::doDeltaBetaCorrection_
bool doDeltaBetaCorrection_
Definition: IsolatedPFCandidateSelectorDefinition.h:103
edm::Ptr< PFCandidate >
looper.cfg
cfg
Definition: looper.py:297
ValueMap.h
pf2pat::IsolatedPFCandidateSelectorDefinition
Definition: IsolatedPFCandidateSelectorDefinition.h:16
pf2pat::IsolatedPFCandidateSelectorDefinition::isolationValueMapChargedTokens_
std::vector< edm::EDGetTokenT< IsoMap > > isolationValueMapChargedTokens_
Definition: IsolatedPFCandidateSelectorDefinition.h:101
heppy_batch.val
val
Definition: heppy_batch.py:351
std
Definition: JetResolutionObject.h:76
objects.IsoTrackAnalyzer.isoSum
isoSum
===> compute the isolation and find the most isolated track
Definition: IsoTrackAnalyzer.py:110
transform.h
edm::ValueMap
Definition: ValueMap.h:107
TriggerAnalyzer.passed
passed
Definition: TriggerAnalyzer.py:62
Exception.h
reco::PFCandidate
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
ConsumesCollector.h
pf2pat::PFCandidateSelectorDefinition
Definition: PFCandidateSelectorDefinition.h:10
pf2pat::IsolatedPFCandidateSelectorDefinition::IsoMap
edm::ValueMap< double > IsoMap
Definition: IsolatedPFCandidateSelectorDefinition.h:18
ParameterSet.h
pf2pat::IsolatedPFCandidateSelectorDefinition::isRelative_
bool isRelative_
Definition: IsolatedPFCandidateSelectorDefinition.h:106
edm::Event
Definition: Event.h:73
crabWrapper.key
key
Definition: crabWrapper.py:19
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
PFCandidateFwd.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37