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
 
bool empty () 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)
 
 MatchEngineUnit (const Settings &settings, bool barrel, unsigned int layerdisk, const TrackletLUT &luttable)
 
std::pair< Tracklet *, const Stub * > peek () const
 
void processPipeline ()
 
std::pair< Tracklet *, const Stub * > read ()
 
void reset ()
 
unsigned int rptr () const
 
void setAlmostFull ()
 
void setimeu (int imeu)
 
void setprint (bool print)
 
void step ()
 
int TCID () const
 
unsigned int wptr () const
 
 ~MatchEngineUnit ()=default
 

Private Attributes

bool almostfullsave_
 
bool barrel_
 
CircularBuffer< std::pair< Tracklet *, const Stub * > > candmatches_
 
bool good__
 
bool good___
 
bool good__t
 
bool idle_
 
int imeu_
 
bool isPSseed_
 
bool isPSseed__
 
bool isPSseed___
 
bool isPSseed__t
 
unsigned int istub_
 
unsigned int iuse_
 
unsigned int layerdisk_
 
const TrackletLUTluttable_
 
unsigned int nrzbins_
 
unsigned int phibin_
 
bool print_
 
Trackletproj_
 
Trackletproj__
 
Trackletproj___
 
Trackletproj__t
 
int projfinephi_
 
int projfinephi__
 
int projfinephi___
 
int projfinephi__t
 
int projfinerz_
 
int projfinerz__
 
int projfinerz___
 
int projfinerz__t
 
int projrinv_
 
int projrinv__
 
int projrinv___
 
int projrinv__t
 
unsigned int rzbin_
 
const Settingssettings_
 
int shift_
 
std::vector< std::pair< unsigned int, unsigned int > > use_
 
VMStubME vmstub__
 
VMStubME vmstub___
 
VMStubME vmstub__t
 
VMStubsMEMemoryvmstubsmemory_
 

Detailed Description

Definition at line 28 of file MatchEngineUnit.h.

Constructor & Destructor Documentation

◆ MatchEngineUnit()

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

Definition at line 8 of file MatchEngineUnit.cc.

References Reference_intrackfit_cff::barrel, barrel_, good__, good___, good__t, idle_, imeu_, layerdisk_, and print_.

12  : settings_(settings), luttable_(luttable), candmatches_(3) {
13  idle_ = true;
14  print_ = false;
15  imeu_ = -1;
16  barrel_ = barrel;
17  layerdisk_ = layerdisk;
18  good__ = false;
19  good__t = false;
20  good___ = false;
21 }
const Settings & settings_
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 59 of file MatchEngineUnit.h.

References empty(), good__, good___, and idle_.

◆ empty()

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

Definition at line 49 of file MatchEngineUnit.h.

References candmatches_.

Referenced by active(), and TCID().

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

◆ idle()

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

Definition at line 57 of file MatchEngineUnit.h.

References idle_.

Referenced by step().

57 { 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 
)

Definition at line 25 of file MatchEngineUnit.cc.

References cms::cuda::assert(), good__, idle_, isPSseed_, istub_, iuse_, nrzbins_, phibin_, amptDefault_cfi::proj, proj_, projfinephi_, projfinerz_, projrinv_, rzbin_, edm::shift, shift_, use_, and vmstubsmemory_.

38  {
39  vmstubsmemory_ = vmstubsmemory;
40  idle_ = false;
41  nrzbins_ = nrzbins;
42  rzbin_ = rzbin;
43  phibin_ = phibin;
44  shift_ = shift;
45  istub_ = 0;
46  iuse_ = 0;
47  projrinv_ = projrinv;
48  projfinerz_ = projfinerz;
49  projfinephi_ = projfinephi;
50  use_.clear();
51  if (usefirstMinus) {
52  use_.emplace_back(0, 0);
53  }
54  if (usesecondMinus) {
55  use_.emplace_back(1, 0);
56  }
57  if (usefirstPlus) {
58  use_.emplace_back(0, 1);
59  }
60  if (usesecondPlus) {
61  use_.emplace_back(1, 1);
62  }
63  assert(!use_.empty());
64  isPSseed_ = isPSseed;
65  proj_ = proj;
66 
67  good__ = false;
68 }
assert(be >=bs)
VMStubsMEMemory * vmstubsmemory_
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 55 of file MatchEngineUnit.h.

