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 
26 TempTrajectory::TempTrajectory(Trajectory&& traj) : thePayload(std::make_unique<Payload>()) {
27  assert(traj.isValid());
28  thePayload->theDirection = traj.direction();
29  thePayload->theNHseed = traj.seedNHits();
30  thePayload->theNLoops = traj.nLoops();
31  thePayload->theDPhiCache = traj.dPhiCacheForLoopersReconstruction();
32  thePayload->theCCCThreshold_ = traj.cccThreshold();
33  thePayload->stopReason_ = traj.stopReason();
34  for (auto& it : traj.measurements()) {
35  push(it);
36  }
37  traj.measurements().clear();
38 }
39 
41  if (!empty()) {
42  if (theData.back().recHit()->isValid()) {
43  thePayload->theNumberOfFoundHits--;
44  if (badForCCC(theData.back()))
45  thePayload->theNumberOfCCCBadHits_--;
47  thePayload->theNumberOfFoundPixelHits--;
48  } else if (lost(*(theData.back().recHit()))) {
49  thePayload->theNumberOfLostHits--;
50  }
51  theData.pop_back();
52  thePayload->theNumberOfTrailingFoundHits = countTrailingValidHits(theData);
53  }
54 }
55 
56 void TempTrajectory::pushAux(double chi2Increment) {
57  const TrajectoryMeasurement& tm = theData.back();
58  if (tm.recHit()->isValid()) {
59  thePayload->theNumberOfFoundHits++;
60  thePayload->theNumberOfTrailingFoundHits++;
61  if (badForCCC(tm))
62  thePayload->theNumberOfCCCBadHits_++;
63  if (Trajectory::pixel(*(tm.recHit())))
64  thePayload->theNumberOfFoundPixelHits++;
65  }
66  //else if (lost( tm.recHit()) && !inactive(tm.recHit().det())) theNumberOfLostHits++;
67  else if (lost(*(tm.recHit()))) {
68  thePayload->theNumberOfLostHits++;
69  thePayload->theNumberOfTrailingFoundHits = 0;
70  }
71 
72  thePayload->theChiSquared += chi2Increment;
73 }
74 
75 void TempTrajectory::push(const TempTrajectory& segment) {
76  assert(segment.thePayload->theDirection == thePayload->theDirection);
77  assert(segment.thePayload->theCCCThreshold_ == thePayload->theCCCThreshold_);
78 
79  const int N = segment.measurements().size();
80  TrajectoryMeasurement const* tmp[N];
81  int i = 0;
82  //for (DataContainer::const_iterator it = segment.measurements().rbegin(), ed = segment.measurements().rend(); it != ed; --it)
83  for (auto const& tm : segment.measurements())
84  tmp[i++] = &tm;
85  while (i != 0)
86  theData.push_back(*tmp[--i]);
87  thePayload->theNumberOfFoundHits += segment.thePayload->theNumberOfFoundHits;
88  thePayload->theNumberOfFoundPixelHits += segment.thePayload->theNumberOfFoundPixelHits;
89  thePayload->theNumberOfLostHits += segment.thePayload->theNumberOfLostHits;
90  thePayload->theNumberOfCCCBadHits_ += segment.thePayload->theNumberOfCCCBadHits_;
91  thePayload->theNumberOfTrailingFoundHits = countTrailingValidHits(theData);
92  thePayload->theChiSquared += segment.thePayload->theChiSquared;
93 }
94 
96  assert(segment.thePayload->theDirection == thePayload->theDirection);
97 
98  if (thePayload->theCCCThreshold_ != segment.thePayload->theCCCThreshold_)
99  segment.updateBadForCCC(thePayload->theCCCThreshold_);
100  if (segment.theData.shared()) {
101  push(segment);
102  segment.theData.clear(); // obey the contract, and increase the chances it will be not shared one day
103  } else {
104  theData.join(segment.theData);
105  thePayload->theNumberOfFoundHits += segment.thePayload->theNumberOfFoundHits;
106  thePayload->theNumberOfFoundPixelHits += segment.thePayload->theNumberOfFoundPixelHits;
107  thePayload->theNumberOfLostHits += segment.thePayload->theNumberOfLostHits;
108  thePayload->theNumberOfCCCBadHits_ += segment.thePayload->theNumberOfCCCBadHits_;
109  thePayload->theNumberOfTrailingFoundHits = countTrailingValidHits(theData);
110  thePayload->theChiSquared += segment.thePayload->theChiSquared;
111  }
112 }
113 
115 
116 void TempTrajectory::check() const {
117  if (theData.empty())
118  throw cms::Exception("TrackingTools/PatternTools",
119  "Trajectory::check() - information requested from empty Trajectory");
120 }
121 
123  if LIKELY (hit.isValid())
124  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) {
132  return false;
133  }
134  return hit.getType() == TrackingRecHit::missing;
135 }
136 
138  if (!trackerHitRTTI::isFromDet(*tm.recHit()))
139  return false;
140  auto const* thit = static_cast<const BaseTrackerRecHit*>(tm.recHit()->hit());
141  if (!thit)
142  return false;
143  if (thit->isPixel() || thit->isPhase2())
144  return false;
145  if (!tm.updatedState().isValid())
146  return false;
147  return siStripClusterTools::chargePerCM(thit->rawId(),
148  thit->firstClusterRef().stripCluster(),
149  tm.updatedState().localParameters()) < thePayload->theCCCThreshold_;
150 }
151 
152 void TempTrajectory::updateBadForCCC(float ccc_threshold) {
153  // If the supplied threshold is the same as the currently cached
154  // one, then return the current number of bad hits for CCC,
155  // otherwise do a new full rescan.
156  if (ccc_threshold == thePayload->theCCCThreshold_)
157  return;
158 
159  thePayload->theCCCThreshold_ = ccc_threshold;
160  thePayload->theNumberOfCCCBadHits_ = 0;
161  for (auto const& h : theData) {
162  if (badForCCC(h))
163  thePayload->theNumberOfCCCBadHits_++;
164  }
165 }
166 
167 int TempTrajectory::numberOfCCCBadHits(float ccc_threshold) {
168  updateBadForCCC(ccc_threshold);
169  return thePayload->theNumberOfCCCBadHits_;
170 }
171 
173  assert(isValid());
175  Trajectory traj(p);
176  traj.setNLoops(thePayload->theNLoops);
177  traj.setStopReason(thePayload->stopReason_);
178  traj.numberOfCCCBadHits(thePayload->theCCCThreshold_);
179 
180  traj.reserve(theData.size());
182  int i = 0;
183  for (DataContainer::const_iterator it = theData.rbegin(), ed = theData.rend(); it != ed; --it)
184  tmp[i++] = &(*it);
185  while (i != 0)
186  traj.push(*tmp[--i]);
187  return traj;
188 }
PropagationDirection direction() const
const_iterator rbegin() const
Definition: bqueue.h:198
void join(TempTrajectory &segment)
const T & back() const
Definition: bqueue.h:196
bool isFromDet(TrackingRecHit const &hit)
void setStopReason(StopReason s)
Definition: Trajectory.h:334
float chargePerCM(DetId detid, Iter a, Iter b)
#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
bool shared()
Definition: bqueue.h:212
bool isValid() const
void updateBadForCCC(float ccc_threshold)
void clear()
Definition: bqueue.h:236
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:202
int numberOfCCCBadHits(float ccc_threshold)
void setNLoops(int8_t value)
Definition: Trajectory.h:331
bool empty() const
Definition: bqueue.h:203
bool badForCCC(const TrajectoryMeasurement &tm)
TrajectoryStateOnSurface const & updatedState() const
int numberOfCCCBadHits(float ccc_threshold)
Definition: Trajectory.cc:212
void pop_back()
Definition: bqueue.h:185
std::unique_ptr< Payload > thePayload
const_iterator rend() const
Definition: bqueue.h:199
void join(bqueue< T > &other)
Definition: bqueue.h:221
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
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
void push(const TrajectoryMeasurement &tm)
Definition: Trajectory.cc:50
void push_back(const T &val)
Definition: bqueue.h:161
ConstRecHitPointer const & recHit() const
void pushAux(double chi2Increment)
bool empty() const
True if trajectory has no measurements.
void push(const TrajectoryMeasurement &tm)