CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pfRecoTauChargedHadronAuxFunctions.cc
Go to the documentation of this file.
2 
5 
6 #include <TMath.h>
7 
8 namespace reco { namespace tau {
9 
10 void setChargedHadronP4(reco::PFRecoTauChargedHadron& chargedHadron, double scaleFactor_neutralPFCands)
11 {
12  double chargedHadronP = 0.;
13  double chargedHadronPx = 0.;
14  double chargedHadronPy = 0.;
15  double chargedHadronPz = 0.;
16  double SumNeutrals = 0.;
19  const reco::PFCandidatePtr& chargedPFCand = chargedHadron.getChargedPFCandidate();
20  assert(chargedPFCand.isNonnull());
21  chargedHadronP += chargedPFCand->p();
22  chargedHadronPx = chargedPFCand->px();
23  chargedHadronPy = chargedPFCand->py();
24  chargedHadronPz = chargedPFCand->pz();
25  } else if ( chargedHadron.algoIs(reco::PFRecoTauChargedHadron::kTrack) ) {
26  const reco::PFRecoTauChargedHadron::TrackPtr& track = chargedHadron.getTrack();
27  assert(track.isNonnull());
28  chargedHadronP += track->p();
29  chargedHadronPx = track->px();
30  chargedHadronPy = track->py();
31  chargedHadronPz = track->pz();
32  } else assert(0);
33  const std::vector<reco::PFCandidatePtr>& neutralPFCands = chargedHadron.getNeutralPFCandidates();
34  for ( std::vector<reco::PFCandidatePtr>::const_iterator neutralPFCand = neutralPFCands.begin();
35  neutralPFCand != neutralPFCands.end(); ++neutralPFCand ) {
36  SumNeutrals += (*neutralPFCand)->p();
37  }
38  double noNeutrals=chargedHadronP;
39  chargedHadronP+=scaleFactor_neutralPFCands*SumNeutrals;
40  double ptRatio=chargedHadronP/noNeutrals;
41  chargedHadronPx*=ptRatio;
42  chargedHadronPy*=ptRatio;
43  chargedHadronPz*=ptRatio;
44 
45 
46  reco::Candidate::LorentzVector chargedHadronP4 = compChargedHadronP4fromPxPyPz(chargedHadronPx, chargedHadronPy, chargedHadronPz);
47  chargedHadron.setP4(chargedHadronP4);
48 }
49 
50 reco::Candidate::LorentzVector compChargedHadronP4fromPxPyPz(double chargedHadronPx, double chargedHadronPy, double chargedHadronPz)
51 {
52  const double chargedPionMass = 0.13957; // GeV
53  double chargedHadronEn = sqrt(chargedHadronPx*chargedHadronPx + chargedHadronPy*chargedHadronPy + chargedHadronPz*chargedHadronPz + chargedPionMass*chargedPionMass);
54  reco::Candidate::LorentzVector chargedHadronP4(chargedHadronPx, chargedHadronPy, chargedHadronPz, chargedHadronEn);
55  return chargedHadronP4;
56 }
57 
58 reco::Candidate::LorentzVector compChargedHadronP4fromPThetaPhi(double chargedHadronP, double chargedHadronTheta, double chargedHadronPhi)
59 {
60  double chargedHadronPx = chargedHadronP*TMath::Cos(chargedHadronPhi)*TMath::Sin(chargedHadronTheta);
61  double chargedHadronPy = chargedHadronP*TMath::Sin(chargedHadronPhi)*TMath::Sin(chargedHadronTheta);
62  double chargedHadronPz = chargedHadronP*TMath::Cos(chargedHadronTheta);
63  return compChargedHadronP4fromPxPyPz(chargedHadronPx, chargedHadronPy, chargedHadronPz);
64 }
65 
66 }} // end namespace reco::tau
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:152
T sqrt(T t)
Definition: SSEVec.h:48
const TrackPtr & getTrack() const
reference to reco::Track
const std::vector< PFCandidatePtr > & getNeutralPFCandidates() const
references to additional neutral PFCandidates
reco::Candidate::LorentzVector compChargedHadronP4fromPThetaPhi(double, double, double)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:41
virtual void setP4(const LorentzVector &p4) GCC11_FINAL
set 4-momentum
bool algoIs(PFRecoTauChargedHadronAlgorithm algo) const
Check whether a given algo produced this charged hadron.
void setChargedHadronP4(reco::PFRecoTauChargedHadron &chargedHadron, double scaleFactor_neutralPFCands=1.0)
const PFCandidatePtr & getChargedPFCandidate() const
reference to &quot;charged&quot; PFCandidate (either charged PFCandidate or PFNeutralHadron) ...
reco::Candidate::LorentzVector compChargedHadronP4fromPxPyPz(double, double, double)