CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AntiElectronIDMVA6.cc
Go to the documentation of this file.
2 
4 
10 
12 
13 #include <TFile.h>
14 #include <array>
15 
16 using namespace antiElecIDMVA6_blocks;
17 
18 namespace {
19  const reco::Track* getTrackFromPFCand(const reco::PFCandidate* pfCandidate) {
20  const reco::Track* track = nullptr;
21  if (pfCandidate->trackRef().isNonnull())
22  track = pfCandidate->trackRef().get();
23  else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->innerTrack().isNonnull())
24  track = pfCandidate->muonRef()->innerTrack().get();
25  else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->globalTrack().isNonnull())
26  track = pfCandidate->muonRef()->globalTrack().get();
27  else if (pfCandidate->muonRef().isNonnull() && pfCandidate->muonRef()->outerTrack().isNonnull())
28  track = pfCandidate->muonRef()->outerTrack().get();
29  else if (pfCandidate->gsfTrackRef().isNonnull())
30  track = pfCandidate->gsfTrackRef().get();
31  return track;
32  }
33 } // namespace
34 
35 template <class TauType, class ElectronType>
37  : isInitialized_(false),
38  mva_NoEleMatch_woGwoGSF_BL_(nullptr),
39  mva_NoEleMatch_wGwoGSF_BL_(nullptr),
40  mva_woGwGSF_BL_(nullptr),
41  mva_wGwGSF_BL_(nullptr),
42  mva_NoEleMatch_woGwoGSF_EC_(nullptr),
43  mva_NoEleMatch_wGwoGSF_EC_(nullptr),
44  mva_woGwGSF_EC_(nullptr),
45  mva_wGwGSF_EC_(nullptr),
46  mva_NoEleMatch_woGwoGSF_VFEC_(nullptr),
47  mva_NoEleMatch_wGwoGSF_VFEC_(nullptr),
48  mva_woGwGSF_VFEC_(nullptr),
49  mva_wGwGSF_VFEC_(nullptr),
50  isPhase2_(cfg.getParameter<bool>("isPhase2")),
51  positionAtECalEntrance_(PositionAtECalEntranceComputer(cc, isPhase2_)),
52  verbosity_(cfg.getParameter<int>("verbosity")) {
53  loadMVAfromDB_ = cfg.exists("loadMVAfromDB") ? cfg.getParameter<bool>("loadMVAfromDB") : false;
54  if (!loadMVAfromDB_) {
55  if (cfg.exists("inputFileName")) {
56  inputFileName_ = cfg.getParameter<edm::FileInPath>("inputFileName");
57  } else
58  throw cms::Exception("MVA input not defined")
59  << "Requested to load tau MVA input from ROOT file but no file provided in cfg file";
60  }
61 
62  mvaName_NoEleMatch_woGwoGSF_BL_ = cfg.getParameter<std::string>("mvaName_NoEleMatch_woGwoGSF_BL");
63  mvaName_NoEleMatch_wGwoGSF_BL_ = cfg.getParameter<std::string>("mvaName_NoEleMatch_wGwoGSF_BL");
64  mvaName_woGwGSF_BL_ = cfg.getParameter<std::string>("mvaName_woGwGSF_BL");
65  mvaName_wGwGSF_BL_ = cfg.getParameter<std::string>("mvaName_wGwGSF_BL");
66  mvaName_NoEleMatch_woGwoGSF_EC_ = cfg.getParameter<std::string>("mvaName_NoEleMatch_woGwoGSF_EC");
67  mvaName_NoEleMatch_wGwoGSF_EC_ = cfg.getParameter<std::string>("mvaName_NoEleMatch_wGwoGSF_EC");
68  mvaName_woGwGSF_EC_ = cfg.getParameter<std::string>("mvaName_woGwGSF_EC");
69  mvaName_wGwGSF_EC_ = cfg.getParameter<std::string>("mvaName_wGwGSF_EC");
70  if (isPhase2_) {
71  mvaName_NoEleMatch_woGwoGSF_VFEC_ = cfg.getParameter<std::string>("mvaName_NoEleMatch_woGwoGSF_VFEC");
72  mvaName_NoEleMatch_wGwoGSF_VFEC_ = cfg.getParameter<std::string>("mvaName_NoEleMatch_wGwoGSF_VFEC");
73  mvaName_woGwGSF_VFEC_ = cfg.getParameter<std::string>("mvaName_woGwGSF_VFEC");
74  mvaName_wGwGSF_VFEC_ = cfg.getParameter<std::string>("mvaName_wGwGSF_VFEC");
75  }
76  if (loadMVAfromDB_) {
78  mvaToken_NoEleMatch_wGwoGSF_BL_ = cc.esConsumes(edm::ESInputTag{"", mvaName_NoEleMatch_wGwoGSF_BL_});
79  mvaToken_woGwGSF_BL_ = cc.esConsumes(edm::ESInputTag{"", mvaName_woGwGSF_BL_});
80  mvaToken_wGwGSF_BL_ = cc.esConsumes(edm::ESInputTag{"", mvaName_wGwGSF_BL_});
81  mvaToken_NoEleMatch_woGwoGSF_EC_ = cc.esConsumes(edm::ESInputTag{"", mvaName_NoEleMatch_woGwoGSF_EC_});
82  mvaToken_NoEleMatch_wGwoGSF_EC_ = cc.esConsumes(edm::ESInputTag{"", mvaName_NoEleMatch_wGwoGSF_EC_});
83  mvaToken_woGwGSF_EC_ = cc.esConsumes(edm::ESInputTag{"", mvaName_woGwGSF_EC_});
84  mvaToken_wGwGSF_EC_ = cc.esConsumes(edm::ESInputTag{"", mvaName_wGwGSF_EC_});
85  if (isPhase2_) {
90  }
91  }
92  usePhiAtEcalEntranceExtrapolation_ = cfg.getParameter<bool>("usePhiAtEcalEntranceExtrapolation");
93 
94  if (!isPhase2_) {
95  var_NoEleMatch_woGwoGSF_Barrel_ = std::vector<float>(10);
96  var_NoEleMatch_wGwoGSF_Barrel_ = std::vector<float>(18);
97  var_woGwGSF_Barrel_ = std::vector<float>(24);
98  var_wGwGSF_Barrel_ = std::vector<float>(32);
99  var_NoEleMatch_woGwoGSF_Endcap_ = std::vector<float>(9);
100  var_NoEleMatch_wGwoGSF_Endcap_ = std::vector<float>(17);
101  var_woGwGSF_Endcap_ = std::vector<float>(23);
102  var_wGwGSF_Endcap_ = std::vector<float>(31);
103  } else {
104  var_NoEleMatch_woGwoGSF_Barrel_ = std::vector<float>(9);
105  var_NoEleMatch_wGwoGSF_Barrel_ = std::vector<float>(17);
106  var_woGwGSF_Barrel_ = std::vector<float>(27);
107  var_wGwGSF_Barrel_ = std::vector<float>(36);
108  var_NoEleMatch_woGwoGSF_Endcap_ = std::vector<float>(6);
109  var_NoEleMatch_wGwoGSF_Endcap_ = std::vector<float>(14);
110  var_woGwGSF_Endcap_ = std::vector<float>(31);
111  var_wGwGSF_Endcap_ = std::vector<float>(38);
112  var_NoEleMatch_woGwoGSF_VFEndcap_ = std::vector<float>(6);
113  var_NoEleMatch_wGwoGSF_VFEndcap_ = std::vector<float>(14);
114  var_woGwGSF_VFEndcap_ = std::vector<float>(32);
115  var_wGwGSF_VFEndcap_ = std::vector<float>(40);
116 
117  //MB: Tokens for additional inputs (HGCal EleID variables) only for Phase2 and reco::GsfElectrons
119  for (const auto& inputTag : cfg.getParameter<std::vector<edm::InputTag>>("hgcalElectronIDs")) {
120  std::string elecIdLabel = "hgcElectronID:" + inputTag.instance();
121  electronIds_tokens_[elecIdLabel] = cc.consumes<edm::ValueMap<float>>(
122  inputTag); //MB: It assumes that instances are not empty and meaningful (as for userData in patElectrons)
124  }
125  }
126  }
127 }
128 
129 template <class TauType, class ElectronType>
131  if (!loadMVAfromDB_) {
132  delete mva_NoEleMatch_woGwoGSF_BL_;
133  delete mva_NoEleMatch_wGwoGSF_BL_;
134  delete mva_woGwGSF_BL_;
135  delete mva_wGwGSF_BL_;
136  delete mva_NoEleMatch_woGwoGSF_EC_;
137  delete mva_NoEleMatch_wGwoGSF_EC_;
138  delete mva_woGwGSF_EC_;
139  delete mva_wGwGSF_EC_;
140  if (isPhase2_) {
141  delete mva_NoEleMatch_woGwoGSF_VFEC_;
142  delete mva_NoEleMatch_wGwoGSF_VFEC_;
143  delete mva_woGwGSF_VFEC_;
144  delete mva_wGwGSF_VFEC_;
145  }
146  }
147 
148  for (std::vector<TFile*>::iterator it = inputFilesToDelete_.begin(); it != inputFilesToDelete_.end(); ++it) {
149  delete (*it);
150  }
151 }
152 
153 namespace {
154  const GBRForest* loadMVAfromFile(TFile* inputFile, const std::string& mvaName) {
155  const GBRForest* mva = (GBRForest*)inputFile->Get(mvaName.data());
156  if (mva == nullptr)
157  throw cms::Exception("PFRecoTauDiscriminationAgainstElectronMVA6::loadMVA")
158  << " Failed to load MVA = " << mvaName.data() << " from file "
159  << " !!\n";
160 
161  return mva;
162  }
163 } // namespace
164 
165 template <class TauType, class ElectronType>
167  if (!isInitialized_) {
168  if (loadMVAfromDB_) {
169  mva_NoEleMatch_woGwoGSF_BL_ = &es.getData(mvaToken_NoEleMatch_woGwoGSF_BL_);
170  mva_NoEleMatch_wGwoGSF_BL_ = &es.getData(mvaToken_NoEleMatch_wGwoGSF_BL_);
171  mva_woGwGSF_BL_ = &es.getData(mvaToken_woGwGSF_BL_);
172  mva_wGwGSF_BL_ = &es.getData(mvaToken_wGwGSF_BL_);
173  mva_NoEleMatch_woGwoGSF_EC_ = &es.getData(mvaToken_NoEleMatch_woGwoGSF_EC_);
174  mva_NoEleMatch_wGwoGSF_EC_ = &es.getData(mvaToken_NoEleMatch_wGwoGSF_EC_);
175  mva_woGwGSF_EC_ = &es.getData(mvaToken_woGwGSF_EC_);
176  mva_wGwGSF_EC_ = &es.getData(mvaToken_wGwGSF_EC_);
177  if (isPhase2_) {
178  mva_NoEleMatch_woGwoGSF_VFEC_ = &es.getData(mvaToken_NoEleMatch_woGwoGSF_VFEC_);
179  mva_NoEleMatch_wGwoGSF_VFEC_ = &es.getData(mvaToken_NoEleMatch_wGwoGSF_VFEC_);
180  mva_woGwGSF_VFEC_ = &es.getData(mvaToken_woGwGSF_VFEC_);
181  mva_wGwGSF_VFEC_ = &es.getData(mvaToken_wGwGSF_VFEC_);
182  }
183  } else {
184  if (inputFileName_.location() == edm::FileInPath::Unknown)
185  throw cms::Exception("PFRecoTauDiscriminationAgainstElectronMVA6::loadMVA")
186  << " Failed to find File = " << inputFileName_ << " !!\n";
187  TFile* inputFile = new TFile(inputFileName_.fullPath().data());
188 
189  mva_NoEleMatch_woGwoGSF_BL_ = loadMVAfromFile(inputFile, mvaName_NoEleMatch_woGwoGSF_BL_);
190  mva_NoEleMatch_wGwoGSF_BL_ = loadMVAfromFile(inputFile, mvaName_NoEleMatch_wGwoGSF_BL_);
191  mva_woGwGSF_BL_ = loadMVAfromFile(inputFile, mvaName_woGwGSF_BL_);
192  mva_wGwGSF_BL_ = loadMVAfromFile(inputFile, mvaName_wGwGSF_BL_);
193  mva_NoEleMatch_woGwoGSF_EC_ = loadMVAfromFile(inputFile, mvaName_NoEleMatch_woGwoGSF_EC_);
194  mva_NoEleMatch_wGwoGSF_EC_ = loadMVAfromFile(inputFile, mvaName_NoEleMatch_wGwoGSF_EC_);
195  mva_woGwGSF_EC_ = loadMVAfromFile(inputFile, mvaName_woGwGSF_EC_);
196  mva_wGwGSF_EC_ = loadMVAfromFile(inputFile, mvaName_wGwGSF_EC_);
197  if (isPhase2_) {
198  mva_NoEleMatch_woGwoGSF_VFEC_ = loadMVAfromFile(inputFile, mvaName_NoEleMatch_woGwoGSF_VFEC_);
199  mva_NoEleMatch_wGwoGSF_VFEC_ = loadMVAfromFile(inputFile, mvaName_NoEleMatch_wGwoGSF_VFEC_);
200  mva_woGwGSF_VFEC_ = loadMVAfromFile(inputFile, mvaName_woGwGSF_VFEC_);
201  mva_wGwGSF_VFEC_ = loadMVAfromFile(inputFile, mvaName_wGwGSF_VFEC_);
202  }
203  inputFilesToDelete_.push_back(inputFile);
204  }
205  isInitialized_ = true;
206  }
207  positionAtECalEntrance_.beginEvent(es);
208  //MB: Handle additional inputs (HGCal EleID variables) only for Phase2 and reco::GsfElectrons
210  for (const auto& eId_token : electronIds_tokens_) {
211  electronIds_[eId_token.first] = evt.getHandle(eId_token.second);
212  }
213  }
214 }
215 
216 template <class TauType, class ElectronType>
218  const TauGammaVecs& tauGammaVecs,
219  const ElecVars& elecVars) {
220  TauGammaMoms tauGammaMoms;
221  double sumPt = 0.;
222  double dEta2 = 0.;
223  double dPhi2 = 0.;
224  tauGammaMoms.signalPFGammaCandsIn = tauGammaVecs.gammasPtInSigCone.size();
225  for (size_t i = 0; i < tauGammaVecs.gammasPtInSigCone.size(); ++i) {
226  double pt_i = tauGammaVecs.gammasPtInSigCone[i];
227  double phi_i = tauGammaVecs.gammasdPhiInSigCone[i];
228  if (tauGammaVecs.gammasdPhiInSigCone[i] > M_PI)
229  phi_i = tauGammaVecs.gammasdPhiInSigCone[i] - 2 * M_PI;
230  else if (tauGammaVecs.gammasdPhiInSigCone[i] < -M_PI)
231  phi_i = tauGammaVecs.gammasdPhiInSigCone[i] + 2 * M_PI;
232  double eta_i = tauGammaVecs.gammasdEtaInSigCone[i];
233  sumPt += pt_i;
234  dEta2 += (pt_i * eta_i * eta_i);
235  dPhi2 += (pt_i * phi_i * phi_i);
236  }
237 
238  tauGammaMoms.gammaEnFracIn = -99.;
239  if (tauVars.pt > 0.) {
240  tauGammaMoms.gammaEnFracIn = sumPt / tauVars.pt;
241  }
242  if (sumPt > 0.) {
243  dEta2 /= sumPt;
244  dPhi2 /= sumPt;
245  }
246  tauGammaMoms.gammaEtaMomIn = std::sqrt(dEta2 * tauGammaMoms.gammaEnFracIn) * tauVars.pt;
247  tauGammaMoms.gammaPhiMomIn = std::sqrt(dPhi2 * tauGammaMoms.gammaEnFracIn) * tauVars.pt;
248 
249  sumPt = 0.;
250  dEta2 = 0.;
251  dPhi2 = 0.;
252  tauGammaMoms.signalPFGammaCandsOut = tauGammaVecs.gammasPtOutSigCone.size();
253  for (size_t i = 0; i < tauGammaVecs.gammasPtOutSigCone.size(); ++i) {
254  double pt_i = tauGammaVecs.gammasPtOutSigCone[i];
255  double phi_i = tauGammaVecs.gammasdPhiOutSigCone[i];
256  if (tauGammaVecs.gammasdPhiOutSigCone[i] > M_PI)
257  phi_i = tauGammaVecs.gammasdPhiOutSigCone[i] - 2 * M_PI;
258  else if (tauGammaVecs.gammasdPhiOutSigCone[i] < -M_PI)
259  phi_i = tauGammaVecs.gammasdPhiOutSigCone[i] + 2 * M_PI;
260  double eta_i = tauGammaVecs.gammasdEtaOutSigCone[i];
261  sumPt += pt_i;
262  dEta2 += (pt_i * eta_i * eta_i);
263  dPhi2 += (pt_i * phi_i * phi_i);
264  }
265 
266  tauGammaMoms.gammaEnFracOut = -99.;
267  if (tauVars.pt > 0.) {
268  tauGammaMoms.gammaEnFracOut = sumPt / tauVars.pt;
269  }
270  if (sumPt > 0.) {
271  dEta2 /= sumPt;
272  dPhi2 /= sumPt;
273  }
274  tauGammaMoms.gammaEtaMomOut = std::sqrt(dEta2 * tauGammaMoms.gammaEnFracOut) * tauVars.pt;
275  tauGammaMoms.gammaPhiMomOut = std::sqrt(dPhi2 * tauGammaMoms.gammaEnFracOut) * tauVars.pt;
276 
277  if (!isPhase2_) {
278  return mvaValue(tauVars, tauGammaMoms, elecVars);
279  } else {
280  return mvaValuePhase2(tauVars, tauGammaMoms, elecVars);
281  }
282 }
283 
284 template <class TauType, class ElectronType>
286  const TauGammaMoms& tauGammaMoms,
287  const ElecVars& elecVars) {
288  if (!isInitialized_) {
289  throw cms::Exception("ClassNotInitialized") << " AntiElectronMVA6 not properly initialized !!\n";
290  }
291 
292  double mvaValue = -99.;
293 
294  float elecDeltaPinPoutOverPin = (elecVars.pIn > 0.0) ? (std::abs(elecVars.pIn - elecVars.pOut) / elecVars.pIn) : 1.0;
295  float elecEecalOverPout = (elecVars.pOut > 0.0) ? (elecVars.eEcal / elecVars.pOut) : 20.0;
296  float elecNumHitsDiffOverSum =
297  ((elecVars.gsfNumHits + elecVars.kfNumHits) > 0.0)
298  ? ((elecVars.gsfNumHits - elecVars.kfNumHits) / (elecVars.gsfNumHits + elecVars.kfNumHits))
299  : 1.0;
300 
301  if (deltaR(tauVars.etaAtEcalEntrance, tauVars.phi, elecVars.eta, elecVars.phi) > 0.3 &&
302  tauGammaMoms.signalPFGammaCandsIn == 0 && tauVars.hasGsf < 0.5) {
303  if (std::abs(tauVars.etaAtEcalEntrance) < ecalBarrelEndcapEtaBorder_) {
304  var_NoEleMatch_woGwoGSF_Barrel_[0] = tauVars.etaAtEcalEntrance;
305  var_NoEleMatch_woGwoGSF_Barrel_[1] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
306  var_NoEleMatch_woGwoGSF_Barrel_[2] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
307  var_NoEleMatch_woGwoGSF_Barrel_[3] = std::log(std::max(1.f, tauVars.pt));
308  var_NoEleMatch_woGwoGSF_Barrel_[4] = tauVars.emFraction;
309  var_NoEleMatch_woGwoGSF_Barrel_[5] = tauVars.leadPFChargedHadrHoP;
310  var_NoEleMatch_woGwoGSF_Barrel_[6] = tauVars.leadPFChargedHadrEoP;
311  var_NoEleMatch_woGwoGSF_Barrel_[7] = tauVars.visMassIn;
312  var_NoEleMatch_woGwoGSF_Barrel_[8] = tauVars.dCrackEta;
313  var_NoEleMatch_woGwoGSF_Barrel_[9] = tauVars.dCrackPhi;
314  mvaValue = mva_NoEleMatch_woGwoGSF_BL_->GetClassifier(var_NoEleMatch_woGwoGSF_Barrel_.data());
315  } else {
316  var_NoEleMatch_woGwoGSF_Endcap_[0] = tauVars.etaAtEcalEntrance;
317  var_NoEleMatch_woGwoGSF_Endcap_[1] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
318  var_NoEleMatch_woGwoGSF_Endcap_[2] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
319  var_NoEleMatch_woGwoGSF_Endcap_[3] = std::log(std::max(1.f, tauVars.pt));
320  var_NoEleMatch_woGwoGSF_Endcap_[4] = tauVars.emFraction;
321  var_NoEleMatch_woGwoGSF_Endcap_[5] = tauVars.leadPFChargedHadrHoP;
322  var_NoEleMatch_woGwoGSF_Endcap_[6] = tauVars.leadPFChargedHadrEoP;
323  var_NoEleMatch_woGwoGSF_Endcap_[7] = tauVars.visMassIn;
324  var_NoEleMatch_woGwoGSF_Endcap_[8] = tauVars.dCrackEta;
325  mvaValue = mva_NoEleMatch_woGwoGSF_EC_->GetClassifier(var_NoEleMatch_woGwoGSF_Endcap_.data());
326  }
327  } else if (deltaR(tauVars.etaAtEcalEntrance, tauVars.phi, elecVars.eta, elecVars.phi) > 0.3 &&
328  tauGammaMoms.signalPFGammaCandsIn > 0 && tauVars.hasGsf < 0.5) {
329  if (std::abs(tauVars.etaAtEcalEntrance) < ecalBarrelEndcapEtaBorder_) {
330  var_NoEleMatch_wGwoGSF_Barrel_[0] = tauVars.etaAtEcalEntrance;
331  var_NoEleMatch_wGwoGSF_Barrel_[1] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
332  var_NoEleMatch_wGwoGSF_Barrel_[2] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
333  var_NoEleMatch_wGwoGSF_Barrel_[3] = std::log(std::max(1.f, tauVars.pt));
334  var_NoEleMatch_wGwoGSF_Barrel_[4] = tauVars.emFraction;
335  var_NoEleMatch_wGwoGSF_Barrel_[5] = tauGammaMoms.signalPFGammaCandsIn;
336  var_NoEleMatch_wGwoGSF_Barrel_[6] = tauGammaMoms.signalPFGammaCandsOut;
337  var_NoEleMatch_wGwoGSF_Barrel_[7] = tauVars.leadPFChargedHadrHoP;
338  var_NoEleMatch_wGwoGSF_Barrel_[8] = tauVars.leadPFChargedHadrEoP;
339  var_NoEleMatch_wGwoGSF_Barrel_[9] = tauVars.visMassIn;
340  var_NoEleMatch_wGwoGSF_Barrel_[10] = tauGammaMoms.gammaEtaMomIn;
341  var_NoEleMatch_wGwoGSF_Barrel_[11] = tauGammaMoms.gammaEtaMomOut;
342  var_NoEleMatch_wGwoGSF_Barrel_[12] = tauGammaMoms.gammaPhiMomIn;
343  var_NoEleMatch_wGwoGSF_Barrel_[13] = tauGammaMoms.gammaPhiMomOut;
344  var_NoEleMatch_wGwoGSF_Barrel_[14] = tauGammaMoms.gammaEnFracIn;
345  var_NoEleMatch_wGwoGSF_Barrel_[15] = tauGammaMoms.gammaEnFracOut;
346  var_NoEleMatch_wGwoGSF_Barrel_[16] = tauVars.dCrackEta;
347  var_NoEleMatch_wGwoGSF_Barrel_[17] = tauVars.dCrackPhi;
348  mvaValue = mva_NoEleMatch_wGwoGSF_BL_->GetClassifier(var_NoEleMatch_wGwoGSF_Barrel_.data());
349  } else {
350  var_NoEleMatch_wGwoGSF_Endcap_[0] = tauVars.etaAtEcalEntrance;
351  var_NoEleMatch_wGwoGSF_Endcap_[1] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
352  var_NoEleMatch_wGwoGSF_Endcap_[2] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
353  var_NoEleMatch_wGwoGSF_Endcap_[3] = std::log(std::max(1.f, tauVars.pt));
354  var_NoEleMatch_wGwoGSF_Endcap_[4] = tauVars.emFraction;
355  var_NoEleMatch_wGwoGSF_Endcap_[5] = tauGammaMoms.signalPFGammaCandsIn;
356  var_NoEleMatch_wGwoGSF_Endcap_[6] = tauGammaMoms.signalPFGammaCandsOut;
357  var_NoEleMatch_wGwoGSF_Endcap_[7] = tauVars.leadPFChargedHadrHoP;
358  var_NoEleMatch_wGwoGSF_Endcap_[8] = tauVars.leadPFChargedHadrEoP;
359  var_NoEleMatch_wGwoGSF_Endcap_[9] = tauVars.visMassIn;
360  var_NoEleMatch_wGwoGSF_Endcap_[10] = tauGammaMoms.gammaEtaMomIn;
361  var_NoEleMatch_wGwoGSF_Endcap_[11] = tauGammaMoms.gammaEtaMomOut;
362  var_NoEleMatch_wGwoGSF_Endcap_[12] = tauGammaMoms.gammaPhiMomIn;
363  var_NoEleMatch_wGwoGSF_Endcap_[13] = tauGammaMoms.gammaPhiMomOut;
364  var_NoEleMatch_wGwoGSF_Endcap_[14] = tauGammaMoms.gammaEnFracIn;
365  var_NoEleMatch_wGwoGSF_Endcap_[15] = tauGammaMoms.gammaEnFracOut;
366  var_NoEleMatch_wGwoGSF_Endcap_[16] = tauVars.dCrackEta;
367  mvaValue = mva_NoEleMatch_wGwoGSF_EC_->GetClassifier(var_NoEleMatch_wGwoGSF_Endcap_.data());
368  }
369  } else if (tauGammaMoms.signalPFGammaCandsIn == 0 && tauVars.hasGsf > 0.5) {
370  if (std::abs(tauVars.etaAtEcalEntrance) < ecalBarrelEndcapEtaBorder_) {
371  var_woGwGSF_Barrel_[0] = std::max(-0.1f, elecVars.eTotOverPin);
372  var_woGwGSF_Barrel_[1] = std::log(std::max(0.01f, elecVars.chi2NormGSF));
373  var_woGwGSF_Barrel_[2] = elecVars.gsfNumHits;
374  var_woGwGSF_Barrel_[3] = std::log(std::max(0.01f, elecVars.gsfTrackResol));
375  var_woGwGSF_Barrel_[4] = elecVars.gsfTracklnPt;
376  var_woGwGSF_Barrel_[5] = elecNumHitsDiffOverSum;
377  var_woGwGSF_Barrel_[6] = std::log(std::max(0.01f, elecVars.chi2NormKF));
378  var_woGwGSF_Barrel_[7] = std::min(elecDeltaPinPoutOverPin, 1.f);
379  var_woGwGSF_Barrel_[8] = std::min(elecEecalOverPout, 20.f);
380  var_woGwGSF_Barrel_[9] = elecVars.deltaEta;
381  var_woGwGSF_Barrel_[10] = elecVars.deltaPhi;
382  var_woGwGSF_Barrel_[11] = std::min(elecVars.mvaInSigmaEtaEta, 0.01f);
383  var_woGwGSF_Barrel_[12] = std::min(elecVars.mvaInHadEnergy, 20.f);
384  var_woGwGSF_Barrel_[13] = std::min(elecVars.mvaInDeltaEta, 0.1f);
385  var_woGwGSF_Barrel_[14] = tauVars.etaAtEcalEntrance;
386  var_woGwGSF_Barrel_[15] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
387  var_woGwGSF_Barrel_[16] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
388  var_woGwGSF_Barrel_[17] = std::log(std::max(1.f, tauVars.pt));
389  var_woGwGSF_Barrel_[18] = tauVars.emFraction;
390  var_woGwGSF_Barrel_[19] = tauVars.leadPFChargedHadrHoP;
391  var_woGwGSF_Barrel_[20] = tauVars.leadPFChargedHadrEoP;
392  var_woGwGSF_Barrel_[21] = tauVars.visMassIn;
393  var_woGwGSF_Barrel_[22] = tauVars.dCrackEta;
394  var_woGwGSF_Barrel_[23] = tauVars.dCrackPhi;
395  mvaValue = mva_woGwGSF_BL_->GetClassifier(var_woGwGSF_Barrel_.data());
396  } else {
397  var_woGwGSF_Endcap_[0] = std::max(-0.1f, elecVars.eTotOverPin);
398  var_woGwGSF_Endcap_[1] = std::log(std::max(0.01f, elecVars.chi2NormGSF));
399  var_woGwGSF_Endcap_[2] = elecVars.gsfNumHits;
400  var_woGwGSF_Endcap_[3] = std::log(std::max(0.01f, elecVars.gsfTrackResol));
401  var_woGwGSF_Endcap_[4] = elecVars.gsfTracklnPt;
402  var_woGwGSF_Endcap_[5] = elecNumHitsDiffOverSum;
403  var_woGwGSF_Endcap_[6] = std::log(std::max(0.01f, elecVars.chi2NormKF));
404  var_woGwGSF_Endcap_[7] = std::min(elecDeltaPinPoutOverPin, 1.f);
405  var_woGwGSF_Endcap_[8] = std::min(elecEecalOverPout, 20.f);
406  var_woGwGSF_Endcap_[9] = elecVars.deltaEta;
407  var_woGwGSF_Endcap_[10] = elecVars.deltaPhi;
408  var_woGwGSF_Endcap_[11] = std::min(elecVars.mvaInSigmaEtaEta, 0.01f);
409  var_woGwGSF_Endcap_[12] = std::min(elecVars.mvaInHadEnergy, 20.f);
410  var_woGwGSF_Endcap_[13] = std::min(elecVars.mvaInDeltaEta, 0.1f);
411  var_woGwGSF_Endcap_[14] = tauVars.etaAtEcalEntrance;
412  var_woGwGSF_Endcap_[15] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
413  var_woGwGSF_Endcap_[16] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
414  var_woGwGSF_Endcap_[17] = std::log(std::max(1.f, tauVars.pt));
415  var_woGwGSF_Endcap_[18] = tauVars.emFraction;
416  var_woGwGSF_Endcap_[19] = tauVars.leadPFChargedHadrHoP;
417  var_woGwGSF_Endcap_[20] = tauVars.leadPFChargedHadrEoP;
418  var_woGwGSF_Endcap_[21] = tauVars.visMassIn;
419  var_woGwGSF_Endcap_[22] = tauVars.dCrackEta;
420  mvaValue = mva_woGwGSF_EC_->GetClassifier(var_woGwGSF_Endcap_.data());
421  }
422  } else if (tauGammaMoms.signalPFGammaCandsIn > 0 && tauVars.hasGsf > 0.5) {
423  if (std::abs(tauVars.etaAtEcalEntrance) < ecalBarrelEndcapEtaBorder_) {
424  var_wGwGSF_Barrel_[0] = std::max(-0.1f, elecVars.eTotOverPin);
425  var_wGwGSF_Barrel_[1] = std::log(std::max(0.01f, elecVars.chi2NormGSF));
426  var_wGwGSF_Barrel_[2] = elecVars.gsfNumHits;
427  var_wGwGSF_Barrel_[3] = std::log(std::max(0.01f, elecVars.gsfTrackResol));
428  var_wGwGSF_Barrel_[4] = elecVars.gsfTracklnPt;
429  var_wGwGSF_Barrel_[5] = elecNumHitsDiffOverSum;
430  var_wGwGSF_Barrel_[6] = std::log(std::max(0.01f, elecVars.chi2NormKF));
431  var_wGwGSF_Barrel_[7] = std::min(elecDeltaPinPoutOverPin, 1.f);
432  var_wGwGSF_Barrel_[8] = std::min(elecEecalOverPout, 20.f);
433  var_wGwGSF_Barrel_[9] = elecVars.deltaEta;
434  var_wGwGSF_Barrel_[10] = elecVars.deltaPhi;
435  var_wGwGSF_Barrel_[11] = std::min(elecVars.mvaInSigmaEtaEta, 0.01f);
436  var_wGwGSF_Barrel_[12] = std::min(elecVars.mvaInHadEnergy, 20.f);
437  var_wGwGSF_Barrel_[13] = std::min(elecVars.mvaInDeltaEta, 0.1f);
438  var_wGwGSF_Barrel_[14] = tauVars.etaAtEcalEntrance;
439  var_wGwGSF_Barrel_[15] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
440  var_wGwGSF_Barrel_[16] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
441  var_wGwGSF_Barrel_[17] = std::log(std::max(1.f, tauVars.pt));
442  var_wGwGSF_Barrel_[18] = tauVars.emFraction;
443  var_wGwGSF_Barrel_[19] = tauGammaMoms.signalPFGammaCandsIn;
444  var_wGwGSF_Barrel_[20] = tauGammaMoms.signalPFGammaCandsOut;
445  var_wGwGSF_Barrel_[21] = tauVars.leadPFChargedHadrHoP;
446  var_wGwGSF_Barrel_[22] = tauVars.leadPFChargedHadrEoP;
447  var_wGwGSF_Barrel_[23] = tauVars.visMassIn;
448  var_wGwGSF_Barrel_[24] = tauGammaMoms.gammaEtaMomIn;
449  var_wGwGSF_Barrel_[25] = tauGammaMoms.gammaEtaMomOut;
450  var_wGwGSF_Barrel_[26] = tauGammaMoms.gammaPhiMomIn;
451  var_wGwGSF_Barrel_[27] = tauGammaMoms.gammaPhiMomOut;
452  var_wGwGSF_Barrel_[28] = tauGammaMoms.gammaEnFracIn;
453  var_wGwGSF_Barrel_[29] = tauGammaMoms.gammaEnFracOut;
454  var_wGwGSF_Barrel_[30] = tauVars.dCrackEta;
455  var_wGwGSF_Barrel_[31] = tauVars.dCrackPhi;
456  mvaValue = mva_wGwGSF_BL_->GetClassifier(var_wGwGSF_Barrel_.data());
457  } else {
458  var_wGwGSF_Endcap_[0] = std::max(-0.1f, elecVars.eTotOverPin);
459  var_wGwGSF_Endcap_[1] = std::log(std::max(0.01f, elecVars.chi2NormGSF));
460  var_wGwGSF_Endcap_[2] = elecVars.gsfNumHits;
461  var_wGwGSF_Endcap_[3] = std::log(std::max(0.01f, elecVars.gsfTrackResol));
462  var_wGwGSF_Endcap_[4] = elecVars.gsfTracklnPt;
463  var_wGwGSF_Endcap_[5] = elecNumHitsDiffOverSum;
464  var_wGwGSF_Endcap_[6] = std::log(std::max(0.01f, elecVars.chi2NormKF));
465  var_wGwGSF_Endcap_[7] = std::min(elecDeltaPinPoutOverPin, 1.f);
466  var_wGwGSF_Endcap_[8] = std::min(elecEecalOverPout, 20.f);
467  var_wGwGSF_Endcap_[9] = elecVars.deltaEta;
468  var_wGwGSF_Endcap_[10] = elecVars.deltaPhi;
469  var_wGwGSF_Endcap_[11] = std::min(elecVars.mvaInSigmaEtaEta, 0.01f);
470  var_wGwGSF_Endcap_[12] = std::min(elecVars.mvaInHadEnergy, 20.f);
471  var_wGwGSF_Endcap_[13] = std::min(elecVars.mvaInDeltaEta, 0.1f);
472  var_wGwGSF_Endcap_[14] = tauVars.etaAtEcalEntrance;
473  var_wGwGSF_Endcap_[15] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
474  var_wGwGSF_Endcap_[16] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
475  var_wGwGSF_Endcap_[17] = std::log(std::max(1.f, tauVars.pt));
476  var_wGwGSF_Endcap_[18] = tauVars.emFraction;
477  var_wGwGSF_Endcap_[19] = tauGammaMoms.signalPFGammaCandsIn;
478  var_wGwGSF_Endcap_[20] = tauGammaMoms.signalPFGammaCandsOut;
479  var_wGwGSF_Endcap_[21] = tauVars.leadPFChargedHadrHoP;
480  var_wGwGSF_Endcap_[22] = tauVars.leadPFChargedHadrEoP;
481  var_wGwGSF_Endcap_[23] = tauVars.visMassIn;
482  var_wGwGSF_Endcap_[24] = tauGammaMoms.gammaEtaMomIn;
483  var_wGwGSF_Endcap_[25] = tauGammaMoms.gammaEtaMomOut;
484  var_wGwGSF_Endcap_[26] = tauGammaMoms.gammaPhiMomIn;
485  var_wGwGSF_Endcap_[27] = tauGammaMoms.gammaPhiMomOut;
486  var_wGwGSF_Endcap_[28] = tauGammaMoms.gammaEnFracIn;
487  var_wGwGSF_Endcap_[29] = tauGammaMoms.gammaEnFracOut;
488  var_wGwGSF_Endcap_[30] = tauVars.dCrackEta;
489  mvaValue = mva_wGwGSF_EC_->GetClassifier(var_wGwGSF_Endcap_.data());
490  }
491  }
492  return mvaValue;
493 }
495 template <class TauType, class ElectronType>
497  const TauGammaMoms& tauGammaMoms,
498  const ElecVars& elecVars) {
499  if (!isInitialized_) {
500  throw cms::Exception("ClassNotInitialized") << " AntiElectronMVA6 not properly initialized !!\n";
501  }
502 
503  double mvaValue = -99.;
504 
505  //do not consider tau candidates outside the HGCal border at |eta|=3
506  if (std::abs(tauVars.etaAtEcalEntrance) > 3.0) {
507  return mvaValue;
508  }
509 
510  float elecDeltaPinPoutOverPin = (elecVars.pIn > 0.0) ? (std::abs(elecVars.pIn - elecVars.pOut) / elecVars.pIn) : 1.0;
511  float elecEecalOverPout = (elecVars.pOut > 0.0) ? (elecVars.eEcal / elecVars.pOut) : 20.0;
512  float elecNumHitsDiffOverSum =
513  ((elecVars.gsfNumHits + elecVars.kfNumHits) > 0.0)
514  ? ((elecVars.gsfNumHits - elecVars.kfNumHits) / (elecVars.gsfNumHits + elecVars.kfNumHits))
515  : 1.0;
516 
517  if (tauGammaMoms.signalPFGammaCandsIn == 0 && tauVars.hasGsf < 0.5) {
518  if (std::abs(tauVars.etaAtEcalEntrance) < ecalBarrelEndcapEtaBorder_) {
519  var_NoEleMatch_woGwoGSF_Barrel_[0] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
520  var_NoEleMatch_woGwoGSF_Barrel_[1] = std::log(std::max(1.f, tauVars.pt));
521  var_NoEleMatch_woGwoGSF_Barrel_[2] = tauVars.emFraction;
522  var_NoEleMatch_woGwoGSF_Barrel_[3] = tauVars.leadPFChargedHadrHoP;
523  var_NoEleMatch_woGwoGSF_Barrel_[4] = tauVars.leadPFChargedHadrEoP;
524  var_NoEleMatch_woGwoGSF_Barrel_[5] = tauVars.visMassIn;
525  var_NoEleMatch_woGwoGSF_Barrel_[6] = tauVars.dCrackEta;
526  var_NoEleMatch_woGwoGSF_Barrel_[7] = tauVars.etaAtEcalEntrance;
527  var_NoEleMatch_woGwoGSF_Barrel_[8] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
528  mvaValue = mva_NoEleMatch_woGwoGSF_BL_->GetClassifier(var_NoEleMatch_woGwoGSF_Barrel_.data());
529  } else if (std::abs(tauVars.etaAtEcalEntrance) < ecalEndcapVFEndcapEtaBorder_) {
530  var_NoEleMatch_woGwoGSF_Endcap_[0] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
531  var_NoEleMatch_woGwoGSF_Endcap_[1] = std::log(std::max(1.f, tauVars.pt));
532  var_NoEleMatch_woGwoGSF_Endcap_[2] = tauVars.visMassIn;
533  var_NoEleMatch_woGwoGSF_Endcap_[3] = tauVars.dCrackEta;
534  var_NoEleMatch_woGwoGSF_Endcap_[4] = tauVars.etaAtEcalEntrance;
535  var_NoEleMatch_woGwoGSF_Endcap_[5] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
536  mvaValue = mva_NoEleMatch_woGwoGSF_EC_->GetClassifier(var_NoEleMatch_woGwoGSF_Endcap_.data());
537  } else {
538  var_NoEleMatch_woGwoGSF_VFEndcap_[0] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
539  var_NoEleMatch_woGwoGSF_VFEndcap_[1] = std::log(std::max(1.f, tauVars.pt));
540  var_NoEleMatch_woGwoGSF_VFEndcap_[2] = tauVars.visMassIn;
541  var_NoEleMatch_woGwoGSF_VFEndcap_[3] = tauVars.dCrackEta;
542  var_NoEleMatch_woGwoGSF_VFEndcap_[4] = tauVars.etaAtEcalEntrance;
543  var_NoEleMatch_woGwoGSF_VFEndcap_[5] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
544  mvaValue = mva_NoEleMatch_woGwoGSF_VFEC_->GetClassifier(var_NoEleMatch_woGwoGSF_VFEndcap_.data());
545  }
546  } else if (tauGammaMoms.signalPFGammaCandsIn > 0 && tauVars.hasGsf < 0.5) {
547  if (std::abs(tauVars.etaAtEcalEntrance) < ecalBarrelEndcapEtaBorder_) {
548  var_NoEleMatch_wGwoGSF_Barrel_[0] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
549  var_NoEleMatch_wGwoGSF_Barrel_[1] = std::log(std::max(1.f, tauVars.pt));
550  var_NoEleMatch_wGwoGSF_Barrel_[2] = tauVars.emFraction;
551  var_NoEleMatch_wGwoGSF_Barrel_[3] = tauGammaMoms.signalPFGammaCandsIn;
552  var_NoEleMatch_wGwoGSF_Barrel_[4] = tauGammaMoms.signalPFGammaCandsOut;
553  var_NoEleMatch_wGwoGSF_Barrel_[5] = tauVars.leadPFChargedHadrHoP;
554  var_NoEleMatch_wGwoGSF_Barrel_[6] = tauVars.leadPFChargedHadrEoP;
555  var_NoEleMatch_wGwoGSF_Barrel_[7] = tauVars.visMassIn;
556  var_NoEleMatch_wGwoGSF_Barrel_[7] = tauGammaMoms.gammaEtaMomIn;
557  var_NoEleMatch_wGwoGSF_Barrel_[9] = tauGammaMoms.gammaEtaMomOut;
558  var_NoEleMatch_wGwoGSF_Barrel_[10] = tauGammaMoms.gammaPhiMomIn;
559  var_NoEleMatch_wGwoGSF_Barrel_[11] = tauGammaMoms.gammaPhiMomOut;
560  var_NoEleMatch_wGwoGSF_Barrel_[12] = tauGammaMoms.gammaEnFracIn;
561  var_NoEleMatch_wGwoGSF_Barrel_[13] = tauGammaMoms.gammaEnFracOut;
562  var_NoEleMatch_wGwoGSF_Barrel_[14] = tauVars.dCrackEta;
563  var_NoEleMatch_wGwoGSF_Barrel_[15] = tauVars.etaAtEcalEntrance;
564  var_NoEleMatch_wGwoGSF_Barrel_[16] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
565  mvaValue = mva_NoEleMatch_wGwoGSF_BL_->GetClassifier(var_NoEleMatch_wGwoGSF_Barrel_.data());
566  } else if (std::abs(tauVars.etaAtEcalEntrance) < ecalEndcapVFEndcapEtaBorder_) {
567  var_NoEleMatch_wGwoGSF_Endcap_[0] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
568  var_NoEleMatch_wGwoGSF_Endcap_[1] = std::log(std::max(1.f, tauVars.pt));
569  var_NoEleMatch_wGwoGSF_Endcap_[2] = tauGammaMoms.signalPFGammaCandsIn;
570  var_NoEleMatch_wGwoGSF_Endcap_[3] = tauGammaMoms.signalPFGammaCandsOut;
571  var_NoEleMatch_wGwoGSF_Endcap_[4] = tauVars.visMassIn;
572  var_NoEleMatch_wGwoGSF_Endcap_[5] = tauGammaMoms.gammaEtaMomIn;
573  var_NoEleMatch_wGwoGSF_Endcap_[6] = tauGammaMoms.gammaEtaMomOut;
574  var_NoEleMatch_wGwoGSF_Endcap_[7] = tauGammaMoms.gammaPhiMomIn;
575  var_NoEleMatch_wGwoGSF_Endcap_[8] = tauGammaMoms.gammaPhiMomOut;
576  var_NoEleMatch_wGwoGSF_Endcap_[9] = tauGammaMoms.gammaEnFracIn;
577  var_NoEleMatch_wGwoGSF_Endcap_[10] = tauGammaMoms.gammaEnFracOut;
578  var_NoEleMatch_wGwoGSF_Endcap_[11] = tauVars.dCrackEta;
579  var_NoEleMatch_wGwoGSF_Endcap_[12] = tauVars.etaAtEcalEntrance;
580  var_NoEleMatch_wGwoGSF_Endcap_[13] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
581  mvaValue = mva_NoEleMatch_wGwoGSF_EC_->GetClassifier(var_NoEleMatch_wGwoGSF_Endcap_.data());
582  } else {
583  var_NoEleMatch_wGwoGSF_VFEndcap_[0] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
584  var_NoEleMatch_wGwoGSF_VFEndcap_[1] = std::log(std::max(1.f, tauVars.pt));
585  var_NoEleMatch_wGwoGSF_VFEndcap_[2] = tauGammaMoms.signalPFGammaCandsIn;
586  var_NoEleMatch_wGwoGSF_VFEndcap_[3] = tauGammaMoms.signalPFGammaCandsOut;
587  var_NoEleMatch_wGwoGSF_VFEndcap_[4] = tauVars.visMassIn;
588  var_NoEleMatch_wGwoGSF_VFEndcap_[5] = tauGammaMoms.gammaEtaMomIn;
589  var_NoEleMatch_wGwoGSF_VFEndcap_[6] = tauGammaMoms.gammaEtaMomOut;
590  var_NoEleMatch_wGwoGSF_VFEndcap_[7] = tauGammaMoms.gammaPhiMomIn;
591  var_NoEleMatch_wGwoGSF_VFEndcap_[8] = tauGammaMoms.gammaPhiMomOut;
592  var_NoEleMatch_wGwoGSF_VFEndcap_[9] = tauGammaMoms.gammaEnFracIn;
593  var_NoEleMatch_wGwoGSF_VFEndcap_[10] = tauGammaMoms.gammaEnFracOut;
594  var_NoEleMatch_wGwoGSF_VFEndcap_[11] = tauVars.dCrackEta;
595  var_NoEleMatch_wGwoGSF_VFEndcap_[12] = tauVars.etaAtEcalEntrance;
596  var_NoEleMatch_wGwoGSF_VFEndcap_[13] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
597  mvaValue = mva_NoEleMatch_wGwoGSF_VFEC_->GetClassifier(var_NoEleMatch_wGwoGSF_VFEndcap_.data());
598  }
599  } else if (tauGammaMoms.signalPFGammaCandsIn == 0 && tauVars.hasGsf > 0.5) {
600  if (std::abs(tauVars.etaAtEcalEntrance) < ecalBarrelEndcapEtaBorder_) {
601  var_woGwGSF_Barrel_[0] = std::log(std::max(0.1f, elecVars.chi2NormGSF));
602  var_woGwGSF_Barrel_[1] = elecVars.gsfNumHits;
603  var_woGwGSF_Barrel_[2] = std::log(std::max(0.1f, elecVars.gsfTrackResol));
604  var_woGwGSF_Barrel_[3] = elecVars.gsfTracklnPt;
605  var_woGwGSF_Barrel_[4] = elecNumHitsDiffOverSum;
606  var_woGwGSF_Barrel_[5] = std::log(std::max(0.1f, elecVars.chi2NormKF));
607  var_woGwGSF_Barrel_[6] = std::min(elecDeltaPinPoutOverPin, 1.f);
608  var_woGwGSF_Barrel_[7] = std::min(elecEecalOverPout, 20.f);
609  var_woGwGSF_Barrel_[8] = std::min(elecVars.mvaInSigmaEtaEta, 0.01f);
610  var_woGwGSF_Barrel_[9] = std::min(elecVars.mvaInHadEnergy, 20.f);
611  var_woGwGSF_Barrel_[10] = std::min(elecVars.mvaInDeltaEta, 0.1f);
612  var_woGwGSF_Barrel_[11] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
613  var_woGwGSF_Barrel_[12] = std::log(std::max(1.f, tauVars.pt));
614  var_woGwGSF_Barrel_[13] = tauVars.emFraction;
615  var_woGwGSF_Barrel_[14] = tauVars.leadPFChargedHadrHoP;
616  var_woGwGSF_Barrel_[15] = tauVars.leadPFChargedHadrEoP;
617  var_woGwGSF_Barrel_[16] = tauVars.visMassIn;
618  var_woGwGSF_Barrel_[17] = tauVars.dCrackEta;
619  var_woGwGSF_Barrel_[18] = tauVars.etaAtEcalEntrance;
620  var_woGwGSF_Barrel_[19] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
621  var_woGwGSF_Barrel_[20] = elecVars.deltaEta;
622  var_woGwGSF_Barrel_[21] = elecVars.deltaPhi;
623  var_woGwGSF_Barrel_[22] = elecVars.sigmaIEtaIEta5x5;
624  var_woGwGSF_Barrel_[23] = elecVars.showerCircularity;
625  var_woGwGSF_Barrel_[24] = elecVars.r9;
626  var_woGwGSF_Barrel_[25] = elecVars.superClusterEtaWidth;
627  var_woGwGSF_Barrel_[26] = elecVars.superClusterPhiWidth;
628  mvaValue = mva_woGwGSF_BL_->GetClassifier(var_woGwGSF_Barrel_.data());
629  } else if (std::abs(tauVars.etaAtEcalEntrance) < ecalEndcapVFEndcapEtaBorder_) {
630  var_woGwGSF_Endcap_[0] = std::log(std::max(0.1f, elecVars.chi2NormGSF));
631  var_woGwGSF_Endcap_[1] = elecVars.gsfNumHits;
632  var_woGwGSF_Endcap_[2] = std::log(std::max(0.1f, elecVars.gsfTrackResol));
633  var_woGwGSF_Endcap_[3] = elecVars.gsfTracklnPt;
634  var_woGwGSF_Endcap_[4] = elecNumHitsDiffOverSum;
635  var_woGwGSF_Endcap_[5] = std::log(std::max(0.1f, elecVars.chi2NormKF));
636  var_woGwGSF_Endcap_[6] = elecVars.eEcal;
637  var_woGwGSF_Endcap_[7] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
638  var_woGwGSF_Endcap_[8] = std::log(std::max(1.f, tauVars.pt));
639  var_woGwGSF_Endcap_[9] = tauVars.visMassIn;
640  var_woGwGSF_Endcap_[10] = tauVars.dCrackEta;
641  var_woGwGSF_Endcap_[11] = tauVars.etaAtEcalEntrance;
642  var_woGwGSF_Endcap_[12] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
643  var_woGwGSF_Endcap_[13] = elecVars.hgcalSigmaUU;
644  var_woGwGSF_Endcap_[14] = elecVars.hgcalSigmaVV;
645  var_woGwGSF_Endcap_[15] = elecVars.hgcalSigmaEE;
646  var_woGwGSF_Endcap_[16] = elecVars.hgcalSigmaPP;
647  var_woGwGSF_Endcap_[17] = elecVars.hgcalNLayers;
648  var_woGwGSF_Endcap_[18] = elecVars.hgcalLastLayer;
649  var_woGwGSF_Endcap_[19] = elecVars.hgcalLayerEfrac10;
650  var_woGwGSF_Endcap_[20] = elecVars.hgcalLayerEfrac90;
651  var_woGwGSF_Endcap_[21] = elecVars.hgcalEcEnergyEE;
652  var_woGwGSF_Endcap_[22] = elecVars.hgcalEcEnergyFH;
653  var_woGwGSF_Endcap_[23] = elecVars.hgcalMeasuredDepth;
654  var_woGwGSF_Endcap_[24] = elecVars.hgcalExpectedDepth;
655  var_woGwGSF_Endcap_[25] = elecVars.hgcalDepthCompatibility;
656  var_woGwGSF_Endcap_[26] = elecVars.deltaEta;
657  var_woGwGSF_Endcap_[27] = elecVars.deltaPhi;
658  var_woGwGSF_Endcap_[28] = elecVars.eSeedClusterOverPout;
659  var_woGwGSF_Endcap_[29] = elecVars.superClusterEtaWidth;
660  var_woGwGSF_Endcap_[30] = elecVars.superClusterPhiWidth;
661  mvaValue = mva_woGwGSF_EC_->GetClassifier(var_woGwGSF_Endcap_.data());
662  } else {
663  var_woGwGSF_VFEndcap_[0] = std::log(std::max(0.1f, elecVars.chi2NormGSF));
664  var_woGwGSF_VFEndcap_[1] = elecVars.gsfNumHits;
665  var_woGwGSF_VFEndcap_[2] = std::log(std::max(0.1f, elecVars.gsfTrackResol));
666  var_woGwGSF_VFEndcap_[3] = elecVars.gsfTracklnPt;
667  var_woGwGSF_VFEndcap_[4] = elecNumHitsDiffOverSum;
668  var_woGwGSF_VFEndcap_[5] = std::log(std::max(0.1f, elecVars.chi2NormKF));
669  var_woGwGSF_VFEndcap_[6] = elecVars.eEcal;
670  var_woGwGSF_VFEndcap_[7] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
671  var_woGwGSF_VFEndcap_[8] = std::log(std::max(1.f, tauVars.pt));
672  var_woGwGSF_VFEndcap_[9] = tauVars.visMassIn;
673  var_woGwGSF_VFEndcap_[10] = tauVars.dCrackEta;
674  var_woGwGSF_VFEndcap_[11] = tauVars.etaAtEcalEntrance;
675  var_woGwGSF_VFEndcap_[12] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
676  var_woGwGSF_VFEndcap_[13] = elecVars.hgcalSigmaUU;
677  var_woGwGSF_VFEndcap_[14] = elecVars.hgcalSigmaVV;
678  var_woGwGSF_VFEndcap_[15] = elecVars.hgcalSigmaEE;
679  var_woGwGSF_VFEndcap_[16] = elecVars.hgcalSigmaPP;
680  var_woGwGSF_VFEndcap_[17] = elecVars.hgcalNLayers;
681  var_woGwGSF_VFEndcap_[18] = elecVars.hgcalLastLayer;
682  var_woGwGSF_VFEndcap_[19] = elecVars.hgcalLayerEfrac10;
683  var_woGwGSF_VFEndcap_[20] = elecVars.hgcalLayerEfrac90;
684  var_woGwGSF_VFEndcap_[21] = elecVars.hgcalEcEnergyEE;
685  var_woGwGSF_VFEndcap_[22] = elecVars.hgcalEcEnergyFH;
686  var_woGwGSF_VFEndcap_[23] = elecVars.hgcalMeasuredDepth;
687  var_woGwGSF_VFEndcap_[24] = elecVars.hgcalExpectedDepth;
688  var_woGwGSF_VFEndcap_[25] = elecVars.hgcalExpectedSigma;
689  var_woGwGSF_VFEndcap_[26] = elecVars.hgcalDepthCompatibility;
690  var_woGwGSF_VFEndcap_[27] = elecVars.deltaEta;
691  var_woGwGSF_VFEndcap_[28] = elecVars.deltaPhi;
692  var_woGwGSF_VFEndcap_[29] = elecVars.eSeedClusterOverPout;
693  var_woGwGSF_VFEndcap_[30] = elecVars.superClusterEtaWidth;
694  var_woGwGSF_VFEndcap_[31] = elecVars.superClusterPhiWidth;
695  mvaValue = mva_woGwGSF_VFEC_->GetClassifier(var_woGwGSF_VFEndcap_.data());
696  }
697  } else if (tauGammaMoms.signalPFGammaCandsIn > 0 && tauVars.hasGsf > 0.5) {
698  if (std::abs(tauVars.etaAtEcalEntrance) < ecalBarrelEndcapEtaBorder_) {
699  var_wGwGSF_Barrel_[0] = std::log(std::max(0.1f, elecVars.chi2NormGSF));
700  var_wGwGSF_Barrel_[1] = elecVars.gsfNumHits;
701  var_wGwGSF_Barrel_[2] = std::log(std::max(0.1f, elecVars.gsfTrackResol));
702  var_wGwGSF_Barrel_[3] = elecVars.gsfTracklnPt;
703  var_wGwGSF_Barrel_[4] = elecNumHitsDiffOverSum;
704  var_wGwGSF_Barrel_[5] = std::log(std::max(0.1f, elecVars.chi2NormKF));
705  var_wGwGSF_Barrel_[6] = std::min(elecDeltaPinPoutOverPin, 1.f);
706  var_wGwGSF_Barrel_[7] = std::min(elecEecalOverPout, 20.f);
707  var_wGwGSF_Barrel_[8] = std::min(elecVars.mvaInSigmaEtaEta, 0.01f);
708  var_wGwGSF_Barrel_[9] = std::min(elecVars.mvaInHadEnergy, 20.f);
709  var_wGwGSF_Barrel_[10] = std::min(elecVars.mvaInDeltaEta, 0.1f);
710  var_wGwGSF_Barrel_[11] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
711  var_wGwGSF_Barrel_[12] = std::log(std::max(1.f, tauVars.pt));
712  var_wGwGSF_Barrel_[13] = tauVars.emFraction;
713  var_wGwGSF_Barrel_[14] = tauGammaMoms.signalPFGammaCandsIn;
714  var_wGwGSF_Barrel_[15] = tauGammaMoms.signalPFGammaCandsOut;
715  var_wGwGSF_Barrel_[16] = tauVars.leadPFChargedHadrHoP;
716  var_wGwGSF_Barrel_[17] = tauVars.leadPFChargedHadrEoP;
717  var_wGwGSF_Barrel_[18] = tauVars.visMassIn;
718  var_wGwGSF_Barrel_[19] = tauGammaMoms.gammaEtaMomIn;
719  var_wGwGSF_Barrel_[20] = tauGammaMoms.gammaEtaMomOut;
720  var_wGwGSF_Barrel_[21] = tauGammaMoms.gammaPhiMomIn;
721  var_wGwGSF_Barrel_[22] = tauGammaMoms.gammaPhiMomOut;
722  var_wGwGSF_Barrel_[23] = tauGammaMoms.gammaEnFracIn;
723  var_wGwGSF_Barrel_[24] = tauGammaMoms.gammaEnFracOut;
724  var_wGwGSF_Barrel_[25] = tauVars.dCrackEta;
725  var_wGwGSF_Barrel_[26] = tauVars.etaAtEcalEntrance;
726  var_wGwGSF_Barrel_[27] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
727  var_wGwGSF_Barrel_[28] = elecVars.deltaEta;
728  var_wGwGSF_Barrel_[29] = elecVars.deltaPhi;
729  var_wGwGSF_Barrel_[30] = elecVars.sigmaIPhiIPhi5x5;
730  var_wGwGSF_Barrel_[31] = elecVars.sigmaIEtaIEta5x5;
731  var_wGwGSF_Barrel_[32] = elecVars.showerCircularity;
732  var_wGwGSF_Barrel_[33] = elecVars.eSeedClusterOverPout;
733  var_wGwGSF_Barrel_[34] = elecVars.superClusterEtaWidth;
734  var_wGwGSF_Barrel_[35] = elecVars.superClusterPhiWidth;
735  mvaValue = mva_wGwGSF_BL_->GetClassifier(var_wGwGSF_Barrel_.data());
736  } else if (std::abs(tauVars.etaAtEcalEntrance) < ecalEndcapVFEndcapEtaBorder_) {
737  var_wGwGSF_Endcap_[0] = std::log(std::max(0.1f, elecVars.chi2NormGSF));
738  var_wGwGSF_Endcap_[1] = elecVars.gsfNumHits;
739  var_wGwGSF_Endcap_[2] = std::log(std::max(0.1f, elecVars.gsfTrackResol));
740  var_wGwGSF_Endcap_[3] = elecVars.gsfTracklnPt;
741  var_wGwGSF_Endcap_[4] = elecNumHitsDiffOverSum;
742  var_wGwGSF_Endcap_[5] = std::log(std::max(0.1f, elecVars.chi2NormKF));
743  var_wGwGSF_Endcap_[6] = elecVars.eEcal;
744  var_wGwGSF_Endcap_[7] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
745  var_wGwGSF_Endcap_[8] = std::log(std::max(1.f, tauVars.pt));
746  var_wGwGSF_Endcap_[9] = tauGammaMoms.signalPFGammaCandsIn;
747  var_wGwGSF_Endcap_[10] = tauGammaMoms.signalPFGammaCandsOut;
748  var_wGwGSF_Endcap_[11] = tauVars.visMassIn;
749  var_wGwGSF_Endcap_[12] = tauGammaMoms.gammaEtaMomIn;
750  var_wGwGSF_Endcap_[13] = tauGammaMoms.gammaEtaMomOut;
751  var_wGwGSF_Endcap_[14] = tauGammaMoms.gammaPhiMomIn;
752  var_wGwGSF_Endcap_[15] = tauGammaMoms.gammaPhiMomOut;
753  var_wGwGSF_Endcap_[16] = tauGammaMoms.gammaEnFracIn;
754  var_wGwGSF_Endcap_[17] = tauGammaMoms.gammaEnFracOut;
755  var_wGwGSF_Endcap_[18] = tauVars.dCrackEta;
756  var_wGwGSF_Endcap_[19] = tauVars.etaAtEcalEntrance;
757  var_wGwGSF_Endcap_[20] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
758  var_wGwGSF_Endcap_[21] = elecVars.hgcalSigmaVV;
759  var_wGwGSF_Endcap_[22] = elecVars.hgcalSigmaEE;
760  var_wGwGSF_Endcap_[23] = elecVars.hgcalSigmaPP;
761  var_wGwGSF_Endcap_[24] = elecVars.hgcalNLayers;
762  var_wGwGSF_Endcap_[25] = elecVars.hgcalFirstLayer;
763  var_wGwGSF_Endcap_[26] = elecVars.hgcalLastLayer;
764  var_wGwGSF_Endcap_[27] = elecVars.hgcalLayerEfrac10;
765  var_wGwGSF_Endcap_[28] = elecVars.hgcalLayerEfrac90;
766  var_wGwGSF_Endcap_[29] = elecVars.hgcalEcEnergyEE;
767  var_wGwGSF_Endcap_[30] = elecVars.hgcalEcEnergyFH;
768  var_wGwGSF_Endcap_[31] = elecVars.hgcalMeasuredDepth;
769  var_wGwGSF_Endcap_[32] = elecVars.hgcalExpectedDepth;
770  var_wGwGSF_Endcap_[33] = elecVars.deltaEta;
771  var_wGwGSF_Endcap_[34] = elecVars.deltaPhi;
772  var_wGwGSF_Endcap_[35] = elecVars.eSeedClusterOverPout;
773  var_wGwGSF_Endcap_[36] = elecVars.superClusterEtaWidth;
774  var_wGwGSF_Endcap_[37] = elecVars.superClusterPhiWidth;
775  mvaValue = mva_wGwGSF_EC_->GetClassifier(var_wGwGSF_Endcap_.data());
776  } else {
777  var_wGwGSF_VFEndcap_[0] = std::log(std::max(0.1f, elecVars.chi2NormGSF));
778  var_wGwGSF_VFEndcap_[1] = elecVars.gsfNumHits;
779  var_wGwGSF_VFEndcap_[2] = std::log(std::max(0.1f, elecVars.gsfTrackResol));
780  var_wGwGSF_VFEndcap_[3] = elecVars.gsfTracklnPt;
781  var_wGwGSF_VFEndcap_[4] = elecNumHitsDiffOverSum;
782  var_wGwGSF_VFEndcap_[5] = std::log(std::max(0.1f, elecVars.chi2NormKF));
783  var_wGwGSF_VFEndcap_[6] = elecVars.eEcal;
784  var_wGwGSF_VFEndcap_[7] = std::min(2.f, tauVars.leadChargedPFCandPt / std::max(1.f, tauVars.pt));
785  var_wGwGSF_VFEndcap_[8] = std::log(std::max(1.f, tauVars.pt));
786  var_wGwGSF_VFEndcap_[9] = tauGammaMoms.signalPFGammaCandsIn;
787  var_wGwGSF_VFEndcap_[10] = tauGammaMoms.signalPFGammaCandsOut;
788  var_wGwGSF_VFEndcap_[11] = tauVars.visMassIn;
789  var_wGwGSF_VFEndcap_[12] = tauGammaMoms.gammaEtaMomIn;
790  var_wGwGSF_VFEndcap_[13] = tauGammaMoms.gammaEtaMomOut;
791  var_wGwGSF_VFEndcap_[14] = tauGammaMoms.gammaPhiMomIn;
792  var_wGwGSF_VFEndcap_[15] = tauGammaMoms.gammaPhiMomOut;
793  var_wGwGSF_VFEndcap_[16] = tauGammaMoms.gammaEnFracIn;
794  var_wGwGSF_VFEndcap_[17] = tauGammaMoms.gammaEnFracOut;
795  var_wGwGSF_VFEndcap_[18] = tauVars.dCrackEta;
796  var_wGwGSF_VFEndcap_[19] = tauVars.etaAtEcalEntrance;
797  var_wGwGSF_VFEndcap_[20] = tauVars.leadChargedPFCandEtaAtEcalEntrance;
798  var_wGwGSF_VFEndcap_[21] = elecVars.hgcalSigmaUU;
799  var_wGwGSF_VFEndcap_[22] = elecVars.hgcalSigmaVV;
800  var_wGwGSF_VFEndcap_[23] = elecVars.hgcalSigmaEE;
801  var_wGwGSF_VFEndcap_[24] = elecVars.hgcalSigmaPP;
802  var_wGwGSF_VFEndcap_[25] = elecVars.hgcalNLayers;
803  var_wGwGSF_VFEndcap_[26] = elecVars.hgcalLastLayer;
804  var_wGwGSF_VFEndcap_[27] = elecVars.hgcalLayerEfrac10;
805  var_wGwGSF_VFEndcap_[28] = elecVars.hgcalLayerEfrac90;
806  var_wGwGSF_VFEndcap_[29] = elecVars.hgcalEcEnergyEE;
807  var_wGwGSF_VFEndcap_[30] = elecVars.hgcalEcEnergyFH;
808  var_wGwGSF_VFEndcap_[31] = elecVars.hgcalMeasuredDepth;
809  var_wGwGSF_VFEndcap_[32] = elecVars.hgcalExpectedDepth;
810  var_wGwGSF_VFEndcap_[33] = elecVars.hgcalExpectedSigma;
811  var_wGwGSF_VFEndcap_[34] = elecVars.hgcalDepthCompatibility;
812  var_wGwGSF_VFEndcap_[35] = elecVars.deltaEta;
813  var_wGwGSF_VFEndcap_[36] = elecVars.deltaPhi;
814  var_wGwGSF_VFEndcap_[37] = elecVars.eSeedClusterOverPout;
815  var_wGwGSF_VFEndcap_[38] = elecVars.superClusterEtaWidth;
816  var_wGwGSF_VFEndcap_[39] = elecVars.superClusterPhiWidth;
817  mvaValue = mva_wGwGSF_VFEC_->GetClassifier(var_wGwGSF_VFEndcap_.data());
818  }
819  }
820  return mvaValue;
821 }
823 template <class TauType, class ElectronType>
824 double AntiElectronIDMVA6<TauType, ElectronType>::mvaValue(const TauType& theTau, const ElectronRef& theEleRef)
825 
826 {
827  // === tau variables ===
830 
831  // === electron variables ===
833 
834  return mvaValue(tauVars, tauGammaVecs, elecVars);
835 }
836 
837 template <class TauType, class ElectronType>
839  // === tau variables ===
842 
843  // === electron variables ===
844  ElecVars elecVars;
845  elecVars.eta = 9.9; // Dummy value used in MVA training
846 
847  return mvaValue(tauVars, tauGammaVecs, elecVars);
848 }
849 
850 template <class TauType, class ElectronType>
852  TauVars tauVars;
854  tauVars = getTauVarsTypeSpecific(theTau);
855  else
856  throw cms::Exception("AntiElectronIDMVA6")
857  << "Unsupported TauType used. You must use either reco::PFTau or pat::Tau.";
858 
859  tauVars.pt = theTau.pt();
860 
861  reco::Candidate::LorentzVector pfGammaSum(0, 0, 0, 0);
862  reco::Candidate::LorentzVector pfChargedSum(0, 0, 0, 0);
863  float signalrad = std::clamp(3.0 / std::max(1.0, theTau.pt()), 0.05, 0.10);
864  for (const auto& gamma : theTau.signalGammaCands()) {
865  float dR = deltaR(gamma->p4(), theTau.leadChargedHadrCand()->p4());
866  // pfGammas inside the tau signal cone
867  if (dR < signalrad) {
868  pfGammaSum += gamma->p4();
869  }
870  }
871  for (const auto& charged : theTau.signalChargedHadrCands()) {
872  float dR = deltaR(charged->p4(), theTau.leadChargedHadrCand()->p4());
873  // charged particles inside the tau signal cone
874  if (dR < signalrad) {
875  pfChargedSum += charged->p4();
876  }
877  }
878  tauVars.visMassIn = (pfGammaSum + pfChargedSum).mass();
879 
880  tauVars.hasGsf = 0;
881  if (theTau.leadChargedHadrCand().isNonnull()) {
882  const pat::PackedCandidate* packedLeadChCand =
883  dynamic_cast<const pat::PackedCandidate*>(theTau.leadChargedHadrCand().get());
884  if (packedLeadChCand != nullptr) {
885  if (std::abs(packedLeadChCand->pdgId()) == 11)
886  tauVars.hasGsf = 1;
887  } else {
888  const reco::PFCandidate* pfLeadChCand =
889  dynamic_cast<const reco::PFCandidate*>(theTau.leadChargedHadrCand().get());
890  if (pfLeadChCand != nullptr && pfLeadChCand->gsfTrackRef().isNonnull())
891  tauVars.hasGsf = 1;
892  }
893  }
894  tauVars.dCrackPhi = dCrackPhi(tauVars.phi, tauVars.etaAtEcalEntrance);
895  tauVars.dCrackEta = dCrackEta(tauVars.etaAtEcalEntrance);
896 
897  return tauVars;
898 }
899 
900 template <class TauType, class ElectronType>
902  TauGammaVecs tauGammaVecs;
903 
904  float signalrad = std::clamp(3.0 / std::max(1.0, theTau.pt()), 0.05, 0.10);
905  for (const auto& gamma : theTau.signalGammaCands()) {
906  float dR = deltaR(gamma->p4(), theTau.leadChargedHadrCand()->p4());
907  // pfGammas inside the tau signal cone
908  if (dR < signalrad) {
909  tauGammaVecs.gammasdEtaInSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta());
910  tauGammaVecs.gammasdPhiInSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi());
911  tauGammaVecs.gammasPtInSigCone.push_back(gamma->pt());
912  }
913  // pfGammas outside the tau signal cone
914  else {
915  tauGammaVecs.gammasdEtaOutSigCone.push_back(gamma->eta() - theTau.leadChargedHadrCand()->eta());
916  tauGammaVecs.gammasdPhiOutSigCone.push_back(gamma->phi() - theTau.leadChargedHadrCand()->phi());
917  tauGammaVecs.gammasPtOutSigCone.push_back(gamma->pt());
918  }
919  }
920  return tauGammaVecs;
921 }
922 
923 template <class TauType, class ElectronType>
925  ElecVars elecVars;
926 
927  elecVars.eta = theEleRef->eta();
928  elecVars.phi = theEleRef->phi();
929 
930  // Variables related to the electron Cluster
931  float elecEe = 0.;
932  float elecEgamma = 0.;
933  reco::SuperClusterRef pfSuperCluster = theEleRef->superCluster();
934  if (pfSuperCluster.isNonnull() && pfSuperCluster.isAvailable()) {
935  if (!isPhase2_) {
936  for (reco::CaloCluster_iterator pfCluster = pfSuperCluster->clustersBegin();
937  pfCluster != pfSuperCluster->clustersEnd();
938  ++pfCluster) {
939  double pfClusterEn = (*pfCluster)->energy();
940  if (pfCluster == pfSuperCluster->clustersBegin())
941  elecEe += pfClusterEn;
942  else
943  elecEgamma += pfClusterEn;
944  }
945  }
946  elecVars.superClusterEtaWidth = pfSuperCluster->etaWidth();
947  elecVars.superClusterPhiWidth = pfSuperCluster->phiWidth();
948  }
949  elecVars.eSeedClusterOverPout = theEleRef->eSeedClusterOverPout();
950  elecVars.showerCircularity = 1. - theEleRef->e1x5() / theEleRef->e5x5();
951  elecVars.r9 = theEleRef->r9();
952  elecVars.sigmaIEtaIEta5x5 = theEleRef->full5x5_sigmaIetaIeta();
953  elecVars.sigmaIPhiIPhi5x5 = theEleRef->full5x5_sigmaIphiIphi();
954 
955  elecVars.pIn = std::sqrt(theEleRef->trackMomentumAtVtx().Mag2());
956  elecVars.pOut = std::sqrt(theEleRef->trackMomentumOut().Mag2());
957  elecVars.eTotOverPin = (elecVars.pIn > 0.0) ? ((elecEe + elecEgamma) / elecVars.pIn) : -0.1;
958  elecVars.eEcal = theEleRef->ecalEnergy();
959  if (!isPhase2_) {
960  elecVars.deltaEta = theEleRef->deltaEtaSeedClusterTrackAtCalo();
961  elecVars.deltaPhi = theEleRef->deltaPhiSeedClusterTrackAtCalo();
962  } else {
963  elecVars.deltaEta = theEleRef->deltaEtaEleClusterTrackAtCalo();
964  elecVars.deltaPhi = theEleRef->deltaPhiEleClusterTrackAtCalo();
965  }
966  elecVars.mvaInSigmaEtaEta = theEleRef->mvaInput().sigmaEtaEta;
967  elecVars.mvaInHadEnergy = theEleRef->mvaInput().hadEnergy;
968  elecVars.mvaInDeltaEta = theEleRef->mvaInput().deltaEta;
969 
970  // Variables related to the GsfTrack
971  elecVars.chi2NormGSF = -99.;
972  elecVars.gsfNumHits = -99.;
973  elecVars.gsfTrackResol = -99.;
974  elecVars.gsfTracklnPt = -99.;
975  if (theEleRef->gsfTrack().isNonnull()) {
976  elecVars.chi2NormGSF = theEleRef->gsfTrack()->normalizedChi2();
977  elecVars.gsfNumHits = theEleRef->gsfTrack()->numberOfValidHits();
978  if (theEleRef->gsfTrack()->pt() > 0.) {
979  elecVars.gsfTrackResol = theEleRef->gsfTrack()->ptError() / theEleRef->gsfTrack()->pt();
980  elecVars.gsfTracklnPt = log(theEleRef->gsfTrack()->pt()) * M_LN10;
981  }
982  }
983 
984  // Variables related to the CtfTrack
985  elecVars.chi2NormKF = -99.;
986  elecVars.kfNumHits = -99.;
987  if (theEleRef->closestCtfTrackRef().isNonnull()) {
988  elecVars.chi2NormKF = theEleRef->closestCtfTrackRef()->normalizedChi2();
989  elecVars.kfNumHits = theEleRef->closestCtfTrackRef()->numberOfValidHits();
990  }
991 
992  // Variables related to HGCal
993  if (isPhase2_ && !theEleRef->isEB()) {
995  getElecVarsHGCalTypeSpecific(theEleRef, elecVars);
996  else
997  throw cms::Exception("AntiElectronIDMVA6")
998  << "Unsupported ElectronType used. You must use either reco::GsfElectron or pat::Electron.";
999  }
1000 
1001  return elecVars;
1002 }
1003 
1004 template <class TauType, class ElectronType>
1006  if (std::abs(b) < std::abs(a))
1007  return b;
1008  else
1009  return a;
1010 }
1011 
1012 namespace {
1013 
1014  // IN: define locations of the 18 phi-cracks
1015  std::array<double, 18> fill_cPhi() {
1016  constexpr double pi = M_PI; // 3.14159265358979323846;
1017  std::array<double, 18> cPhi;
1018  // IN: define locations of the 18 phi-cracks
1019  cPhi[0] = 2.97025;
1020  for (unsigned iCrack = 1; iCrack <= 17; ++iCrack) {
1021  cPhi[iCrack] = cPhi[0] - 2. * iCrack * pi / 18;
1022  }
1023  return cPhi;
1024  }
1025 
1026  const std::array<double, 18> cPhi = fill_cPhi();
1027 
1028 } // namespace
1029 
1030 template <class TauType, class ElectronType>
1032  //--- compute the (unsigned) distance to the closest phi-crack in the ECAL barrel
1033 
1034  constexpr double pi = M_PI; // 3.14159265358979323846;
1035 
1036  // IN: shift of this location if eta < 0
1037  constexpr double delta_cPhi = 0.00638;
1038 
1039  double retVal = 99.;
1040 
1041  if (eta >= -1.47464 && eta <= 1.47464) {
1042  // the location is shifted
1043  if (eta < 0.)
1044  phi += delta_cPhi;
1045 
1046  // CV: need to bring-back phi into interval [-pi,+pi]
1047  if (phi > pi)
1048  phi -= 2. * pi;
1049  if (phi < -pi)
1050  phi += 2. * pi;
1051 
1052  if (phi >= -pi && phi <= pi) {
1053  // the problem of the extrema:
1054  if (phi < cPhi[17] || phi >= cPhi[0]) {
1055  if (phi < 0.)
1056  phi += 2. * pi;
1057  retVal = minimum(phi - cPhi[0], phi - cPhi[17] - 2. * pi);
1058  } else {
1059  // between these extrema...
1060  bool OK = false;
1061  unsigned iCrack = 16;
1062  while (!OK) {
1063  if (phi < cPhi[iCrack]) {
1064  retVal = minimum(phi - cPhi[iCrack + 1], phi - cPhi[iCrack]);
1065  OK = true;
1066  } else {
1067  iCrack -= 1;
1068  }
1069  }
1070  }
1071  } else {
1072  retVal = 0.; // IN: if there is a problem, we assume that we are in a crack
1073  }
1074  } else {
1075  return -99.;
1076  }
1077 
1078  return std::abs(retVal);
1079 }
1080 
1081 template <class TauType, class ElectronType>
1083  //--- compute the (unsigned) distance to the closest eta-crack in the ECAL barrel
1084 
1085  // IN: define locations of the eta-cracks
1086  double cracks[5] = {0., 4.44747e-01, 7.92824e-01, 1.14090e+00, 1.47464e+00};
1087 
1088  double retVal = 99.;
1089 
1090  for (int iCrack = 0; iCrack < 5; ++iCrack) {
1091  double d = minimum(eta - cracks[iCrack], eta + cracks[iCrack]);
1092  if (std::abs(d) < std::abs(retVal)) {
1093  retVal = d;
1094  }
1095  }
1096 
1097  return std::abs(retVal);
1098 }
1099 
1100 // pat::Tau
1101 template <class TauType, class ElectronType>
1103  TauVars tauVars;
1104  tauVars.etaAtEcalEntrance = theTau.etaAtEcalEntrance();
1106  tauVars.leadChargedPFCandPt = theTau.ptLeadChargedCand();
1107  tauVars.phi = theTau.phi();
1108  if (!isPhase2_) {
1109  if (!usePhiAtEcalEntranceExtrapolation_) {
1110  tauVars.phi = theTau.phiAtEcalEntrance();
1111  } else {
1112  float etaAtECal = 0.;
1113  float phiAtECal = 0.;
1114  bool success = energyWeightedEtaAndPhiAtECal(theTau, etaAtECal, phiAtECal);
1115  if (success) {
1116  tauVars.phi = phiAtECal;
1117  }
1118  }
1119  tauVars.emFraction = std::max(theTau.emFraction_MVA(), 0.f);
1120  } else {
1121  if (std::abs(theTau.eta()) >= ecalBarrelEndcapEtaBorder_) { //HGCal
1122  tauVars.etaAtEcalEntrance = -99.;
1123  tauVars.leadChargedPFCandEtaAtEcalEntrance = -99.;
1124  bool success = false;
1125  reco::Candidate::Point posAtECal = positionAtECalEntrance_(theTau.leadChargedHadrCand().get(), success);
1126  if (success) {
1127  tauVars.leadChargedPFCandEtaAtEcalEntrance = posAtECal.eta();
1128  }
1129  float phiAtECal = 0.;
1130  float etaAtECal = 0.;
1131  success = energyWeightedEtaAndPhiAtECal(theTau, etaAtECal, phiAtECal);
1132  if (success) {
1133  tauVars.etaAtEcalEntrance = etaAtECal;
1134  }
1135  }
1138  0.f);
1139  }
1140  tauVars.leadPFChargedHadrHoP = 0.;
1141  tauVars.leadPFChargedHadrEoP = 0.;
1142  if (theTau.leadChargedHadrCand()->p() > 0.) {
1143  tauVars.leadPFChargedHadrHoP = theTau.hcalEnergyLeadChargedHadrCand() / theTau.leadChargedHadrCand()->p();
1144  tauVars.leadPFChargedHadrEoP = theTau.ecalEnergyLeadChargedHadrCand() / theTau.leadChargedHadrCand()->p();
1145  }
1146 
1147  return tauVars;
1148 }
1149 
1150 // reco::PFTau
1151 template <class TauType, class ElectronType>
1153  TauVars tauVars;
1154  tauVars.etaAtEcalEntrance = -99.;
1155  tauVars.leadChargedPFCandEtaAtEcalEntrance = -99.;
1156  tauVars.leadChargedPFCandPt = -99.;
1157  float sumEtaTimesEnergy = 0.;
1158  float sumPhiTimesEnergy = 0.;
1159  float sumEnergy = 0.;
1160  tauVars.phi = theTau.phi();
1161  // Check type of candidates building tau to avoid dynamic casts further
1162  bool isFromPFCands =
1163  (theTau.leadCand().isNonnull() && dynamic_cast<const reco::PFCandidate*>(theTau.leadCand().get()) != nullptr);
1164  if (!isPhase2_) {
1165  for (const auto& candidate : theTau.signalCands()) {
1166  float etaAtECalEntrance = candidate->eta();
1167  float phiAtECalEntrance = candidate->phi();
1168  const reco::Track* track = nullptr;
1169  if (isFromPFCands) {
1170  const reco::PFCandidate* pfCandidate = static_cast<const reco::PFCandidate*>(candidate.get());
1171  etaAtECalEntrance = pfCandidate->positionAtECALEntrance().eta();
1172  if (!usePhiAtEcalEntranceExtrapolation_) {
1173  phiAtECalEntrance = pfCandidate->positionAtECALEntrance().phi();
1174  } else {
1175  bool success = false;
1176  reco::Candidate::Point posAtECal = positionAtECalEntrance_(candidate.get(), success);
1177  if (success) {
1178  phiAtECalEntrance = posAtECal.phi();
1179  }
1180  }
1181  track = getTrackFromPFCand(pfCandidate);
1182  } else {
1183  bool success = false;
1184  reco::Candidate::Point posAtECal = positionAtECalEntrance_(candidate.get(), success);
1185  if (success) {
1186  etaAtECalEntrance = posAtECal.eta();
1187  phiAtECalEntrance = posAtECal.phi();
1188  }
1189  track = candidate->bestTrack();
1190  }
1191  if (track != nullptr) {
1192  if (track->pt() > tauVars.leadChargedPFCandPt) {
1193  tauVars.leadChargedPFCandEtaAtEcalEntrance = etaAtECalEntrance;
1194  tauVars.leadChargedPFCandPt = track->pt();
1195  }
1196  }
1197  sumEtaTimesEnergy += etaAtECalEntrance * candidate->energy();
1198  sumPhiTimesEnergy += phiAtECalEntrance * candidate->energy();
1199  sumEnergy += candidate->energy();
1200  }
1201  if (sumEnergy > 0.) {
1202  tauVars.etaAtEcalEntrance = sumEtaTimesEnergy / sumEnergy;
1203  tauVars.phi = sumPhiTimesEnergy / sumEnergy;
1204  }
1205  tauVars.emFraction = std::max(theTau.emFraction(), 0.f);
1206  } else { // Phase2
1207  for (const auto& candidate : theTau.signalCands()) {
1208  float etaAtECalEntrance = candidate->eta();
1209  const reco::Track* track = nullptr;
1210  if (isFromPFCands) {
1211  const reco::PFCandidate* pfCandidate = static_cast<const reco::PFCandidate*>(candidate.get());
1212  etaAtECalEntrance = pfCandidate->positionAtECALEntrance().eta();
1213  if (std::abs(theTau.eta()) >= ecalBarrelEndcapEtaBorder_) { //HGCal
1214  bool success = false;
1215  reco::Candidate::Point posAtECal = positionAtECalEntrance_(candidate.get(), success);
1216  if (success) {
1217  etaAtECalEntrance = posAtECal.eta();
1218  }
1219  }
1220  track = getTrackFromPFCand(pfCandidate);
1221  } else {
1222  bool success = false;
1223  reco::Candidate::Point posAtECal = positionAtECalEntrance_(candidate.get(), success);
1224  if (success) {
1225  etaAtECalEntrance = posAtECal.eta();
1226  }
1227  track = candidate->bestTrack();
1228  }
1229  if (track != nullptr) {
1230  if (track->pt() > tauVars.leadChargedPFCandPt) {
1231  tauVars.leadChargedPFCandEtaAtEcalEntrance = etaAtECalEntrance;
1232  tauVars.leadChargedPFCandPt = track->pt();
1233  }
1234  }
1235  sumEtaTimesEnergy += etaAtECalEntrance * candidate->energy();
1236  sumEnergy += candidate->energy();
1237  }
1238  if (sumEnergy > 0.) {
1239  tauVars.etaAtEcalEntrance = sumEtaTimesEnergy / sumEnergy;
1240  }
1241  if (isFromPFCands) {
1242  const reco::PFCandidate* pfLeadCandidte =
1243  static_cast<const reco::PFCandidate*>(theTau.leadChargedHadrCand().get());
1244  tauVars.emFraction =
1245  std::max(pfLeadCandidte->ecalEnergy() / (pfLeadCandidte->ecalEnergy() + pfLeadCandidte->hcalEnergy()), 0.);
1246  } else {
1247  const pat::PackedCandidate* patLeadCandiate =
1248  dynamic_cast<const pat::PackedCandidate*>(theTau.leadChargedHadrCand().get());
1249  if (patLeadCandiate != nullptr) {
1250  tauVars.emFraction = std::max(1. - patLeadCandiate->hcalFraction(), 0.);
1251  }
1252  }
1253  }
1254  tauVars.leadPFChargedHadrHoP = 0.;
1255  tauVars.leadPFChargedHadrEoP = 0.;
1256  if (theTau.leadChargedHadrCand()->p() > 0.) {
1257  if (isFromPFCands) {
1258  const reco::PFCandidate* pfLeadCandiate =
1259  static_cast<const reco::PFCandidate*>(theTau.leadChargedHadrCand().get());
1260  tauVars.leadPFChargedHadrHoP = pfLeadCandiate->hcalEnergy() / pfLeadCandiate->p();
1261  tauVars.leadPFChargedHadrEoP = pfLeadCandiate->ecalEnergy() / pfLeadCandiate->p();
1262  } else {
1263  const pat::PackedCandidate* patLeadCandiate =
1264  dynamic_cast<const pat::PackedCandidate*>(theTau.leadChargedHadrCand().get());
1265  if (patLeadCandiate != nullptr) {
1266  tauVars.leadPFChargedHadrHoP = patLeadCandiate->caloFraction() * patLeadCandiate->energy() *
1267  patLeadCandiate->hcalFraction() / patLeadCandiate->p();
1268  tauVars.leadPFChargedHadrEoP = patLeadCandiate->caloFraction() * patLeadCandiate->energy() *
1269  (1. - patLeadCandiate->hcalFraction()) / patLeadCandiate->p();
1270  }
1271  }
1272  }
1273 
1274  return tauVars;
1275 }
1276 
1277 // reco::GsfElectron
1278 template <class TauType, class ElectronType>
1280  const reco::GsfElectronRef& theEleRef, antiElecIDMVA6_blocks::ElecVars& elecVars) {
1281  //MB: Assumed that presence of one of the HGCal EleID variables guarantee presence of all
1282  if (!(electronIds_.find("hgcElectronID:sigmaUU") != electronIds_.end() &&
1283  electronIds_.at("hgcElectronID:sigmaUU").isValid()))
1284  return;
1285 
1286  elecVars.hgcalSigmaUU = (*electronIds_.at("hgcElectronID:sigmaUU"))[theEleRef];
1287  elecVars.hgcalSigmaVV = (*electronIds_.at("hgcElectronID:sigmaVV"))[theEleRef];
1288  elecVars.hgcalSigmaEE = (*electronIds_.at("hgcElectronID:sigmaEE"))[theEleRef];
1289  elecVars.hgcalSigmaPP = (*electronIds_.at("hgcElectronID:sigmaPP"))[theEleRef];
1290  elecVars.hgcalNLayers = (*electronIds_.at("hgcElectronID:nLayers"))[theEleRef];
1291  elecVars.hgcalFirstLayer = (*electronIds_.at("hgcElectronID:firstLayer"))[theEleRef];
1292  elecVars.hgcalLastLayer = (*electronIds_.at("hgcElectronID:lastLayer"))[theEleRef];
1293  elecVars.hgcalLayerEfrac10 = (*electronIds_.at("hgcElectronID:layerEfrac10"))[theEleRef];
1294  elecVars.hgcalLayerEfrac90 = (*electronIds_.at("hgcElectronID:layerEfrac90"))[theEleRef];
1295  elecVars.hgcalEcEnergyEE = (*electronIds_.at("hgcElectronID:ecEnergyEE"))[theEleRef];
1296  elecVars.hgcalEcEnergyFH = (*electronIds_.at("hgcElectronID:ecEnergyFH"))[theEleRef];
1297  elecVars.hgcalMeasuredDepth = (*electronIds_.at("hgcElectronID:measuredDepth"))[theEleRef];
1298  elecVars.hgcalExpectedDepth = (*electronIds_.at("hgcElectronID:expectedDepth"))[theEleRef];
1299  elecVars.hgcalExpectedSigma = (*electronIds_.at("hgcElectronID:expectedSigma"))[theEleRef];
1300  elecVars.hgcalDepthCompatibility = (*electronIds_.at("hgcElectronID:depthCompatibility"))[theEleRef];
1301 }
1302 
1303 // pat::Electron
1304 template <class TauType, class ElectronType>
1306  const pat::ElectronRef& theEleRef, antiElecIDMVA6_blocks::ElecVars& elecVars) {
1307  //MB: Assumed that presence of one of the HGCal EleID variables guarantee presence of all
1308  if (!theEleRef->hasUserFloat("hgcElectronID:sigmaUU"))
1309  return;
1310 
1311  elecVars.hgcalSigmaUU = theEleRef->userFloat("hgcElectronID:sigmaUU");
1312  elecVars.hgcalSigmaVV = theEleRef->userFloat("hgcElectronID:sigmaVV");
1313  elecVars.hgcalSigmaEE = theEleRef->userFloat("hgcElectronID:sigmaEE");
1314  elecVars.hgcalSigmaPP = theEleRef->userFloat("hgcElectronID:sigmaPP");
1315  elecVars.hgcalNLayers = theEleRef->userFloat("hgcElectronID:nLayers");
1316  elecVars.hgcalFirstLayer = theEleRef->userFloat("hgcElectronID:firstLayer");
1317  elecVars.hgcalLastLayer = theEleRef->userFloat("hgcElectronID:lastLayer");
1318  elecVars.hgcalLayerEfrac10 = theEleRef->userFloat("hgcElectronID:layerEfrac10");
1319  elecVars.hgcalLayerEfrac90 = theEleRef->userFloat("hgcElectronID:layerEfrac90");
1320  elecVars.hgcalEcEnergyEE = theEleRef->userFloat("hgcElectronID:ecEnergyEE");
1321  elecVars.hgcalEcEnergyFH = theEleRef->userFloat("hgcElectronID:ecEnergyFH");
1322  elecVars.hgcalMeasuredDepth = theEleRef->userFloat("hgcElectronID:measuredDepth");
1323  elecVars.hgcalExpectedDepth = theEleRef->userFloat("hgcElectronID:expectedDepth");
1324  elecVars.hgcalExpectedSigma = theEleRef->userFloat("hgcElectronID:expectedSigma");
1325  elecVars.hgcalDepthCompatibility = theEleRef->userFloat("hgcElectronID:depthCompatibility");
1326 }
1327 
1328 template <class TauType, class ElectronType>
1330  float& eta,
1331  float& phi) {
1332  eta = 0.;
1333  phi = 0.;
1334  float sumEnergy = 0.;
1335  for (const auto& candidate : theTau.signalCands()) {
1336  float etaAtECalEntrance = candidate->eta();
1337  float phiAtECalEntrance = candidate->phi();
1338  bool success = false;
1339  reco::Candidate::Point posAtECal = positionAtECalEntrance_(candidate.get(), success);
1340  if (success) {
1341  etaAtECalEntrance = posAtECal.eta();
1342  phiAtECalEntrance = posAtECal.phi();
1343  }
1344  eta += etaAtECalEntrance * candidate->energy();
1345  phi += phiAtECalEntrance * candidate->energy();
1346  sumEnergy += candidate->energy();
1347  }
1348  if (sumEnergy > 0.) {
1349  eta = eta / sumEnergy;
1350  phi = phi / sumEnergy;
1351  } else {
1352  eta = -99.;
1353  phi = -99.;
1354  }
1355  return (sumEnergy > 0.);
1356 }
1357 
1358 // compile desired types and make available to linker
std::vector< float > var_NoEleMatch_wGwoGSF_Barrel_
bool isAvailable() const
Definition: Ref.h:537
double ecalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:221
double minimum(double a, double b)
std::string mvaName_wGwGSF_BL_
std::vector< float > var_wGwGSF_Endcap_
std::vector< float > var_wGwGSF_VFEndcap_
static std::vector< std::string > checklist log
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
antiElecIDMVA6_blocks::TauVars getTauVars(const TauType &theTau)
tuple cfg
Definition: looper.py:296
float hcalEnergyLeadChargedHadrCand() const
return hcal energy from LeadChargedHadrCand
Definition: Tau.h:308
float hcalFraction() const
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_NoEleMatch_wGwoGSF_EC_
antiElecIDMVA6_blocks::TauVars getTauVarsTypeSpecific(const reco::PFTau &theTau)
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::string mvaName_NoEleMatch_woGwoGSF_VFEC_
float emFraction() const
Definition: PFTau.cc:340
reco::CandidatePtrVector signalCands() const
int pdgId() const override
PDG identifier.
const math::XYZPointF & positionAtECALEntrance() const
Definition: PFCandidate.h:388
std::vector< float > var_NoEleMatch_woGwoGSF_Endcap_
const Double_t pi
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:430
bool getData(T &iHolder) const
Definition: EventSetup.h:128
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_NoEleMatch_wGwoGSF_VFEC_
double p() const override
magnitude of momentum vector
tuple d
Definition: ztail.py:151
std::string mvaName_NoEleMatch_wGwoGSF_BL_
Handle< PROD > getHandle(EDGetTokenT< PROD > token) const
Definition: Event.h:563
void getElecVarsHGCalTypeSpecific(const reco::GsfElectronRef &theEleRef, antiElecIDMVA6_blocks::ElecVars &elecVars)
double p() const final
magnitude of momentum vector
std::string mvaName_NoEleMatch_wGwoGSF_EC_
const CandidatePtr & leadChargedHadrCand() const
Definition: PFTau.cc:63
T sqrt(T t)
Definition: SSEVec.h:19
double pt() const
track transverse momentum
Definition: TrackBase.h:637
std::vector< float > var_wGwGSF_Barrel_
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_wGwGSF_BL_
std::string mvaName_wGwGSF_VFEC_
float ecalEnergyLeadChargedHadrCand() const
Definition: Tau.h:306
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_NoEleMatch_woGwoGSF_BL_
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_woGwGSF_BL_
std::string mvaName_NoEleMatch_wGwoGSF_VFEC_
std::vector< float > var_woGwGSF_Endcap_
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_wGwGSF_EC_
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
T min(T a, T b)
Definition: MathUtil.h:58
float phiAtEcalEntrance() const
return phiAtEcalEntrance
Definition: Tau.h:310
const reco::CandidatePtr leadChargedHadrCand() const
float caloFraction() const
Set the fraction of ECAL+HCAL energy over candidate energy.
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_woGwGSF_VFEC_
std::vector< float > var_NoEleMatch_woGwoGSF_Barrel_
Analysis-level tau class.
Definition: Tau.h:53
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_NoEleMatch_wGwoGSF_BL_
reco::MuonRef muonRef() const
Definition: PFCandidate.cc:443
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
#define M_PI
double mvaValue(const antiElecIDMVA6_blocks::TauVars &tauVars, const antiElecIDMVA6_blocks::TauGammaVecs &tauGammaVecs, const antiElecIDMVA6_blocks::ElecVars &elecVars)
antiElecIDMVA6_blocks::TauGammaVecs getTauGammaVecs(const TauType &theTau)
float ptLeadChargedCand() const
return pt from LeadChargedCand
Definition: Tau.h:316
std::map< std::string, edm::EDGetTokenT< edm::ValueMap< float > > > electronIds_tokens_
std::pair< int, edm::FunctionWithDict > OK
Definition: findMethod.cc:126
bool energyWeightedEtaAndPhiAtECal(const pat::Tau &theTau, float &eta, float &phi)
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_woGwGSF_EC_
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_NoEleMatch_woGwoGSF_EC_
std::string mvaName_woGwGSF_VFEC_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
double b
Definition: hdecay.h:118
const CandidatePtr & leadCand() const
Definition: PFTau.cc:65
std::vector< float > var_NoEleMatch_wGwoGSF_VFEndcap_
double dCrackEta(double eta)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
float emFraction_MVA() const
return emFraction_MVA
Definition: Tau.h:318
antiElecIDMVA6_blocks::ElecVars getElecVars(const ElectronRef &theEleRef)
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_wGwGSF_VFEC_
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
std::vector< float > var_NoEleMatch_wGwoGSF_Endcap_
double mvaValuePhase2(const antiElecIDMVA6_blocks::TauVars &tauVars, const antiElecIDMVA6_blocks::TauGammaMoms &tauGammaMoms, const antiElecIDMVA6_blocks::ElecVars &elecVars)
edm::FileInPath inputFileName_
double a
Definition: hdecay.h:119
double energy() const override
energy
reco::GsfTrackRef gsfTrackRef() const
Definition: PFCandidate.cc:462
double hcalEnergy() const
return corrected Hcal energy
Definition: PFCandidate.h:233
std::string mvaName_wGwGSF_EC_
math::XYZPoint Point
point in the space
Definition: Candidate.h:40
std::map< std::string, edm::Handle< edm::ValueMap< float > > > electronIds_
std::string mvaName_NoEleMatch_woGwoGSF_EC_
float etaAtEcalEntrance() const
return etaAtEcalEntrance
Definition: Tau.h:312
float etaAtEcalEntranceLeadChargedCand() const
return etaAtEcalEntrance from LeadChargedCand
Definition: Tau.h:314
const std::vector< reco::CandidatePtr > & signalCands() const
Candidates in signal region.
Definition: PFTau.cc:74
std::vector< float > var_woGwGSF_Barrel_
std::string mvaName_woGwGSF_EC_
std::string mvaName_woGwGSF_BL_
double phi() const final
momentum azimuthal angle
edm::ESGetToken< GBRForest, GBRWrapperRcd > mvaToken_NoEleMatch_woGwoGSF_VFEC_
AntiElectronIDMVA6(const edm::ParameterSet &, edm::ConsumesCollector &&)
void beginEvent(const edm::Event &, const edm::EventSetup &)
double dCrackPhi(double phi, double eta)
std::vector< float > var_NoEleMatch_woGwoGSF_VFEndcap_
std::vector< float > var_woGwGSF_VFEndcap_
double eta() const final
momentum pseudorapidity
std::string mvaName_NoEleMatch_woGwoGSF_BL_