CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
trklet::MatchEngineUnit Class Reference

#include <MatchEngineUnit.h>

Public Member Functions

bool active () const
 
TrackletcurrentProj () const
 
bool empty () const
 
bool have_ () const
 
bool have__ () const
 
bool idle () const
 
void init (VMStubsMEMemory *vmstubsmemory, unsigned int nrzbin, unsigned int rzbin, unsigned int iphi, int shift, int projrinv, int projfinerz, int projfinephi, bool usefirstMinus, bool usefirstPlus, bool usesecondMinus, bool usesecondPlus, bool isPSseed, Tracklet *proj, bool print)
 
 MatchEngineUnit (bool barrel, unsigned int layerdisk, const TrackletLUT &luttable)
 
std::pair< Tracklet *, const Stub * > peek () const
 
std::pair< Tracklet *, const Stub * > read ()
 
void reset ()
 
unsigned int rptr () const
 
void step (bool print)
 
int TCID () const
 
unsigned int wptr () const
 
 ~MatchEngineUnit ()=default
 

Private Attributes

bool barrel_
 
CircularBuffer< std::pair< Tracklet *, const Stub * > > candmatches_
 
bool goodpair_
 
bool goodpair__
 
bool havepair_
 
bool havepair__
 
bool idle_
 
bool isPSseed_
 
unsigned int istub_
 
unsigned int iuse_
 
unsigned int layerdisk_
 
const TrackletLUTluttable_
 
unsigned int nrzbins_
 
unsigned int phibin_
 
Trackletproj_
 
int projfinephi_
 
int projfinerz_
 
int projrinv_
 
unsigned int rzbin_
 
int shift_
 
std::pair< Tracklet *, const Stub * > tmppair_
 
std::pair< Tracklet *, const Stub * > tmppair__
 
std::vector< std::pair< unsigned int, unsigned int > > use_
 
VMStubsMEMemoryvmstubsmemory_
 

Detailed Description

Definition at line 19 of file MatchEngineUnit.h.

Constructor & Destructor Documentation

◆ MatchEngineUnit()

MatchEngineUnit::MatchEngineUnit ( bool  barrel,
unsigned int  layerdisk,
const TrackletLUT luttable 
)

Definition at line 7 of file MatchEngineUnit.cc.

References Reference_intrackfit_cff::barrel, barrel_, goodpair_, goodpair__, havepair_, havepair__, idle_, and layerdisk_.

8  : luttable_(luttable), candmatches_(3) {
9  idle_ = true;
10  barrel_ = barrel;
11  layerdisk_ = layerdisk;
12  goodpair_ = false;
13  goodpair__ = false;
14  havepair_ = false;
15  havepair__ = false;
16 }
CircularBuffer< std::pair< Tracklet *, const Stub * > > candmatches_
const TrackletLUT & luttable_

◆ ~MatchEngineUnit()

trklet::MatchEngineUnit::~MatchEngineUnit ( )
default

Member Function Documentation

◆ active()

bool trklet::MatchEngineUnit::active ( void  ) const
inline

Definition at line 53 of file MatchEngineUnit.h.

References empty(), goodpair_, goodpair__, and idle_.

◆ currentProj()

Tracklet* trklet::MatchEngineUnit::currentProj ( ) const
inline

Definition at line 49 of file MatchEngineUnit.h.

References proj_.

49 { return proj_; }

◆ empty()

bool trklet::MatchEngineUnit::empty ( void  ) const
inline

Definition at line 41 of file MatchEngineUnit.h.

References candmatches_.

Referenced by active(), and TCID().

41 { return candmatches_.empty(); }
CircularBuffer< std::pair< Tracklet *, const Stub * > > candmatches_

◆ have_()

bool trklet::MatchEngineUnit::have_ ( ) const
inline

Definition at line 56 of file MatchEngineUnit.h.

References havepair_.

56 { return havepair_; }

◆ have__()

