18 edm::LogInfo(
"L1T") <<
"EMTF using pc_lut_ver: " << pc_lut_version <<
", configured for " 19 << (pc_lut_data ?
"data" :
"MC");
22 if (pc_lut_version == 0)
23 coord_lut_dir =
"ph_lut_v1";
24 else if (pc_lut_version == 1)
25 coord_lut_dir =
"ph_lut_v2";
26 else if (pc_lut_version == 2 && pc_lut_data)
27 coord_lut_dir =
"ph_lut_v3_data";
28 else if (pc_lut_version == 3 && pc_lut_data)
29 coord_lut_dir =
"ph_lut_Run3_2022_data";
30 else if (pc_lut_version == 4 && pc_lut_data)
31 coord_lut_dir =
"ph_lut_Run3_2023_data";
32 else if (pc_lut_version >= 2)
33 coord_lut_dir =
"ph_lut_v2";
34 else if (pc_lut_version == -1 && pc_lut_data)
35 coord_lut_dir =
"ph_lut_v3_data";
36 else if (pc_lut_version == -1)
37 coord_lut_dir =
"ph_lut_v2";
40 <<
"Trying to use EMTF pc_lut_version = " << pc_lut_version <<
", does not exist!";
43 std::string coord_lut_path =
"L1Trigger/L1TMuon/data/emtf_luts/" + coord_lut_dir +
"/";
52 std::string cppf_coord_lut_path =
"L1Trigger/L1TMuon/data/cppf/";
53 bool use_local_cppf_files = (pc_lut_version == -1);
54 if (use_local_cppf_files) {
55 cppf_coord_lut_path =
"L1Trigger/L1TMuon/data/cppf_luts/angleScale_v1/";
61 use_local_cppf_files);
64 throw cms::Exception(
"L1TMuonEndCap") <<
"Expected ph_init_neighbor_ to get " << 2 * 6 * 61 <<
" values, " 69 throw cms::Exception(
"L1TMuonEndCap") <<
"Expected ph_disp_neighbor_ to get " << 2 * 6 * 61 <<
" values, " 74 throw cms::Exception(
"L1TMuonEndCap") <<
"Expected th_init_neighbor_ to get " << 2 * 6 * 61 <<
" values, " 79 throw cms::Exception(
"L1TMuonEndCap") <<
"Expected th_disp_neighbor_ to get " << 2 * 6 * 61 <<
" values, " 84 throw cms::Exception(
"L1TMuonEndCap") <<
"Expected th_lut_neighbor_ to get " << 2 * 6 * 61 * 128 <<
" values, " 89 throw cms::Exception(
"L1TMuonEndCap") <<
"Expected th_corr_lut_neighbor_ to get " << 2 * 6 * 7 * 128 <<
" values, " 96 throw cms::Exception(
"L1TMuonEndCap") <<
"Expected cppf_ph_lut_ to get " << 2 * 6 * 6 * 6 * 3 * 64 <<
" values, " 102 throw cms::Exception(
"L1TMuonEndCap") <<
"Expected cppf_th_lut_ to get " << 2 * 6 * 6 * 6 * 3 <<
" values, " 109 ph_patt_corr_ = {0, 0, 5, 5, 5, 5, 2, 2, 2, 2, 0};
111 throw cms::Exception(
"L1TMuonEndCap") <<
"Expected ph_patt_corr_ to get " << 11 <<
" values, " 115 ph_patt_corr_sign_ = {0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0};
117 throw cms::Exception(
"L1TMuonEndCap") <<
"Expected ph_patt_corr_sign_ to get " << 11 <<
" values, " 121 ph_zone_offset_ = {39, 57, 76, 39, 58, 76, 41, 60, 79, 95, 114, 132, 95, 114, 133, 98, 116, 135,
122 38, 76, 113, 39, 58, 76, 95, 114, 132, 38, 76, 113, 39, 58, 76, 95, 114, 132,
123 38, 76, 113, 38, 57, 76, 95, 113, 132, 21, 21, 23, 1, 21, 1, 21, 1, 20};
125 throw cms::Exception(
"L1TMuonEndCap") <<
"Expected ph_zone_offset_ to get " << 6 * 9 <<
" values, " 131 ph_init_hard_ = {39, 57, 76, 39, 58, 76, 41, 60, 79, 39, 57, 76, 21, 21, 23, 21, 95, 114, 132, 95,
132 114, 133, 98, 116, 135, 95, 114, 132, 0, 0, 0, 0, 38, 76, 113, 39, 58, 76, 95, 114,
133 132, 1, 21, 0, 0, 0, 0, 0, 38, 76, 113, 39, 58, 76, 95, 114, 132, 1, 21, 0,
134 0, 0, 0, 0, 38, 76, 113, 38, 57, 76, 95, 113, 132, 1, 20, 0, 0, 0, 0, 0};
136 throw cms::Exception(
"L1TMuonEndCap") <<
"Expected ph_init_hard_ to get " << 5 * 16 <<
" values, " 145 const uint32_t
index = (fw_endcap * 6 + fw_sector) * 61 + pc_lut_id;
151 edm::LogError(
"L1T") <<
"Could not retrieve entry from LUT. fw_endcap: " << fw_endcap
152 <<
", fw_sector: " << fw_sector <<
", pc_lut_id: " << pc_lut_id;
158 const uint32_t
index = (fw_endcap * 6 + fw_sector) * 61 + pc_lut_id;
164 edm::LogError(
"L1T") <<
"Could not retrieve entry from LUT. fw_endcap: " << fw_endcap
165 <<
", fw_sector: " << fw_sector <<
", pc_lut_id: " << pc_lut_id;
171 const uint32_t
index = (fw_endcap * 6 + fw_sector) * 61 + pc_lut_id;
177 edm::LogError(
"L1T") <<
"Could not retrieve entry from LUT. fw_endcap: " << fw_endcap
178 <<
", fw_sector: " << fw_sector <<
", pc_lut_id: " << pc_lut_id;
184 const uint32_t
index = (fw_endcap * 6 + fw_sector) * 61 + pc_lut_id;
190 edm::LogError(
"L1T") <<
"Could not retrieve entry from LUT. fw_endcap: " << fw_endcap
191 <<
", fw_sector: " << fw_sector <<
", pc_lut_id: " << pc_lut_id;
197 int pc_lut_id2 = pc_lut_id;
200 if ((9 <= pc_lut_id2 && pc_lut_id2 < 12) || (25 <= pc_lut_id2 && pc_lut_id2 < 28))
203 if (pc_lut_id2 == 15)
206 const uint32_t
index = ((fw_endcap * 6 + fw_sector) * 61 + pc_lut_id2) * 128 + pc_wire_id;
212 edm::LogError(
"L1T") <<
"Could not retrieve entry from LUT. fw_endcap: " << fw_endcap
213 <<
", fw_sector: " << fw_sector <<
", pc_lut_id: " << pc_lut_id
214 <<
", pc_wire_id: " << pc_wire_id;
220 int pc_lut_id2 = pc_lut_id;
223 if ((9 <= pc_lut_id2 && pc_lut_id2 < 12) || (25 <= pc_lut_id2 && pc_lut_id2 < 28))
226 if (pc_lut_id2 == 15)
229 if (pc_lut_id2 <= 3) {
231 }
else if (pc_lut_id2 == 12) {
233 }
else if (16 <= pc_lut_id2 && pc_lut_id2 < 19) {
236 edm::LogError(
"L1T") <<
"get_th_corr_lut(): out of range pc_lut_id: " << pc_lut_id;
239 const uint32_t
index = ((fw_endcap * 6 + fw_sector) * 7 + pc_lut_id2) * 128 + pc_wire_strip_id;
245 edm::LogError(
"L1T") <<
"Could not retrieve entry from LUT. fw_endcap: " << fw_endcap
246 <<
", fw_sector: " << fw_sector <<
", pc_lut_id: " << pc_lut_id
247 <<
", pc_wire_strip_id: " << pc_wire_strip_id;
277 const uint32_t
index = pc_station * 9 + pc_chamber;
283 edm::LogError(
"L1T") <<
"Could not retrieve entry from LUT. pc_station: " << pc_station
284 <<
", pc_chamber: " << pc_chamber;
290 const uint32_t
index = fw_station * 16 + fw_cscid;
296 edm::LogError(
"L1T") <<
"Could not retrieve entry from LUT. fw_station: " << fw_station
297 <<
", fw_cscid: " << fw_cscid;
303 int rpc_region,
int rpc_sector,
int rpc_station,
int rpc_ring,
int rpc_subsector,
int rpc_roll)
const {
304 uint32_t iendcap = (rpc_region == -1) ? 1 : 0;
305 uint32_t isector = (rpc_sector - 1);
306 uint32_t istationring = (rpc_station >= 3) ? ((rpc_station - 3) * 2 + (rpc_ring - 2) + 2) : (rpc_station - 1);
307 uint32_t isubsector = (rpc_subsector - 1);
308 uint32_t iroll = (rpc_roll - 1);
309 return ((((iendcap * 6 + isector) * 6 + istationring) * 6 + isubsector) * 3 + iroll);
319 bool is_neighbor)
const {
320 const uint32_t th_index =
get_cppf_lut_id(rpc_region, rpc_sector, rpc_station, rpc_ring, rpc_subsector, rpc_roll);
321 const uint32_t ph_index = (th_index * 64) + (halfstrip - 1);
327 edm::LogError(
"L1T") <<
"Could not retrieve entry from LUT. rpc_region: " << rpc_region
328 <<
", rpc_sector: " << rpc_sector <<
", rpc_station: " << rpc_station
329 <<
", rpc_ring: " << rpc_ring <<
", rpc_subsector: " << rpc_subsector
330 <<
", rpc_roll: " << rpc_roll <<
", halfstrip: " << halfstrip
331 <<
", is_neighbor: " << is_neighbor;
334 if (!is_neighbor && rpc_subsector == 2)
340 int rpc_region,
int rpc_sector,
int rpc_station,
int rpc_ring,
int rpc_subsector,
int rpc_roll)
const {
341 const uint32_t th_index =
get_cppf_lut_id(rpc_region, rpc_sector, rpc_station, rpc_ring, rpc_subsector, rpc_roll);
347 edm::LogError(
"L1T") <<
"Could not retrieve entry from LUT. rpc_region: " << rpc_region
348 <<
", rpc_sector: " << rpc_sector <<
", rpc_station: " << rpc_station
349 <<
", rpc_ring: " << rpc_ring <<
", rpc_subsector: " << rpc_subsector
350 <<
", rpc_roll: " << rpc_roll;
370 std::vector<uint32_t>&
vec1,
371 std::vector<uint32_t>&
vec2,
373 auto get_rpc_region = [](uint32_t
id) {
return (static_cast<int>((
id >> 0) & 0X3) + (-1)); };
374 auto get_rpc_sector = [](uint32_t
id) {
return (static_cast<int>((
id >> 7) & 0XF) + (1)); };
375 auto get_rpc_ring = [](uint32_t
id) {
return (static_cast<int>((
id >> 2) & 0X7) + (1)); };
376 auto get_rpc_station = [](uint32_t
id) {
return (static_cast<int>((
id >> 5) & 0X3) + (1)); };
377 auto get_rpc_subsector = [](uint32_t
id) {
return (static_cast<int>((
id >> 12) & 0X7) + (1)); };
378 auto get_rpc_roll = [](uint32_t
id) {
return (static_cast<int>((
id >> 15) & 0X7) + (0)); };
380 std::vector<std::string> cppf_filenames = {
381 "angleScale_RPC_CPPFp1.txt",
382 "angleScale_RPC_CPPFp2.txt",
383 "angleScale_RPC_CPPFp3.txt",
384 "angleScale_RPC_CPPFp4.txt",
385 "angleScale_RPC_CPPFn1.txt",
386 "angleScale_RPC_CPPFn2.txt",
387 "angleScale_RPC_CPPFn3.txt",
388 "angleScale_RPC_CPPFn4.txt",
393 vec1.resize(2 * 6 * 6 * 6 * 3 * 64, 0);
394 vec2.resize(2 * 6 * 6 * 6 * 3, 0);
396 for (
size_t i = 0;
i < cppf_filenames.size(); ++
i) {
402 int buf1, buf2, buf3, buf4, buf5, buf6;
404 int buf1_prev = 0, buf2_prev = 0, halfstrip_prev = 0;
410 if ((line_num % 192) == 191)
415 if ((line_num % 2) == 1) {
420 if (
local && (buf1 == 0 || buf2 == 0)) {
421 throw cms::Exception(
"L1TMuonEndCap") <<
"Expected non-0 values, got buf1 = " << buf1 <<
", buf2 = " << buf2;
423 if (!
local && (buf1_prev == 0 || buf2_prev == 0)) {
425 <<
"Expected non-0 values, got buf1_prev = " << buf1_prev <<
", buf2_prev = " << buf2_prev;
428 uint32_t
id = (
local ? buf1 : buf1_prev);
429 int32_t rpc_region = get_rpc_region(
id);
430 int32_t rpc_sector = get_rpc_sector(
id);
431 int32_t rpc_station = get_rpc_station(
id);
432 int32_t rpc_ring = get_rpc_ring(
id);
433 int32_t rpc_subsector = get_rpc_subsector(
id);
434 int32_t rpc_roll = get_rpc_roll(
id);
437 if (buf2_prev * 2 > halfstrip_prev + 8 ||
438 buf2_prev * 2 < halfstrip_prev - 8) {
445 dStrip = (buf2_prev * 2 == halfstrip_prev ? 1 : 0);
447 dStrip = (buf2_prev * 2 == halfstrip_prev + 2 ? 1 : 0);
448 if (buf2_prev * 2 < halfstrip_prev - 8 && buf2_prev == 1)
456 halfstrip_prev = halfstrip;
461 const uint32_t th_index =
get_cppf_lut_id(rpc_region, rpc_sector, rpc_station, rpc_ring, rpc_subsector, rpc_roll);
462 const uint32_t ph_index = (th_index * 64) + (halfstrip - 1);
469 vec2.at(th_index) = th;
472 if (!
local && (line_num % 192) == 191)
473 vec1.at(ph_index + 1) =
ph;
uint32_t get_ph_init_hard(int fw_station, int fw_cscid) const
uint32_t get_ph_patt_corr_sign(int pattern) const
uint32_t get_th_corr_lut(int fw_endcap, int fw_sector, int pc_lut_id, int pc_wire_strip_id) const
uint32_t get_th_lut(int fw_endcap, int fw_sector, int pc_lut_id, int pc_wire_id) const
std::vector< uint32_t > ph_zone_offset_
std::vector< uint32_t > cppf_ph_lut_
void read(bool pc_lut_data, int pc_lut_version)
std::vector< uint32_t > th_corr_lut_neighbor_
std::vector< uint32_t > cppf_th_lut_
Log< level::Error, false > LogError
std::vector< uint32_t > th_disp_neighbor_
uint32_t get_ph_patt_corr(int pattern) const
std::vector< uint32_t > ph_patt_corr_
std::vector< double > vec1
std::vector< uint32_t > ph_init_hard_
uint32_t get_ph_zone_offset(int pc_station, int pc_chamber) const
uint32_t get_cppf_th_lut(int rpc_region, int rpc_sector, int rpc_station, int rpc_ring, int rpc_subsector, int rpc_roll) const
std::vector< uint32_t > ph_patt_corr_sign_
Log< level::Info, false > LogInfo
uint32_t get_cppf_lut_id(int rpc_region, int rpc_sector, int rpc_station, int rpc_ring, int rpc_subsector, int rpc_roll) const
void read_cppf_file(const std::string &filename, std::vector< uint32_t > &vec1, std::vector< uint32_t > &vec2, bool local)
std::vector< uint32_t > th_init_neighbor_
uint32_t get_cppf_ph_lut(int rpc_region, int rpc_sector, int rpc_station, int rpc_ring, int rpc_subsector, int rpc_roll, int halfstrip, bool is_neighbor) const
uint32_t get_ph_disp(int fw_endcap, int fw_sector, int pc_lut_id) const
uint32_t get_ph_init(int fw_endcap, int fw_sector, int pc_lut_id) const
std::vector< uint32_t > ph_disp_neighbor_
uint32_t get_th_init(int fw_endcap, int fw_sector, int pc_lut_id) const
std::vector< uint32_t > ph_init_neighbor_
void read_file(const std::string &filename, std::vector< uint32_t > &vec)
uint32_t get_th_disp(int fw_endcap, int fw_sector, int pc_lut_id) const
std::vector< uint32_t > th_lut_neighbor_