16 int bxShiftCSC,
int bxShiftRPC,
int bxShiftGEM,
17 const std::vector<int>& zoneBoundaries,
int zoneOverlap,
18 bool duplicateTheta,
bool fixZonePhi,
bool useNewZones,
bool fixME11Edges,
21 if (not(tp_geom !=
nullptr))
23 if (not(lut !=
nullptr))
48 const std::map<int, TriggerPrimitiveCollection>& selected_prim_map,
51 std::map<int, TriggerPrimitiveCollection>::const_iterator map_tp_it = selected_prim_map.begin();
52 std::map<int, TriggerPrimitiveCollection>::const_iterator map_tp_end = selected_prim_map.end();
54 for (; map_tp_it != map_tp_end; ++map_tp_it) {
56 int selected = map_tp_it->first;
59 int pc_station = selected / 9;
60 int pc_chamber = selected % 9;
63 TriggerPrimitiveCollection::const_iterator tp_it = map_tp_it->second.begin();
64 TriggerPrimitiveCollection::const_iterator tp_end = map_tp_it->second.end();
66 for (; tp_it != tp_end; ++tp_it) {
69 convert_csc(pc_sector, pc_station, pc_chamber, pc_segment, *tp_it, conv_hit);
71 convert_rpc(pc_sector, pc_station, pc_chamber, pc_segment, *tp_it, conv_hit);
73 convert_gem(pc_sector, pc_station, pc_chamber, pc_segment, *tp_it, conv_hit);
75 if (not(
false &&
"Incorrect subsystem type"))
76 {
edm::LogError(
"L1T") <<
"Incorrect subsystem type";
return; }
78 conv_hits.push_back(conv_hit);
88 int pc_sector,
int pc_station,
int pc_chamber,
int pc_segment,
95 int tp_endcap = tp_detId.
endcap();
97 int tp_station = tp_detId.
station();
98 int tp_ring = tp_detId.
ring();
99 int tp_chamber = tp_detId.
chamber();
101 int tp_bx = tp_data.bx;
102 int tp_csc_ID = tp_data.cscID;
106 int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber % 6 > 2) ? 1 : 2);
108 const bool is_neighbor = (pc_station == 5);
110 int csc_nID = tp_csc_ID;
115 csc_nID = (pc_chamber < 3) ? (pc_chamber + 12) : ( ((pc_chamber - 1) % 2) + 9);
118 if (tp_station == 1) {
119 if (not(tp_subsector == 2))
120 {
edm::LogError(
"L1T") <<
"tp_subsector = " << tp_subsector;
return; }
127 conv_hit.
set_endcap ( (tp_endcap == 2) ? -1 : tp_endcap );
151 conv_hit.
set_wire ( tp_data.keywire );
166 double glob_eta = gp.
eta();
175 const bool is_neighbor = conv_hit.
Neighbor();
182 const int fw_endcap = (
endcap_-1);
183 const int fw_sector = (
sector_-1);
184 const int fw_station = (conv_hit.
Station() == 1) ? (is_neighbor ? 0 : (conv_hit.
Subsector()-1)) : conv_hit.
Station();
185 const int fw_cscid = (conv_hit.
CSC_nID()-1);
186 const int fw_strip = conv_hit.
Strip();
187 const int fw_wire = conv_hit.
Wire();
196 const bool is_me11a = (conv_hit.
Station() == 1 && conv_hit.
Ring() == 4);
197 const bool is_me11b = (conv_hit.
Station() == 1 && conv_hit.
Ring() == 1);
198 const bool is_me13 = (conv_hit.
Station() == 1 && conv_hit.
Ring() == 3);
202 bool ph_reverse =
false;
203 if ((fw_endcap == 0 && fw_station >= 3) || (fw_endcap == 1 && fw_station < 3))
209 if (fw_station <= 1 && ((fw_cscid >= 6 && fw_cscid <= 8) || fw_cscid == 14))
211 else if (fw_station >= 2 && (fw_cscid <= 2 || fw_cscid == 9))
218 bool is_10degree =
false;
221 (fw_station >= 2 && ((fw_cscid >= 3 && fw_cscid <= 8) || fw_cscid == 10))
229 int pc_lut_id = pc_chamber;
230 if (pc_station == 0) {
231 pc_lut_id = is_me11a ? pc_lut_id + 9 : pc_lut_id;
232 }
else if (pc_station == 1) {
234 pc_lut_id = is_me11a ? pc_lut_id + 9 : pc_lut_id;
235 }
else if (pc_station == 2) {
237 }
else if (pc_station == 3) {
239 }
else if (pc_station == 4) {
241 }
else if (pc_station == 5 && pc_chamber < 3) {
242 pc_lut_id = is_me11a ? pc_lut_id + 15 : pc_lut_id + 12;
243 }
else if (pc_station == 5 && pc_chamber < 5) {
244 pc_lut_id += 28 + 9 - 3;
245 }
else if (pc_station == 5 && pc_chamber < 7) {
246 pc_lut_id += 39 + 9 - 5;
247 }
else if (pc_station == 5 && pc_chamber < 9) {
248 pc_lut_id += 50 + 9 - 7;
250 if (not(pc_lut_id < 61))
251 {
edm::LogError(
"L1T") <<
"pc_lut_id = " << pc_lut_id;
return; }
254 std::cout <<
"pc_station: " << pc_station <<
" pc_chamber: " << pc_chamber
255 <<
" fw_station: " << fw_station <<
" fw_cscid: " << fw_cscid
256 <<
" lut_id: " << pc_lut_id
257 <<
" ph_init: " <<
lut().
get_ph_init(fw_endcap, fw_sector, pc_lut_id)
258 <<
" ph_disp: " <<
lut().
get_ph_disp(fw_endcap, fw_sector, pc_lut_id)
259 <<
" th_init: " <<
lut().
get_th_init(fw_endcap, fw_sector, pc_lut_id)
260 <<
" th_disp: " <<
lut().
get_th_disp(fw_endcap, fw_sector, pc_lut_id)
269 int eighth_strip = 0;
276 bool bugStrip0BeforeFW48200 =
false;
277 if (bugStrip0BeforeFW48200 ==
false && fw_strip == 0 && clct_pat_corr_sign == -1)
281 eighth_strip = fw_strip << 2;
282 eighth_strip += clct_pat_corr_sign * (clct_pat_corr >> 1);
284 eighth_strip = fw_strip << 3;
285 eighth_strip += clct_pat_corr_sign * (clct_pat_corr >> 0);
287 if (not(bugStrip0BeforeFW48200 ==
true || eighth_strip >= 0))
288 {
edm::LogError(
"L1T") <<
"bugStrip0BeforeFW48200 = " << bugStrip0BeforeFW48200
289 <<
", eighth_strip = " << eighth_strip;
return; }
303 int ph_tmp = (eighth_strip * factor) >> 10;
304 int ph_tmp_sign = (ph_reverse == 0) ? 1 : -1;
307 fph = fph + ph_tmp_sign * ph_tmp;
310 ph_hit = (ph_hit >> 1) + ph_tmp_sign * (ph_tmp >> 5) + ph_coverage;
315 ph_hit_fixed = ph_hit_fixed + ((fph + (1<<4)) >> 5);
318 ph_hit = ph_hit_fixed;
325 zone_hit_fixed += ph_hit_fixed;
330 zone_hit = zone_hit_fixed;
332 if (not(0 <= fph && fph < 5000))
334 if (not(0 <= zone_hit && zone_hit < 192))
335 {
edm::LogError(
"L1T") <<
"zone_hit = " << zone_hit;
return; }
341 int pc_wire_id = (fw_wire & 0x7f);
342 int th_tmp =
lut().
get_th_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_id);
346 int pc_wire_strip_id = (((fw_wire >> 4) & 0x3) << 5) | ((eighth_strip >> 4) & 0x1f);
351 bool bugME11DupesBeforeFW47114 =
false;
352 if (bugME11DupesBeforeFW47114) {
353 if (pc_segment == 1) {
354 pc_wire_strip_id = (((fw_wire >> 4) & 0x3) << 5) | (0);
359 int th_corr =
lut().
get_th_corr_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_strip_id);
360 int th_corr_sign = (ph_reverse == 0) ? 1 : -1;
362 th_tmp = th_tmp + th_corr_sign * th_corr;
365 const int th_negative = 50;
366 const int th_coverage = 45;
367 if (th_tmp > th_negative || th_tmp < 0 || fw_wire == 0)
369 if (th_tmp > th_coverage)
370 th_tmp = th_coverage;
373 int pc_wire_strip_id = (((fw_wire >> 4) & 0x3) << 5) | ((eighth_strip >> 4) & 0x1f);
375 pc_wire_strip_id = (((fw_wire >> 4) & 0x3) << 5) | ((((eighth_strip*341)>>8) >> 4) & 0x1f);
376 int th_corr =
lut().
get_th_corr_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_strip_id);
378 th_tmp = th_tmp + th_corr;
381 const int th_coverage = 46;
384 if (th_tmp > th_coverage)
385 th_tmp = th_coverage;
393 if (not(0 <= th && th < 128))
395 th = (th == 0) ? 1 : th;
401 int phzvl =
get_phzvl(conv_hit, zone_code);
404 int fs_segment =
get_fs_segment(conv_hit, fw_station, fw_cscid, pc_segment);
406 int bt_station =
get_bt_station(conv_hit, fw_station, fw_cscid, pc_segment);
407 int bt_segment =
get_bt_segment(conv_hit, fw_station, fw_cscid, pc_segment);
435 int pc_sector,
int pc_station,
int pc_chamber,
int pc_segment,
442 int tp_region = tp_detId.
region();
443 int tp_endcap = (tp_region == -1) ? 2 : tp_region;
444 int tp_sector = tp_detId.
sector();
446 int tp_station = tp_detId.
station();
447 int tp_ring = tp_detId.
ring();
448 int tp_roll = tp_detId.
roll();
451 int tp_bx = tp_data.bx;
452 int tp_strip = ((tp_data.strip_low + tp_data.strip_hi) / 2);
453 int tp_valid = tp_data.valid;
455 const bool is_neighbor = (pc_station == 5);
460 conv_hit.
set_endcap ( (tp_endcap == 2) ? -1 : tp_endcap );
466 conv_hit.
set_chamber ( (tp_sector - 1)*6 + tp_subsector );
467 conv_hit.
set_sector ( tp_subsector > 2 ? tp_sector : ((tp_sector + 4) % 6) + 1 );
492 bool use_fullsim_coords =
true;
493 if (use_fullsim_coords) {
497 double glob_eta = gp.
eta();
505 if (not(0 <= fph && fph < 1250))
507 if (not(0 <= th && th < 32))
509 if (not(th != 0b11111))
513 th = (th == 0) ? 1 : th;
530 const bool is_neighbor = conv_hit.
Neighbor();
538 const int fw_station = (conv_hit.
Station() == 1) ? (is_neighbor ? 0 : pc_station) : conv_hit.
Station();
540 int fw_cscid = pc_chamber;
547 csc_nID = (pc_chamber < 3) ? (pc_chamber + 12) : ( ((pc_chamber - 1) % 2) + 9);
550 fw_cscid = csc_nID - 1;
553 int fph = conv_hit.
Phi_fp();
557 std::cout <<
"RPC hit pc_station: " << pc_station <<
" pc_chamber: " << pc_chamber
558 <<
" fw_station: " << fw_station <<
" fw_cscid: " << fw_cscid
559 <<
" tp_station: " << conv_hit.
Station() <<
" tp_ring: " << conv_hit.
Ring()
560 <<
" tp_sector: " << conv_hit.
Sector() <<
" tp_subsector: " << conv_hit.
Subsector()
561 <<
" fph: " << fph <<
" th: " << th
568 int zone_hit = ((fph + (1<<4)) >> 5);
573 int fs_segment =
get_fs_segment(conv_hit, fw_station, fw_cscid, pc_segment);
575 int bt_station =
get_bt_station(conv_hit, fw_station, fw_cscid, pc_segment);
576 int bt_segment =
get_bt_segment(conv_hit, fw_station, fw_cscid, pc_segment);
604 int pc_sector,
int pc_station,
int pc_chamber,
int pc_segment,
611 int tp_region = tp_detId.
region();
612 int tp_endcap = (tp_region == -1) ? 2 : tp_region;
613 int tp_station = tp_detId.
station();
614 int tp_ring = tp_detId.
ring();
615 int tp_roll = tp_detId.
roll();
617 int tp_chamber = tp_detId.
chamber();
619 int tp_bx = tp_data.bx;
620 int tp_strip = ((tp_data.pad_low + tp_data.pad_hi) / 2);
626 if( station > 1 && ring > 1 ) {
627 result = ((
static_cast<unsigned>(
chamber-3) & 0x7f) / 6) + 1;
630 result = (station != 1) ? ((static_cast<unsigned>(
chamber-2) & 0x1f) / 3) + 1 :
631 ((
static_cast<unsigned>(
chamber-3) & 0x7f) / 6) + 1;
633 return (result <= 6) ? result : 6;
664 int tp_sector = get_trigger_sector(tp_ring, tp_station, tp_chamber);
665 int tp_csc_ID = get_trigger_csc_ID(tp_ring, tp_station, tp_chamber);
669 int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber%6 > 2) ? 1 : 2);
671 const bool is_neighbor = (pc_station == 5);
673 int csc_nID = tp_csc_ID;
678 csc_nID = (pc_chamber < 3) ? (pc_chamber + 12) : ( ((pc_chamber - 1) % 2) + 9);
681 if (tp_station == 1) {
682 if (not(tp_subsector == 2))
683 {
edm::LogError(
"L1T") <<
"tp_subsector = " << tp_subsector;
return; }
690 conv_hit.
set_endcap ( (tp_endcap == 2) ? -1 : tp_endcap );
727 bool use_fullsim_coords =
true;
728 if (use_fullsim_coords) {
732 double glob_eta = gp.
eta();
738 if (not(0 <= fph && fph < 5000))
740 if (not(0 <= th && th < 128))
742 th = (th == 0) ? 1 : th;
759 const bool is_neighbor = conv_hit.
Neighbor();
767 const int fw_station = (conv_hit.
Station() == 1) ? (is_neighbor ? 0 : (conv_hit.
Subsector()-1)) : conv_hit.
Station();
768 const int fw_cscid = (conv_hit.
CSC_nID()-1);
770 int fph = conv_hit.
Phi_fp();
774 std::cout <<
"GEM hit pc_station: " << pc_station <<
" pc_chamber: " << pc_chamber
775 <<
" fw_station: " << fw_station <<
" fw_cscid: " << fw_cscid
776 <<
" tp_station: " << conv_hit.
Station() <<
" tp_ring: " << conv_hit.
Ring()
777 <<
" tp_sector: " << conv_hit.
Sector() <<
" tp_subsector: " << conv_hit.
Subsector()
778 <<
" fph: " << fph <<
" th: " << th
785 int zone_hit = ((fph + (1<<4)) >> 5);
790 int fs_segment =
get_fs_segment(conv_hit, fw_station, fw_cscid, pc_segment);
792 int bt_station =
get_bt_station(conv_hit, fw_station, fw_cscid, pc_segment);
793 int bt_segment =
get_bt_segment(conv_hit, fw_station, fw_cscid, pc_segment);
826 bool is_me13 = (is_csc && conv_hit.
Station() == 1 && conv_hit.
Ring() == 3);
830 if (zone_code_tmp & (1<<izone)) {
831 bool no_use_bnd1 = ((izone==0) || ((zone_code_tmp & (1<<(izone-1))) == 0) || is_me13);
832 bool no_use_bnd2 = (((zone_code_tmp & (1<<(izone+1))) == 0) || is_me13);
838 zone_code |= (1<<izone);
842 if (not(zone_code > 0))
843 {
edm::LogError(
"L1T") <<
"zone_code = " << zone_code;
return 0; }
852 if (conv_hit.
Ring() == 1 || conv_hit.
Ring() == 4) {
853 phzvl = (zone_code >> 0);
854 }
else if (conv_hit.
Ring() == 2) {
856 phzvl = (zone_code >> 1);
858 phzvl = (zone_code >> 2);
860 }
else if (conv_hit.
Ring() == 3) {
861 phzvl = (zone_code >> 3);
867 static const unsigned int zone_code_table[4][3] = {
868 {0b0011, 0b0100, 0b1000},
869 {0b0011, 0b1100, 0b1100},
870 {0b0001, 0b1110, 0b1110},
871 {0b0001, 0b0110, 0b0110}
874 static const unsigned int zone_code_table_new[4][3] = {
875 {0b0011, 0b0110, 0b1000},
876 {0b0011, 0b1110, 0b1110},
877 {0b0011, 0b1110, 0b1110},
878 {0b0001, 0b0110, 0b0110}
881 unsigned int istation = (conv_hit.
Station()-1);
882 unsigned int iring = (conv_hit.
Ring() == 4) ? 0 : (conv_hit.
Ring()-1);
883 if (not(istation < 4 && iring < 3))
884 {
edm::LogError(
"L1T") <<
"istation = " << istation <<
", iring = " << iring;
return 0; }
885 unsigned int zone_code =
useNewZones_ ? zone_code_table_new[istation][iring] : zone_code_table[istation][iring];
894 int fs_segment = pc_segment % 2;
903 const bool is_neighbor = conv_hit.
Neighbor();
904 if (fw_station <= 1) {
905 int n = fw_cscid % 3;
906 fs_chamber = is_neighbor ? 0 : ((fw_station == 0) ? 1+n : 4+n);
908 int n = (conv_hit.
Ring() == 1) ? fw_cscid : (fw_cscid-3);
909 fs_chamber = is_neighbor ? 0 : 1+
n;
912 if (not(fs_history == 0 && (0 <= fs_chamber && fs_chamber < 7) && (0 <= fs_segment && fs_segment < 2)))
913 {
edm::LogError(
"L1T") <<
"fs_history = " << fs_history <<
", fs_chamber = " << fs_chamber
914 <<
", fs_segment = " << fs_segment;
return 0; }
918 fs_segment = ((fs_history & 0x3)<<4) | ((fs_chamber & 0x7)<<1) | (fs_segment & 0x1);
923 int bt_station = fw_station;
932 int bt_segment = pc_segment % 2;
942 bt_chamber = fw_cscid+1;
943 if (fw_station == 0 && bt_chamber >= 13)
949 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)
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
void set_sync_err(int bits)
int chamber() const
Chamber id: it identifies a chamber in a ring it goes from 1 to 36.
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
int calc_theta_int(double theta, int endcap, int bits)
void set_theta_fp(int bits)
void set_endcap(int bits)
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)
void set_is_CSC(int bits)
void set_pattern(int bits)
void set_csc_ID(int bits)
void set_pc_chamber(int bits)
void set_strip_hi(int bits)
int station() const
Station id : the station is the pair of chambers at same disk.
void convert_csc_details(EMTFHit &conv_hit) const
l1t::EMTFHitCollection EMTFHitCollection
double calc_phi_glob_deg(double loc, int sector)
int region() const
Region id: 0 for Barrel Not in use, +/-1 For +/- Endcap.
void set_phi_loc(float val)
uint32_t get_th_disp(int fw_endcap, int fw_sector, int pc_lut_id) const
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)
int calc_phi_loc_int(double glob, int sector, 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
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)
void SetGEMDetId(const GEMDetId &id)
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)
void convert_rpc_details(EMTFHit &conv_hit) const
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
void set_fs_zone_code(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)
const GeometryTranslator * tp_geom_
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