CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TempTrajectory.cc
Go to the documentation of this file.
4 
5 
7  theChiSquared(0),
8  theNumberOfFoundHits(0), theNumberOfLostHits(0),
9  theDirection(traj.direction()), theDirectionValidity(true),
10  theValid(traj.isValid()),
11  theNLoops(traj.nLoops()),
12  theDPhiCache(traj.dPhiCacheForLoopersReconstruction()) {
13 
14  Trajectory::DataContainer::const_iterator begin=traj.measurements().begin();
15  Trajectory::DataContainer::const_iterator end=traj.measurements().end();
16 
17  for(Trajectory::DataContainer::const_iterator it=begin; it!=end; ++it){
18  push(std::move(*it));
19  }
20 
21 }
22 
23 
24 
26  if (!empty()) {
27  if (theData.back().recHit()->isValid()) theNumberOfFoundHits--;
28  else if(lost(* (theData.back().recHit()) )) theNumberOfLostHits--;
29  theData.pop_back();
30  }
31 }
32 
33 
34 
35 void TempTrajectory::pushAux(double chi2Increment) {
36  const TrajectoryMeasurement& tm = theData.back();
37  if ( tm.recHit()->isValid()) {
39  }
40  //else if (lost( tm.recHit()) && !inactive(tm.recHit().det())) theNumberOfLostHits++;
41  else if (lost( *(tm.recHit()) ) ) theNumberOfLostHits++;
42 
43 
44  theChiSquared += chi2Increment;
45 
46  // in case of a Trajectory constructed without direction,
47  // determine direction from the radii of the first two measurements
48 
49  if ( !theDirectionValidity && theData.size() >= 2) {
54  theDirectionValidity = true;
55  }
56 }
57 
58 void TempTrajectory::push(const TempTrajectory& segment) {
59  assert (segment.theDirection == theDirection) ;
60  assert(theDirectionValidity); // given the above...
61 
62  const int N = segment.measurements().size();
63  TrajectoryMeasurement const * tmp[N];
64  int i=0;
65  //for (DataContainer::const_iterator it = segment.measurements().rbegin(), ed = segment.measurements().rend(); it != ed; --it)
66  for ( auto const & tm : segment.measurements())
67  tmp[i++] =&tm;
68  while(i!=0) theData.push_back(*tmp[--i]);
71  theChiSquared += segment.theChiSquared;
72 }
73 
75  assert (segment.theDirection == theDirection) ;
76  assert(theDirectionValidity);
77 
78  if (segment.theData.shared()) {
79  push(segment);
80  segment.theData.clear(); // obey the contract, and increase the chances it will be not shared one day
81  } else {
82  theData.join(segment.theData);
85  theChiSquared += segment.theChiSquared;
86  }
87 }
88 
89 
92  else throw cms::Exception("TrackingTools/PatternTools","Trajectory::direction() requested but not set");
93 }
94 
95 void TempTrajectory::check() const {
96  if ( theData.size() == 0)
97  throw cms::Exception("TrackingTools/PatternTools","Trajectory::check() - information requested from empty Trajectory");
98 }
99 
101 {
102  if likely(hit.isValid()) return false;
103 
104  // // A DetLayer is always inactive in this logic.
105  // // The DetLayer is the Det of an invalid RecHit only if no DetUnit
106  // // is compatible with the predicted state, so we don't really expect
107  // // a hit in this case.
108 
109  if(hit.geographicalId().rawId() == 0) {return false;}
110  return hit.getType() == TrackingRecHit::missing;
111 }
112 
114  assert(theDirectionValidity);
116  Trajectory traj(p);
117  traj.setNLoops(theNLoops);
118 
119  traj.reserve(theData.size());
121  int i=0;
122  for (DataContainer::const_iterator it = theData.rbegin(), ed = theData.rend(); it != ed; --it)
123  tmp[i++] = &(*it);
124  while(i!=0) traj.push(*tmp[--i]);
125  return traj;
126 }
127 
signed short theNumberOfFoundHits
const_iterator rend() const
Definition: bqueue.h:164
int i
Definition: DBlmapReader.cc:9
ConstRecHitPointer const & recHit() const
void join(TempTrajectory &segment)
bool empty() const
True if trajectory has no measurements.
const DataContainer & measurements() const
void setNLoops(signed char value)
Definition: Trajectory.h:332
GlobalPoint globalPosition() const
T perp2() const
Definition: PV3DBase.h:71
PropagationDirection
void reserve(unsigned int n)
Definition: Trajectory.h:155
const T & front() const
Definition: bqueue.h:159
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
PropagationDirection direction() const
DataContainer theData
bool shared()
Definition: bqueue.h:176
Trajectory toTrajectory() const
Convert to a standard Trajectory.
signed short theNumberOfLostHits
void check() const
void clear()
Definition: bqueue.h:201
#define end
Definition: vmac.h:37
const T & back() const
Definition: bqueue.h:161
const_iterator rbegin() const
Definition: bqueue.h:163
Type getType() const
#define N
Definition: blowfish.cc:9
signed char theNLoops
bool isValid() const
static bool lost(const TrackingRecHit &hit) dso_internal
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
#define likely(x)
Definition: Likely.h:20
#define begin
Definition: vmac.h:30
void pop_back()
Definition: bqueue.h:151
signed char theDirection
void join(bqueue< T > &other)
Definition: bqueue.h:186
TrajectoryStateOnSurface const & updatedState() const
size_type size() const
Definition: bqueue.h:167
DetId geographicalId() const
void push(const TrajectoryMeasurement &tm)
Definition: Trajectory.cc:30
void push_back(const T &val)
Definition: bqueue.h:133
void pushAux(double chi2Increment)
void push(const TrajectoryMeasurement &tm)