CMS 3D CMS Logo

TrackletEngineUnit.cc
Go to the documentation of this file.
4 
5 using namespace std;
6 using namespace trklet;
7 
8 TrackletEngineUnit::TrackletEngineUnit(const Settings* const settings,
9  unsigned int nbitsfinephi,
10  unsigned int layerdisk2,
11  unsigned int iSeed,
12  unsigned int nbitsfinephidiff,
13  unsigned int iAllStub,
14  std::vector<bool> const& pttableinner,
15  std::vector<bool> const& pttableouter,
16  VMStubsTEMemory* outervmstubs)
17  : settings_(settings), candpairs_(5) {
18  idle_ = true;
19  nbitsfinephi_ = nbitsfinephi;
20  layerdisk2_ = layerdisk2;
21  iSeed_ = iSeed;
22  nbitsfinephidiff_ = nbitsfinephidiff;
23  iAllStub_ = iAllStub;
24  pttableinner_ = pttableinner;
25  pttableouter_ = pttableouter;
26  outervmstubs_ = outervmstubs;
27 }
28 
29 void TrackletEngineUnit::init(const TEData& tedata) {
30  tedata_ = tedata;
31  nreg_ = 0;
32  istub_ = 0;
33  idle_ = false;
34  assert(!tedata_.regions_.empty());
35  std::tie(next_, ireg_, nstub_) = tedata_.regions_[0];
36 }
37 
39  idle_ = true;
40  candpairs_.reset();
41 }
42 
44  if (candpairs_.full())
45  return;
46 
47  int ibin = tedata_.start_ + next_;
48 
49  int nbins = (1 << NFINERZBITS);
50 
51  assert(istub_ < outervmstubs_->nVMStubsBinned(ireg_ * nbins + ibin));
52 
53  const VMStubTE& outervmstub = outervmstubs_->getVMStubTEBinned(ireg_ * nbins + ibin, istub_);
54  int rzbin = (outervmstub.vmbits().value() & (nbins - 1));
55 
56  FPGAWord iphiouterbin = outervmstub.finephi();
57 
58  assert(iphiouterbin == outervmstub.finephi());
59 
60  //New code to calculate lut value
61  int outerfinephi = iAllStub_ * (1 << (nbitsfinephi_ - settings_->nbitsallstubs(layerdisk2_))) +
62  ireg_ * (1 << settings_->nfinephi(1, iSeed_)) + iphiouterbin.value();
63  int idphi = outerfinephi - tedata_.innerfinephi_;
64  bool inrange = (idphi < (1 << (nbitsfinephidiff_ - 1))) && (idphi >= -(1 << (nbitsfinephidiff_ - 1)));
65  if (idphi < 0)
66  idphi = idphi + (1 << nbitsfinephidiff_);
67 
68  unsigned int firstDiskSeed = 4;
69  if (iSeed_ >= firstDiskSeed) { //Also use r-position
70  int ibinMask = 3; //Get two least sign. bits
71  int ir = ((ibin & ibinMask) << 1) + (rzbin >> (NFINERZBITS - 1));
72  int nrbits = 3;
73  idphi = (idphi << nrbits) + ir;
74  }
75 
76  if (next_ != 0)
77  rzbin += (1 << NFINERZBITS);
78  if ((rzbin < tedata_.rzbinfirst_) || (rzbin - tedata_.rzbinfirst_ > tedata_.rzdiffmax_)) {
79  if (settings_->debugTracklet()) {
80  edm::LogVerbatim("Tracklet") << " layer-disk stub pair rejected because rbin cut : " << rzbin << " "
82  }
83  } else {
84  FPGAWord outerbend = outervmstub.bend();
85 
86  int ptinnerindex = (idphi << tedata_.innerbend_.nbits()) + tedata_.innerbend_.value();
87  int ptouterindex = (idphi << outerbend.nbits()) + outerbend.value();
88 
89  if (!(inrange && pttableinner_[ptinnerindex] && pttableouter_[ptouterindex])) {
90  if (settings_->debugTracklet()) {
91  edm::LogVerbatim("Tracklet") << " Stub pair rejected because of stub pt cut bends : "
93  << benddecode(outerbend.value(), outervmstub.isPSmodule());
94  }
95  } else {
96  candpairs_.store(pair<const Stub*, const Stub*>(tedata_.stub_, outervmstub.stub()));
97  }
98  }
99  istub_++;
100  if (istub_ >= nstub_) {
101  istub_ = 0;
102  nreg_++;
103  if (nreg_ >= tedata_.regions_.size()) {
104  nreg_ = 0;
105  idle_ = true;
106  } else {
107  std::tie(next_, ireg_, nstub_) = tedata_.regions_[nreg_];
108  }
109  }
110 }
trklet::TrackletEngineUnit::settings_
const Settings * settings_
Definition: TrackletEngineUnit.h:58
Settings.h
trklet::TEData::rzbinfirst_
int rzbinfirst_
Definition: TrackletEngineUnit.h:20
trklet::TEData::start_
int start_
Definition: TrackletEngineUnit.h:19
trklet::VMStubTE
Definition: VMStubTE.h:15
trklet::TEData::rzdiffmax_
int rzdiffmax_
Definition: TrackletEngineUnit.h:21
trklet::TrackletEngineUnit::pttableouter_
std::vector< bool > pttableouter_
Definition: TrackletEngineUnit.h:76
trklet::VMStubsTEMemory::getVMStubTEBinned
const VMStubTE & getVMStubTEBinned(unsigned int bin, unsigned int i) const
Definition: VMStubsTEMemory.h:36
trklet::Settings
Definition: Settings.h:31
trklet::TrackletEngineUnit::outervmstubs_
VMStubsTEMemory * outervmstubs_
Definition: TrackletEngineUnit.h:56
trklet::Settings::nbitsallstubs
unsigned int nbitsallstubs(unsigned int layerdisk) const
Definition: Settings.h:93
trklet::VMStubsTEMemory
Definition: VMStubsTEMemory.h:16
cms::cuda::assert
assert(be >=bs)
trklet::TrackletEngineUnit::idle_
bool idle_
Definition: TrackletEngineUnit.h:73
trklet::TrackletEngineUnit::tedata_
TEData tedata_
Definition: TrackletEngineUnit.h:57
trklet::TEData::innerbend_
FPGAWord innerbend_
Definition: TrackletEngineUnit.h:23
trklet::FPGAWord::nbits
int nbits() const
Definition: FPGAWord.h:25
trklet::VMStubTE::isPSmodule
bool isPSmodule() const
Definition: VMStubTE.h:31
trklet::VMStubTE::bend
const FPGAWord & bend() const
Definition: VMStubTE.h:25
trklet::TrackletEngineUnit::pttableinner_
std::vector< bool > pttableinner_
Definition: TrackletEngineUnit.h:75
trklet::TEData::innerfinephi_
int innerfinephi_
Definition: TrackletEngineUnit.h:22
trklet::TrackletEngineUnit::nreg_
unsigned int nreg_
Definition: TrackletEngineUnit.h:67
trklet::TrackletEngineUnit::next_
unsigned int next_
Definition: TrackletEngineUnit.h:70
trklet::TrackletEngineUnit::nstub_
unsigned int nstub_
Definition: TrackletEngineUnit.h:71
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
trklet::FPGAWord
Definition: FPGAWord.h:9
trklet::TrackletEngineUnit::iAllStub_
unsigned int iAllStub_
Definition: TrackletEngineUnit.h:64
trklet::Settings::nfinephi
int nfinephi(unsigned int inner, unsigned int iSeed) const
Definition: Settings.h:122
trklet::VMStubTE::stub
const Stub * stub() const
Definition: VMStubTE.h:29
trklet::TrackletEngineUnit::step
void step()
Definition: TrackletEngineUnit.cc:43
trklet::TrackletEngineUnit::init
void init(const TEData &tedata)
Definition: TrackletEngineUnit.cc:29
trklet::TrackletEngineUnit::ireg_
unsigned int ireg_
Definition: TrackletEngineUnit.h:69
trklet::VMStubTE::vmbits
const FPGAWord & vmbits() const
Definition: VMStubTE.h:27
trklet
Definition: AllProjectionsMemory.h:9
trklet::FPGAWord::value
int value() const
Definition: FPGAWord.h:24
trklet::TrackletEngineUnit::nbitsfinephi_
unsigned int nbitsfinephi_
Definition: TrackletEngineUnit.h:59
VMStubsTEMemory.h
trklet::TrackletEngineUnit::candpairs_
CircularBuffer< std::pair< const Stub *, const Stub * > > candpairs_
Definition: TrackletEngineUnit.h:79
std
Definition: JetResolutionObject.h:76
trklet::TEData::stub_
const Stub * stub_
Definition: TrackletEngineUnit.h:18
trklet::NFINERZBITS
constexpr unsigned int NFINERZBITS
Definition: Settings.h:27
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
trklet::TrackletEngineUnit::iSeed_
unsigned int iSeed_
Definition: TrackletEngineUnit.h:61
trklet::TrackletEngineUnit::nbitsfinephidiff_
unsigned int nbitsfinephidiff_
Definition: TrackletEngineUnit.h:62
trklet::VMStubTE::finephi
const FPGAWord & finephi() const
Definition: VMStubTE.h:23
trklet::Settings::debugTracklet
bool debugTracklet() const
Definition: Settings.h:161
trklet::Stub::isPSmodule
bool isPSmodule() const
Definition: Stub.h:63
trklet::TEData::regions_
std::vector< std::tuple< int, int, int > > regions_
Definition: TrackletEngineUnit.h:24
trklet::benddecode
double benddecode(int ibend, bool isPS)
Definition: Util.h:106
trklet::TrackletEngineUnit::reset
void reset()
Definition: TrackletEngineUnit.cc:38
TrackletEngineUnit.h
trklet::TrackletEngineUnit::layerdisk2_
unsigned int layerdisk2_
Definition: TrackletEngineUnit.h:60
trklet::TrackletEngineUnit::istub_
unsigned int istub_
Definition: TrackletEngineUnit.h:68
trklet::TEData
Definition: TrackletEngineUnit.h:17