bool trklet::MatchEngineUnit::have__ ( ) const
inline

Definition at line 57 of file MatchEngineUnit.h.

References havepair__.

57 { return havepair__; }

◆ idle()

bool trklet::MatchEngineUnit::idle ( ) const
inline

Definition at line 51 of file MatchEngineUnit.h.

References idle_.

Referenced by step().

51 { return idle_; }

◆ init()

void MatchEngineUnit::init ( VMStubsMEMemory vmstubsmemory,
unsigned int  nrzbin,
unsigned int  rzbin,
unsigned int  iphi,
int  shift,
int  projrinv,
int  projfinerz,
int  projfinephi,
bool  usefirstMinus,
bool  usefirstPlus,
bool  usesecondMinus,
bool  usesecondPlus,
bool  isPSseed,
Tracklet proj,
bool  print 
)

Definition at line 18 of file MatchEngineUnit.cc.

References cms::cuda::assert(), candmatches_, goodpair_, goodpair__, havepair_, havepair__, idle_, isPSseed_, istub_, iuse_, nrzbins_, phibin_, amptDefault_cfi::proj, proj_, projfinephi_, projfinerz_, projrinv_, rzbin_, edm::shift, shift_, tmppair_, tmppair__, use_, and vmstubsmemory_.

32  {
33  vmstubsmemory_ = vmstubsmemory;
34  idle_ = false;
35  nrzbins_ = nrzbins;
36  rzbin_ = rzbin;
37  phibin_ = phibin;
38  shift_ = shift;
39  istub_ = 0;
40  iuse_ = 0;
41  projrinv_ = projrinv;
42  projfinerz_ = projfinerz;
43  projfinephi_ = projfinephi;
44  use_.clear();
45  if (usefirstMinus) {
46  use_.emplace_back(0, 0);
47  }
48  if (usesecondMinus) {
49  use_.emplace_back(1, 0);
50  }
51  if (usefirstPlus) {
52  use_.emplace_back(0, 1);
53  }
54  if (usesecondPlus) {
55  use_.emplace_back(1, 1);
56  }
57  assert(!use_.empty());
58  isPSseed_ = isPSseed;
59  proj_ = proj;
60 
61  //Even when you init a new projection you need to process the pipeline
62  //This should be fixed to be done more cleanly - but require synchronizaton
63  //with the HLS code
64  if (goodpair__) {
65  candmatches_.store(tmppair__);
66  }
67 
71 
72  havepair_ = false;
73  goodpair_ = false;
74 }
assert(be >=bs)
CircularBuffer< std::pair< Tracklet *, const Stub * > > candmatches_
std::pair< Tracklet *, const Stub * > tmppair_
VMStubsMEMemory * vmstubsmemory_
std::pair< Tracklet *, const Stub * > tmppair__
std::vector< std::pair< unsigned int, unsigned int > > use_
static unsigned int const shift

◆ peek()

std::pair<Tracklet*, const Stub*> trklet::MatchEngineUnit::peek ( ) const
inline

Definition at line 47 of file MatchEngineUnit.h.

References candmatches_.

Referenced by TCID().

47 { return candmatches_.peek(); }
CircularBuffer< std::pair< Tracklet *, const Stub * > > candmatches_

◆ read()

std::pair<Tracklet*, const Stub*> trklet::MatchEngineUnit::read ( )
inline

Definition at line 45 of file MatchEngineUnit.h.

References candmatches_.

Referenced by edmIntegrityCheck.PublishToFileSystem::get().

45 { return candmatches_.read(); }
CircularBuffer< std::pair< Tracklet *, const Stub * > > candmatches_

◆ reset()

void MatchEngineUnit::reset ( void  )

Definition at line 173 of file MatchEngineUnit.cc.

References candmatches_, goodpair_, goodpair__, havepair_, havepair__, idle_, and istub_.

