CMS 3D CMS Logo

InputLinkMemory.cc
Go to the documentation of this file.
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 InputLinkMemory::InputLinkMemory(string name, Settings const& settings, unsigned int iSector, double, double)
18  : MemoryBase(name, settings, iSector) {
19  string subname = name.substr(5, 7);
20  phiregion_ = subname[3] - 'A';
21  assert(phiregion_ >= 0 && phiregion_ < 8);
22 
24 }
25 
27  Settings const& settings, Globals* globals, L1TStub& al1stub, Stub& stub, string dtc = "") {
28  if (layerdisk_ < N_LAYER && globals->phiCorr(layerdisk_) == nullptr) {
29  globals->phiCorr(layerdisk_) = new VMRouterPhiCorrTable(settings);
30  int nbits = 3;
31  if (layerdisk_ >= N_PSLAYER)
32  nbits = 4;
33  globals->phiCorr(layerdisk_)->init(layerdisk_ + 1, nbits, 3);
34  }
35 
36  unsigned int stublayerdisk = stub.layerdisk();
37  assert(stublayerdisk < 11);
38 
39  if (stublayerdisk != layerdisk_)
40  return false;
41 
42  if (layerdisk_ < N_LAYER) {
43  FPGAWord r = stub.r();
44  int bendbin = stub.bend().value();
45  int rbin = (r.value() + (1 << (r.nbits() - 1))) >> (r.nbits() - 3);
46  const VMRouterPhiCorrTable& phiCorrTable = *globals->phiCorr(layerdisk_);
47  int iphicorr = phiCorrTable.getphiCorrValue(bendbin, rbin);
48  stub.setPhiCorr(iphicorr);
49  }
50 
51  FPGAWord iphi = stub.phicorr();
52  unsigned int nallbits = settings_.nbitsallstubs(layerdisk_);
53  int phibin = iphi.bits(iphi.nbits() - nallbits, nallbits);
54  int iphivmRaw = iphi.bits(iphi.nbits() - 5, 5);
55 
56  if (phibin != phiregion_)
57  return false;
58 
59  if (getName().substr(10, dtc.size()) != dtc)
60  return false;
61 
62  string half = getName().substr(getName().size() - 3, 3);
63  if (half[1] != 'n') {
64  half = getName().substr(getName().size() - 1, 1);
65  }
66 
67  assert(half[0] == 'A' || half[0] == 'B');
68 
69  if (half[0] == 'B' && iphivmRaw <= 15)
70  return false;
71  if (half[0] == 'A' && iphivmRaw > 15)
72  return false;
73 
74  if (settings_.debugTracklet()) {
75  edm::LogVerbatim("Tracklet") << "Will add stub in " << getName() << " "
76  << "iphiwmRaw = " << iphivmRaw << " phi=" << al1stub.phi() << " z=" << al1stub.z()
77  << " r=" << al1stub.r();
78  }
79  if (stubs_.size() < settings_.maxStep("Link")) {
80  Stub* stubptr = new Stub(stub);
81  stubptr->setl1tstub(new L1TStub(al1stub));
82 
83  stubs_.emplace_back(stubptr);
84  }
85  return true;
86 }
87 
89  openFile(first, "../data/MemPrints/InputStubs/InputStubs_");
90 
91  for (unsigned int j = 0; j < stubs_.size(); j++) {
92  string stub = stubs_[j]->str();
93  out_ << std::setfill('0') << std::setw(2);
94  out_ << hex << j << dec;
95  out_ << " " << stub << " " << trklet::hexFormat(stub) << endl;
96  }
97  out_.close();
98 }
99 
101  for (auto& stub : stubs_) {
102  delete stub->l1tstub();
103  delete stub;
104  }
105  stubs_.clear();
106 }
trklet::InputLinkMemory::InputLinkMemory
InputLinkMemory(std::string name, Settings const &settings, unsigned int iSector, double, double)
Definition: InputLinkMemory.cc:17
trklet::N_PSLAYER
constexpr unsigned int N_PSLAYER
Definition: Settings.h:21
trklet::Globals::phiCorr
VMRouterPhiCorrTable *& phiCorr(unsigned int layer)
Definition: Globals.h:44
trklet::VMRouterPhiCorrTable::getphiCorrValue
int getphiCorrValue(int ibend, int irbin) const
Definition: VMRouterPhiCorrTable.cc:38
trklet::VMRouterPhiCorrTable::init
void init(int layer, int bendbits, int rbits)
Definition: VMRouterPhiCorrTable.cc:10
trklet::MemoryBase::settings_
Settings const & settings_
Definition: MemoryBase.h:50
L1TStub.h
MessageLogger.h
trklet::InputLinkMemory::clean
void clean() override
Definition: InputLinkMemory.cc:100
trklet::MemoryBase::openFile
void openFile(bool first, std::string filebase)
Definition: MemoryBase.cc:72
trklet::Stub::bend
const FPGAWord & bend() const
Definition: Stub.h:47
trklet::Settings
Definition: Settings.h:26
trklet::L1TStub
Definition: L1TStub.h:12
trklet::InputLinkMemory::stubs_
std::vector< Stub * > stubs_
Definition: InputLinkMemory.h:35
trklet::L1TStub::z
double z() const
Definition: L1TStub.h:56
trklet::Settings::nbitsallstubs
unsigned int nbitsallstubs(unsigned int layerdisk) const
Definition: Settings.h:83
cms::cuda::assert
assert(be >=bs)
trklet::MemoryBase::out_
std::ofstream out_
Definition: MemoryBase.h:46
trklet::MemoryBase::initLayerDisk
void initLayerDisk(unsigned int pos, int &layer, int &disk)
Definition: MemoryBase.cc:17
trklet::Globals
Definition: Globals.h:32
InputLinkMemory.h
dqmdumpme.first
first
Definition: dqmdumpme.py:55
trklet::InputLinkMemory::addStub
bool addStub(Settings const &settings, Globals *globals, L1TStub &al1stub, Stub &stub, std::string dtc)
Definition: InputLinkMemory.cc:26
trklet::Stub::r
const FPGAWord & r() const
Definition: Stub.h:49
trklet::InputLinkMemory::phiregion_
int phiregion_
Definition: InputLinkMemory.h:36
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
VMRouterPhiCorrTable.h
trklet::MemoryBase::getName
std::string const & getName() const
Definition: MemoryBase.h:19
trklet::Stub
Definition: Stub.h:16
trklet::N_LAYER
constexpr int N_LAYER
Definition: Settings.h:19
trklet::Stub::layerdisk
unsigned int layerdisk() const
Definition: Stub.cc:244
trklet::FPGAWord
Definition: FPGAWord.h:9
trklet::InputLinkMemory::writeStubs
void writeStubs(bool first)
Definition: InputLinkMemory.cc:88
trklet::MemoryBase
Definition: MemoryBase.h:13
Globals.h
trklet
Definition: AllProjectionsMemory.h:9
trklet::FPGAWord::value
int value() const
Definition: FPGAWord.h:24
trklet::InputLinkMemory::layerdisk_
unsigned int layerdisk_
Definition: InputLinkMemory.h:37
alignCSCRings.r
r
Definition: alignCSCRings.py:93
trklet::Stub::setl1tstub
void setl1tstub(L1TStub *l1tstub)
Definition: Stub.h:71
std
Definition: JetResolutionObject.h:76
trklet::Stub::phicorr
const FPGAWord & phicorr() const
Definition: Stub.h:52
trklet::Stub::setPhiCorr
void setPhiCorr(int phiCorr)
Definition: Stub.cc:198
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
trklet::Settings::debugTracklet
bool debugTracklet() const
Definition: Settings.h:146
trklet::VMRouterPhiCorrTable
Definition: VMRouterPhiCorrTable.h:16
trklet::Settings::maxStep
unsigned int maxStep(std::string module) const
Definition: Settings.h:93
trklet::L1TStub::r
double r() const
Definition: L1TStub.h:57
trklet::hexFormat
std::string hexFormat(const std::string &binary)
Definition: Util.h:14
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
Stub.h
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
trklet::L1TStub::phi
double phi() const
Definition: L1TStub.h:62
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443