CMS 3D CMS Logo

PFRecoTauClusterVariables.h
Go to the documentation of this file.
1 
15 
17  public:
23  float tau_leadTrackChi2(const reco::PFTau& tau) const {
24  float LeadingTracknormalizedChi2 = 0;
25  const reco::PFCandidatePtr& leadingPFCharged = tau.leadPFChargedHadrCand() ;
26  if (leadingPFCharged.isNonnull()) {
27  reco::TrackRef tref = leadingPFCharged -> trackRef();
28  if (tref.isNonnull()) {
29  LeadingTracknormalizedChi2 = (float)(tref -> normalizedChi2());
30  }
31  }
32  return LeadingTracknormalizedChi2;
33  }
35  float tau_Eratio(const reco::PFTau& tau) const {
36  std::vector<reco::PFCandidatePtr> constsignal = tau.signalPFCands();
37  float EcalEnInSignalPFCands = 0;
38  float HcalEnInSignalPFCands = 0;
39  typedef std::vector <reco::PFCandidatePtr>::iterator constituents_iterator;
40  for(constituents_iterator it=constsignal.begin(); it != constsignal.end(); ++it) {
41  reco::PFCandidatePtr & icand = *it;
42  EcalEnInSignalPFCands += icand -> ecalEnergy();
43  HcalEnInSignalPFCands += icand -> hcalEnergy();
44  }
45  float total = EcalEnInSignalPFCands + HcalEnInSignalPFCands;
46  if(total==0){
47  return -1;
48  }
49  return EcalEnInSignalPFCands/total;
50  }
51  float tau_Eratio(const pat::Tau& tau) const {
52  float EcalEnInSignalCands = tau.ecalEnergy();
53  float HcalEnInSignalCands = tau.hcalEnergy();
54  float total = EcalEnInSignalCands + HcalEnInSignalCands;
55  if(total == 0){
56  return -1;
57  }
58  return EcalEnInSignalCands/total;
59  }
62  float pt_weighted_dx(const reco::PFTau& tau, int mode = 0, int var = 0, int decaymode = -1) const {
63  float sum_pt = 0.;
64  float sum_dx_pt = 0.;
65  float signalrad = std::max(0.05, std::min(0.1, 3./std::max(1., tau.pt())));
66  int is3prong = (decaymode==10);
67  const auto& cands = getPFGammas(tau, mode < 2);
68  for (const auto& cand : cands) {
69  // only look at electrons/photons with pT > 0.5
70  if ((float)cand->pt() < 0.5){
71  continue;
72  }
73  float dr = reco::deltaR((float)cand->eta(),(float)cand->phi(),(float)tau.eta(),(float)tau.phi());
74  float deta = std::abs((float)cand->eta() - (float)tau.eta());
75  float dphi = std::abs(reco::deltaPhi((float)cand->phi(), (float)tau.phi()));
76  float pt = cand->pt();
77  bool flag = isInside(pt, deta, dphi);
78  if(is3prong==0){
79  if (mode == 2 || (mode == 0 && dr < signalrad) || (mode == 1 && dr > signalrad)) {
80  sum_pt += pt;
81  if (var == 0)
82  sum_dx_pt += pt * dr;
83  else if (var == 1)
84  sum_dx_pt += pt * deta;
85  else if (var == 2)
86  sum_dx_pt += pt * dphi;
87  }
88  }
89  else if(is3prong==1){
90  if( (mode==2 && flag==false) || (mode==1 && flag==true) || mode==0){
91  sum_pt += pt;
92  if (var == 0)
93  sum_dx_pt += pt * dr;
94  else if (var == 1)
95  sum_dx_pt += pt * deta;
96  else if (var == 2)
97  sum_dx_pt += pt * dphi;
98  }
99  }
100  }
101  if (sum_pt > 0.){
102  return sum_dx_pt/sum_pt;
103  }
104  return 0.;
105  }
106  float pt_weighted_dx(const pat::Tau& tau, int mode = 0, int var = 0, int decaymode = -1) const {
107  float sum_pt = 0.;
108  float sum_dx_pt = 0.;
109  float signalrad = std::max(0.05, std::min(0.1, 3./std::max(1., tau.pt())));
110  int is3prong = (decaymode==10);
111  const auto cands = getGammas(tau, mode < 2);
112  for (const auto& cand : cands) {
113  // only look at electrons/photons with pT > 0.5
114  if (cand->pt() < 0.5){
115  continue;
116  }
117  float dr = reco::deltaR(*cand, tau);
118  float deta = std::abs(cand->eta() - tau.eta());
119  float dphi = std::abs(reco::deltaPhi(cand->phi(), tau.phi()));
120  float pt = cand->pt();
121  bool flag = isInside(pt, deta, dphi);
122  if(is3prong==0){
123  if (mode == 2 || (mode == 0 && dr < signalrad) || (mode == 1 && dr > signalrad)) {
124  sum_pt += pt;
125  if (var == 0)
126  sum_dx_pt += pt * dr;
127  else if (var == 1)
128  sum_dx_pt += pt * deta;
129  else if (var == 2)
130  sum_dx_pt += pt * dphi;
131  }
132  }
133  else if(is3prong==1){
134  if( (mode==2 && flag==false) || (mode==1 && flag==true) || mode==0){
135  sum_pt += pt;
136  if (var == 0)
137  sum_dx_pt += pt * dr;
138  else if (var == 1)
139  sum_dx_pt += pt * deta;
140  else if (var == 2)
141  sum_dx_pt += pt * dphi;
142  }
143  }
144  }
145  if (sum_pt > 0.){
146  return sum_dx_pt/sum_pt;
147  }
148  return 0.;
149  }
152  float tau_pt_weighted_dr_signal(const reco::PFTau& tau, int dm) const {
153  return pt_weighted_dx(tau, 0, 0, dm);
154  }
155  float tau_pt_weighted_dr_signal(const pat::Tau& tau, int dm) const {
156  return pt_weighted_dx(tau, 0, 0, dm);
157  }
160  float tau_pt_weighted_deta_strip(const reco::PFTau& tau, int dm) const {
161  return pt_weighted_dx(tau, dm==10 ? 2 : 1, 1, dm);
162  }
163  float tau_pt_weighted_deta_strip(const pat::Tau& tau, int dm) const {
164  return pt_weighted_dx(tau, dm==10 ? 2 : 1, 1, dm);
165  }
168  float tau_pt_weighted_dphi_strip(const reco::PFTau& tau, int dm) const {
169  return pt_weighted_dx(tau, dm==10 ? 2 : 1, 2, dm);
170  }
171  float tau_pt_weighted_dphi_strip(const pat::Tau& tau, int dm) const {
172  return pt_weighted_dx(tau, dm==10 ? 2 : 1, 2, dm);
173  }
176  float tau_pt_weighted_dr_iso(const reco::PFTau& tau, int dm) const {
177  return pt_weighted_dx(tau, 2, 0, dm);
178  }
179  float tau_pt_weighted_dr_iso(const pat::Tau& tau, int dm) const {
180  return pt_weighted_dx(tau, 2, 0, dm);
181  }
183  unsigned int tau_n_photons_total(const reco::PFTau& tau) const {
184  unsigned int n_photons = 0;
185  for (auto& cand : tau.signalPFGammaCands()) {
186  if ((float)cand->pt() > 0.5)
187  ++n_photons;
188  }
189  for (auto& cand : tau.isolationPFGammaCands()) {
190  if ((float)cand->pt() > 0.5)
191  ++n_photons;
192  }
193  return n_photons;
194  }
195  unsigned int tau_n_photons_total(const pat::Tau& tau) const {
196  unsigned int n_photons = 0;
197  for (auto& cand : tau.signalGammaCands()) {
198  if (cand->pt() > 0.5)
199  ++n_photons;
200  }
201  for (auto& cand : tau.isolationGammaCands()) {
202  if (cand->pt() > 0.5)
203  ++n_photons;
204  }
205  return n_photons;
206  }
207 
208  private:
210  const std::vector<reco::PFCandidatePtr>& getPFGammas(const reco::PFTau& tau, bool signal = true) const {
211  if (signal){
212  return tau.signalPFGammaCands();
213  }
214  return tau.isolationPFGammaCands();
215  }
216  reco::CandidatePtrVector getGammas(const pat::Tau& tau, bool signal = true) const {
217  if(signal){
218  return tau.signalGammaCands();
219  }
220  return tau.isolationGammaCands();
221  }
223  bool isInside(float photon_pt, float deta, float dphi) const {
224  const double stripEtaAssociationDistance_0p95_p0 = 0.197077;
225  const double stripEtaAssociationDistance_0p95_p1 = 0.658701;
226  const double stripPhiAssociationDistance_0p95_p0 = 0.352476;
227  const double stripPhiAssociationDistance_0p95_p1 = 0.707716;
228  if(photon_pt==0){
229  return false;
230  }
231  if((dphi<0.3 && dphi<std::max(0.05, stripPhiAssociationDistance_0p95_p0*std::pow(photon_pt, -stripPhiAssociationDistance_0p95_p1))) && \
232  (deta<0.15 && deta<std::max(0.05, stripEtaAssociationDistance_0p95_p0*std::pow(photon_pt, -stripEtaAssociationDistance_0p95_p1)))){
233  return true;
234  }
235  return false;
236  }
237 };
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
float tau_pt_weighted_dr_signal(const pat::Tau &tau, int dm) const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
float tau_Eratio(const reco::PFTau &tau) const
return ratio of energy in ECAL over sum of energy in ECAL and HCAL
double eta() const final
momentum pseudorapidity
const PFCandidatePtr & leadPFChargedHadrCand() const
Definition: PFTau.cc:67
float tau_pt_weighted_deta_strip(const pat::Tau &tau, int dm) const
const std::vector< reco::PFCandidatePtr > & getPFGammas(const reco::PFTau &tau, bool signal=true) const
return pf photon candidates that are associated to signal
reco::CandidatePtrVector getGammas(const pat::Tau &tau, bool signal=true) const
float tau_pt_weighted_dphi_strip(const pat::Tau &tau, int dm) const
const std::vector< reco::PFCandidatePtr > & signalPFGammaCands() const
Gamma candidates in signal region.
Definition: PFTau.cc:84
double pt() const final
transverse momentum
~TauIdMVAAuxiliaries()
default destructor
TauIdMVAAuxiliaries()
default constructor
float hcalEnergy() const
return sum of hcal energies from signal candidates
Definition: Tau.h:336
float ecalEnergy() const
Definition: Tau.h:334
const std::vector< reco::PFCandidatePtr > & signalPFCands() const
PFCandidates in signal region.
Definition: PFTau.cc:78
reco::CandidatePtrVector signalGammaCands() const
const std::vector< reco::PFCandidatePtr > & isolationPFGammaCands() const
Gamma candidates in isolation region.
Definition: PFTau.cc:93
bool isInside(float photon_pt, float deta, float dphi) const
decide if photon candidate is inside the cone to be associated to the tau signal
float tau_pt_weighted_dphi_strip(const reco::PFTau &tau, int dm) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
float tau_pt_weighted_dr_signal(const reco::PFTau &tau, int dm) const
float tau_leadTrackChi2(const reco::PFTau &tau) const
return chi2 of the leading track ==> deprecated? <==
Analysis-level tau class.
Definition: Tau.h:55
float tau_pt_weighted_dr_iso(const reco::PFTau &tau, int dm) const
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:168
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
float tau_pt_weighted_deta_strip(const reco::PFTau &tau, int dm) const
float pt_weighted_dx(const reco::PFTau &tau, int mode=0, int var=0, int decaymode=-1) const
float pt_weighted_dx(const pat::Tau &tau, int mode=0, int var=0, int decaymode=-1) const
reco::CandidatePtrVector isolationGammaCands() const
double phi() const final
momentum azimuthal angle
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
float tau_Eratio(const pat::Tau &tau) const
float tau_pt_weighted_dr_iso(const pat::Tau &tau, int dm) const
unsigned int tau_n_photons_total(const pat::Tau &tau) const
unsigned int tau_n_photons_total(const reco::PFTau &tau) const
return total number of pf photon candidates with pT>500 MeV, which are associated to signal ...