CMS 3D CMS Logo

TempTrajectory.cc
Go to the documentation of this file.
10 
11 namespace {
12  template<typename DataContainer>
13  unsigned short countTrailingValidHits(DataContainer const & meas) {
14  unsigned short n=0;
15  for(auto it=meas.rbegin(); it!=meas.rend(); --it) { // it is not consistent with std...
16  if (TempTrajectory::lost(*(*it).recHit())) break;
17  if((*it).recHit()->isValid()) ++n;
18  }
19  return n;
20  }
21 }
22 
24  theChiSquared(0),
25  theNumberOfFoundHits(0),
26  theNumberOfFoundPixelHits(0),
27  theNumberOfLostHits(0),
28  theNumberOfCCCBadHits_(0),
29  theDirection(traj.direction()),
30  theValid(traj.isValid()),
31  theNHseed(traj.seedNHits()),
32  theNLoops(traj.nLoops()),
33  theDPhiCache(traj.dPhiCacheForLoopersReconstruction()),
34  theCCCThreshold_(traj.cccThreshold()),
35  stopReason_(traj.stopReason()) {
36 
37  for(auto & it : traj.measurements()){
38  push(std::move(it));
39  }
40 
41 }
42 
43 
45  if (!empty()) {
46  if (theData.back().recHit()->isValid()) {
50  }
51  else if(lost(* (theData.back().recHit()) )) {theNumberOfLostHits--;}
52  theData.pop_back();
53  theNumberOfTrailingFoundHits=countTrailingValidHits(theData);
54  }
55 }
56 
57 
58 
59 void TempTrajectory::pushAux(double chi2Increment) {
60  const TrajectoryMeasurement& tm = theData.back();
61  if ( tm.recHit()->isValid()) {
66  }
67  //else if (lost( tm.recHit()) && !inactive(tm.recHit().det())) theNumberOfLostHits++;
68  else if (lost( *(tm.recHit()) ) ) { theNumberOfLostHits++; theNumberOfTrailingFoundHits=0;}
69 
70  theChiSquared += chi2Increment;
71 
72 }
73 
74 void TempTrajectory::push(const TempTrajectory& segment) {
75  assert (segment.theDirection == theDirection) ;
76  assert (segment.theCCCThreshold_ == theCCCThreshold_);
77 
78  const int N = segment.measurements().size();
79  TrajectoryMeasurement const * tmp[N];
80  int i=0;
81  //for (DataContainer::const_iterator it = segment.measurements().rbegin(), ed = segment.measurements().rend(); it != ed; --it)
82  for ( auto const & tm : segment.measurements())
83  tmp[i++] =&tm;
84  while(i!=0) theData.push_back(*tmp[--i]);
89  theNumberOfTrailingFoundHits=countTrailingValidHits(theData);
90  theChiSquared += segment.theChiSquared;
91 }
92 
94  assert (segment.theDirection == theDirection) ;
95 
96  if (theCCCThreshold_ != segment.theCCCThreshold_)
98  if (segment.theData.shared()) {
99  push(segment);
100  segment.theData.clear(); // obey the contract, and increase the chances it will be not shared one day
101  } else {
102  theData.join(segment.theData);
107  theNumberOfTrailingFoundHits=countTrailingValidHits(theData);
108  theChiSquared += segment.theChiSquared;
109  }
110 }
111 
112 
115 }
116 
117 void TempTrajectory::check() const {
118  if ( theData.size() == 0)
119  throw cms::Exception("TrackingTools/PatternTools","Trajectory::check() - information requested from empty Trajectory");
120 }
121 
123 {
124  if likely(hit.isValid()) return false;
125 
126  // // A DetLayer is always inactive in this logic.
127  // // The DetLayer is the Det of an invalid RecHit only if no DetUnit
128  // // is compatible with the predicted state, so we don't really expect
129  // // a hit in this case.
130 
131  if(hit.geographicalId().rawId() == 0) {return false;}
132  return hit.getType() == TrackingRecHit::missing;
133 }
134 
136  if (trackerHitRTTI::isUndef(*tm.recHit())) return false;
137  auto const * thit = static_cast<const BaseTrackerRecHit*>( tm.recHit()->hit() );
138  if (!thit)
139  return false;
140  if (thit->isPixel() || thit->isPhase2())
141  return false;
142  if (!tm.updatedState().isValid())
143  return false;
144  return siStripClusterTools::chargePerCM(thit->rawId(),
145  thit->firstClusterRef().stripCluster(),
147 }
148 
149 void TempTrajectory::updateBadForCCC(float ccc_threshold) {
150  // If the supplied threshold is the same as the currently cached
151  // one, then return the current number of bad hits for CCC,
152  // otherwise do a new full rescan.
153  if (ccc_threshold == theCCCThreshold_)
154  return;
155 
156  theCCCThreshold_ = ccc_threshold;
158  for (auto const & h : theData) {
159  if (badForCCC(h))
161  }
162 }
163 
164 int TempTrajectory::numberOfCCCBadHits(float ccc_threshold) {
165  updateBadForCCC(ccc_threshold);
166  return theNumberOfCCCBadHits_;
167 }
168 
171  Trajectory traj(p);
172  traj.setNLoops(theNLoops);
175 
176  traj.reserve(theData.size());
178  int i=0;
179  for (DataContainer::const_iterator it = theData.rbegin(), ed = theData.rend(); it != ed; --it)
180  tmp[i++] = &(*it);
181  while(i!=0) traj.push(*tmp[--i]);
182  return traj;
183 }
184 
signed short theNumberOfFoundHits
const_iterator rend() const
Definition: bqueue.h:164
ConstRecHitPointer const & recHit() const
void join(TempTrajectory &segment)
bool empty() const
True if trajectory has no measurements.
const LocalTrajectoryParameters & localParameters() const
void setStopReason(StopReason s)
Definition: Trajectory.h:352
signed short theNumberOfCCCBadHits_
const DataContainer & measurements() const
float chargePerCM(DetId detid, Iter a, Iter b)
void setNLoops(signed char value)
Definition: Trajectory.h:349
static bool lost(const TrackingRecHit &hit)
PropagationDirection
void reserve(unsigned int n)
Definition: Trajectory.h:150
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
PropagationDirection direction() const
DataContainer theData
#define likely(x)
StopReason stopReason_
bool shared()
Definition: bqueue.h:176
Trajectory toTrajectory() const
Convert to a standard Trajectory.
signed short theNumberOfLostHits
void check() const
void updateBadForCCC(float ccc_threshold)
void clear()
Definition: bqueue.h:201
static bool pixel(const TrackingRecHit &hit)
Definition: Trajectory.cc:177
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
int numberOfCCCBadHits(float ccc_threshold)
signed char theNLoops
bool isValid() const
signed short theNumberOfFoundPixelHits
bool badForCCC(const TrajectoryMeasurement &tm)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
int numberOfCCCBadHits(float ccc_threshold)
Definition: Trajectory.cc:215
void pop_back()
Definition: bqueue.h:151
signed short theNumberOfTrailingFoundHits
signed char theDirection
void join(bqueue< T > &other)
Definition: bqueue.h:186
bool isUndef(TrackingRecHit const &hit)
TrajectoryStateOnSurface const & updatedState() const
size_type size() const
Definition: bqueue.h:167
DetId geographicalId() const
void push(const TrajectoryMeasurement &tm)
Definition: Trajectory.cc:50
def move(src, dest)
Definition: eostools.py:510
void push_back(const T &val)
Definition: bqueue.h:133
void pushAux(double chi2Increment)
void push(const TrajectoryMeasurement &tm)