File indexing completed on 2023-03-17 11:13:49
0001 #include "L1Trigger/TrackFindingTracklet/interface/DTCLinkMemory.h"
0002 #include "L1Trigger/TrackFindingTracklet/interface/L1TStub.h"
0003 #include "L1Trigger/TrackFindingTracklet/interface/Stub.h"
0004
0005 #include "L1Trigger/TrackFindingTracklet/interface/Globals.h"
0006
0007 #include <iomanip>
0008 #include <cmath>
0009 #include <sstream>
0010 #include <cctype>
0011
0012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0013
0014 using namespace trklet;
0015 using namespace std;
0016
0017 DTCLinkMemory::DTCLinkMemory(string name, Settings const& settings, double, double) : MemoryBase(name, settings) {}
0018
0019 void DTCLinkMemory::addStub(const L1TStub& al1stub, const Stub& stub) {
0020
0021 if (stubs_.size() < settings_.maxStep("IR")) {
0022 Stub* stubptr = new Stub(stub);
0023 stubptr->setl1tstub(new L1TStub(al1stub));
0024
0025 stubs_.emplace_back(stubptr);
0026 }
0027 }
0028
0029 void DTCLinkMemory::writeStubs(bool first, unsigned int iSector) {
0030 iSector_ = iSector;
0031
0032 const string dirIS = settings_.memPath() + "InputStubs/";
0033 openFile(first, dirIS, "Link_");
0034
0035 for (unsigned int j = 0; j < stubs_.size(); j++) {
0036 string dtcname = stubs_[j]->l1tstub()->DTClink();
0037 int layerdisk = stubs_[j]->l1tstub()->layerdisk();
0038
0039
0040 int start = dtcname.substr(0, 3) == "neg" ? 3 : 0;
0041
0042
0043 string dtcbase = dtcname.substr(start, dtcname.size() - 2 - start);
0044
0045 const vector<int>& layers = settings_.dtcLayers(dtcbase);
0046
0047 int lcode = -1;
0048 for (unsigned int index = 0; index < layers.size(); index++) {
0049 if (layerdisk == layers[index]) {
0050 lcode = index;
0051 }
0052 }
0053 assert(lcode != -1);
0054
0055 FPGAWord ldcode(lcode, 2, true);
0056
0057 string stub = stubs_[j]->str() + "|" + ldcode.str() + "|1";
0058 out_ << hexstr(j) << " " << stub << " " << trklet::hexFormat(stub) << endl;
0059 }
0060 out_.close();
0061 }
0062
0063 void DTCLinkMemory::clean() {
0064 for (auto& stub : stubs_) {
0065 delete stub->l1tstub();
0066 delete stub;
0067 }
0068 stubs_.clear();
0069 }