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();
89 float total = ecal_en_in_signal_pf_cands + hcal_en_in_signal_pf_cands;
93 return ecal_en_in_signal_pf_cands /
total;
96 float ecal_en_in_signal_cands =
tau.ecalEnergy();
97 float hcal_en_in_signal_cands =
tau.hcalEnergy();
98 float total = ecal_en_in_signal_cands + hcal_en_in_signal_cands;
102 return ecal_en_in_signal_cands /
total;
106 template <
typename T>
109 float sum_dx_pt = 0.;
115 if (
cand->pt() < 0.5) {
122 bool flag = isInside(
pt, deta, dphi);
124 if (
mode == 2 || (
mode == 0 &&
dr < signalrad) || (
mode == 1 &&
dr > signalrad)) {
127 sum_dx_pt +=
pt *
dr;
129 sum_dx_pt +=
pt * deta;
131 sum_dx_pt +=
pt * dphi;
133 }
else if (is3prong == 1) {
137 sum_dx_pt +=
pt *
dr;
139 sum_dx_pt +=
pt * deta;
141 sum_dx_pt +=
pt * dphi;
146 return sum_dx_pt / sum_pt;
158 unsigned int n_photons = 0;
159 for (
auto&
cand :
tau.signalGammaCands()) {
160 if (
cand->pt() > 0.5)
163 for (
auto&
cand :
tau.isolationGammaCands()) {
164 if (
cand->pt() > 0.5)
170 unsigned int n_photons = 0;
171 for (
auto&
cand :
tau.signalGammaCands()) {
172 if (
cand->pt() > 0.5)
175 for (
auto&
cand :
tau.isolationGammaCands()) {
176 if (
cand->pt() > 0.5)
190 int tauDecayMode =
tau.decayMode();
191 const float mTau = 1.77682;
195 (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10)) ||
198 (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 ||
199 tauDecayMode == 10 || tauDecayMode == 11))) {
200 float chargedIsoPtSum =
tau.tauID(nameCharged);
201 float neutralIsoPtSum =
tau.tauID(nameNeutral);
202 float puCorrPtSum =
tau.tauID(namePu);
203 float photonPtSumOutsideSignalCone =
tau.tauID(nameOutside);
204 float footprintCorrection =
tau.tauID(nameFootprint);
206 float decayDistX =
tau.flightLength().x();
207 float decayDistY =
tau.flightLength().y();
208 float decayDistZ =
tau.flightLength().z();
209 float decayDistMag =
std::sqrt(decayDistX * decayDistX + decayDistY * decayDistY + decayDistZ * decayDistZ);
219 float leadingTrackChi2 =
tau.leadingTrackNormChi2();
223 float gjAngleDiff = -999;
224 if (tauDecayMode == 10) {
225 double mAOne =
tau.p4().M();
226 double pAOneMag =
tau.p();
227 double argumentThetaGJmax = (
std::pow(mTau, 2) -
std::pow(mAOne, 2)) / (2 * mTau * pAOneMag);
228 double argumentThetaGJmeasured =
229 (
tau.p4().px() * decayDistX +
tau.p4().py() * decayDistY +
tau.p4().pz() * decayDistZ) /
230 (pAOneMag * decayDistMag);
231 if (
std::abs(argumentThetaGJmax) <= 1. &&
std::abs(argumentThetaGJmeasured) <= 1.) {
232 double thetaGJmax = std::asin(argumentThetaGJmax);
233 double thetaGJmeasured = std::acos(argumentThetaGJmeasured);
234 gjAngleDiff = thetaGJmeasured - thetaGJmax;
239 mvaInput[0] =
tau.pt();
241 mvaInput[2] = chargedIsoPtSum;
242 mvaInput[3] = neutralIsoPtSum;
243 mvaInput[4] = puCorrPtSum;
244 mvaInput[5] = photonPtSumOutsideSignalCone;
245 mvaInput[6] = tauDecayMode;
246 mvaInput[7] =
tau.signalGammaCands().size();
247 mvaInput[8] =
tau.isolationGammaCands().size();
249 float sigCands_pt = 0.;
250 float sigCands_dr, sigCands_deta, sigCands_dphi;
251 sigCands_dr = sigCands_deta = sigCands_dphi = 0.;
252 for (
const auto&
j :
tau.signalGammaCands()) {
256 const float pt_ =
j->pt();
257 sigCands_dr +=
dr * pt_;
258 sigCands_deta += deta * pt_;
259 sigCands_dphi += dphi * pt_;
262 if (sigCands_pt > 0.) {
263 sigCands_dr = sigCands_dr / sigCands_pt;
264 sigCands_deta = sigCands_deta / sigCands_pt;
265 sigCands_dphi = sigCands_dphi / sigCands_pt;
267 sigCands_dr = sigCands_deta = sigCands_dphi = -0.1;
269 float isoCands_pt = 0.;
270 float isoCands_dr, isoCands_deta, isoCands_dphi;
271 isoCands_dr = isoCands_deta = isoCands_dphi = 0.;
272 for (
const auto&
j :
tau.isolationGammaCands()) {
276 const float pt_ =
j->pt();
277 isoCands_dr +=
dr * pt_;
278 isoCands_deta += deta * pt_;
279 isoCands_dphi += dphi * pt_;
282 if (isoCands_pt > 0.) {
283 isoCands_dr = isoCands_dr / isoCands_pt;
284 isoCands_deta = isoCands_deta / isoCands_pt;
285 isoCands_dphi = isoCands_dphi / isoCands_pt;
287 isoCands_dr = isoCands_deta = isoCands_dphi = -0.1;
289 mvaInput[9] = isoCands_deta;
290 mvaInput[10] = isoCands_dphi;
291 mvaInput[11] = isoCands_dr;
292 mvaInput[12] = sigCands_deta;
293 mvaInput[13] = sigCands_dphi;
294 mvaInput[14] = sigCands_dr;
296 float e =
tau.hcalEnergy() +
tau.ecalEnergy();
297 e > 0. ?
e =
tau.ecalEnergy() /
e :
e = -1.;
299 mvaInput[16] =
tau.dxy() >= 0. ? +1 : -1;
302 mvaInput[19] =
tau.ip3d() >= 0. ? +1 : -1;
305 mvaInput[22] = (
tau.hasSecondaryVertex()) ? 1. : 0.;
306 mvaInput[23] = decayDistMag;
307 mvaInput[24] =
tau.flightLengthSig();
308 mvaInput[25] = leadingTrackChi2;
310 float thetaGJmax, thetaGJ;
311 if (decayDistMag > 0. &&
tau.hasSecondaryVertex()) {
312 const float mAOne =
tau.p4().M();
313 const float pAOneMag =
tau.p();
314 thetaGJmax = (mTau * mTau - mAOne * mAOne) / (2. * mTau * pAOneMag);
315 thetaGJmax = asin(thetaGJmax);
316 thetaGJ = (
tau.px() *
tau.flightLength().x() +
tau.py() *
tau.flightLength().y() +
317 tau.pz() *
tau.flightLength().z()) /
318 (pAOneMag * decayDistMag);
319 thetaGJ = acos(thetaGJ);
328 mvaInput[26] = thetaGJ - thetaGJmax;
333 if (
tau.leadChargedHadrCand().isNonnull()) {
334 if (
tau.leadChargedHadrCand()->bestTrack()) {
335 const float trackdxy =
tau.leadChargedHadrCand()->bestTrack()->dxy();
336 const float trackdxy_err =
tau.leadChargedHadrCand()->bestTrack()->dxyError();
337 mvaInput[27] = trackdxy >= 0. ? +1 : -1;
339 mvaInput[29] =
std::abs(trackdxy / trackdxy_err);
349 mvaInput[5] = tauDecayMode;
356 mvaInput[5] = tauDecayMode;
357 mvaInput[6] = std::copysign(+1.
f,
tau.dxy());
360 mvaInput[9] = (
tau.hasSecondaryVertex()) ? 1. : 0.;
370 mvaInput[6] = tauDecayMode;
372 mvaInput[8] =
std::min(0.5
f, ptWeightedDetaStrip);
373 mvaInput[9] =
std::min(0.5
f, ptWeightedDphiStrip);
374 mvaInput[10] =
std::min(0.5
f, ptWeightedDrSignal);
375 mvaInput[11] =
std::min(0.5
f, ptWeightedDrIsolation);
376 mvaInput[12] =
std::min(100.
f, leadingTrackChi2);
378 mvaInput[14] = std::copysign(+1.
f,
tau.dxy());
381 mvaInput[17] = std::copysign(+1.
f,
tau.ip3d());
384 mvaInput[20] = (
tau.hasSecondaryVertex()) ? 1. : 0.;
394 mvaInput[6] = tauDecayMode;
396 mvaInput[8] =
std::min(0.5
f, ptWeightedDetaStrip);
397 mvaInput[9] =
std::min(0.5
f, ptWeightedDphiStrip);
398 mvaInput[10] =
std::min(0.5
f, ptWeightedDrSignal);
399 mvaInput[11] =
std::min(0.5
f, ptWeightedDrIsolation);
400 mvaInput[12] =
std::min(100.
f, leadingTrackChi2);
402 mvaInput[14] = std::copysign(+1.
f,
tau.dxy());
405 mvaInput[17] = std::copysign(+1.
f,
tau.ip3d());
408 mvaInput[20] = (
tau.hasSecondaryVertex()) ? 1. : 0.;
418 mvaInput[6] = tauDecayMode;
420 mvaInput[8] =
std::min(0.5
f, ptWeightedDetaStrip);
421 mvaInput[9] =
std::min(0.5
f, ptWeightedDphiStrip);
422 mvaInput[10] =
std::min(0.5
f, ptWeightedDrSignal);
423 mvaInput[11] =
std::min(0.5
f, ptWeightedDrIsolation);
425 mvaInput[13] = std::copysign(+1.
f,
tau.dxy());
428 mvaInput[16] = std::copysign(+1.
f,
tau.ip3d());
431 mvaInput[19] = (
tau.hasSecondaryVertex()) ? 1. : 0.;
434 mvaInput[22] =
std::max(-1.
f, gjAngleDiff);