CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
47 TransientTrack TransientTrackBuilder::build(const CandidatePtr& t) const { return this->build(&t); }
48 
50  return TransientTrack(*t, theField, theTrackingGeometry);
51 }
52 
54  return TransientTrack(t, theField, theTrackingGeometry);
55 }
56 
58  return TransientTrack(new GsfTransientTrack(*t, theField, theTrackingGeometry));
59 }
60 
62  return TransientTrack(new GsfTransientTrack(t, theField, theTrackingGeometry));
63 }
64 
65 vector<TransientTrack> TransientTrackBuilder::build(const edm::Handle<reco::TrackCollection>& trkColl) const {
66  vector<TransientTrack> ttVect;
67  ttVect.reserve((*trkColl).size());
68  for (unsigned int i = 0; i < (*trkColl).size(); i++) {
69  ttVect.push_back(TransientTrack(TrackRef(trkColl, i), theField, theTrackingGeometry));
70  }
71  return ttVect;
72 }
73 
74 vector<TransientTrack> TransientTrackBuilder::build(const edm::Handle<reco::GsfTrackCollection>& trkColl) const {
75  vector<TransientTrack> ttVect;
76  ttVect.reserve((*trkColl).size());
77  for (unsigned int i = 0; i < (*trkColl).size(); i++) {
78  ttVect.push_back(TransientTrack(new GsfTransientTrack(GsfTrackRef(trkColl, i), theField, theTrackingGeometry)));
79  }
80  return ttVect;
81 }
82 
83 vector<TransientTrack> TransientTrackBuilder::build(const edm::Handle<edm::View<Track> >& trkColl) const {
84  vector<TransientTrack> ttVect;
85  ttVect.reserve((*trkColl).size());
86  for (unsigned int i = 0; i < (*trkColl).size(); i++) {
87  const Track* trk = &(*trkColl)[i];
88  const GsfTrack* gsfTrack = dynamic_cast<const GsfTrack*>(trk);
89  if (gsfTrack) {
90  ttVect.push_back(TransientTrack(
91  new GsfTransientTrack(RefToBase<Track>(trkColl, i).castTo<GsfTrackRef>(), theField, theTrackingGeometry)));
92  } else { // gsf
93  ttVect.push_back(TransientTrack(RefToBase<Track>(trkColl, i).castTo<TrackRef>(), theField, theTrackingGeometry));
94  }
95  }
96  return ttVect;
97 }
98 
100  const edm::ValueMap<float>& trackTimes,
101  const edm::ValueMap<float>& trackTimeResos) const {
102  vector<TransientTrack> ttVect;
103  ttVect.reserve((*trkColl).size());
104  for (unsigned int i = 0; i < (*trkColl).size(); i++) {
105  TrackRef ref(trkColl, i);
106  double time = trackTimes[ref];
107  double timeReso = trackTimeResos[ref];
108  timeReso =
109  (timeReso > 1e-6 ? timeReso : defaultInvalidTrackReso); // make the error much larger than the BS time width
110  if (edm::isNotFinite(time)) {
111  time = 0.0;
112  timeReso = defaultInvalidTrackReso;
113  }
114  ttVect.push_back(TransientTrack(ref, time, timeReso, theField, theTrackingGeometry));
115  }
116  return ttVect;
117 }
118 
120  const edm::ValueMap<float>& trackTimes,
121  const edm::ValueMap<float>& trackTimeResos) const {
122  vector<TransientTrack> ttVect;
123  ttVect.reserve((*trkColl).size());
124  for (unsigned int i = 0; i < (*trkColl).size(); i++) {
125  GsfTrackRef ref(trkColl, i);
126  double time = trackTimes[ref];
127  double timeReso = trackTimeResos[ref];
128  timeReso =
129  (timeReso > 1e-6 ? timeReso : defaultInvalidTrackReso); // make the error much larger than the BS time width
130  if (edm::isNotFinite(time)) {
131  time = 0.0;
132  timeReso = defaultInvalidTrackReso;
133  }
134  ttVect.push_back(TransientTrack(new GsfTransientTrack(ref, time, timeReso, theField, theTrackingGeometry)));
135  }
136  return ttVect;
137 }
138 
139 vector<TransientTrack> TransientTrackBuilder::build(const edm::Handle<edm::View<Track> >& trkColl,
140  const edm::ValueMap<float>& trackTimes,
141  const edm::ValueMap<float>& trackTimeResos) const {
142  vector<TransientTrack> ttVect;
143  ttVect.reserve((*trkColl).size());
144  for (unsigned int i = 0; i < (*trkColl).size(); i++) {
145  const Track* trk = &(*trkColl)[i];
146  const GsfTrack* gsfTrack = dynamic_cast<const GsfTrack*>(trk);
147  if (gsfTrack) {
148  GsfTrackRef ref = RefToBase<Track>(trkColl, i).castTo<GsfTrackRef>();
149  double time = trackTimes[ref];
150  double timeReso = trackTimeResos[ref];
151  timeReso =
152  (timeReso > 1e-6 ? timeReso : defaultInvalidTrackReso); // make the error much larger than the BS time width
153  if (edm::isNotFinite(time)) {
154  time = 0.0;
155  timeReso = defaultInvalidTrackReso;
156  }
157  ttVect.push_back(TransientTrack(new GsfTransientTrack(
158  RefToBase<Track>(trkColl, i).castTo<GsfTrackRef>(), time, timeReso, theField, theTrackingGeometry)));
159  } else { // gsf
160  TrackRef ref = RefToBase<Track>(trkColl, i).castTo<TrackRef>();
161  double time = trackTimes[ref];
162  double timeReso = trackTimeResos[ref];
163  timeReso =
164  (timeReso > 1e-6 ? timeReso : defaultInvalidTrackReso); // make the error much larger than the BS time width
165  if (edm::isNotFinite(time)) {
166  time = 0.0;
167  timeReso = defaultInvalidTrackReso;
168  }
169  ttVect.push_back(TransientTrack(
170  RefToBase<Track>(trkColl, i).castTo<TrackRef>(), time, timeReso, theField, theTrackingGeometry));
171  }
172  }
173  return ttVect;
174 }
175 
177  const reco::BeamSpot& beamSpot) const {
178  vector<TransientTrack> ttVect = build(trkColl);
179  for (unsigned int i = 0; i < ttVect.size(); i++) {
180  ttVect[i].setBeamSpot(beamSpot);
181  }
182  return ttVect;
183 }
184 
186  const reco::BeamSpot& beamSpot) const {
187  vector<TransientTrack> ttVect = build(trkColl);
188  for (unsigned int i = 0; i < ttVect.size(); i++) {
189  ttVect[i].setBeamSpot(beamSpot);
190  }
191  return ttVect;
192 }
193 
194 vector<TransientTrack> TransientTrackBuilder::build(const edm::Handle<edm::View<Track> >& trkColl,
195  const reco::BeamSpot& beamSpot) const {
196  vector<TransientTrack> ttVect = build(trkColl);
197  for (unsigned int i = 0; i < ttVect.size(); i++) {
198  ttVect[i].setBeamSpot(beamSpot);
199  }
200  return ttVect;
201 }
202 
204  const reco::BeamSpot& beamSpot,
205  const edm::ValueMap<float>& trackTimes,
206  const edm::ValueMap<float>& trackTimeResos) const {
207  vector<TransientTrack> ttVect = build(trkColl, trackTimes, trackTimeResos);
208  for (unsigned int i = 0; i < ttVect.size(); i++) {
209  ttVect[i].setBeamSpot(beamSpot);
210  }
211  return ttVect;
212 }
213 
215  const reco::BeamSpot& beamSpot,
216  const edm::ValueMap<float>& trackTimes,
217  const edm::ValueMap<float>& trackTimeResos) const {
218  vector<TransientTrack> ttVect = build(trkColl, trackTimes, trackTimeResos);
219  for (unsigned int i = 0; i < ttVect.size(); i++) {
220  ttVect[i].setBeamSpot(beamSpot);
221  }
222  return ttVect;
223 }
224 
225 vector<TransientTrack> TransientTrackBuilder::build(const edm::Handle<edm::View<Track> >& trkColl,
226  const reco::BeamSpot& beamSpot,
227  const edm::ValueMap<float>& trackTimes,
228  const edm::ValueMap<float>& trackTimeResos) const {
229  vector<TransientTrack> ttVect = build(trkColl, trackTimes, trackTimeResos);
230  for (unsigned int i = 0; i < ttVect.size(); i++) {
231  ttVect[i].setBeamSpot(beamSpot);
232  }
233  return ttVect;
234 }
235 
237  return TransientTrack(new TransientTrackFromFTS(fts));
238 }
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
reco::TransientTrack build(const reco::Track *p) const
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20