References candmatches_.

Referenced by TCID().

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

◆ processPipeline()

void MatchEngineUnit::processPipeline ( )

Definition at line 108 of file MatchEngineUnit.cc.

References funct::abs(), barrel_, trklet::VMStubME::bend(), candmatches_, trklet::VMStubME::finephi(), trklet::VMStubME::finerz(), good__, good___, good__t, trklet::VMStubME::isPSmodule(), isPSseed__, isPSseed___, isPSseed__t, trklet::TrackletLUT::lookup(), luttable_, trklet::N_BENDBITS_2S, trklet::N_BENDBITS_PS, trklet::NRINVBITS, proj__, proj___, proj__t, projfinephi__, projfinephi___, projfinephi__t, projfinerz__, projfinerz___, projfinerz__t, projrinv__, projrinv___, projrinv__t, trklet::VMStubME::stub(), trklet::FPGAWord::value(), vmstub__, vmstub___, and vmstub__t.

108  {
109  if (good___) {
110  bool isPSmodule = vmstub___.isPSmodule();
111  int stubfinerz = vmstub___.finerz().value();
112  int stubfinephi = vmstub___.finephi().value();
113 
114  int deltaphi = stubfinephi - projfinephi___;
115 
116  constexpr int idphicut = 3;
117 
118  bool dphicut = (abs(deltaphi) < idphicut);
119 
120  int nbits = isPSmodule ? N_BENDBITS_PS : N_BENDBITS_2S;
121 
122  int diskps = (!barrel_) && isPSmodule;
123 
124  //here we always use the larger number of bits for the bend
125  unsigned int index = (diskps << (N_BENDBITS_2S + NRINVBITS)) + (projrinv___ << nbits) + vmstub___.bend().value();
126 
127  //Check if stub z position consistent
128  int idrz = stubfinerz - projfinerz___;
129  bool pass;
130 
131  if (barrel_) {
132  if (isPSseed___) {
133  constexpr int drzcut = 1;
134  pass = std::abs(idrz) <= drzcut;
135  } else {
136  constexpr int drzcut = 5;
137  pass = std::abs(idrz) <= drzcut;
138  }
139  } else {
140  if (isPSmodule) {
141  constexpr int drzcut = 1;
142  pass = std::abs(idrz) <= drzcut;
143  } else {
144  constexpr int drzcut = 3;
145  pass = std::abs(idrz) <= drzcut;
146  }
147  }
148 
149  bool goodpair = (pass && dphicut) && luttable_.lookup(index);
150 
151  std::pair<Tracklet*, const Stub*> tmppair(proj___, vmstub___.stub());
152 
153  if (goodpair) {
154  candmatches_.store(tmppair);
155  }
156  }
157 
158  proj___ = proj__t;
163  good___ = good__t;
165 
166  proj__t = proj__;
171  good__t = good__;
173 }
const FPGAWord & bend() const
Definition: VMStubME.h:26
const FPGAWord & finerz() const
Definition: VMStubME.h:24
const Stub * stub() const
Definition: VMStubME.h:28
constexpr unsigned int NRINVBITS
Definition: Settings.h:36
constexpr unsigned int N_BENDBITS_2S
Definition: Settings.h:34
int lookup(unsigned int index) const
bool isPSmodule() const
Definition: VMStubME.h:30
constexpr unsigned int N_BENDBITS_PS
Definition: Settings.h:33
CircularBuffer< std::pair< Tracklet *, const Stub * > > candmatches_
const TrackletLUT & luttable_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int value() const
Definition: FPGAWord.h:24
const FPGAWord & finephi() const
Definition: VMStubME.h:23

