CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IsolatedPFCandidateSelectorDefinition.h
Go to the documentation of this file.
1 #ifndef CommonTools_ParticleFlow_IsolatedPFCandidateSelectorDefinition
2 #define CommonTools_ParticleFlow_IsolatedPFCandidateSelectorDefinition
3 
9 
10 namespace pf2pat {
11 
13 
14  public:
16 
18  isolationValueMapChargedLabels_(cfg.getParameter< std::vector<edm::InputTag> >("isolationValueMapsCharged") ),
19  isolationValueMapNeutralLabels_(cfg.getParameter< std::vector<edm::InputTag> >("isolationValueMapsNeutral") ),
20  doDeltaBetaCorrection_(cfg.getParameter<bool>("doDeltaBetaCorrection")),
21  deltaBetaIsolationValueMap_(cfg.getParameter< edm::InputTag >("deltaBetaIsolationValueMap") ),
22  deltaBetaFactor_(cfg.getParameter<double>("deltaBetaFactor")),
23  isRelative_(cfg.getParameter<bool>("isRelative")),
24  isolationCut_(cfg.getParameter<double>("isolationCut")) {}
25 
26 
27 
28  void select( const HandleToCollection & hc,
29  const edm::EventBase & e,
30  const edm::EventSetup& s) {
31  selected_.clear();
32 
33 
34  // read all charged isolation value maps
35  std::vector< edm::Handle<IsoMap> >
36  isoMapsCharged(isolationValueMapChargedLabels_.size());
37  for(unsigned iMap = 0; iMap<isolationValueMapChargedLabels_.size(); ++iMap) {
38  e.getByLabel(isolationValueMapChargedLabels_[iMap], isoMapsCharged[iMap]);
39  }
40 
41 
42  // read all neutral isolation value maps
43  std::vector< edm::Handle<IsoMap> >
44  isoMapsNeutral(isolationValueMapNeutralLabels_.size());
45  for(unsigned iMap = 0; iMap<isolationValueMapNeutralLabels_.size(); ++iMap) {
46  e.getByLabel(isolationValueMapNeutralLabels_[iMap], isoMapsNeutral[iMap]);
47  }
48 
49  edm::Handle<IsoMap> dBetaH;
52  }
53 
54  unsigned key=0;
55  for( collection::const_iterator pfc = hc->begin();
56  pfc != hc->end(); ++pfc, ++key) {
57  reco::PFCandidateRef candidate(hc,key);
58 
59  bool passed = true;
60  double isoSumCharged=0.0;
61  double isoSumNeutral=0.0;
62 
63  for(unsigned iMap = 0; iMap<isoMapsCharged.size(); ++iMap) {
64  const IsoMap & isoMap = *(isoMapsCharged[iMap]);
65  double val = isoMap[candidate];
66  isoSumCharged+=val;
67  }
68 
69  for(unsigned iMap = 0; iMap<isoMapsNeutral.size(); ++iMap) {
70  const IsoMap & isoMap = *(isoMapsNeutral[iMap]);
71  double val = isoMap[candidate];
72  isoSumNeutral+=val;
73  }
74 
75 
76  if ( doDeltaBetaCorrection_ ) {
77  const IsoMap& isoMap = *dBetaH;
78  double dBetaVal = isoMap[candidate];
79  double dBetaCorIsoSumNeutral = isoSumNeutral + deltaBetaFactor_*dBetaVal;
80  isoSumNeutral = dBetaCorIsoSumNeutral>0 ? dBetaCorIsoSumNeutral : 0; //follow muon POG definition in 2012
81  }
82 
83  double isoSum=isoSumCharged+isoSumNeutral;
84 
85  if( isRelative_ ) {
86  isoSum /= candidate->pt();
87  }
88 
89  if ( isoSum>isolationCut_ ) {
90  passed = false;
91  }
92 
93  if(passed) {
94  // passed all cuts, selected
95  selected_.push_back( reco::PFCandidate(*pfc) );
96  reco::PFCandidatePtr ptrToMother( hc, key );
97  selected_.back().setSourceCandidatePtr( ptrToMother );
98  }
99  }
100  }
101 
102 
103  private:
104  std::vector<edm::InputTag> isolationValueMapChargedLabels_;
105  std::vector<edm::InputTag> isolationValueMapNeutralLabels_;
109  bool isRelative_;
111  };
112 
113 }
114 
115 #endif
void select(const HandleToCollection &hc, const edm::EventBase &e, const edm::EventSetup &s)
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:33
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:86
list key
Definition: combine.py:13