CMS 3D CMS Logo

TempTrajectory.h
Go to the documentation of this file.
1 #ifndef CkfPattern_TempTrajectory_H
2 #define CkfPattern_TempTrajectory_H
3 
10 
11 #include <vector>
12 #include <algorithm>
13 #include <limits>
15 
17 
41 public:
45 
46  struct Payload {
47  float theChiSquared = 0;
48  float theDPhiCache = 0;
50 
51  uint8_t theNumberOfFoundHits = 0;
53  uint8_t theNumberOfLostHits = 0;
56 
57  // PropagationDirection
59 
60  uint8_t theNHseed = 0;
61  uint8_t theNLoops = 0;
63  };
64 
71 
76  TempTrajectory(PropagationDirection dir, unsigned char nhseed) : thePayload(std::make_unique<Payload>()) {
77  thePayload->theDirection = dir;
78  thePayload->theNHseed = nhseed;
79  }
80 
82  : theData(rh.theData), thePayload(rh.thePayload ? std::make_unique<Payload>(*rh.thePayload) : nullptr) {}
83 
85  theData = rh.theData;
86  thePayload = rh.thePayload ? std::make_unique<Payload>(*rh.thePayload) : nullptr;
87  return *this;
88  }
89 
90  TempTrajectory(TempTrajectory&& rh) noexcept : theData(std::move(rh.theData)), thePayload(std::move(rh.thePayload)) {}
91 
93  using std::swap;
94  swap(theData, rh.theData);
95  swap(thePayload, rh.thePayload);
96  return *this;
97  }
98 
99  void swap(TempTrajectory& rh) noexcept {
100  using std::swap;
101  swap(theData, rh.theData);
102  swap(thePayload, rh.thePayload);
103  }
104 
106  explicit TempTrajectory(Trajectory&& traj);
107 
109  ~TempTrajectory() = default;
110 
115  void push(const TrajectoryMeasurement& tm) { push(tm, tm.estimate()); }
116 
117  void push(TrajectoryMeasurement&& tm) { push(std::forward<TrajectoryMeasurement>(tm), tm.estimate()); }
118 
119  template <typename... Args>
120  void emplace(Args&&... args) {
121  theData.emplace_back(std::forward<Args>(args)...);
123  }
124 
130  void push(TempTrajectory const& segment);
131 
136  void join(TempTrajectory& segment);
137 
141  void push(const TrajectoryMeasurement& tm, double chi2Increment) {
142  theData.push_back(tm);
143  pushAux(chi2Increment);
144  }
145 
146  void push(TrajectoryMeasurement&& tm, double chi2Increment) {
148  pushAux(chi2Increment);
149  }
150 
151  template <typename... Args>
152  void emplace(double chi2Increment, Args&&... args) { // works only because the first Arg is never a double!
153  theData.emplace_back(std::forward<Args>(args)...);
154  pushAux(chi2Increment);
155  }
156 
159  void pop();
160 
167  check();
168  return theData.back();
169  }
170 
178  check();
179  return theData.front();
180  }
181 
184  const DataContainer& measurements() const { return theData; }
185 
191  int foundHits() const { return thePayload->theNumberOfFoundHits; }
192 
195  int foundPixelHits() const { return thePayload->theNumberOfFoundPixelHits; }
196 
201  int lostHits() const { return thePayload->theNumberOfLostHits; }
202 
205  int trailingFoundHits() const { return thePayload->theNumberOfTrailingFoundHits; }
206 
211  int cccBadHits() const { return thePayload->theNumberOfCCCBadHits_; }
212 
213  //number of hits in seed
214  unsigned int seedNHits() const { return thePayload->theNHseed; }
215 
217  bool empty() const { return theData.empty(); }
218 
220  float chiSquared() const { return thePayload->theChiSquared; }
221 
227 
231  bool isValid() const { return bool(thePayload); }
232 
234  void invalidate() { thePayload.reset(); }
235 
238  static bool inactive( //const Det& det
239  ) {
240  return false;
241  } //FIXME
242 
244  const DetLayer* lastLayer() const {
245  check();
246  return theData.back().layer();
247  }
248 
250  Trajectory toTrajectory() const;
251 
253  void popInvalidTail();
254 
257  float dPhiCacheForLoopersReconstruction() const { return thePayload->theDPhiCache; }
258 
261  void setDPhiCacheForLoopersReconstruction(float dphi) { thePayload->theDPhiCache = dphi; }
262 
263  bool isLooper() const { return (thePayload->theNLoops > 0); }
264  signed char nLoops() const { return thePayload->theNLoops; }
265 
266  void setNLoops(int8_t value) { thePayload->theNLoops = value; }
267  void incrementLoops() { thePayload->theNLoops++; }
268 
269  StopReason stopReason() const { return thePayload->stopReason_; }
270  void setStopReason(StopReason s) { thePayload->stopReason_ = s; }
271 
272  int numberOfCCCBadHits(float ccc_threshold);
273 
274  static bool lost(const TrackingRecHit& hit) dso_internal;
275 
276 private:
281  void updateBadForCCC(float ccc_threshold) dso_internal;
282 
283  void pushAux(double chi2Increment);
284 
285 private:
287  std::unique_ptr<Payload> thePayload;
288 
289  void check() const;
290 };
291 
292 #endif
void emplace(Args &&... args)
PropagationDirection direction() const
int cccBadHits() const
void join(TempTrajectory &segment)
ConstRecHitContainer RecHitContainer
const T & back() const
Definition: bqueue.h:196
void push(TrajectoryMeasurement &&tm)
TrackingRecHit::ConstRecHitContainer ConstRecHitContainer
const T & front() const
Definition: bqueue.h:194
int trailingFoundHits() const
static bool lost(const TrackingRecHit &hit)
PropagationDirection
unsigned int seedNHits() const
void emplace_back(Args &&...args)
Definition: bqueue.h:178
TempTrajectory(TempTrajectory &&rh) noexcept
const DataContainer & measurements() const
void setNLoops(int8_t value)
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
void setDPhiCacheForLoopersReconstruction(float dphi)
DataContainer theData
~TempTrajectory()=default
destruct a TempTrajectory
void invalidate()
Method to invalidate a trajectory. Useful during ambiguity resolution.
bool isLooper() const
bool isValid() const
static bool inactive()
void updateBadForCCC(float ccc_threshold)
const TrajectoryMeasurement & lastMeasurement() const
void emplace(double chi2Increment, Args &&... args)
const TrajectoryMeasurement & firstMeasurement() const
#define dso_internal
Definition: Visibility.h:13
TempTrajectory & operator=(TempTrajectory &&rh) noexcept
int foundHits() const
Definition: value.py:1
void push(TrajectoryMeasurement &&tm, double chi2Increment)
float chiSquared() const
Value of the raw Chi2 of the trajectory, not normalised to the N.D.F.
int lostHits() const
void check() const
StopReason stopReason() const
std::vector< ConstRecHitPointer > ConstRecHitContainer
void swap(TempTrajectory &rh) noexcept
Trajectory toTrajectory() const
Convert to a standard Trajectory.
void push(const TrajectoryMeasurement &tm, double chi2Increment)
int numberOfCCCBadHits(float ccc_threshold)
const DetLayer * lastLayer() const
Redundant method, returns the layer of lastMeasurement() .
float dPhiCacheForLoopersReconstruction() const
uint8_t theNumberOfTrailingFoundHits
bool empty() const
Definition: bqueue.h:203
bool badForCCC(const TrajectoryMeasurement &tm)
void popInvalidTail()
Pops out all the invalid hits on the tail.
cmsutils::bqueue< TrajectoryMeasurement > DataContainer
std::unique_ptr< Payload > thePayload
void setStopReason(StopReason s)
signed char nLoops() const
TempTrajectory(TempTrajectory const &rh)
int foundPixelHits() const
const DetLayer * layer() const
TempTrajectory & operator=(TempTrajectory const &rh)
def move(src, dest)
Definition: eostools.py:511
void push_back(const T &val)
Definition: bqueue.h:161
void pushAux(double chi2Increment)
bool empty() const
True if trajectory has no measurements.
void push(const TrajectoryMeasurement &tm)
TempTrajectory(PropagationDirection dir, unsigned char nhseed)