CMS 3D CMS Logo

TransientTrackBuilder.cc
Go to the documentation of this file.
6 
9 
11 
12 using namespace reco;
13 using namespace std;
14 using namespace edm;
15 
17  return TransientTrack(*t, theField, theTrackingGeometry);
18 }
19 
21  return TransientTrack(t, theField, theTrackingGeometry);
22 }
23 
25  return TransientTrack(new GsfTransientTrack(*t, theField, theTrackingGeometry));
26 }
27 
29  return TransientTrack(new GsfTransientTrack(t, theField, theTrackingGeometry));
30 }
31 
33  reco::PFCandidatePtr tryPF(*t);
35  if (tryPF.get() != nullptr && tryPF->isTimeValid()) {
36  return TransientTrack(*t, tryPF->time(), tryPF->timeError(), theField, theTrackingGeometry);
37  } else if (tryPacked.get() != nullptr && tryPacked->timeError() > 0.f) {
38  return TransientTrack(*t, (double)tryPacked->time(), (double)tryPacked->timeError(), theField, theTrackingGeometry);
39  }
40  return TransientTrack(*t, theField, theTrackingGeometry);
41 }
42 
43 TransientTrack TransientTrackBuilder::build(const CandidatePtr& t) const { return this->build(&t); }
44 
46  return TransientTrack(*t, theField, theTrackingGeometry);
47 }
48 
50  return TransientTrack(t, theField, theTrackingGeometry);
51 }
52 
54  return TransientTrack(new GsfTransientTrack(*t, theField, theTrackingGeometry));
55 }
56 
58  return TransientTrack(new GsfTransientTrack(t, theField, theTrackingGeometry));
59 }
60 
61 vector<TransientTrack> TransientTrackBuilder::build(const edm::Handle<reco::TrackCollection>& trkColl) const {
62  vector<TransientTrack> ttVect;
63  ttVect.reserve((*trkColl).size());
64  for (unsigned int i = 0; i < (*trkColl).size(); i++) {
65  ttVect.push_back(TransientTrack(TrackRef(trkColl, i), theField, theTrackingGeometry));
66  }
67  return ttVect;
68 }
69 
70 vector<TransientTrack> TransientTrackBuilder::build(const edm::Handle<reco::GsfTrackCollection>& trkColl) const {
71  vector<TransientTrack> ttVect;
72  ttVect.reserve((*trkColl).size());
73  for (unsigned int i = 0; i < (*trkColl).size(); i++) {
74  ttVect.push_back(TransientTrack(new GsfTransientTrack(GsfTrackRef(trkColl, i), theField, theTrackingGeometry)));
75  }
76  return ttVect;
77 }
78 
79 vector<TransientTrack> TransientTrackBuilder::build(const edm::Handle<edm::View<Track> >& trkColl) const {
80  vector<TransientTrack> ttVect;
81  ttVect.reserve((*trkColl).size());
82  for (unsigned int i = 0; i < (*trkColl).size(); i++) {
83  const Track* trk = &(*trkColl)[i];
84  const GsfTrack* gsfTrack = dynamic_cast<const GsfTrack*>(trk);
85  if (gsfTrack) {
86  ttVect.push_back(TransientTrack(
87  new GsfTransientTrack(RefToBase<Track>(trkColl, i).castTo<GsfTrackRef>(), theField, theTrackingGeometry)));
88  } else { // gsf
89  ttVect.push_back(TransientTrack(RefToBase<Track>(trkColl, i).castTo<TrackRef>(), theField, theTrackingGeometry));
90  }
91  }
92  return ttVect;
93 }
94 
96  const edm::ValueMap<float>& trackTimes,
97  const edm::ValueMap<float>& trackTimeResos) const {
98  vector<TransientTrack> ttVect;
99  ttVect.reserve((*trkColl).size());
100  for (unsigned int i = 0; i < (*trkColl).size(); i++) {
101  TrackRef ref(trkColl, i);
102  double time = trackTimes[ref];
103  double timeReso = trackTimeResos[ref];
104  timeReso = (timeReso > 1e-6 ? timeReso
105  : defaultInvalidTrackTimeReso); // make the error much larger than the BS time width
106  if (edm::isNotFinite(time)) {
107  time = 0.0;
108  timeReso = defaultInvalidTrackTimeReso;
109  }
110  ttVect.push_back(TransientTrack(ref, time, timeReso, theField, theTrackingGeometry));
111  }
112  return ttVect;
113 }
114 
116  const edm::ValueMap<float>& trackTimes,
117  const edm::ValueMap<float>& trackTimeResos) const {
118  vector<TransientTrack> ttVect;
119  ttVect.reserve((*trkColl).size());
120  for (unsigned int i = 0; i < (*trkColl).size(); i++) {
121  GsfTrackRef ref(trkColl, i);
122  double time = trackTimes[ref];
123  double timeReso = trackTimeResos[ref];
124  timeReso = (timeReso > 1e-6 ? timeReso
125  : defaultInvalidTrackTimeReso); // make the error much larger than the BS time width
126  if (edm::isNotFinite(time)) {
127  time = 0.0;
128  timeReso = defaultInvalidTrackTimeReso;
129  }
130  ttVect.push_back(TransientTrack(new GsfTransientTrack(ref, time, timeReso, theField, theTrackingGeometry)));
131  }
132  return ttVect;
133 }
134 
135 vector<TransientTrack> TransientTrackBuilder::build(const edm::Handle<edm::View<Track> >& trkColl,
136  const edm::ValueMap<float>& trackTimes,
137  const edm::ValueMap<float>& trackTimeResos) const {
138  vector<TransientTrack> ttVect;
139  ttVect.reserve((*trkColl).size());
140  for (unsigned int i = 0; i < (*trkColl).size(); i++) {
141  const Track* trk = &(*trkColl)[i];
142  const GsfTrack* gsfTrack = dynamic_cast<const GsfTrack*>(trk);
143  if (gsfTrack) {
144  GsfTrackRef ref = RefToBase<Track>(trkColl, i).castTo<GsfTrackRef>();
145  double time = trackTimes[ref];
146  double timeReso = trackTimeResos[ref];
147  timeReso = (timeReso > 1e-6 ? timeReso
148  : defaultInvalidTrackTimeReso); // make the error much larger than the BS time width
149  if (edm::isNotFinite(time)) {
150  time = 0.0;
151  timeReso = defaultInvalidTrackTimeReso;
152  }
153  ttVect.push_back(TransientTrack(new GsfTransientTrack(
154  RefToBase<Track>(trkColl, i).castTo<GsfTrackRef>(), time, timeReso, theField, theTrackingGeometry)));
155  } else { // gsf
156  TrackRef ref = RefToBase<Track>(trkColl, i).castTo<TrackRef>();
157  double time = trackTimes[ref];
158  double timeReso = trackTimeResos[ref];
159  timeReso = (timeReso > 1e-6 ? timeReso
160  : defaultInvalidTrackTimeReso); // make the error much larger than the BS time width
161  if (edm::isNotFinite(time)) {
162  time = 0.0;
163  timeReso = defaultInvalidTrackTimeReso;
164  }
165  ttVect.push_back(TransientTrack(
166  RefToBase<Track>(trkColl, i).castTo<TrackRef>(), time, timeReso, theField, theTrackingGeometry));
167  }
168  }
169  return ttVect;
170 }
171 
173  const reco::BeamSpot& beamSpot) const {
174  vector<TransientTrack> ttVect = build(trkColl);
175  for (unsigned int i = 0; i < ttVect.size(); i++) {
176  ttVect[i].setBeamSpot(beamSpot);
177  }
178  return ttVect;
179 }
180 
182  const reco::BeamSpot& beamSpot) const {
183  vector<TransientTrack> ttVect = build(trkColl);
184  for (unsigned int i = 0; i < ttVect.size(); i++) {
185  ttVect[i].setBeamSpot(beamSpot);
186  }
187  return ttVect;
188 }
189 
190 vector<TransientTrack> TransientTrackBuilder::build(const edm::Handle<edm::View<Track> >& trkColl,
191  const reco::BeamSpot& beamSpot) const {
192  vector<TransientTrack> ttVect = build(trkColl);
193  for (unsigned int i = 0; i < ttVect.size(); i++) {
194  ttVect[i].setBeamSpot(beamSpot);
195  }
196  return ttVect;
197 }
198 
200  const reco::BeamSpot& beamSpot,
201  const edm::ValueMap<float>& trackTimes,
202  const edm::ValueMap<float>& trackTimeResos) const {
203  vector<TransientTrack> ttVect = build(trkColl, trackTimes, trackTimeResos);
204  for (unsigned int i = 0; i < ttVect.size(); i++) {
205  ttVect[i].setBeamSpot(beamSpot);
206  }
207  return ttVect;
208 }
209 
211  const reco::BeamSpot& beamSpot,
212  const edm::ValueMap<float>& trackTimes,
213  const edm::ValueMap<float>& trackTimeResos) const {
214  vector<TransientTrack> ttVect = build(trkColl, trackTimes, trackTimeResos);
215  for (unsigned int i = 0; i < ttVect.size(); i++) {
216  ttVect[i].setBeamSpot(beamSpot);
217  }
218  return ttVect;
219 }
220 
221 vector<TransientTrack> TransientTrackBuilder::build(const edm::Handle<edm::View<Track> >& trkColl,
222  const reco::BeamSpot& beamSpot,
223  const edm::ValueMap<float>& trackTimes,
224  const edm::ValueMap<float>& trackTimeResos) const {
225  vector<TransientTrack> ttVect = build(trkColl, trackTimes, trackTimeResos);
226  for (unsigned int i = 0; i < ttVect.size(); i++) {
227  ttVect[i].setBeamSpot(beamSpot);
228  }
229  return ttVect;
230 }
231 
233  return TransientTrack(new TransientTrackFromFTS(fts));
234 }
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
float time() const
Definition: PFCandidate.h:423
float timeError() const
Definition: PFCandidate.h:425
reco::TransientTrack build(const reco::Track *p) const
virtual float timeError() const
time measurement uncertainty (-1 if not available)
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:141
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
bool isTimeValid() const
do we have a valid time information
Definition: PFCandidate.h:421
fixed size matrix
HLT enums.
virtual float time() const
time (wrt nominal zero of the collision)