22 const std::vector<int>& zoneBoundaries,
29 if (not(tp_geom !=
nullptr)) {
33 if (not(lut !=
nullptr)) {
61 std::map<int, TriggerPrimitiveCollection>::const_iterator map_tp_it = selected_prim_map.begin();
62 std::map<int, TriggerPrimitiveCollection>::const_iterator map_tp_end = selected_prim_map.end();
64 for (; map_tp_it != map_tp_end; ++map_tp_it) {
66 int selected = map_tp_it->first;
69 int pc_station = selected / 9;
70 int pc_chamber = selected % 9;
73 TriggerPrimitiveCollection::const_iterator tp_it = map_tp_it->second.begin();
74 TriggerPrimitiveCollection::const_iterator tp_end = map_tp_it->second.end();
76 for (; tp_it != tp_end; ++tp_it) {
79 convert_csc(pc_sector, pc_station, pc_chamber, pc_segment, *tp_it, conv_hit);
81 convert_rpc(pc_sector, pc_station, pc_chamber, pc_segment, *tp_it, conv_hit);
83 convert_gem(pc_sector, pc_station, pc_chamber, pc_segment, *tp_it, conv_hit);
85 if (not(
false &&
"Incorrect subsystem type")) {
90 conv_hits.push_back(conv_hit);
107 int tp_endcap = tp_detId.
endcap();
109 int tp_station = tp_detId.
station();
110 int tp_ring = tp_detId.
ring();
111 int tp_chamber = tp_detId.
chamber();
113 int tp_bx = tp_data.bx;
114 int tp_csc_ID = tp_data.cscID;
118 int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber % 6 > 2) ? 1 : 2);
120 const bool is_neighbor = (pc_station == 5);
122 int csc_nID = tp_csc_ID;
127 csc_nID = (pc_chamber < 3) ? (pc_chamber + 12) : (((pc_chamber - 1) % 2) + 9);
130 if (tp_station == 1) {
131 if (not(tp_subsector == 2)) {
141 conv_hit.
set_endcap((tp_endcap == 2) ? -1 : tp_endcap);
188 double glob_eta = gp.
eta();
189 double glob_rho = gp.
perp();
190 double glob_z = gp.
z();
201 const bool is_neighbor = conv_hit.
Neighbor();
208 const int fw_endcap = (
endcap_ - 1);
209 const int fw_sector = (
sector_ - 1);
210 const int fw_station =
212 const int fw_cscid = (conv_hit.
CSC_nID() - 1);
213 const int fw_strip = conv_hit.
Strip();
214 const int fw_wire = conv_hit.
Wire();
223 const bool is_me11a = (conv_hit.
Station() == 1 && conv_hit.
Ring() == 4);
224 const bool is_me11b = (conv_hit.
Station() == 1 && conv_hit.
Ring() == 1);
225 const bool is_me13 = (conv_hit.
Station() == 1 && conv_hit.
Ring() == 3);
229 bool ph_reverse =
false;
230 if ((fw_endcap == 0 && fw_station >= 3) || (fw_endcap == 1 && fw_station < 3))
236 if (fw_station <= 1 && ((fw_cscid >= 6 && fw_cscid <= 8) || fw_cscid == 14))
238 else if (fw_station >= 2 && (fw_cscid <= 2 || fw_cscid == 9))
245 bool is_10degree =
false;
246 if ((fw_station <= 1) ||
247 (fw_station >= 2 && ((fw_cscid >= 3 && fw_cscid <= 8) || fw_cscid == 10))
255 int pc_lut_id = pc_chamber;
256 if (pc_station == 0) {
257 pc_lut_id = is_me11a ? pc_lut_id + 9 : pc_lut_id;
258 }
else if (pc_station == 1) {
260 pc_lut_id = is_me11a ? pc_lut_id + 9 : pc_lut_id;
261 }
else if (pc_station == 2) {
263 }
else if (pc_station == 3) {
265 }
else if (pc_station == 4) {
267 }
else if (pc_station == 5 && pc_chamber < 3) {
268 pc_lut_id = is_me11a ? pc_lut_id + 15 : pc_lut_id + 12;
269 }
else if (pc_station == 5 && pc_chamber < 5) {
270 pc_lut_id += 28 + 9 - 3;
271 }
else if (pc_station == 5 && pc_chamber < 7) {
272 pc_lut_id += 39 + 9 - 5;
273 }
else if (pc_station == 5 && pc_chamber < 9) {
274 pc_lut_id += 50 + 9 - 7;
276 if (not(pc_lut_id < 61)) {
282 std::cout <<
"pc_station: " << pc_station <<
" pc_chamber: " << pc_chamber <<
" fw_station: " << fw_station
283 <<
" fw_cscid: " << fw_cscid <<
" lut_id: " << pc_lut_id
284 <<
" ph_init: " <<
lut().
get_ph_init(fw_endcap, fw_sector, pc_lut_id)
285 <<
" ph_disp: " <<
lut().
get_ph_disp(fw_endcap, fw_sector, pc_lut_id)
286 <<
" th_init: " <<
lut().
get_th_init(fw_endcap, fw_sector, pc_lut_id)
287 <<
" th_disp: " <<
lut().
get_th_disp(fw_endcap, fw_sector, pc_lut_id)
295 int eighth_strip = 0;
302 bool bugStrip0BeforeFW48200 =
false;
303 if (bugStrip0BeforeFW48200 ==
false && fw_strip == 0 && clct_pat_corr_sign == -1)
307 eighth_strip = fw_strip << 2;
308 eighth_strip += clct_pat_corr_sign * (clct_pat_corr >> 1);
310 eighth_strip = fw_strip << 3;
311 eighth_strip += clct_pat_corr_sign * (clct_pat_corr >> 0);
313 if (not(bugStrip0BeforeFW48200 ==
true || eighth_strip >= 0)) {
314 edm::LogError(
"L1T") <<
"bugStrip0BeforeFW48200 = " << bugStrip0BeforeFW48200
315 <<
", eighth_strip = " << eighth_strip;
331 int ph_tmp = (eighth_strip *
factor) >> 10;
332 int ph_tmp_sign = (ph_reverse == 0) ? 1 : -1;
335 fph = fph + ph_tmp_sign * ph_tmp;
338 ph_hit = (ph_hit >> 1) + ph_tmp_sign * (ph_tmp >> 5) + ph_coverage;
343 ph_hit_fixed = ph_hit_fixed + ((fph + (1 << 4)) >> 5);
346 ph_hit = ph_hit_fixed;
353 zone_hit_fixed += ph_hit_fixed;
358 zone_hit = zone_hit_fixed;
360 if (not(0 <= fph && fph < 5000)) {
364 if (not(0 <= zone_hit && zone_hit < 192)) {
373 int pc_wire_id = (fw_wire & 0x7f);
374 int th_tmp =
lut().
get_th_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_id);
378 int pc_wire_strip_id =
379 (((fw_wire >> 4) & 0x3) << 5) | ((eighth_strip >> 4) & 0x1f);
384 bool bugME11DupesBeforeFW47114 =
false;
385 if (bugME11DupesBeforeFW47114) {
386 if (pc_segment == 1) {
387 pc_wire_strip_id = (((fw_wire >> 4) & 0x3) << 5) | (0);
392 int th_corr =
lut().
get_th_corr_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_strip_id);
393 int th_corr_sign = (ph_reverse == 0) ? 1 : -1;
395 th_tmp = th_tmp + th_corr_sign * th_corr;
398 const int th_negative = 50;
399 const int th_coverage = 45;
400 if (th_tmp > th_negative || th_tmp < 0 || fw_wire == 0)
402 if (th_tmp > th_coverage)
403 th_tmp = th_coverage;
406 int pc_wire_strip_id =
407 (((fw_wire >> 4) & 0x3) << 5) | ((eighth_strip >> 4) & 0x1f);
409 pc_wire_strip_id = (((fw_wire >> 4) & 0x3) << 5) | ((((eighth_strip * 341) >> 8) >> 4) &
411 int th_corr =
lut().
get_th_corr_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_strip_id);
413 th_tmp = th_tmp + th_corr;
416 const int th_coverage = 46;
419 if (th_tmp > th_coverage)
420 th_tmp = th_coverage;
428 if (not(0 <= th && th < 128)) {
432 th = (th == 0) ? 1 : th;
439 int phzvl =
get_phzvl(conv_hit, zone_code);
442 int fs_segment =
get_fs_segment(conv_hit, fw_station, fw_cscid, pc_segment);
444 int bt_station =
get_bt_station(conv_hit, fw_station, fw_cscid, pc_segment);
445 int bt_segment =
get_bt_segment(conv_hit, fw_station, fw_cscid, pc_segment);
480 int tp_region = tp_detId.
region();
481 int tp_endcap = (tp_region == -1) ? 2 : tp_region;
482 int tp_sector = tp_detId.
sector();
484 int tp_station = tp_detId.
station();
485 int tp_ring = tp_detId.
ring();
486 int tp_roll = tp_detId.
roll();
489 int tp_bx = tp_data.bx;
490 int tp_strip = ((tp_data.strip_low + tp_data.strip_hi) / 2);
491 int tp_valid = tp_data.valid;
493 const bool is_neighbor = (pc_station == 5);
496 int csc_tp_chamber = (tp_sector - 1) * 6 + tp_subsector;
497 int csc_tp_sector = (tp_subsector > 2) ? tp_sector : ((tp_sector + 4) % 6) + 1;
498 int csc_tp_subsector = ((tp_subsector + 3) % 6) + 1;
503 conv_hit.
set_endcap((tp_endcap == 2) ? -1 : tp_endcap);
544 bool use_fullsim_coords =
true;
546 if (tp_data.isCPPF) {
549 }
else if (use_fullsim_coords) {
553 double glob_eta = gp.
eta();
554 double glob_rho = gp.
perp();
555 double glob_z = gp.
z();
567 if (not(0 <= fph && fph < 1250)) {
571 if (not(0 <= th && th < 32)) {
575 if (not(th != 0b11111))
582 th = (th == 0) ? 1 : th;
601 const bool is_neighbor = conv_hit.
Neighbor();
609 const int fw_station = (conv_hit.
Station() == 1) ? (is_neighbor ? 0 : pc_station) : conv_hit.
Station();
611 int fw_cscid = pc_chamber;
618 csc_nID = (pc_chamber < 3) ? (pc_chamber + 12) : (((pc_chamber - 1) % 2) + 9);
621 fw_cscid = csc_nID - 1;
624 int fph = conv_hit.
Phi_fp();
629 if (not(1 <= halfstrip && halfstrip <= 64)) {
651 if (not(0 <= fph && fph < 1250)) {
655 if (not(0 <= th && th < 32)) {
659 if (not(th != 0b11111))
666 th = (th == 0) ? 1 : th;
670 std::cout <<
"RPC hit pc_station: " << pc_station <<
" pc_chamber: " << pc_chamber <<
" fw_station: " << fw_station
671 <<
" fw_cscid: " << fw_cscid <<
" tp_station: " << conv_hit.
Station() <<
" tp_ring: " << conv_hit.
Ring()
673 <<
" fph: " << fph <<
" th: " << th << std::endl;
679 int zone_hit = ((fph + (1 << 4)) >> 5);
684 int fs_segment =
get_fs_segment(conv_hit, fw_station, fw_cscid, pc_segment);
686 int bt_station =
get_bt_station(conv_hit, fw_station, fw_cscid, pc_segment);
687 int bt_segment =
get_bt_segment(conv_hit, fw_station, fw_cscid, pc_segment);
722 int tp_region = tp_detId.
region();
723 int tp_endcap = (tp_region == -1) ? 2 : tp_region;
724 int tp_station = tp_detId.
station();
725 int tp_ring = tp_detId.
ring();
726 int tp_roll = tp_detId.
roll();
728 int tp_chamber = tp_detId.
chamber();
730 int tp_bx = tp_data.
bx;
737 if (station > 1 && ring > 1) {
738 result = ((
static_cast<unsigned>(
chamber - 3) & 0x7f) / 6) + 1;
740 result = (station != 1) ? ((static_cast<unsigned>(
chamber - 2) & 0x1f) / 3) + 1 :
741 ((
static_cast<unsigned>(
chamber - 3) & 0x7f) / 6) + 1;
743 return (result <= 6) ? result
765 result = (
chamber + 1) % 3 + 1;
767 result = (
chamber + 3) % 6 + 4;
773 int tp_sector = get_trigger_sector(tp_ring, tp_station, tp_chamber);
774 int tp_csc_ID = get_trigger_csc_ID(tp_ring, tp_station, tp_chamber);
778 int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber % 6 > 2) ? 1 : 2);
780 const bool is_neighbor = (pc_station == 5);
782 int csc_nID = tp_csc_ID;
787 csc_nID = (pc_chamber < 3) ? (pc_chamber + 12) : (((pc_chamber - 1) % 2) + 9);
790 if (tp_station == 1) {
791 if (not(tp_subsector == 2)) {
801 conv_hit.
set_endcap((tp_endcap == 2) ? -1 : tp_endcap);
842 bool use_fullsim_coords =
true;
843 if (use_fullsim_coords) {
847 double glob_eta = gp.
eta();
848 double glob_rho = gp.
perp();
849 double glob_z = gp.
z();
855 if (not(0 <= fph && fph < 5000)) {
859 if (not(0 <= th && th < 128)) {
863 th = (th == 0) ? 1 : th;
882 const bool is_neighbor = conv_hit.
Neighbor();
890 const int fw_station =
892 const int fw_cscid = (conv_hit.
CSC_nID() - 1);
894 int fph = conv_hit.
Phi_fp();
898 std::cout <<
"GEM hit pc_station: " << pc_station <<
" pc_chamber: " << pc_chamber <<
" fw_station: " << fw_station
899 <<
" fw_cscid: " << fw_cscid <<
" tp_station: " << conv_hit.
Station() <<
" tp_ring: " << conv_hit.
Ring()
900 <<
" tp_sector: " << conv_hit.
Sector() <<
" tp_subsector: " << conv_hit.
Subsector() <<
" fph: " << fph
901 <<
" th: " << th << std::endl;
907 int zone_hit = ((fph + (1 << 4)) >> 5);
912 int fs_segment =
get_fs_segment(conv_hit, fw_station, fw_cscid, pc_segment);
914 int bt_station =
get_bt_station(conv_hit, fw_station, fw_cscid, pc_segment);
915 int bt_segment =
get_bt_segment(conv_hit, fw_station, fw_cscid, pc_segment);
947 bool is_me13 = (is_csc && conv_hit.
Station() == 1 && conv_hit.
Ring() == 3);
951 if (zone_code_tmp & (1 << izone)) {
953 ((izone == 0) || ((zone_code_tmp & (1 << (izone - 1))) == 0) || is_me13);
954 bool no_use_bnd2 = (((zone_code_tmp & (1 << (izone + 1))) == 0) || is_me13);
960 zone_code |= (1 << izone);
964 if (not(zone_code > 0)) {
976 if (conv_hit.
Ring() == 1 || conv_hit.
Ring() == 4) {
977 phzvl = (zone_code >> 0);
978 }
else if (conv_hit.
Ring() == 2) {
980 phzvl = (zone_code >> 1);
982 phzvl = (zone_code >> 2);
984 }
else if (conv_hit.
Ring() == 3) {
985 phzvl = (zone_code >> 3);
991 static const unsigned int zone_code_table[4][3] = {
993 {0b0011, 0b0100, 0b1000},
994 {0b0011, 0b1100, 0b1100},
995 {0b0001, 0b1110, 0b1110},
996 {0b0001, 0b0110, 0b0110}
999 static const unsigned int zone_code_table_new[4][3] = {
1001 {0b0011, 0b0110, 0b1000},
1002 {0b0011, 0b1110, 0b1110},
1003 {0b0011, 0b1110, 0b1110},
1004 {0b0001, 0b0110, 0b0110}
1007 unsigned int istation = (conv_hit.
Station() - 1);
1008 unsigned int iring = (conv_hit.
Ring() == 4) ? 0 : (conv_hit.
Ring() - 1);
1009 if (not(istation < 4 && iring < 3)) {
1010 edm::LogError(
"L1T") <<
"istation = " << istation <<
", iring = " << iring;
1013 unsigned int zone_code =
useNewZones_ ? zone_code_table_new[istation][iring] : zone_code_table[istation][iring];
1021 int fs_chamber = -1;
1022 int fs_segment = pc_segment % 2;
1031 const bool is_neighbor = conv_hit.
Neighbor();
1032 if (fw_station <= 1) {
1033 int n = fw_cscid % 3;
1034 fs_chamber = is_neighbor ? 0 : ((fw_station == 0) ? 1 + n : 4 + n);
1036 int n = (conv_hit.
Ring() == 1) ? fw_cscid : (fw_cscid - 3);
1037 fs_chamber = is_neighbor ? 0 : 1 +
n;
1040 if (not(fs_history == 0 && (0 <= fs_chamber && fs_chamber < 7) && (0 <= fs_segment && fs_segment < 2))) {
1041 edm::LogError(
"L1T") <<
"fs_history = " << fs_history <<
", fs_chamber = " << fs_chamber
1042 <<
", fs_segment = " << fs_segment;
1048 fs_segment = ((fs_history & 0x3) << 4) | ((fs_chamber & 0x7) << 1) | (fs_segment & 0x1);
1053 int bt_station = fw_station;
1061 int bt_chamber = -1;
1062 int bt_segment = pc_segment % 2;
1072 bt_chamber = fw_cscid + 1;
1073 if (fw_station == 0 && bt_chamber >= 13)
1076 if (not(bt_history == 0 && (0 <= bt_chamber && bt_chamber < 13) && (0 <= bt_segment && bt_segment < 2))) {
1077 edm::LogError(
"L1T") <<
"bt_history = " << bt_history <<
", bt_chamber = " << bt_chamber
1078 <<
", bt_segment = " << bt_segment;
1085 bt_segment = ((bt_history & 0x3) << 5) | ((bt_chamber & 0xf) << 1) | (bt_segment & 0x1);
void set_subsector_RPC(int bits)
void set_phi_glob(float val)
void set_theta_sim(float val)
void set_is_GEM(int bits)
void set_neighbor(int bits)
void set_rho_sim(float val)
int get_bt_station(const EMTFHit &conv_hit, int fw_station, int fw_cscid, int pc_segment) const
void set_csc_nID(int bits)
void set_pc_station(int bits)
void set_phi_sim(float val)
int get_zone_code(const EMTFHit &conv_hit, int th) const
void convert_gem_details(EMTFHit &conv_hit) const
void configure(const GeometryTranslator *tp_geom, const SectorProcessorLUT *lut, int verbose, int endcap, int sector, int bx, int bxShiftCSC, int bxShiftRPC, int bxShiftGEM, const std::vector< int > &zoneBoundaries, int zoneOverlap, bool duplicateTheta, bool fixZonePhi, bool useNewZones, bool fixME11Edges, bool bugME11Dupes)
const GEMData getGEMData() const
const SectorProcessorLUT * lut_
void set_station(int bits)
void set_ph_hit(int bits)
void set_theta(float val)
Geom::Phi< T > phi() const
void set_bt_station(int bits)
void set_eta_sim(float val)
void convert_gem(int pc_sector, int pc_station, int pc_chamber, int pc_segment, const TriggerPrimitive &muon_primitive, EMTFHit &conv_hit) const
double calc_phi_loc_deg(int bits)
void set_sector_idx(int bits)
void convert_rpc(int pc_sector, int pc_station, int pc_chamber, int pc_segment, const TriggerPrimitive &muon_primitive, EMTFHit &conv_hit) const
T1 value() const
Explicit access to value in case implicit conversion not OK.
int calc_phi_loc_int(double glob, int sector)
l1t::EMTFHitCollection EMTFHitCollection
void set_sync_err(int bits)
uint32_t get_ph_patt_corr_sign(int pattern) const
const CSCData getCSCData() const
int get_bt_segment(const EMTFHit &conv_hit, int fw_station, int fw_cscid, int pc_segment) const
void set_theta_fp(int bits)
void set_endcap(int bits)
int calc_theta_int_rpc(double theta, int endcap)
const RPCData getRPCData() const
Geom::Theta< T > theta() const
void SetRPCDetId(const RPCDetId &id)
uint32_t get_th_init(int fw_endcap, int fw_sector, int pc_lut_id) const
int get_fs_segment(const EMTFHit &conv_hit, int fw_station, int fw_cscid, int pc_segment) const
void set_strip_low(int bits)
double calc_theta_deg_from_int(int theta_int)
void set_bt_segment(int bits)
int region() const
The identifiers.
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
void set_is_CSC(int bits)
void set_pattern(int bits)
int Subsector_RPC() const
void set_csc_ID(int bits)
void set_pc_chamber(int bits)
void set_strip_hi(int bits)
int calc_phi_loc_int_rpc(double glob, int sector)
void convert_csc_details(EMTFHit &conv_hit) const
double calc_phi_glob_deg(double loc, int sector)
void set_phi_loc(float val)
uint32_t get_th_disp(int fw_endcap, int fw_sector, int pc_lut_id) const
int calc_theta_int(double theta, int endcap)
void set_pc_segment(int bits)
uint32_t get_ph_disp(int fw_endcap, int fw_sector, int pc_lut_id) const
void set_is_RPC(int bits)
void SetCSCDetId(const CSCDetId &id)
void set_fs_segment(int bits)
void set_sector_RPC(int bits)
std::vector< int > zoneBoundaries_
void set_sector(int bits)
void process(const std::map< int, TriggerPrimitiveCollection > &selected_prim_map, EMTFHitCollection &conv_hits) const
void set_z_sim(float val)
int triggerSector() const
double calc_eta_from_theta_deg(double theta_deg, int endcap)
uint32_t get_ph_zone_offset(int pc_station, int pc_chamber) const
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
void set_subsystem(int bits)
void set_track_num(int bits)
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel...
void set_zone_code(int bits)
uint32_t get_ph_patt_corr(int pattern) const
void set_zone_hit(int bits)
uint32_t get_th_lut(int fw_endcap, int fw_sector, int pc_lut_id, int pc_wire_id) const
double rad_to_deg(double rad)
int get_phzvl(const EMTFHit &conv_hit, int zone_code) const
const SectorProcessorLUT & lut() const
int get_fs_zone_code(const EMTFHit &conv_hit) const
uint32_t get_ph_init_hard(int fw_station, int fw_cscid) const
EMTFGEMDetId construct_EMTFGEMDetId(const L1TMuon::TriggerPrimitive &tp)
void set_fs_zone_code(int bits)
void set_clct_quality(int bits)
void set_quality(int bits)
void set_chamber(int bits)
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
void set_subsector(int bits)
void set_alct_quality(int bits)
void convert_rpc_details(EMTFHit &conv_hit, const bool use_cppf_lut) const
const GeometryTranslator * tp_geom_
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
void convert_csc(int pc_sector, int pc_station, int pc_chamber, int pc_segment, const TriggerPrimitive &muon_primitive, EMTFHit &conv_hit) const
void set_phi_fp(int bits)
void set_pc_sector(int bits)
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
GlobalPoint getGlobalPoint(const TriggerPrimitive &) const