173  {
174  candmatches_.reset();
175  idle_ = true;
176  istub_ = 0;
177  goodpair_ = false;
178  goodpair__ = false;
179  havepair_ = false;
180  havepair__ = false;
181 }
CircularBuffer< std::pair< Tracklet *, const Stub * > > candmatches_

◆ rptr()

unsigned int trklet::MatchEngineUnit::rptr ( ) const
inline

Definition at line 61 of file MatchEngineUnit.h.

References candmatches_.

61 { return candmatches_.rptr(); }
CircularBuffer< std::pair< Tracklet *, const Stub * > > candmatches_

◆ step()

void MatchEngineUnit::step ( bool  print)

Definition at line 76 of file MatchEngineUnit.cc.

References funct::abs(), cms::cuda::assert(), barrel_, trklet::VMStubME::bend(), candmatches_, trklet::VMStubME::finephi(), trklet::VMStubME::finerz(), first, trklet::VMStubsMEMemory::getVMStubMEBin(), goodpair_, goodpair__, havepair_, havepair__, idle(), idle_, trklet::VMStubME::isPSmodule(), isPSseed_, istub_, iuse_, trklet::TrackletLUT::lookup(), luttable_, trklet::NFINEPHIBITS, trklet::NFINERZBITS, nrzbins_, trklet::VMStubsMEMemory::nStubsBin(), phibin_, print(), proj_, projfinephi_, projfinerz_, projrinv_, rzbin_, edm::second(), shift_, trklet::VMStubME::stub(), trklet::VMStubME::stubindex(), trklet::Tracklet::TCIndex(), tmppair_, tmppair__, trklet::Tracklet::trackletIndex(), use_, trklet::FPGAWord::value(), and vmstubsmemory_.

