CMS 3D CMS Logo

MatchEngineUnit.cc
Go to the documentation of this file.
2 
3 using namespace std;
4 using namespace trklet;
5 
6 MatchEngineUnit::MatchEngineUnit(bool barrel, vector<bool> table, vector<bool> tablePS, vector<bool> table2S)
7  : candmatches_(5) {
8  idle_ = true;
9  barrel_ = barrel;
10  table_ = table;
11  tablePS_ = tablePS;
12  table2S_ = table2S;
13  slot_ = 1; //This makes it idle until initialized
14 }
15 
17  unsigned int slot,
18  int projrinv,
19  int projfinerz,
20  int projfinephi,
21  bool usesecond,
22  bool isPSseed,
23  Tracklet* proj) {
24  vmstubsmemory_ = vmstubsmemory;
25  idle_ = false;
26  slot_ = slot;
27  istub_ = 0;
28  projrinv_ = projrinv;
29  projfinerz_ = projfinerz;
30  projfinephi_ = projfinephi;
31  usesecond_ = usesecond;
32  isPSseed_ = isPSseed;
33  proj_ = proj;
34 }
35 
37  if (idle() || candmatches_.almostfull())
38  return;
39 
41 
42  bool isPSmodule = vmstub.isPSmodule();
43  int stubfinerz = vmstub.finerz().value();
44  int stubfinephi = vmstub.finephi().value();
45 
46  int deltaphi = stubfinephi - projfinephi_;
47 
48  bool dphicut = (abs(deltaphi) < 3) || (abs(deltaphi) > 5); //TODO - need better implementations
49 
50  int nbits = isPSmodule ? 3 : 4;
51 
52  unsigned int index = (projrinv_ << nbits) + vmstub.bend().value();
53 
54  //Check if stub z position consistent
55  int idrz = stubfinerz - projfinerz_;
56  bool pass;
57 
58  if (barrel_) {
59  if (isPSseed_) {
60  pass = idrz >= -1 && idrz <= 1;
61  } else {
62  pass = idrz >= -5 && idrz <= 5;
63  }
64  } else {
65  if (isPSmodule) {
66  pass = idrz >= -1 && idrz <= 1;
67  } else {
68  pass = idrz >= -3 && idrz <= 3;
69  }
70  }
71 
72  //Check if stub bend and proj rinv consistent
73  if ((pass && dphicut) && (barrel_ ? table_[index] : (isPSmodule ? tablePS_[index] : table2S_[index]))) {
74  std::pair<Tracklet*, const Stub*> tmp(proj_, vmstub.stub());
75  candmatches_.store(tmp);
76  }
77 
78  istub_++;
80  if (usesecond_) {
81  usesecond_ = false;
82  istub_ = 0;
83  slot_++;
84  projfinerz_ -= (1 << NFINERZBITS);
85  } else {
86  idle_ = true;
87  }
88  }
89 }
90 
92  candmatches_.reset();
93  idle_ = true;
94  istub_ = 0;
95 }
trklet::VMStubsMEMemory
Definition: VMStubsMEMemory.h:16
Reference_intrackfit_cff.barrel
list barrel
Definition: Reference_intrackfit_cff.py:37
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:55
trklet::MatchEngineUnit::tablePS_
std::vector< bool > tablePS_
Definition: MatchEngineUnit.h:68
trklet::VMStubME::bend
const FPGAWord & bend() const
Definition: VMStubME.h:26
trklet::MatchEngineUnit::init
void init(VMStubsMEMemory *vmstubsmemory, unsigned int slot, int projrinv, int projfinerz, int projfinephi, bool usesecond, bool isPSseed, Tracklet *proj)
Definition: MatchEngineUnit.cc:16
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
trklet::Tracklet
Definition: Tracklet.h:28
trklet::MatchEngineUnit::istub_
unsigned int istub_
Definition: MatchEngineUnit.h:52
trklet::MatchEngineUnit::table_
std::vector< bool > table_
Definition: MatchEngineUnit.h:65
trklet::VMStubME::stub
const Stub * stub() const
Definition: VMStubME.h:28
trklet::MatchEngineUnit::candmatches_
CircularBuffer< std::pair< Tracklet *, const Stub * > > candmatches_
Definition: MatchEngineUnit.h:72
trklet::MatchEngineUnit::table2S_
std::vector< bool > table2S_
Definition: MatchEngineUnit.h:69
trklet::MatchEngineUnit::barrel_
bool barrel_
Definition: MatchEngineUnit.h:54
trklet::MatchEngineUnit::step
void step()
Definition: MatchEngineUnit.cc:36
amptDefault_cfi.proj
proj
Definition: amptDefault_cfi.py:13
trklet::MatchEngineUnit::proj_
Tracklet * proj_
Definition: MatchEngineUnit.h:60
trklet::MatchEngineUnit::idle_
bool idle_
Definition: MatchEngineUnit.h:62
trklet::MatchEngineUnit::vmstubsmemory_
VMStubsMEMemory * vmstubsmemory_
Definition: MatchEngineUnit.h:48
MatchEngineUnit.h
trklet
Definition: AllProjectionsMemory.h:9
trklet::FPGAWord::value
int value() const
Definition: FPGAWord.h:24
trklet::MatchEngineUnit::reset
void reset()
Definition: MatchEngineUnit.cc:91
std
Definition: JetResolutionObject.h:76
trklet::MatchEngineUnit::isPSseed_
bool isPSseed_
Definition: MatchEngineUnit.h:59
trklet::NFINERZBITS
constexpr unsigned int NFINERZBITS
Definition: Settings.h:27
trklet::MatchEngineUnit::usesecond_
bool usesecond_
Definition: MatchEngineUnit.h:58
trklet::MatchEngineUnit::projfinephi_
int projfinephi_
Definition: MatchEngineUnit.h:57
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
trklet::MatchEngineUnit::projfinerz_
int projfinerz_
Definition: MatchEngineUnit.h:56
trklet::MatchEngineUnit::idle
bool idle() const
Definition: MatchEngineUnit.h:41
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
TableParser.table
table
Definition: TableParser.py:111
trklet::VMStubME
Definition: VMStubME.h:15
trklet::VMStubsMEMemory::nStubsBin
unsigned int nStubsBin(unsigned int bin) const
Definition: VMStubsMEMemory.h:30
trklet::MatchEngineUnit::slot_
unsigned int slot_
Definition: MatchEngineUnit.h:51