File indexing completed on 2024-04-06 12:19:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include "L1Trigger/DTTraco/interface/DTTracoLUTs.h"
0019
0020
0021
0022
0023 #include <algorithm>
0024 #include <cmath>
0025 #include <iomanip>
0026 #include <iostream>
0027 #include <string>
0028
0029
0030
0031
0032
0033 #include "L1Trigger/DTUtilities/interface/DTTPGLutFile.h"
0034
0035 using namespace std;
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 DTTracoLUTs::DTTracoLUTs(string testfile) : _testfile(testfile) {}
0046
0047
0048
0049
0050
0051 DTTracoLUTs::~DTTracoLUTs() {
0052 psi_lut.clear();
0053 for (int k = 0; k < 3; k++)
0054 phi_lut[k].clear();
0055 }
0056
0057
0058
0059
0060
0061
0062
0063
0064 void DTTracoLUTs::reset() {
0065 psi_lut.clear();
0066 for (int k = 0; k < 3; k++)
0067 phi_lut[k].clear();
0068 }
0069
0070
0071
0072
0073 int DTTracoLUTs::load() {
0074
0075 string ang_file = _testfile + ".anglut";
0076 string pos_file = _testfile + ".poslut";
0077
0078
0079 DTTPGLutFile filePSI(ang_file);
0080 if (filePSI.open() != 0)
0081 return -1;
0082
0083
0084
0085
0086
0087
0088 for (int u = 0; u < 1024; u++) {
0089 int word = filePSI.readHex();
0090
0091
0092
0093
0094 psi_lut.push_back(word);
0095 }
0096 filePSI.close();
0097
0098
0099 DTTPGLutFile filePHI(pos_file);
0100 if (filePHI.open() != 0)
0101 return -1;
0102
0103
0104
0105 for (int y = 0; y < 3; y++) {
0106 for (int h = 0; h < 512; h++) {
0107 int phi = filePHI.readHex();
0108
0109
0110
0111
0112
0113
0114 phi_lut[y].push_back(phi);
0115 }
0116 }
0117 filePHI.close();
0118 return 0;
0119 }
0120
0121
0122
0123
0124 void DTTracoLUTs::print() const {
0125 cout << endl;
0126 cout << "L1 barrel Traco look-up tables :" << endl;
0127 cout << "====================================================" << endl;
0128 cout << endl;
0129
0130
0131
0132 for (int x = 0; x < 1024; x++)
0133 cout << "K=" << x << " ---> " << hex << psi_lut[x] << dec << endl;
0134 for (int m = 0; m < 512; m++)
0135 cout << "X=" << m << " ---> " << hex << (phi_lut[0])[m] << " " << (phi_lut[1])[m] << " " << (phi_lut[2])[m]
0136 << " " << dec << endl;
0137 }
0138
0139
0140
0141
0142 unsigned short int DTTracoLUTs::getPhiRad(int pos, int flag) const {
0143 unsigned short int phi = (phi_lut[flag])[pos] & 0xFFF;
0144
0145
0146
0147
0148 return phi;
0149 }
0150
0151
0152
0153
0154 unsigned short int DTTracoLUTs::getPsi(int ang) const {
0155 unsigned short int ipsi = (psi_lut)[ang + 512];
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168 return ipsi;
0169 }
0170
0171
0172
0173
0174 unsigned short int DTTracoLUTs::getBendAng(int pos, int ang, int flag) const {
0175
0176
0177
0178 unsigned short int BendAng = ((psi_lut)[ang + 512] - ((phi_lut[flag])[pos] / 8)) & 0x3FF;
0179
0180
0181
0182
0183 return BendAng;
0184 }