CMS 3D CMS Logo

VMStubsTEMemory.cc
Go to the documentation of this file.
4 #include <iomanip>
5 #include <filesystem>
6 
7 using namespace std;
8 using namespace trklet;
9 
10 VMStubsTEMemory::VMStubsTEMemory(string name, Settings const& settings)
11  : MemoryBase(name, settings), bendtable_(settings) {
12  //set the layer or disk that the memory is in
14 
16 
17  //Pointer to other VMStub memory for creating stub pairs
18  other_ = nullptr;
19 
20  //What type of seeding is this memory used for
22 
23  string subname = name.substr(12, 2);
24  phibin_ = subname[0] - '0';
25  if (subname[1] != 'n') {
26  phibin_ = 10 * phibin_ + (subname[1] - '0');
27  }
28 
29  isinner_ = (layer_ % 2 == 1 or disk_ % 2 == 1);
30  // special cases with overlap seeding
31  if (overlap_ and layer_ == 2)
32  isinner_ = true;
33  if (overlap_ and layer_ == 3)
34  isinner_ = false;
35  if (overlap_ and disk_ == 1)
36  isinner_ = false;
37 
38  if (extra_ and layer_ == 2)
39  isinner_ = true;
40  if (extra_ and layer_ == 3)
41  isinner_ = false;
42  // more special cases for triplets
43  if (!overlap_ and extended_ and layer_ == 2)
44  isinner_ = true;
45  if (!overlap_ and extended_ and layer_ == 3)
46  isinner_ = false;
47  if (overlap_ and extended_ and layer_ == 2)
48  isinner_ = false;
49  if (overlap_ and extended_ and disk_ == 1)
50  isinner_ = false;
51 
53 }
54 
56  //If the pt of the stub is consistent with the allowed pt of tracklets
57  //in that can be formed in this VM and the other VM used in the TE.
58 
59  if (settings_.combined()) {
60  if (disk_ > 0) {
61  assert(vmstub.stub()->isPSmodule());
62  }
63  bool negdisk = vmstub.stub()->disk().value() < 0.0;
64  if (negdisk)
65  bin += 4;
66  assert(bin < (int)stubsbinnedvm_.size());
68  stubsbinnedvm_[bin].push_back(vmstub);
69  stubsvm_.push_back(vmstub);
70  }
71  return true;
72  }
73 
74  bool pass = false;
75  if (settings_.extended() && bendtable_.size() == 0) {
76  pass = true;
77  } else {
78  pass = bendtable_.lookup(vmstub.bend().value());
79  }
80 
81  if (!pass) {
83  edm::LogVerbatim("Tracklet") << getName() << " Stub failed bend cut. bend = "
84  << settings_.benddecode(vmstub.bend().value(), layerdisk_, vmstub.isPSmodule());
85  return false;
86  }
87 
88  bool negdisk = vmstub.stub()->disk().value() < 0.0;
89 
90  if (overlap_) {
91  if (disk_ == 1) {
92  assert(bin < 4);
93  if (negdisk)
94  bin += 4;
96  return false;
97  stubsbinnedvm_[bin].push_back(vmstub);
99  edm::LogVerbatim("Tracklet") << getName() << " Stub in disk = " << disk_ << " in bin = " << bin;
100  } else if (layer_ == 2) {
102  return false;
103  stubsbinnedvm_[bin].push_back(vmstub);
104  }
105  } else {
106  if (vmstub.stub()->layerdisk() < N_LAYER) {
107  if (!isinner_) {
109  return false;
110  stubsbinnedvm_[bin].push_back(vmstub);
111  }
112 
113  } else {
114  if (disk_ % 2 == 0) {
115  assert(bin < 4);
116  if (negdisk)
117  bin += 4;
119  return false;
120  stubsbinnedvm_[bin].push_back(vmstub);
121  }
122  }
123  }
124  if (settings_.debugTracklet())
125  edm::LogVerbatim("Tracklet") << "Adding stubs to " << getName();
127  return false;
128  stubsvm_.push_back(vmstub);
129  return true;
130 }
131 
132 // TODO - should migrate away from using this method for any binned memory
134  FPGAWord binlookup = vmstub.vmbits();
135 
136  assert(binlookup.value() >= 0);
137  int bin = (binlookup.value() / 8);
138 
139  //If the pt of the stub is consistent with the allowed pt of tracklets
140  //in that can be formed in this VM and the other VM used in the TE.
141 
142  bool pass = false;
143  if (settings_.extended() && bendtable_.size() == 0) {
144  pass = true;
145  } else {
146  pass = bendtable_.lookup(vmstub.bend().value());
147  }
148 
149  if (!pass) {
150  if (settings_.debugTracklet())
151  edm::LogVerbatim("Tracklet") << getName() << " Stub failed bend cut. bend = "
152  << settings_.benddecode(vmstub.bend().value(), layerdisk_, vmstub.isPSmodule());
153  return false;
154  }
155 
156  bool negdisk = vmstub.stub()->disk().value() < 0.0;
157 
158  if (!extended_) {
159  if (overlap_) {
160  if (disk_ == 1) {
161  assert(bin < 4);
162  if (negdisk)
163  bin += 4;
164  stubsbinnedvm_[bin].push_back(vmstub);
165  if (settings_.debugTracklet()) {
166  edm::LogVerbatim("Tracklet") << getName() << " Stub with lookup = " << binlookup.value()
167  << " in disk = " << disk_ << " in bin = " << bin;
168  }
169  }
170  } else {
171  if (vmstub.stub()->layerdisk() < N_LAYER) {
172  if (!isinner_) {
173  stubsbinnedvm_[bin].push_back(vmstub);
174  }
175 
176  } else {
177  if (disk_ % 2 == 0) {
178  assert(bin < 4);
179  if (negdisk)
180  bin += 4;
181  stubsbinnedvm_[bin].push_back(vmstub);
182  }
183  }
184  }
185  } else { //extended
186  if (!isinner_) {
187  if (layer_ > 0) {
188  stubsbinnedvm_[bin].push_back(vmstub);
189  } else {
190  if (overlap_) {
191  assert(disk_ == 1); // D1 from L2L3D1
192 
193  //bin 0 is PS, 1 through 3 is 2S
194  if (vmstub.stub()->isPSmodule()) {
195  bin = 0;
196  } else {
197  bin = vmstub.stub()->r().value(); // 0 to 9
198  bin = bin >> 2; // 0 to 2
199  bin += 1;
200  }
201  }
202  assert(bin < 4);
203  if (negdisk)
204  bin += 4;
205  stubsbinnedvm_[bin].push_back(vmstub);
206  }
207  }
208  }
209 
210  if (settings_.debugTracklet())
211  edm::LogVerbatim("Tracklet") << "Adding stubs to " << getName();
212  stubsvm_.push_back(vmstub);
213  return true;
214 }
215 
217  stubsvm_.clear();
218  for (auto& stubsbinnedvm : stubsbinnedvm_) {
219  stubsbinnedvm.clear();
220  }
221 }
222 
223 void VMStubsTEMemory::writeStubs(bool first, unsigned int iSector) {
224  iSector_ = iSector;
225  const string dirVM = settings_.memPath() + "VMStubsTE/";
226  openFile(first, dirVM, "VMStubs_");
227 
228  if (isinner_) { // inner VM for TE purpose
229  for (unsigned int j = 0; j < stubsvm_.size(); j++) {
230  out_ << "0x";
231  out_ << std::setfill('0') << std::setw(2);
232  out_ << hex << j << dec;
233  string stub = stubsvm_[j].str();
234  out_ << " " << stub << " " << trklet::hexFormat(stub) << endl;
235  }
236  } else { // outer VM for TE purpose
237  for (unsigned int i = 0; i < stubsbinnedvm_.size(); i++) {
238  for (unsigned int j = 0; j < stubsbinnedvm_[i].size(); j++) {
239  string stub = stubsbinnedvm_[i][j].str();
240  out_ << hex << i << " " << j << dec << " " << stub << " " << trklet::hexFormat(stub) << endl;
241  }
242  }
243  }
244 
245  out_.close();
246 }
247 
248 void VMStubsTEMemory::getPhiRange(double& phimin, double& phimax, unsigned int iSeed, unsigned int inner) {
249  int nvm = -1;
250  if (overlap_) {
251  if (layer_ > 0) {
252  nvm = settings_.nallstubs(layer_ - 1) * settings_.nvmte(inner, iSeed);
253  }
254  if (disk_ > 0) {
255  nvm = settings_.nallstubs(disk_ + N_DISK) * settings_.nvmte(inner, iSeed);
256  }
257  } else {
258  if (layer_ > 0) {
259  nvm = settings_.nallstubs(layer_ - 1) * settings_.nvmte(inner, iSeed);
260  if (extra_) {
261  nvm = settings_.nallstubs(layer_ - 1) * settings_.nvmte(inner, iSeed);
262  }
263  }
264  if (disk_ > 0) {
265  nvm = settings_.nallstubs(disk_ + N_DISK) * settings_.nvmte(inner, iSeed);
266  }
267  }
268  assert(nvm > 0);
269  assert(nvm <= 32);
270  double dphi = settings_.dphisectorHG() / nvm;
271  phimax = phibin() * dphi;
272  phimin = phimax - dphi;
273 
274  return;
275 }
276 
277 void VMStubsTEMemory::setbendtable(const TrackletLUT& bendtable) { bendtable_ = bendtable; }
trklet::MemoryBase::settings_
Settings const & settings_
Definition: MemoryBase.h:50
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
trklet::TrackletLUT::lookup
int lookup(unsigned int index) const
Definition: TrackletLUT.cc:900
trklet::VMStubTE
Definition: VMStubTE.h:15
phimin
float phimin
Definition: ReggeGribovPartonMCHadronizer.h:107
trklet::VMStubsTEMemory::layerdisk_
int layerdisk_
Definition: VMStubsTEMemory.h:57
TrackletLUT.h
trklet::Settings
Definition: Settings.h:52
trklet::TrackletLUT
Definition: TrackletLUT.h:12
cms::cuda::assert
assert(be >=bs)
trklet::MemoryBase::out_
std::ofstream out_
Definition: MemoryBase.h:46
trklet::N_DISK
constexpr int N_DISK
Definition: Settings.h:22
trklet::TrackletLUT::size
unsigned int size() const
Definition: TrackletLUT.h:77
trklet::MemoryBase::initLayerDisk
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: MemoryBase.cc:19
trklet::VMStubTE::isPSmodule
bool isPSmodule() const
Definition: VMStubTE.h:31
trklet::Stub::r
const FPGAWord & r() const
Definition: Stub.h:60
trklet::VMStubTE::bend
const FPGAWord & bend() const
Definition: VMStubTE.h:25
trklet::Settings::combined
bool combined() const
Definition: Settings.h:250
trklet::Settings::benddecode
double benddecode(int ibend, int layerdisk, bool isPSmodule) const
Definition: Settings.h:402
trklet::Stub::disk
const FPGAWord & disk() const
Definition: Stub.h:68
trklet::MemoryBase::getName
std::string const & getName() const
Definition: MemoryBase.h:19
trklet::MemoryBase::openFile
void openFile(bool first, std::string dirName, std::string filebase)
Definition: MemoryBase.cc:74
trklet::VMStubsTEMemory::extra_
bool extra_
Definition: VMStubsTEMemory.h:61
trklet::Settings::dphisectorHG
double dphisectorHG() const
Definition: Settings.h:281
trklet::VMStubsTEMemory::disk_
int disk_
Definition: VMStubsTEMemory.h:56
SurfaceOrientation::inner
Definition: Surface.h:19
trklet::VMStubsTEMemory::isinner_
bool isinner_
Definition: VMStubsTEMemory.h:63
trklet::VMStubsTEMemory::bendtable_
TrackletLUT bendtable_
Definition: VMStubsTEMemory.h:65
trklet::N_LAYER
constexpr int N_LAYER
Definition: Settings.h:21
trklet::VMStubsTEMemory::extended_
bool extended_
Definition: VMStubsTEMemory.h:62
trklet::N_VMSTUBSMAX
constexpr unsigned int N_VMSTUBSMAX
Definition: Settings.h:38
trklet::VMStubsTEMemory::layer_
int layer_
Definition: VMStubsTEMemory.h:55
trklet::Stub::layerdisk
unsigned int layerdisk() const
Definition: Stub.cc:185
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
trklet::FPGAWord
Definition: FPGAWord.h:9
trklet::VMStubsTEMemory::writeStubs
void writeStubs(bool first, unsigned int iSector)
Definition: VMStubsTEMemory.cc:223
trklet::MemoryBase
Definition: MemoryBase.h:13
trklet::Settings::NLONGVMBINS
unsigned int NLONGVMBINS() const
Definition: Settings.h:329
trklet::VMStubsTEMemory::addVMStub
bool addVMStub(VMStubTE vmstub, int bin)
Definition: VMStubsTEMemory.cc:55
trklet::Settings::memPath
std::string memPath() const
Definition: Settings.h:192
trklet::Settings::extended
bool extended() const
Definition: Settings.h:248
trklet::VMStubTE::stub
const Stub * stub() const
Definition: VMStubTE.h:29
trklet::VMStubsTEMemory::other_
VMStubsTEMemory * other_
Definition: VMStubsTEMemory.h:59
trklet::VMStubsTEMemory::phibin
int phibin() const
Definition: VMStubsTEMemory.h:44
trklet::Settings::maxStubsPerBin
unsigned int maxStubsPerBin() const
Definition: Settings.h:224
trklet::VMStubTE::vmbits
const FPGAWord & vmbits() const
Definition: VMStubTE.h:27
trklet
Definition: AllInnerStubsMemory.h:10
trklet::FPGAWord::value
int value() const
Definition: FPGAWord.h:24
trklet::VMStubsTEMemory::clean
void clean() override
Definition: VMStubsTEMemory.cc:216
VMStubsTEMemory.h
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
phimax
float phimax
Definition: ReggeGribovPartonMCHadronizer.h:106
std
Definition: JetResolutionObject.h:76
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
trklet::VMStubsTEMemory::getPhiRange
void getPhiRange(double &phimin, double &phimax, unsigned int iSeed, unsigned int inner)
Definition: VMStubsTEMemory.cc:248
trklet::Settings::nvmte
unsigned int nvmte(unsigned int inner, unsigned int iSeed) const
Definition: Settings.h:101
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
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
trklet::Stub::isPSmodule
bool isPSmodule() const
Definition: Stub.h:71
trklet::VMStubsTEMemory::stubsbinnedvm_
std::vector< std::vector< VMStubTE > > stubsbinnedvm_
Definition: VMStubsTEMemory.h:68
trklet::hexFormat
std::string hexFormat(const std::string &binary)
Definition: Util.h:19
trklet::VMStubsTEMemory::phibin_
int phibin_
Definition: VMStubsTEMemory.h:58
trklet::VMStubsTEMemory::setbendtable
void setbendtable(const TrackletLUT &bendtable)
Definition: VMStubsTEMemory.cc:277
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
edm::Log
Definition: MessageLogger.h:70
trklet::MemoryBase::initSpecialSeeding
void initSpecialSeeding(unsigned int pos, bool &overlap, bool &extra, bool &extended)
Definition: MemoryBase.cc:42
trklet::VMStubsTEMemory::stubsvm_
std::vector< VMStubTE > stubsvm_
Definition: VMStubsTEMemory.h:67
trklet::VMStubsTEMemory::overlap_
bool overlap_
Definition: VMStubsTEMemory.h:60
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
trklet::MemoryBase::iSector_
unsigned int iSector_
Definition: MemoryBase.h:44
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443