CMS 3D CMS Logo

DataFormats.cc
Go to the documentation of this file.
3 
4 #include <vector>
5 #include <deque>
6 #include <cmath>
7 #include <tuple>
8 #include <iterator>
9 #include <algorithm>
10 #include <string>
11 #include <iostream>
12 
13 using namespace std;
14 using namespace edm;
15 using namespace tt;
16 
17 namespace trackerTFP {
18 
19  // default constructor, trying to needs space as proper constructed object
20  DataFormats::DataFormats()
21  : numDataFormats_(0),
22  formats_(+Variable::end, std::vector<DataFormat*>(+Process::end, nullptr)),
23  numUnusedBitsStubs_(+Process::end, TTBV::S_),
24  numUnusedBitsTracks_(+Process::end, TTBV::S_),
25  numChannel_(+Process::end, 0) {
26  setup_ = nullptr;
27  countFormats();
29  numStreams_.reserve(+Process::end);
32  }
33 
34  // method to count number of unique data formats
35  template <Variable v, Process p>
37  if constexpr (config_[+v][+p] == p)
39  if constexpr (++p != Process::end)
40  countFormats<v, ++p>();
41  else if constexpr (++v != Variable::end)
42  countFormats<++v>();
43  }
44 
45  // proper constructor
47  iConfig_ = iConfig;
48  setup_ = setup;
50  for (const Process p : Processes)
51  for (const Variable v : stubs_[+p])
52  numUnusedBitsStubs_[+p] -= formats_[+v][+p] ? formats_[+v][+p]->width() : 0;
53  for (const Process p : Processes)
54  for (const Variable v : tracks_[+p])
55  numUnusedBitsTracks_[+p] -= formats_[+v][+p] ? formats_[+v][+p]->width() : 0;
64  transform(numChannel_.begin(), numChannel_.end(), back_inserter(numStreams_), [this](int channel) {
65  return channel * setup_->numRegions();
66  });
69  numStreamsTracks_ = vector<int>(+Process::end, 0);
72  }
73 
74  // constructs data formats of all unique used variables and flavours
75  template <Variable v, Process p>
77  if constexpr (config_[+v][+p] == p) {
78  dataFormats_.emplace_back(Format<v, p>(iConfig_, setup_));
79  fillFormats<v, p>();
80  }
81  if constexpr (++p != Process::end)
82  fillDataFormats<v, ++p>();
83  else if constexpr (++v != Variable::end)
84  fillDataFormats<++v>();
85  }
86 
87  // helper (loop) data formats of all unique used variables and flavours
88  template <Variable v, Process p, Process it>
90  if (config_[+v][+it] == p) {
91  formats_[+v][+it] = &dataFormats_.back();
92  }
93  if constexpr (++it != Process::end)
94  fillFormats<v, p, ++it>();
95  }
96 
97  // converts bits to ntuple of variables
98  template <typename... Ts>
99  void DataFormats::convertStub(Process p, const Frame& bv, tuple<Ts...>& data) const {
100  TTBV ttBV(bv);
101  extractStub(p, ttBV, data);
102  }
103 
104  // helper (loop) to convert bits to ntuple of variables
105  template <int it, typename... Ts>
106  void DataFormats::extractStub(Process p, TTBV& ttBV, std::tuple<Ts...>& data) const {
107  Variable v = *next(stubs_[+p].begin(), sizeof...(Ts) - 1 - it);
108  formats_[+v][+p]->extract(ttBV, get<sizeof...(Ts) - 1 - it>(data));
109  if constexpr (it + 1 != sizeof...(Ts))
110  extractStub<it + 1>(p, ttBV, data);
111  }
112 
113  // converts ntuple of variables to bits
114  template <typename... Ts>
115  void DataFormats::convertStub(Process p, const std::tuple<Ts...>& data, Frame& bv) const {
116  TTBV ttBV(1, numUnusedBitsStubs_[+p]);
117  attachStub(p, data, ttBV);
118  bv = ttBV.bs();
119  }
120 
121  // helper (loop) to convert ntuple of variables to bits
122  template <int it, typename... Ts>
123  void DataFormats::attachStub(Process p, const tuple<Ts...>& data, TTBV& ttBV) const {
124  Variable v = *next(stubs_[+p].begin(), it);
125  formats_[+v][+p]->attach(get<it>(data), ttBV);
126  if constexpr (it + 1 != sizeof...(Ts))
127  attachStub<it + 1>(p, data, ttBV);
128  }
129 
130  // converts bits to ntuple of variables
131  template <typename... Ts>
132  void DataFormats::convertTrack(Process p, const Frame& bv, tuple<Ts...>& data) const {
133  TTBV ttBV(bv);
134  extractTrack(p, ttBV, data);
135  }
136 
137  // helper (loop) to convert bits to ntuple of variables
138  template <int it, typename... Ts>
139  void DataFormats::extractTrack(Process p, TTBV& ttBV, std::tuple<Ts...>& data) const {
140  Variable v = *next(tracks_[+p].begin(), sizeof...(Ts) - 1 - it);
141  formats_[+v][+p]->extract(ttBV, get<sizeof...(Ts) - 1 - it>(data));
142  if constexpr (it + 1 != sizeof...(Ts))
143  extractTrack<it + 1>(p, ttBV, data);
144  }
145 
146  // converts ntuple of variables to bits
147  template <typename... Ts>
148  void DataFormats::convertTrack(Process p, const std::tuple<Ts...>& data, Frame& bv) const {
149  TTBV ttBV(1, numUnusedBitsTracks_[+p]);
150  attachTrack(p, data, ttBV);
151  bv = ttBV.bs();
152  }
153 
154  // helper (loop) to convert ntuple of variables to bits
155  template <int it, typename... Ts>
156  void DataFormats::attachTrack(Process p, const tuple<Ts...>& data, TTBV& ttBV) const {
157  Variable v = *next(tracks_[+p].begin(), it);
158  formats_[+v][+p]->attach(get<it>(data), ttBV);
159  if constexpr (it + 1 != sizeof...(Ts))
160  attachTrack<it + 1>(p, data, ttBV);
161  }
162 
163  // construct Stub from Frame
164  template <typename... Ts>
165  Stub<Ts...>::Stub(const FrameStub& frame, const DataFormats* dataFormats, Process p)
166  : dataFormats_(dataFormats), p_(p), frame_(frame), trackId_(0) {
167  dataFormats_->convertStub(p, frame.second, data_);
168  }
169 
170  // construct Stub from other Stub
171  template <typename... Ts>
172  template <typename... Others>
174  : dataFormats_(stub.dataFormats()),
175  p_(++stub.p()),
176  frame_(stub.frame().first, Frame()),
177  data_(data...),
178  trackId_(0) {}
179 
180  // construct Stub from TTStubRef
181  template <typename... Ts>
182  Stub<Ts...>::Stub(const TTStubRef& ttStubRef, const DataFormats* dataFormats, Process p, Ts... data)
183  : dataFormats_(dataFormats), p_(p), frame_(ttStubRef, Frame()), data_(data...), trackId_(0) {}
184 
185  // construct StubPP from Frame
186  StubPP::StubPP(const FrameStub& frame, const DataFormats* formats) : Stub(frame, formats, Process::pp) {
187  for (int sectorEta = sectorEtaMin(); sectorEta <= sectorEtaMax(); sectorEta++)
190  }
191 
192  // construct StubGP from Frame
193  StubGP::StubGP(const FrameStub& frame, const DataFormats* formats, int sectorPhi, int sectorEta)
194  : Stub(frame, formats, Process::gp), sectorPhi_(sectorPhi), sectorEta_(sectorEta) {
195  const Setup* setup = dataFormats_->setup();
196  inv2RBins_ = TTBV(0, setup->htNumBinsInv2R());
197  for (int inv2R = inv2RMin(); inv2R <= inv2RMax(); inv2R++)
199  }
200 
201  // construct StubGP from StubPP
202  StubGP::StubGP(const StubPP& stub, int sectorPhi, int sectorEta)
203  : Stub(stub, stub.r(), stub.phi(), stub.z(), stub.layer(), stub.inv2RMin(), stub.inv2RMax()),
204  sectorPhi_(sectorPhi),
205  sectorEta_(sectorEta) {
206  const Setup* setup = dataFormats_->setup();
207  get<1>(data_) -= (sectorPhi_ - .5) * setup->baseSector();
208  get<2>(data_) -= (r() + dataFormats_->chosenRofPhi()) * setup->sectorCot(sectorEta_);
210  }
211 
212  // construct StubHT from Frame
213  StubHT::StubHT(const FrameStub& frame, const DataFormats* formats, int inv2R)
214  : Stub(frame, formats, Process::ht), inv2R_(inv2R) {
215  fillTrackId();
216  }
217 
218  // construct StubHT from StubGP and HT cell assignment
219  StubHT::StubHT(const StubGP& stub, int phiT, int inv2R)
220  : Stub(stub, stub.r(), stub.phi(), stub.z(), stub.layer(), stub.sectorPhi(), stub.sectorEta(), phiT),
221  inv2R_(inv2R) {
222  get<1>(data_) -=
224  fillTrackId();
226  }
227 
229  TTBV ttBV(bv());
231  }
232 
233  // construct StubMHT from Frame
234  StubMHT::StubMHT(const FrameStub& frame, const DataFormats* formats) : Stub(frame, formats, Process::mht) {
235  fillTrackId();
236  }
237 
238  // construct StubMHT from StubHT and MHT cell assignment
239  StubMHT::StubMHT(const StubHT& stub, int phiT, int inv2R)
240  : Stub(stub,
241  stub.r(),
242  stub.phi(),
243  stub.z(),
244  stub.layer(),
245  stub.sectorPhi(),
246  stub.sectorEta(),
247  stub.phiT(),
248  stub.inv2R()) {
249  const Setup* setup = dataFormats_->setup();
250  // update track (phIT, inv2R), and phi residuals w.r.t. track, to reflect MHT cell assignment.
251  get<6>(data_) = this->phiT() * setup->mhtNumBinsPhiT() + phiT;
252  get<7>(data_) = this->inv2R() * setup->mhtNumBinsInv2R() + inv2R;
253  get<1>(data_) -= base(Variable::inv2R) * (inv2R - .5) * r() + base(Variable::phiT) * (phiT - .5);
255  fillTrackId();
256  }
257 
258  // fills track id
260  TTBV ttBV(bv());
263  }
264 
265  // construct StubZHT from Frame
266  StubZHT::StubZHT(const FrameStub& frame, const DataFormats* formats) : Stub(frame, formats, Process::zht) {
267  cot_ = 0.;
268  zT_ = 0.;
269  fillTrackId();
270  }
271 
272  // construct StubZHT from StubMHT
274  : Stub(stub,
275  stub.r(),
276  stub.phi(),
277  stub.z(),
278  stub.layer(),
279  stub.sectorPhi(),
280  stub.sectorEta(),
281  stub.phiT(),
282  stub.inv2R(),
283  0,
284  0) {
285  cot_ = 0.;
286  zT_ = 0.;
288  chi_ = stub.z();
289  trackId_ = stub.trackId();
290  }
291 
292  //
293  StubZHT::StubZHT(const StubZHT& stub, double zT, double cot, int id)
294  : Stub(stub.frame().first,
295  stub.dataFormats(),
296  Process::zht,
297  stub.r(),
298  stub.phi(),
299  stub.z(),
300  stub.layer(),
301  stub.sectorPhi(),
302  stub.sectorEta(),
303  stub.phiT(),
304  stub.inv2R(),
305  stub.zT(),
306  stub.cot()) {
307  // update track (zT, cot), and phi residuals w.r.t. track, to reflect ZHT cell assignment.
308  r_ = stub.r_;
309  cot_ = stub.cotf() + cot;
310  zT_ = stub.ztf() + zT;
311  chi_ = stub.z() - zT_ + r_ * cot_;
312  get<8>(data_) = format(Variable::zT).integer(zT_);
313  get<9>(data_) = format(Variable::cot).integer(cot_);
315  trackId_ = stub.trackId() * 4 + id;
316  }
317 
318  //
319  StubZHT::StubZHT(const StubZHT& stub, int cot, int zT)
320  : Stub(stub.frame().first,
321  stub.dataFormats(),
322  Process::zht,
323  stub.r(),
324  stub.phi(),
325  0.,
326  stub.layer(),
327  stub.sectorPhi(),
328  stub.sectorEta(),
329  stub.phiT(),
330  stub.inv2R(),
331  zT,
332  cot) {
333  get<2>(data_) =
335  .digi(stub.z() - (format(Variable::zT).floating(zT) - stub.r_ * format(Variable::cot).floating(cot)));
337  fillTrackId();
338  }
339 
340  // fills track id
342  TTBV ttBV(bv());
345  }
346 
347  // construct StubKFin from Frame
348  StubKFin::StubKFin(const FrameStub& frame, const DataFormats* formats, int layer)
349  : Stub(frame, formats, Process::kfin), layer_(layer) {}
350 
351  // construct StubKFin from StubZHT
352  StubKFin::StubKFin(const StubZHT& stub, double dPhi, double dZ, int layer)
353  : Stub(stub, stub.r(), stub.phi(), stub.z(), dPhi, dZ), layer_(layer) {
355  }
356 
357  // construct StubKFin from TTStubRef
358  StubKFin::StubKFin(const TTStubRef& ttStubRef,
359  const DataFormats* dataFormats,
360  double r,
361  double phi,
362  double z,
363  double dPhi,
364  double dZ,
365  int layer)
366  : Stub(ttStubRef, dataFormats, Process::kfin, r, phi, z, dPhi, dZ), layer_(layer) {
368  }
369 
370  // construct StubKF from Frame
371  StubKF::StubKF(const FrameStub& frame, const DataFormats* formats, int layer)
372  : Stub(frame, formats, Process::kf), layer_(layer) {}
373 
374  // construct StubKF from StubKFin
375  StubKF::StubKF(const StubKFin& stub, double inv2R, double phiT, double cot, double zT)
376  : Stub(stub, stub.r(), 0., 0., stub.dPhi(), stub.dZ()), layer_(stub.layer()) {
377  const Setup* setup = dataFormats_->setup();
378  get<1>(data_) = format(Variable::phi).digi(stub.phi() - (phiT + this->r() * inv2R));
379  const double d =
380  (dataFormats_->hybrid() ? setup->hybridChosenRofPhi() : setup->chosenRofPhi()) - setup->chosenRofZ();
381  const double rz = format(Variable::r).digi(this->r() + d);
382  get<2>(data_) = format(Variable::z).digi(stub.z() - (zT + rz * cot));
384  }
385 
386  // construct Track from Frame
387  template <typename... Ts>
389  : dataFormats_(dataFormats), p_(p), frame_(frame) {
390  dataFormats_->convertTrack(p_, frame.second, data_);
391  }
392 
393  // construct Track from other Track
394  template <typename... Ts>
395  template <typename... Others>
397  : dataFormats_(track.dataFormats()), p_(++track.p()), frame_(track.frame().first, Frame()), data_(data...) {}
398 
399  // construct Track from Stub
400  template <typename... Ts>
401  template <typename... Others>
402  Track<Ts...>::Track(const Stub<Others...>& stub, const TTTrackRef& ttTrackRef, Ts... data)
403  : dataFormats_(stub.dataFormats()), p_(++stub.p()), frame_(ttTrackRef, Frame()), data_(data...) {}
404 
405  // construct Track from TTTrackRef
406  template <typename... Ts>
407  Track<Ts...>::Track(const TTTrackRef& ttTrackRef, const DataFormats* dataFormats, Process p, Ts... data)
408  : dataFormats_(dataFormats), p_(p), frame_(ttTrackRef, Frame()), data_(data...) {}
409 
410  // construct TrackKFin from Frame
411  TrackKFin::TrackKFin(const FrameTrack& frame, const DataFormats* dataFormats, const vector<StubKFin*>& stubs)
412  : Track(frame, dataFormats, Process::kfin), stubs_(setup()->numLayers()), hitPattern_(0, setup()->numLayers()) {
413  vector<int> nStubs(stubs_.size(), 0);
414  for (StubKFin* stub : stubs)
415  nStubs[stub->layer()]++;
416  for (int layer = 0; layer < dataFormats->setup()->numLayers(); layer++)
417  stubs_[layer].reserve(nStubs[layer]);
418  for (StubKFin* stub : stubs) {
419  const int layer = stub->layer();
420  stubs_[layer].push_back(stub);
422  }
423  }
424 
425  // construct TrackKFin from StubZHT
426  TrackKFin::TrackKFin(const StubZHT& stub, const TTTrackRef& ttTrackRef, const TTBV& maybePattern)
427  : Track(stub, ttTrackRef, maybePattern, stub.sectorPhi(), stub.sectorEta(), 0., 0., 0., 0.),
428  stubs_(setup()->numLayers()),
429  hitPattern_(0, setup()->numLayers()) {
430  get<3>(data_) = format(Variable::phiT, Process::mht).floating(stub.phiT());
432  get<5>(data_) = format(Variable::zT, Process::zht).floating(stub.zT());
433  get<6>(data_) = format(Variable::cot, Process::zht).floating(stub.cot());
435  }
436 
437  // construct TrackKFin from TTTrackRef
438  TrackKFin::TrackKFin(const TTTrackRef& ttTrackRef,
439  const DataFormats* dataFormats,
440  const TTBV& maybePattern,
441  double phiT,
442  double inv2R,
443  double zT,
444  double cot,
445  int sectorPhi,
446  int sectorEta)
447  : Track(ttTrackRef, dataFormats, Process::kfin, maybePattern, sectorPhi, sectorEta, phiT, inv2R, zT, cot),
448  stubs_(setup()->numLayers()),
449  hitPattern_(0, setup()->numLayers()) {
451  }
452 
453  vector<TTStubRef> TrackKFin::ttStubRefs(const TTBV& hitPattern, const vector<int>& layerMap) const {
454  vector<TTStubRef> stubs;
455  stubs.reserve(hitPattern.count());
456  for (int layer = 0; layer < setup()->numLayers(); layer++)
457  if (hitPattern[layer])
458  stubs.push_back(stubs_[layer][layerMap[layer]]->ttStubRef());
459  return stubs;
460  }
461 
462  // construct TrackKF from Frame
463  TrackKF::TrackKF(const FrameTrack& frame, const DataFormats* dataFormats) : Track(frame, dataFormats, Process::kf) {}
464 
465  // construct TrackKF from TrackKfin
466  TrackKF::TrackKF(const TrackKFin& track, double phiT, double inv2R, double zT, double cot)
467  : Track(
471  get<3>(data_) += phiT;
472  get<4>(data_) += inv2R;
473  get<5>(data_) += cot;
474  get<6>(data_) += zT;
476  }
477 
478  // conversion to TTTrack with given stubs
479  TTTrack<Ref_Phase2TrackerDigi_> TrackKF::ttTrack(const vector<StubKF>& stubs) const {
480  const double invR = -this->inv2R() * 2.;
481  const double phi0 =
482  deltaPhi(this->phiT() - this->inv2R() * dataFormats_->chosenRofPhi() +
483  setup()->baseSector() * (this->sectorPhi() - .5) + setup()->baseRegion() * frame_.first->phiSector());
484  const double cot = this->cot() + setup()->sectorCot(this->sectorEta());
485  const double z0 = this->zT() - this->cot() * setup()->chosenRofZ();
486  TTBV hitVector(0, setup()->numLayers());
487  double chi2phi(0.);
488  double chi2z(0.);
489  vector<TTStubRef> ttStubRefs;
490  const int nLayer = stubs.size();
491  ttStubRefs.reserve(nLayer);
492  for (const StubKF& stub : stubs) {
493  hitVector.set(stub.layer());
494  const TTStubRef& ttStubRef = stub.ttStubRef();
495  chi2phi += pow(stub.phi(), 2) / setup()->v0(ttStubRef, this->inv2R());
496  chi2z += pow(stub.z(), 2) / setup()->v1(ttStubRef, cot);
497  ttStubRefs.push_back(ttStubRef);
498  }
499  static constexpr int nPar = 4;
500  static constexpr double d0 = 0.;
501  static constexpr double trkMVA1 = 0.;
502  static constexpr double trkMVA2 = 0.;
503  static constexpr double trkMVA3 = 0.;
504  const int hitPattern = hitVector.val();
505  const double bField = setup()->bField();
507  invR, phi0, cot, z0, d0, chi2phi, chi2z, trkMVA1, trkMVA2, trkMVA3, hitPattern, nPar, bField);
508  ttTrack.setStubRefs(ttStubRefs);
509  ttTrack.setPhiSector(frame_.first->phiSector());
510  ttTrack.setEtaSector(this->sectorEta());
511  ttTrack.setTrackSeedType(frame_.first->trackSeedType());
512  ttTrack.setStubPtConsistency(StubPtConsistency::getConsistency(
513  ttTrack, setup()->trackerGeometry(), setup()->trackerTopology(), bField, nPar));
514  return ttTrack;
515  }
516 
517  // construct TrackDR from Frame
518  TrackDR::TrackDR(const FrameTrack& frame, const DataFormats* dataFormats) : Track(frame, dataFormats, Process::dr) {}
519 
520  // construct TrackDR from TrackKF
521  TrackDR::TrackDR(const TrackKF& track) : Track(track, 0., 0., 0., 0.) {
522  get<0>(data_) = track.phiT() + track.inv2R() * dataFormats_->chosenRofPhi() +
523  dataFormats_->format(Variable::phi, Process::gp).range() * (track.sectorPhi() - .5);
524  get<1>(data_) = track.inv2R();
525  get<2>(data_) = track.zT() - track.cot() * setup()->chosenRofZ();
526  get<3>(data_) = track.cot() + setup()->sectorCot(track.sectorEta());
528  }
529 
530  // conversion to TTTrack
532  const double inv2R = this->inv2R();
533  const double phi0 = this->phi0();
534  const double cot = this->cot();
535  const double z0 = this->z0();
536  static constexpr double d0 = 0.;
537  static constexpr double chi2phi = 0.;
538  static constexpr double chi2z = 0;
539  static constexpr double trkMVA1 = 0.;
540  static constexpr double trkMVA2 = 0.;
541  static constexpr double trkMVA3 = 0.;
542  static constexpr int hitPattern = 0.;
543  static constexpr int nPar = 4;
544  static constexpr double bField = 0.;
545  const int sectorPhi = frame_.first->phiSector();
546  const int sectorEta = frame_.first->etaSector();
548  inv2R, phi0, cot, z0, d0, chi2phi, chi2z, trkMVA1, trkMVA2, trkMVA3, hitPattern, nPar, bField);
549  ttTrack.setPhiSector(sectorPhi);
550  ttTrack.setEtaSector(sectorEta);
551  return ttTrack;
552  }
553 
554  template <>
556  range_ = 2. * M_PI / (double)(setup->numRegions() * setup->numSectorsPhi());
557  base_ = range_ / (double)setup->htNumBinsPhiT();
558  width_ = ceil(log2(setup->htNumBinsPhiT()));
559  }
560 
561  template <>
564  range_ = ht.range();
565  base_ = ht.base() / setup->mhtNumBinsPhiT();
566  width_ = ceil(log2(setup->htNumBinsPhiT() * setup->mhtNumBinsPhiT()));
567  }
568 
569  template <>
571  const double mintPt = iConfig.getParameter<bool>("UseHybrid") ? setup->hybridMinPtCand() : setup->minPt();
572  range_ = 2. * setup->invPtToDphi() / mintPt;
573  base_ = range_ / (double)setup->htNumBinsInv2R();
574  width_ = ceil(log2(setup->htNumBinsInv2R()));
575  }
576 
577  template <>
580  range_ = ht.range();
581  base_ = ht.base() / setup->mhtNumBinsInv2R();
582  width_ = ceil(log2(setup->htNumBinsInv2R() * setup->mhtNumBinsInv2R()));
583  }
584 
585  template <>
587  const double chosenRofPhi =
588  iConfig.getParameter<bool>("UseHybrid") ? setup->hybridChosenRofPhi() : setup->chosenRofPhi();
589  width_ = setup->tmttWidthR();
590  range_ = 2. * max(abs(setup->outerRadius() - chosenRofPhi), abs(setup->innerRadius() - chosenRofPhi));
593  base_ = phiT.base() / inv2R.base();
594  const int shift = ceil(log2(range_ / base_ / pow(2., width_)));
595  base_ *= pow(2., shift);
596  }
597 
598  template <>
602  const Format<Variable::r, Process::ht> r(iConfig, setup);
603  range_ = phiT.range() + inv2R.range() * r.base() * pow(2., r.width()) / 4.;
605  base_ = dtc.base();
606  width_ = ceil(log2(range_ / base_));
607  }
608 
609  template <>
611  width_ = setup->tmttWidthPhi();
614  const Format<Variable::r, Process::ht> r(iConfig, setup);
615  range_ = 2. * M_PI / (double)setup->numRegions() + inv2R.range() * r.base() * pow(2., r.width()) / 4.;
616  const int shift = ceil(log2(range_ / phiT.base() / pow(2., width_)));
617  base_ = phiT.base() * pow(2., shift);
618  }
619 
620  template <>
623  range_ = 2. * phiT.base();
625  base_ = gp.base();
626  width_ = ceil(log2(range_ / base_));
627  }
628 
629  template <>
632  range_ = 2. * phiT.base();
634  base_ = ht.base();
635  width_ = ceil(log2(range_ / base_));
636  }
637 
638  template <>
641  const double rangeFactor = iConfig.getParameter<ParameterSet>("KalmanFilter").getParameter<double>("RangeFactor");
642  range_ = rangeFactor * phi.range();
643  base_ = phi.base();
644  width_ = ceil(log2(range_ / base_));
645  }
646 
647  template <>
649  width_ = setup->tmttWidthZ();
650  range_ = 2. * setup->halfLength();
651  const Format<Variable::r, Process::ht> r(iConfig, setup);
652  const int shift = ceil(log2(range_ / r.base())) - width_;
653  base_ = r.base() * pow(2., shift);
654  }
655 
656  template <>
658  range_ = setup->neededRangeChiZ();
660  base_ = dtc.base();
661  width_ = ceil(log2(range_ / base_));
662  }
663 
664  template <>
666  const int numBinsZT = iConfig.getParameter<ParameterSet>("ZHoughTransform").getParameter<int>("NumBinsZT");
667  const int numStages = iConfig.getParameter<ParameterSet>("ZHoughTransform").getParameter<int>("NumStages");
668  width_ = ceil(log2(pow(numBinsZT, numStages)));
669  const Format<Variable::z, Process::dtc> z(iConfig, setup);
670  range_ = -1.;
671  for (int eta = 0; eta < setup->numSectorsEta(); eta++)
672  range_ = max(range_, (sinh(setup->boundarieEta(eta + 1)) - sinh(setup->boundarieEta(eta))));
673  range_ *= setup->chosenRofZ();
674  const int shift = ceil(log2(range_ / z.base() / pow(2., width_)));
675  base_ = z.base() * pow(2., shift);
676  }
677 
678  template <>
680  const int numBinsCot = iConfig.getParameter<ParameterSet>("ZHoughTransform").getParameter<int>("NumBinsCot");
681  const int numStages = iConfig.getParameter<ParameterSet>("ZHoughTransform").getParameter<int>("NumStages");
682  width_ = ceil(log2(pow(numBinsCot, numStages)));
684  range_ = (zT.range() + 2. * setup->beamWindowZ()) / setup->chosenRofZ();
685  const int shift = ceil(log2(range_)) - width_;
686  base_ = pow(2., shift);
687  }
688 
689  template <>
693  const double rangeR =
694  2. * max(abs(setup->outerRadius() - setup->chosenRofZ()), abs(setup->innerRadius() - setup->chosenRofZ()));
695  range_ = zT.base() + cot.base() * rangeR + setup->maxdZ();
697  base_ = dtc.base();
698  width_ = ceil(log2(range_ / base_));
699  /*const Format<Variable::z, Process::gp> z(iConfig, setup);
700  width_ = z.width();
701  range_ = z.range();
702  base_ = z.base();*/
703  }
704 
705  template <>
708  range_ = zht.range() * pow(2, setup->kfinShiftRangeZ());
709  base_ = zht.base();
710  width_ = ceil(log2(range_ / base_));
711  }
712 
713  template <>
717  const double chosenRofPhi =
718  iConfig.getParameter<bool>("UseHybrid") ? setup->hybridChosenRofPhi() : setup->chosenRofPhi();
719  const double rangeR = 2. * max(abs(setup->outerRadius() - chosenRofPhi), abs(setup->innerRadius() - chosenRofPhi));
720  range_ = phiT.base() + inv2R.base() * rangeR + setup->maxdPhi();
722  base_ = dtc.base();
723  width_ = ceil(log2(range_ / base_));
724  }
725 
726  template <>
729  range_ = zht.range() * pow(2, setup->kfinShiftRangePhi());
730  base_ = zht.base();
731  width_ = ceil(log2(range_ / base_));
732  }
733 
734  template <>
736  /*const Format<Variable::z, Process::zht> z(iConfig, setup);
737  const double rangeFactor = iConfig.getParameter<ParameterSet>("KalmanFilter").getParameter<double>("RangeFactor");
738  range_ = rangeFactor * z.range();
739  base_ = z.base();
740  width_ = ceil(log2(range_ / base_));*/
743  const double rangeR =
744  2. * max(abs(setup->outerRadius() - setup->chosenRofZ()), abs(setup->innerRadius() - setup->chosenRofZ()));
745  range_ = zT.base() + cot.base() * rangeR + setup->maxdZ();
747  base_ = dtc.base();
748  const double rangeFactor = iConfig.getParameter<ParameterSet>("KalmanFilter").getParameter<double>("RangeFactor");
749  range_ *= rangeFactor;
750  width_ = ceil(log2(range_ / base_));
751  }
752 
753  template <>
755  range_ = setup->numLayers();
756  width_ = ceil(log2(range_));
757  }
758 
759  template <>
761  : DataFormat(false) {
762  range_ = setup->numSectorsEta();
763  width_ = ceil(log2(range_));
764  }
765 
766  template <>
768  : DataFormat(false) {
769  range_ = setup->numSectorsPhi();
770  width_ = ceil(log2(range_));
771  }
772 
773  template <>
775  : DataFormat(false) {
776  range_ = setup->numSectorsPhi();
777  width_ = setup->numSectorsPhi();
778  }
779 
780  template <>
782  : DataFormat(false) {
783  width_ = 1;
784  range_ = 1.;
785  }
786 
787  template <>
789  : DataFormat(false) {
790  width_ = setup->numLayers();
791  }
792 
793  template <>
797  const double chosenRofPhi =
798  iConfig.getParameter<bool>("UseHybrid") ? setup->hybridChosenRofPhi() : setup->chosenRofPhi();
799  width_ = setup->tfpWidthPhi0();
800  range_ = 2. * M_PI / (double)setup->numRegions() + inv2R.range() * chosenRofPhi;
801  base_ = phiT.base();
802  const int shift = ceil(log2(range_ / base_ / pow(2., width_)));
803  base_ *= pow(2., shift);
804  }
805 
806  template <>
808  : DataFormat(true) {
810  width_ = setup->tfpWidthInv2R();
811  range_ = inv2R.range();
812  base_ = inv2R.base();
813  const int shift = ceil(log2(range_ / base_ / pow(2., width_)));
814  base_ *= pow(2., shift);
815  }
816 
817  template <>
820  width_ = setup->tfpWidthZ0();
821  range_ = 2. * setup->beamWindowZ();
822  base_ = zT.base();
823  const int shift = ceil(log2(range_ / base_ / pow(2., width_)));
824  base_ *= pow(2., shift);
825  }
826 
827  template <>
830  width_ = setup->tfpWidthCot();
831  range_ = 2. * setup->maxCot();
832  base_ = cot.base();
833  const int shift = ceil(log2(range_ / base_ / pow(2., width_)));
834  base_ *= pow(2., shift);
835  }
836 
837  template <>
841  const double rangeFactor = iConfig.getParameter<ParameterSet>("KalmanFilter").getParameter<double>("RangeFactor");
842  range_ = rangeFactor * phiT.range();
843  base_ = phi0.base();
844  width_ = ceil(log2(range_ / base_));
845  }
846 
847  template <>
849  : DataFormat(true) {
852  const double rangeFactor = iConfig.getParameter<ParameterSet>("KalmanFilter").getParameter<double>("RangeFactor");
853  range_ = mht.range() + rangeFactor * mht.base();
854  base_ = dr.base();
855  width_ = ceil(log2(range_ / base_));
856  }
857 
858  template <>
862  const double rangeFactor = iConfig.getParameter<ParameterSet>("KalmanFilter").getParameter<double>("RangeFactor");
863  range_ = zT.range() + rangeFactor * zT.base();
864  base_ = z0.base();
865  width_ = ceil(log2(range_ / base_));
866  }
867 
868  template <>
872  const double rangeFactor = iConfig.getParameter<ParameterSet>("KalmanFilter").getParameter<double>("RangeFactor");
873  range_ = zht.range() + rangeFactor * zht.base();
874  base_ = dr.base();
875  width_ = ceil(log2(range_ / base_));
876  }
877 
878  template <>
880  : DataFormat(false) {
882  range_ = setup->maxdPhi();
883  base_ = phi.base();
884  width_ = ceil(log2(range_ / base_));
885  }
886 
887  template <>
889  : DataFormat(false) {
891  range_ = setup->maxdZ();
892  base_ = z.base();
893  width_ = ceil(log2(range_ / base_));
894  }
895 
896 } // namespace trackerTFP
double cot() const
Definition: DataFormats.h:968
int inv2R() const
Definition: DataFormats.h:764
constexpr std::initializer_list< Process > Processes
Definition: DataFormats.h:53
double zT() const
Definition: DataFormats.h:970
constexpr int32_t ceil(float num)
double extract(double base, int size, bool twos=false)
Definition: TTBV.h:276
double phiT() const
Definition: DataFormats.h:964
std::bitset< TTBV::S_ > Frame
Definition: TTTypes.h:58
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
static const char layer_[]
StubGP(const tt::FrameStub &frame, const DataFormats *dataFormats, int sectorPhi, int sectorEta)
Definition: DataFormats.cc:193
TTTrack< Ref_Phase2TrackerDigi_ > ttTrack(const std::vector< StubKF > &stubs) const
Definition: DataFormats.cc:479
int trackId() const
Definition: DataFormats.h:582
int sectorEtaMax() const
Definition: DataFormats.h:626
double base() const
Definition: DataFormats.h:117
std::vector< int > numUnusedBitsStubs_
Definition: DataFormats.h:543
const tt::Setup * setup_
Definition: DataFormats.h:537
double chosenRofZ() const
Definition: Setup.h:413
Bit vector used by Track Trigger emulators. Mainly used to convert integers into arbitrary (within ma...
Definition: TTBV.h:20
std::pair< TTStubRef, Frame > FrameStub
Definition: TTTypes.h:60
Class to process and provide run-time constants used by Track Trigger emulators.
Definition: Setup.h:44
double v1(const TTStubRef &ttStubRef, double cot) const
Definition: Setup.cc:625
int phiT() const
Definition: DataFormats.h:762
double z() const
Definition: DataFormats.h:806
const std::bitset< S_ > & bs() const
Definition: TTBV.h:71
double r() const
Definition: DataFormats.h:716
int htNumBinsInv2R() const
Definition: Setup.h:435
double cotf() const
Definition: DataFormats.h:769
void convertStub(Process p, const tt::Frame &bv, std::tuple< Ts... > &data) const
void extractStub(Process p, TTBV &ttBV, std::tuple< Ts... > &data) const
Definition: DataFormats.cc:106
int numDTCsPerRegion() const
Definition: Setup.h:351
StubZHT(const tt::FrameStub &frame, const DataFormats *dataFormats)
Definition: DataFormats.cc:266
std::vector< std::vector< StubKFin * > > stubs_
Definition: DataFormats.h:944
int phiT() const
Definition: DataFormats.h:698
int inv2R() const
Definition: DataFormats.h:684
void extractTrack(Process p, TTBV &ttBV, std::tuple< Ts... > &data) const
Definition: DataFormats.cc:139
std::vector< int > numStreamsTracks_
Definition: DataFormats.h:553
Format(const edm::ParameterSet &iConfig, const tt::Setup *setup)
TTBV sectorsPhi() const
Definition: DataFormats.h:622
Track(const tt::FrameTrack &frame, const DataFormats *dataFormats, Process p)
Definition: DataFormats.cc:388
double chosenRofPhi() const
Definition: DataFormats.h:508
int integer(double d) const
Definition: DataFormats.h:96
StubHT(const tt::FrameStub &frame, const DataFormats *dataFormats, int inv2R)
Definition: DataFormats.cc:213
std::pair< TTTrackRef, Frame > FrameTrack
Definition: TTTypes.h:62
double v0(const TTStubRef &ttStubRef, double inv2R) const
Definition: Setup.cc:613
StubKFin(const tt::FrameStub &frame, const DataFormats *dataFormats, int layer)
Definition: DataFormats.cc:348
int sectorPhi() const
Definition: DataFormats.h:960
int numSectors() const
Definition: Setup.h:426
Definition: TTTypes.h:54
TTBV hitPattern() const
Definition: DataFormats.h:926
int size() const
Definition: TTBV.h:69
double inv2R() const
Definition: DataFormats.h:966
double inv2R() const
Definition: DataFormats.h:1043
TrackDR(const tt::FrameTrack &frame, const DataFormats *dataFormats)
Definition: DataFormats.cc:518
int kfNumWorker() const
Definition: Setup.h:487
double baseSector() const
Definition: Setup.h:420
double r() const
Definition: DataFormats.h:686
double r() const
Definition: DataFormats.h:750
double floating(int i) const
Definition: DataFormats.h:94
double phi0() const
Definition: DataFormats.h:1041
int sectorEta() const
Definition: DataFormats.h:962
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double range() const
Definition: DataFormats.h:119
int count() const
Definition: TTBV.h:88
void attachTrack(Process p, const std::tuple< Ts... > &data, TTBV &ttBV) const
TTBV & set()
Definition: TTBV.h:187
d
Definition: ztail.py:151
TrackKFin(const tt::FrameTrack &frame, const DataFormats *dataFormats, const std::vector< StubKFin *> &stubs)
Definition: DataFormats.cc:411
static constexpr std::array< std::initializer_list< Variable >,+Process::end > stubs_
Definition: DataFormats.h:393
double bField() const
Definition: Setup.h:204
int inv2RMin() const
Definition: DataFormats.h:662
int numLayers() const
Definition: Setup.h:215
double hybridChosenRofPhi() const
Definition: Setup.h:266
#define M_PI
int numDTCsPerTFP() const
Definition: Setup.h:375
int mhtNumBinsInv2R() const
Definition: Setup.h:446
int sectorEtaMin() const
Definition: DataFormats.h:624
int inv2RMax() const
Definition: DataFormats.h:664
std::vector< std::vector< DataFormat * > > formats_
Definition: DataFormats.h:541
static constexpr float d0
static constexpr std::array< std::array< Process,+Process::end >,+Variable::end > config_
Definition: DataFormats.h:219
double r() const
Definition: DataFormats.h:828
const tt::Setup * setup() const
Definition: DataFormats.h:488
void attachStub(Process p, const std::tuple< Ts... > &data, TTBV &ttBV) const
double z() const
Definition: DataFormats.h:720
int inv2R() const
Definition: DataFormats.h:730
Class to store the L1 Track Trigger tracks.
Definition: TTTrack.h:29
edm::ParameterSet iConfig_
Definition: DataFormats.h:535
int val() const
Definition: TTBV.h:259
void convertTrack(Process p, const tt::Frame &bv, std::tuple< Ts... > &data) const
double r() const
Definition: DataFormats.h:654
std::vector< DataFormat > dataFormats_
Definition: DataFormats.h:539
double ztf() const
Definition: DataFormats.h:770
StubMHT(const tt::FrameStub &frame, const DataFormats *dataFormats)
Definition: DataFormats.cc:234
int numRegions() const
Definition: Setup.h:345
std::vector< TTStubRef > ttStubRefs(const TTBV &hitPattern, const std::vector< int > &layerMap) const
Definition: DataFormats.cc:453
TTTrack< Ref_Phase2TrackerDigi_ > ttTrack() const
Definition: DataFormats.cc:531
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
TrackKF(const tt::FrameTrack &frame, const DataFormats *dataFormats)
Definition: DataFormats.cc:463
int mhtNumBinsPhiT() const
Definition: Setup.h:448
static constexpr std::array< std::initializer_list< Variable >,+Process::end > tracks_
Definition: DataFormats.h:444
static unsigned int const shift
StubKF(const tt::FrameStub &frame, const DataFormats *dataFormats, int layer)
Definition: DataFormats.cc:371
void setTrackSeedType(int aSeed)
Definition: TTTrack.h:144
std::vector< int > numUnusedBitsTracks_
Definition: DataFormats.h:545
double z0() const
Definition: DataFormats.h:1045
std::vector< int > numStreamsStubs_
Definition: DataFormats.h:551
Class to calculate and provide dataformats used by Track Trigger emulator.
Definition: DataFormats.h:216
double baseRegion() const
Definition: Setup.h:184
std::vector< std::vector< StubKFin * > > stubs() const
Definition: DataFormats.h:938
double digi(double d) const
Definition: DataFormats.h:98
double sectorCot(int eta) const
Definition: Setup.h:428
std::vector< int > numChannel_
Definition: DataFormats.h:547
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
double cot() const
Definition: DataFormats.h:1047
double z() const
Definition: DataFormats.h:754
double phi() const
Definition: DataFormats.h:804
int phiT() const
Definition: DataFormats.h:728
const DataFormat & format(Variable v, Process p) const
Definition: DataFormats.h:506
std::vector< int > numStreams_
Definition: DataFormats.h:549
float getConsistency(TTTrack< Ref_Phase2TrackerDigi_ > aTrack, const TrackerGeometry *theTrackerGeom, const TrackerTopology *tTopo, double mMagneticFieldStrength, int nPar)
unsigned transform(const HcalDetId &id, unsigned transformCode)