CMS 3D CMS Logo

DTCLinkMemory.cc
Go to the documentation of this file.
4 
6 
7 #include <iomanip>
8 #include <cmath>
9 #include <sstream>
10 #include <cctype>
11 
13 
14 using namespace trklet;
15 using namespace std;
16 
17 DTCLinkMemory::DTCLinkMemory(string name, Settings const& settings, double, double) : MemoryBase(name, settings) {}
18 
19 void DTCLinkMemory::addStub(const L1TStub& al1stub, const Stub& stub) {
20  //Make new objects owned by the dtclink memory and save in list of stubs
21  if (stubs_.size() < settings_.maxStep("IR")) {
22  Stub* stubptr = new Stub(stub);
23  stubptr->setl1tstub(new L1TStub(al1stub));
24 
25  stubs_.emplace_back(stubptr);
26  }
27 }
28 
29 void DTCLinkMemory::writeStubs(bool first, unsigned int iSector) {
30  iSector_ = iSector;
31 
32  const string dirIS = settings_.memPath() + "InputStubs/";
33  openFile(first, dirIS, "Link_");
34 
35  for (unsigned int j = 0; j < stubs_.size(); j++) {
36  string dtcname = stubs_[j]->l1tstub()->DTClink();
37  int layerdisk = stubs_[j]->l1tstub()->layerdisk();
38 
39  //If the string starts with 'neg' skip the first three character
40  int start = dtcname.substr(0, 3) == "neg" ? 3 : 0;
41 
42  //For the dtcbase name remove the leading 'neg' if in the name and the trailing '_A' or '_B'
43  string dtcbase = dtcname.substr(start, dtcname.size() - 2 - start);
44 
45  const vector<int>& layers = settings_.dtcLayers(dtcbase);
46 
47  int lcode = -1;
48  for (unsigned int index = 0; index < layers.size(); index++) {
49  if (layerdisk == layers[index]) {
50  lcode = index;
51  }
52  }
53  assert(lcode != -1);
54 
55  FPGAWord ldcode(lcode, 2, true);
56 
57  string stub = stubs_[j]->str() + "|" + ldcode.str() + "|1";
58  out_ << std::setfill('0') << std::setw(2);
59  out_ << hex << j << dec;
60  out_ << " " << stub << " " << trklet::hexFormat(stub) << endl;
61  }
62  out_.close();
63 }
64 
66  for (auto& stub : stubs_) {
67  delete stub->l1tstub();
68  delete stub;
69  }
70  stubs_.clear();
71 }
trklet::MemoryBase::settings_
Settings const & settings_
Definition: MemoryBase.h:50
L1TStub.h
start
Definition: start.py:1
MessageLogger.h
trklet::FPGAWord::str
std::string str() const
Definition: FPGAWord.cc:54
trklet::DTCLinkMemory::stubs_
std::vector< Stub * > stubs_
Definition: DTCLinkMemory.h:34
trklet::Settings
Definition: Settings.h:52
trklet::L1TStub
Definition: L1TStub.h:14
cms::cuda::assert
assert(be >=bs)
trklet::MemoryBase::out_
std::ofstream out_
Definition: MemoryBase.h:46
trklet::DTCLinkMemory::writeStubs
void writeStubs(bool first, unsigned int iSector)
Definition: DTCLinkMemory.cc:29
trklet::MemoryBase::openFile
void openFile(bool first, std::string dirName, std::string filebase)
Definition: MemoryBase.cc:74
trklet::Stub
Definition: Stub.h:18
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
trklet::FPGAWord
Definition: FPGAWord.h:9
trklet::DTCLinkMemory::addStub
void addStub(const L1TStub &al1stub, const Stub &stub)
Definition: DTCLinkMemory.cc:19
trklet::MemoryBase
Definition: MemoryBase.h:13
trklet::Settings::memPath
std::string memPath() const
Definition: Settings.h:192
Globals.h
trklet::DTCLinkMemory::clean
void clean() override
Definition: DTCLinkMemory.cc:65
trklet
Definition: AllInnerStubsMemory.h:10
trklet::Stub::setl1tstub
void setl1tstub(L1TStub *l1tstub)
Definition: Stub.h:79
std
Definition: JetResolutionObject.h:76
trklet::DTCLinkMemory::DTCLinkMemory
DTCLinkMemory(std::string name, Settings const &settings, double, double)
Definition: DTCLinkMemory.cc:17
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
trklet::Settings::maxStep
unsigned int maxStep(std::string module) const
Definition: Settings.h:116
trklet::hexFormat
std::string hexFormat(const std::string &binary)
Definition: Util.h:19
trklet::Settings::dtcLayers
const std::vector< int > & dtcLayers(const std::string &dtcName) const
Definition: Settings.h:420
DTCLinkMemory.h
command_line.start
start
Definition: command_line.py:167
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
Stub.h
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
hgcalTopologyTester_cfi.layers
layers
Definition: hgcalTopologyTester_cfi.py:8
trklet::MemoryBase::iSector_
unsigned int iSector_
Definition: MemoryBase.h:44