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