CMS 3D CMS Logo

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