76  {
77  bool almostfull = candmatches_.nearfull();
78 
79  if (goodpair__) {
81  candmatches_.store(tmppair__);
82  }
83 
87 
88  havepair_ = false;
89  goodpair_ = false;
90 
91  if (idle() || almostfull)
92  return;
93 
94  unsigned int slot = (phibin_ + use_[iuse_].second) * nrzbins_ + rzbin_ + use_[iuse_].first;
95 
96  int projfinerz = projfinerz_ - (1 << NFINERZBITS) * use_[iuse_].first;
97  int projfinephi = projfinephi_;
98  if (use_[iuse_].second == 0) {
99  if (shift_ == -1) {
100  projfinephi -= (1 << NFINEPHIBITS);
101  }
102  } else {
103  //When we get here shift_ is either 1 or -1
104  if (shift_ == 1) {
105  projfinephi += (1 << NFINEPHIBITS);
106  }
107  }
108 
109  const VMStubME& vmstub = vmstubsmemory_->getVMStubMEBin(slot, istub_);
110 
111  bool isPSmodule = vmstub.isPSmodule();
112  int stubfinerz = vmstub.finerz().value();
113  int stubfinephi = vmstub.finephi().value();
114 
115  int deltaphi = stubfinephi - projfinephi;
116 
117  bool dphicut = (abs(deltaphi) < 3);
118 
119  int nbits = isPSmodule ? 3 : 4;
120 
121  int diskps = (!barrel_) && isPSmodule;
122 
123  unsigned int index = (diskps << (4 + 5)) + (projrinv_ << nbits) + vmstub.bend().value();
124 
125  //Check if stub z position consistent
126  int idrz = stubfinerz - projfinerz;
127  bool pass;
128 
129  if (barrel_) {
130  if (isPSseed_) {
131  pass = idrz >= -1 && idrz <= 1;
132  } else {
133  pass = idrz >= -5 && idrz <= 5;
134  }
135  } else {
136  if (isPSmodule) {
137  pass = idrz >= -1 && idrz <= 1;
138  } else {
139  pass = idrz >= -3 && idrz <= 3;
140  }
141  }
142 
143  // Detailed printout for comparison with HLS code
144  bool print = false;
145  if (print)
146  edm::LogVerbatim("Tracklet") << "MEU TrkId stubindex : " << 128 * proj_->TCIndex() + proj_->trackletIndex() << " "
147  << vmstub.stubindex().value() << " "
148  << ((pass && dphicut) && luttable_.lookup(index)) << " index=" << index
149  << " projrinv bend : " << projrinv_ << " " << vmstub.bend().value()
150  << " shift_ isPSseed_ :" << shift_ << " " << isPSseed_ << " slot=" << slot;
151 
152  //Check if stub bend and proj rinv consistent
153 
154  goodpair_ = (pass && dphicut) && luttable_.lookup(index);
155  havepair_ = true;
156 
157  if (havepair_) {
158  std::pair<Tracklet*, const Stub*> tmppair(proj_, vmstub.stub());
159  tmppair_ = tmppair;
160  }
161 
162  istub_++;
163  if (istub_ >= vmstubsmemory_->nStubsBin(slot)) {
164  iuse_++;
165  if (iuse_ < use_.size()) {
166  istub_ = 0;
167  } else {
168  idle_ = true;
169  }
170  }
171 }
Log< level::Info, true > LogVerbatim
const FPGAWord & bend() const
Definition: VMStubME.h:26
const FPGAWord & finerz() const
Definition: VMStubME.h:24
const Stub * stub() const
Definition: VMStubME.h:28
int lookup(unsigned int index) const
Definition: TrackletLUT.cc:900
assert(be >=bs)
bool isPSmodule() const
Definition: VMStubME.h:30
int TCIndex() const
Definition: Tracklet.h:210
U second(std::pair< T, U > const &p)
CircularBuffer< std::pair< Tracklet *, const Stub * > > candmatches_
int trackletIndex() const
Definition: Tracklet.h:206
const FPGAWord & stubindex() const
Definition: VMStubME.h:32
const TrackletLUT & luttable_
std::pair< Tracklet *, const Stub * > tmppair_
const VMStubME & getVMStubMEBin(unsigned int bin, unsigned int i) const
VMStubsMEMemory * vmstubsmemory_
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int value() const
Definition: FPGAWord.h:24
constexpr unsigned int NFINERZBITS
Definition: Settings.h:33
std::pair< Tracklet *, const Stub * > tmppair__
std::vector< std::pair< unsigned int, unsigned int > > use_
constexpr unsigned int NFINEPHIBITS
Definition: Settings.h:34
const FPGAWord & finephi() const
Definition: VMStubME.h:23
unsigned int nStubsBin(unsigned int bin) const

◆ TCID()

int MatchEngineUnit::TCID ( ) const

Definition at line 183 of file MatchEngineUnit.cc.

References empty(), havepair_, havepair__, idle_, peek(), proj_, trklet::Tracklet::TCID(), tmppair_, and tmppair__.

183  {
184  if (!empty()) {
185  return peek().first->TCID();
186  }
187 
188  if (idle_ && !havepair_ && !havepair__) {
189  return 16383;
190  }
191  if (havepair__) {
192  return tmppair__.first->TCID();
193  }
194  if (havepair_) {
195  return tmppair_.first->TCID();
196  }
197  return proj_->TCID();
198 }
int TCID() const
Definition: Tracklet.h:212
std::pair< Tracklet *, const Stub * > peek() const
std::pair< Tracklet *, const Stub * > tmppair_
std::pair< Tracklet *, const Stub * > tmppair__

◆ wptr()

unsigned int trklet::MatchEngineUnit::wptr ( ) const
inline

Definition at line 62 of file MatchEngineUnit.h.

References candmatches_.

62 { return candmatches_.wptr(); }
CircularBuffer< std::pair< Tracklet *, const Stub * > > candmatches_

Member Data Documentation

◆ barrel_

bool trklet::MatchEngineUnit::barrel_
private

Definition at line 77 of file MatchEngineUnit.h.

Referenced by MatchEngineUnit(), and step().

