CMS 3D CMS Logo

Trajectory.h
Go to the documentation of this file.
1 #ifndef CommonDet_Trajectory_H
2 #define CommonDet_Trajectory_H
3 
11 
12 #include <vector>
13 #include <algorithm>
14 #include <limits>
15 #include <boost/shared_ptr.hpp>
16 
41 {
42 public:
43 
44  typedef std::vector<TrajectoryMeasurement> DataContainer;
47 
54 
55 
62  explicit Trajectory( const TrajectorySeed& seed) :
63  theSeed( new TrajectorySeed(seed) ),
64  theValid(true)
65  {}
66 
72  theSeed( new TrajectorySeed(seed) ),
73  theDirection(dir),
75  theValid(true)
76  {}
77 
82  Trajectory( const boost::shared_ptr<const TrajectorySeed> & seed, PropagationDirection dir) :
83  theSeed( seed ),
84  theDirection(dir),
86  theValid(true)
87  {}
88 
94  theDirection(dir),
96  theValid(true)
97  {}
98 
99 
100  Trajectory(Trajectory const & rh) = default;
101  Trajectory & operator=(Trajectory const & rh) = default;
102 
104  theSeed(std::move(rh.theSeed)),
105  seedRef_(std::move(rh.seedRef_)),
106  theData(std::move(rh.theData)),
116  theValid(rh.theValid),
119  theNLoops(rh.theNLoops),
121  {}
122 
124  using std::swap;
125  swap(theData,rh.theData);
128  theValid=rh.theValid;
131  theNLoops=rh.theNLoops;
140  swap(theSeed,rh.theSeed);
141  swap(seedRef_,rh.seedRef_);
142 
143  return *this;
144 
145  }
146 
147 
150  void reserve (unsigned int n) { theData.reserve(n); }
151 
156  void push(const TrajectoryMeasurement& tm);
160  void push(const TrajectoryMeasurement & tm, double chi2Increment);
161 
162  void push(TrajectoryMeasurement&& tm);
163  void push(TrajectoryMeasurement&& tm, double chi2Increment);
164 
167  void pop();
168 
175  check();
176  if (theData.back().recHitR().hit()!=nullptr) return theData.back();
177  else if (theData.size()>2) return *(theData.end()-2);
178  else throw cms::Exception("TrajectoryMeasurement::lastMeasurement - Too few measurements in trajectory");
179  }
180 
188  check();
189  if (theData.front().recHitR().hit()!=nullptr) return theData.front();
190  else if (theData.size()>2) return *(theData.begin()+1);
191  else throw cms::Exception("TrajectoryMeasurement::firstMeasurement - Too few measurements in trajectory");
192  }
193 
196  DataContainer const & measurements() const { return theData;}
197  DataContainer & measurements() { return theData;}
198 
200  DataContainer const & data() const { return measurements();}
201 
206  hits.reserve(theData.size());
207  for (Trajectory::DataContainer::const_iterator itm
208  = theData.begin(); itm != theData.end(); itm++){
209  hits.push_back((*itm).recHit());
210  }
211  return hits;
212  }
213 
217  void validRecHits(ConstRecHitContainer & cont) const;
218 
225  int foundHits() const { return theNumberOfFoundHits;}
226 
230 
236  int lostHits() const { return theNumberOfLostHits;}
237 
241 
242 
247  int cccBadHits() const { return theNumberOfCCCBadHits_;}
248 
249  //number of hits in seed
250  unsigned int seedNHits() const { return seed().nHits();}
251 
252 
254  bool empty() const { return theData.empty();}
255 
263 
267  int ndof(bool bon = true) const;
268 
269 
274  PropagationDirection const & direction() const;
275 
279  bool isValid() const { return theValid;}
280 
282  void invalidate() { theValid = false;}
283 
285  TrajectorySeed const & seed() const { return *theSeed;}
286 
287 
290  static bool inactive(//const Det& det
291  ){return false;}//FIXME
292 
296  static bool lost( const TrackingRecHit& hit);
297 
301  static bool isBad( const TrackingRecHit& hit);
302 
306  static bool pixel( const TrackingRecHit& hit);
307 
309  const DetLayer* lastLayer() const {
310  check();
311  if (theData.back().recHit()->hit()!=nullptr) return theData.back().layer();
312  else if (theData.size()>2) return (theData.end()-2)->layer();
313  else throw cms::Exception("TrajectoryMeasurement::lastMeasurement - Too few measurements in trajectory");
314  }
315 
322 
324 
326 
328 
331  void reverse() ;
332 
333  const boost::shared_ptr<const TrajectorySeed> & sharedSeed() const { return theSeed; }
334  void setSharedSeed(const boost::shared_ptr<const TrajectorySeed> & seed) { theSeed=seed;}
335 
339 
340  float cccThreshold() const {return theCCCThreshold_;}
341 
345 
346  bool isLooper() const { return (theNLoops>0);}
347  signed char nLoops() const {return theNLoops;}
348 
349  void setNLoops(signed char value) { theNLoops=value;}
351 
354 
355  int numberOfCCCBadHits(float ccc_threshold);
356 
357 private:
358 
359  void pushAux(double chi2Increment);
360  bool badForCCC(const TrajectoryMeasurement &tm);
361  void updateBadForCCC(float ccc_threshold);
362 
363  boost::shared_ptr<const TrajectorySeed> theSeed;
365 
366  DataContainer theData;
367  float theChiSquared=0;
369 
370  signed short theNumberOfFoundHits=0;
372  signed short theNumberOfLostHits=0;
374  signed short theNumberOfCCCBadHits_=0;
375 
378  bool theValid=false;
379 
380  float theDPhiCache=0;
382  signed char theNLoops=0;
384 
385  void check() const;
386 };
387 
388 #endif
float dPhiCacheForLoopersReconstruction() const
Definition: Trajectory.h:338
signed short theNumberOfTrailingFoundHits
Definition: Trajectory.h:373
bool empty() const
True if trajectory has no measurements.
Definition: Trajectory.h:254
Trajectory(const TrajectorySeed &seed, PropagationDirection dir)
Definition: Trajectory.h:71
int foundHits() const
Definition: Trajectory.h:225
float theChiSquaredBad
Definition: Trajectory.h:368
signed short theNumberOfFoundHits
Definition: Trajectory.h:370
int lostHits() const
Definition: Trajectory.h:236
bool theDirectionValidity
Definition: Trajectory.h:377
int trailingFoundHits() const
Definition: Trajectory.h:240
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
Definition: Trajectory.h:285
signed short theNumberOfFoundPixelHits
Definition: Trajectory.h:371
signed short theNumberOfLostHits
Definition: Trajectory.h:372
float cccThreshold() const
Definition: Trajectory.h:340
void pushAux(double chi2Increment)
Definition: Trajectory.cc:70
Trajectory & operator=(Trajectory const &rh)=default
void setStopReason(StopReason s)
Definition: Trajectory.h:352
void setNLoops(signed char value)
Definition: Trajectory.h:349
void invalidate()
Method to invalidate a trajectory. Useful during ambiguity resolution.
Definition: Trajectory.h:282
ConstRecHitContainer recHits() const
Definition: Trajectory.h:204
DataContainer theData
Definition: Trajectory.h:366
bool badForCCC(const TrajectoryMeasurement &tm)
Definition: Trajectory.cc:184
void check() const
Definition: Trajectory.cc:145
PropagationDirection
void reserve(unsigned int n)
Definition: Trajectory.h:150
const boost::shared_ptr< const TrajectorySeed > & sharedSeed() const
Definition: Trajectory.h:333
float theCCCThreshold_
Definition: Trajectory.h:381
signed char theNLoops
Definition: Trajectory.h:382
TrajectoryMeasurement const & closestMeasurement(GlobalPoint) const
Definition: Trajectory.cc:257
TrajectoryStateOnSurface geometricalInnermostState() const
Definition: Trajectory.cc:220
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:116
signed char nLoops() const
Definition: Trajectory.h:347
void incrementLoops()
Definition: Trajectory.h:350
float theDPhiCache
Definition: Trajectory.h:380
PropagationDirection const & direction() const
Definition: Trajectory.cc:140
DataContainer const & measurements() const
Definition: Trajectory.h:196
void updateBadForCCC(float ccc_threshold)
Definition: Trajectory.cc:200
std::vector< TrajectoryMeasurement > DataContainer
Definition: Trajectory.h:44
bool isLooper() const
Definition: Trajectory.h:346
StopReason stopReason() const
Definition: Trajectory.h:353
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:174
void validRecHits(ConstRecHitContainer &cont) const
Definition: Trajectory.cc:133
int foundPixelHits() const
Definition: Trajectory.h:229
static bool pixel(const TrackingRecHit &hit)
Definition: Trajectory.cc:177
Definition: value.py:1
edm::RefToBase< TrajectorySeed > seedRef(void) const
Definition: Trajectory.h:321
DataContainer & measurements()
Definition: Trajectory.h:197
Trajectory(const TrajectorySeed &seed)
Definition: Trajectory.h:62
Trajectory(PropagationDirection dir)
Definition: Trajectory.h:93
bool theValid
Definition: Trajectory.h:378
StopReason stopReason_
Definition: Trajectory.h:383
PropagationDirection theDirection
Definition: Trajectory.h:376
void setSharedSeed(const boost::shared_ptr< const TrajectorySeed > &seed)
Definition: Trajectory.h:334
std::vector< ConstRecHitPointer > ConstRecHitContainer
float theChiSquared
Definition: Trajectory.h:367
boost::shared_ptr< const TrajectorySeed > theSeed
Definition: Trajectory.h:363
int ndof(bool bon=true) const
Definition: Trajectory.cc:102
bool isValid() const
Definition: Trajectory.h:279
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:187
ConstRecHitContainer RecHitContainer
Definition: Trajectory.h:46
unsigned int seedNHits() const
Definition: Trajectory.h:250
void pop()
Definition: Trajectory.cc:29
static bool isBad(const TrackingRecHit &hit)
Definition: Trajectory.cc:166
Trajectory(const boost::shared_ptr< const TrajectorySeed > &seed, PropagationDirection dir)
Definition: Trajectory.h:82
static bool inactive()
Definition: Trajectory.h:290
void setSeedRef(const edm::RefToBase< TrajectorySeed > &seedRef)
Definition: Trajectory.h:323
float chiSquared() const
Definition: Trajectory.h:262
edm::RefToBase< TrajectorySeed > seedRef_
Definition: Trajectory.h:364
void setDPhiCacheForLoopersReconstruction(float dphi)
Definition: Trajectory.h:344
TrackingRecHit::ConstRecHitContainer ConstRecHitContainer
Definition: Trajectory.h:45
int numberOfCCCBadHits(float ccc_threshold)
Definition: Trajectory.cc:215
unsigned int nHits() const
DataContainer const & data() const
obsolete name, use measurements() instead.
Definition: Trajectory.h:200
Trajectory(Trajectory &&rh)
Definition: Trajectory.h:103
Trajectory & operator=(Trajectory &&rh)
Definition: Trajectory.h:123
int cccBadHits() const
Definition: Trajectory.h:247
const DetLayer * lastLayer() const
Redundant method, returns the layer of lastMeasurement() .
Definition: Trajectory.h:309
void reverse()
Definition: Trajectory.cc:264
dbl *** dir
Definition: mlp_gen.cc:35
void push(const TrajectoryMeasurement &tm)
Definition: Trajectory.cc:50
def move(src, dest)
Definition: eostools.py:510
signed short theNumberOfCCCBadHits_
Definition: Trajectory.h:374
static bool lost(const TrackingRecHit &hit)
Definition: Trajectory.cc:150