CMS 3D CMS Logo

VMRouterCM.cc
Go to the documentation of this file.
10 
13 
14 using namespace std;
15 using namespace trklet;
16 
17 VMRouterCM::VMRouterCM(string name, Settings const& settings, Globals* global)
18  : ProcessBase(name, settings, global), meTable_(settings), diskTable_(settings) {
20 
21  unsigned int region = name[9] - 'A';
23 
24  vmstubsMEPHI_.resize(1, nullptr);
25 
26  overlapbits_ = 7;
28 
29  meTable_.initVMRTable(layerdisk_, TrackletLUT::VMRTableType::me, region); //used for ME and outer TE barrel
30 
32  diskTable_.initVMRTable(layerdisk_, TrackletLUT::VMRTableType::disk, region); //outer disk used by D1, D2, and D4
33  }
34 
37 
38  nvmmebins_ = settings_.NLONGVMBINS() * ((layerdisk_ >= N_LAYER) ? 2 : 1); //number of long z/r bins in VM
39 }
40 
42  if (settings_.writetrace()) {
43  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding output to " << memory->getName() << " to output "
44  << output;
45  }
46 
47  if (output == "allinnerstubout") {
48  AllInnerStubsMemory* tmp = dynamic_cast<AllInnerStubsMemory*>(memory);
49  assert(tmp != nullptr);
50  char memtype = memory->getName().back();
51  allinnerstubs_.emplace_back(memtype, tmp);
52  return;
53  }
54 
55  if (output.substr(0, 10) == "allstubout") {
56  AllStubsMemory* tmp = dynamic_cast<AllStubsMemory*>(memory);
57  allstubs_.push_back(tmp);
58  return;
59  }
60 
61  if (output.substr(0, 9) == "vmstubout") {
62  unsigned int pos = 12;
63  int vmbin = memory->getName().substr(pos, 1)[0] - '0';
64  pos++;
65  if (pos < memory->getName().size()) {
66  if (memory->getName().substr(pos, 1)[0] != 'n') {
67  vmbin = vmbin * 10 + memory->getName().substr(pos, 1)[0] - '0';
68  pos++;
69  }
70  }
71  if (memory->getName().substr(3, 2) == "TE") {
72  VMStubsTEMemory* tmp = dynamic_cast<VMStubsTEMemory*>(memory);
73  unsigned int iseed = output[output.size() - 1] - '0';
75 
76  int seedindex = -1;
77  for (unsigned int k = 0; k < vmstubsTEPHI_.size(); k++) {
78  if (vmstubsTEPHI_[k].seednumber == iseed) {
79  seedindex = k;
80  }
81  }
82  if (seedindex == -1) {
83  seedindex = vmstubsTEPHI_.size();
84  vector<VMStubsTEMemory*> vectmp;
85  VMStubsTEPHICM atmp(iseed, vectmp);
86  vmstubsTEPHI_.push_back(atmp);
87  }
88  tmp->resize(settings_.NLONGVMBINS() * settings_.nvmte(1, iseed));
89  vmstubsTEPHI_[seedindex].vmstubmem.push_back(tmp);
90 
91  } else if (memory->getName().substr(3, 2) == "ME") {
92  VMStubsMEMemory* tmp = dynamic_cast<VMStubsMEMemory*>(memory);
93  assert(tmp != nullptr);
95  assert(vmstubsMEPHI_[0] == nullptr);
96  vmstubsMEPHI_[0] = tmp;
97  } else {
98  throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " memory: " << memory->getName()
99  << " => should never get here!";
100  }
101 
102  return;
103  }
104 
105  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find output : " << output;
106 }
107 
109  if (settings_.writetrace()) {
110  edm::LogVerbatim("Tracklet") << "In " << name_ << " adding input from " << memory->getName() << " to input "
111  << input;
112  }
113  if (input == "stubin") {
114  InputLinkMemory* tmp1 = dynamic_cast<InputLinkMemory*>(memory);
115  assert(tmp1 != nullptr);
116  if (tmp1 != nullptr) {
117  stubinputs_.push_back(tmp1);
118  }
119  return;
120  }
121  throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " Could not find input : " << input;
122 }
123 
125  unsigned int allStubCounter = 0;
126 
127  //Loop over the input stubs
128  for (auto& stubinput : stubinputs_) {
129  for (unsigned int i = 0; i < stubinput->nStubs(); i++) {
130  if (allStubCounter > settings_.maxStep("VMR"))
131  continue;
132  if (allStubCounter >= (1 << N_BITSMEMADDRESS))
133  continue;
134 
135  Stub* stub = stubinput->getStub(i);
136 
137  //Note - below information is not part of the stub, but rather from which input memory
138  //we are reading
139  bool negdisk = (stub->disk().value() < 0);
140 
141  //use &127 to make sure we fit into the number of bits -
142  //though we should have protected against overflows above
143  FPGAWord allStubIndex(allStubCounter & ((1 << N_BITSMEMADDRESS) - 1), N_BITSMEMADDRESS, true, __LINE__, __FILE__);
144 
145  //TODO - should not be needed - but need to migrate some other pieces of code before removing
146  stub->setAllStubIndex(allStubCounter);
147  //TODO - should not be needed - but need to migrate some other pieces of code before removing
148  stub->l1tstub()->setAllStubIndex(allStubCounter);
149 
150  allStubCounter++;
151 
152  for (auto& allstub : allstubs_) {
153  allstub->addStub(stub);
154  if (settings_.debugTracklet()) {
155  edm::LogVerbatim("Tracklet") << getName() << " adding stub to " << allstub->getName();
156  }
157  }
158 
159  FPGAWord iphi = stub->phicorr();
160  unsigned int iphipos = iphi.bits(iphi.nbits() - (settings_.nbitsallstubs(layerdisk_) + N_PHIBITS), N_PHIBITS);
161 
162  unsigned int phicutmax = 4;
163  unsigned int phicutmin = 4;
164 
165  if (layerdisk_ != 0) {
166  phicutmax = 6;
167  phicutmin = 2;
168  }
169 
170  //Fill inner allstubs memories - in HLS this is the same write to multiple memories
171  for (auto& allstub : allinnerstubs_) {
172  char memtype = allstub.first;
173  if (memtype == 'R' && iphipos < phicutmax)
174  continue;
175  if (memtype == 'L' && iphipos >= phicutmin)
176  continue;
177  if (memtype == 'A' && iphipos < 4)
178  continue;
179  if (memtype == 'B' && iphipos >= 4)
180  continue;
181  if (memtype == 'E' && iphipos >= 4)
182  continue;
183  if (memtype == 'F' && iphipos < 4)
184  continue;
185  if (memtype == 'C' && iphipos >= 4)
186  continue;
187  if (memtype == 'D' && iphipos < 4)
188  continue;
189 
190  int absz = std::abs(stub->z().value());
192  continue;
195  continue;
197  stub->r().value() > VMROUTERCUTRD1D3 / settings_.kr())
198  continue;
199  if ((layerdisk_ == LayerDisk::D1 || layerdisk_ == LayerDisk::D3) && stub->r().value() < 2 * int(N_DSS_MOD))
200  continue;
201  if (layerdisk_ == LayerDisk::L1) {
202  if (memtype == 'M' || memtype == 'R' || memtype == 'L') {
203  if (absz < VMROUTERCUTZL1 / settings_.kz(layerdisk_))
204  continue;
205  } else {
207  continue;
208  }
209  }
210 
211  if (settings_.debugTracklet()) {
212  edm::LogVerbatim("Tracklet") << getName() << " adding stub to " << allstub.second->getName();
213  }
214 
215  allstub.second->addStub(stub);
216  }
217 
218  //Fill all the ME VM memories
219  unsigned int ivm =
222 
223  //Calculate the z and r position for the vmstub
224 
225  //Take the top nbitszfinebintable_ bits of the z coordinate
226  int indexz = (stub->z().value() >> (stub->z().nbits() - nbitszfinebintable_)) & ((1 << nbitszfinebintable_) - 1);
227  int indexr = -1;
228  if (layerdisk_ > (N_LAYER - 1)) {
229  if (negdisk) {
230  indexz = ((1 << nbitszfinebintable_) - 1) - indexz;
231  }
232  indexr = stub->r().value();
233  if (stub->isPSmodule()) {
234  indexr = stub->r().value() >> (stub->r().nbits() - nbitsrfinebintable_);
235  }
236  } else {
237  //Take the top nbitsfinebintable_ bits of the z coordinate. The & is to handle the negative z values.
238  indexr = (stub->r().value() >> (stub->r().nbits() - nbitsrfinebintable_)) & ((1 << nbitsrfinebintable_) - 1);
239  }
240 
241  assert(indexz >= 0);
242  assert(indexr >= 0);
243  assert(indexz < (1 << nbitszfinebintable_));
244  assert(indexr < (1 << nbitsrfinebintable_));
245 
246  int melut = meTable_.lookup((indexz << nbitsrfinebintable_) + indexr);
247 
248  assert(melut >= 0);
249 
250  int vmbin = melut >> NFINERZBITS;
251  if (negdisk)
252  vmbin += (1 << NFINERZBITS);
253  int rzfine = melut & ((1 << NFINERZBITS) - 1);
254 
255  // pad disk PS bend word with a '0' in MSB so that all disk bends have 4 bits (for HLS compatibility)
256  int nbendbits = stub->bend().nbits();
257  if (layerdisk_ >= N_LAYER)
258  nbendbits = settings_.nbendbitsmedisk();
259 
260  VMStubME vmstub(
261  stub,
263  FPGAWord(rzfine, NFINERZBITS, true, __LINE__, __FILE__),
264  FPGAWord(stub->bend().value(), nbendbits, true, __LINE__, __FILE__),
265  allStubIndex);
266 
267  assert(vmstubsMEPHI_[0] != nullptr);
268 
269  vmstubsMEPHI_[0]->addStub(vmstub, ivm * nvmmebins_ + vmbin);
270 
271  //Fill the TE VM memories
272  if (layerdisk_ >= N_LAYER && (!stub->isPSmodule()))
273  continue;
274 
275  for (auto& ivmstubTEPHI : vmstubsTEPHI_) {
276  unsigned int iseed = ivmstubTEPHI.seednumber;
277  unsigned int lutwidth = settings_.lutwidthtab(1, iseed);
278 
279  int lutval = -999;
280 
281  if (layerdisk_ < N_LAYER) {
282  lutval = melut;
283  } else {
284  lutval = diskTable_.lookup((indexz << nbitsrfinebintable_) + indexr);
285  if (lutval == 0) {
286  continue;
287  }
288  }
289 
290  assert(lutval >= 0);
291 
292  FPGAWord binlookup(lutval, lutwidth, true, __LINE__, __FILE__);
293 
294  if (binlookup.value() < 0)
295  continue;
296 
297  unsigned int ivmte =
300 
301  int bin = binlookup.value() / 8;
302  unsigned int tmp = binlookup.value() & 7; //three bits in outer layers - this could be coded cleaner...
303  binlookup.set(tmp, 3, true, __LINE__, __FILE__);
304 
306 
307  VMStubTE tmpstub(stub, finephi, stub->bend(), binlookup, allStubIndex);
308 
309  unsigned int nmem = ivmstubTEPHI.vmstubmem.size();
310  assert(nmem > 0);
311 
312  for (unsigned int l = 0; l < nmem; l++) {
313  if (settings_.debugTracklet()) {
314  edm::LogVerbatim("Tracklet") << getName() << " try adding stub to " << ivmstubTEPHI.vmstubmem[l]->getName()
315  << " bin=" << bin << " ivmte " << ivmte << " finephi " << finephi.value()
316  << " regions bits " << settings_.nphireg(1, iseed) << " finephibits "
317  << settings_.nfinephi(1, iseed);
318  }
319  ivmstubTEPHI.vmstubmem[l]->addVMStub(tmpstub, ivmte * settings_.NLONGVMBINS() + bin);
320  }
321  }
322  }
323  }
324 }
PixelRegions::L3
Definition: PixelRegionContainers.h:32
Settings.h
PixelRegions::L1
Definition: PixelRegionContainers.h:32
trklet::AllStubsMemory
Definition: AllStubsMemory.h:16
funct::D1
Divides< A, C > D1
Definition: Factorize.h:136
mps_fire.i
i
Definition: mps_fire.py:428
PixelRegions::L2
Definition: PixelRegionContainers.h:32
trklet::Settings::writetrace
bool writetrace() const
Definition: Settings.h:183
trklet::VMRouterCM::vmstubsMEPHI_
std::vector< VMStubsMEMemory * > vmstubsMEPHI_
Definition: VMRouterCM.h:68
trklet::VMStubsMEMemory
Definition: VMStubsMEMemory.h:16
input
static const std::string input
Definition: EdmProvDump.cc:48
MessageLogger.h
trklet::TrackletLUT::lookup
int lookup(unsigned int index) const
Definition: TrackletLUT.cc:900
trklet::VMStubTE
Definition: VMStubTE.h:15
AllStubsMemory.h
funct::D2
Divides< B, C > D2
Definition: Factorize.h:137
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
trklet::Stub::bend
const FPGAWord & bend() const
Definition: Stub.h:58
memory
Definition: HGCRecHitSoA.h:20
pos
Definition: PixelAliasList.h:18
trklet::Settings::vmrlutrbits
unsigned int vmrlutrbits(unsigned int layerdisk) const
Definition: Settings.h:179
trklet::Settings
Definition: Settings.h:52
trklet::Settings::nbitsallstubs
unsigned int nbitsallstubs(unsigned int layerdisk) const
Definition: Settings.h:106
trklet::VMStubsTEMemory
Definition: VMStubsTEMemory.h:18
cms::cuda::assert
assert(be >=bs)
trklet::FPGAWord::set
void set(int value, int nbits, bool positive=true, int line=-1, const char *file=nullptr)
Definition: FPGAWord.cc:14
trklet::AllInnerStubsMemory
Definition: AllInnerStubsMemory.h:16
trklet::VMROUTERCUTZL1L3L5
constexpr double VMROUTERCUTZL1L3L5
Definition: Settings.h:45
trklet::TrackletLUT::initVMRTable
void initVMRTable(unsigned int layerdisk, VMRTableType type, int region=-1)
Definition: TrackletLUT.cc:490
trklet::Settings::lutwidthtab
double lutwidthtab(unsigned int inner, unsigned int iSeed) const
Definition: Settings.h:140
trklet::VMRouterCM::meTable_
TrackletLUT meTable_
Definition: VMRouterCM.h:57
trklet::ProcessBase::settings_
Settings const & settings_
Definition: ProcessBase.h:40
trklet::VMROUTERCUTRD1D3
constexpr double VMROUTERCUTRD1D3
Definition: Settings.h:47
trklet::FPGAWord::nbits
int nbits() const
Definition: FPGAWord.h:25
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
trklet::Globals
Definition: Globals.h:30
InputLinkMemory.h
trklet::Stub::r
const FPGAWord & r() const
Definition: Stub.h:60
trklet::VMRouterCM::addInput
void addInput(MemoryBase *memory, std::string input) override
Definition: VMRouterCM.cc:108
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
trklet::D3
Definition: Settings.h:50
trklet::VMRouterCM::overlapbits_
unsigned int overlapbits_
Definition: VMRouterCM.h:49
trklet::InputLinkMemory
Definition: InputLinkMemory.h:16
trklet::VMROUTERCUTZL1
constexpr double VMROUTERCUTZL1
Definition: Settings.h:46
trklet::Stub::disk
const FPGAWord & disk() const
Definition: Stub.h:68
trklet::Stub::iphivmFineBins
FPGAWord iphivmFineBins(int VMbits, int finebits) const
Definition: Stub.cc:107
trklet::Stub::z
const FPGAWord & z() const
Definition: Stub.h:61
trklet::Stub
Definition: Stub.h:18
trklet::Settings::nbitsvmme
unsigned int nbitsvmme(unsigned int layerdisk) const
Definition: Settings.h:103
trklet::VMRouterCM::diskTable_
TrackletLUT diskTable_
Definition: VMRouterCM.h:58
trklet::N_LAYER
constexpr int N_LAYER
Definition: Settings.h:21
trklet::VMRouterCM::nbitszfinebintable_
int nbitszfinebintable_
Definition: VMRouterCM.h:52
trklet::VMRouterCM::nvmmebins_
unsigned int nvmmebins_
Definition: VMRouterCM.h:55
dqmdumpme.k
k
Definition: dqmdumpme.py:60
trklet::N_PHIBITS
constexpr unsigned int N_PHIBITS
Definition: Settings.h:36
trklet::FPGAWord
Definition: FPGAWord.h:9
trklet::VMRouterCM::allstubs_
std::vector< AllStubsMemory * > allstubs_
Definition: VMRouterCM.h:64
trklet::ProcessBase::initLayerDisk
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: ProcessBase.cc:33
trklet::Settings::kr
double kr() const
Definition: Settings.h:304
VMStubsMEMemory.h
trklet::MemoryBase
Definition: MemoryBase.h:13
trklet::Settings::nfinephi
int nfinephi(unsigned int inner, unsigned int iSeed) const
Definition: Settings.h:133
iseed
int iseed
Definition: AMPTWrapper.h:134
trklet::VMRouterCM::vmstubsTEPHI_
std::vector< VMStubsTEPHICM > vmstubsTEPHI_
Definition: VMRouterCM.h:71
trklet::Settings::NLONGVMBINS
unsigned int NLONGVMBINS() const
Definition: Settings.h:329
trklet::N_DSS_MOD
constexpr unsigned int N_DSS_MOD
Definition: Settings.h:27
trklet::VMRouterCM::execute
void execute()
Definition: VMRouterCM.cc:124
trklet::VMRouterCM::nbitsrfinebintable_
int nbitsrfinebintable_
Definition: VMRouterCM.h:53
trklet::Settings::nvmme
unsigned int nvmme(unsigned int layerdisk) const
Definition: Settings.h:104
trklet::VMStubsTEPHICM
Definition: VMRouterCM.h:24
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88286
createfilelist.int
int
Definition: createfilelist.py:10
Globals.h
trklet::Settings::nphireg
double nphireg(unsigned int inner, unsigned int iSeed) const
Definition: Settings.h:134
trklet
Definition: AllInnerStubsMemory.h:10
trklet::Stub::setAllStubIndex
void setAllStubIndex(int nstub)
Definition: Stub.cc:123
trklet::FPGAWord::value
int value() const
Definition: FPGAWord.h:24
VMStubsTEMemory.h
trklet::VMRouterCM::allinnerstubs_
std::vector< std::pair< char, AllInnerStubsMemory * > > allinnerstubs_
Definition: VMRouterCM.h:65
VMRouterCM.h
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
trklet::VMRouterCM::nextrabits_
unsigned int nextrabits_
Definition: VMRouterCM.h:50
trklet::N_BITSMEMADDRESS
constexpr unsigned int N_BITSMEMADDRESS
Definition: Settings.h:39
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
trklet::Settings::nbitsvmte
unsigned int nbitsvmte(unsigned int inner, unsigned int iSeed) const
Definition: Settings.h:95
trklet::N_SEED_PROMPT
constexpr unsigned int N_SEED_PROMPT
Definition: Settings.h:25
trklet::VMRouterCM::layerdisk_
unsigned int layerdisk_
Definition: VMRouterCM.h:45
std
Definition: JetResolutionObject.h:76
VMStubTE.h
trklet::VMROUTERCUTZL2
constexpr double VMROUTERCUTZL2
Definition: Settings.h:44
trklet::Stub::phicorr
const FPGAWord & phicorr() const
Definition: Stub.h:63
trklet::ProcessBase
Definition: ProcessBase.h:12
trklet::NFINERZBITS
constexpr unsigned int NFINERZBITS
Definition: Settings.h:33
trklet::Stub::l1tstub
L1TStub * l1tstub()
Definition: Stub.h:77
trklet::Settings::vmrlutzbits
unsigned int vmrlutzbits(unsigned int layerdisk) const
Definition: Settings.h:178
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Exception
Definition: hltDiff.cc:245
trklet::ProcessBase::getName
std::string const & getName() const
Definition: ProcessBase.h:22
trklet::VMRouterCM::addOutput
void addOutput(MemoryBase *memory, std::string output) override
Definition: VMRouterCM.cc:41
trklet::Settings::nvmte
unsigned int nvmte(unsigned int inner, unsigned int iSeed) const
Definition: Settings.h:101
trklet::Settings::kz
double kz() const
Definition: Settings.h:302
trklet::ProcessBase::name_
std::string name_
Definition: ProcessBase.h:38
trklet::Settings::nallstubs
unsigned int nallstubs(unsigned int layerdisk) const
Definition: Settings.h:107
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
trklet::Settings::debugTracklet
bool debugTracklet() const
Definition: Settings.h:182
Exception.h
trklet::Stub::isPSmodule
bool isPSmodule() const
Definition: Stub.h:71
trklet::Settings::maxStep
unsigned int maxStep(std::string module) const
Definition: Settings.h:116
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
trklet::L5
Definition: Settings.h:50
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
trklet::L1TStub::setAllStubIndex
void setAllStubIndex(unsigned int index)
Definition: L1TStub.h:81
trklet::D4
Definition: Settings.h:50
trklet::VMStubME
Definition: VMStubME.h:15
trklet::VMRouterCM::stubinputs_
std::vector< InputLinkMemory * > stubinputs_
Definition: VMRouterCM.h:61
AllInnerStubsMemory.h
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
trklet::Settings::nbendbitsmedisk
unsigned int nbendbitsmedisk() const
Definition: Settings.h:92