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);
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 }
reco::PFCandidate::isTimeValid
bool isTimeValid() const
do we have a valid time information
Definition: PFCandidate.h:414
reco::GsfTrackRef
edm::Ref< GsfTrackCollection > GsfTrackRef
persistent reference to a GsfTrack
Definition: GsfTrackFwd.h:13
Handle.h
mps_fire.i
i
Definition: mps_fire.py:355
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
edm::isNotFinite
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
PFCandidate.h
reco::GsfTransientTrack
Definition: GsfTransientTrack.h:18
pat::PackedCandidate::time
virtual float time() const
time (wrt nominal zero of the collision)
Definition: PackedCandidate.h:962
edm
HLT enums.
Definition: AlignableModifier.h:19
reco::TransientTrackFromFTS
Definition: TransientTrackFromFTS.h:16
edm::Ptr::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
newFWLiteAna.build
build
Definition: newFWLiteAna.py:126
pat::PackedCandidate::timeError
virtual float timeError() const
time measurement uncertainty (-1 if not available)
Definition: PackedCandidate.h:977
edm::Handle< reco::TrackCollection >
edm::Ref< TrackCollection >
GsfTransientTrack.h
reco::GsfTrack
Definition: GsfTrack.h:12
reco::BeamSpot
Definition: BeamSpot.h:21
reco::Track
Definition: Track.h:27
OrderedSet.t
t
Definition: OrderedSet.py:90
reco::TrackRef
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
edm::View
Definition: CaloClusterFwd.h:14
TransientTrackBuilder.h
reco::PFCandidate::time
float time() const
Definition: PFCandidate.h:416
PackedCandidate.h
edm::RefToBase::castTo
REF castTo() const
Definition: RefToBase.h:257
edm::Ptr< Candidate >
std
Definition: JetResolutionObject.h:76
reco::TransientTrack
Definition: TransientTrack.h:19
isFinite.h
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
reco::PFCandidate::timeError
float timeError() const
Definition: PFCandidate.h:418
edm::ValueMap< float >
TransientTrackFromFTS.h
edm::RefToBase
Definition: AssociativeIterator.h:54
TransientTrackBuilder::build
reco::TransientTrack build(const reco::Track *p) const
Definition: TransientTrackBuilder.cc:20
ntuplemaker.time
time
Definition: ntuplemaker.py:310
PFCandidateFwd.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37