CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RecoTauDiscriminantFunctions.cc
Go to the documentation of this file.
3 #include <algorithm>
7 #include <boost/foreach.hpp>
8 
9 namespace reco { namespace tau { namespace disc {
10 
11 // Helper functions
12 namespace {
13 
14 const PFCandidate& removeRef(const PFCandidateRef& pfRef) {
15  return *pfRef;
16 }
17 
18 const RecoTauPiZero& removeRef(const RecoTauPiZero& piZero) {
19  return piZero;
20 }
21 
22 // A PFTau member function
23 template<typename Collection, typename Function>
24 VDouble extract(const Collection& cands, Function func) {
25  // #define CALL_MEMBER_FN(object,ptrToMember) ((object).*(ptrToMember))
27  output.reserve(cands.size());
28  for(typename Collection::const_iterator cand = cands.begin();
29  cand != cands.end(); ++cand) {
30  output.push_back(func(removeRef(*cand)));
31  }
32  return output;
33 }
34 
35 class DeltaRToAxis {
36  public:
37  DeltaRToAxis(const reco::Candidate::LorentzVector& axis):axis_(axis){}
38  double operator()(const Candidate& cand)
39  {
40  return deltaR(cand.p4(), axis_);
41  }
42  private:
44 };
45 
46 } // end helper functions
47 
49  if (tau.signalPFChargedHadrCands().size() == 3) {
50  for (size_t itrk = 0; itrk < 3; ++itrk) {
51  if (tau.signalPFChargedHadrCands()[itrk]->charge() * tau.charge() < 0)
52  return tau.signalPFChargedHadrCands()[itrk];
53  }
54  }
55  return tau.leadPFChargedHadrCand();
56 }
57 
59 {
60  const PFCandidateRef& mainTrackRef = mainTrack(tau);
62  output.reserve(tau.signalPFChargedHadrCands().size() - 1);
63  BOOST_FOREACH(const PFCandidateRef& ref, tau.signalPFChargedHadrCands()) {
64  if (ref != mainTrackRef)
65  output.push_back(ref);
66  }
67  return output;
68 }
69 
70 /*
71  * HPStanc variables
72  */
73 
74 double JetPt(Tau tau) {
75  return tau.jetRef()->pt();
76 }
77 
78 double JetEta(Tau tau) {
79  return tau.jetRef()->eta();
80 }
81 
82 double JetWidth(Tau tau) {
83  return std::sqrt(
84  std::abs(tau.jetRef()->etaetaMoment()) +
85  std::abs(tau.jetRef()->phiphiMoment()));
86 }
87 
89  return tau.pt()/tau.jetRef()->pt();
90 }
91 
93  return tau.isolationPFChargedHadrCandsPtSum()/tau.jetRef()->pt();
94 }
95 
97  return tau.isolationPFGammaCandsEtSum()/tau.jetRef()->pt();
98 }
99 
101  double sum = 0.0;
102  BOOST_FOREACH(PFCandidateRef cand, tau.isolationPFNeutrHadrCands()) {
103  sum += cand->pt();
104  }
105  return sum/tau.jetRef()->pt();
106 }
107 
109  return tau.jetRef()->pt()*sqrt(std::abs(
110  tau.jetRef()->etaetaMoment()));
111 }
112 
114  double max = 0.0;
115  const PFCandidateRefVector& cands = tau.signalPFCands();
116  for (size_t i = 0; i < cands.size()-1; ++i) {
117  for (size_t j = i+1; j < cands.size(); ++j) {
118  double deltaRVal = deltaR(cands[i]->p4(), cands[j]->p4());
119  if (deltaRVal > max) {
120  max = deltaRVal;
121  }
122  }
123  }
124  // Correct for resolution
125  if ( max < 0.05 )
126  max = 0.05;
127  // Make invariant of PT
128  return max*tau.pt();;
129 }
130 
132  return tau.jetRef()->pt()*sqrt(std::abs(
133  tau.jetRef()->phiphiMoment()));
134 }
135 
137  size_t nIsoCharged = tau.isolationPFChargedHadrCands().size();
138  double averagePt = (nIsoCharged) ?
139  tau.isolationPFChargedHadrCandsPtSum()/nIsoCharged : 0;
140  return averagePt/tau.leadPFChargedHadrCand()->pt();
141 }
142 
144  return mainTrack(tau)->pt()/tau.jetRef()->pt();
145 }
146 
148  PFCandidateRef theMainTrack = mainTrack(tau);
149  PFCandidateRefVector otherSignalTracks = notMainTrack(tau);
150  const std::vector<RecoTauPiZero> &pizeros = tau.signalPiZeroCandidates();
151  VDouble output;
152  output.reserve(otherSignalTracks.size() + pizeros.size());
153  // Add combos with tracks
154  BOOST_FOREACH(PFCandidateRef trk, otherSignalTracks) {
155  reco::Candidate::LorentzVector p4 = theMainTrack->p4() + trk->p4();
156  output.push_back(p4.mass());
157  }
158  // Add combos with pizeros
159  BOOST_FOREACH(const RecoTauPiZero &pizero, pizeros) {
160  reco::Candidate::LorentzVector p4 = theMainTrack->p4() + pizero.p4();
161  output.push_back(p4.mass());
162  }
163  return output;
164 }
165 
168  std::mem_fun_ref(&PFCandidate::pt));
169  double output = 0.0;
170  BOOST_FOREACH(double pt, isocands) {
171  if (pt > 1.0)
172  output += pt;
173  }
174  return output;
175 }
176 
179  std::mem_fun_ref(&PFCandidate::pt));
180  double output = 0.0;
181  BOOST_FOREACH(double pt, isocands) {
182  if (pt < 1.0)
183  output += pt;
184  }
185  return output;
186 }
187 
188 // Relative versions.
190  return IsolationChargedSumHard(tau)/tau.jetRef()->pt();
191 }
192 
194  return IsolationChargedSumSoft(tau)/tau.jetRef()->pt();
195 }
196 
198  VDouble isocands = extract(tau.isolationPFGammaCands(),
199  std::mem_fun_ref(&PFCandidate::pt));
200  double output = 0.0;
201  BOOST_FOREACH(double pt, isocands) {
202  if (pt > 1.5)
203  output += pt;
204  }
205  return output;
206 }
207 
209  VDouble isocands = extract(tau.isolationPFGammaCands(),
210  std::mem_fun_ref(&PFCandidate::pt));
211  double output = 0.0;
212  BOOST_FOREACH(double pt, isocands) {
213  if (pt < 1.5)
214  output += pt;
215  }
216  return output;
217 }
218 
219 // Relative versions.
221  return IsolationECALSumHard(tau)/tau.jetRef()->pt();
222 }
224  return IsolationECALSumSoft(tau)/tau.jetRef()->pt();
225 }
226 
227 double EMFraction(Tau tau) {
228  return tau.emFraction();
229 }
230 
233 }
234 
235 double OutlierN(Tau tau) {
236  return tau.isolationPFChargedHadrCands().size() +
237  tau.isolationPFGammaCands().size();
238 }
239 
241  return tau.isolationPFChargedHadrCands().size();
242 }
243 
244 double MainTrackPt(Tau tau) {
245  PFCandidateRef trk = mainTrack(tau);
246  return (!trk) ? 0.0 : trk->pt();
247 }
248 
250  PFCandidateRef trk = mainTrack(tau);
251  return (!trk) ? 0.0 : trk->eta();
252 }
253 
255  PFCandidateRef trk = mainTrack(tau);
256  return (!trk) ? 0.0 : deltaR(trk->p4(), tau.p4());
257 }
258 
260  return tau.isolationPFChargedHadrCandsPtSum() +
262 }
263 
266 }
267 
269  return tau.isolationPFGammaCandsEtSum();
270 }
271 
272 // Quantities associated to tracks - that are not the main track
274  return extract(notMainTrack(tau), std::mem_fun_ref(&PFCandidate::pt));
275 }
276 
278  return extract(notMainTrack(tau), std::mem_fun_ref(&PFCandidate::eta));
279 }
280 
282  return extract(notMainTrack(tau), DeltaRToAxis(tau.p4()));
283 }
284 
285 // Quantities associated to PiZeros
287  return extract(tau.signalPiZeroCandidates(), std::mem_fun_ref(&RecoTauPiZero::pt));
288 }
289 
291  return extract(tau.signalPiZeroCandidates(), std::mem_fun_ref(&RecoTauPiZero::eta));
292 }
293 
295  return extract(tau.signalPiZeroCandidates(), DeltaRToAxis(tau.p4()));
296 }
297 
298 // Isolation quantities
300  return extract(tau.isolationPFCands(), std::mem_fun_ref(&PFCandidate::pt));
301 }
302 
304  return extract(tau.isolationPFCands(), DeltaRToAxis(tau.p4()));
305 }
306 
309  std::mem_fun_ref(&PFCandidate::pt));
310 }
311 
313  return extract(tau.isolationPFChargedHadrCands(), DeltaRToAxis(tau.p4()));
314 }
315 
317  return extract(tau.isolationPFGammaCands(),
318  std::mem_fun_ref(&PFCandidate::pt));
319 }
320 
322  return extract(tau.isolationPFGammaCands(), DeltaRToAxis(tau.p4()));
323 }
324 
325 // Invariant mass of main track with other combinations
327  return Dalitz2(tau);
328 }
329 
330 // The below functions are deprecated.
331 // Not used, for backwards compatability
334 VDouble GammaPt(Tau tau) { return VDouble(); }
338 
339 }}} // end reco::tau::disc namespace
340 
int i
Definition: DBlmapReader.cc:9
double IsolationECALSumHardRelative(Tau tau)
double ScaledPhiJetCollimation(Tau tau)
float isolationPFGammaCandsEtSum() const
Definition: PFTau.cc:127
const PFCandidateRefVector & isolationPFCands() const
PFCandidates in isolation region.
Definition: PFTau.cc:82
const PFJetRef & jetRef() const
Definition: PFTau.cc:50
float isolationPFChargedHadrCandsPtSum() const
Definition: PFTau.cc:124
std::vector< double > VDouble
double IsolationECALSumHard(Tau tau)
#define abs(x)
Definition: mlp_lapack.h:159
double IsolationChargedSumSoftRelative(Tau tau)
float emFraction() const
Definition: PFTau.cc:134
const PFCandidateRefVector & signalPFChargedHadrCands() const
Charged hadrons in signal region.
Definition: PFTau.cc:75
double IsolationChargedPtFraction(Tau tau)
virtual double eta() const
momentum pseudorapidity
const PFCandidateRefVector & signalPFCands() const
PFCandidates in signal region.
Definition: PFTau.cc:73
double ScaledEtaJetCollimation(Tau tau)
double deltaR(double eta1, double phi1, double eta2, double phi2)
Definition: deltaR.h:19
double ImpactParameterSignificance(Tau tau)
PFCandidateRef mainTrack(const PFTau &tau)
PFCandidateRefVector notMainTrack(Tau tau)
const T & max(const T &a, const T &b)
const std::vector< RecoTauPiZero > & signalPiZeroCandidates() const
Retrieve the association of signal region gamma candidates into candidate PiZeros.
Definition: PFTau.cc:92
T sqrt(T t)
Definition: SSEVec.h:28
double p4[4]
Definition: TauolaWrapper.h:92
double IsolationChargedSumHard(Tau tau)
const PFCandidateRefVector & isolationPFGammaCands() const
Gamma candidates in isolation region.
Definition: PFTau.cc:88
double IsolationChargedAveragePtFraction(Tau tau)
virtual int charge() const
electric charge
const reco::Candidate::LorentzVector & axis_
int j
Definition: DBlmapReader.cc:9
double IsolationECALPtFraction(Tau tau)
edm::Ref< PFCandidateCollection > PFCandidateRef
persistent reference to a PFCandidate
void reserve(size_type n)
Reserve space for RefVector.
Definition: RefVector.h:91
VDouble InvariantMassOfSignalWithFiltered(Tau)
float leadPFChargedHadrCandsignedSipt() const
Definition: PFTau.cc:70
int extract(std::vector< int > *output, const std::string &dati)
const PFCandidateRef & leadPFChargedHadrCand() const
Definition: PFTau.cc:62
double IsolationChargedSumHardRelative(Tau tau)
virtual double pt() const
transverse momentum
double IsolationECALSumSoftRelative(Tau tau)
double IsolationChargedSumSoft(Tau tau)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:39
double IsolationNeutralHadronPtFraction(Tau tau)
double IsolationECALSumSoft(Tau tau)
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:61
size_type size() const
Size of the RefVector.
Definition: RefVector.h:85
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
const PFCandidateRefVector & isolationPFNeutrHadrCands() const
Definition: PFTau.cc:86
const PFCandidateRefVector & isolationPFChargedHadrCands() const
Charged candidates in isolation region.
Definition: PFTau.cc:84