CMS 3D CMS Logo

State.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 using namespace tt;
5 
6 namespace trackerTFP {
7 
8  // default constructor
10  : dataFormats_(state->dataFormats_),
11  setup_(state->setup_),
12  track_(state->track_),
13  trackId_(state->trackId_),
14  parent_(state->parent_),
15  stub_(state->stub_),
16  layerMap_(state->layerMap_),
17  hitPattern_(state->hitPattern_),
18  x0_(state->x0_),
19  x1_(state->x1_),
20  x2_(state->x2_),
21  x3_(state->x3_),
22  C00_(state->C00_),
23  C01_(state->C01_),
24  C11_(state->C11_),
25  C22_(state->C22_),
26  C23_(state->C23_),
27  C33_(state->C33_),
28  numSkippedLayers_(state->numSkippedLayers_),
29  numConsistentLayers_(state->numConsistentLayers_) {}
30 
31  // proto state constructor
32  State::State(const DataFormats* dataFormats, TrackKFin* track, int trackId)
33  : dataFormats_(dataFormats),
34  setup_(dataFormats->setup()),
35  track_(track),
36  trackId_(trackId),
37  parent_(nullptr),
38  stub_(nullptr),
39  layerMap_(setup_->numLayers()),
40  hitPattern_(0, setup_->numLayers()),
41  numSkippedLayers_(0),
42  numConsistentLayers_(0) {
43  // initial track parameter residuals w.r.t. found track
44  x0_ = 0.;
45  x1_ = 0.;
46  x2_ = 0.;
47  x3_ = 0.;
48  // initial uncertainties
53  C01_ = 0.;
54  C23_ = 0.;
55  // first stub from first layer on input track with stubs
57  }
58 
59  // combinatoric state constructor
61  parent_ = state->parent();
62  stub_ = stub;
63  }
64 
65  // updated state constructor
66  State::State(State* state, const std::vector<double>& doubles) : State(state) {
67  parent_ = state;
68  // updated track parameter and uncertainties
69  x0_ = doubles[0];
70  x1_ = doubles[1];
71  x2_ = doubles[2];
72  x3_ = doubles[3];
73  C00_ = doubles[4];
74  C11_ = doubles[5];
75  C22_ = doubles[6];
76  C33_ = doubles[7];
77  C01_ = doubles[8];
78  C23_ = doubles[9];
79  // update maps
80  const int layer = stub_->layer();
82  const vector<StubKFin*>& stubs = track_->layerStubs(layer);
83  layerMap_[layer] = distance(stubs.begin(), find(stubs.begin(), stubs.end(), stub_));
84  // pick next stub (first stub in next layer with stub)
85  stub_ = nullptr;
86  if (hitPattern_.count() == setup_->kfMaxLayers())
87  return;
88  for (int nextLayer = layer + 1; nextLayer < setup_->numLayers(); nextLayer++) {
89  if (track_->hitPattern(nextLayer)) {
90  stub_ = track_->layerStub(nextLayer);
91  break;
92  }
93  }
94  }
95 
96  // fills collection of stubs added so far to state
97  void State::fill(vector<StubKF>& stubs) const {
98  stubs.reserve(hitPattern_.count());
99  State* s = parent_;
100  while (s) {
101  stubs.emplace_back(*(s->stub()), x0_, x1_, x2_, x3_);
102  s = s->parent();
103  }
104  }
105 
106  // Determine quality of completed state
107  void State::finish() {
108  auto consistent = [this](int sum, const StubKF& stub) {
111  // Check stub consistent with helix, allowing for stub uncertainty
112  const bool inRange0 = 2. * abs(stub.phi()) - stub.dPhi() < phi.base();
113  const bool inRange1 = 2. * abs(stub.z()) - stub.dZ() < z.base();
114  return sum + (inRange0 && inRange1 ? 1 : 0);
115  };
116  vector<StubKF> stubs;
117  fill(stubs);
118  numConsistentLayers_ = accumulate(stubs.begin(), stubs.end(), 0, consistent);
120  pattern |= maybePattern();
121  // Skipped layers before final stub on state
122  numSkippedLayers_ = pattern.count(0, hitPattern_.pmEncode(), false);
123  }
124 
125 } // namespace trackerTFP
double dPhi() const
Definition: DataFormats.h:808
StubKFin * layerStub(int layer) const
Definition: DataFormats.h:934
double base(Variable v, Process p) const
Definition: DataFormats.h:492
double C22_
Definition: State.h:119
int plEncode(bool b=true) const
Definition: TTBV.h:306
StubKFin * stub_
Definition: State.h:100
Bit vector used by Track Trigger emulators. Mainly used to convert integers into arbitrary (within ma...
Definition: TTBV.h:20
double z() const
Definition: DataFormats.h:806
double x3_
Definition: State.h:112
constexpr int pow(int x)
Definition: conifer.h:24
TrackKFin * track_
Definition: State.h:94
int numSkippedLayers_
Definition: State.h:124
double C33_
Definition: State.h:121
ROOT::VecOps::RVec< double > doubles
Definition: Resolutions.cc:7
double x0_
Definition: State.h:106
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
double C23_
Definition: State.h:120
void finish()
Definition: State.cc:107
std::vector< int > layerMap_
Definition: State.h:102
int kfMaxLayers() const
Definition: Setup.h:491
Definition: TTTypes.h:54
TTBV hitPattern() const
Definition: DataFormats.h:926
TTBV hitPattern_
Definition: State.h:104
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const DataFormats * dataFormats_
Definition: State.h:90
int count() const
Definition: TTBV.h:88
const tt::Setup * setup_
Definition: State.h:92
double C01_
Definition: State.h:117
double x2_
Definition: State.h:110
void fill(std::vector< StubKF > &stubs) const
Definition: State.cc:97
TTBV & set()
Definition: TTBV.h:187
int numLayers() const
Definition: Setup.h:215
int layer() const
Definition: State.h:46
TrackKFin * track() const
Definition: State.h:32
double C00_
Definition: State.h:116
StubKFin * stub() const
Definition: State.h:36
int numConsistentLayers_
Definition: State.h:126
std::vector< StubKFin * > layerStubs(int layer) const
Definition: DataFormats.h:932
TTBV maybePattern() const
Definition: State.h:42
double dZ() const
Definition: DataFormats.h:810
double x1_
Definition: State.h:108
double C11_
Definition: State.h:118
State * parent_
Definition: State.h:98
Class to calculate and provide dataformats used by Track Trigger emulator.
Definition: DataFormats.h:216
int pmEncode(bool b=true) const
Definition: TTBV.h:314
State(State *state)
Definition: State.cc:9
double phi() const
Definition: DataFormats.h:804
const DataFormat & format(Variable v, Process p) const
Definition: DataFormats.h:506