◆ read()

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

Definition at line 53 of file MatchEngineUnit.h.

References candmatches_.

Referenced by edmIntegrityCheck.PublishToFileSystem::get().

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

◆ reset()

void MatchEngineUnit::reset ( void  )

Definition at line 175 of file MatchEngineUnit.cc.

References candmatches_, good__, good___, good__t, idle_, and istub_.

175  {
176  candmatches_.reset();
177  idle_ = true;
178  istub_ = 0;
179  good__ = false;
180  good__t = false;
181  good___ = false;
182 }
CircularBuffer< std::pair< Tracklet *, const Stub * > > candmatches_

◆ rptr()

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

Definition at line 69 of file MatchEngineUnit.h.

References candmatches_.

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

◆ setAlmostFull()

void MatchEngineUnit::setAlmostFull ( )

Definition at line 23 of file MatchEngineUnit.cc.

References almostfullsave_, and candmatches_.

23 { almostfullsave_ = candmatches_.nearfull(); }
CircularBuffer< std::pair< Tracklet *, const Stub * > > candmatches_

◆ setimeu()

void trklet::MatchEngineUnit::setimeu ( int  imeu)
inline

Definition at line 63 of file MatchEngineUnit.h.

References imeu_.

Referenced by trklet::MatchProcessor::MatchProcessor().

63 { imeu_ = imeu; }

◆ setprint()

void trklet::MatchEngineUnit::setprint ( bool  print)
inline

Definition at line 65 of file MatchEngineUnit.h.

References print(), and print_.

65 { print_ = print; }
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

◆ step()

void MatchEngineUnit::step ( )

Definition at line 70 of file MatchEngineUnit.cc.

References almostfullsave_, dqmdumpme::first, trklet::VMStubsMEMemory::getVMStubMEBin(), good__, idle(), idle_, isPSseed_, isPSseed__, istub_, iuse_, trklet::NFINEPHIBITS, trklet::NFINERZBITS, nrzbins_, trklet::VMStubsMEMemory::nStubsBin(), phibin_, proj_, proj__, projfinephi_, projfinephi__, projfinerz_, projfinerz__, projrinv_, projrinv__, rzbin_, edm::second(), shift_, use_, vmstub__, and vmstubsmemory_.

70  {
71  good__ = !idle() && !almostfullsave_;
72 
73  if (!good__)
74  return;
75 
76  unsigned int slot = (phibin_ + use_[iuse_].second) * nrzbins_ + rzbin_ + use_[iuse_].first;
77 
80  if (use_[iuse_].second == 0) {
81  if (shift_ == -1) {
82  projfinephi__ -= (1 << NFINEPHIBITS);
83  }
84  } else {
85  //When we get here shift_ is either 1 or -1
86  if (shift_ == 1) {
87  projfinephi__ += (1 << NFINEPHIBITS);
88  }
89  }
90 
92 
95  proj__ = proj_;
96 
97  istub_++;
98  if (istub_ >= vmstubsmemory_->nStubsBin(slot)) {
99  iuse_++;
100  if (iuse_ < use_.size()) {
101  istub_ = 0;
102  } else {
103  idle_ = true;
104  }
105  }
106 }
U second(std::pair< T, U > const &p)
const VMStubME & getVMStubMEBin(unsigned int bin, unsigned int i) const
VMStubsMEMemory * vmstubsmemory_
constexpr unsigned int NFINERZBITS
Definition: Settings.h:37
std::vector< std::pair< unsigned int, unsigned int > > use_
constexpr unsigned int NFINEPHIBITS
Definition: Settings.h:38
unsigned int nStubsBin(unsigned int bin) const

◆ TCID()

int MatchEngineUnit::TCID ( ) const

Definition at line 184 of file MatchEngineUnit.cc.

References empty(), good__, good___, good__t, idle_, trklet::Settings::nbitstcindex(), trklet::Settings::nbitstrackletindex(), peek(), proj_, proj__, proj___, proj__t, settings_, and trklet::Tracklet::TCID().

