4 struct PFTau_traits{
typedef reco::PFTau Tau_t;
typedef const std::vector<reco::PFCandidatePtr>& Ret_t; };
8 typename T::Ret_t getGammas_T(
const typename T::Tau_t&
tau,
bool signal) {
9 return typename T::Ret_t();
13 const std::vector<reco::PFCandidatePtr>& getGammas_T<PFTau_traits>(
const reco::PFTau&
tau,
bool signal) {
15 return tau.signalPFGammaCands();
17 return tau.isolationPFGammaCands();
23 return tau.signalGammaCands();
25 return tau.isolationGammaCands();
29 bool isInside(
float photon_pt,
float deta,
float dphi) {
30 constexpr double stripEtaAssociationDistance_0p95_p0 = 0.197077;
31 constexpr double stripEtaAssociationDistance_0p95_p1 = 0.658701;
32 constexpr double stripPhiAssociationDistance_0p95_p0 = 0.352476;
33 constexpr double stripPhiAssociationDistance_0p95_p1 = 0.707716;
36 }
if((dphi<0.3 && dphi<
std::max(0.05, stripPhiAssociationDistance_0p95_p0*
std::pow(photon_pt, -stripPhiAssociationDistance_0p95_p1))) && (deta<0.15 && deta<
std::max(0.05, stripEtaAssociationDistance_0p95_p0*
std::pow(photon_pt, -stripEtaAssociationDistance_0p95_p1)))){
43 namespace reco {
namespace tau {
46 float LeadingTracknormalizedChi2 = 0;
51 LeadingTracknormalizedChi2 = (
float)(tref -> normalizedChi2());
54 return LeadingTracknormalizedChi2;
58 float ecal_en_in_signal_pf_cands = 0;
59 float hcal_en_in_signal_pf_cands = 0;
61 ecal_en_in_signal_pf_cands += signal_cand->ecalEnergy();
62 hcal_en_in_signal_pf_cands += signal_cand->hcalEnergy();
64 float total = ecal_en_in_signal_pf_cands + hcal_en_in_signal_pf_cands;
68 return ecal_en_in_signal_pf_cands/
total;
71 float ecal_en_in_signal_cands = tau.
ecalEnergy();
72 float hcal_en_in_signal_cands = tau.
hcalEnergy();
73 float total = ecal_en_in_signal_cands + hcal_en_in_signal_cands;
77 return ecal_en_in_signal_cands/
total;
86 int is3prong = (decaymode==10);
87 const auto&
cands = getGammas_T<T>(
tau, mode < 2);
90 if (
cand->pt() < 0.5){
97 bool flag = isInside(pt, deta, dphi);
99 if (mode == 2 || (mode == 0 && dr < signalrad) || (mode == 1 && dr > signalrad)) {
102 sum_dx_pt += pt *
dr;
104 sum_dx_pt += pt * deta;
106 sum_dx_pt += pt * dphi;
109 else if(is3prong==1){
110 if( (mode==2 && flag==
false) || (mode==1 && flag==
true) || mode==0){
113 sum_dx_pt += pt *
dr;
115 sum_dx_pt += pt * deta;
117 sum_dx_pt += pt * dphi;
122 return sum_dx_pt/sum_pt;
134 unsigned int n_photons = 0;
136 if (
cand->pt() > 0.5)
140 if (
cand->pt() > 0.5)
146 unsigned int n_photons = 0;
148 if (
cand->pt() > 0.5)
152 if (
cand->pt() > 0.5)
165 && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10))
168 && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 || tauDecayMode == 10 || tauDecayMode == 11))
180 float decayDistMag =
std::sqrt(decayDistX*decayDistX + decayDistY*decayDistY + decayDistZ*decayDistZ);
194 float gjAngleDiff = -999;
195 if ( tauDecayMode == 10 ) {
196 double mTau = 1.77682;
197 double mAOne = tau.
p4().M();
198 double pAOneMag = tau.
p();
199 double argumentThetaGJmax = (
std::pow(mTau,2) -
std::pow(mAOne,2) ) / ( 2 * mTau * pAOneMag );
200 double argumentThetaGJmeasured = ( tau.
p4().px() * decayDistX + tau.
p4().py() * decayDistY + tau.
p4().pz() * decayDistZ ) / ( pAOneMag * decayDistMag );
201 if (
std::abs(argumentThetaGJmax) <= 1. &&
std::abs(argumentThetaGJmeasured) <= 1. ) {
202 double thetaGJmax = std::asin( argumentThetaGJmax );
203 double thetaGJmeasured = std::acos( argumentThetaGJmeasured );
204 gjAngleDiff = thetaGJmeasured - thetaGJmax;
214 mvaInput[5] = tauDecayMode;
221 mvaInput[5] = tauDecayMode;
222 mvaInput[6] = std::copysign(+1.
f, tau.
dxy());
235 mvaInput[6] = tauDecayMode;
237 mvaInput[8] =
std::min(0.5
f, ptWeightedDetaStrip);
238 mvaInput[9] =
std::min(0.5
f, ptWeightedDphiStrip);
239 mvaInput[10] =
std::min(0.5
f, ptWeightedDrSignal);
240 mvaInput[11] =
std::min(0.5
f, ptWeightedDrIsolation);
241 mvaInput[12] =
std::min(100.
f, leadingTrackChi2);
243 mvaInput[14] = std::copysign(+1.
f, tau.
dxy());
246 mvaInput[17] = std::copysign(+1.
f, tau.
ip3d());
259 mvaInput[6] = tauDecayMode;
261 mvaInput[8] =
std::min(0.5
f, ptWeightedDetaStrip);
262 mvaInput[9] =
std::min(0.5
f, ptWeightedDphiStrip);
263 mvaInput[10] =
std::min(0.5
f, ptWeightedDrSignal);
264 mvaInput[11] =
std::min(0.5
f, ptWeightedDrIsolation);
265 mvaInput[12] =
std::min(100.
f, leadingTrackChi2);
267 mvaInput[14] = std::copysign(+1.
f, tau.
dxy());
270 mvaInput[17] = std::copysign(+1.
f, tau.
ip3d());
283 mvaInput[6] = tauDecayMode;
285 mvaInput[8] =
std::min(0.5
f, ptWeightedDetaStrip);
286 mvaInput[9] =
std::min(0.5
f, ptWeightedDphiStrip);
287 mvaInput[10] =
std::min(0.5
f, ptWeightedDrSignal);
288 mvaInput[11] =
std::min(0.5
f, ptWeightedDrIsolation);
290 mvaInput[13] = std::copysign(+1.
f, tau.
dxy());
293 mvaInput[16] = std::copysign(+1.
f, tau.
ip3d());
299 mvaInput[22] =
std::max(-1.
f, gjAngleDiff);
constexpr double deltaPhi(double phi1, double phi2)
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
const PFCandidatePtr & leadPFChargedHadrCand() const
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)
const std::vector< reco::PFCandidatePtr > & signalPFGammaCands() const
Gamma candidates in signal region.
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
float tauID(const std::string &name) const
float hcalEnergy() const
return sum of hcal energies from signal candidates
const std::vector< reco::PFCandidatePtr > & signalPFCands() const
PFCandidates in signal region.
reco::CandidatePtrVector signalGammaCands() const
const std::vector< reco::PFCandidatePtr > & isolationPFGammaCands() const
Gamma candidates in isolation region.
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)
const LorentzVector & p4() const final
four-momentum Lorentz vector
bool hasSecondaryVertex() const
Analysis-level tau class.
photonPtSumOutsideSignalCone
bool isNonnull() const
Checks for non-null.
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
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)
reco::CandidatePtrVector isolationGammaCands() const
float lead_track_chi2(const reco::PFTau &tau)
return chi2 of the leading track ==> deprecated? <==
Power< A, B >::type pow(const A &a, const B &b)