CMS 3D CMS Logo

PFTrack.cc
Go to the documentation of this file.
2 #include "Math/GenVector/PositionVector3D.h"
6 
7 using namespace reco;
8 using namespace std;
9 
10 const unsigned PFTrack::nMaxTrackingLayers_ = 17;
11 
12 PFTrack::PFTrack() : charge_(0.), indexInnermost_(0), indexOutermost_(0) {
13  // prepare vector of trajectory points for propagated positions
15 }
16 
17 PFTrack::PFTrack(double charge) : charge_(charge), indexInnermost_(0), indexOutermost_(0) {
18  // prepare vector of trajectory points for propagated positions
20 }
21 
23  : charge_(other.charge_),
24  trajectoryPoints_(other.trajectoryPoints_),
25  indexInnermost_(other.indexInnermost_),
26  indexOutermost_(other.indexOutermost_) {}
27 
28 void PFTrack::addPoint(const PFTrajectoryPoint& trajPt) {
29  if (trajPt.isTrackerLayer()) {
30  if (!indexOutermost_) { // first time a measurement is added
32  PFTrajectoryPoint dummyPt;
33  for (unsigned iPt = trajectoryPoints_.size(); iPt < PFTrajectoryPoint::BeamPipeOrEndVertex + 1; iPt++)
34  trajectoryPoints_.push_back(dummyPt);
36  edm::LogWarning("PFTrack") << "trajectoryPoints_.size() is too large = " << trajectoryPoints_.size();
37  }
39  } else
41  }
42  // Use push_back instead of insert in order to gain time
43  trajectoryPoints_.push_back(trajPt);
44 }
45 
46 const reco::PFTrajectoryPoint& PFTrack::extrapolatedPoint(unsigned layerid) const {
47  const unsigned offset_layerid = nTrajectoryMeasurements() + layerid;
48  if (layerid >= reco::PFTrajectoryPoint::NLayers || offset_layerid >= trajectoryPoints_.size()) {
49  throw cms::Exception("SizeError") << "PFRecTrack::extrapolatedPoint: cannot access " << layerid
50  << " #traj meas = " << nTrajectoryMeasurements()
51  << " #traj points = " << trajectoryPoints_.size() << endl
52  << (*this);
53  }
54  if (layerid < indexInnermost_)
55  return trajectoryPoints_[layerid];
56  else
57  return trajectoryPoints_[offset_layerid];
58 }
59 
60 ostream& reco::operator<<(ostream& out, const PFTrack& track) {
61  if (!out)
62  return out;
63 
64  const reco::PFTrajectoryPoint& closestApproach = track.trajectoryPoint(reco::PFTrajectoryPoint::ClosestApproach);
65 
66  out << "Track charge = " << track.charge() << ", Pt = " << closestApproach.momentum().Pt()
67  << ", P = " << closestApproach.momentum().P() << endl
68  << "\tR0 = " << closestApproach.position().Rho() << " Z0 = " << closestApproach.position().Z() << endl
69  << "\tnumber of tracker measurements = " << track.nTrajectoryMeasurements() << endl;
70  for (unsigned i = 0; i < track.trajectoryPoints().size(); i++)
71  out << track.trajectoryPoints()[i] << endl;
72 
73  return out;
74 }
const math::XYZTLorentzVector & momentum() const
4-momenta quadrivector
Base class for particle flow input reconstructed tracks and simulated particles.
Definition: PFTrack.h:63
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr float charge(ConstView const &tracks, int32_t i)
Definition: TracksSoA.h:73
bool isTrackerLayer() const
is this point corresponding to an intersection with a tracker layer ?
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:66
Point of closest approach from beam axis (initial point in the case of PFSimParticle) ...
void addPoint(const reco::PFTrajectoryPoint &trajPt)
Definition: PFTrack.cc:28
std::vector< reco::PFTrajectoryPoint > trajectoryPoints_
vector of trajectory points
Definition: PFTrack.h:121
const reco::PFTrajectoryPoint & extrapolatedPoint(unsigned layerid) const
Definition: PFTrack.cc:46
unsigned int nTrajectoryMeasurements() const
Definition: PFTrack.h:89
const math::XYZPoint & position() const
cartesian position (x, y, z)
static const unsigned int nMaxTrackingLayers_
maximal number of tracking layers
Definition: PFTrack.h:115
unsigned int indexOutermost_
index outermost tracker measurement
Definition: PFTrack.h:127
fixed size matrix
unsigned int indexInnermost_
index innermost tracker measurement
Definition: PFTrack.h:124
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
Log< level::Warning, false > LogWarning