Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-07 22:33:30

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   //Make new objects owned by the dtclink memory and save in list of stubs
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     //If the string starts with 'neg' skip the first three character
0040     int start = dtcname.substr(0, 3) == "neg" ? 3 : 0;
0041 
0042     //For the dtcbase name remove the leading 'neg' if in the name and the trailing '_A' or '_B'
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_ << std::setfill('0') << std::setw(2);
0059     out_ << hex << j << dec;
0060     out_ << " " << stub << " " << trklet::hexFormat(stub) << endl;
0061   }
0062   out_.close();
0063 }
0064 
0065 void DTCLinkMemory::clean() {
0066   for (auto& stub : stubs_) {
0067     delete stub->l1tstub();
0068     delete stub;
0069   }
0070   stubs_.clear();
0071 }