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.

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 }

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

◆ ~MatchEngineUnit()

trklet::MatchEngineUnit::~MatchEngineUnit ( )
default

Member Function Documentation

◆ active()

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

Definition at line 53 of file MatchEngineUnit.h.

53 { return !idle_ || goodpair_ || goodpair__ || !empty(); }

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

◆ currentProj()

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

Definition at line 49 of file MatchEngineUnit.h.

49 { return proj_; }

References proj_.

◆ empty()

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

Definition at line 41 of file MatchEngineUnit.h.

41 { return candmatches_.empty(); }

References candmatches_.

Referenced by active(), and TCID().

◆ have_()

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

Definition at line 56 of file MatchEngineUnit.h.

56 { return havepair_; }

References havepair_.

◆ have__()

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

Definition at line 57 of file MatchEngineUnit.h.

57 { return havepair__; }

References havepair__.

◆ idle()

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

Definition at line 51 of file MatchEngineUnit.h.

51 { return idle_; }

References idle_.

Referenced by step().

◆ 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.

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 }

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_.

◆ peek()

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

Definition at line 47 of file MatchEngineUnit.h.

47 { return candmatches_.peek(); }

References candmatches_.

Referenced by TCID().

◆ read()

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

Definition at line 45 of file MatchEngineUnit.h.

45 { return candmatches_.read(); }

References candmatches_.

Referenced by edmIntegrityCheck.PublishToFileSystem::get().

◆ reset()

void MatchEngineUnit::reset ( void  )

Definition at line 173 of file MatchEngineUnit.cc.

173  {
174  candmatches_.reset();
175  idle_ = true;
176  istub_ = 0;
177  goodpair_ = false;
178  goodpair__ = false;
179  havepair_ = false;
180  havepair__ = false;
181 }

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

◆ rptr()

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

Definition at line 61 of file MatchEngineUnit.h.

61 { return candmatches_.rptr(); }

References candmatches_.

◆ step()

void MatchEngineUnit::step ( bool  print)

Definition at line 76 of file MatchEngineUnit.cc.

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 }

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_.

◆ TCID()

int MatchEngineUnit::TCID ( ) const

Definition at line 183 of file MatchEngineUnit.cc.

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 }

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

◆ wptr()

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

Definition at line 62 of file MatchEngineUnit.h.

62 { return candmatches_.wptr(); }

References 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().

trklet::Tracklet::TCIndex
int TCIndex() const
Definition: Tracklet.h:210
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
trklet::TrackletLUT::lookup
int lookup(unsigned int index) const
Definition: TrackletLUT.cc:900
trklet::MatchEngineUnit::havepair_
bool havepair_
Definition: MatchEngineUnit.h:95
trklet::VMStubME::isPSmodule
bool isPSmodule() const
Definition: VMStubME.h:30
trklet::VMStubsMEMemory::getVMStubMEBin
const VMStubME & getVMStubMEBin(unsigned int bin, unsigned int i) const
Definition: VMStubsMEMemory.h:35
trklet::MatchEngineUnit::projrinv_
int projrinv_
Definition: MatchEngineUnit.h:78
cms::cuda::assert
assert(be >=bs)
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
trklet::MatchEngineUnit::peek
std::pair< Tracklet *, const Stub * > peek() const
Definition: MatchEngineUnit.h:47
trklet::VMStubME::bend
const FPGAWord & bend() const
Definition: VMStubME.h:26
trklet::MatchEngineUnit::layerdisk_
unsigned int layerdisk_
Definition: MatchEngineUnit.h:87
trklet::MatchEngineUnit::istub_
unsigned int istub_
Definition: MatchEngineUnit.h:74
trklet::Tracklet::trackletIndex
int trackletIndex() const
Definition: Tracklet.h:206
trklet::MatchEngineUnit::rzbin_
unsigned int rzbin_
Definition: MatchEngineUnit.h:70
trklet::MatchEngineUnit::luttable_
const TrackletLUT & luttable_
Definition: MatchEngineUnit.h:90
trklet::VMStubME::stub
const Stub * stub() const
Definition: VMStubME.h:28
trklet::MatchEngineUnit::goodpair__
bool goodpair__
Definition: MatchEngineUnit.h:94
trklet::NFINEPHIBITS
constexpr unsigned int NFINEPHIBITS
Definition: Settings.h:34
trklet::MatchEngineUnit::candmatches_
CircularBuffer< std::pair< Tracklet *, const Stub * > > candmatches_
Definition: MatchEngineUnit.h:98
trklet::MatchEngineUnit::barrel_
bool barrel_
Definition: MatchEngineUnit.h:77
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
trklet::MatchEngineUnit::empty
bool empty() const
Definition: MatchEngineUnit.h:41
trklet::MatchEngineUnit::nrzbins_
unsigned int nrzbins_
Definition: MatchEngineUnit.h:69
amptDefault_cfi.proj
proj
Definition: amptDefault_cfi.py:13
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
trklet::Tracklet::TCID
int TCID() const
Definition: Tracklet.h:212
trklet::MatchEngineUnit::proj_
Tracklet * proj_
Definition: MatchEngineUnit.h:83
trklet::MatchEngineUnit::idle_
bool idle_
Definition: MatchEngineUnit.h:85
trklet::VMStubME::stubindex
const FPGAWord & stubindex() const
Definition: VMStubME.h:32
trklet::MatchEngineUnit::vmstubsmemory_
VMStubsMEMemory * vmstubsmemory_
Definition: MatchEngineUnit.h:67
trklet::MatchEngineUnit::use_
std::vector< std::pair< unsigned int, unsigned int > > use_
Definition: MatchEngineUnit.h:81
trklet::FPGAWord::value
int value() const
Definition: FPGAWord.h:24
trklet::MatchEngineUnit::isPSseed_
bool isPSseed_
Definition: MatchEngineUnit.h:82
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
trklet::NFINERZBITS
constexpr unsigned int NFINERZBITS
Definition: Settings.h:33
trklet::MatchEngineUnit::havepair__
bool havepair__
Definition: MatchEngineUnit.h:95
trklet::MatchEngineUnit::shift_
int shift_
Definition: MatchEngineUnit.h:72
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
trklet::MatchEngineUnit::tmppair_
std::pair< Tracklet *, const Stub * > tmppair_
Definition: MatchEngineUnit.h:93
trklet::MatchEngineUnit::projfinephi_
int projfinephi_
Definition: MatchEngineUnit.h:80
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
trklet::MatchEngineUnit::projfinerz_
int projfinerz_
Definition: MatchEngineUnit.h:79
trklet::MatchEngineUnit::iuse_
unsigned int iuse_
Definition: MatchEngineUnit.h:75
trklet::MatchEngineUnit::phibin_
unsigned int phibin_
Definition: MatchEngineUnit.h:71
trklet::MatchEngineUnit::idle
bool idle() const
Definition: MatchEngineUnit.h:51
trklet::VMStubME::finerz
const FPGAWord & finerz() const
Definition: VMStubME.h:24
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
trklet::VMStubME::finephi
const FPGAWord & finephi() const
Definition: VMStubME.h:23
trklet::VMStubME
Definition: VMStubME.h:15
trklet::VMStubsMEMemory::nStubsBin
unsigned int nStubsBin(unsigned int bin) const
Definition: VMStubsMEMemory.h:30
trklet::MatchEngineUnit::tmppair__
std::pair< Tracklet *, const Stub * > tmppair__
Definition: MatchEngineUnit.h:93
trklet::MatchEngineUnit::goodpair_
bool goodpair_
Definition: MatchEngineUnit.h:94