184  {
185  if (!empty()) {
186  return peek().first->TCID();
187  }
188 
189  if (good___) {
190  return proj___->TCID();
191  }
192 
193  if (good__t) {
194  return proj__t->TCID();
195  }
196 
197  if (good__) {
198  return proj__->TCID();
199  }
200 
201  if (idle_) {
202  return (1 << (settings_.nbitstrackletindex() + settings_.nbitstcindex())) - 1;
203  }
204 
205  return proj_->TCID();
206 }
unsigned int nbitstrackletindex() const
Definition: Settings.h:303
int TCID() const
Definition: Tracklet.h:214
std::pair< Tracklet *, const Stub * > peek() const
const Settings & settings_
unsigned int nbitstcindex() const
Definition: Settings.h:308

◆ wptr()

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

Definition at line 70 of file MatchEngineUnit.h.

References candmatches_.

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

Member Data Documentation

◆ almostfullsave_

bool trklet::MatchEngineUnit::almostfullsave_
private

Definition at line 103 of file MatchEngineUnit.h.

Referenced by setAlmostFull(), and step().

◆ barrel_

bool trklet::MatchEngineUnit::barrel_
private

Definition at line 90 of file MatchEngineUnit.h.

Referenced by MatchEngineUnit(), and processPipeline().

◆ candmatches_

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

Definition at line 120 of file MatchEngineUnit.h.

Referenced by empty(), peek(), processPipeline(), read(), reset(), rptr(), setAlmostFull(), and wptr().

◆ good__

bool trklet::MatchEngineUnit::good__
private

Definition at line 113 of file MatchEngineUnit.h.

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

◆ good___

bool trklet::MatchEngineUnit::good___
private

Definition at line 113 of file MatchEngineUnit.h.

Referenced by active(), MatchEngineUnit(), processPipeline(), reset(), and TCID().

◆ good__t

bool trklet::MatchEngineUnit::good__t
private

Definition at line 113 of file MatchEngineUnit.h.

Referenced by MatchEngineUnit(), processPipeline(), reset(), and TCID().

◆ idle_

bool trklet::MatchEngineUnit::idle_
private

Definition at line 98 of file MatchEngineUnit.h.

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

◆ imeu_

int trklet::MatchEngineUnit::imeu_
private

Definition at line 123 of file MatchEngineUnit.h.

Referenced by MatchEngineUnit(), and setimeu().

◆ isPSseed_

bool trklet::MatchEngineUnit::isPSseed_
private

Definition at line 95 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ isPSseed__

bool trklet::MatchEngineUnit::isPSseed__
private

Definition at line 112 of file MatchEngineUnit.h.

Referenced by processPipeline(), and step().

◆ isPSseed___

bool trklet::MatchEngineUnit::isPSseed___
private

Definition at line 112 of file MatchEngineUnit.h.

Referenced by processPipeline().

◆ isPSseed__t

bool trklet::MatchEngineUnit::isPSseed__t
private

Definition at line 112 of file MatchEngineUnit.h.

Referenced by processPipeline().

◆ istub_

unsigned int trklet::MatchEngineUnit::istub_
private

Definition at line 87 of file MatchEngineUnit.h.

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

◆ iuse_

unsigned int trklet::MatchEngineUnit::iuse_
private

Definition at line 88 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ layerdisk_

unsigned int trklet::MatchEngineUnit::layerdisk_
private

Definition at line 100 of file MatchEngineUnit.h.

Referenced by MatchEngineUnit().

◆ luttable_

const TrackletLUT& trklet::MatchEngineUnit::luttable_
private

Definition at line 106 of file MatchEngineUnit.h.

Referenced by processPipeline().

◆ nrzbins_

unsigned int trklet::MatchEngineUnit::nrzbins_
private

Definition at line 82 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ phibin_

unsigned int trklet::MatchEngineUnit::phibin_
private

Definition at line 84 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ print_

