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 
16 namespace {
17  constexpr float defaultInvalidTrackReso = 0.350f;
18 }
19 
21  return TransientTrack(*t, theField, theTrackingGeometry);
22 }
23 
25  return TransientTrack(t, theField, theTrackingGeometry);
26 }
27 
29  return TransientTrack(new GsfTransientTrack(*t, theField, theTrackingGeometry));
30 }
31 
33  return TransientTrack(new GsfTransientTrack(t, theField, theTrackingGeometry));
34 }
35 
37  reco::PFCandidatePtr tryPF(*t);
38  edm::Ptr<pat::PackedCandidate> tryPacked(*t);
39  if( tryPF.get() != nullptr && tryPF->isTimeValid() ) {
40  return TransientTrack(*t, tryPF->time(), tryPF->timeError(), theField, theTrackingGeometry);
41  } else if ( tryPacked.get() != nullptr && tryPacked->timeError() > 0.f ) {
42  return TransientTrack(*t, (double)tryPacked->time(), (double)tryPacked->timeError(), theField, theTrackingGeometry);
43  }
44  return TransientTrack(*t, theField, theTrackingGeometry);
45 }
46 
48  return this->build(&t);
49 }
50 
52  return TransientTrack(*t, theField, theTrackingGeometry);
53 }
54 
56  return TransientTrack(t, theField, theTrackingGeometry);
57 }
58 
59 
61  return TransientTrack(new GsfTransientTrack(*t, theField, theTrackingGeometry));
62 }
63 
65  return TransientTrack(new GsfTransientTrack(t, theField, theTrackingGeometry));
66 }
67 
68 vector<TransientTrack>
70 {
71  vector<TransientTrack> ttVect;
72  ttVect.reserve((*trkColl).size());
73  for (unsigned int i = 0; i < (*trkColl).size() ; i++) {
74  ttVect.push_back(TransientTrack(TrackRef(trkColl, i), theField, theTrackingGeometry));
75  }
76  return ttVect;
77 }
78 
79 vector<TransientTrack>
81 {
82  vector<TransientTrack> ttVect;
83  ttVect.reserve((*trkColl).size());
84  for (unsigned int i = 0; i < (*trkColl).size() ; i++) {
85  ttVect.push_back( TransientTrack(
86  new GsfTransientTrack(GsfTrackRef(trkColl, i), theField, theTrackingGeometry)) );
87  }
88  return ttVect;
89 }
90 
91 vector<TransientTrack>
93 {
94  vector<TransientTrack> ttVect;
95  ttVect.reserve((*trkColl).size());
96  for (unsigned int i = 0; i < (*trkColl).size() ; i++) {
97  const Track * trk = &(*trkColl)[i];
98  const GsfTrack * gsfTrack = dynamic_cast<const GsfTrack *>(trk);
99  if (gsfTrack) {
100  ttVect.push_back( TransientTrack(
101  new GsfTransientTrack(RefToBase<Track>(trkColl, i).castTo<GsfTrackRef>(), theField, theTrackingGeometry)) );
102  } else { // gsf
103  ttVect.push_back(TransientTrack(RefToBase<Track>(trkColl, i).castTo<TrackRef>(), theField, theTrackingGeometry));
104  }
105  }
106  return ttVect;
107 }
108 
109 vector<TransientTrack>
111  const edm::ValueMap<float>& trackTimes,
112  const edm::ValueMap<float>& trackTimeResos ) const
113 {
114  vector<TransientTrack> ttVect;
115  ttVect.reserve((*trkColl).size());
116  for (unsigned int i = 0; i < (*trkColl).size() ; i++) {
117  TrackRef ref(trkColl, i);
118  double time = trackTimes[ref];
119  double timeReso = trackTimeResos[ref];
120  timeReso = ( timeReso > 1e-6 ? timeReso : defaultInvalidTrackReso ); // make the error much larger than the BS time width
121  if( edm::isNotFinite(time) ) {
122  time = 0.0;
123  timeReso = defaultInvalidTrackReso;
124  }
125  ttVect.push_back(TransientTrack(ref, time, timeReso, theField, theTrackingGeometry));
126  }
127  return ttVect;
128 }
129 
130 vector<TransientTrack>
132  const edm::ValueMap<float>& trackTimes,
133  const edm::ValueMap<float>& trackTimeResos ) const
134 {
135  vector<TransientTrack> ttVect;
136  ttVect.reserve((*trkColl).size());
137  for (unsigned int i = 0; i < (*trkColl).size() ; i++) {
138  GsfTrackRef ref(trkColl, i);
139  double time = trackTimes[ref];
140  double timeReso = trackTimeResos[ref];
141  timeReso = ( timeReso > 1e-6 ? timeReso : defaultInvalidTrackReso ); // make the error much larger than the BS time width
142  if( edm::isNotFinite(time) ) {
143  time = 0.0;
144  timeReso = defaultInvalidTrackReso;
145  }
146  ttVect.push_back( TransientTrack(
147  new GsfTransientTrack(ref, time, timeReso, theField, theTrackingGeometry)) );
148  }
149  return ttVect;
150 }
151 
152 vector<TransientTrack>
154  const edm::ValueMap<float>& trackTimes,
155  const edm::ValueMap<float>& trackTimeResos ) const
156 {
157  vector<TransientTrack> ttVect;
158  ttVect.reserve((*trkColl).size());
159  for (unsigned int i = 0; i < (*trkColl).size() ; i++) {
160  const Track * trk = &(*trkColl)[i];
161  const GsfTrack * gsfTrack = dynamic_cast<const GsfTrack *>(trk);
162  if (gsfTrack) {
163  GsfTrackRef ref = RefToBase<Track>(trkColl, i).castTo<GsfTrackRef>();
164  double time = trackTimes[ref];
165  double timeReso = trackTimeResos[ref];
166  timeReso = ( timeReso > 1e-6 ? timeReso : defaultInvalidTrackReso ); // make the error much larger than the BS time width
167  if( edm::isNotFinite(time) ) {
168  time = 0.0;
169  timeReso = defaultInvalidTrackReso;
170  }
171  ttVect.push_back( TransientTrack(
172  new GsfTransientTrack(RefToBase<Track>(trkColl, i).castTo<GsfTrackRef>(), time, timeReso, theField, theTrackingGeometry)) );
173  } else { // gsf
174  TrackRef ref = RefToBase<Track>(trkColl, i).castTo<TrackRef>();
175  double time = trackTimes[ref];
176  double timeReso = trackTimeResos[ref];
177  timeReso = ( timeReso > 1e-6 ? timeReso : defaultInvalidTrackReso ); // make the error much larger than the BS time width
178  if( edm::isNotFinite(time) ) {
179  time = 0.0;
180  timeReso = defaultInvalidTrackReso;
181  }
182  ttVect.push_back(TransientTrack(RefToBase<Track>(trkColl, i).castTo<TrackRef>(), time, timeReso, theField, theTrackingGeometry));
183  }
184  }
185  return ttVect;
186 }
187 
188 vector<TransientTrack>
190  const reco::BeamSpot & beamSpot) const
191 {
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 
199 vector<TransientTrack>
201  const reco::BeamSpot & beamSpot) const
202 {
203  vector<TransientTrack> ttVect = build(trkColl);
204  for (unsigned int i = 0; i < ttVect.size() ; i++) {
205  ttVect[i].setBeamSpot(beamSpot);
206  }
207  return ttVect;
208 }
209 
210 vector<TransientTrack>
212  const reco::BeamSpot & beamSpot) const
213 {
214  vector<TransientTrack> ttVect = build(trkColl);
215  for (unsigned int i = 0; i < ttVect.size() ; i++) {
216  ttVect[i].setBeamSpot(beamSpot);
217  }
218  return ttVect;
219 }
220 
221 vector<TransientTrack>
223  const reco::BeamSpot & beamSpot,
224  const edm::ValueMap<float>& trackTimes,
225  const edm::ValueMap<float>& trackTimeResos ) const
226 {
227  vector<TransientTrack> ttVect = build(trkColl, trackTimes, trackTimeResos );
228  for (unsigned int i = 0; i < ttVect.size() ; i++) {
229  ttVect[i].setBeamSpot(beamSpot);
230  }
231  return ttVect;
232 }
233 
234 vector<TransientTrack>
236  const reco::BeamSpot & beamSpot,
237  const edm::ValueMap<float>& trackTimes,
238  const edm::ValueMap<float>& trackTimeResos ) const
239 {
240  vector<TransientTrack> ttVect = build(trkColl, trackTimes, trackTimeResos);
241  for (unsigned int i = 0; i < ttVect.size() ; i++) {
242  ttVect[i].setBeamSpot(beamSpot);
243  }
244  return ttVect;
245 }
246 
247 vector<TransientTrack>
249  const reco::BeamSpot & beamSpot,
250  const edm::ValueMap<float>& trackTimes,
251  const edm::ValueMap<float>& trackTimeResos ) const
252 {
253  vector<TransientTrack> ttVect = build(trkColl, trackTimes, trackTimeResos);
254  for (unsigned int i = 0; i < ttVect.size() ; i++) {
255  ttVect[i].setBeamSpot(beamSpot);
256  }
257  return ttVect;
258 }
259 
261  return TransientTrack(new TransientTrackFromFTS(fts));
262 }
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:159
reco::TransientTrack build(const reco::Track *p) const
virtual float time() const
time (wrt nominal zero of the collision)
float time() const
Definition: PFCandidate.h:421
#define constexpr
bool isTimeValid() const
do we have a valid time information
Definition: PFCandidate.h:419
bool isNotFinite(T x)
Definition: isFinite.h:10
virtual float timeError() const
time measurement uncertainty (-1 if not available)
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
fixed size matrix
HLT enums.
float timeError() const
Definition: PFCandidate.h:423