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 layerdisk1,
11  unsigned int layerdisk2,
12  unsigned int iSeed,
13  unsigned int nbitsfinephidiff,
14  unsigned int iAllStub,
15  const TrackletLUT* pttableinnernew,
16  const TrackletLUT* pttableouternew,
17  VMStubsTEMemory* outervmstubs)
18  : settings_(settings), pttableinnernew_(pttableinnernew), pttableouternew_(pttableouternew), candpairs_(3) {
19  idle_ = true;
20  nbitsfinephi_ = nbitsfinephi;
21  layerdisk2_ = layerdisk2;
22  layerdisk1_ = layerdisk1;
23  iSeed_ = iSeed;
24  nbitsfinephidiff_ = nbitsfinephidiff;
25  iAllStub_ = iAllStub;
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  goodpair_ = false;
41  goodpair__ = false;
42  candpairs_.reset();
43 }
44 
45 void TrackletEngineUnit::step(bool, int, int) {
46  if (goodpair__) {
47  candpairs_.store(candpair__);
48  }
49 
52 
53  goodpair_ = false;
54 
55  if (idle_ || nearfull_) {
56  return;
57  }
58 
59  int ibin = tedata_.start_ + next_;
60 
61  int nbins = (1 << NFINERZBITS);
62 
63  assert(istub_ < outervmstubs_->nVMStubsBinned(ireg_ * nbins + ibin));
64 
65  const VMStubTE& outervmstub = outervmstubs_->getVMStubTEBinned(ireg_ * nbins + ibin, istub_);
66  int rzbin = (outervmstub.vmbits().value() & (nbins - 1));
67 
68  FPGAWord iphiouterbin = outervmstub.finephi();
69 
70  assert(iphiouterbin == outervmstub.finephi());
71 
72  //New code to calculate lut value
73  int outerfinephi = iAllStub_ * (1 << (nbitsfinephi_ - settings_->nbitsallstubs(layerdisk2_))) +
74  ireg_ * (1 << settings_->nfinephi(1, iSeed_)) + iphiouterbin.value();
75  int idphi = outerfinephi - tedata_.innerfinephi_;
76 
77  bool inrange = (idphi < (1 << (nbitsfinephidiff_ - 1))) && (idphi >= -(1 << (nbitsfinephidiff_ - 1)));
78 
79  idphi = idphi & ((1 << nbitsfinephidiff_) - 1);
80 
81  unsigned int firstDiskSeed = 4;
82  if (iSeed_ >= firstDiskSeed) { //Also use r-position
83  int ibinMask = 3; //Get two least sign. bits
84  int ir = ((ibin & ibinMask) << 1) + (rzbin >> (NFINERZBITS - 1));
85  int nrbits = 3;
86  idphi = (idphi << nrbits) + ir;
87  }
88 
89  if (next_ != 0)
90  rzbin += (1 << NFINERZBITS);
91 
92  if ((rzbin < tedata_.rzbinfirst_) || (rzbin - tedata_.rzbinfirst_ > tedata_.rzdiffmax_)) {
93  if (settings_->debugTracklet()) {
94  edm::LogVerbatim("Tracklet") << " layer-disk stub pair rejected because rbin cut : " << rzbin << " "
96  }
97  } else {
98  FPGAWord outerbend = outervmstub.bend();
99 
100  int ptinnerindex = (idphi << tedata_.innerbend_.nbits()) + tedata_.innerbend_.value();
101  int ptouterindex = (idphi << outerbend.nbits()) + outerbend.value();
102 
103  if (!(inrange && pttableinnernew_->lookup(ptinnerindex) && pttableouternew_->lookup(ptouterindex))) {
104  if (settings_->debugTracklet()) {
105  edm::LogVerbatim("Tracklet") << " Stub pair rejected because of stub pt cut bends : "
106  << settings_->benddecode(
108  << " "
109  << settings_->benddecode(outerbend.value(), layerdisk2_, outervmstub.isPSmodule());
110  }
111  } else {
112  candpair_ = pair<const Stub*, const Stub*>(tedata_.stub_, outervmstub.stub());
113  goodpair_ = true;
114  }
115  }
116 
117  istub_++;
119  if (istub_ >= nstub_) {
120  istub_ = 0;
121  nreg_++;
122  if (nreg_ >= tedata_.regions_.size()) {
123  nreg_ = 0;
124  idle_ = true;
125  } else {
126  std::tie(next_, ireg_, nstub_) = tedata_.regions_[nreg_];
127  }
128  }
129 }
trklet::TrackletEngineUnit::settings_
const Settings * settings_
Definition: TrackletEngineUnit.h:68
Settings.h
trklet::TEData::rzbinfirst_
int rzbinfirst_
Definition: TrackletEngineUnit.h:21
trklet::TEData::start_
int start_
Definition: TrackletEngineUnit.h:20
trklet::TrackletEngineUnit::goodpair__
bool goodpair__
Definition: TrackletEngineUnit.h:90
trklet::TrackletLUT::lookup
int lookup(unsigned int index) const
Definition: TrackletLUT.cc:900
trklet::VMStubTE
Definition: VMStubTE.h:15
trklet::TEData::rzdiffmax_
int rzdiffmax_
Definition: TrackletEngineUnit.h:22
trklet::TrackletEngineUnit::pttableinnernew_
const TrackletLUT * pttableinnernew_
Definition: TrackletEngineUnit.h:86
trklet::VMStubsTEMemory::getVMStubTEBinned
const VMStubTE & getVMStubTEBinned(unsigned int bin, unsigned int i) const
Definition: VMStubsTEMemory.h:38
trklet::Settings
Definition: Settings.h:52
trklet::TrackletEngineUnit::outervmstubs_
VMStubsTEMemory * outervmstubs_
Definition: TrackletEngineUnit.h:66
trklet::TrackletLUT
Definition: TrackletLUT.h:12
trklet::Settings::nbitsallstubs
unsigned int nbitsallstubs(unsigned int layerdisk) const
Definition: Settings.h:106
trklet::VMStubsTEMemory
Definition: VMStubsTEMemory.h:18
cms::cuda::assert
assert(be >=bs)
trklet::TrackletEngineUnit::idle_
bool idle_
Definition: TrackletEngineUnit.h:84
trklet::TrackletEngineUnit::layerdisk1_
unsigned int layerdisk1_
Definition: TrackletEngineUnit.h:70
trklet::TrackletEngineUnit::tedata_
TEData tedata_
Definition: TrackletEngineUnit.h:67
trklet::TEData::innerbend_
FPGAWord innerbend_
Definition: TrackletEngineUnit.h:24
trklet::TrackletEngineUnit::nearfull_
bool nearfull_
Definition: TrackletEngineUnit.h:74
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::Settings::benddecode
double benddecode(int ibend, int layerdisk, bool isPSmodule) const
Definition: Settings.h:402
trklet::TEData::innerfinephi_
int innerfinephi_
Definition: TrackletEngineUnit.h:23
trklet::TrackletEngineUnit::nreg_
unsigned int nreg_
Definition: TrackletEngineUnit.h:78
trklet::TrackletEngineUnit::next_
unsigned int next_
Definition: TrackletEngineUnit.h:81
trklet::TrackletEngineUnit::nstub_
unsigned int nstub_
Definition: TrackletEngineUnit.h:82
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
trklet::N_VMSTUBSMAX
constexpr unsigned int N_VMSTUBSMAX
Definition: Settings.h:38
trklet::FPGAWord
Definition: FPGAWord.h:9
trklet::TrackletEngineUnit::candpair_
std::pair< const Stub *, const Stub * > candpair_
Definition: TrackletEngineUnit.h:89
trklet::TrackletEngineUnit::iAllStub_
unsigned int iAllStub_
Definition: TrackletEngineUnit.h:75
trklet::Settings::nfinephi
int nfinephi(unsigned int inner, unsigned int iSeed) const
Definition: Settings.h:133
trklet::VMStubTE::stub
const Stub * stub() const
Definition: VMStubTE.h:29
trklet::TrackletEngineUnit::init
void init(const TEData &tedata)
Definition: TrackletEngineUnit.cc:29
trklet::TrackletEngineUnit::ireg_
unsigned int ireg_
Definition: TrackletEngineUnit.h:80
trklet::VMStubTE::vmbits
const FPGAWord & vmbits() const
Definition: VMStubTE.h:27
trklet
Definition: AllInnerStubsMemory.h:10
trklet::FPGAWord::value
int value() const
Definition: FPGAWord.h:24
trklet::TrackletEngineUnit::nbitsfinephi_
unsigned int nbitsfinephi_
Definition: TrackletEngineUnit.h:69
VMStubsTEMemory.h
trklet::TrackletEngineUnit::candpairs_
CircularBuffer< std::pair< const Stub *, const Stub * > > candpairs_
Definition: TrackletEngineUnit.h:93
trklet::TrackletEngineUnit::step
void step(bool print, int istep, int iTE)
Definition: TrackletEngineUnit.cc:45
std
Definition: JetResolutionObject.h:76
trklet::TEData::stub_
const Stub * stub_
Definition: TrackletEngineUnit.h:19
trklet::NFINERZBITS
constexpr unsigned int NFINERZBITS
Definition: Settings.h:33
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
trklet::TrackletEngineUnit::iSeed_
unsigned int iSeed_
Definition: TrackletEngineUnit.h:72
trklet::TrackletEngineUnit::pttableouternew_
const TrackletLUT * pttableouternew_
Definition: TrackletEngineUnit.h:87
trklet::TrackletEngineUnit::nbitsfinephidiff_
unsigned int nbitsfinephidiff_
Definition: TrackletEngineUnit.h:73
trklet::VMStubTE::finephi
const FPGAWord & finephi() const
Definition: VMStubTE.h:23
trklet::Settings::debugTracklet
bool debugTracklet() const
Definition: Settings.h:182
trklet::Stub::isPSmodule
bool isPSmodule() const
Definition: Stub.h:71
trklet::TEData::regions_
std::vector< std::tuple< int, int, int > > regions_
Definition: TrackletEngineUnit.h:25
trklet::TrackletEngineUnit::goodpair_
bool goodpair_
Definition: TrackletEngineUnit.h:90
trklet::TrackletEngineUnit::candpair__
std::pair< const Stub *, const Stub * > candpair__
Definition: TrackletEngineUnit.h:89
trklet::TrackletEngineUnit::reset
void reset()
Definition: TrackletEngineUnit.cc:38
TrackletEngineUnit.h
trklet::TrackletEngineUnit::layerdisk2_
unsigned int layerdisk2_
Definition: TrackletEngineUnit.h:71
trklet::TrackletEngineUnit::istub_
unsigned int istub_
Definition: TrackletEngineUnit.h:79
trklet::TEData
Definition: TrackletEngineUnit.h:18