CMS 3D CMS Logo

pfRecoTauChargedHadronAuxFunctions.cc
Go to the documentation of this file.
2 
6 
7 #include <TMath.h>
8 
9 namespace reco {
10  namespace tau {
11 
13  // Charged hadron made from track (reco::Track) - RECO/AOD only
14  if (chargedHadron.getTrack().isNonnull()) {
15  return chargedHadron.getTrack().get();
16  }
17  // In MiniAOD, even isolated tracks are saved as candidates, so the track Ptr doesn't exist
18  const pat::PackedCandidate* chargedPFPCand =
19  dynamic_cast<const pat::PackedCandidate*>(chargedHadron.getChargedPFCandidate().get());
20  if (chargedPFPCand != nullptr) {
21  return chargedPFPCand->bestTrack();
22  }
23  const pat::PackedCandidate* lostTrackCand =
24  dynamic_cast<const pat::PackedCandidate*>(chargedHadron.getLostTrackCandidate().get());
25  if (lostTrackCand != nullptr) {
26  return lostTrackCand->bestTrack();
27  }
28  return nullptr;
29  }
30 
31  void setChargedHadronP4(reco::PFRecoTauChargedHadron& chargedHadron, double scaleFactor_neutralPFCands) {
32  double chargedHadronP = 0.;
33  double chargedHadronPx = 0.;
34  double chargedHadronPy = 0.;
35  double chargedHadronPz = 0.;
36  double SumNeutrals = 0.;
39  const reco::CandidatePtr& chargedPFCand = chargedHadron.getChargedPFCandidate();
40  assert(chargedPFCand.isNonnull());
41  chargedHadronP += chargedPFCand->p();
42  chargedHadronPx = chargedPFCand->px();
43  chargedHadronPy = chargedPFCand->py();
44  chargedHadronPz = chargedPFCand->pz();
47  if (track != nullptr) {
48  chargedHadronP += track->p();
49  chargedHadronPx = track->px();
50  chargedHadronPy = track->py();
51  chargedHadronPz = track->pz();
52  } else { // lost tracks from MiniAOD that don't have track information saved
53  const reco::CandidatePtr& lostTrack = chargedHadron.getLostTrackCandidate();
54  assert(lostTrack.isNonnull());
55  chargedHadronP += lostTrack->p();
56  chargedHadronPx = lostTrack->px();
57  chargedHadronPy = lostTrack->py();
58  chargedHadronPz = lostTrack->pz();
59  }
60  } else
61  assert(0);
62  const std::vector<reco::CandidatePtr>& neutralPFCands = chargedHadron.getNeutralPFCandidates();
63  for (std::vector<reco::CandidatePtr>::const_iterator neutralPFCand = neutralPFCands.begin();
64  neutralPFCand != neutralPFCands.end();
65  ++neutralPFCand) {
66  SumNeutrals += (*neutralPFCand)->p();
67  }
68  double noNeutrals = chargedHadronP;
69  chargedHadronP += scaleFactor_neutralPFCands * SumNeutrals;
70  double ptRatio = chargedHadronP / noNeutrals;
71  chargedHadronPx *= ptRatio;
72  chargedHadronPy *= ptRatio;
73  chargedHadronPz *= ptRatio;
74 
75  reco::Candidate::LorentzVector chargedHadronP4 =
76  compChargedHadronP4fromPxPyPz(chargedHadronPx, chargedHadronPy, chargedHadronPz);
77  chargedHadron.setP4(chargedHadronP4);
78  }
79 
81  double chargedHadronPy,
82  double chargedHadronPz) {
83  const double chargedPionMass = 0.13957; // GeV
84  double chargedHadronEn = sqrt(chargedHadronPx * chargedHadronPx + chargedHadronPy * chargedHadronPy +
85  chargedHadronPz * chargedHadronPz + chargedPionMass * chargedPionMass);
86  reco::Candidate::LorentzVector chargedHadronP4(
87  chargedHadronPx, chargedHadronPy, chargedHadronPz, chargedHadronEn);
88  return chargedHadronP4;
89  }
90 
92  double chargedHadronTheta,
93  double chargedHadronPhi) {
94  double chargedHadronPx = chargedHadronP * TMath::Cos(chargedHadronPhi) * TMath::Sin(chargedHadronTheta);
95  double chargedHadronPy = chargedHadronP * TMath::Sin(chargedHadronPhi) * TMath::Sin(chargedHadronTheta);
96  double chargedHadronPz = chargedHadronP * TMath::Cos(chargedHadronTheta);
97  return compChargedHadronP4fromPxPyPz(chargedHadronPx, chargedHadronPy, chargedHadronPz);
98  }
99 
100  } // namespace tau
101 } // namespace reco
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
metsig::tau
Definition: SignAlgoResolutions.h:49
muons2muons_cfi.chargedHadron
chargedHadron
Definition: muons2muons_cfi.py:26
electrons_cff.ptRatio
ptRatio
Definition: electrons_cff.py:204
cms::cuda::assert
assert(be >=bs)
reco::tau::getTrackFromChargedHadron
const reco::Track * getTrackFromChargedHadron(const reco::PFRecoTauChargedHadron &chargedHadron)
Definition: pfRecoTauChargedHadronAuxFunctions.cc:12
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
reco::PFRecoTauChargedHadron
Definition: PFRecoTauChargedHadron.h:23
CandidateFwd.h
reco::tau::setChargedHadronP4
void setChargedHadronP4(reco::PFRecoTauChargedHadron &chargedHadron, double scaleFactor_neutralPFCands=1.0)
Definition: pfRecoTauChargedHadronAuxFunctions.cc:31
pat::PackedCandidate::bestTrack
const reco::Track * bestTrack() const override
return a pointer to the track if present. otherwise, return a null pointer
Definition: PackedCandidate.h:780
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::Track
Definition: Track.h:27
reco::tau::compChargedHadronP4fromPThetaPhi
reco::Candidate::LorentzVector compChargedHadronP4fromPThetaPhi(double, double, double)
Definition: pfRecoTauChargedHadronAuxFunctions.cc:91
reco::tau::compChargedHadronP4fromPxPyPz
reco::Candidate::LorentzVector compChargedHadronP4fromPxPyPz(double, double, double)
Definition: pfRecoTauChargedHadronAuxFunctions.cc:80
pat::PackedCandidate
Definition: PackedCandidate.h:22
PackedCandidate.h
reco::PFRecoTauChargedHadron::kChargedPFCandidate
Definition: PFRecoTauChargedHadron.h:30
edm::Ptr< Candidate >
reco::PFRecoTauChargedHadron::kPFNeutralHadron
Definition: PFRecoTauChargedHadron.h:32
edm::Ptr::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
pfRecoTauChargedHadronAuxFunctions.h
Candidate.h
reco::Candidate::LorentzVector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
reco::PFRecoTauChargedHadron::kTrack
Definition: PFRecoTauChargedHadron.h:31