6 typedef const std::vector<reco::CandidatePtr>& Ret_t;
14 typename T::Ret_t getGammas_T(
const typename T::Tau_t&
tau,
bool signal) {
15 return typename T::Ret_t();
19 const std::vector<reco::CandidatePtr>& getGammas_T<PFTau_traits>(
const reco::PFTau&
tau,
bool signal) {
21 return tau.signalGammaCands();
23 return tau.isolationGammaCands();
29 return tau.signalGammaCands();
31 return tau.isolationGammaCands();
35 bool isInside(
float photon_pt,
float deta,
float dphi) {
36 constexpr
double stripEtaAssociationDistance_0p95_p0 = 0.197077;
37 constexpr
double stripEtaAssociationDistance_0p95_p1 = 0.658701;
38 constexpr
double stripPhiAssociationDistance_0p95_p0 = 0.352476;
39 constexpr
double stripPhiAssociationDistance_0p95_p1 = 0.707716;
43 if ((dphi < 0.3 && dphi <
std::max(0.05,
44 stripPhiAssociationDistance_0p95_p0 *
45 std::pow(photon_pt, -stripPhiAssociationDistance_0p95_p1))) &&
46 (deta < 0.15 && deta <
std::max(0.05,
47 stripEtaAssociationDistance_0p95_p0 *
48 std::pow(photon_pt, -stripEtaAssociationDistance_0p95_p1)))) {
59 float LeadingTracknormalizedChi2 = 0;
66 LeadingTracknormalizedChi2 = tref->normalizedChi2();
75 return LeadingTracknormalizedChi2;
79 float ecal_en_in_signal_pf_cands = 0;
80 float hcal_en_in_signal_pf_cands = 0;
81 for (
const auto& signal_cand :
tau.signalCands()) {
82 const reco::PFCandidate* signal_pfcand = dynamic_cast<const reco::PFCandidate*>(signal_cand.get());
83 if (signal_pfcand !=
nullptr) {
84 ecal_en_in_signal_pf_cands += signal_pfcand->
ecalEnergy();
85 hcal_en_in_signal_pf_cands += signal_pfcand->
hcalEnergy();
88 const pat::PackedCandidate* signal_pcand = dynamic_cast<const pat::PackedCandidate*>(signal_cand.get());
91 ecal_en_in_signal_pf_cands += calo_en * (1. - signal_pcand->
hcalFraction());
92 hcal_en_in_signal_pf_cands += calo_en * signal_pcand->
hcalFraction();
95 float total = ecal_en_in_signal_pf_cands + hcal_en_in_signal_pf_cands;
99 return ecal_en_in_signal_pf_cands /
total;
102 float ecal_en_in_signal_cands =
tau.ecalEnergy();
103 float hcal_en_in_signal_cands =
tau.hcalEnergy();
104 float total = ecal_en_in_signal_cands + hcal_en_in_signal_cands;
108 return ecal_en_in_signal_cands /
total;
112 template <
typename T>
115 float sum_dx_pt = 0.;
121 if (
cand->pt() < 0.5) {
128 bool flag = isInside(
pt, deta, dphi);
130 if (
mode == 2 || (
mode == 0 &&
dr < signalrad) || (
mode == 1 &&
dr > signalrad)) {
133 sum_dx_pt +=
pt *
dr;
135 sum_dx_pt +=
pt * deta;
137 sum_dx_pt +=
pt * dphi;
139 }
else if (is3prong == 1) {
143 sum_dx_pt +=
pt *
dr;
145 sum_dx_pt +=
pt * deta;
147 sum_dx_pt +=
pt * dphi;
152 return sum_dx_pt / sum_pt;
164 unsigned int n_photons = 0;
165 for (
auto&
cand :
tau.signalGammaCands()) {
166 if (
cand->pt() > 0.5)
169 for (
auto&
cand :
tau.isolationGammaCands()) {
170 if (
cand->pt() > 0.5)
176 unsigned int n_photons = 0;
177 for (
auto&
cand :
tau.signalGammaCands()) {
178 if (
cand->pt() > 0.5)
181 for (
auto&
cand :
tau.isolationGammaCands()) {
182 if (
cand->pt() > 0.5)
196 int tauDecayMode =
tau.decayMode();
197 const float mTau = 1.77682;
201 (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10)) ||
204 (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 ||
205 tauDecayMode == 10 || tauDecayMode == 11))) {
206 float chargedIsoPtSum =
tau.tauID(nameCharged);
207 float neutralIsoPtSum =
tau.tauID(nameNeutral);
208 float puCorrPtSum =
tau.tauID(namePu);
209 float photonPtSumOutsideSignalCone =
tau.tauID(nameOutside);
210 float footprintCorrection =
tau.tauID(nameFootprint);
212 float decayDistX =
tau.flightLength().x();
213 float decayDistY =
tau.flightLength().y();
214 float decayDistZ =
tau.flightLength().z();
215 float decayDistMag =
std::sqrt(decayDistX * decayDistX + decayDistY * decayDistY + decayDistZ * decayDistZ);
225 float leadingTrackChi2 =
tau.leadingTrackNormChi2();
229 float gjAngleDiff = -999;
230 if (tauDecayMode == 10) {
231 double mAOne =
tau.p4().M();
232 double pAOneMag =
tau.p();
233 double argumentThetaGJmax = (
std::pow(mTau, 2) -
std::pow(mAOne, 2)) / (2 * mTau * pAOneMag);
234 double argumentThetaGJmeasured =
235 (
tau.p4().px() * decayDistX +
tau.p4().py() * decayDistY +
tau.p4().pz() * decayDistZ) /
236 (pAOneMag * decayDistMag);
237 if (
std::abs(argumentThetaGJmax) <= 1. &&
std::abs(argumentThetaGJmeasured) <= 1.) {
238 double thetaGJmax = std::asin(argumentThetaGJmax);
239 double thetaGJmeasured = std::acos(argumentThetaGJmeasured);
240 gjAngleDiff = thetaGJmeasured - thetaGJmax;
245 mvaInput[0] =
tau.pt();
247 mvaInput[2] = chargedIsoPtSum;
248 mvaInput[3] = neutralIsoPtSum;
249 mvaInput[4] = puCorrPtSum;
250 mvaInput[5] = photonPtSumOutsideSignalCone;
251 mvaInput[6] = tauDecayMode;
252 mvaInput[7] =
tau.signalGammaCands().size();
253 mvaInput[8] =
tau.isolationGammaCands().size();
255 float sigCands_pt = 0.;
256 float sigCands_dr, sigCands_deta, sigCands_dphi;
257 sigCands_dr = sigCands_deta = sigCands_dphi = 0.;
258 for (
const auto&
j :
tau.signalGammaCands()) {
262 const float pt_ =
j->pt();
263 sigCands_dr +=
dr * pt_;
264 sigCands_deta += deta * pt_;
265 sigCands_dphi += dphi * pt_;
268 if (sigCands_pt > 0.) {
269 sigCands_dr = sigCands_dr / sigCands_pt;
270 sigCands_deta = sigCands_deta / sigCands_pt;
271 sigCands_dphi = sigCands_dphi / sigCands_pt;
273 sigCands_dr = sigCands_deta = sigCands_dphi = -0.1;
275 float isoCands_pt = 0.;
276 float isoCands_dr, isoCands_deta, isoCands_dphi;
277 isoCands_dr = isoCands_deta = isoCands_dphi = 0.;
278 for (
const auto&
j :
tau.isolationGammaCands()) {
282 const float pt_ =
j->pt();
283 isoCands_dr +=
dr * pt_;
284 isoCands_deta += deta * pt_;
285 isoCands_dphi += dphi * pt_;
288 if (isoCands_pt > 0.) {
289 isoCands_dr = isoCands_dr / isoCands_pt;
290 isoCands_deta = isoCands_deta / isoCands_pt;
291 isoCands_dphi = isoCands_dphi / isoCands_pt;
293 isoCands_dr = isoCands_deta = isoCands_dphi = -0.1;
295 mvaInput[9] = isoCands_deta;
296 mvaInput[10] = isoCands_dphi;
297 mvaInput[11] = isoCands_dr;
298 mvaInput[12] = sigCands_deta;
299 mvaInput[13] = sigCands_dphi;
300 mvaInput[14] = sigCands_dr;
302 float e =
tau.hcalEnergy() +
tau.ecalEnergy();
303 e > 0. ?
e =
tau.ecalEnergy() /
e :
e = -1.;
305 mvaInput[16] =
tau.dxy() >= 0. ? +1 : -1;
308 mvaInput[19] =
tau.ip3d() >= 0. ? +1 : -1;
311 mvaInput[22] = (
tau.hasSecondaryVertex()) ? 1. : 0.;
312 mvaInput[23] = decayDistMag;
313 mvaInput[24] =
tau.flightLengthSig();
314 mvaInput[25] = leadingTrackChi2;
316 float thetaGJmax, thetaGJ;
317 if (decayDistMag > 0. &&
tau.hasSecondaryVertex()) {
318 const float mAOne =
tau.p4().M();
319 const float pAOneMag =
tau.p();
320 thetaGJmax = (mTau * mTau - mAOne * mAOne) / (2. * mTau * pAOneMag);
321 thetaGJmax = asin(thetaGJmax);
322 thetaGJ = (
tau.px() *
tau.flightLength().x() +
tau.py() *
tau.flightLength().y() +
323 tau.pz() *
tau.flightLength().z()) /
324 (pAOneMag * decayDistMag);
325 thetaGJ = acos(thetaGJ);
334 mvaInput[26] = thetaGJ - thetaGJmax;
339 if (
tau.leadChargedHadrCand().isNonnull()) {
340 if (
tau.leadChargedHadrCand()->bestTrack()) {
341 const float trackdxy =
tau.leadChargedHadrCand()->bestTrack()->dxy();
342 const float trackdxy_err =
tau.leadChargedHadrCand()->bestTrack()->dxyError();
343 mvaInput[27] = trackdxy >= 0. ? +1 : -1;
345 mvaInput[29] =
std::abs(trackdxy / trackdxy_err);
355 mvaInput[5] = tauDecayMode;
362 mvaInput[5] = tauDecayMode;
363 mvaInput[6] = std::copysign(+1.
f,
tau.dxy());
366 mvaInput[9] = (
tau.hasSecondaryVertex()) ? 1. : 0.;
376 mvaInput[6] = tauDecayMode;
378 mvaInput[8] =
std::min(0.5
f, ptWeightedDetaStrip);
379 mvaInput[9] =
std::min(0.5
f, ptWeightedDphiStrip);
380 mvaInput[10] =
std::min(0.5
f, ptWeightedDrSignal);
381 mvaInput[11] =
std::min(0.5
f, ptWeightedDrIsolation);
382 mvaInput[12] =
std::min(100.
f, leadingTrackChi2);
384 mvaInput[14] = std::copysign(+1.
f,
tau.dxy());
387 mvaInput[17] = std::copysign(+1.
f,
tau.ip3d());
390 mvaInput[20] = (
tau.hasSecondaryVertex()) ? 1. : 0.;
400 mvaInput[6] = tauDecayMode;
402 mvaInput[8] =
std::min(0.5
f, ptWeightedDetaStrip);
403 mvaInput[9] =
std::min(0.5
f, ptWeightedDphiStrip);
404 mvaInput[10] =
std::min(0.5
f, ptWeightedDrSignal);
405 mvaInput[11] =
std::min(0.5
f, ptWeightedDrIsolation);
406 mvaInput[12] =
std::min(100.
f, leadingTrackChi2);
408 mvaInput[14] = std::copysign(+1.
f,
tau.dxy());
411 mvaInput[17] = std::copysign(+1.
f,
tau.ip3d());
414 mvaInput[20] = (
tau.hasSecondaryVertex()) ? 1. : 0.;
424 mvaInput[6] = tauDecayMode;
426 mvaInput[8] =
std::min(0.5
f, ptWeightedDetaStrip);
427 mvaInput[9] =
std::min(0.5
f, ptWeightedDphiStrip);
428 mvaInput[10] =
std::min(0.5
f, ptWeightedDrSignal);
429 mvaInput[11] =
std::min(0.5
f, ptWeightedDrIsolation);
431 mvaInput[13] = std::copysign(+1.
f,
tau.dxy());
434 mvaInput[16] = std::copysign(+1.
f,
tau.ip3d());
437 mvaInput[19] = (
tau.hasSecondaryVertex()) ? 1. : 0.;
440 mvaInput[22] =
std::max(-1.
f, gjAngleDiff);