4 struct PFTau_traits{
typedef reco::PFTau Tau_t;
typedef const std::vector<reco::CandidatePtr>& 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::CandidatePtr>& getGammas_T<PFTau_traits>(
const reco::PFTau&
tau,
bool signal) {
15 return tau.signalGammaCands();
17 return tau.isolationGammaCands();
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;
50 if (pfcand !=
nullptr) {
53 LeadingTracknormalizedChi2 = tref->normalizedChi2();
63 return LeadingTracknormalizedChi2;
67 float ecal_en_in_signal_pf_cands = 0;
68 float hcal_en_in_signal_pf_cands = 0;
71 if (signal_pfcand !=
nullptr) {
72 ecal_en_in_signal_pf_cands += signal_pfcand->
ecalEnergy();
73 hcal_en_in_signal_pf_cands += signal_pfcand->
hcalEnergy();
77 float total = ecal_en_in_signal_pf_cands + hcal_en_in_signal_pf_cands;
81 return ecal_en_in_signal_pf_cands/
total;
84 float ecal_en_in_signal_cands = tau.
ecalEnergy();
85 float hcal_en_in_signal_cands = tau.
hcalEnergy();
86 float total = ecal_en_in_signal_cands + hcal_en_in_signal_cands;
90 return ecal_en_in_signal_cands/
total;
99 int is3prong = (decaymode==10);
100 const auto&
cands = getGammas_T<T>(
tau, mode < 2);
103 if (
cand->pt() < 0.5){
110 bool flag = isInside(pt, deta, dphi);
112 if (mode == 2 || (mode == 0 && dr < signalrad) || (mode == 1 && dr > signalrad)) {
115 sum_dx_pt += pt *
dr;
117 sum_dx_pt += pt * deta;
119 sum_dx_pt += pt * dphi;
122 else if(is3prong==1){
123 if( (mode==2 && flag==
false) || (mode==1 && flag==
true) || mode==0){
126 sum_dx_pt += pt *
dr;
128 sum_dx_pt += pt * deta;
130 sum_dx_pt += pt * dphi;
135 return sum_dx_pt/sum_pt;
147 unsigned int n_photons = 0;
149 if (
cand->pt() > 0.5)
153 if (
cand->pt() > 0.5)
159 unsigned int n_photons = 0;
161 if (
cand->pt() > 0.5)
165 if (
cand->pt() > 0.5)
178 && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 10))
181 && (tauDecayMode == 0 || tauDecayMode == 1 || tauDecayMode == 2 || tauDecayMode == 5 || tauDecayMode == 6 || tauDecayMode == 10 || tauDecayMode == 11))
193 float decayDistMag =
std::sqrt(decayDistX*decayDistX + decayDistY*decayDistY + decayDistZ*decayDistZ);
207 float gjAngleDiff = -999;
208 if ( tauDecayMode == 10 ) {
209 double mTau = 1.77682;
210 double mAOne = tau.
p4().M();
211 double pAOneMag = tau.
p();
212 double argumentThetaGJmax = (
std::pow(mTau,2) -
std::pow(mAOne,2) ) / ( 2 * mTau * pAOneMag );
213 double argumentThetaGJmeasured = ( tau.
p4().px() * decayDistX + tau.
p4().py() * decayDistY + tau.
p4().pz() * decayDistZ ) / ( pAOneMag * decayDistMag );
214 if (
std::abs(argumentThetaGJmax) <= 1. &&
std::abs(argumentThetaGJmeasured) <= 1. ) {
215 double thetaGJmax = std::asin( argumentThetaGJmax );
216 double thetaGJmeasured = std::acos( argumentThetaGJmeasured );
217 gjAngleDiff = thetaGJmeasured - thetaGJmax;
227 mvaInput[5] = tauDecayMode;
234 mvaInput[5] = tauDecayMode;
235 mvaInput[6] = std::copysign(+1.
f, tau.
dxy());
248 mvaInput[6] = tauDecayMode;
250 mvaInput[8] =
std::min(0.5
f, ptWeightedDetaStrip);
251 mvaInput[9] =
std::min(0.5
f, ptWeightedDphiStrip);
252 mvaInput[10] =
std::min(0.5
f, ptWeightedDrSignal);
253 mvaInput[11] =
std::min(0.5
f, ptWeightedDrIsolation);
254 mvaInput[12] =
std::min(100.
f, leadingTrackChi2);
256 mvaInput[14] = std::copysign(+1.
f, tau.
dxy());
259 mvaInput[17] = std::copysign(+1.
f, tau.
ip3d());
272 mvaInput[6] = tauDecayMode;
274 mvaInput[8] =
std::min(0.5
f, ptWeightedDetaStrip);
275 mvaInput[9] =
std::min(0.5
f, ptWeightedDphiStrip);
276 mvaInput[10] =
std::min(0.5
f, ptWeightedDrSignal);
277 mvaInput[11] =
std::min(0.5
f, ptWeightedDrIsolation);
278 mvaInput[12] =
std::min(100.
f, leadingTrackChi2);
280 mvaInput[14] = std::copysign(+1.
f, tau.
dxy());
283 mvaInput[17] = std::copysign(+1.
f, tau.
ip3d());
296 mvaInput[6] = tauDecayMode;
298 mvaInput[8] =
std::min(0.5
f, ptWeightedDetaStrip);
299 mvaInput[9] =
std::min(0.5
f, ptWeightedDphiStrip);
300 mvaInput[10] =
std::min(0.5
f, ptWeightedDrSignal);
301 mvaInput[11] =
std::min(0.5
f, ptWeightedDrIsolation);
303 mvaInput[13] = std::copysign(+1.
f, tau.
dxy());
306 mvaInput[16] = std::copysign(+1.
f, tau.
ip3d());
312 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)