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 idle_
 
int imeu_
 
bool isPSseed_
 
bool isPSseed__
 
bool isPSseed___
 
unsigned int istub_
 
unsigned int iuse_
 
unsigned int layerdisk_
 
const TrackletLUTluttable_
 
unsigned int nrzbins_
 
unsigned int phibin_
 
bool print_
 
Trackletproj_
 
Trackletproj__
 
Trackletproj___
 
int projfinephi_
 
int projfinephi__
 
int projfinephi___
 
int projfinerz_
 
int projfinerz__
 
int projfinerz___
 
int projrinv_
 
int projrinv__
 
int projrinv___
 
unsigned int rzbin_
 
const Settingssettings_
 
int shift_
 
std::vector< std::pair< unsigned int, unsigned int > > use_
 
VMStubME vmstub__
 
VMStubME vmstub___
 
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___, 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___ = false;
20 }
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 24 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_.

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

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

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

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

166  {
167  candmatches_.reset();
168  idle_ = true;
169  istub_ = 0;
170  good__ = false;
171  good___ = false;
172 }
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 22 of file MatchEngineUnit.cc.

References almostfullsave_, and candmatches_.

22 { 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 69 of file MatchEngineUnit.cc.

References almostfullsave_, 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_.

69  {
70  good__ = !idle() && !almostfullsave_;
71 
72  if (!good__)
73  return;
74 
75  unsigned int slot = (phibin_ + use_[iuse_].second) * nrzbins_ + rzbin_ + use_[iuse_].first;
76 
79  if (use_[iuse_].second == 0) {
80  if (shift_ == -1) {
81  projfinephi__ -= (1 << NFINEPHIBITS);
82  }
83  } else {
84  //When we get here shift_ is either 1 or -1
85  if (shift_ == 1) {
86  projfinephi__ += (1 << NFINEPHIBITS);
87  }
88  }
89 
91 
94  proj__ = proj_;
95 
96  istub_++;
97  if (istub_ >= vmstubsmemory_->nStubsBin(slot)) {
98  iuse_++;
99  if (iuse_ < use_.size()) {
100  istub_ = 0;
101  } else {
102  idle_ = true;
103  }
104  }
105 }
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:33
std::vector< std::pair< unsigned int, unsigned int > > use_
constexpr unsigned int NFINEPHIBITS
Definition: Settings.h:34
unsigned int nStubsBin(unsigned int bin) const

◆ TCID()

int MatchEngineUnit::TCID ( ) const

Definition at line 174 of file MatchEngineUnit.cc.

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

174  {
175  if (!empty()) {
176  return peek().first->TCID();
177  }
178 
179  if (good___) {
180  return proj___->TCID();
181  }
182 
183  if (good__) {
184  return proj__->TCID();
185  }
186 
187  if (idle_) {
188  return (1 << (settings_.nbitstrackletindex() + settings_.nbitstcindex())) - 1;
189  }
190 
191  return proj_->TCID();
192 }
unsigned int nbitstrackletindex() const
Definition: Settings.h:281
int TCID() const
Definition: Tracklet.h:214
std::pair< Tracklet *, const Stub * > peek() const
const Settings & settings_
unsigned int nbitstcindex() const
Definition: Settings.h:286

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

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

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

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

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

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

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

◆ vmstubsmemory_

VMStubsMEMemory* trklet::MatchEngineUnit::vmstubsmemory_
private

Definition at line 80 of file MatchEngineUnit.h.

Referenced by init(), and step().