File indexing completed on 2024-05-23 03:13:38
0001 #ifndef CkfPattern_TempTrajectory_H
0002 #define CkfPattern_TempTrajectory_H
0003
0004 #include "TrackingTools/PatternTools/interface/TrajectoryMeasurement.h"
0005 #include "DataFormats/TrackCandidate/interface/TrajectoryStopReasons.h"
0006 #include "DataFormats/TrajectorySeed/interface/PropagationDirection.h"
0007 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0008 #include "DataFormats/Common/interface/OwnVector.h"
0009 #include "FWCore/Utilities/interface/Visibility.h"
0010
0011 #include <vector>
0012 #include <algorithm>
0013 #include <limits>
0014 #include "TrackingTools/PatternTools/interface/bqueue.h"
0015
0016 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 class TempTrajectory {
0041 public:
0042 typedef cmsutils::bqueue<TrajectoryMeasurement> DataContainer;
0043 typedef TrackingRecHit::ConstRecHitContainer ConstRecHitContainer;
0044 typedef ConstRecHitContainer RecHitContainer;
0045
0046 struct Payload {
0047 float theChiSquared = 0;
0048 float theDPhiCache = 0;
0049 float theCCCThreshold_ = std::numeric_limits<float>::max();
0050
0051 uint8_t theNumberOfFoundHits = 0;
0052 uint8_t theNumberOfFoundPixelHits = 0;
0053 uint8_t theNumberOfLostHits = 0;
0054 uint8_t theNumberOfTrailingFoundHits = 0;
0055 uint8_t theNumberOfCCCBadHits_ = 0;
0056
0057
0058 int8_t theDirection = anyDirection;
0059
0060 uint8_t theNHseed = 0;
0061 uint8_t theNLoops = 0;
0062 StopReason stopReason_ = StopReason::UNINITIALIZED;
0063 };
0064
0065
0066
0067
0068
0069
0070 TempTrajectory() {}
0071
0072
0073
0074
0075
0076 TempTrajectory(PropagationDirection dir, unsigned char nhseed) : thePayload(std::make_unique<Payload>()) {
0077 thePayload->theDirection = dir;
0078 thePayload->theNHseed = nhseed;
0079 }
0080
0081 TempTrajectory(TempTrajectory const& rh)
0082 : theData(rh.theData), thePayload(rh.thePayload ? std::make_unique<Payload>(*rh.thePayload) : nullptr) {}
0083
0084 TempTrajectory& operator=(TempTrajectory const& rh) {
0085 theData = rh.theData;
0086 thePayload = rh.thePayload ? std::make_unique<Payload>(*rh.thePayload) : nullptr;
0087 return *this;
0088 }
0089
0090 TempTrajectory(TempTrajectory&& rh) noexcept : theData(std::move(rh.theData)), thePayload(std::move(rh.thePayload)) {}
0091
0092 TempTrajectory& operator=(TempTrajectory&& rh) noexcept {
0093 using std::swap;
0094 swap(theData, rh.theData);
0095 swap(thePayload, rh.thePayload);
0096 return *this;
0097 }
0098
0099 void swap(TempTrajectory& rh) noexcept {
0100 using std::swap;
0101 swap(theData, rh.theData);
0102 swap(thePayload, rh.thePayload);
0103 }
0104
0105
0106 explicit TempTrajectory(Trajectory&& traj);
0107
0108
0109 ~TempTrajectory() = default;
0110
0111
0112
0113
0114
0115 void push(const TrajectoryMeasurement& tm) { push(tm, tm.estimate()); }
0116
0117 void push(TrajectoryMeasurement&& tm) { push(std::forward<TrajectoryMeasurement>(tm), tm.estimate()); }
0118
0119 template <typename... Args>
0120 void emplace(Args&&... args) {
0121 theData.emplace_back(std::forward<Args>(args)...);
0122 pushAux(theData.back().estimate());
0123 }
0124
0125
0126
0127
0128
0129
0130 void push(TempTrajectory const& segment);
0131
0132
0133
0134
0135
0136 void join(TempTrajectory& segment);
0137
0138
0139
0140
0141 void push(const TrajectoryMeasurement& tm, double chi2Increment) {
0142 theData.push_back(tm);
0143 pushAux(chi2Increment);
0144 }
0145
0146 void push(TrajectoryMeasurement&& tm, double chi2Increment) {
0147 theData.push_back(std::move(tm));
0148 pushAux(chi2Increment);
0149 }
0150
0151 template <typename... Args>
0152 void emplace(double chi2Increment, Args&&... args) {
0153 theData.emplace_back(std::forward<Args>(args)...);
0154 pushAux(chi2Increment);
0155 }
0156
0157
0158
0159 void pop();
0160
0161
0162
0163
0164
0165
0166 const TrajectoryMeasurement& lastMeasurement() const {
0167 check();
0168 return theData.back();
0169 }
0170
0171
0172
0173
0174
0175
0176
0177 const TrajectoryMeasurement& firstMeasurement() const {
0178 check();
0179 return theData.front();
0180 }
0181
0182
0183
0184 const DataContainer& measurements() const { return theData; }
0185
0186
0187
0188
0189
0190
0191 int foundHits() const { return thePayload->theNumberOfFoundHits; }
0192
0193
0194
0195 int foundPixelHits() const { return thePayload->theNumberOfFoundPixelHits; }
0196
0197
0198
0199
0200
0201 int lostHits() const { return thePayload->theNumberOfLostHits; }
0202
0203
0204
0205 int trailingFoundHits() const { return thePayload->theNumberOfTrailingFoundHits; }
0206
0207
0208
0209
0210
0211 int cccBadHits() const { return thePayload->theNumberOfCCCBadHits_; }
0212
0213
0214 unsigned int seedNHits() const { return thePayload->theNHseed; }
0215
0216
0217 bool empty() const { return theData.empty(); }
0218
0219
0220 float chiSquared() const { return thePayload->theChiSquared; }
0221
0222
0223
0224
0225
0226 PropagationDirection direction() const;
0227
0228
0229
0230
0231 bool isValid() const { return bool(thePayload); }
0232
0233
0234 void invalidate() { thePayload.reset(); }
0235
0236
0237
0238 static bool inactive(
0239 ) {
0240 return false;
0241 }
0242
0243
0244 const DetLayer* lastLayer() const {
0245 check();
0246 return theData.back().layer();
0247 }
0248
0249
0250 Trajectory toTrajectory() const;
0251
0252
0253 void popInvalidTail();
0254
0255
0256
0257 float dPhiCacheForLoopersReconstruction() const { return thePayload->theDPhiCache; }
0258
0259
0260
0261 void setDPhiCacheForLoopersReconstruction(float dphi) { thePayload->theDPhiCache = dphi; }
0262
0263 bool isLooper() const { return (thePayload->theNLoops > 0); }
0264 signed char nLoops() const { return thePayload->theNLoops; }
0265
0266 void setNLoops(int8_t value) { thePayload->theNLoops = value; }
0267 void incrementLoops() { thePayload->theNLoops++; }
0268
0269 StopReason stopReason() const { return thePayload->stopReason_; }
0270 void setStopReason(StopReason s) { thePayload->stopReason_ = s; }
0271
0272 int numberOfCCCBadHits(float ccc_threshold);
0273
0274 static bool lost(const TrackingRecHit& hit) dso_internal;
0275
0276 private:
0277
0278
0279
0280 bool badForCCC(const TrajectoryMeasurement& tm) dso_internal;
0281 void updateBadForCCC(float ccc_threshold) dso_internal;
0282
0283 void pushAux(double chi2Increment);
0284
0285 private:
0286 DataContainer theData;
0287 std::unique_ptr<Payload> thePayload;
0288
0289 void check() const;
0290 };
0291
0292 #endif