CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
electronSelections.cc
Go to the documentation of this file.
1 #include "Math/VectorUtil.h"
8 
9 using namespace std;
10 using namespace wp2012;
11 
12 namespace HWWFunctions {
13 
14  bool pass_electronSelectionCompareMask( const cuts_t cuts_passed, const cuts_t selectionType ) {
15  if ((cuts_passed & selectionType) == selectionType) return true;
16  return false;
17  }
18 
19  bool pass_electronSelection(HWW& hww, const unsigned int index, const cuts_t selectionType, bool applyAlignmentCorrection, bool removedEtaCutInEndcap, bool useGsfTrack) {
21  cuts_t cuts_passed = electronSelection(hww, index, applyAlignmentCorrection, removedEtaCutInEndcap, useGsfTrack);
22  if ( (cuts_passed & selectionType) == selectionType ) return true;
23  return false;
24  }
25 
26  cuts_t electronSelection(HWW& hww, const unsigned int index, bool applyAlignmentCorrection, bool removedEtaCutInEndcap, bool useGsfTrack) {
27 
28  // keep track of which cuts passed
29  cuts_t cuts_passed = 0;
30 
32  // Isolation //
34 
35 
36  //pf iso
37  float pfiso = electronIsoValuePF(hww, index,0);
38  if (fabs(hww.els_p4().at(index).eta()) < 1.479){
39  if (pfiso<0.15) cuts_passed |= (1ll<<ELEISO_SMURFV4);
40  if (pfiso<0.13) cuts_passed |= (1ll<<ELEISO_SMURFV5);
41  } else if (pfiso<0.09) {
42  cuts_passed |= (1ll<<ELEISO_SMURFV4);
43  cuts_passed |= (1ll<<ELEISO_SMURFV5);
44  }
45 
47  // d0 //
49  if (fabs(electron_d0PV_smurfV3(hww, index)) < 0.02 && fabs(electron_dzPV_smurfV3(hww, index)) < 0.2 ) cuts_passed |= (1ll<<ELEIP_PV_SMURFV3);
50  if (fabs(electron_dzPV_smurfV3(hww, index)) < 0.1 ) cuts_passed |= (1ll<<ELEIP_PV_DZ_1MM);
51  if (fabs(electron_d0PV_smurfV3(hww, index)) < 0.04 && fabs(electron_dzPV_smurfV3(hww, index)) < 1.0 ) cuts_passed |= (1ll<<ELEIP_PV_OSV2);
52  if (fabs(electron_d0PV_smurfV3(hww, index)) < 0.20 && fabs(electron_dzPV_smurfV3(hww, index)) < 1.0 ) cuts_passed |= (1ll<<ELEIP_PV_OSV2_FO);
53 
55  // Identification //
57 
58  // SMURF ID
59  if (electronId_smurf_v1(hww, index)) cuts_passed |= (1ll<<ELEID_SMURFV1_EXTRA);
60  if (electronId_smurf_v2(hww, index)) cuts_passed |= (1ll<<ELEID_SMURFV2_EXTRA);
61  if (electronId_smurf_v3(hww, index)) cuts_passed |= (1ll<<ELEID_SMURFV3_EXTRA);
62 
63 
64  electronIdComponent_t answer_med_2012 = electronId_WP2012(hww, index, MEDIUM);
65  if ((answer_med_2012 & PassWP2012CutsNoIso) == PassWP2012CutsNoIso) cuts_passed |= (1ll<<ELEID_WP2012_MEDIUM_NOISO);
66  if ((answer_med_2012 & PassWP2012CutsNoIsoNoIP) == PassWP2012CutsNoIsoNoIP) cuts_passed |= (1ll<<ELEID_WP2012_MEDIUM_NOISO_NOIP);
67 
68  electronIdComponent_t answer_loose_2012 = electronId_WP2012(hww, index, LOOSE);
69  if ((answer_loose_2012 & PassWP2012CutsNoIso) == PassWP2012CutsNoIso) cuts_passed |= (1ll<<ELEID_WP2012_LOOSE_NOISO);
70 
71  // VBTF ID
72  electronIdComponent_t answer_vbtf = 0;
73  // VBTF95 (optimised in 35X)
74  answer_vbtf = electronId_VBTF(hww, index, VBTF_35X_95, applyAlignmentCorrection, removedEtaCutInEndcap);
75  if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_35X_95);
76  // VBTF90 (optimised in 35X)
77  answer_vbtf = electronId_VBTF(hww, index, VBTF_35X_90, applyAlignmentCorrection, removedEtaCutInEndcap);
78  if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_35X_90);
79  // VBTF80 (optimised in 35X)
80  answer_vbtf = electronId_VBTF(hww, index, VBTF_35X_80, applyAlignmentCorrection, removedEtaCutInEndcap);
81  if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_35X_80);
82  // VBTF85 no H/E in endcap
83  answer_vbtf = electronId_VBTF(hww, index, VBTF_85_NOHOEEND, applyAlignmentCorrection, removedEtaCutInEndcap);
84  if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_85_NOHOEEND);
85  // VBTF85
86  answer_vbtf = electronId_VBTF(hww, index, VBTF_85 , applyAlignmentCorrection, removedEtaCutInEndcap);
87  if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_85);
88  // VBTF80 no H/E in endcap
89  answer_vbtf = electronId_VBTF(hww, index, VBTF_80_NOHOEEND, applyAlignmentCorrection, removedEtaCutInEndcap);
90  if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_80_NOHOEEND);
91  // VBTF70 no H/E in endcap
92  answer_vbtf = electronId_VBTF(hww, index, VBTF_70_NOHOEEND, applyAlignmentCorrection, removedEtaCutInEndcap);
93  if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_70_NOHOEEND);
94  // VBTF90 with H/E and dPhiIn tuned to match HLT
95  answer_vbtf = electronId_VBTF(hww, index, VBTF_90_HLT, applyAlignmentCorrection, removedEtaCutInEndcap);
96  if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_90_HLT);
97  // VBTF90 with H/E and dPhiIn tuned to match HLT (CaloIdT+TrkIdVL)
98  answer_vbtf = electronId_VBTF(hww, index, VBTF_90_HLT_CALOIDT_TRKIDVL, applyAlignmentCorrection, removedEtaCutInEndcap);
99  if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_90_HLT_CALOIDT_TRKIDVL);
100  // VBTF95 no H/E in endcap
101  answer_vbtf = electronId_VBTF(hww, index, VBTF_95_NOHOEEND, applyAlignmentCorrection, removedEtaCutInEndcap);
102  if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) cuts_passed |= (1ll<<ELEID_VBTF_95_NOHOEEND);
103 
104 
106  // Conversion Rejection //
108  if (!isFromConversionPartnerTrack(hww, index)) cuts_passed |= (1ll<<ELENOTCONV_DISTDCOT002);
109  if (hww.els_exp_innerlayers().at(index) == 0) cuts_passed |= (1ll<<ELENOTCONV_HITPATTERN_0MHITS);
110  if(!isFromConversionMIT(hww, index)) cuts_passed |= (1ll<<ELENOTCONV_MIT);
111 
113  // Fiduciality //
115  if ((hww.els_type().at(index) & (1ll<<ISECALDRIVEN))) cuts_passed |= (1ll<<ELESEED_ECAL);
116  if (fabs(hww.els_p4().at(index).eta()) < 2.5) cuts_passed |= (1ll<<ELEETA_250);
117  if (fabs(hww.els_p4().at(index).eta()) < 2.4) cuts_passed |= (1ll<<ELEETA_240);
118 
120  // Pt //
122  if( hww.els_p4().at(index).pt() > 10.0 ) cuts_passed |= (1ll<<ELEPT_010);
123 
124  // Veto electron in transition region
125  if( fabs(hww.els_etaSC().at(index)) < 1.4442 || fabs(hww.els_etaSC().at(index)) > 1.566 ) cuts_passed |= (1ll<<ELE_NOT_TRANSITION);
126 
128  // Charge Flip //
130  if (!isChargeFlip3agree(hww, index)) cuts_passed |= (1ll<<ELECHARGE_NOTFLIP3AGREE);
131 
132  // return which selections passed
133  return cuts_passed;
134 
135  }
136 
138  // Identification //
140 
141  bool electronId_smurf_v1(HWW& hww, const unsigned int index)
142  {
143 
144  if (hww.els_p4().at(index).pt() > 20.0) return true;
145 
146  if (hww.els_fbrem().at(index) > 0.15) return true;
147 
148  if (fabs(hww.els_etaSC().at(index)) < 1.) {
149  if (hww.els_eOverPIn().at(index) > 0.95 && fabs(hww.els_dPhiIn().at(index)*hww.els_charge().at(index)) < 0.006) return true;
150  }
151 
152  return false;
153  }
154 
155  bool electronId_smurf_v2(HWW& hww, const unsigned int index)
156  {
157 
158  if (hww.els_p4().at(index).pt() > 20.0) return true;
159 
160  if (hww.els_fbrem().at(index) > 0.15) return true;
161 
162  if (fabs(hww.els_etaSC().at(index)) < 1.) {
163  if (hww.els_eOverPIn().at(index) > 0.95) return true;
164  }
165 
166  return false;
167  }
168 
169  bool electronId_smurf_v3(HWW& hww, const unsigned int index)
170  {
171  if (fabs(hww.els_etaSC().at(index)) > 1.479 && hww.els_hOverE().at(index) > 0.1) return false;
172 
173  if (hww.els_p4().at(index).pt() > 20.0) return true;
174 
175  electronIdComponent_t answer_vbtf = 0;
176  answer_vbtf = electronId_VBTF(hww, index, VBTF_70_NOHOEEND, false, false);
177  if ((answer_vbtf & (1ll<<ELEID_ID)) == (1ll<<ELEID_ID)) {
178 
179  if (hww.els_fbrem().at(index) > 0.15) return true;
180 
181  if (fabs(hww.els_etaSC().at(index)) < 1.) {
182  if (hww.els_eOverPIn().at(index) > 0.95) return true;
183  }
184 
185  }
186 
187  return false;
188  }
189 
190 
191  // WP2012
192  electronIdComponent_t electronId_WP2012(HWW& hww, const unsigned int index, const wp2012_tightness tightness)
193  {
194 
195  // set return value
196  unsigned int mask = 0;
197 
198  // cut values
199  std::vector<double> dEtaInThresholds;
200  std::vector<double> dPhiInThresholds;
201  std::vector<double> sigmaIEtaIEtaThresholds;
202  std::vector<double> hoeThresholds;
203  std::vector<double> ooemoopThresholds;
204  std::vector<double> d0VtxThresholds;
205  std::vector<double> dzVtxThresholds;
206  std::vector<bool> vtxFitThresholds;
207  std::vector<int> mHitsThresholds;
208  std::vector<double> isoHiThresholds;
209  std::vector<double> isoLoThresholds;
210 
211  // set cut values
212  eidGetWP2012(tightness, dEtaInThresholds, dPhiInThresholds, hoeThresholds, sigmaIEtaIEtaThresholds,
213  ooemoopThresholds, d0VtxThresholds, dzVtxThresholds, vtxFitThresholds, mHitsThresholds,
214  isoHiThresholds, isoLoThresholds);
215 
216  // useful kinematic variables
217  unsigned int det = ((hww.els_fiduciality().at(index) & (1<<ISEB)) == (1<<ISEB)) ? 0 : 1;
218  float etaAbs = fabs(hww.els_etaSC().at(index));
219  float pt = hww.els_p4().at(index).pt();
220 
221  // get effective area
222  float AEff = 0.;
223  if (etaAbs <= 1.0) AEff = 0.10;
224  else if (etaAbs > 1.0 && etaAbs <= 1.479) AEff = 0.12;
225  else if (etaAbs > 1.479 && etaAbs <= 2.0) AEff = 0.085;
226  else if (etaAbs > 2.0 && etaAbs <= 2.2) AEff = 0.11;
227  else if (etaAbs > 2.2 && etaAbs <= 2.3) AEff = 0.12;
228  else if (etaAbs > 2.3 && etaAbs <= 2.4) AEff = 0.12;
229  else if (etaAbs > 2.4) AEff = 0.13;
230 
231  // pf iso
232  // calculate from the ntuple for now...
233  float pfiso_ch = hww.els_iso03_pf2012_ch().at(index);
234  float pfiso_em = hww.els_iso03_pf2012_em().at(index);
235  float pfiso_nh = hww.els_iso03_pf2012_nh().at(index);
236 
237  // rho
238  float rhoPrime = std::max(hww.evt_kt6pf_foregiso_rho(), float(0.0));
239  float pfiso_n = std::max(pfiso_em + pfiso_nh - rhoPrime * AEff, float(0.0));
240  float pfiso = (pfiso_ch + pfiso_n) / pt;
241 
242  // |1/E - 1/p|
243  float ooemoop = fabs( (1.0/hww.els_ecalEnergy().at(index)) - (hww.els_eOverPIn().at(index)/hww.els_ecalEnergy().at(index)) );
244 
245  // MIT conversion vtx fit
246  bool vtxFitConversion = isMITConversion(hww, index, 0, 1e-6, 2.0, true, false);
247 
248  // d0
249  float d0vtx = electron_d0PV_smurfV3(hww, index);
250  float dzvtx = electron_dzPV_smurfV3(hww, index);
251 
252  // test cuts
253  if (fabs(hww.els_dEtaIn().at(index)) < dEtaInThresholds[det]) mask |= wp2012::DETAIN;
254  if (fabs(hww.els_dPhiIn().at(index)) < dPhiInThresholds[det]) mask |= wp2012::DPHIIN;
255  if (hww.els_sigmaIEtaIEta().at(index) < sigmaIEtaIEtaThresholds[det]) mask |= wp2012::SIGMAIETAIETA;
256  if (hww.els_hOverE().at(index) < hoeThresholds[det]) mask |= wp2012::HOE;
257  if (ooemoop < ooemoopThresholds[det]) mask |= wp2012::OOEMOOP;
258  if (fabs(d0vtx) < d0VtxThresholds[det]) mask |= wp2012::D0VTX;
259  if (fabs(dzvtx) < dzVtxThresholds[det]) mask |= wp2012::DZVTX;
260  if (!vtxFitThresholds[det] || !vtxFitConversion) mask |= wp2012::VTXFIT;
261  if (hww.els_exp_innerlayers().at(index) <= mHitsThresholds[det]) mask |= wp2012::MHITS;
262  if (pt >= 20.0 && pfiso < isoHiThresholds[det]) mask |= wp2012::ISO;
263  if (pt < 20.0 && pfiso < isoLoThresholds[det]) mask |= wp2012::ISO;
264 
265  // return the mask
266  return mask;
267 
268  }
269 
270  float fastJetEffArea04_v1(const float eta)
271  {
272  // use absolute eta
273  const float etaAbs = fabs(eta);
274 
275  // get effective area
276  if (etaAbs <= 1.0 ) {return 0.19;}
277  else if (etaAbs > 1.0 && etaAbs <= 1.479) {return 0.25;}
278  else if (etaAbs > 1.479 && etaAbs <= 2.0) {return 0.12;}
279  else if (etaAbs > 2.0 && etaAbs <= 2.2 ) {return 0.21;}
280  else if (etaAbs > 2.2 && etaAbs <= 2.3 ) {return 0.27;}
281  else if (etaAbs > 2.3 && etaAbs <= 2.4 ) {return 0.44;}
282  else if (etaAbs > 2.4 ) {return 0.52;}
283  return -9999.0f;
284  }
285 
286  // VBTF stuff
287  electronIdComponent_t electronId_VBTF(HWW& hww, const unsigned int index, const vbtf_tightness tightness, bool applyAlignementCorrection, bool removedEtaCutInEndcap)
288  {
289 
290  unsigned int answer = 0;
291 
292  std::vector<double> relisoThresholds;
293  std::vector<double> dEtaInThresholds;
294  std::vector<double> dPhiInThresholds;
295  std::vector<double> hoeThresholds;
296  std::vector<double> sigmaIEtaIEtaThresholds;
297 
298  eidGetVBTF(tightness, dEtaInThresholds, dPhiInThresholds, hoeThresholds,
299  sigmaIEtaIEtaThresholds, relisoThresholds);
300 
301  //
302  // get corrected dEtaIn and dPhiIn
303  //
304 
305  float dEtaIn = hww.els_dEtaIn().at(index);
306  float dPhiIn = hww.els_dPhiIn().at(index);
307  if (applyAlignementCorrection) electronCorrection_pos(hww, index, dEtaIn, dPhiIn);
308 
309  // barrel
310  if (fabs(hww.els_etaSC().at(index)) < 1.479) {
311 
312  if (electronIsolation_rel(hww, index, true) < relisoThresholds[0])
313  answer |= (1<<ELEID_ISO);
314 
315  if (fabs(dEtaIn) < dEtaInThresholds[0] &&
316  fabs(dPhiIn) < dPhiInThresholds[0] &&
317  hww.els_hOverE().at(index) < hoeThresholds[0] &&
318  hww.els_sigmaIEtaIEta().at(index) < sigmaIEtaIEtaThresholds[0])
319  answer |= (1<<ELEID_ID);
320  }
321 
322  // endcap
323  if (fabs(hww.els_etaSC().at(index)) > 1.479) {
324  if (electronIsolation_rel(hww, index, true) < relisoThresholds[1])
325  answer |= (1<<ELEID_ISO);
326  bool passdEtaCut = fabs(dEtaIn) < dEtaInThresholds[1];
327  if(removedEtaCutInEndcap) passdEtaCut = true;
328  if ( passdEtaCut &&
329  fabs(dPhiIn) < dPhiInThresholds[1] &&
330  hww.els_hOverE().at(index) < hoeThresholds[1] &&
331  hww.els_sigmaIEtaIEta().at(index) < sigmaIEtaIEtaThresholds[1])
332  answer |= (1<<ELEID_ID);
333  }
334 
335  return answer;
336 
337  }
338 
339  bool passLikelihoodId_v2(HWW& hww, unsigned int index, float lhValue, int workingPoint)
340  {
341 
342  float etaSC = hww.els_etaSC().at(index);
343  float pt = hww.els_p4().at(index).Pt();
344  unsigned int nbrem = hww.els_nSeed().at(index);
345 
346  if ( workingPoint == 0 ) {
347 
348  if (pt > 20.0) {
349  if ( ( fabs(etaSC) < 1.479 && nbrem == 0 && lhValue > 3.5 ) ||
350  ( fabs(etaSC) < 1.479 && nbrem >= 1 && lhValue > 4.0 ) ||
351  ( fabs(etaSC) > 1.479 && nbrem == 0 && lhValue > 4.0 ) ||
352  ( fabs(etaSC) > 1.479 && nbrem >= 1 && lhValue > 4.0 )) return true;
353  } else if (pt > 10.0 && pt <= 20.0) {
354  if ( ( fabs(etaSC) < 1.479 && nbrem == 0 && lhValue > 4.0 ) ||
355  ( fabs(etaSC) < 1.479 && nbrem >= 1 && lhValue > 4.5 ) ||
356  ( fabs(etaSC) > 1.479 && nbrem == 0 && lhValue > 4.0 ) ||
357  ( fabs(etaSC) > 1.479 && nbrem >= 1 && lhValue > 4.0 )) return true;
358  }
359 
360  } else {
361  edm::LogError("InvalidInput") << "Error! Likelihood WP not supported: "
362  << workingPoint << ". Please choose 0 for Emanuele 8th September";
363  }
364 
365  return false;
366  }
367 
369  // Isolation //
371 
372  // relative truncated
373  float electronIsolation_rel(HWW& hww, const unsigned int index, bool use_calo_iso ) {
374  float sum = hww.els_tkIso().at(index);
375  if (use_calo_iso) {
376  if (fabs(hww.els_etaSC().at(index)) > 1.479) sum += hww.els_ecalIso().at(index);
377  if (fabs(hww.els_etaSC().at(index)) <= 1.479) sum += max(0., (hww.els_ecalIso().at(index) -1.));
378  sum += hww.els_hcalIso().at(index);
379  }
380  double pt = hww.els_p4().at(index).pt();
381  return sum/max(pt, 20.);
382  }
383 
384  float electronIsoValuePF(HWW& hww, const unsigned int iel, unsigned int ivtx, float coner, float minptn, float dzcut, float footprintdr, float gammastripveto, float elestripveto, int filterId ) {
385 
386  int elgsftkid = hww.els_gsftrkidx().at(iel);
387  int eltkid = hww.els_trkidx().at(iel);
388  float eldz = elgsftkid>=0 ? gsftrks_dz_pv(hww, elgsftkid,ivtx ).first : trks_dz_pv(hww, eltkid,ivtx).first;
389  float eleta = hww.els_p4().at(iel).eta();
390 
391  float pfciso = 0.;
392  float pfniso = 0.;
393  float pffootprint = 0.;
394  float pfjurveto = 0.;
395  float pfjurvetoq = 0.;
396  for (unsigned int ipf=0; ipf<hww.pfcands_p4().size(); ++ipf){
397 
398  float dR = ROOT::Math::VectorUtil::DeltaR( hww.pfcands_p4().at(ipf), hww.els_p4().at(iel) );
399 
400  if (dR>coner) continue;
401 
402  float pfpt = hww.pfcands_p4().at(ipf).pt();
403  float pfeta = hww.pfcands_p4().at(ipf).eta();
404  float deta = fabs(pfeta - eleta);
405  int pfid = abs(hww.pfcands_particleId().at(ipf));
406 
407  if (filterId!=0 && filterId!=pfid) continue;
408 
409  if (hww.pfcands_charge().at(ipf)==0) {
410  //neutrals
411  if (pfpt>minptn) {
412  pfniso+=pfpt;
413  if (dR<footprintdr && pfid==130) pffootprint+=pfpt;
414  if (deta<gammastripveto && pfid==22) pfjurveto+=pfpt;
415  }
416  } else {
417  //charged
418  //avoid double counting of electron itself
419  //if either the gsf or the ctf track are shared with the candidate, skip it
420  int pftkid = hww.pfcands_trkidx().at(ipf);
421  if (eltkid>=0 && pftkid>=0 && eltkid==pftkid) continue;
422  if (pfid==11 && hww.pfcands_pfelsidx().at(ipf)>=0 && hww.pfels_elsidx().at(hww.pfcands_pfelsidx().at(ipf))>=0) {
423  int pfgsfid = hww.els_gsftrkidx().at(hww.pfels_elsidx().at(hww.pfcands_pfelsidx().at(ipf)));
424  if (elgsftkid>=0 && pfgsfid>=0 && elgsftkid==pfgsfid) continue;
425  }
426  //check electrons with gsf track
427  if (pfid==11 && hww.pfcands_pfelsidx().at(ipf)>=0 && hww.pfels_elsidx().at(hww.pfcands_pfelsidx().at(ipf))>=0) {
428  int gsfid = hww.els_gsftrkidx().at(hww.pfels_elsidx().at(hww.pfcands_pfelsidx().at(ipf)));
429  if (gsfid>=0) {
430  if(fabs(gsftrks_dz_pv(hww, gsfid,ivtx ).first - eldz )<dzcut) {//dz cut
431  pfciso+=pfpt;
432  if (deta<elestripveto && pfid==11) pfjurvetoq+=pfpt;
433  }
434  continue;//and avoid double counting
435  }
436  }
437  //then check anything that has a ctf track
438  if (pftkid>=0) {//charged (with a ctf track)
439  if(fabs( trks_dz_pv(hww, hww.pfcands_trkidx().at(ipf),ivtx).first - eldz )<dzcut) {//dz cut
440  pfciso+=pfpt;
441  if (deta<elestripveto && pfid==11) pfjurvetoq+=pfpt;
442  }
443  }
444  }
445  }
446 
447 
448  return (pfciso+pfniso-pffootprint-pfjurveto-pfjurvetoq)/hww.els_p4().at(iel).pt();
449 
450  }
451 
453  // Conversion Rejection //
455 
456  bool isFromConversionPartnerTrack(HWW& hww, const unsigned int index) {
457  if( fabs(hww.els_conv_dist().at(index)) < 0.02 && fabs(hww.els_conv_dcot().at(index)) < 0.02 ) return true;
458  return false;
459  }
460 
461  bool isFromConversionMIT(HWW& hww, const unsigned int index){
462  return isMITConversion(hww, index, 0, 1e-6, 2.0, true, false);
463  }
464 
465 
466  bool isChargeFlip3agree(HWW& hww, int elIndex){
467  if (hww.els_trkidx().at(elIndex) >= 0) {
468  // false if 3 charge measurements agree
469  if(
470  (hww.els_trk_charge().at(elIndex) // gsf
471  == hww.trks_charge().at(hww.els_trkidx().at(elIndex))) // ctf
472  &&
473  (hww.trks_charge().at(hww.els_trkidx().at(elIndex)) // ctf
474  == hww.els_sccharge().at(elIndex)) ) // sc
475  return false;
476  }
477  return true;
478  }
479 
481  // position correction //
483  void electronCorrection_pos(HWW& hww, const unsigned int index, float &dEtaIn, float &dPhiIn ) {
484 
485  //
486  // uncorrected dEtaIn and dPhiIn
487  //
488 
489  dEtaIn = hww.els_dEtaIn().at(index);
490  dPhiIn = hww.els_dPhiIn().at(index);
491 
492  //
493  // if configered not to apply correction
494  // or in barrel or no valid super cluster
495  // return uncorrected values
496  //
497 
498  if (!(hww.els_fiduciality().at(index) & 1<<ISEE)) return;
499  if (hww.els_scindex().at(index) == -1) return;
500 
501  //
502  // set up correction parameters for EE+ and EE-
503  // RecoEgamma/EgammaTools/python/correctedElectronsProducer_cfi.py?revision=1.2
504  //
505 
506  // X', Y', Z'
507  float scPositionCorrectionEEP[3] = { 0.52, -0.81, 0.81};
508  float scPositionCorrectionEEM[3] = { -0.02, -0.81, -0.94};
509 
510  LorentzVector initial_pos = hww.scs_pos_p4().at(hww.els_scindex().at(index));
511  LorentzVector corrected_pos;
512 
513  //
514  // work out corrected position
515  //
516 
517  if (hww.els_etaSC().at(index) < 0) {
518  corrected_pos = LorentzVector( initial_pos.x() + scPositionCorrectionEEM[0],
519  initial_pos.y() + scPositionCorrectionEEM[1],
520  initial_pos.z() + scPositionCorrectionEEM[2], 0.0);
521  }
522  if (hww.els_etaSC().at(index) > 0) {
523  corrected_pos = LorentzVector( initial_pos.x() + scPositionCorrectionEEP[0],
524  initial_pos.y() + scPositionCorrectionEEP[1],
525  initial_pos.z() + scPositionCorrectionEEP[2], 0.0);
526  }
527 
528  //
529  // work out correction to dEtaIn and dPhiIn
530  //
531 
532  float deta_sc = corrected_pos.Eta() - initial_pos.Eta();
533  float dphi_sc = acos(cos(corrected_pos.Phi() - initial_pos.Phi()));
534  dEtaIn = deta_sc + hww.els_dEtaIn().at(index);
535  dPhiIn = acos(cos(dphi_sc + hww.els_dPhiIn().at(index)));
536 
537  }
538 
540  // d0 //
542 
543  double electron_d0PV_smurfV3(HWW& hww, unsigned int index){
544  int vtxIndex = 0;
545  double dxyPV = hww.els_d0().at(index)-
546  hww.vtxs_position().at(vtxIndex).x()*sin(hww.els_trk_p4().at(index).phi())+
547  hww.vtxs_position().at(vtxIndex).y()*cos(hww.els_trk_p4().at(index).phi());
548  return dxyPV;
549  }
550 
551  double dzPV(const LorentzVector& vtx, const LorentzVector& p4, const LorentzVector& pv){
552  return (vtx.z()-pv.z()) - ((vtx.x()-pv.x())*p4.x()+(vtx.y()-pv.y())*p4.y())/p4.pt() * p4.z()/p4.pt();
553  }
554  double electron_dzPV_smurfV3(HWW& hww, unsigned int index){
555  int vtxIndex = 0;
556  double dzpv = dzPV(hww.els_vertex_p4().at(index), hww.els_trk_p4().at(index), hww.vtxs_position().at(vtxIndex));
557  return dzpv;
558  }
559 
560  double electron_dzPV_wwV1(HWW& hww, unsigned int index){
561  if ( hww.vtxs_sumpt().empty() ) return 9999.;
562  double sumPtMax = -1;
563  int iMax = -1;
564  for ( unsigned int i = 0; i < hww.vtxs_sumpt().size(); ++i ){
565  if (!isGoodVertex(hww, i)) continue;
566  if ( hww.vtxs_sumpt().at(i) > sumPtMax ){
567  iMax = i;
568  sumPtMax = hww.vtxs_sumpt().at(i);
569  }
570  }
571  if (iMax<0) return 9999.;
572 
573  const LorentzVector& vtx = hww.els_vertex_p4().at(index);
574  const LorentzVector& p4 = hww.els_trk_p4().at(index);
575  const LorentzVector& pv = hww.vtxs_position().at(iMax);
576  return (vtx.z()-pv.z()) - ((vtx.x()-pv.x())*p4.x()+(vtx.y()-pv.y())*p4.y())/p4.pt() * p4.z()/p4.pt();
577  }
578 
579  double electron_d0PV_wwV1(HWW& hww, unsigned int index){
580  if ( hww.vtxs_sumpt().empty() ) return 9999.;
581  double sumPtMax = -1;
582  int iMax = -1;
583  for ( unsigned int i = 0; i < hww.vtxs_sumpt().size(); ++i ){
584  if (!isGoodVertex(hww, i)) continue;
585  if ( hww.vtxs_sumpt().at(i) > sumPtMax ){
586  iMax = i;
587  sumPtMax = hww.vtxs_sumpt().at(i);
588  }
589  }
590  if (iMax<0) return 9999.;
591  double dxyPV = hww.els_d0().at(index)-
592  hww.vtxs_position().at(iMax).x()*sin(hww.els_trk_p4().at(index).phi())+
593  hww.vtxs_position().at(iMax).y()*cos(hww.els_trk_p4().at(index).phi());
594  return dxyPV;
595  }
596 
597 
598  // this is now redundant
600 
601  const float etaAbs = fabs(hww.els_etaSC().at(index));
602  const float pt = hww.els_p4().at(index).pt();
603 
604  // get effective area
605  const float AEff = fastJetEffArea04_v1(etaAbs);
606 
607  // pf iso
608  // calculate from the ntuple for now...
609  const float pfiso_ch = hww.els_iso04_pf2012_ch().at(index);
610  const float pfiso_em = hww.els_iso04_pf2012_em().at(index);
611  const float pfiso_nh = hww.els_iso04_pf2012_nh().at(index);
612 
613  // rho
614  const float rhoPrime = std::max(hww.evt_ww_rho(), 0.0f);
615  const float pfiso_n = std::max(pfiso_em + pfiso_nh - rhoPrime * AEff, 0.0f);
616  const float pfiso = (pfiso_ch + pfiso_n) / pt;
617 
618  // debug
619  if(0) {
620  LogDebug("electronSelections") << "AEff : " << AEff << " "
621  << "rho : " << rhoPrime << " "
622  << "pfiso_ch : " << pfiso_ch << " "
623  << "pfiso_em : " << pfiso_em << " "
624  << "pfiso_nh : " << pfiso_nh << " "
625  << "pfiso_n : " << pfiso_n << " "
626  << "pfiso : " << pfiso << " "
627  << "pt : " << pt << " "
628  << "etaAbs : " << etaAbs;
629  }
630 
631  return pfiso;
632  }
633 
634 }
#define LogDebug(id)
bool electronId_smurf_v2(HWW &, const unsigned int index)
std::vector< float > & els_iso03_pf2012_ch()
Definition: HWW.cc:301
float electronIsolation_rel(HWW &, const unsigned int index, bool use_calo_iso)
answer
Definition: submit.py:44
uint64 electronIdComponent_t
int i
Definition: DBlmapReader.cc:9
double electron_dzPV_wwV1(HWW &, unsigned int index)
std::vector< float > & els_conv_dcot()
Definition: HWW.cc:277
std::vector< int > & pfels_elsidx()
Definition: HWW.cc:749
float fastJetEffArea04_v1(HWW &, const float eta)
std::vector< float > & els_tkIso()
Definition: HWW.cc:137
std::vector< int > & els_exp_innerlayers()
Definition: HWW.cc:337
bool passLikelihoodId_v2(HWW &, unsigned int index, float lhValue, int workingPoint)
bool pass_electronSelectionCompareMask(HWW &, const cuts_t cuts_passed, const cuts_t selectionType)
bool isMITConversion(HWW &, unsigned int elidx, int nWrongHitsMax, float probMin, float dlMin, bool matchCTF, bool requireArbitratedMerged)
std::vector< LorentzVector > & els_vertex_p4()
Definition: HWW.cc:109
std::vector< float > & els_hOverE()
Definition: HWW.cc:133
std::vector< int > & pfcands_charge()
Definition: HWW.cc:745
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< float > & els_ecalEnergy()
Definition: HWW.cc:253
std::vector< int > & els_nSeed()
Definition: HWW.cc:321
std::vector< float > & els_d0()
Definition: HWW.cc:145
std::vector< float > & els_iso04_pf2012_nh()
Definition: HWW.cc:297
std::vector< int > & els_sccharge()
Definition: HWW.cc:353
std::vector< float > & els_iso04_pf2012_em()
Definition: HWW.cc:293
std::vector< float > & els_fbrem()
Definition: HWW.cc:153
std::vector< LorentzVector > & pfcands_p4()
Definition: HWW.cc:725
std::vector< float > & els_conv_dist()
Definition: HWW.cc:273
T eta() const
float electronIsoValuePF(HWW &, const unsigned int iel, unsigned int ivtx, float coner=0.4, float minptn=1.0, float dzcut=0.1, float footprintdr=0.07, float gammastripveto=0.025, float elestripveto=-999., int filterId=0)
std::vector< float > & els_iso04_pf2012_ch()
Definition: HWW.cc:289
float electronIsoValuePF2012_FastJetEffArea_HWW(HWW &, int index)
electronIdComponent_t electronId_VBTF(HWW &, const unsigned int index, const vbtf_tightness tightness, bool applyAlignementCorrection=false, bool removedEtaCutInEndcap=false)
std::vector< int > & els_gsftrkidx()
Definition: HWW.cc:333
std::vector< float > & els_iso03_pf2012_nh()
Definition: HWW.cc:309
double electron_dzPV_smurfV3(HWW &, unsigned int index)
cuts_t electronSelection(HWW &, const unsigned int index, bool applyAlignmentCorrection=false, bool removedEtaCutInEndcap=false, bool useGsfTrack=true)
std::vector< float > & els_eOverPIn()
Definition: HWW.cc:157
std::vector< int > & els_scindex()
Definition: HWW.cc:325
std::vector< int > & pfcands_trkidx()
Definition: HWW.cc:729
static const electronIdComponent_t PassWP2012CutsNoIso
std::vector< int > & pfcands_pfelsidx()
Definition: HWW.cc:737
std::pair< double, double > gsftrks_dz_pv(HWW &, int itrk, int ipv)
void checkElectronSelections(void)
std::vector< int > & els_trk_charge()
Definition: HWW.cc:357
std::vector< float > & els_ecalIso()
Definition: HWW.cc:261
double p4[4]
Definition: TauolaWrapper.h:92
double electron_d0PV_smurfV3(HWW &, unsigned int index)
void eidGetVBTF(const vbtf_tightness tightness, std::vector< double > &cutdeta, std::vector< double > &cutdphi, std::vector< double > &cuthoe, std::vector< double > &cutsee, std::vector< double > &cutreliso)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
std::vector< int > & pfcands_particleId()
Definition: HWW.cc:733
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
std::vector< LorentzVector > & vtxs_position()
Definition: HWW.cc:5
double electron_d0PV_wwV1(HWW &, unsigned int index)
std::vector< float > & els_hcalIso()
Definition: HWW.cc:265
bool first
Definition: L1TdeRCT.cc:75
bool electronId_smurf_v1(HWW &, const unsigned int index)
std::vector< LorentzVector > & els_p4()
Definition: HWW.cc:101
std::vector< float > & els_etaSC()
Definition: HWW.cc:117
bool pass_electronSelection(HWW &, const unsigned int index, const cuts_t selectionType, bool applyAlignmentCorrection=false, bool removedEtaCutInEndcap=false, bool useGsfTrack=true)
Definition: HWW.h:11
static const electronIdComponent_t PassWP2012CutsNoIsoNoIP
std::vector< int > & els_charge()
Definition: HWW.cc:329
bool isFromConversionMIT(HWW &, const unsigned int index)
std::pair< double, double > trks_dz_pv(HWW &, int itrk, int ipv)
std::vector< float > & els_dPhiIn()
Definition: HWW.cc:129
float & evt_kt6pf_foregiso_rho()
Definition: HWW.cc:635
std::vector< int > & els_type()
Definition: HWW.cc:345
double dzPV(const LorentzVector &vtx, const LorentzVector &p4, const LorentzVector &pv)
void eidGetWP2012(const wp2012_tightness tightness, std::vector< double > &cutdeta, std::vector< double > &cutdphi, std::vector< double > &cuthoe, std::vector< double > &cutsee, std::vector< double > &cutooemoop, std::vector< double > &cutd0vtx, std::vector< double > &cutdzvtx, std::vector< bool > &cutvtxfit, std::vector< int > &cutmhit, std::vector< double > &cutrelisohighpt, std::vector< double > &cutrelisolowpt)
bool electronId_smurf_v3(HWW &, const unsigned int index)
std::vector< float > & els_dEtaIn()
Definition: HWW.cc:125
uint64 cuts_t
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< float > > LorentzVector
Definition: pfjetMVAtools.h:10
electronIdComponent_t electronId_WP2012(HWW &, const unsigned int index, const wp2012_tightness tightness)
float & evt_ww_rho()
Definition: HWW.cc:627
std::vector< float > & els_iso03_pf2012_em()
Definition: HWW.cc:305
std::vector< LorentzVector > & scs_pos_p4()
Definition: HWW.cc:685
bool isChargeFlip3agree(HWW &, int elIndex)
void electronCorrection_pos(HWW &, const unsigned int index, float &dEtaIn, float &dPhiIn)
std::vector< int > & trks_charge()
Definition: HWW.cc:95
std::vector< float > & els_sigmaIEtaIEta()
Definition: HWW.cc:121
std::vector< float > & vtxs_sumpt()
Definition: HWW.cc:13
std::vector< LorentzVector > & els_trk_p4()
Definition: HWW.cc:105
math::PtEtaPhiELorentzVectorF LorentzVector
std::vector< int > & els_trkidx()
Definition: HWW.cc:341
bool isFromConversionPartnerTrack(HWW &, const unsigned int index)
std::vector< int > & els_fiduciality()
Definition: HWW.cc:349
bool isGoodVertex(HWW &hww, int)