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_->kfMinLayers())
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  // collection of stubs added so far to state
97  vector<StubKF> State::stubs() const {
98  vector<StubKF> stubs;
99  stubs.reserve(hitPattern_.count());
100  State* s = parent_;
101  while (s) {
102  stubs.emplace_back(*(s->stub()), x0_, x1_, x2_, x3_);
103  s = s->parent();
104  }
105  return stubs;
106  }
107 
108  // Determine quality of completed state
109  void State::finish() {
110  const vector<StubKF>& stubs = this->stubs();
111  auto consistent = [this](int& sum, const StubKF& stub) {
112  auto inConsistentRange = [](float v, float r, float d) { return abs(v) <= (r + d) / 2.; };
113  // Check stub consistent with helix, allowing for stub & digi uncertainty
114  const bool inRange0 =
115  inConsistentRange(stub.phi(), stub.dPhi(), dataFormats_->format(Variable::dPhi, Process::kf).base());
116  const bool inRange1 =
117  inConsistentRange(stub.z(), stub.dZ(), dataFormats_->format(Variable::dZ, Process::kf).base());
118  return sum += (inRange0 && inRange1 ? 1 : 0);
119  };
120  numConsistentLayers_ = accumulate(stubs.begin(), stubs.end(), 0, consistent);
122  pattern |= maybePattern();
123  // Skipped layers before final stub on state
124  numSkippedLayers_ = pattern.count(0, hitPattern_.pmEncode(), false);
125  }
126 
127 } // 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
double base() const
Definition: DataFormats.h:117
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
TrackKFin * track_
Definition: State.h:94
int numSkippedLayers_
Definition: State.h:124
double C33_
Definition: State.h:121
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:109
int kfMinLayers() const
Definition: Setup.h:489
std::vector< int > layerMap_
Definition: State.h:102
Definition: TTTypes.h:54
TTBV hitPattern() const
Definition: DataFormats.h:926
TTBV hitPattern_
Definition: State.h:104
std::vector< StubKF > stubs() const
Definition: State.cc:97
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
TTBV & set()
Definition: TTBV.h:187
d
Definition: ztail.py:151
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
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
double phi() const
Definition: DataFormats.h:804
const DataFormat & format(Variable v, Process p) const
Definition: DataFormats.h:506