CMS 3D CMS Logo

PFRecoTauDiscriminationAgainstElectron.cc
Go to the documentation of this file.
1 /* class PFRecoTauDiscriminationAgainstElectron
2  * created : May 02 2008,
3  * revised : ,
4  * Authorss : Chi Nhan Nguyen (Texas A&M)
5  */
6 
9 
10 namespace {
11 
12 using namespace reco;
13 
14 class PFRecoTauDiscriminationAgainstElectron final : public PFTauDiscriminationProducerBase {
15  public:
16  explicit PFRecoTauDiscriminationAgainstElectron(const edm::ParameterSet& iConfig):PFTauDiscriminationProducerBase(iConfig) {
17 
18  emFraction_maxValue_ = iConfig.getParameter<double>("EmFraction_maxValue");
19  applyCut_emFraction_ = iConfig.getParameter<bool>("ApplyCut_EmFraction");
20  hcalTotOverPLead_minValue_ = iConfig.getParameter<double>("HcalTotOverPLead_minValue");
21  applyCut_hcalTotOverPLead_ = iConfig.getParameter<bool>("ApplyCut_HcalTotOverPLead");
22  hcalMaxOverPLead_minValue_ = iConfig.getParameter<double>("HcalMaxOverPLead_minValue");
23  applyCut_hcalMaxOverPLead_ = iConfig.getParameter<bool>("ApplyCut_HcalMaxOverPLead");
24  hcal3x3OverPLead_minValue_ = iConfig.getParameter<double>("Hcal3x3OverPLead_minValue");
25 
26  applyCut_hcal3x3OverPLead_ = iConfig.getParameter<bool>("ApplyCut_Hcal3x3OverPLead");
27  EOverPLead_minValue_ = iConfig.getParameter<double>("EOverPLead_minValue");
28  EOverPLead_maxValue_ = iConfig.getParameter<double>("EOverPLead_maxValue");
29  applyCut_EOverPLead_ = iConfig.getParameter<bool>("ApplyCut_EOverPLead");
30  bremsRecoveryEOverPLead_minValue_ = iConfig.getParameter<double>("BremsRecoveryEOverPLead_minValue");
31  bremsRecoveryEOverPLead_maxValue_ = iConfig.getParameter<double>("BremsRecoveryEOverPLead_maxValue");
32 
33  applyCut_bremsRecoveryEOverPLead_ = iConfig.getParameter<bool>("ApplyCut_BremsRecoveryEOverPLead");
34 
35  applyCut_electronPreID_ = iConfig.getParameter<bool>("ApplyCut_ElectronPreID");
36 
37  applyCut_electronPreID_2D_ = iConfig.getParameter<bool>("ApplyCut_ElectronPreID_2D");
38 
39  elecPreID0_EOverPLead_maxValue_ = iConfig.getParameter<double>("ElecPreID0_EOverPLead_maxValue");
40  elecPreID0_HOverPLead_minValue_ = iConfig.getParameter<double>("ElecPreID0_HOverPLead_minValue");
41  elecPreID1_EOverPLead_maxValue_ = iConfig.getParameter<double>("ElecPreID1_EOverPLead_maxValue");
42  elecPreID1_HOverPLead_minValue_ = iConfig.getParameter<double>("ElecPreID1_HOverPLead_minValue");
43 
44 
45  applyCut_PFElectronMVA_ = iConfig.getParameter<bool>("ApplyCut_PFElectronMVA");
46  pfelectronMVA_maxValue_ = iConfig.getParameter<double>("PFElectronMVA_maxValue");
47 
48 
49 
50  applyCut_ecalCrack_ = iConfig.getParameter<bool>("ApplyCut_EcalCrackCut");
51 
52  applyCut_bremCombined_ = iConfig.getParameter<bool>("ApplyCut_BremCombined");
53  bremCombined_fraction_ = iConfig.getParameter<double>("BremCombined_Fraction");
54  bremCombined_maxHOP_ = iConfig.getParameter<double>("BremCombined_HOP");
55  bremCombined_minMass_ = iConfig.getParameter<double>("BremCombined_Mass");
56  bremCombined_stripSize_ = iConfig.getParameter<double>("BremCombined_StripSize");
57 
58  }
59 
60  double discriminate(const PFTauRef& pfTau) const override;
61 
62  ~PFRecoTauDiscriminationAgainstElectron(){}
63 
64  private:
65  bool isInEcalCrack(double) const;
66  edm::InputTag PFTauProducer_;
67  bool applyCut_emFraction_;
68  double emFraction_maxValue_;
69  bool applyCut_hcalTotOverPLead_;
70  double hcalTotOverPLead_minValue_;
71  bool applyCut_hcalMaxOverPLead_;
72  double hcalMaxOverPLead_minValue_;
73  bool applyCut_hcal3x3OverPLead_;
74  double hcal3x3OverPLead_minValue_;
75 
76  bool applyCut_EOverPLead_;
77  double EOverPLead_minValue_;
78  double EOverPLead_maxValue_;
79  bool applyCut_bremsRecoveryEOverPLead_;
80  double bremsRecoveryEOverPLead_minValue_;
81  double bremsRecoveryEOverPLead_maxValue_;
82 
83  bool applyCut_electronPreID_;
84 
85  bool applyCut_electronPreID_2D_;
86  double elecPreID0_EOverPLead_maxValue_;
87  double elecPreID0_HOverPLead_minValue_;
88  double elecPreID1_EOverPLead_maxValue_;
89  double elecPreID1_HOverPLead_minValue_;
90 
91  bool applyCut_PFElectronMVA_;
92  double pfelectronMVA_maxValue_;
93  bool applyCut_ecalCrack_;
94 
95  bool applyCut_bremCombined_;
96  double bremCombined_fraction_;
97  double bremCombined_maxHOP_;
98  double bremCombined_minMass_;
99  double bremCombined_stripSize_;
100 
101 
102 
103 };
104 
105 double PFRecoTauDiscriminationAgainstElectron::discriminate(const PFTauRef& thePFTauRef) const
106 {
107 
108 
109 
110  // ensure tau has at least one charged object
111 
112  if( (*thePFTauRef).leadPFChargedHadrCand().isNull() )
113  {
114  return 0.;
115  } else
116  {
117  // Check if track goes to Ecal crack
118  TrackRef myleadTk;
119  myleadTk=(*thePFTauRef).leadPFChargedHadrCand()->trackRef();
120  math::XYZPointF myleadTkEcalPos = (*thePFTauRef).leadPFChargedHadrCand()->positionAtECALEntrance();
121  if(myleadTk.isNonnull())
122  {
123  if (applyCut_ecalCrack_ && isInEcalCrack(myleadTkEcalPos.eta()))
124  {
125  return 0.;
126  }
127  }
128  }
129 
130  bool decision = false;
131  bool emfPass = true, htotPass = true, hmaxPass = true;
132  bool h3x3Pass = true, estripPass = true, erecovPass = true;
133  bool epreidPass = true, epreid2DPass = true;
134  bool mvaPass = true, bremCombinedPass = true;
135 
136  if (applyCut_emFraction_) {
137  if ((*thePFTauRef).emFraction() > emFraction_maxValue_) {
138  emfPass = false;
139  }
140  }
141  if (applyCut_hcalTotOverPLead_) {
142  if ((*thePFTauRef).hcalTotOverPLead() < hcalTotOverPLead_minValue_) {
143  htotPass = false;
144  }
145  }
146  if (applyCut_hcalMaxOverPLead_) {
147  if ((*thePFTauRef).hcalMaxOverPLead() < hcalMaxOverPLead_minValue_) {
148  hmaxPass = false;
149  }
150  }
151  if (applyCut_hcal3x3OverPLead_) {
152  if ((*thePFTauRef).hcal3x3OverPLead() < hcal3x3OverPLead_minValue_) {
153  h3x3Pass = false;
154  }
155  }
156  if (applyCut_EOverPLead_) {
157  if ((*thePFTauRef).ecalStripSumEOverPLead() > EOverPLead_minValue_ &&
158  (*thePFTauRef).ecalStripSumEOverPLead() < EOverPLead_maxValue_) {
159  estripPass = false;
160  } else {
161  estripPass = true;
162  }
163  }
164  if (applyCut_bremsRecoveryEOverPLead_) {
165  if ((*thePFTauRef).bremsRecoveryEOverPLead() > bremsRecoveryEOverPLead_minValue_ &&
166  (*thePFTauRef).bremsRecoveryEOverPLead() < bremsRecoveryEOverPLead_maxValue_) {
167  erecovPass = false;
168  } else {
169  erecovPass = true;
170  }
171  }
172  if (applyCut_electronPreID_) {
173  if ((*thePFTauRef).electronPreIDDecision()) {
174  epreidPass = false;
175  } else {
176  epreidPass = true;
177  }
178  }
179 
180  if (applyCut_electronPreID_2D_) {
181  if (
182  ((*thePFTauRef).electronPreIDDecision() &&
183  ((*thePFTauRef).ecalStripSumEOverPLead() < elecPreID1_EOverPLead_maxValue_ ||
184  (*thePFTauRef).hcal3x3OverPLead() > elecPreID1_HOverPLead_minValue_))
185  ||
186  (!(*thePFTauRef).electronPreIDDecision() &&
187  ((*thePFTauRef).ecalStripSumEOverPLead() < elecPreID0_EOverPLead_maxValue_ ||
188  (*thePFTauRef).hcal3x3OverPLead() > elecPreID0_HOverPLead_minValue_))
189  ){
190  epreid2DPass = true;
191  } else {
192  epreid2DPass = false;
193  }
194  }
195 
196  if (applyCut_PFElectronMVA_) {
197  if ((*thePFTauRef).electronPreIDOutput()>pfelectronMVA_maxValue_) {
198  mvaPass = false;
199  }
200  }
201  if (applyCut_bremCombined_) {
202  if (thePFTauRef->leadPFChargedHadrCand()->trackRef().isNull()) {
203  // No KF track found
204  return 0;
205  }
206  if(thePFTauRef->signalPFChargedHadrCands().size()==1 && thePFTauRef->signalPFGammaCands().size()==0) {
207  if(thePFTauRef->leadPFChargedHadrCand()->hcalEnergy()/thePFTauRef->leadPFChargedHadrCand()->trackRef()->p()<bremCombined_maxHOP_)
208  bremCombinedPass = false;
209  }
210  else if(thePFTauRef->signalPFChargedHadrCands().size()==1 && thePFTauRef->signalPFGammaCands().size()>0) {
211  //calculate the brem ratio energy
212  float bremEnergy=0.;
213  float emEnergy=0.;
214  for(unsigned int Nc = 0 ;Nc < thePFTauRef->signalPFGammaCands().size();++Nc)
215  {
216  PFCandidatePtr cand = thePFTauRef->signalPFGammaCands().at(Nc);
217  if(fabs(thePFTauRef->leadPFChargedHadrCand()->trackRef()->eta()-cand->eta())<bremCombined_stripSize_)
218  bremEnergy+=cand->energy();
219  emEnergy+=cand->energy();
220  }
221  if(bremEnergy/emEnergy>bremCombined_fraction_&&thePFTauRef->mass()<bremCombined_minMass_)
222  bremCombinedPass = false;
223 
224  }
225  }
226 
227  decision = emfPass && htotPass && hmaxPass &&
228  h3x3Pass && estripPass && erecovPass && epreidPass && epreid2DPass && mvaPass &&bremCombinedPass;
229 
230  return (decision ? 1. : 0.);
231 }
232 
233 bool
234 PFRecoTauDiscriminationAgainstElectron::isInEcalCrack(double eta) const
235 {
236  eta = fabs(eta);
237  return (eta < 0.018 ||
238  (eta>0.423 && eta<0.461) ||
239  (eta>0.770 && eta<0.806) ||
240  (eta>1.127 && eta<1.163) ||
241  (eta>1.460 && eta<1.558));
242 }
243 }
244 
245 DEFINE_FWK_MODULE(PFRecoTauDiscriminationAgainstElectron);
T getParameter(std::string const &) const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:252
virtual double eta() const final
momentum pseudorapidity
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:10
virtual double energy() const final
energy
bool isNull() const
Checks for null.
Definition: Ref.h:249
fixed size matrix