◆ candmatches_

CircularBuffer<std::pair<Tracklet*, const Stub*> > trklet::MatchEngineUnit::candmatches_
private

Definition at line 98 of file MatchEngineUnit.h.

Referenced by empty(), init(), peek(), read(), reset(), rptr(), step(), and wptr().

◆ goodpair_

bool trklet::MatchEngineUnit::goodpair_
private

Definition at line 94 of file MatchEngineUnit.h.

Referenced by active(), init(), MatchEngineUnit(), reset(), and step().

◆ goodpair__

bool trklet::MatchEngineUnit::goodpair__
private

Definition at line 94 of file MatchEngineUnit.h.

Referenced by active(), init(), MatchEngineUnit(), reset(), and step().

◆ havepair_

bool trklet::MatchEngineUnit::havepair_
private

Definition at line 95 of file MatchEngineUnit.h.

Referenced by have_(), init(), MatchEngineUnit(), reset(), step(), and TCID().

◆ havepair__

bool trklet::MatchEngineUnit::havepair__
private

Definition at line 95 of file MatchEngineUnit.h.

Referenced by have__(), init(), MatchEngineUnit(), reset(), step(), and TCID().

◆ idle_

bool trklet::MatchEngineUnit::idle_
private

Definition at line 85 of file MatchEngineUnit.h.

Referenced by active(), idle(), init(), MatchEngineUnit(), reset(), step(), and TCID().

◆ isPSseed_

bool trklet::MatchEngineUnit::isPSseed_
private

Definition at line 82 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ istub_

unsigned int trklet::MatchEngineUnit::istub_
private

Definition at line 74 of file MatchEngineUnit.h.

Referenced by init(), reset(), and step().

◆ iuse_

unsigned int trklet::MatchEngineUnit::iuse_
private

Definition at line 75 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ layerdisk_

unsigned int trklet::MatchEngineUnit::layerdisk_
private

Definition at line 87 of file MatchEngineUnit.h.

Referenced by MatchEngineUnit().

◆ luttable_

const TrackletLUT& trklet::MatchEngineUnit::luttable_
private

Definition at line 90 of file MatchEngineUnit.h.

Referenced by step().

◆ nrzbins_

unsigned int trklet::MatchEngineUnit::nrzbins_
private

Definition at line 69 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ phibin_

unsigned int trklet::MatchEngineUnit::phibin_
private

Definition at line 71 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ proj_

Tracklet* trklet::MatchEngineUnit::proj_
private

Definition at line 83 of file MatchEngineUnit.h.

Referenced by currentProj(), init(), step(), and TCID().

◆ projfinephi_

int trklet::MatchEngineUnit::projfinephi_
private

Definition at line 80 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ projfinerz_

int trklet::MatchEngineUnit::projfinerz_
private

Definition at line 79 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ projrinv_

int trklet::MatchEngineUnit::projrinv_
private

Definition at line 78 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ rzbin_

unsigned int trklet::MatchEngineUnit::rzbin_
private

Definition at line 70 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ shift_

int trklet::MatchEngineUnit::shift_
private

Definition at line 72 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ tmppair_

std::pair<Tracklet*, const Stub*> trklet::MatchEngineUnit::tmppair_
private

Definition at line 93 of file MatchEngineUnit.h.

Referenced by init(), step(), and TCID().

◆ tmppair__

std::pair<Tracklet*, const Stub*> trklet::MatchEngineUnit::tmppair__
private

Definition at line 93 of file MatchEngineUnit.h.

Referenced by init(), step(), and TCID().

◆ use_

std::vector<std::pair<unsigned int, unsigned int> > trklet::MatchEngineUnit::use_
private

Definition at line 81 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ vmstubsmemory_

VMStubsMEMemory* trklet::MatchEngineUnit::vmstubsmemory_
private

Definition at line 67 of file MatchEngineUnit.h.

Referenced by init(), and step().