bool trklet::MatchEngineUnit::print_
private

Definition at line 124 of file MatchEngineUnit.h.

Referenced by MatchEngineUnit(), and setprint().

◆ proj_

Tracklet* trklet::MatchEngineUnit::proj_
private

Definition at line 96 of file MatchEngineUnit.h.

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

◆ proj__

Tracklet* trklet::MatchEngineUnit::proj__
private

Definition at line 117 of file MatchEngineUnit.h.

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

◆ proj___

Tracklet * trklet::MatchEngineUnit::proj___
private

Definition at line 117 of file MatchEngineUnit.h.

Referenced by processPipeline(), and TCID().

◆ proj__t

Tracklet * trklet::MatchEngineUnit::proj__t
private

Definition at line 117 of file MatchEngineUnit.h.

Referenced by processPipeline(), and TCID().

◆ projfinephi_

int trklet::MatchEngineUnit::projfinephi_
private

Definition at line 93 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ projfinephi__

int trklet::MatchEngineUnit::projfinephi__
private

Definition at line 115 of file MatchEngineUnit.h.

Referenced by processPipeline(), and step().

◆ projfinephi___

int trklet::MatchEngineUnit::projfinephi___
private

Definition at line 115 of file MatchEngineUnit.h.

Referenced by processPipeline().

◆ projfinephi__t

int trklet::MatchEngineUnit::projfinephi__t
private

Definition at line 115 of file MatchEngineUnit.h.

Referenced by processPipeline().

◆ projfinerz_

int trklet::MatchEngineUnit::projfinerz_
private

Definition at line 92 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ projfinerz__

int trklet::MatchEngineUnit::projfinerz__
private

Definition at line 114 of file MatchEngineUnit.h.

Referenced by processPipeline(), and step().

◆ projfinerz___

int trklet::MatchEngineUnit::projfinerz___
private

Definition at line 114 of file MatchEngineUnit.h.

Referenced by processPipeline().

◆ projfinerz__t

int trklet::MatchEngineUnit::projfinerz__t
private

Definition at line 114 of file MatchEngineUnit.h.

Referenced by processPipeline().

◆ projrinv_

int trklet::MatchEngineUnit::projrinv_
private

Definition at line 91 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ projrinv__

int trklet::MatchEngineUnit::projrinv__
private

Definition at line 116 of file MatchEngineUnit.h.

Referenced by processPipeline(), and step().

◆ projrinv___

int trklet::MatchEngineUnit::projrinv___
private

Definition at line 116 of file MatchEngineUnit.h.

Referenced by processPipeline().

◆ projrinv__t

int trklet::MatchEngineUnit::projrinv__t
private

Definition at line 116 of file MatchEngineUnit.h.

Referenced by processPipeline().

◆ rzbin_

unsigned int trklet::MatchEngineUnit::rzbin_
private

Definition at line 83 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ settings_

const Settings& trklet::MatchEngineUnit::settings_
private

Definition at line 78 of file MatchEngineUnit.h.

Referenced by TCID().

◆ shift_

int trklet::MatchEngineUnit::shift_
private

Definition at line 85 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ use_

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

Definition at line 94 of file MatchEngineUnit.h.

Referenced by init(), and step().

◆ vmstub__

VMStubME trklet::MatchEngineUnit::vmstub__
private

Definition at line 111 of file MatchEngineUnit.h.

Referenced by processPipeline(), and step().

◆ vmstub___

VMStubME trklet::MatchEngineUnit::vmstub___
private

Definition at line 111 of file MatchEngineUnit.h.

Referenced by processPipeline().

◆ vmstub__t

VMStubME trklet::MatchEngineUnit::vmstub__t
private

Definition at line 111 of file MatchEngineUnit.h.

Referenced by processPipeline().

◆ vmstubsmemory_

VMStubsMEMemory* trklet::MatchEngineUnit::vmstubsmemory_
private

Definition at line 80 of file MatchEngineUnit.h.

Referenced by init(), and step().