CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 using namespace reco;
11 
13  public:
15 
16  emFraction_maxValue_ = iConfig.getParameter<double>("EmFraction_maxValue");
17  applyCut_emFraction_ = iConfig.getParameter<bool>("ApplyCut_EmFraction");
18  hcalTotOverPLead_minValue_ = iConfig.getParameter<double>("HcalTotOverPLead_minValue");
19  applyCut_hcalTotOverPLead_ = iConfig.getParameter<bool>("ApplyCut_HcalTotOverPLead");
20  hcalMaxOverPLead_minValue_ = iConfig.getParameter<double>("HcalMaxOverPLead_minValue");
21  applyCut_hcalMaxOverPLead_ = iConfig.getParameter<bool>("ApplyCut_HcalMaxOverPLead");
22  hcal3x3OverPLead_minValue_ = iConfig.getParameter<double>("Hcal3x3OverPLead_minValue");
23 
24  applyCut_hcal3x3OverPLead_ = iConfig.getParameter<bool>("ApplyCut_Hcal3x3OverPLead");
25  EOverPLead_minValue_ = iConfig.getParameter<double>("EOverPLead_minValue");
26  EOverPLead_maxValue_ = iConfig.getParameter<double>("EOverPLead_maxValue");
27  applyCut_EOverPLead_ = iConfig.getParameter<bool>("ApplyCut_EOverPLead");
28  bremsRecoveryEOverPLead_minValue_ = iConfig.getParameter<double>("BremsRecoveryEOverPLead_minValue");
29  bremsRecoveryEOverPLead_maxValue_ = iConfig.getParameter<double>("BremsRecoveryEOverPLead_maxValue");
30 
31  applyCut_bremsRecoveryEOverPLead_ = iConfig.getParameter<bool>("ApplyCut_BremsRecoveryEOverPLead");
32 
33  applyCut_electronPreID_ = iConfig.getParameter<bool>("ApplyCut_ElectronPreID");
34 
35  applyCut_electronPreID_2D_ = iConfig.getParameter<bool>("ApplyCut_ElectronPreID_2D");
36 
37  elecPreID0_EOverPLead_maxValue_ = iConfig.getParameter<double>("ElecPreID0_EOverPLead_maxValue");
38  elecPreID0_HOverPLead_minValue_ = iConfig.getParameter<double>("ElecPreID0_HOverPLead_minValue");
39  elecPreID1_EOverPLead_maxValue_ = iConfig.getParameter<double>("ElecPreID1_EOverPLead_maxValue");
40  elecPreID1_HOverPLead_minValue_ = iConfig.getParameter<double>("ElecPreID1_HOverPLead_minValue");
41 
42 
43  applyCut_PFElectronMVA_ = iConfig.getParameter<bool>("ApplyCut_PFElectronMVA");
44  pfelectronMVA_maxValue_ = iConfig.getParameter<double>("PFElectronMVA_maxValue");
45 
46 
47 
48  applyCut_ecalCrack_ = iConfig.getParameter<bool>("ApplyCut_EcalCrackCut");
49 
50  applyCut_bremCombined_ = iConfig.getParameter<bool>("ApplyCut_BremCombined");
51  bremCombined_fraction_ = iConfig.getParameter<double>("BremCombined_Fraction");
52  bremCombined_maxHOP_ = iConfig.getParameter<double>("BremCombined_HOP");
53  bremCombined_minMass_ = iConfig.getParameter<double>("BremCombined_Mass");
54  bremCombined_stripSize_ = iConfig.getParameter<double>("BremCombined_StripSize");
55 
56  }
57 
58  double discriminate(const PFTauRef& pfTau) override;
59 
61 
62  private:
63  bool isInEcalCrack(double) const;
73 
80 
82 
88 
92 
98 
99 
100 
101 };
102 
104 {
105 
106 
107 
108  // ensure tau has at least one charged object
109 
110  if( (*thePFTauRef).leadPFChargedHadrCand().isNull() )
111  {
112  return 0.;
113  } else
114  {
115  // Check if track goes to Ecal crack
116  TrackRef myleadTk;
117  myleadTk=(*thePFTauRef).leadPFChargedHadrCand()->trackRef();
118  math::XYZPointF myleadTkEcalPos = (*thePFTauRef).leadPFChargedHadrCand()->positionAtECALEntrance();
119  if(myleadTk.isNonnull())
120  {
121  if (applyCut_ecalCrack_ && isInEcalCrack(myleadTkEcalPos.eta()))
122  {
123  return 0.;
124  }
125  }
126  }
127 
128  bool decision = false;
129  bool emfPass = true, htotPass = true, hmaxPass = true;
130  bool h3x3Pass = true, estripPass = true, erecovPass = true;
131  bool epreidPass = true, epreid2DPass = true;
132  bool mvaPass = true, bremCombinedPass = true;
133 
134  if (applyCut_emFraction_) {
135  if ((*thePFTauRef).emFraction() > emFraction_maxValue_) {
136  emfPass = false;
137  }
138  }
139  if (applyCut_hcalTotOverPLead_) {
140  if ((*thePFTauRef).hcalTotOverPLead() < hcalTotOverPLead_minValue_) {
141  htotPass = false;
142  }
143  }
144  if (applyCut_hcalMaxOverPLead_) {
145  if ((*thePFTauRef).hcalMaxOverPLead() < hcalMaxOverPLead_minValue_) {
146  hmaxPass = false;
147  }
148  }
149  if (applyCut_hcal3x3OverPLead_) {
150  if ((*thePFTauRef).hcal3x3OverPLead() < hcal3x3OverPLead_minValue_) {
151  h3x3Pass = false;
152  }
153  }
154  if (applyCut_EOverPLead_) {
155  if ((*thePFTauRef).ecalStripSumEOverPLead() > EOverPLead_minValue_ &&
156  (*thePFTauRef).ecalStripSumEOverPLead() < EOverPLead_maxValue_) {
157  estripPass = false;
158  } else {
159  estripPass = true;
160  }
161  }
162  if (applyCut_bremsRecoveryEOverPLead_) {
163  if ((*thePFTauRef).bremsRecoveryEOverPLead() > bremsRecoveryEOverPLead_minValue_ &&
164  (*thePFTauRef).bremsRecoveryEOverPLead() < bremsRecoveryEOverPLead_maxValue_) {
165  erecovPass = false;
166  } else {
167  erecovPass = true;
168  }
169  }
170  if (applyCut_electronPreID_) {
171  if ((*thePFTauRef).electronPreIDDecision()) {
172  epreidPass = false;
173  } else {
174  epreidPass = true;
175  }
176  }
177 
178  if (applyCut_electronPreID_2D_) {
179  if (
180  ((*thePFTauRef).electronPreIDDecision() &&
181  ((*thePFTauRef).ecalStripSumEOverPLead() < elecPreID1_EOverPLead_maxValue_ ||
182  (*thePFTauRef).hcal3x3OverPLead() > elecPreID1_HOverPLead_minValue_))
183  ||
184  (!(*thePFTauRef).electronPreIDDecision() &&
185  ((*thePFTauRef).ecalStripSumEOverPLead() < elecPreID0_EOverPLead_maxValue_ ||
186  (*thePFTauRef).hcal3x3OverPLead() > elecPreID0_HOverPLead_minValue_))
187  ){
188  epreid2DPass = true;
189  } else {
190  epreid2DPass = false;
191  }
192  }
193 
194  if (applyCut_PFElectronMVA_) {
195  if ((*thePFTauRef).electronPreIDOutput()>pfelectronMVA_maxValue_) {
196  mvaPass = false;
197  }
198  }
199  if (applyCut_bremCombined_) {
200  if (thePFTauRef->leadPFChargedHadrCand()->trackRef().isNull()) {
201  // No KF track found
202  return 0;
203  }
204  if(thePFTauRef->signalPFChargedHadrCands().size()==1 && thePFTauRef->signalPFGammaCands().size()==0) {
205  if(thePFTauRef->leadPFChargedHadrCand()->hcalEnergy()/thePFTauRef->leadPFChargedHadrCand()->trackRef()->p()<bremCombined_maxHOP_)
206  bremCombinedPass = false;
207  }
208  else if(thePFTauRef->signalPFChargedHadrCands().size()==1 && thePFTauRef->signalPFGammaCands().size()>0) {
209  //calculate the brem ratio energy
210  float bremEnergy=0.;
211  float emEnergy=0.;
212  for(unsigned int Nc = 0 ;Nc < thePFTauRef->signalPFGammaCands().size();++Nc)
213  {
214  PFCandidatePtr cand = thePFTauRef->signalPFGammaCands().at(Nc);
215  if(fabs(thePFTauRef->leadPFChargedHadrCand()->trackRef()->eta()-cand->eta())<bremCombined_stripSize_)
216  bremEnergy+=cand->energy();
217  emEnergy+=cand->energy();
218  }
219  if(bremEnergy/emEnergy>bremCombined_fraction_&&thePFTauRef->mass()<bremCombined_minMass_)
220  bremCombinedPass = false;
221 
222  }
223  }
224 
225  decision = emfPass && htotPass && hmaxPass &&
226  h3x3Pass && estripPass && erecovPass && epreidPass && epreid2DPass && mvaPass &&bremCombinedPass;
227 
228  return (decision ? 1. : 0.);
229 }
230 
231 bool
233 {
234  eta = fabs(eta);
235  return (eta < 0.018 ||
236  (eta>0.423 && eta<0.461) ||
237  (eta>0.770 && eta<0.806) ||
238  (eta>1.127 && eta<1.163) ||
239  (eta>1.460 && eta<1.558));
240 }
241 
T getParameter(std::string const &) const
#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
T eta() const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
bool isNull() const
Checks for null.
Definition: Ref.h:247
PFRecoTauDiscriminationAgainstElectron(const edm::ParameterSet &iConfig)