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 
18  public:
20 
22  isolationValueMapChargedTokens_(edm::vector_transform(cfg.getParameter< std::vector<edm::InputTag> >("isolationValueMapsCharged"), [&](edm::InputTag const & tag){return iC.consumes<IsoMap>(tag);}) ),
23  isolationValueMapNeutralTokens_(edm::vector_transform(cfg.getParameter< std::vector<edm::InputTag> >("isolationValueMapsNeutral"), [&](edm::InputTag const & tag){return iC.consumes<IsoMap>(tag);}) ),
24  doDeltaBetaCorrection_(cfg.getParameter<bool>("doDeltaBetaCorrection")),
25  deltaBetaIsolationValueMapToken_(iC.mayConsume<IsoMap>(cfg.getParameter< edm::InputTag >("deltaBetaIsolationValueMap") ) ),
26  deltaBetaFactor_(cfg.getParameter<double>("deltaBetaFactor")),
27  isRelative_(cfg.getParameter<bool>("isRelative")),
28  isolationCut_(cfg.getParameter<double>("isolationCut")) {}
29 
30 
31 
32  void select( const HandleToCollection & hc,
33  const edm::Event & e,
34  const edm::EventSetup& s) {
35  selected_.clear();
36 
37 
38  // read all charged isolation value maps
39  std::vector< edm::Handle<IsoMap> >
40  isoMapsCharged(isolationValueMapChargedTokens_.size());
41  for(unsigned iMap = 0; iMap<isolationValueMapChargedTokens_.size(); ++iMap) {
42  e.getByToken(isolationValueMapChargedTokens_[iMap], isoMapsCharged[iMap]);
43  }
44 
45 
46  // read all neutral isolation value maps
47  std::vector< edm::Handle<IsoMap> >
48  isoMapsNeutral(isolationValueMapNeutralTokens_.size());
49  for(unsigned iMap = 0; iMap<isolationValueMapNeutralTokens_.size(); ++iMap) {
50  e.getByToken(isolationValueMapNeutralTokens_[iMap], isoMapsNeutral[iMap]);
51  }
52 
53  edm::Handle<IsoMap> dBetaH;
56  }
57 
58  unsigned key=0;
59  for( collection::const_iterator pfc = hc->begin();
60  pfc != hc->end(); ++pfc, ++key) {
61  reco::PFCandidateRef candidate(hc,key);
62 
63  bool passed = true;
64  double isoSumCharged=0.0;
65  double isoSumNeutral=0.0;
66 
67  for(unsigned iMap = 0; iMap<isoMapsCharged.size(); ++iMap) {
68  const IsoMap & isoMap = *(isoMapsCharged[iMap]);
69  double val = isoMap[candidate];
70  isoSumCharged+=val;
71  }
72 
73  for(unsigned iMap = 0; iMap<isoMapsNeutral.size(); ++iMap) {
74  const IsoMap & isoMap = *(isoMapsNeutral[iMap]);
75  double val = isoMap[candidate];
76  isoSumNeutral+=val;
77  }
78 
79 
80  if ( doDeltaBetaCorrection_ ) {
81  const IsoMap& isoMap = *dBetaH;
82  double dBetaVal = isoMap[candidate];
83  double dBetaCorIsoSumNeutral = isoSumNeutral + deltaBetaFactor_*dBetaVal;
84  isoSumNeutral = dBetaCorIsoSumNeutral>0 ? dBetaCorIsoSumNeutral : 0; //follow muon POG definition in 2012
85  }
86 
87  double isoSum=isoSumCharged+isoSumNeutral;
88 
89  if( isRelative_ ) {
90  isoSum /= candidate->pt();
91  }
92 
93  if ( isoSum>isolationCut_ ) {
94  passed = false;
95  }
96 
97  if(passed) {
98  // passed all cuts, selected
99  selected_.push_back( reco::PFCandidate(*pfc) );
100  reco::PFCandidatePtr ptrToMother( hc, key );
101  selected_.back().setSourceCandidatePtr( ptrToMother );
102  }
103  }
104  }
105 
106 
107  private:
108  std::vector<edm::EDGetTokenT<IsoMap> > isolationValueMapChargedTokens_;
109  std::vector<edm::EDGetTokenT<IsoMap> > isolationValueMapNeutralTokens_;
115  };
116 
117 }
118 
119 #endif
IsolatedPFCandidateSelectorDefinition(const edm::ParameterSet &cfg, edm::ConsumesCollector &&iC)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
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
std::vector< edm::EDGetTokenT< IsoMap > > isolationValueMapChargedTokens_
void select(const HandleToCollection &hc, const edm::Event &e, const edm::EventSetup &s)
std::vector< edm::EDGetTokenT< IsoMap > > isolationValueMapNeutralTokens_
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
HLT enums.
susybsm::HSCParticleCollection hc
Definition: classes.h:25
isoSum
===> compute the isolation and find the most isolated track