CMS 3D CMS Logo

TempTrajectory.cc
Go to the documentation of this file.
11 
12 namespace {
13  template <typename DataContainer>
14  unsigned short countTrailingValidHits(DataContainer const& meas) {
15  unsigned short n = 0;
16  for (auto it = meas.rbegin(); it != meas.rend(); --it) { // it is not consistent with std...
17  if (TempTrajectory::lost(*(*it).recHit()))
18  break;
19  if ((*it).recHit()->isValid())
20  ++n;
21  }
22  return n;
23  }
24 } // namespace
25 
27  : theChiSquared(0),
28  theNumberOfFoundHits(0),
29  theNumberOfFoundPixelHits(0),
30  theNumberOfLostHits(0),
31  theNumberOfCCCBadHits_(0),
32  theDirection(traj.direction()),
33  theValid(traj.isValid()),
34  theNHseed(traj.seedNHits()),
35  theNLoops(traj.nLoops()),
36  theDPhiCache(traj.dPhiCacheForLoopersReconstruction()),
37  theCCCThreshold_(traj.cccThreshold()),
38  stopReason_(traj.stopReason()) {
39  for (auto& it : traj.measurements()) {
40  push(it);
41  }
42  traj.measurements().clear();
43 }
44 
46  if (!empty()) {
47  if (theData.back().recHit()->isValid()) {
49  if (badForCCC(theData.back()))
53  } else if (lost(*(theData.back().recHit()))) {
55  }
56  theData.pop_back();
57  theNumberOfTrailingFoundHits = countTrailingValidHits(theData);
58  }
59 }
60 
61 void TempTrajectory::pushAux(double chi2Increment) {
62  const TrajectoryMeasurement& tm = theData.back();
63  if (tm.recHit()->isValid()) {
66  if (badForCCC(tm))
68  if (Trajectory::pixel(*(tm.recHit())))
70  }
71  //else if (lost( tm.recHit()) && !inactive(tm.recHit().det())) theNumberOfLostHits++;
72  else if (lost(*(tm.recHit()))) {
75  }
76 
77  theChiSquared += chi2Increment;
78 }
79 
80 void TempTrajectory::push(const TempTrajectory& segment) {
81  assert(segment.theDirection == theDirection);
83 
84  const int N = segment.measurements().size();
85  TrajectoryMeasurement const* tmp[N];
86  int i = 0;
87  //for (DataContainer::const_iterator it = segment.measurements().rbegin(), ed = segment.measurements().rend(); it != ed; --it)
88  for (auto const& tm : segment.measurements())
89  tmp[i++] = &tm;
90  while (i != 0)
91  theData.push_back(*tmp[--i]);
96  theNumberOfTrailingFoundHits = countTrailingValidHits(theData);
97  theChiSquared += segment.theChiSquared;
98 }
99 
101  assert(segment.theDirection == theDirection);
102 
103  if (theCCCThreshold_ != segment.theCCCThreshold_)
105  if (segment.theData.shared()) {
106  push(segment);
107  segment.theData.clear(); // obey the contract, and increase the chances it will be not shared one day
108  } else {
109  theData.join(segment.theData);
114  theNumberOfTrailingFoundHits = countTrailingValidHits(theData);
115  theChiSquared += segment.theChiSquared;
116  }
117 }
118 
120 
121 void TempTrajectory::check() const {
122  if (theData.size() == 0)
123  throw cms::Exception("TrackingTools/PatternTools",
124  "Trajectory::check() - information requested from empty Trajectory");
125 }
126 
128  if LIKELY (hit.isValid())
129  return false;
130 
131  // // A DetLayer is always inactive in this logic.
132  // // The DetLayer is the Det of an invalid RecHit only if no DetUnit
133  // // is compatible with the predicted state, so we don't really expect
134  // // a hit in this case.
135 
136  if (hit.geographicalId().rawId() == 0) {
137  return false;
138  }
139  return hit.getType() == TrackingRecHit::missing;
140 }
141 
143  if (!trackerHitRTTI::isFromDet(*tm.recHit()))
144  return false;
145  auto const* thit = static_cast<const BaseTrackerRecHit*>(tm.recHit()->hit());
146  if (!thit)
147  return false;
148  if (thit->isPixel() || thit->isPhase2())
149  return false;
150  if (!tm.updatedState().isValid())
151  return false;
152  return siStripClusterTools::chargePerCM(thit->rawId(),
153  thit->firstClusterRef().stripCluster(),
155 }
156 
157 void TempTrajectory::updateBadForCCC(float ccc_threshold) {
158  // If the supplied threshold is the same as the currently cached
159  // one, then return the current number of bad hits for CCC,
160  // otherwise do a new full rescan.
161  if (ccc_threshold == theCCCThreshold_)
162  return;
163 
164  theCCCThreshold_ = ccc_threshold;
166  for (auto const& h : theData) {
167  if (badForCCC(h))
169  }
170 }
171 
172 int TempTrajectory::numberOfCCCBadHits(float ccc_threshold) {
173  updateBadForCCC(ccc_threshold);
174  return theNumberOfCCCBadHits_;
175 }
176 
179  Trajectory traj(p);
180  traj.setNLoops(theNLoops);
183 
184  traj.reserve(theData.size());
186  int i = 0;
187  for (DataContainer::const_iterator it = theData.rbegin(), ed = theData.rend(); it != ed; --it)
188  tmp[i++] = &(*it);
189  while (i != 0)
190  traj.push(*tmp[--i]);
191  return traj;
192 }
signed short theNumberOfFoundHits
PropagationDirection direction() const
const_iterator rbegin() const
Definition: bqueue.h:197
void join(TempTrajectory &segment)
const T & back() const
Definition: bqueue.h:195
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
bool isFromDet(TrackingRecHit const &hit)
void setStopReason(StopReason s)
Definition: Trajectory.h:334
signed short theNumberOfCCCBadHits_
float chargePerCM(DetId detid, Iter a, Iter b)
void setNLoops(signed char value)
Definition: Trajectory.h:331
#define LIKELY(x)
Definition: Likely.h:20
const LocalTrajectoryParameters & localParameters() const
static bool lost(const TrackingRecHit &hit)
PropagationDirection
void reserve(unsigned int n)
Definition: Trajectory.h:126
const DataContainer & measurements() const
assert(be >=bs)
DataContainer theData
StopReason stopReason_
bool shared()
Definition: bqueue.h:211
signed short theNumberOfLostHits
void updateBadForCCC(float ccc_threshold)
void clear()
Definition: bqueue.h:235
static bool pixel(const TrackingRecHit &hit)
Definition: Trajectory.cc:175
void check() const
#define N
Definition: blowfish.cc:9
Trajectory toTrajectory() const
Convert to a standard Trajectory.
size_type size() const
Definition: bqueue.h:201
int numberOfCCCBadHits(float ccc_threshold)
signed char theNLoops
signed short theNumberOfFoundPixelHits
bool badForCCC(const TrajectoryMeasurement &tm)
TrajectoryStateOnSurface const & updatedState() const
int numberOfCCCBadHits(float ccc_threshold)
Definition: Trajectory.cc:212
void pop_back()
Definition: bqueue.h:184
signed short theNumberOfTrailingFoundHits
signed char theDirection
const_iterator rend() const
Definition: bqueue.h:198
void join(bqueue< T > &other)
Definition: bqueue.h:220
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
tmp
align.sh
Definition: createJobs.py:716
void push(const TrajectoryMeasurement &tm)
Definition: Trajectory.cc:50
void push_back(const T &val)
Definition: bqueue.h:160
ConstRecHitPointer const & recHit() const
void pushAux(double chi2Increment)
bool empty() const
True if trajectory has no measurements.
void push(const TrajectoryMeasurement &tm)