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  // Print digi data format of all variables of any specified algo step
73  //for (const Variable v : tracks_[+Process::kf]) {
74  // const DataFormat& f = format(v, Process::kf);
75  // cout <<" KF "<< f.base() << " " << f.range() << " " << f.width() << endl;
76  //}
77  }
78 
79  // constructs data formats of all unique used variables and flavours
80  template <Variable v, Process p>
82  if constexpr (config_[+v][+p] == p) {
83  dataFormats_.emplace_back(Format<v, p>(iConfig_, setup_));
84  fillFormats<v, p>();
85  }
86  if constexpr (++p != Process::end)
87  fillDataFormats<v, ++p>();
88  else if constexpr (++v != Variable::end)
89  fillDataFormats<++v>();
90  }
91 
92  // helper (loop) data formats of all unique used variables and flavours
93  template <Variable v, Process p, Process it>
95  if (config_[+v][+it] == p) {
96  formats_[+v][+it] = &dataFormats_.back();
97  }
98  if constexpr (++it != Process::end)
99  fillFormats<v, p, ++it>();
100  }
101 
102  // converts bits to ntuple of variables
103  template <typename... Ts>
104  void DataFormats::convertStub(Process p, const Frame& bv, tuple<Ts...>& data) const {
105  TTBV ttBV(bv);
106  extractStub(p, ttBV, data);
107  }
108 
109  // helper (loop) to convert bits to ntuple of variables
110  template <int it, typename... Ts>
111  void DataFormats::extractStub(Process p, TTBV& ttBV, std::tuple<Ts...>& data) const {
112  Variable v = *next(stubs_[+p].begin(), sizeof...(Ts) - 1 - it);
113  formats_[+v][+p]->extract(ttBV, get<sizeof...(Ts) - 1 - it>(data));
114  if constexpr (it + 1 != sizeof...(Ts))
115  extractStub<it + 1>(p, ttBV, data);
116  }
117 
118  // converts ntuple of variables to bits
119  template <typename... Ts>
120  void DataFormats::convertStub(Process p, const std::tuple<Ts...>& data, Frame& bv) const {
121  TTBV ttBV(1, numUnusedBitsStubs_[+p]);
122  attachStub(p, data, ttBV);
123  bv = ttBV.bs();
124  }
125 
126  // helper (loop) to convert ntuple of variables to bits
127  template <int it, typename... Ts>
128  void DataFormats::attachStub(Process p, const tuple<Ts...>& data, TTBV& ttBV) const {
129  Variable v = *next(stubs_[+p].begin(), it);
130  formats_[+v][+p]->attach(get<it>(data), ttBV);
131  if constexpr (it + 1 != sizeof...(Ts))
132  attachStub<it + 1>(p, data, ttBV);
133  }
134 
135  // converts bits to ntuple of variables
136  template <typename... Ts>
137  void DataFormats::convertTrack(Process p, const Frame& bv, tuple<Ts...>& data) const {
138  TTBV ttBV(bv);
139  extractTrack(p, ttBV, data);
140  }
141 
142  // helper (loop) to convert bits to ntuple of variables
143  template <int it, typename... Ts>
144  void DataFormats::extractTrack(Process p, TTBV& ttBV, std::tuple<Ts...>& data) const {
145  Variable v = *next(tracks_[+p].begin(), sizeof...(Ts) - 1 - it);
146  formats_[+v][+p]->extract(ttBV, get<sizeof...(Ts) - 1 - it>(data));
147  if constexpr (it + 1 != sizeof...(Ts))
148  extractTrack<it + 1>(p, ttBV, data);
149  }
150 
151  // converts ntuple of variables to bits
152  template <typename... Ts>
153  void DataFormats::convertTrack(Process p, const std::tuple<Ts...>& data, Frame& bv) const {
154  TTBV ttBV(1, numUnusedBitsTracks_[+p]);
155  attachTrack(p, data, ttBV);
156  bv = ttBV.bs();
157  }
158 
159  // helper (loop) to convert ntuple of variables to bits
160  template <int it, typename... Ts>
161  void DataFormats::attachTrack(Process p, const tuple<Ts...>& data, TTBV& ttBV) const {
162  Variable v = *next(tracks_[+p].begin(), it);
163  formats_[+v][+p]->attach(get<it>(data), ttBV);
164  if constexpr (it + 1 != sizeof...(Ts))
165  attachTrack<it + 1>(p, data, ttBV);
166  }
167 
168  // construct Stub from Frame
169  template <typename... Ts>
170  Stub<Ts...>::Stub(const FrameStub& frame, const DataFormats* dataFormats, Process p)
171  : dataFormats_(dataFormats), p_(p), frame_(frame), trackId_(0) {
172  dataFormats_->convertStub(p, frame.second, data_);
173  }
174 
175  // construct Stub from other Stub
176  template <typename... Ts>
177  template <typename... Others>
179  : dataFormats_(stub.dataFormats()),
180  p_(++stub.p()),
181  frame_(stub.frame().first, Frame()),
182  data_(data...),
183  trackId_(0) {}
184 
185  // construct Stub from TTStubRef
186  template <typename... Ts>
187  Stub<Ts...>::Stub(const TTStubRef& ttStubRef, const DataFormats* dataFormats, Process p, Ts... data)
188  : dataFormats_(dataFormats), p_(p), frame_(ttStubRef, Frame()), data_(data...), trackId_(0) {}
189 
190  // construct StubPP from Frame
191  StubPP::StubPP(const FrameStub& frame, const DataFormats* formats) : Stub(frame, formats, Process::pp) {
192  for (int sectorEta = sectorEtaMin(); sectorEta <= sectorEtaMax(); sectorEta++)
195  }
196 
197  // construct StubGP from Frame
198  StubGP::StubGP(const FrameStub& frame, const DataFormats* formats, int sectorPhi, int sectorEta)
199  : Stub(frame, formats, Process::gp), sectorPhi_(sectorPhi), sectorEta_(sectorEta) {
200  const Setup* setup = dataFormats_->setup();
201  inv2RBins_ = TTBV(0, setup->htNumBinsInv2R());
202  for (int inv2R = inv2RMin(); inv2R <= inv2RMax(); inv2R++)
204  }
205 
206  // construct StubGP from StubPP
207  StubGP::StubGP(const StubPP& stub, int sectorPhi, int sectorEta)
208  : Stub(stub, stub.r(), stub.phi(), stub.z(), stub.layer(), stub.inv2RMin(), stub.inv2RMax()),
209  sectorPhi_(sectorPhi),
210  sectorEta_(sectorEta) {
211  const Setup* setup = dataFormats_->setup();
212  get<1>(data_) -= (sectorPhi_ - .5) * setup->baseSector();
213  get<2>(data_) -= (r() + dataFormats_->chosenRofPhi()) * setup->sectorCot(sectorEta_);
215  }
216 
217  // construct StubHT from Frame
218  StubHT::StubHT(const FrameStub& frame, const DataFormats* formats, int inv2R)
219  : Stub(frame, formats, Process::ht), inv2R_(inv2R) {
220  fillTrackId();
221  }
222 
223  // construct StubHT from StubGP and HT cell assignment
224  StubHT::StubHT(const StubGP& stub, int phiT, int inv2R)
225  : Stub(stub, stub.r(), stub.phi(), stub.z(), stub.layer(), stub.sectorPhi(), stub.sectorEta(), phiT),
226  inv2R_(inv2R) {
227  get<1>(data_) -=
229  fillTrackId();
231  }
232 
234  TTBV ttBV(bv());
236  }
237 
238  // construct StubMHT from Frame
239  StubMHT::StubMHT(const FrameStub& frame, const DataFormats* formats) : Stub(frame, formats, Process::mht) {
240  fillTrackId();
241  }
242 
243  // construct StubMHT from StubHT and MHT cell assignment
244  StubMHT::StubMHT(const StubHT& stub, int phiT, int inv2R)
245  : Stub(stub,
246  stub.r(),
247  stub.phi(),
248  stub.z(),
249  stub.layer(),
250  stub.sectorPhi(),
251  stub.sectorEta(),
252  stub.phiT(),
253  stub.inv2R()) {
254  const Setup* setup = dataFormats_->setup();
255  // update track (phIT, inv2R), and phi residuals w.r.t. track, to reflect MHT cell assignment.
256  get<6>(data_) = this->phiT() * setup->mhtNumBinsPhiT() + phiT;
257  get<7>(data_) = this->inv2R() * setup->mhtNumBinsInv2R() + inv2R;
258  get<1>(data_) -= base(Variable::inv2R) * (inv2R - .5) * r() + base(Variable::phiT) * (phiT - .5);
260  fillTrackId();
261  }
262 
263  // fills track id
265  TTBV ttBV(bv());
268  }
269 
270  // construct StubZHT from Frame
271  StubZHT::StubZHT(const FrameStub& frame, const DataFormats* formats) : Stub(frame, formats, Process::zht) {
272  cot_ = 0.;
273  zT_ = 0.;
274  fillTrackId();
275  }
276 
277  // construct StubZHT from StubMHT
279  : Stub(stub,
280  stub.r(),
281  stub.phi(),
282  stub.z(),
283  stub.layer(),
284  stub.sectorPhi(),
285  stub.sectorEta(),
286  stub.phiT(),
287  stub.inv2R(),
288  0,
289  0) {
290  cot_ = 0.;
291  zT_ = 0.;
293  chi_ = stub.z();
294  trackId_ = stub.trackId();
295  }
296 
297  //
298  StubZHT::StubZHT(const StubZHT& stub, double zT, double cot, int id)
299  : Stub(stub.frame().first,
300  stub.dataFormats(),
301  Process::zht,
302  stub.r(),
303  stub.phi(),
304  stub.z(),
305  stub.layer(),
306  stub.sectorPhi(),
307  stub.sectorEta(),
308  stub.phiT(),
309  stub.inv2R(),
310  stub.zT(),
311  stub.cot()) {
312  // update track (zT, cot), and phi residuals w.r.t. track, to reflect ZHT cell assignment.
313  r_ = stub.r_;
314  cot_ = stub.cotf() + cot;
315  zT_ = stub.ztf() + zT;
316  chi_ = stub.z() - zT_ + r_ * cot_;
317  get<8>(data_) = format(Variable::zT).integer(zT_);
318  get<9>(data_) = format(Variable::cot).integer(cot_);
320  trackId_ = stub.trackId() * 4 + id;
321  }
322 
323  //
324  StubZHT::StubZHT(const StubZHT& stub, int cot, int zT)
325  : Stub(stub.frame().first,
326  stub.dataFormats(),
327  Process::zht,
328  stub.r(),
329  stub.phi(),
330  0.,
331  stub.layer(),
332  stub.sectorPhi(),
333  stub.sectorEta(),
334  stub.phiT(),
335  stub.inv2R(),
336  zT,
337  cot) {
338  get<2>(data_) =
340  .digi(stub.z() - (format(Variable::zT).floating(zT) - stub.r_ * format(Variable::cot).floating(cot)));
342  fillTrackId();
343  }
344 
345  // fills track id
347  TTBV ttBV(bv());
350  }
351 
352  // construct StubKFin from Frame
353  StubKFin::StubKFin(const FrameStub& frame, const DataFormats* formats, int layer)
354  : Stub(frame, formats, Process::kfin), layer_(layer) {}
355 
356  // construct StubKFin from StubZHT
357  StubKFin::StubKFin(const StubZHT& stub, double dPhi, double dZ, int layer)
358  : Stub(stub, stub.r(), stub.phi(), stub.z(), dPhi, dZ), layer_(layer) {
360  }
361 
362  // construct StubKFin from TTStubRef
363  StubKFin::StubKFin(const TTStubRef& ttStubRef,
364  const DataFormats* dataFormats,
365  double r,
366  double phi,
367  double z,
368  double dPhi,
369  double dZ,
370  int layer)
371  : Stub(ttStubRef, dataFormats, Process::kfin, r, phi, z, dPhi, dZ), layer_(layer) {
373  }
374 
375  // construct StubKF from Frame
376  StubKF::StubKF(const FrameStub& frame, const DataFormats* formats, int layer)
377  : Stub(frame, formats, Process::kf), layer_(layer) {}
378 
379  // construct StubKF from StubKFin
380  StubKF::StubKF(const StubKFin& stub, double inv2R, double phiT, double cot, double zT)
381  : Stub(stub, stub.r(), 0., 0., stub.dPhi(), stub.dZ()), layer_(stub.layer()) {
382  const Setup* setup = dataFormats_->setup();
383  get<1>(data_) = format(Variable::phi).digi(stub.phi() - (phiT + this->r() * inv2R));
384  const double d =
385  (dataFormats_->hybrid() ? setup->hybridChosenRofPhi() : setup->chosenRofPhi()) - setup->chosenRofZ();
386  const double rz = format(Variable::r).digi(this->r() + d);
387  get<2>(data_) = format(Variable::z).digi(stub.z() - (zT + rz * cot));
389  }
390 
391  // construct Track from Frame
392  template <typename... Ts>
394  : dataFormats_(dataFormats), p_(p), frame_(frame) {
395  dataFormats_->convertTrack(p_, frame.second, data_);
396  }
397 
398  // construct Track from other Track
399  template <typename... Ts>
400  template <typename... Others>
402  : dataFormats_(track.dataFormats()), p_(++track.p()), frame_(track.frame().first, Frame()), data_(data...) {}
403 
404  // construct Track from Stub
405  template <typename... Ts>
406  template <typename... Others>
407  Track<Ts...>::Track(const Stub<Others...>& stub, const TTTrackRef& ttTrackRef, Ts... data)
408  : dataFormats_(stub.dataFormats()), p_(++stub.p()), frame_(ttTrackRef, Frame()), data_(data...) {}
409 
410  // construct Track from TTTrackRef
411  template <typename... Ts>
412  Track<Ts...>::Track(const TTTrackRef& ttTrackRef, const DataFormats* dataFormats, Process p, Ts... data)
413  : dataFormats_(dataFormats), p_(p), frame_(ttTrackRef, Frame()), data_(data...) {}
414 
415  // construct TrackKFin from Frame
416  TrackKFin::TrackKFin(const FrameTrack& frame, const DataFormats* dataFormats, const vector<StubKFin*>& stubs)
417  : Track(frame, dataFormats, Process::kfin), stubs_(setup()->numLayers()), hitPattern_(0, setup()->numLayers()) {
418  vector<int> nStubs(stubs_.size(), 0);
419  for (StubKFin* stub : stubs)
420  nStubs[stub->layer()]++;
421  for (int layer = 0; layer < dataFormats->setup()->numLayers(); layer++)
422  stubs_[layer].reserve(nStubs[layer]);
423  for (StubKFin* stub : stubs) {
424  const int layer = stub->layer();
425  stubs_[layer].push_back(stub);
427  }
428  }
429 
430  // construct TrackKFin from StubZHT
431  TrackKFin::TrackKFin(const StubZHT& stub, const TTTrackRef& ttTrackRef, const TTBV& maybePattern)
432  : Track(stub, ttTrackRef, maybePattern, stub.sectorPhi(), stub.sectorEta(), 0., 0., 0., 0.),
433  stubs_(setup()->numLayers()),
434  hitPattern_(0, setup()->numLayers()) {
435  get<3>(data_) = format(Variable::phiT, Process::mht).floating(stub.phiT());
437  get<5>(data_) = format(Variable::zT, Process::zht).floating(stub.zT());
438  get<6>(data_) = format(Variable::cot, Process::zht).floating(stub.cot());
440  }
441 
442  // construct TrackKFin from TTTrackRef
443  TrackKFin::TrackKFin(const TTTrackRef& ttTrackRef,
444  const DataFormats* dataFormats,
445  const TTBV& maybePattern,
446  double phiT,
447  double inv2R,
448  double zT,
449  double cot,
450  int sectorPhi,
451  int sectorEta)
452  : Track(ttTrackRef, dataFormats, Process::kfin, maybePattern, sectorPhi, sectorEta, phiT, inv2R, zT, cot),
453  stubs_(setup()->numLayers()),
454  hitPattern_(0, setup()->numLayers()) {
456  }
457 
458  vector<TTStubRef> TrackKFin::ttStubRefs(const TTBV& hitPattern, const vector<int>& layerMap) const {
459  vector<TTStubRef> stubs;
460  stubs.reserve(hitPattern.count());
461  for (int layer = 0; layer < setup()->numLayers(); layer++)
462  if (hitPattern[layer])
463  stubs.push_back(stubs_[layer][layerMap[layer]]->ttStubRef());
464  return stubs;
465  }
466 
467  // construct TrackKF from Frame
468  TrackKF::TrackKF(const FrameTrack& frame, const DataFormats* dataFormats) : Track(frame, dataFormats, Process::kf) {}
469 
470  // construct TrackKF from TrackKfin
471  TrackKF::TrackKF(const TrackKFin& track, double phiT, double inv2R, double zT, double cot)
472  : Track(
476  get<3>(data_) += phiT;
477  get<4>(data_) += inv2R;
478  get<5>(data_) += cot;
479  get<6>(data_) += zT;
481  }
482 
483  // conversion to TTTrack with given stubs
484  TTTrack<Ref_Phase2TrackerDigi_> TrackKF::ttTrack(const vector<StubKF>& stubs) const {
485  const double invR = -this->inv2R() * 2.;
486  const double phi0 =
487  deltaPhi(this->phiT() - this->inv2R() * dataFormats_->chosenRofPhi() +
488  setup()->baseSector() * (this->sectorPhi() - .5) + setup()->baseRegion() * frame_.first->phiSector());
489  const double cot = this->cot() + setup()->sectorCot(this->sectorEta());
490  const double z0 = this->zT() - this->cot() * setup()->chosenRofZ();
491  TTBV hitVector(0, setup()->numLayers());
492  double chi2phi(0.);
493  double chi2z(0.);
494  vector<TTStubRef> ttStubRefs;
495  const int nLayer = stubs.size();
496  ttStubRefs.reserve(nLayer);
497  for (const StubKF& stub : stubs) {
498  hitVector.set(stub.layer());
499  const TTStubRef& ttStubRef = stub.ttStubRef();
500  chi2phi += pow(stub.phi(), 2) / setup()->v0(ttStubRef, this->inv2R());
501  chi2z += pow(stub.z(), 2) / setup()->v1(ttStubRef, cot);
502  ttStubRefs.push_back(ttStubRef);
503  }
504  static constexpr int nPar = 4;
505  static constexpr double d0 = 0.;
506  static constexpr double trkMVA1 = 0.;
507  static constexpr double trkMVA2 = 0.;
508  static constexpr double trkMVA3 = 0.;
509  const int hitPattern = hitVector.val();
510  const double bField = setup()->bField();
512  invR, phi0, cot, z0, d0, chi2phi, chi2z, trkMVA1, trkMVA2, trkMVA3, hitPattern, nPar, bField);
513  ttTrack.setStubRefs(ttStubRefs);
514  ttTrack.setPhiSector(frame_.first->phiSector());
515  ttTrack.setEtaSector(this->sectorEta());
516  ttTrack.setTrackSeedType(frame_.first->trackSeedType());
517  ttTrack.setStubPtConsistency(StubPtConsistency::getConsistency(
518  ttTrack, setup()->trackerGeometry(), setup()->trackerTopology(), bField, nPar));
519  return ttTrack;
520  }
521 
522  // construct TrackDR from Frame
523  TrackDR::TrackDR(const FrameTrack& frame, const DataFormats* dataFormats) : Track(frame, dataFormats, Process::dr) {}
524 
525  // construct TrackDR from TrackKF
526  TrackDR::TrackDR(const TrackKF& track) : Track(track, 0., 0., 0., 0.) {
527  get<0>(data_) = track.phiT() + track.inv2R() * dataFormats_->chosenRofPhi() +
528  dataFormats_->format(Variable::phi, Process::gp).range() * (track.sectorPhi() - .5);
529  get<1>(data_) = track.inv2R();
530  get<2>(data_) = track.zT() - track.cot() * setup()->chosenRofZ();
531  get<3>(data_) = track.cot() + setup()->sectorCot(track.sectorEta());
533  }
534 
535  // conversion to TTTrack
537  const double inv2R = this->inv2R();
538  const double phi0 = this->phi0();
539  const double cot = this->cot();
540  const double z0 = this->z0();
541  static constexpr double d0 = 0.;
542  static constexpr double chi2phi = 0.;
543  static constexpr double chi2z = 0;
544  static constexpr double trkMVA1 = 0.;
545  static constexpr double trkMVA2 = 0.;
546  static constexpr double trkMVA3 = 0.;
547  static constexpr int hitPattern = 0.;
548  static constexpr int nPar = 4;
549  static constexpr double bField = 0.;
550  const int sectorPhi = frame_.first->phiSector();
551  const int sectorEta = frame_.first->etaSector();
553  inv2R, phi0, cot, z0, d0, chi2phi, chi2z, trkMVA1, trkMVA2, trkMVA3, hitPattern, nPar, bField);
554  ttTrack.setPhiSector(sectorPhi);
555  ttTrack.setEtaSector(sectorEta);
556  return ttTrack;
557  }
558 
559  template <>
561  range_ = 2. * M_PI / (double)(setup->numRegions() * setup->numSectorsPhi());
562  base_ = range_ / (double)setup->htNumBinsPhiT();
563  width_ = ceil(log2(setup->htNumBinsPhiT()));
564  }
565 
566  template <>
569  range_ = ht.range();
570  base_ = ht.base() / setup->mhtNumBinsPhiT();
571  width_ = ceil(log2(setup->htNumBinsPhiT() * setup->mhtNumBinsPhiT()));
572  }
573 
574  template <>
576  const double mintPt = iConfig.getParameter<bool>("UseHybrid") ? setup->hybridMinPtCand() : setup->minPt();
577  range_ = 2. * setup->invPtToDphi() / mintPt;
578  base_ = range_ / (double)setup->htNumBinsInv2R();
579  width_ = ceil(log2(setup->htNumBinsInv2R()));
580  }
581 
582  template <>
585  range_ = ht.range();
586  base_ = ht.base() / setup->mhtNumBinsInv2R();
587  width_ = ceil(log2(setup->htNumBinsInv2R() * setup->mhtNumBinsInv2R()));
588  }
589 
590  template <>
592  const double chosenRofPhi =
593  iConfig.getParameter<bool>("UseHybrid") ? setup->hybridChosenRofPhi() : setup->chosenRofPhi();
594  width_ = setup->tmttWidthR();
595  range_ = 2. * max(abs(setup->outerRadius() - chosenRofPhi), abs(setup->innerRadius() - chosenRofPhi));
598  base_ = phiT.base() / inv2R.base();
599  const int shift = ceil(log2(range_ / base_ / pow(2., width_)));
600  base_ *= pow(2., shift);
601  }
602 
603  template <>
607  const Format<Variable::r, Process::ht> r(iConfig, setup);
608  range_ = phiT.range() + inv2R.range() * r.base() * pow(2., r.width()) / 4.;
610  base_ = dtc.base();
611  width_ = ceil(log2(range_ / base_));
612  }
613 
614  template <>
616  width_ = setup->tmttWidthPhi();
619  const Format<Variable::r, Process::ht> r(iConfig, setup);
620  range_ = 2. * M_PI / (double)setup->numRegions() + inv2R.range() * r.base() * pow(2., r.width()) / 4.;
621  const int shift = ceil(log2(range_ / phiT.base() / pow(2., width_)));
622  base_ = phiT.base() * pow(2., shift);
623  }
624 
625  template <>
628  range_ = 2. * phiT.base();
630  base_ = gp.base();
631  width_ = ceil(log2(range_ / base_));
632  }
633 
634  template <>
637  range_ = 2. * phiT.base();
639  base_ = ht.base();
640  width_ = ceil(log2(range_ / base_));
641  }
642 
643  template <>
646  const double rangeFactor = iConfig.getParameter<ParameterSet>("KalmanFilter").getParameter<double>("RangeFactor");
647  range_ = rangeFactor * phi.range();
648  base_ = phi.base();
649  width_ = ceil(log2(range_ / base_));
650  }
651 
652  template <>
654  width_ = setup->tmttWidthZ();
655  range_ = 2. * setup->halfLength();
656  const Format<Variable::r, Process::ht> r(iConfig, setup);
657  const int shift = ceil(log2(range_ / r.base())) - width_;
658  base_ = r.base() * pow(2., shift);
659  }
660 
661  template <>
663  range_ = setup->neededRangeChiZ();
665  base_ = dtc.base();
666  width_ = ceil(log2(range_ / base_));
667  }
668 
669  template <>
671  const int numBinsZT = iConfig.getParameter<ParameterSet>("ZHoughTransform").getParameter<int>("NumBinsZT");
672  const int numStages = iConfig.getParameter<ParameterSet>("ZHoughTransform").getParameter<int>("NumStages");
673  width_ = ceil(log2(pow(numBinsZT, numStages)));
674  const Format<Variable::z, Process::dtc> z(iConfig, setup);
675  range_ = -1.;
676  for (int eta = 0; eta < setup->numSectorsEta(); eta++)
677  range_ = max(range_, (sinh(setup->boundarieEta(eta + 1)) - sinh(setup->boundarieEta(eta))));
678  range_ *= setup->chosenRofZ();
679  const int shift = ceil(log2(range_ / z.base() / pow(2., width_)));
680  base_ = z.base() * pow(2., shift);
681  }
682 
683  template <>
685  const int numBinsCot = iConfig.getParameter<ParameterSet>("ZHoughTransform").getParameter<int>("NumBinsCot");
686  const int numStages = iConfig.getParameter<ParameterSet>("ZHoughTransform").getParameter<int>("NumStages");
687  width_ = ceil(log2(pow(numBinsCot, numStages)));
689  range_ = (zT.range() + 2. * setup->beamWindowZ()) / setup->chosenRofZ();
690  const int shift = ceil(log2(range_)) - width_;
691  base_ = pow(2., shift);
692  }
693 
694  template <>
698  const double rangeR =
699  2. * max(abs(setup->outerRadius() - setup->chosenRofZ()), abs(setup->innerRadius() - setup->chosenRofZ()));
700  range_ = zT.base() + cot.base() * rangeR + setup->maxdZ();
702  base_ = dtc.base();
703  width_ = ceil(log2(range_ / base_));
704  /*const Format<Variable::z, Process::gp> z(iConfig, setup);
705  width_ = z.width();
706  range_ = z.range();
707  base_ = z.base();*/
708  }
709 
710  template <>
713  range_ = zht.range() * pow(2, setup->kfinShiftRangeZ());
714  base_ = zht.base();
715  width_ = ceil(log2(range_ / base_));
716  }
717 
718  template <>
722  const double chosenRofPhi =
723  iConfig.getParameter<bool>("UseHybrid") ? setup->hybridChosenRofPhi() : setup->chosenRofPhi();
724  const double rangeR = 2. * max(abs(setup->outerRadius() - chosenRofPhi), abs(setup->innerRadius() - chosenRofPhi));
725  range_ = phiT.base() + inv2R.base() * rangeR + setup->maxdPhi();
727  base_ = dtc.base();
728  width_ = ceil(log2(range_ / base_));
729  }
730 
731  template <>
734  range_ = zht.range() * pow(2, setup->kfinShiftRangePhi());
735  base_ = zht.base();
736  width_ = ceil(log2(range_ / base_));
737  }
738 
739  template <>
741  /*const Format<Variable::z, Process::zht> z(iConfig, setup);
742  const double rangeFactor = iConfig.getParameter<ParameterSet>("KalmanFilter").getParameter<double>("RangeFactor");
743  range_ = rangeFactor * z.range();
744  base_ = z.base();
745  width_ = ceil(log2(range_ / base_));*/
748  const double rangeR =
749  2. * max(abs(setup->outerRadius() - setup->chosenRofZ()), abs(setup->innerRadius() - setup->chosenRofZ()));
750  range_ = zT.base() + cot.base() * rangeR + setup->maxdZ();
752  base_ = dtc.base();
753  const double rangeFactor = iConfig.getParameter<ParameterSet>("KalmanFilter").getParameter<double>("RangeFactor");
754  range_ *= rangeFactor;
755  width_ = ceil(log2(range_ / base_));
756  }
757 
758  template <>
760  range_ = setup->numLayers();
761  width_ = ceil(log2(range_));
762  }
763 
764  template <>
766  : DataFormat(false) {
767  range_ = setup->numSectorsEta();
768  width_ = ceil(log2(range_));
769  }
770 
771  template <>
773  : DataFormat(false) {
774  range_ = setup->numSectorsPhi();
775  width_ = ceil(log2(range_));
776  }
777 
778  template <>
780  : DataFormat(false) {
781  range_ = setup->numSectorsPhi();
782  width_ = setup->numSectorsPhi();
783  }
784 
785  template <>
787  : DataFormat(false) {
788  width_ = 1;
789  range_ = 1.;
790  }
791 
792  template <>
794  : DataFormat(false) {
795  width_ = setup->numLayers();
796  }
797 
798  template <>
802  const double chosenRofPhi =
803  iConfig.getParameter<bool>("UseHybrid") ? setup->hybridChosenRofPhi() : setup->chosenRofPhi();
804  width_ = setup->tfpWidthPhi0();
805  range_ = 2. * M_PI / (double)setup->numRegions() + inv2R.range() * chosenRofPhi;
806  base_ = phiT.base();
807  const int shift = ceil(log2(range_ / base_ / pow(2., width_)));
808  base_ *= pow(2., shift);
809  }
810 
811  template <>
813  : DataFormat(true) {
815  width_ = setup->tfpWidthInv2R();
816  range_ = inv2R.range();
817  base_ = inv2R.base();
818  const int shift = ceil(log2(range_ / base_ / pow(2., width_)));
819  base_ *= pow(2., shift);
820  }
821 
822  template <>
825  width_ = setup->tfpWidthZ0();
826  range_ = 2. * setup->beamWindowZ();
827  base_ = zT.base();
828  const int shift = ceil(log2(range_ / base_ / pow(2., width_)));
829  base_ *= pow(2., shift);
830  }
831 
832  template <>
835  width_ = setup->tfpWidthCot();
836  range_ = 2. * setup->maxCot();
837  base_ = cot.base();
838  const int shift = ceil(log2(range_ / base_ / pow(2., width_)));
839  base_ *= pow(2., shift);
840  }
841 
842  template <>
846  const double rangeFactor = iConfig.getParameter<ParameterSet>("KalmanFilter").getParameter<double>("RangeFactor");
847  range_ = rangeFactor * phiT.range();
848  base_ = phi0.base();
849  width_ = ceil(log2(range_ / base_));
850  }
851 
852  template <>
854  : DataFormat(true) {
857  const double rangeFactor = iConfig.getParameter<ParameterSet>("KalmanFilter").getParameter<double>("RangeFactor");
858  range_ = mht.range() + rangeFactor * mht.base();
859  base_ = dr.base();
860  width_ = ceil(log2(range_ / base_));
861  }
862 
863  template <>
867  const double rangeFactor = iConfig.getParameter<ParameterSet>("KalmanFilter").getParameter<double>("RangeFactor");
868  range_ = zT.range() + rangeFactor * zT.base();
869  base_ = z0.base();
870  width_ = ceil(log2(range_ / base_));
871  }
872 
873  template <>
877  const double rangeFactor = iConfig.getParameter<ParameterSet>("KalmanFilter").getParameter<double>("RangeFactor");
878  range_ = zht.range() + rangeFactor * zht.base();
879  base_ = dr.base();
880  width_ = ceil(log2(range_ / base_));
881  }
882 
883  template <>
885  : DataFormat(false) {
887  range_ = setup->maxdPhi();
888  base_ = phi.base();
889  width_ = ceil(log2(range_ / base_));
890  }
891 
892  template <>
894  : DataFormat(false) {
896  range_ = setup->maxdZ();
897  base_ = z.base();
898  width_ = ceil(log2(range_ / base_));
899  }
900 
901 } // 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:198
TTTrack< Ref_Phase2TrackerDigi_ > ttTrack(const std::vector< StubKF > &stubs) const
Definition: DataFormats.cc:484
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
constexpr int pow(int x)
Definition: conifer.h:24
void extractStub(Process p, TTBV &ttBV, std::tuple< Ts... > &data) const
Definition: DataFormats.cc:111
int numDTCsPerRegion() const
Definition: Setup.h:351
StubZHT(const tt::FrameStub &frame, const DataFormats *dataFormats)
Definition: DataFormats.cc:271
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:144
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:393
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:218
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:353
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:523
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:416
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:239
int numRegions() const
Definition: Setup.h:345
std::vector< TTStubRef > ttStubRefs(const TTBV &hitPattern, const std::vector< int > &layerMap) const
Definition: DataFormats.cc:458
TTTrack< Ref_Phase2TrackerDigi_ > ttTrack() const
Definition: DataFormats.cc:536
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:80
TrackKF(const tt::FrameTrack &frame, const DataFormats *dataFormats)
Definition: DataFormats.cc:468
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:376
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
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)