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;
63 if (pfcand !=
nullptr) {
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;
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();
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.;
117 int is3prong = (decaymode == 10);
118 const auto&
cands = getGammas_T<T>(
tau, mode < 2);
119 for (
const auto& cand :
cands) {
121 if (cand->pt() < 0.5) {
124 float dr =
reco::deltaR(cand->eta(), cand->phi(), tau.eta(), tau.phi());
125 float deta =
std::abs(cand->eta() - tau.eta());
127 float pt = cand->pt();
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) {
140 if ((mode == 2 && flag ==
false) || (mode == 1 && flag ==
true) || mode == 0) {
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;
157 return pt_weighted_dx_T<PFTau_traits>(
tau,
mode,
var, decaymode);
160 return pt_weighted_dx_T<PATTau_traits>(
tau,
mode,
var, decaymode);
164 unsigned int n_photons = 0;
166 if (cand->pt() > 0.5)
170 if (cand->pt() > 0.5)
176 unsigned int n_photons = 0;
178 if (cand->pt() > 0.5)
182 if (cand->pt() > 0.5)
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);
215 float decayDistMag =
std::sqrt(decayDistX * decayDistX + decayDistY * decayDistY + decayDistZ * decayDistZ);
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;
255 float sigCands_pt = 0.;
256 float sigCands_dr, sigCands_deta, sigCands_dphi;
257 sigCands_dr = sigCands_deta = sigCands_dphi = 0.;
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.;
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;
305 mvaInput[16] = tau.
dxy() >= 0. ? +1 : -1;
308 mvaInput[19] = tau.
ip3d() >= 0. ? +1 : -1;
312 mvaInput[23] = decayDistMag;
314 mvaInput[25] = leadingTrackChi2;
316 float thetaGJmax, thetaGJ;
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);
324 (pAOneMag * decayDistMag);
325 thetaGJ = acos(thetaGJ);
334 mvaInput[26] = thetaGJ - thetaGJmax;
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());
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());
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());
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());
440 mvaInput[22] =
std::max(-1.
f, gjAngleDiff);
constexpr double deltaPhi(double phi1, double phi2)
double ecalEnergy() const
return corrected Ecal energy
unsigned int n_photons_total(const reco::PFTau &tau)
return total number of pf photon candidates with pT>500 MeV, which are associated to signal ...
static std::vector< std::string > checklist log
double pz() const final
z coordinate of momentum vector
bool isNonnull() const
Checks for non-null.
size_type size() const
Size of the RefVector.
double pt() const final
transverse momentum
float pt_weighted_dx(const reco::PFTau &tau, int mode=0, int var=0, int decaymode=-1)
float pt_weighted_dr_signal(const reco::PFTau &tau, int dm)
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
float hcalFraction() const
T const * get() const
Returns C++ pointer to the item.
bool fillIsoMVARun2Inputs(float *mvaInput, const pat::Tau &tau, int mvaOpt, const std::string &nameCharged, const std::string &nameNeutral, const std::string &namePu, const std::string &nameOutside, const std::string &nameFootprint)
const std::vector< reco::CandidatePtr > & signalGammaCands() const
Gamma candidates in signal region.
float tauID(const std::string &name) const
float hcalEnergy() const
return sum of hcal energies from signal candidates
reco::CandidatePtrVector signalGammaCands() const
const std::vector< reco::CandidatePtr > & isolationGammaCands() const
Gamma candidates in isolation region.
reco::TrackRef trackRef() const
double px() const final
x coordinate of momentum vector
double p() const final
magnitude of momentum vector
const CandidatePtr & leadChargedHadrCand() const
float pt_weighted_deta_strip(const reco::PFTau &tau, int dm)
const pat::tau::TauPFEssential::Vector & flightLength() const
list var
if using global norm cols_to_minmax = ['t_delta', 't_hmaxNearP','t_emaxNearP', 't_hAnnular', 't_eAnnular','t_pt','t_nVtx','t_ieta','t_eHcal10', 't_eHcal30','t_rhoh','t_eHcal'] df[cols_to_minmax] = df[cols_to_minmax].apply(lambda x: (x - x.min()) / (x.max() - x.min()) if (x.max() - x.min() > 0) else 1.0/200.0)
Abs< T >::type abs(const T &t)
float pt_weighted_dr_iso(const reco::PFTau &tau, int dm)
virtual const reco::Track & pseudoTrack() const
bool hasSecondaryVertex() const
const reco::CandidatePtr leadChargedHadrCand() const
float caloFraction() const
Set the fraction of ECAL+HCAL energy over candidate energy.
double py() const final
y coordinate of momentum vector
Analysis-level tau class.
bool isNonnull() const
Checks for non-null.
bool hasTrackDetails() const
Return true if a bestTrack can be extracted from this Candidate.
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
float pt_weighted_dphi_strip(const reco::PFTau &tau, int dm)
int decayMode() const
reconstructed tau decay mode (specific to PFTau)
float eratio(const reco::PFTau &tau)
return ratio of energy in ECAL over sum of energy in ECAL and HCAL
Particle reconstructed by the particle flow algorithm.
float flightLengthSig() const
float leadingTrackNormChi2() const
return normalized chi2 of leading track
double energy() const override
energy
float pt_weighted_dx_T(const typename T::Tau_t &tau, int mode, int var, int decaymode)
double hcalEnergy() const
return corrected Hcal energy
reco::CandidatePtrVector isolationGammaCands() const
float lead_track_chi2(const reco::PFTau &tau)
return chi2 of the leading track ==> deprecated? <==
const std::vector< reco::CandidatePtr > & signalCands() const
Candidates in signal region.
double phi() const final
momentum azimuthal angle
Power< A, B >::type pow(const A &a, const B &b)
double eta() const final
momentum pseudorapidity