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();
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.;
111 int is3prong = (decaymode == 10);
112 const auto&
cands = getGammas_T<T>(
tau, mode < 2);
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) {
134 if ((mode == 2 && flag ==
false) || (mode == 1 && flag ==
true) || mode == 0) {
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;
160 if (
cand->pt() > 0.5)
164 if (
cand->pt() > 0.5)
170 unsigned int n_photons = 0;
172 if (
cand->pt() > 0.5)
176 if (
cand->pt() > 0.5)
194 (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10)) ||
197 (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 ||
198 tauDecayMode == 10 || tauDecayMode == 11))) {
208 float decayDistMag =
std::sqrt(decayDistX * decayDistX + decayDistY * decayDistY + decayDistZ * decayDistZ);
222 float gjAngleDiff = -999;
223 if (tauDecayMode == 10) {
224 double mTau = 1.77682;
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;
244 mvaInput[5] = tauDecayMode;
251 mvaInput[5] = tauDecayMode;
252 mvaInput[6] = std::copysign(+1.
f, tau.
dxy());
265 mvaInput[6] = tauDecayMode;
267 mvaInput[8] =
std::min(0.5
f, ptWeightedDetaStrip);
268 mvaInput[9] =
std::min(0.5
f, ptWeightedDphiStrip);
269 mvaInput[10] =
std::min(0.5
f, ptWeightedDrSignal);
270 mvaInput[11] =
std::min(0.5
f, ptWeightedDrIsolation);
271 mvaInput[12] =
std::min(100.
f, leadingTrackChi2);
273 mvaInput[14] = std::copysign(+1.
f, tau.
dxy());
276 mvaInput[17] = std::copysign(+1.
f, tau.
ip3d());
289 mvaInput[6] = tauDecayMode;
291 mvaInput[8] =
std::min(0.5
f, ptWeightedDetaStrip);
292 mvaInput[9] =
std::min(0.5
f, ptWeightedDphiStrip);
293 mvaInput[10] =
std::min(0.5
f, ptWeightedDrSignal);
294 mvaInput[11] =
std::min(0.5
f, ptWeightedDrIsolation);
295 mvaInput[12] =
std::min(100.
f, leadingTrackChi2);
297 mvaInput[14] = std::copysign(+1.
f, tau.
dxy());
300 mvaInput[17] = std::copysign(+1.
f, tau.
ip3d());
313 mvaInput[6] = tauDecayMode;
315 mvaInput[8] =
std::min(0.5
f, ptWeightedDetaStrip);
316 mvaInput[9] =
std::min(0.5
f, ptWeightedDphiStrip);
317 mvaInput[10] =
std::min(0.5
f, ptWeightedDrSignal);
318 mvaInput[11] =
std::min(0.5
f, ptWeightedDrIsolation);
320 mvaInput[13] = std::copysign(+1.
f, tau.
dxy());
323 mvaInput[16] = std::copysign(+1.
f, tau.
ip3d());
329 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 ...
bool isNonnull() const
Checks for non-null.
double eta() const final
momentum pseudorapidity
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)
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)
double pt() const final
transverse momentum
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
const CandidatePtr & leadChargedHadrCand() const
float pt_weighted_deta_strip(const reco::PFTau &tau, int dm)
const pat::tau::TauPFEssential::Vector & flightLength() const
Abs< T >::type abs(const T &t)
float pt_weighted_dr_iso(const reco::PFTau &tau, int dm)
virtual const reco::Track & pseudoTrack() const
const LorentzVector & p4() const final
four-momentum Lorentz vector
bool hasSecondaryVertex() const
Analysis-level tau class.
photonPtSumOutsideSignalCone
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())
double p() const final
magnitude of momentum vector
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
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.
Power< A, B >::type pow(const A &a, const B &b)