23 if (
version_ == pc_lut_version)
return;
25 edm::LogInfo(
"L1T") <<
"EMTF using pc_lut_ver: " << pc_lut_version
26 <<
", configured for " << (pc_lut_data ?
"data" :
"MC");
29 if (pc_lut_version == 0)
30 coord_lut_dir =
"ph_lut_v1";
31 else if (pc_lut_version == 1)
32 coord_lut_dir =
"ph_lut_v2";
33 else if (pc_lut_version == 2 && pc_lut_data)
34 coord_lut_dir =
"ph_lut_v3_data";
35 else if (pc_lut_version == 2)
36 coord_lut_dir =
"ph_lut_v2";
37 else if (pc_lut_version == -1 && pc_lut_data)
38 coord_lut_dir =
"ph_lut_v3_data";
39 else if (pc_lut_version == -1)
40 coord_lut_dir =
"ph_lut_v2";
43 <<
"Trying to use EMTF pc_lut_version = " << pc_lut_version <<
", does not exist!";
46 std::string coord_lut_path =
"L1Trigger/L1TMuon/data/emtf_luts/" + coord_lut_dir +
"/";
55 std::string cppf_coord_lut_path =
"L1Trigger/L1TMuon/data/cppf/";
56 bool use_local_cppf_files = (pc_lut_version == -1);
57 if (use_local_cppf_files) {
58 cppf_coord_lut_path =
"L1Trigger/L1TMuon/data/cppf_luts/angleScale_v1/";
65 <<
"Expected ph_init_neighbor_ to get " << 2*6*61 <<
" values, " 71 <<
"Expected ph_disp_neighbor_ to get " << 2*6*61 <<
" values, " 77 <<
"Expected th_init_neighbor_ to get " << 2*6*61 <<
" values, " 83 <<
"Expected th_disp_neighbor_ to get " << 2*6*61 <<
" values, " 89 <<
"Expected th_lut_neighbor_ to get " << 2*6*61*128 <<
" values, " 95 <<
"Expected th_corr_lut_neighbor_ to get " << 2*6*7*128 <<
" values, " 101 <<
"Expected cppf_ph_lut_ to get " << 2*6*6*6*3*64 <<
" values, " 107 <<
"Expected cppf_th_lut_ to get " << 2*6*6*6*3 <<
" values, " 115 0, 0, 5, 5, 5, 5, 2, 2, 2, 2, 0
119 <<
"Expected ph_patt_corr_ to get " << 11 <<
" values, " 124 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0
128 <<
"Expected ph_patt_corr_sign_ to get " << 11 <<
" values, " 133 39,57,76,39,58,76,41,60,79,
134 95,114,132,95,114,133,98,116,135,
135 38,76,113,39,58,76,95,114,132,
136 38,76,113,39,58,76,95,114,132,
137 38,76,113,38,57,76,95,113,132,
138 21,21,23,1,21,1,21,1,20
142 <<
"Expected ph_zone_offset_ to get " << 6*9 <<
" values, " 149 39, 57, 76, 39, 58, 76, 41, 60, 79, 39, 57, 76, 21, 21, 23, 21,
150 95, 114, 132, 95, 114, 133, 98, 116, 135, 95, 114, 132, 0, 0, 0, 0,
151 38, 76, 113, 39, 58, 76, 95, 114, 132, 1, 21, 0, 0, 0, 0, 0,
152 38, 76, 113, 39, 58, 76, 95, 114, 132, 1, 21, 0, 0, 0, 0, 0,
153 38, 76, 113, 38, 57, 76, 95, 113, 132, 1, 20, 0, 0, 0, 0, 0
157 <<
"Expected ph_init_hard_ to get " << 5*16 <<
" values, " 166 size_t index = (fw_endcap * 6 + fw_sector) * 61 + pc_lut_id;
171 size_t index = (fw_endcap * 6 + fw_sector) * 61 + pc_lut_id;
176 size_t index = (fw_endcap * 6 + fw_sector) * 61 + pc_lut_id;
181 size_t index = (fw_endcap * 6 + fw_sector) * 61 + pc_lut_id;
186 int pc_lut_id2 = pc_lut_id;
189 if ((9 <= pc_lut_id2 && pc_lut_id2 < 12) || (25 <= pc_lut_id2 && pc_lut_id2 < 28))
192 if (pc_lut_id2 == 15)
195 size_t index = ((fw_endcap * 6 + fw_sector) * 61 + pc_lut_id2) * 128 + pc_wire_id;
200 int pc_lut_id2 = pc_lut_id;
203 if ((9 <= pc_lut_id2 && pc_lut_id2 < 12) || (25 <= pc_lut_id2 && pc_lut_id2 < 28))
206 if (pc_lut_id2 == 15)
209 if (pc_lut_id2 <= 3) {
211 }
else if (pc_lut_id2 == 12) {
213 }
else if (16 <= pc_lut_id2 && pc_lut_id2 < 19) {
217 <<
"get_th_corr_lut(): out of range pc_lut_id: " << pc_lut_id;
220 size_t index = ((fw_endcap * 6 + fw_sector) * 7 + pc_lut_id2) * 128 + pc_wire_strip_id;
233 size_t index = pc_station * 9 + pc_chamber;
238 size_t index = fw_station * 16 + fw_cscid;
243 uint32_t iendcap = (rpc_region == -1) ? 1 : 0;
244 uint32_t isector = (rpc_sector - 1);
245 uint32_t istationring = (rpc_station >= 3) ? ((rpc_station - 3) * 2 + (rpc_ring - 2) + 2) : (rpc_station - 1);
246 uint32_t isubsector = (rpc_subsector - 1);
247 uint32_t iroll = (rpc_roll - 1);
248 return ((((iendcap * 6 + isector) * 6 + istationring) * 6 + isubsector) * 3 + iroll);
252 size_t th_index =
get_cppf_lut_id(rpc_region, rpc_sector, rpc_station, rpc_ring, rpc_subsector, rpc_roll);
253 size_t ph_index = (th_index * 64) + (halfstrip - 1);
255 if (!is_neighbor && rpc_subsector == 2)
261 size_t th_index =
get_cppf_lut_id(rpc_region, rpc_sector, rpc_station, rpc_ring, rpc_subsector, rpc_roll);
269 std::ifstream infile;
273 while (infile >> buf) {
274 buf = (buf == -999) ? 0 : buf;
281 auto get_rpc_region = [](uint32_t
id) {
return (static_cast<int>((
id >> 0) & 0X3) + (-1)); };
282 auto get_rpc_sector = [](uint32_t
id) {
return (static_cast<int>((
id >> 7) & 0XF) + (1)); };
283 auto get_rpc_ring = [](uint32_t
id) {
return (static_cast<int>((
id >> 2) & 0X7) + (1)); };
284 auto get_rpc_station = [](uint32_t
id) {
return (static_cast<int>((
id >> 5) & 0X3) + (1)); };
285 auto get_rpc_subsector = [](uint32_t
id) {
return (static_cast<int>((
id >> 12) & 0X7) + (1)); };
286 auto get_rpc_roll = [](uint32_t
id) {
return (static_cast<int>((
id >> 15) & 0X7) + (0)); };
288 std::vector<std::string> cppf_filenames = {
289 "angleScale_RPC_CPPFp1.txt",
290 "angleScale_RPC_CPPFp2.txt",
291 "angleScale_RPC_CPPFp3.txt",
292 "angleScale_RPC_CPPFp4.txt",
293 "angleScale_RPC_CPPFn1.txt",
294 "angleScale_RPC_CPPFn2.txt",
295 "angleScale_RPC_CPPFn3.txt",
296 "angleScale_RPC_CPPFn4.txt",
302 vec1.resize(2*6*6*6*3*64, 0);
303 vec2.resize(2*6*6*6*3, 0);
305 for (
size_t i = 0;
i < cppf_filenames.size(); ++
i) {
306 std::ifstream infile;
307 infile.open(
edm::FileInPath(filename + cppf_filenames.at(
i)).fullPath().c_str());
311 int buf1, buf2, buf3, buf4, buf5, buf6;
313 int buf1_prev = 0, buf2_prev = 0, halfstrip_prev = 0;
317 while ((infile >> buf1) && (infile >> buf2) && (infile >> buf3) && (infile >> buf4) && (infile >> buf5) && (infile >> buf6)) {
319 if ((line_num % 192) == 191) line_num += 1;
323 if ((line_num % 2) == 1) {
328 if (local && (buf1 == 0 || buf2 == 0)) {
329 throw cms::Exception(
"SectorProcessorLUT") <<
"Expected non-0 values, got buf1 = " << buf1 <<
", buf2 = " << buf2;
331 if (!local && (buf1_prev == 0 || buf2_prev == 0)) {
332 throw cms::Exception(
"SectorProcessorLUT") <<
"Expected non-0 values, got buf1_prev = " << buf1_prev <<
", buf2_prev = " << buf2_prev;
335 uint32_t
id = (local ? buf1 : buf1_prev);
336 int32_t rpc_region = get_rpc_region(
id);
337 int32_t rpc_sector = get_rpc_sector(
id);
338 int32_t rpc_station = get_rpc_station(
id);
339 int32_t rpc_ring = get_rpc_ring(
id);
340 int32_t rpc_subsector = get_rpc_subsector(
id);
341 int32_t rpc_roll = get_rpc_roll(
id);
344 if ( buf2_prev*2 > halfstrip_prev + 8 ||
345 buf2_prev*2 < halfstrip_prev - 8 ) {
346 if (buf2_prev == 1) count_dir = +1;
349 if (count_dir == -1) dStrip = (buf2_prev*2 == halfstrip_prev ? 1 : 0);
350 if (count_dir == +1) dStrip = (buf2_prev*2 == halfstrip_prev + 2 ? 1 : 0);
351 if (buf2_prev*2 < halfstrip_prev - 8 && buf2_prev == 1) dStrip = 1;
354 uint32_t halfstrip = (local ? buf2 : buf2_prev*2 - dStrip);
355 halfstrip_prev = halfstrip;
360 size_t th_index =
get_cppf_lut_id(rpc_region, rpc_sector, rpc_station, rpc_ring, rpc_subsector, rpc_roll);
361 size_t ph_index = (th_index * 64) + (halfstrip - 1);
366 vec1.at(ph_index) = ph;
368 vec2.at(th_index) = th;
371 if (!local && (line_num % 192) == 191)
372 vec1.at(ph_index+1) = ph;
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_
uint32_t get_ph_patt_corr_sign(int pattern) const
std::vector< uint32_t > cppf_th_lut_
std::vector< uint32_t > th_disp_neighbor_
uint32_t get_th_init(int fw_endcap, int fw_sector, int pc_lut_id) const
std::vector< uint32_t > ph_patt_corr_
std::vector< double > vec1
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_init_hard_
uint32_t get_th_disp(int fw_endcap, int fw_sector, int pc_lut_id) const
uint32_t get_ph_disp(int fw_endcap, int fw_sector, int pc_lut_id) const
std::vector< uint32_t > ph_patt_corr_sign_
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_ph_zone_offset(int pc_station, int pc_chamber) const
std::vector< uint32_t > ph_disp_neighbor_
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
uint32_t get_ph_patt_corr(int pattern) 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_init_neighbor_
uint32_t get_ph_init_hard(int fw_station, int fw_cscid) const
void read_file(const std::string &filename, std::vector< uint32_t > &vec)
uint32_t get_ph_init(int fw_endcap, int fw_sector, int pc_lut_id) 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_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
std::vector< uint32_t > th_lut_neighbor_