CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
PrimitiveConversion Class Reference

#include <PrimitiveConversion.h>

Public Member Functions

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)
 
void convert_csc (int pc_sector, int pc_station, int pc_chamber, int pc_segment, const TriggerPrimitive &muon_primitive, EMTFHit &conv_hit) const
 
void convert_csc_details (EMTFHit &conv_hit) const
 
void convert_gem (int pc_sector, int pc_station, int pc_chamber, int pc_segment, const TriggerPrimitive &muon_primitive, EMTFHit &conv_hit) const
 
void convert_gem_details (EMTFHit &conv_hit) const
 
void convert_rpc (int pc_sector, int pc_station, int pc_chamber, int pc_segment, const TriggerPrimitive &muon_primitive, EMTFHit &conv_hit) const
 
void convert_rpc_details (EMTFHit &conv_hit, const bool use_cppf_lut) const
 
int get_bt_segment (const EMTFHit &conv_hit, int fw_station, int fw_cscid, int pc_segment) const
 
int get_bt_station (const EMTFHit &conv_hit, int fw_station, int fw_cscid, int pc_segment) const
 
int get_fs_segment (const EMTFHit &conv_hit, int fw_station, int fw_cscid, int pc_segment) const
 
int get_fs_zone_code (const EMTFHit &conv_hit) const
 
int get_phzvl (const EMTFHit &conv_hit, int zone_code) const
 
int get_zone_code (const EMTFHit &conv_hit, int th) const
 
bool is_valid_for_run2 (const EMTFHit &conv_hit) const
 
const SectorProcessorLUTlut () const
 
void process (const std::map< int, TriggerPrimitiveCollection > &selected_prim_map, EMTFHitCollection &conv_hits) const
 

Private Attributes

bool bugME11Dupes_
 
int bx_
 
int bxShiftCSC_
 
int bxShiftGEM_
 
int bxShiftRPC_
 
bool duplicateTheta_
 
int endcap_
 
bool fixME11Edges_
 
bool fixZonePhi_
 
const SectorProcessorLUTlut_
 
int sector_
 
const GeometryTranslatortp_geom_
 
bool useNewZones_
 
int verbose_
 
std::vector< int > zoneBoundaries_
 
int zoneOverlap_
 

Detailed Description

Definition at line 8 of file PrimitiveConversion.h.

Member Function Documentation

void PrimitiveConversion::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 
)

Definition at line 13 of file PrimitiveConversion.cc.

References bugME11Dupes_, l1GtPatternGenerator_cfi::bx, bx_, bxShiftCSC_, bxShiftGEM_, bxShiftRPC_, duplicateTheta_, makeMuonMisalignmentScenario::endcap, endcap_, fixME11Edges_, fixZonePhi_, lut(), lut_, sector_, tp_geom_, useNewZones_, verbose, verbose_, zoneBoundaries_, and zoneOverlap_.

Referenced by SectorProcessor::process_single_bx().

28  {
29  if (not(tp_geom != nullptr)) {
30  edm::LogError("L1T") << "tp_geom = " << tp_geom;
31  return;
32  }
33  if (not(lut != nullptr)) {
34  edm::LogError("L1T") << "lut = " << lut;
35  return;
36  }
37 
38  tp_geom_ = tp_geom;
39  lut_ = lut;
40 
41  verbose_ = verbose;
42  endcap_ = endcap; // 1 for ME+, 2 for ME-
43  sector_ = sector;
44  bx_ = bx;
45 
46  bxShiftCSC_ = bxShiftCSC;
47  bxShiftRPC_ = bxShiftRPC;
48  bxShiftGEM_ = bxShiftGEM;
49 
50  zoneBoundaries_ = zoneBoundaries;
51  zoneOverlap_ = zoneOverlap;
52  duplicateTheta_ = duplicateTheta;
53  fixZonePhi_ = fixZonePhi;
54  useNewZones_ = useNewZones;
55  fixME11Edges_ = fixME11Edges;
56  bugME11Dupes_ = bugME11Dupes;
57 }
const SectorProcessorLUT * lut_
static int verbose
std::vector< int > zoneBoundaries_
const SectorProcessorLUT & lut() const
const GeometryTranslator * tp_geom_
void PrimitiveConversion::convert_csc ( int  pc_sector,
int  pc_station,
int  pc_chamber,
int  pc_segment,
const TriggerPrimitive muon_primitive,
EMTFHit conv_hit 
) const

Definition at line 98 of file PrimitiveConversion.cc.

References bxShiftCSC_, CSCDetId::chamber(), convert_csc_details(), L1TMuon::TriggerPrimitive::detId(), CSCDetId::endcap(), endcap_, PV3DBase< T, PVType, FrameType >::eta(), L1TMuon::TriggerPrimitive::getCSCData(), L1TMuon::GeometryTranslator::getGlobalPoint(), runTauDisplay::gp, L1TMuon::TriggerPrimitive::kCSC, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), emtf::rad_to_deg(), CSCDetId::ring(), sector_, l1t::EMTFHit::set_alct_quality(), l1t::EMTFHit::set_bend(), l1t::EMTFHit::set_bx(), l1t::EMTFHit::set_chamber(), l1t::EMTFHit::set_clct_quality(), l1t::EMTFHit::set_csc_ID(), l1t::EMTFHit::set_csc_nID(), l1t::EMTFHit::set_endcap(), l1t::EMTFHit::set_eta_sim(), l1t::EMTFHit::set_is_CSC(), l1t::EMTFHit::set_is_GEM(), l1t::EMTFHit::set_is_RPC(), l1t::EMTFHit::set_neighbor(), l1t::EMTFHit::set_pattern(), l1t::EMTFHit::set_pc_chamber(), l1t::EMTFHit::set_pc_sector(), l1t::EMTFHit::set_pc_segment(), l1t::EMTFHit::set_pc_station(), l1t::EMTFHit::set_phi_sim(), l1t::EMTFHit::set_quality(), l1t::EMTFHit::set_rho_sim(), l1t::EMTFHit::set_ring(), l1t::EMTFHit::set_sector(), l1t::EMTFHit::set_sector_idx(), l1t::EMTFHit::set_station(), l1t::EMTFHit::set_strip(), l1t::EMTFHit::set_subsector(), l1t::EMTFHit::set_subsystem(), l1t::EMTFHit::set_sync_err(), l1t::EMTFHit::set_theta_sim(), l1t::EMTFHit::set_track_num(), l1t::EMTFHit::set_valid(), l1t::EMTFHit::set_wire(), l1t::EMTFHit::set_z_sim(), l1t::EMTFHit::SetCSCDetId(), CSCDetId::station(), PV3DBase< T, PVType, FrameType >::theta(), tp_geom_, CSCDetId::triggerSector(), Geom::Phi< T1, Range >::value(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by lut(), and process().

103  {
104  const CSCDetId& tp_detId = muon_primitive.detId<CSCDetId>();
105  const CSCData& tp_data = muon_primitive.getCSCData();
106 
107  int tp_endcap = tp_detId.endcap();
108  int tp_sector = tp_detId.triggerSector();
109  int tp_station = tp_detId.station();
110  int tp_ring = tp_detId.ring();
111  int tp_chamber = tp_detId.chamber();
112 
113  int tp_bx = tp_data.bx;
114  int tp_csc_ID = tp_data.cscID;
115 
116  // station 1 --> subsector 1 or 2
117  // station 2,3,4 --> subsector 0
118  int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber % 6 > 2) ? 1 : 2);
119 
120  const bool is_neighbor = (pc_station == 5);
121 
122  int csc_nID = tp_csc_ID; // modify csc_ID if coming from neighbor sector
123  if (is_neighbor) {
124  // station 1 has 3 neighbor chambers: 13,14,15 in rings 1,2,3
125  // (where are chambers 10,11,12 in station 1? they were used to label ME1/1a, but not anymore)
126  // station 2,3,4 have 2 neighbor chambers: 10,11 in rings 1,2
127  csc_nID = (pc_chamber < 3) ? (pc_chamber + 12) : (((pc_chamber - 1) % 2) + 9);
128  csc_nID += 1;
129 
130  if (tp_station == 1) { // neighbor ME1
131  if (not(tp_subsector == 2)) {
132  edm::LogError("L1T") << "tp_subsector = " << tp_subsector;
133  return;
134  }
135  }
136  }
137 
138  // Set properties
139  conv_hit.SetCSCDetId(tp_detId);
140 
141  conv_hit.set_endcap((tp_endcap == 2) ? -1 : tp_endcap);
142  conv_hit.set_station(tp_station);
143  conv_hit.set_ring(tp_ring);
144  //conv_hit.set_roll ( tp_roll );
145  conv_hit.set_chamber(tp_chamber);
146  conv_hit.set_sector(tp_sector);
147  conv_hit.set_subsector(tp_subsector);
148  conv_hit.set_csc_ID(tp_csc_ID);
149  conv_hit.set_csc_nID(csc_nID);
150  conv_hit.set_track_num(tp_data.trknmb);
151  conv_hit.set_sync_err(tp_data.syncErr);
152  //conv_hit.set_sector_RPC ( tp_sector );
153  //conv_hit.set_subsector_RPC ( tp_subsector );
154 
155  conv_hit.set_bx(tp_bx + bxShiftCSC_);
157  conv_hit.set_is_CSC(true);
158  conv_hit.set_is_RPC(false);
159  conv_hit.set_is_GEM(false);
160 
161  conv_hit.set_pc_sector(pc_sector);
162  conv_hit.set_pc_station(pc_station);
163  conv_hit.set_pc_chamber(pc_chamber);
164  conv_hit.set_pc_segment(pc_segment);
165 
166  conv_hit.set_valid(tp_data.valid);
167  conv_hit.set_strip(tp_data.strip);
168  //conv_hit.set_strip_low ( tp_data.strip_low );
169  //conv_hit.set_strip_hi ( tp_data.strip_hi );
170  conv_hit.set_wire(tp_data.keywire);
171  conv_hit.set_quality(tp_data.quality);
172  conv_hit.set_pattern(tp_data.pattern);
173  conv_hit.set_bend(tp_data.bend);
174  //conv_hit.set_time ( tp_data.time );
175  conv_hit.set_alct_quality(tp_data.alct_quality);
176  conv_hit.set_clct_quality(tp_data.clct_quality);
177 
178  conv_hit.set_neighbor(is_neighbor);
179  conv_hit.set_sector_idx((endcap_ == 1) ? sector_ - 1 : sector_ + 5);
180 
181  convert_csc_details(conv_hit);
182 
183  // Add coordinates from fullsim
184  {
185  const GlobalPoint& gp = tp_geom_->getGlobalPoint(muon_primitive);
186  double glob_phi = emtf::rad_to_deg(gp.phi().value());
187  double glob_theta = emtf::rad_to_deg(gp.theta());
188  double glob_eta = gp.eta();
189  double glob_rho = gp.perp();
190  double glob_z = gp.z();
191 
192  conv_hit.set_phi_sim(glob_phi);
193  conv_hit.set_theta_sim(glob_theta);
194  conv_hit.set_eta_sim(glob_eta);
195  conv_hit.set_rho_sim(glob_rho);
196  conv_hit.set_z_sim(glob_z);
197  }
198 }
int chamber() const
Definition: CSCDetId.h:62
void set_theta_sim(float val)
Definition: EMTFHit.h:177
void set_is_GEM(int bits)
Definition: EMTFHit.h:185
void set_neighbor(int bits)
Definition: EMTFHit.h:142
void set_rho_sim(float val)
Definition: EMTFHit.h:179
void set_csc_nID(int bits)
Definition: EMTFHit.h:140
void set_pc_station(int bits)
Definition: EMTFHit.h:145
void set_phi_sim(float val)
Definition: EMTFHit.h:176
T perp() const
Definition: PV3DBase.h:69
void set_station(int bits)
Definition: EMTFHit.h:131
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
void set_eta_sim(float val)
Definition: EMTFHit.h:178
void set_sector_idx(int bits)
Definition: EMTFHit.h:135
T1 value() const
Explicit access to value in case implicit conversion not OK.
Definition: Phi.h:75
void set_sync_err(int bits)
Definition: EMTFHit.h:157
const CSCData getCSCData() const
void set_endcap(int bits)
Definition: EMTFHit.h:130
void set_ring(int bits)
Definition: EMTFHit.h:132
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
int endcap() const
Definition: CSCDetId.h:85
void set_is_CSC(int bits)
Definition: EMTFHit.h:183
void set_pattern(int bits)
Definition: EMTFHit.h:154
T z() const
Definition: PV3DBase.h:61
void set_csc_ID(int bits)
Definition: EMTFHit.h:139
void set_pc_chamber(int bits)
Definition: EMTFHit.h:146
void set_wire(int bits)
Definition: EMTFHit.h:148
void convert_csc_details(EMTFHit &conv_hit) const
void set_pc_segment(int bits)
Definition: EMTFHit.h:147
void set_is_RPC(int bits)
Definition: EMTFHit.h:184
void SetCSCDetId(const CSCDetId &id)
Definition: EMTFHit.h:113
int ring() const
Definition: CSCDetId.h:68
void set_sector(int bits)
Definition: EMTFHit.h:133
void set_valid(int bits)
Definition: EMTFHit.h:156
void set_z_sim(float val)
Definition: EMTFHit.h:180
void set_strip(int bits)
Definition: EMTFHit.h:149
int triggerSector() const
Definition: CSCDetId.cc:3
void set_subsystem(int bits)
Definition: EMTFHit.h:186
T eta() const
Definition: PV3DBase.h:73
void set_track_num(int bits)
Definition: EMTFHit.h:152
void set_bx(int bits)
Definition: EMTFHit.h:159
int station() const
Definition: CSCDetId.h:79
double rad_to_deg(double rad)
Definition: TrackTools.h:62
void set_clct_quality(int bits)
Definition: EMTFHit.h:182
void set_quality(int bits)
Definition: EMTFHit.h:153
void set_chamber(int bits)
Definition: EMTFHit.h:138
void set_subsector(int bits)
Definition: EMTFHit.h:136
void set_bend(int bits)
Definition: EMTFHit.h:155
void set_alct_quality(int bits)
Definition: EMTFHit.h:181
const GeometryTranslator * tp_geom_
void set_pc_sector(int bits)
Definition: EMTFHit.h:144
GlobalPoint getGlobalPoint(const TriggerPrimitive &) const
void PrimitiveConversion::convert_csc_details ( EMTFHit conv_hit) const

Definition at line 200 of file PrimitiveConversion.cc.

References bugME11Dupes_, emtf::calc_eta_from_theta_deg(), emtf::calc_phi_glob_deg(), emtf::calc_phi_loc_deg(), emtf::calc_theta_deg_from_int(), gather_cfg::cout, l1t::EMTFHit::CSC_nID(), l1t::EMTFHit::Endcap(), endcap_, DQMScaleToClient_cfi::factor, fixME11Edges_, fixZonePhi_, get_bt_segment(), get_bt_station(), get_fs_segment(), get_fs_zone_code(), SectorProcessorLUT::get_ph_disp(), SectorProcessorLUT::get_ph_init(), SectorProcessorLUT::get_ph_init_hard(), SectorProcessorLUT::get_ph_patt_corr(), SectorProcessorLUT::get_ph_patt_corr_sign(), SectorProcessorLUT::get_ph_zone_offset(), get_phzvl(), SectorProcessorLUT::get_th_corr_lut(), SectorProcessorLUT::get_th_disp(), SectorProcessorLUT::get_th_init(), SectorProcessorLUT::get_th_lut(), get_zone_code(), lut(), l1t::EMTFHit::Neighbor(), l1t::EMTFHit::Pattern(), l1t::EMTFHit::PC_chamber(), l1t::EMTFHit::PC_sector(), l1t::EMTFHit::PC_segment(), l1t::EMTFHit::PC_station(), l1t::EMTFHit::Phi_loc(), l1t::EMTFHit::Ring(), sector_, l1t::EMTFHit::set_bt_segment(), l1t::EMTFHit::set_bt_station(), l1t::EMTFHit::set_eta(), l1t::EMTFHit::set_fs_segment(), l1t::EMTFHit::set_fs_zone_code(), l1t::EMTFHit::set_ph_hit(), l1t::EMTFHit::set_phi_fp(), l1t::EMTFHit::set_phi_glob(), l1t::EMTFHit::set_phi_loc(), l1t::EMTFHit::set_phzvl(), l1t::EMTFHit::set_theta(), l1t::EMTFHit::set_theta_fp(), l1t::EMTFHit::set_zone_code(), l1t::EMTFHit::set_zone_hit(), l1t::EMTFHit::Station(), l1t::EMTFHit::Strip(), l1t::EMTFHit::Subsector(), l1t::EMTFHit::Theta(), verbose_, and l1t::EMTFHit::Wire().

Referenced by convert_csc(), and lut().

200  {
201  const bool is_neighbor = conv_hit.Neighbor();
202 
203  // Defined as in firmware
204  // endcap : 0-1 for ME+,ME-
205  // sector : 0-5
206  // station: 0-4 for st1 sub1 or st1 sub2 from neighbor, st1 sub2, st2, st3, st4
207  // cscid : 0-14 (excluding 11), including neighbors
208  const int fw_endcap = (endcap_ - 1);
209  const int fw_sector = (sector_ - 1);
210  const int fw_station =
211  (conv_hit.Station() == 1) ? (is_neighbor ? 0 : (conv_hit.Subsector() - 1)) : conv_hit.Station();
212  const int fw_cscid = (conv_hit.CSC_nID() - 1);
213  const int fw_strip = conv_hit.Strip(); // it is half-strip, despite the name
214  const int fw_wire = conv_hit.Wire(); // it is wiregroup, despite the name
215 
216  // Primitive converter unit
217  // station: 0-5 for st1 sub1, st1 sub2, st2, st3, st4, neigh all st*
218  // chamber: 0-8
219  const int pc_station = conv_hit.PC_station();
220  const int pc_chamber = conv_hit.PC_chamber();
221  const int pc_segment = conv_hit.PC_segment();
222 
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);
226 
227  // Is this chamber mounted in reverse direction?
228  // (i.e., phi vs. strip number is reversed)
229  bool ph_reverse = false;
230  if ((fw_endcap == 0 && fw_station >= 3) || (fw_endcap == 1 && fw_station < 3))
231  ph_reverse = true;
232 
233  // Chamber coverage if phi_reverse = true
234  int ph_coverage = 0; // Offset for coordinate conversion
235  if (ph_reverse) {
236  if (fw_station <= 1 && ((fw_cscid >= 6 && fw_cscid <= 8) || fw_cscid == 14)) // ME1/3
237  ph_coverage = 15;
238  else if (fw_station >= 2 && (fw_cscid <= 2 || fw_cscid == 9)) // ME2,3,4/1
239  ph_coverage = 40;
240  else // all others
241  ph_coverage = 20;
242  }
243 
244  // Is this 10-deg or 20-deg chamber?
245  bool is_10degree = false;
246  if ((fw_station <= 1) || // ME1
247  (fw_station >= 2 && ((fw_cscid >= 3 && fw_cscid <= 8) || fw_cscid == 10)) // ME2,3,4/2
248  ) {
249  is_10degree = true;
250  }
251 
252  // LUT index
253  // There are 54 CSC chambers including the neighbors in a sector, but 61 LUT indices
254  // This comes from dividing the 6 chambers + 1 neighbor in ME1/1 into ME1/1a and ME1/1b
255  int pc_lut_id = pc_chamber;
256  if (pc_station == 0) { // ME1 sub 1: 0 - 11
257  pc_lut_id = is_me11a ? pc_lut_id + 9 : pc_lut_id;
258  } else if (pc_station == 1) { // ME1 sub 2: 16 - 27
259  pc_lut_id += 16;
260  pc_lut_id = is_me11a ? pc_lut_id + 9 : pc_lut_id;
261  } else if (pc_station == 2) { // ME2: 28 - 36
262  pc_lut_id += 28;
263  } else if (pc_station == 3) { // ME3: 39 - 47
264  pc_lut_id += 39;
265  } else if (pc_station == 4) { // ME4 : 50 - 58
266  pc_lut_id += 50;
267  } else if (pc_station == 5 && pc_chamber < 3) { // neighbor ME1: 12 - 15
268  pc_lut_id = is_me11a ? pc_lut_id + 15 : pc_lut_id + 12;
269  } else if (pc_station == 5 && pc_chamber < 5) { // neighbor ME2: 37 - 38
270  pc_lut_id += 28 + 9 - 3;
271  } else if (pc_station == 5 && pc_chamber < 7) { // neighbor ME3: 48 - 49
272  pc_lut_id += 39 + 9 - 5;
273  } else if (pc_station == 5 && pc_chamber < 9) { // neighbor ME4: 59 - 60
274  pc_lut_id += 50 + 9 - 7;
275  }
276  if (not(pc_lut_id < 61)) {
277  edm::LogError("L1T") << "pc_lut_id = " << pc_lut_id;
278  return;
279  }
280 
281  if (verbose_ > 1) { // debug
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)
288  << " ph_init_hard: " << lut().get_ph_init_hard(fw_station, fw_cscid) << std::endl;
289  }
290 
291  // ___________________________________________________________________________
292  // phi conversion
293 
294  // Convert half-strip into 1/8-strip
295  int eighth_strip = 0;
296 
297  // Apply phi correction from CLCT pattern number (from src/SectorProcessorLUT.cc)
298  int clct_pat_corr = lut().get_ph_patt_corr(conv_hit.Pattern());
299  int clct_pat_corr_sign = (lut().get_ph_patt_corr_sign(conv_hit.Pattern()) == 0) ? 1 : -1;
300 
301  // At strip number 0, protect against negative correction
302  bool bugStrip0BeforeFW48200 = false;
303  if (bugStrip0BeforeFW48200 == false && fw_strip == 0 && clct_pat_corr_sign == -1)
304  clct_pat_corr = 0;
305 
306  if (is_10degree) {
307  eighth_strip = fw_strip << 2; // full precision, uses only 2 bits of pattern correction
308  eighth_strip += clct_pat_corr_sign * (clct_pat_corr >> 1);
309  } else {
310  eighth_strip = fw_strip << 3; // multiply by 2, uses all 3 bits of pattern correction
311  eighth_strip += clct_pat_corr_sign * (clct_pat_corr >> 0);
312  }
313  if (not(bugStrip0BeforeFW48200 == true || eighth_strip >= 0)) {
314  edm::LogError("L1T") << "bugStrip0BeforeFW48200 = " << bugStrip0BeforeFW48200
315  << ", eighth_strip = " << eighth_strip;
316  return;
317  }
318 
319  // Multiplicative factor for eighth_strip
320  int factor = 1024;
321  if (is_me11a)
322  factor = 1707; // ME1/1a
323  else if (is_me11b)
324  factor = 1301; // ME1/1b
325  else if (is_me13)
326  factor = 947; // ME1/3
327 
328  // ph_tmp is full-precision phi, but local to chamber (counted from strip 0)
329  // full phi precision: ( 1/60) deg (1/8-strip)
330  // zone phi precision: (32/60) deg (4-strip, 32 times coarser than full phi precision)
331  int ph_tmp = (eighth_strip * factor) >> 10;
332  int ph_tmp_sign = (ph_reverse == 0) ? 1 : -1;
333 
334  int fph = lut().get_ph_init(fw_endcap, fw_sector, pc_lut_id);
335  fph = fph + ph_tmp_sign * ph_tmp;
336 
337  int ph_hit = lut().get_ph_disp(fw_endcap, fw_sector, pc_lut_id);
338  ph_hit = (ph_hit >> 1) + ph_tmp_sign * (ph_tmp >> 5) + ph_coverage;
339 
340  // Full phi +16 to put the rounded value into the middle of error range
341  // Divide full phi by 32, subtract chamber start
342  int ph_hit_fixed = -1 * lut().get_ph_init_hard(fw_station, fw_cscid);
343  ph_hit_fixed = ph_hit_fixed + ((fph + (1 << 4)) >> 5);
344 
345  if (fixZonePhi_)
346  ph_hit = ph_hit_fixed;
347 
348  // Zone phi
349  int zone_hit = lut().get_ph_zone_offset(pc_station, pc_chamber);
350  zone_hit += ph_hit;
351 
352  int zone_hit_fixed = lut().get_ph_init_hard(fw_station, fw_cscid);
353  zone_hit_fixed += ph_hit_fixed;
354  // Since ph_hit_fixed = ((fph + (1<<4)) >> 5) - lut().get_ph_init_hard(), the following is equivalent:
355  //zone_hit_fixed = ((fph + (1<<4)) >> 5);
356 
357  if (fixZonePhi_)
358  zone_hit = zone_hit_fixed;
359 
360  if (not(0 <= fph && fph < 5000)) {
361  edm::LogError("L1T") << "fph = " << fph;
362  return;
363  }
364  if (not(0 <= zone_hit && zone_hit < 192)) {
365  edm::LogError("L1T") << "zone_hit = " << zone_hit;
366  return;
367  }
368 
369  // ___________________________________________________________________________
370  // theta conversion
371 
372  // th_tmp is theta local to chamber
373  int pc_wire_id = (fw_wire & 0x7f); // 7-bit
374  int th_tmp = lut().get_th_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_id);
375 
376  // For ME1/1 with tilted wires, add theta correction as a function of (wire,strip) index
377  if (!fixME11Edges_ && (is_me11a || is_me11b)) {
378  int pc_wire_strip_id =
379  (((fw_wire >> 4) & 0x3) << 5) | ((eighth_strip >> 4) & 0x1f); // 2-bit from wire, 5-bit from 2-strip
380 
381  // Only affect runs before FW changeset 47114 is applied
382  // e.g. Run 281707 and earlier
383  if (bugME11Dupes_) {
384  bool bugME11DupesBeforeFW47114 = false;
385  if (bugME11DupesBeforeFW47114) {
386  if (pc_segment == 1) {
387  pc_wire_strip_id = (((fw_wire >> 4) & 0x3) << 5) | (0); // 2-bit from wire, 5-bit from 2-strip
388  }
389  }
390  }
391 
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;
394 
395  th_tmp = th_tmp + th_corr_sign * th_corr;
396 
397  // Check that correction did not make invalid value outside chamber coverage
398  const int th_negative = 50;
399  const int th_coverage = 45;
400  if (th_tmp > th_negative || th_tmp < 0 || fw_wire == 0)
401  th_tmp = 0; // limit at the bottom
402  if (th_tmp > th_coverage)
403  th_tmp = th_coverage; // limit at the top
404 
405  } else if (fixME11Edges_ && (is_me11a || is_me11b)) {
406  int pc_wire_strip_id =
407  (((fw_wire >> 4) & 0x3) << 5) | ((eighth_strip >> 4) & 0x1f); // 2-bit from wire, 5-bit from 2-strip
408  if (is_me11a)
409  pc_wire_strip_id = (((fw_wire >> 4) & 0x3) << 5) | ((((eighth_strip * 341) >> 8) >> 4) &
410  0x1f); // correct for ME1/1a strip number (341/256 =~ 1.333)
411  int th_corr = lut().get_th_corr_lut(fw_endcap, fw_sector, pc_lut_id, pc_wire_strip_id);
412 
413  th_tmp = th_tmp + th_corr;
414 
415  // Check that correction did not make invalid value outside chamber coverage
416  const int th_coverage = 46; // max coverage for front chamber is 47, max coverage for rear chamber is 45
417  if (fw_wire == 0)
418  th_tmp = 0; // limit at the bottom
419  if (th_tmp > th_coverage)
420  th_tmp = th_coverage; // limit at the top
421  }
422 
423  // theta precision: (36.5/128) deg
424  // theta starts at 8.5 deg: {1, 127} <--> {8.785, 44.715}
425  int th = lut().get_th_init(fw_endcap, fw_sector, pc_lut_id);
426  th = th + th_tmp;
427 
428  if (not(0 <= th && th < 128)) {
429  edm::LogError("L1T") << "th = " << th;
430  return;
431  }
432  th = (th == 0) ? 1 : th; // protect against invalid value
433 
434  // ___________________________________________________________________________
435  // Zone codes and other segment IDs
436 
437  //int zone_hit = ((fph + (1<<4)) >> 5);
438  int zone_code = get_zone_code(conv_hit, th);
439  int phzvl = get_phzvl(conv_hit, zone_code);
440 
441  int fs_zone_code = get_fs_zone_code(conv_hit);
442  int fs_segment = get_fs_segment(conv_hit, fw_station, fw_cscid, pc_segment);
443 
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);
446 
447  // ___________________________________________________________________________
448  // Output
449 
450  conv_hit.set_phi_fp(fph); // Full-precision integer phi
451  conv_hit.set_theta_fp(th); // Full-precision integer theta
452  conv_hit.set_phzvl(phzvl); // Local zone word: (1*low) + (2*mid) + (4*low) - used in FW debugging
453  conv_hit.set_ph_hit(ph_hit); // Intermediate quantity in phi calculation - used in FW debugging
454  conv_hit.set_zone_hit(zone_hit); // Phi value for building patterns (0.53333 deg precision)
455  conv_hit.set_zone_code(zone_code); // Full zone word: 1*(zone 0) + 2*(zone 1) + 4*(zone 2) + 8*(zone 3)
456 
457  conv_hit.set_fs_segment(fs_segment); // Segment number used in primitive matching
458  conv_hit.set_fs_zone_code(fs_zone_code); // Zone word used in primitive matching
459 
460  conv_hit.set_bt_station(bt_station);
461  conv_hit.set_bt_segment(bt_segment);
462 
463  conv_hit.set_phi_loc(emtf::calc_phi_loc_deg(fph));
464  conv_hit.set_phi_glob(emtf::calc_phi_glob_deg(conv_hit.Phi_loc(), conv_hit.PC_sector()));
466  conv_hit.set_eta(emtf::calc_eta_from_theta_deg(conv_hit.Theta(), conv_hit.Endcap()));
467 }
void set_phi_glob(float val)
Definition: EMTFHit.h:172
int get_bt_station(const EMTFHit &conv_hit, int fw_station, int fw_cscid, int pc_segment) const
float Phi_loc() const
Definition: EMTFHit.h:229
int Strip() const
Definition: EMTFHit.h:207
int get_zone_code(const EMTFHit &conv_hit, int th) const
int CSC_nID() const
Definition: EMTFHit.h:198
void set_ph_hit(int bits)
Definition: EMTFHit.h:164
void set_theta(float val)
Definition: EMTFHit.h:173
float Theta() const
Definition: EMTFHit.h:231
void set_bt_station(int bits)
Definition: EMTFHit.h:169
double calc_phi_loc_deg(int bits)
Definition: TrackTools.h:165
uint32_t get_ph_patt_corr_sign(int pattern) 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)
Definition: EMTFHit.h:162
int PC_sector() const
Definition: EMTFHit.h:202
int Wire() const
Definition: EMTFHit.h:206
uint32_t get_th_init(int fw_endcap, int fw_sector, int pc_lut_id) const
int Subsector() const
Definition: EMTFHit.h:194
int PC_station() const
Definition: EMTFHit.h:203
int get_fs_segment(const EMTFHit &conv_hit, int fw_station, int fw_cscid, int pc_segment) const
double calc_theta_deg_from_int(int theta_int)
Definition: TrackTools.h:117
void set_phzvl(int bits)
Definition: EMTFHit.h:163
void set_bt_segment(int bits)
Definition: EMTFHit.h:170
int PC_segment() const
Definition: EMTFHit.h:205
int Ring() const
Definition: EMTFHit.h:190
double calc_phi_glob_deg(double loc, int sector)
Definition: TrackTools.h:155
void set_phi_loc(float val)
Definition: EMTFHit.h:171
uint32_t get_th_disp(int fw_endcap, int fw_sector, int pc_lut_id) const
int PC_chamber() const
Definition: EMTFHit.h:204
uint32_t get_ph_disp(int fw_endcap, int fw_sector, int pc_lut_id) const
void set_fs_segment(int bits)
Definition: EMTFHit.h:167
int Station() const
Definition: EMTFHit.h:189
double calc_eta_from_theta_deg(double theta_deg, int endcap)
Definition: TrackTools.h:102
uint32_t get_ph_zone_offset(int pc_station, int pc_chamber) const
void set_zone_code(int bits)
Definition: EMTFHit.h:166
uint32_t get_ph_patt_corr(int pattern) const
int Pattern() const
Definition: EMTFHit.h:212
void set_zone_hit(int bits)
Definition: EMTFHit.h:165
int Endcap() const
Definition: EMTFHit.h:188
uint32_t get_th_lut(int fw_endcap, int fw_sector, int pc_lut_id, int pc_wire_id) 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)
Definition: EMTFHit.h:168
uint32_t get_ph_init(int fw_endcap, int fw_sector, int pc_lut_id) const
int Neighbor() const
Definition: EMTFHit.h:200
uint32_t get_th_corr_lut(int fw_endcap, int fw_sector, int pc_lut_id, int pc_wire_strip_id) const
void set_phi_fp(int bits)
Definition: EMTFHit.h:161
void set_eta(float val)
Definition: EMTFHit.h:174
void PrimitiveConversion::convert_gem ( int  pc_sector,
int  pc_station,
int  pc_chamber,
int  pc_segment,
const TriggerPrimitive muon_primitive,
EMTFHit conv_hit 
) const

Definition at line 713 of file PrimitiveConversion.cc.

References L1TMuon::TriggerPrimitive::GEMData::bend, L1TMuon::TriggerPrimitive::GEMData::bx, bxShiftGEM_, emtf::calc_phi_loc_int(), emtf::calc_theta_int(), EMTFGEMDetId::chamber(), relativeConstraints::chamber, emtf::construct_EMTFGEMDetId(), convert_gem_details(), l1t::EMTFHit::Endcap(), endcap_, PV3DBase< T, PVType, FrameType >::eta(), L1TMuon::TriggerPrimitive::getGEMData(), L1TMuon::GeometryTranslator::getGlobalPoint(), runTauDisplay::gp, L1TMuon::TriggerPrimitive::kGEM, L1TMuon::TriggerPrimitive::GEMData::pad_hi, L1TMuon::TriggerPrimitive::GEMData::pad_low, l1t::EMTFHit::PC_sector(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), emtf::rad_to_deg(), EMTFGEMDetId::region(), mps_fire::result, EMTFGEMDetId::ring(), relativeConstraints::ring, EMTFGEMDetId::roll(), sector_, l1t::EMTFHit::set_bend(), l1t::EMTFHit::set_bx(), l1t::EMTFHit::set_chamber(), l1t::EMTFHit::set_csc_ID(), l1t::EMTFHit::set_csc_nID(), l1t::EMTFHit::set_endcap(), l1t::EMTFHit::set_eta_sim(), l1t::EMTFHit::set_is_CSC(), l1t::EMTFHit::set_is_GEM(), l1t::EMTFHit::set_is_RPC(), l1t::EMTFHit::set_neighbor(), l1t::EMTFHit::set_pattern(), l1t::EMTFHit::set_pc_chamber(), l1t::EMTFHit::set_pc_sector(), l1t::EMTFHit::set_pc_segment(), l1t::EMTFHit::set_pc_station(), l1t::EMTFHit::set_phi_fp(), l1t::EMTFHit::set_phi_sim(), l1t::EMTFHit::set_rho_sim(), l1t::EMTFHit::set_ring(), l1t::EMTFHit::set_roll(), l1t::EMTFHit::set_sector(), l1t::EMTFHit::set_sector_idx(), l1t::EMTFHit::set_station(), l1t::EMTFHit::set_strip(), l1t::EMTFHit::set_strip_hi(), l1t::EMTFHit::set_strip_low(), l1t::EMTFHit::set_subsector(), l1t::EMTFHit::set_subsystem(), l1t::EMTFHit::set_theta_fp(), l1t::EMTFHit::set_theta_sim(), l1t::EMTFHit::set_valid(), l1t::EMTFHit::set_z_sim(), EMTFGEMDetId::station(), relativeConstraints::station, PV3DBase< T, PVType, FrameType >::theta(), tp_geom_, Geom::Phi< T1, Range >::value(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by lut(), and process().

718  {
719  const EMTFGEMDetId& tp_detId = emtf::construct_EMTFGEMDetId(muon_primitive);
720  const GEMData& tp_data = muon_primitive.getGEMData();
721 
722  int tp_region = tp_detId.region(); // 0 for Barrel, +/-1 for +/- Endcap
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();
727  //int tp_layer = tp_detId.layer();
728  int tp_chamber = tp_detId.chamber();
729 
730  int tp_bx = tp_data.bx;
731  int tp_strip = ((tp_data.pad_low + tp_data.pad_hi) / 2); // in full-strip unit
732 
733  // Use CSC trigger sector definitions
734  // Code copied from DataFormats/MuonDetId/src/CSCDetId.cc
735  auto get_trigger_sector = [](int ring, int station, int chamber) {
736  int result = 0;
737  if (station > 1 && ring > 1) {
738  result = ((static_cast<unsigned>(chamber - 3) & 0x7f) / 6) + 1; // ch 3-8->1, 9-14->2, ... 1,2 -> 6
739  } else {
740  result = (station != 1) ? ((static_cast<unsigned>(chamber - 2) & 0x1f) / 3) + 1 : // ch 2-4-> 1, 5-7->2, ...
741  ((static_cast<unsigned>(chamber - 3) & 0x7f) / 6) + 1;
742  }
743  return (result <= 6) ? result
744  : 6; // max sector is 6, some calculations give a value greater than six but this is expected.
745  };
746 
747  // Use CSC trigger "CSC ID" definitions
748  // Code copied from DataFormats/MuonDetId/src/CSCDetId.cc
749  auto get_trigger_csc_ID = [](int ring, int station, int chamber) {
750  int result = 0;
751  if (station == 1) {
752  result = (chamber) % 3 + 1; // 1,2,3
753  switch (ring) {
754  case 1:
755  break;
756  case 2:
757  result += 3; // 4,5,6
758  break;
759  case 3:
760  result += 6; // 7,8,9
761  break;
762  }
763  } else {
764  if (ring == 1) {
765  result = (chamber + 1) % 3 + 1; // 1,2,3
766  } else {
767  result = (chamber + 3) % 6 + 4; // 4,5,6,7,8,9
768  }
769  }
770  return result;
771  };
772 
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);
775 
776  // station 1 --> subsector 1 or 2
777  // station 2,3,4 --> subsector 0
778  int tp_subsector = (tp_station != 1) ? 0 : ((tp_chamber % 6 > 2) ? 1 : 2);
779 
780  const bool is_neighbor = (pc_station == 5);
781 
782  int csc_nID = tp_csc_ID; // modify csc_ID if coming from neighbor sector
783  if (is_neighbor) {
784  // station 1 has 3 neighbor chambers: 13,14,15 in rings 1,2,3
785  // (where are chambers 10,11,12 in station 1? they were used to label ME1/1a, but not anymore)
786  // station 2,3,4 have 2 neighbor chambers: 10,11 in rings 1,2
787  csc_nID = (pc_chamber < 3) ? (pc_chamber + 12) : (((pc_chamber - 1) % 2) + 9);
788  csc_nID += 1;
789 
790  if (tp_station == 1) { // neighbor ME1
791  if (not(tp_subsector == 2)) {
792  edm::LogError("L1T") << "tp_subsector = " << tp_subsector;
793  return;
794  }
795  }
796  }
797 
798  // Set properties
799  //conv_hit.SetGEMDetId ( tp_detId ); // Temporarily disable, caused compile error - AWB 12.04.2018
800 
801  conv_hit.set_endcap((tp_endcap == 2) ? -1 : tp_endcap);
802  conv_hit.set_station(tp_station);
803  conv_hit.set_ring(tp_ring);
804  conv_hit.set_roll(tp_roll);
805  conv_hit.set_chamber(tp_chamber);
806  conv_hit.set_sector(tp_sector);
807  conv_hit.set_subsector(tp_subsector);
808  conv_hit.set_csc_ID(tp_csc_ID);
809  conv_hit.set_csc_nID(csc_nID);
810  //conv_hit.set_track_num ( tp_data.trknmb );
811  //conv_hit.set_sync_err ( tp_data.syncErr );
812  //conv_hit.set_sector_RPC ( tp_sector );
813  //conv_hit.set_subsector_RPC ( tp_subsector );
814 
815  conv_hit.set_bx(tp_bx + bxShiftGEM_);
817  conv_hit.set_is_CSC(false);
818  conv_hit.set_is_RPC(false);
819  conv_hit.set_is_GEM(true);
820 
821  conv_hit.set_pc_sector(pc_sector);
822  conv_hit.set_pc_station(pc_station);
823  conv_hit.set_pc_chamber(pc_chamber);
824  conv_hit.set_pc_segment(pc_segment);
825 
826  conv_hit.set_valid(true);
827  conv_hit.set_strip(tp_strip);
828  conv_hit.set_strip_low(tp_data.pad_low);
829  conv_hit.set_strip_hi(tp_data.pad_hi);
830  //conv_hit.set_wire ( tp_data.keywire );
831  //conv_hit.set_quality ( tp_data.quality );
832  conv_hit.set_pattern(1); // In firmware, this marks GEM stub (unconfirmed!)
833  conv_hit.set_bend(tp_data.bend);
834  //conv_hit.set_time ( tp_data.time );
835  //conv_hit.set_alct_quality ( tp_data.alct_quality );
836  //conv_hit.set_clct_quality ( tp_data.clct_quality );
837 
838  conv_hit.set_neighbor(is_neighbor);
839  conv_hit.set_sector_idx((endcap_ == 1) ? sector_ - 1 : sector_ + 5);
840 
841  // Get coordinates from fullsim since LUTs do not exist yet
842  bool use_fullsim_coords = true;
843  if (use_fullsim_coords) {
844  const GlobalPoint& gp = tp_geom_->getGlobalPoint(muon_primitive);
845  double glob_phi = emtf::rad_to_deg(gp.phi().value());
846  double glob_theta = emtf::rad_to_deg(gp.theta());
847  double glob_eta = gp.eta();
848  double glob_rho = gp.perp();
849  double glob_z = gp.z();
850 
851  // Use the CSC precision (unconfirmed!)
852  int fph = emtf::calc_phi_loc_int(glob_phi, conv_hit.PC_sector());
853  int th = emtf::calc_theta_int(glob_theta, conv_hit.Endcap());
854 
855  if (not(0 <= fph && fph < 5000)) {
856  edm::LogError("L1T") << "fph = " << fph;
857  return;
858  }
859  if (not(0 <= th && th < 128)) {
860  edm::LogError("L1T") << "th = " << th;
861  return;
862  }
863  th = (th == 0) ? 1 : th; // protect against invalid value
864 
865  // _________________________________________________________________________
866  // Output
867 
868  conv_hit.set_phi_sim(glob_phi);
869  conv_hit.set_theta_sim(glob_theta);
870  conv_hit.set_eta_sim(glob_eta);
871  conv_hit.set_rho_sim(glob_rho);
872  conv_hit.set_z_sim(glob_z);
873 
874  conv_hit.set_phi_fp(fph); // Full-precision integer phi
875  conv_hit.set_theta_fp(th); // Full-precision integer theta
876  }
877 
878  convert_gem_details(conv_hit);
879 }
void set_theta_sim(float val)
Definition: EMTFHit.h:177
void set_is_GEM(int bits)
Definition: EMTFHit.h:185
void set_neighbor(int bits)
Definition: EMTFHit.h:142
void set_rho_sim(float val)
Definition: EMTFHit.h:179
void set_csc_nID(int bits)
Definition: EMTFHit.h:140
void set_pc_station(int bits)
Definition: EMTFHit.h:145
void set_phi_sim(float val)
Definition: EMTFHit.h:176
T perp() const
Definition: PV3DBase.h:69
void convert_gem_details(EMTFHit &conv_hit) const
const GEMData getGEMData() const
void set_station(int bits)
Definition: EMTFHit.h:131
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
void set_eta_sim(float val)
Definition: EMTFHit.h:178
void set_sector_idx(int bits)
Definition: EMTFHit.h:135
T1 value() const
Explicit access to value in case implicit conversion not OK.
Definition: Phi.h:75
int calc_phi_loc_int(double glob, int sector)
Definition: TrackTools.h:190
void set_theta_fp(int bits)
Definition: EMTFHit.h:162
void set_endcap(int bits)
Definition: EMTFHit.h:130
void set_ring(int bits)
Definition: EMTFHit.h:132
int PC_sector() const
Definition: EMTFHit.h:202
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
void set_strip_low(int bits)
Definition: EMTFHit.h:151
int roll() const
Definition: EMTFGEMDetId.cc:56
int region() const
The identifiers.
Definition: EMTFGEMDetId.cc:19
void set_is_CSC(int bits)
Definition: EMTFHit.h:183
void set_pattern(int bits)
Definition: EMTFHit.h:154
T z() const
Definition: PV3DBase.h:61
void set_csc_ID(int bits)
Definition: EMTFHit.h:139
void set_pc_chamber(int bits)
Definition: EMTFHit.h:146
void set_strip_hi(int bits)
Definition: EMTFHit.h:150
int chamber() const
Definition: EMTFGEMDetId.cc:49
int calc_theta_int(double theta, int endcap)
Definition: TrackTools.h:132
void set_pc_segment(int bits)
Definition: EMTFHit.h:147
void set_is_RPC(int bits)
Definition: EMTFHit.h:184
int station() const
Definition: EMTFGEMDetId.cc:34
void set_sector(int bits)
Definition: EMTFHit.h:133
void set_valid(int bits)
Definition: EMTFHit.h:156
void set_z_sim(float val)
Definition: EMTFHit.h:180
void set_strip(int bits)
Definition: EMTFHit.h:149
void set_subsystem(int bits)
Definition: EMTFHit.h:186
T eta() const
Definition: PV3DBase.h:73
void set_bx(int bits)
Definition: EMTFHit.h:159
int Endcap() const
Definition: EMTFHit.h:188
double rad_to_deg(double rad)
Definition: TrackTools.h:62
EMTFGEMDetId construct_EMTFGEMDetId(const L1TMuon::TriggerPrimitive &tp)
void set_chamber(int bits)
Definition: EMTFHit.h:138
void set_subsector(int bits)
Definition: EMTFHit.h:136
void set_bend(int bits)
Definition: EMTFHit.h:155
const GeometryTranslator * tp_geom_
void set_phi_fp(int bits)
Definition: EMTFHit.h:161
void set_roll(int bits)
Definition: EMTFHit.h:141
int ring() const
Definition: EMTFGEMDetId.cc:26
void set_pc_sector(int bits)
Definition: EMTFHit.h:144
GlobalPoint getGlobalPoint(const TriggerPrimitive &) const
void PrimitiveConversion::convert_gem_details ( EMTFHit conv_hit) const

Definition at line 881 of file PrimitiveConversion.cc.

References emtf::calc_eta_from_theta_deg(), emtf::calc_phi_glob_deg(), emtf::calc_phi_loc_deg(), emtf::calc_theta_deg_from_int(), gather_cfg::cout, l1t::EMTFHit::CSC_nID(), l1t::EMTFHit::Endcap(), get_bt_segment(), get_bt_station(), get_fs_segment(), get_fs_zone_code(), get_zone_code(), l1t::EMTFHit::Neighbor(), l1t::EMTFHit::PC_chamber(), l1t::EMTFHit::PC_sector(), l1t::EMTFHit::PC_segment(), l1t::EMTFHit::PC_station(), l1t::EMTFHit::Phi_fp(), l1t::EMTFHit::Phi_loc(), l1t::EMTFHit::Ring(), l1t::EMTFHit::Sector(), l1t::EMTFHit::set_bt_segment(), l1t::EMTFHit::set_bt_station(), l1t::EMTFHit::set_eta(), l1t::EMTFHit::set_fs_segment(), l1t::EMTFHit::set_fs_zone_code(), l1t::EMTFHit::set_phi_fp(), l1t::EMTFHit::set_phi_glob(), l1t::EMTFHit::set_phi_loc(), l1t::EMTFHit::set_theta(), l1t::EMTFHit::set_theta_fp(), l1t::EMTFHit::set_zone_code(), l1t::EMTFHit::set_zone_hit(), l1t::EMTFHit::Station(), l1t::EMTFHit::Subsector(), l1t::EMTFHit::Theta(), l1t::EMTFHit::Theta_fp(), and verbose_.

Referenced by convert_gem(), and lut().

881  {
882  const bool is_neighbor = conv_hit.Neighbor();
883 
884  const int pc_station = conv_hit.PC_station();
885  const int pc_chamber = conv_hit.PC_chamber();
886  const int pc_segment = conv_hit.PC_segment();
887 
888  //const int fw_endcap = (endcap_-1);
889  //const int fw_sector = (sector_-1);
890  const int fw_station =
891  (conv_hit.Station() == 1) ? (is_neighbor ? 0 : (conv_hit.Subsector() - 1)) : conv_hit.Station();
892  const int fw_cscid = (conv_hit.CSC_nID() - 1);
893 
894  int fph = conv_hit.Phi_fp();
895  int th = conv_hit.Theta_fp();
896 
897  if (verbose_ > 1) { // debug
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;
902  }
903 
904  // ___________________________________________________________________________
905  // Zone codes and other segment IDs
906 
907  int zone_hit = ((fph + (1 << 4)) >> 5);
908  int zone_code = get_zone_code(conv_hit, th);
909  //int phzvl = get_phzvl(conv_hit, zone_code);
910 
911  int fs_zone_code = get_fs_zone_code(conv_hit);
912  int fs_segment = get_fs_segment(conv_hit, fw_station, fw_cscid, pc_segment);
913 
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);
916 
917  // ___________________________________________________________________________
918  // Output
919 
920  conv_hit.set_phi_fp(fph); // Full-precision integer phi
921  conv_hit.set_theta_fp(th); // Full-precision integer theta
922  //conv_hit.set_phzvl ( phzvl ); // Local zone word: (1*low) + (2*mid) + (4*low) - used in FW debugging
923  //conv_hit.set_ph_hit ( ph_hit ); // Intermediate quantity in phi calculation - used in FW debugging
924  conv_hit.set_zone_hit(zone_hit); // Phi value for building patterns (0.53333 deg precision)
925  conv_hit.set_zone_code(zone_code); // Full zone word: 1*(zone 0) + 2*(zone 1) + 4*(zone 2) + 8*(zone 3)
926 
927  conv_hit.set_fs_segment(fs_segment); // Segment number used in primitive matching
928  conv_hit.set_fs_zone_code(fs_zone_code); // Zone word used in primitive matching
929 
930  conv_hit.set_bt_station(bt_station);
931  conv_hit.set_bt_segment(bt_segment);
932 
933  conv_hit.set_phi_loc(emtf::calc_phi_loc_deg(fph));
934  conv_hit.set_phi_glob(emtf::calc_phi_glob_deg(conv_hit.Phi_loc(), conv_hit.PC_sector()));
936  conv_hit.set_eta(emtf::calc_eta_from_theta_deg(conv_hit.Theta(), conv_hit.Endcap()));
937 }
void set_phi_glob(float val)
Definition: EMTFHit.h:172
int get_bt_station(const EMTFHit &conv_hit, int fw_station, int fw_cscid, int pc_segment) const
float Phi_loc() const
Definition: EMTFHit.h:229
int get_zone_code(const EMTFHit &conv_hit, int th) const
int CSC_nID() const
Definition: EMTFHit.h:198
int Phi_fp() const
Definition: EMTFHit.h:219
void set_theta(float val)
Definition: EMTFHit.h:173
float Theta() const
Definition: EMTFHit.h:231
void set_bt_station(int bits)
Definition: EMTFHit.h:169
double calc_phi_loc_deg(int bits)
Definition: TrackTools.h:165
int get_bt_segment(const EMTFHit &conv_hit, int fw_station, int fw_cscid, int pc_segment) const
void set_theta_fp(int bits)
Definition: EMTFHit.h:162
int PC_sector() const
Definition: EMTFHit.h:202
int Subsector() const
Definition: EMTFHit.h:194
int PC_station() const
Definition: EMTFHit.h:203
int get_fs_segment(const EMTFHit &conv_hit, int fw_station, int fw_cscid, int pc_segment) const
int Sector() const
Definition: EMTFHit.h:191
double calc_theta_deg_from_int(int theta_int)
Definition: TrackTools.h:117
void set_bt_segment(int bits)
Definition: EMTFHit.h:170
int PC_segment() const
Definition: EMTFHit.h:205
int Ring() const
Definition: EMTFHit.h:190
double calc_phi_glob_deg(double loc, int sector)
Definition: TrackTools.h:155
void set_phi_loc(float val)
Definition: EMTFHit.h:171
int PC_chamber() const
Definition: EMTFHit.h:204
void set_fs_segment(int bits)
Definition: EMTFHit.h:167
int Station() const
Definition: EMTFHit.h:189
double calc_eta_from_theta_deg(double theta_deg, int endcap)
Definition: TrackTools.h:102
void set_zone_code(int bits)
Definition: EMTFHit.h:166
void set_zone_hit(int bits)
Definition: EMTFHit.h:165
int Endcap() const
Definition: EMTFHit.h:188
int get_fs_zone_code(const EMTFHit &conv_hit) const
void set_fs_zone_code(int bits)
Definition: EMTFHit.h:168
int Theta_fp() const
Definition: EMTFHit.h:220
int Neighbor() const
Definition: EMTFHit.h:200
void set_phi_fp(int bits)
Definition: EMTFHit.h:161
void set_eta(float val)
Definition: EMTFHit.h:174
void PrimitiveConversion::convert_rpc ( int  pc_sector,
int  pc_station,
int  pc_chamber,
int  pc_segment,
const TriggerPrimitive muon_primitive,
EMTFHit conv_hit 
) const

Definition at line 471 of file PrimitiveConversion.cc.

References bxShiftRPC_, emtf::calc_phi_loc_int_rpc(), emtf::calc_theta_int_rpc(), convert_rpc_details(), L1TMuon::TriggerPrimitive::detId(), l1t::EMTFHit::Endcap(), endcap_, PV3DBase< T, PVType, FrameType >::eta(), L1TMuon::GeometryTranslator::getGlobalPoint(), L1TMuon::TriggerPrimitive::getRPCData(), runTauDisplay::gp, L1TMuon::TriggerPrimitive::kRPC, l1t::EMTFHit::PC_sector(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), emtf::rad_to_deg(), RPCDetId::region(), RPCDetId::ring(), RPCDetId::roll(), RPCDetId::sector(), sector_, l1t::EMTFHit::set_bx(), l1t::EMTFHit::set_chamber(), l1t::EMTFHit::set_endcap(), l1t::EMTFHit::set_eta_sim(), l1t::EMTFHit::set_is_CSC(), l1t::EMTFHit::set_is_GEM(), l1t::EMTFHit::set_is_RPC(), l1t::EMTFHit::set_neighbor(), l1t::EMTFHit::set_pattern(), l1t::EMTFHit::set_pc_chamber(), l1t::EMTFHit::set_pc_sector(), l1t::EMTFHit::set_pc_segment(), l1t::EMTFHit::set_pc_station(), l1t::EMTFHit::set_phi_fp(), l1t::EMTFHit::set_phi_sim(), l1t::EMTFHit::set_rho_sim(), l1t::EMTFHit::set_ring(), l1t::EMTFHit::set_roll(), l1t::EMTFHit::set_sector(), l1t::EMTFHit::set_sector_idx(), l1t::EMTFHit::set_sector_RPC(), l1t::EMTFHit::set_station(), l1t::EMTFHit::set_strip(), l1t::EMTFHit::set_strip_hi(), l1t::EMTFHit::set_strip_low(), l1t::EMTFHit::set_subsector(), l1t::EMTFHit::set_subsector_RPC(), l1t::EMTFHit::set_subsystem(), l1t::EMTFHit::set_theta_fp(), l1t::EMTFHit::set_theta_sim(), l1t::EMTFHit::set_time(), l1t::EMTFHit::set_valid(), l1t::EMTFHit::set_z_sim(), l1t::EMTFHit::SetRPCDetId(), RPCDetId::station(), RPCDetId::subsector(), PV3DBase< T, PVType, FrameType >::theta(), tp_geom_, Geom::Phi< T1, Range >::value(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by lut(), and process().

476  {
477  const RPCDetId& tp_detId = muon_primitive.detId<RPCDetId>();
478  const RPCData& tp_data = muon_primitive.getRPCData();
479 
480  int tp_region = tp_detId.region(); // 0 for Barrel, +/-1 for +/- Endcap
481  int tp_endcap = (tp_region == -1) ? 2 : tp_region;
482  int tp_sector = tp_detId.sector(); // 1 - 6 (60 degrees in phi, sector 1 begins at -5 deg)
483  int tp_subsector = tp_detId.subsector(); // 1 - 6 (10 degrees in phi; staggered in z)
484  int tp_station = tp_detId.station(); // 1 - 4
485  int tp_ring = tp_detId.ring(); // 2 - 3 (increasing theta)
486  int tp_roll = tp_detId.roll(); // 1 - 3 (decreasing theta; aka A - C; space between rolls is 9 - 15 in theta_fp)
487  //int tp_layer = tp_detId.layer(); // Always 1 in the Endcap, 1 or 2 in the Barrel
488 
489  int tp_bx = tp_data.bx;
490  int tp_strip = ((tp_data.strip_low + tp_data.strip_hi) / 2); // in full-strip unit
491  int tp_valid = tp_data.valid;
492 
493  const bool is_neighbor = (pc_station == 5);
494 
495  // CSC-like sector, subsector and chamber numbers
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; // Rotate by 20 deg
498  int csc_tp_subsector = ((tp_subsector + 3) % 6) + 1; // Rotate by 2
499 
500  // Set properties
501  conv_hit.SetRPCDetId(tp_detId);
502 
503  conv_hit.set_endcap((tp_endcap == 2) ? -1 : tp_endcap);
504  conv_hit.set_station(tp_station);
505  conv_hit.set_ring(tp_ring);
506  conv_hit.set_roll(tp_roll);
507  conv_hit.set_chamber(csc_tp_chamber);
508  conv_hit.set_sector(csc_tp_sector);
509  conv_hit.set_subsector(csc_tp_subsector);
510  //conv_hit.set_csc_ID ( tp_csc_ID );
511  //conv_hit.set_csc_nID ( csc_nID );
512  //conv_hit.set_track_num ( tp_data.trknmb );
513  //conv_hit.set_sync_err ( tp_data.syncErr );
514  conv_hit.set_sector_RPC(tp_sector); // In RPC convention in CMSSW (RPCDetId.h), sector 1 starts at -5 deg
515  conv_hit.set_subsector_RPC(tp_subsector);
516 
517  conv_hit.set_bx(tp_bx + bxShiftRPC_);
519  conv_hit.set_is_CSC(false);
520  conv_hit.set_is_RPC(true);
521  conv_hit.set_is_GEM(false);
522 
523  conv_hit.set_pc_sector(pc_sector);
524  conv_hit.set_pc_station(pc_station);
525  conv_hit.set_pc_chamber(pc_chamber);
526  conv_hit.set_pc_segment(pc_segment);
527 
528  conv_hit.set_valid(tp_valid);
529  conv_hit.set_strip(tp_strip);
530  conv_hit.set_strip_low(tp_data.strip_low);
531  conv_hit.set_strip_hi(tp_data.strip_hi);
532  //conv_hit.set_wire ( tp_data.keywire );
533  //conv_hit.set_quality ( tp_data.quality );
534  conv_hit.set_pattern(0); // In firmware, this marks RPC stub
535  //conv_hit.set_bend ( tp_data.bend );
536  conv_hit.set_time(tp_data.time);
537  //conv_hit.set_alct_quality ( tp_data.alct_quality );
538  //conv_hit.set_clct_quality ( tp_data.clct_quality );
539 
540  conv_hit.set_neighbor(is_neighbor);
541  conv_hit.set_sector_idx((endcap_ == 1) ? sector_ - 1 : sector_ + 5);
542 
543  // Get coordinates from fullsim
544  bool use_fullsim_coords = true;
545 
546  if (tp_data.isCPPF) { // CPPF digis from EMTF unpacker or CPPF emulator
547  conv_hit.set_phi_fp(tp_data.phi_int * 4); // Full-precision integer phi
548  conv_hit.set_theta_fp(tp_data.theta_int * 4); // Full-precision integer theta
549  } else if (use_fullsim_coords) {
550  const GlobalPoint& gp = tp_geom_->getGlobalPoint(muon_primitive);
551  double glob_phi = emtf::rad_to_deg(gp.phi().value());
552  double glob_theta = emtf::rad_to_deg(gp.theta());
553  double glob_eta = gp.eta();
554  double glob_rho = gp.perp();
555  double glob_z = gp.z();
556 
557  // Use RPC-specific convention in docs/CPPF-EMTF-format_2016_11_01.docx
558  // Phi precision is 1/15 degrees (11 bits), 4x larger than CSC precision of 1/60 degrees (13 bits)
559  // Theta precision is 36.5/32 degrees (5 bits), 4x larger than CSC precision of 36.5/128 degrees (7 bits)
560  //
561  // NOTE: fph and th are recalculated using CPPF LUTs in the convert_rpc_details() function,
562  // this part is still kept because it is needed for Phase 2 iRPC hits.
563  //
564  int fph = emtf::calc_phi_loc_int_rpc(glob_phi, conv_hit.PC_sector());
565  int th = emtf::calc_theta_int_rpc(glob_theta, conv_hit.Endcap());
566 
567  if (not(0 <= fph && fph < 1250)) {
568  edm::LogError("L1T") << "fph = " << fph;
569  return;
570  }
571  if (not(0 <= th && th < 32)) {
572  edm::LogError("L1T") << "th = " << th;
573  return;
574  }
575  if (not(th != 0b11111)) // RPC hit valid when data is not all ones
576  {
577  edm::LogError("L1T") << "th = " << th;
578  return;
579  }
580  fph <<= 2; // upgrade to full CSC precision by adding 2 zeros
581  th <<= 2; // upgrade to full CSC precision by adding 2 zeros
582  th = (th == 0) ? 1 : th; // protect against invalid value
583 
584  // _________________________________________________________________________
585  // Output
586 
587  conv_hit.set_phi_sim(glob_phi);
588  conv_hit.set_theta_sim(glob_theta);
589  conv_hit.set_eta_sim(glob_eta);
590  conv_hit.set_rho_sim(glob_rho);
591  conv_hit.set_z_sim(glob_z);
592 
593  conv_hit.set_phi_fp(fph); // Full-precision integer phi
594  conv_hit.set_theta_fp(th); // Full-precision integer theta
595  }
596 
597  convert_rpc_details(conv_hit, (tp_data.isCPPF == false));
598 }
void set_subsector_RPC(int bits)
Definition: EMTFHit.h:137
void set_theta_sim(float val)
Definition: EMTFHit.h:177
void set_is_GEM(int bits)
Definition: EMTFHit.h:185
void set_neighbor(int bits)
Definition: EMTFHit.h:142
void set_rho_sim(float val)
Definition: EMTFHit.h:179
void set_pc_station(int bits)
Definition: EMTFHit.h:145
void set_phi_sim(float val)
Definition: EMTFHit.h:176
T perp() const
Definition: PV3DBase.h:69
void set_station(int bits)
Definition: EMTFHit.h:131
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
void set_eta_sim(float val)
Definition: EMTFHit.h:178
void set_sector_idx(int bits)
Definition: EMTFHit.h:135
T1 value() const
Explicit access to value in case implicit conversion not OK.
Definition: Phi.h:75
void set_theta_fp(int bits)
Definition: EMTFHit.h:162
void set_endcap(int bits)
Definition: EMTFHit.h:130
void set_ring(int bits)
Definition: EMTFHit.h:132
int calc_theta_int_rpc(double theta, int endcap)
Definition: TrackTools.h:139
int PC_sector() const
Definition: EMTFHit.h:202
const RPCData getRPCData() const
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
void SetRPCDetId(const RPCDetId &id)
Definition: EMTFHit.h:114
void set_strip_low(int bits)
Definition: EMTFHit.h:151
int roll() const
Definition: RPCDetId.h:92
int ring() const
Definition: RPCDetId.h:59
void set_is_CSC(int bits)
Definition: EMTFHit.h:183
void set_pattern(int bits)
Definition: EMTFHit.h:154
T z() const
Definition: PV3DBase.h:61
void set_pc_chamber(int bits)
Definition: EMTFHit.h:146
void set_strip_hi(int bits)
Definition: EMTFHit.h:150
int calc_phi_loc_int_rpc(double glob, int sector)
Definition: TrackTools.h:198
void set_time(float val)
Definition: EMTFHit.h:175
void set_pc_segment(int bits)
Definition: EMTFHit.h:147
void set_is_RPC(int bits)
Definition: EMTFHit.h:184
void set_sector_RPC(int bits)
Definition: EMTFHit.h:134
void set_sector(int bits)
Definition: EMTFHit.h:133
void set_valid(int bits)
Definition: EMTFHit.h:156
void set_z_sim(float val)
Definition: EMTFHit.h:180
void set_strip(int bits)
Definition: EMTFHit.h:149
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:81
void set_subsystem(int bits)
Definition: EMTFHit.h:186
T eta() const
Definition: PV3DBase.h:73
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel...
Definition: RPCDetId.h:88
void set_bx(int bits)
Definition: EMTFHit.h:159
int Endcap() const
Definition: EMTFHit.h:188
double rad_to_deg(double rad)
Definition: TrackTools.h:62
void set_chamber(int bits)
Definition: EMTFHit.h:138
void set_subsector(int bits)
Definition: EMTFHit.h:136
void convert_rpc_details(EMTFHit &conv_hit, const bool use_cppf_lut) const
const GeometryTranslator * tp_geom_
void set_phi_fp(int bits)
Definition: EMTFHit.h:161
void set_roll(int bits)
Definition: EMTFHit.h:141
void set_pc_sector(int bits)
Definition: EMTFHit.h:144
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
int station() const
Definition: RPCDetId.h:78
GlobalPoint getGlobalPoint(const TriggerPrimitive &) const
void PrimitiveConversion::convert_rpc_details ( EMTFHit conv_hit,
const bool  use_cppf_lut 
) const

Definition at line 600 of file PrimitiveConversion.cc.

References emtf::calc_eta_from_theta_deg(), emtf::calc_phi_glob_deg(), emtf::calc_phi_loc_deg(), emtf::calc_theta_deg_from_int(), gather_cfg::cout, l1t::EMTFHit::Endcap(), get_bt_segment(), get_bt_station(), SectorProcessorLUT::get_cppf_ph_lut(), SectorProcessorLUT::get_cppf_th_lut(), get_fs_segment(), get_fs_zone_code(), get_zone_code(), lut(), l1t::EMTFHit::Neighbor(), l1t::EMTFHit::PC_chamber(), l1t::EMTFHit::PC_sector(), l1t::EMTFHit::PC_segment(), l1t::EMTFHit::PC_station(), l1t::EMTFHit::Phi_fp(), l1t::EMTFHit::Phi_loc(), l1t::EMTFHit::Ring(), l1t::EMTFHit::Roll(), l1t::EMTFHit::Sector_RPC(), l1t::EMTFHit::set_bt_segment(), l1t::EMTFHit::set_bt_station(), l1t::EMTFHit::set_eta(), l1t::EMTFHit::set_fs_segment(), l1t::EMTFHit::set_fs_zone_code(), l1t::EMTFHit::set_phi_fp(), l1t::EMTFHit::set_phi_glob(), l1t::EMTFHit::set_phi_loc(), l1t::EMTFHit::set_theta(), l1t::EMTFHit::set_theta_fp(), l1t::EMTFHit::set_zone_code(), l1t::EMTFHit::set_zone_hit(), l1t::EMTFHit::Station(), l1t::EMTFHit::Strip_hi(), l1t::EMTFHit::Strip_low(), l1t::EMTFHit::Subsector_RPC(), l1t::EMTFHit::Theta(), l1t::EMTFHit::Theta_fp(), and verbose_.

Referenced by convert_rpc(), and lut().

600  {
601  const bool is_neighbor = conv_hit.Neighbor();
602 
603  const int pc_station = conv_hit.PC_station();
604  const int pc_chamber = conv_hit.PC_chamber();
605  const int pc_segment = conv_hit.PC_segment();
606 
607  //const int fw_endcap = (endcap_-1);
608  //const int fw_sector = (sector_-1);
609  const int fw_station = (conv_hit.Station() == 1) ? (is_neighbor ? 0 : pc_station) : conv_hit.Station();
610 
611  int fw_cscid = pc_chamber;
612  if (is_neighbor) {
613  int csc_nID = -1;
614 
615  // station 1 has 3 neighbor chambers: 13,14,15 in rings 1,2,3
616  // (where are chambers 10,11,12 in station 1? they were used to label ME1/1a, but not anymore)
617  // station 2,3,4 have 2 neighbor chambers: 10,11 in rings 1,2
618  csc_nID = (pc_chamber < 3) ? (pc_chamber + 12) : (((pc_chamber - 1) % 2) + 9);
619  csc_nID += 1;
620 
621  fw_cscid = csc_nID - 1;
622  }
623 
624  int fph = conv_hit.Phi_fp();
625  int th = conv_hit.Theta_fp();
626 
627  if (use_cppf_lut) {
628  int halfstrip = (conv_hit.Strip_low() + conv_hit.Strip_hi() - 1);
629  if (not(1 <= halfstrip && halfstrip <= 64)) {
630  edm::LogError("L1T") << "halfstrip = " << halfstrip;
631  return;
632  }
633 
634  int fph2 = lut().get_cppf_ph_lut(conv_hit.Endcap(),
635  conv_hit.Sector_RPC(),
636  conv_hit.Station(),
637  conv_hit.Ring(),
638  conv_hit.Subsector_RPC(),
639  conv_hit.Roll(),
640  halfstrip,
641  is_neighbor);
642  int th2 = lut().get_cppf_th_lut(conv_hit.Endcap(),
643  conv_hit.Sector_RPC(),
644  conv_hit.Station(),
645  conv_hit.Ring(),
646  conv_hit.Subsector_RPC(),
647  conv_hit.Roll());
648  fph = fph2;
649  th = th2;
650 
651  if (not(0 <= fph && fph < 1250)) {
652  edm::LogError("L1T") << "fph = " << fph;
653  return;
654  }
655  if (not(0 <= th && th < 32)) {
656  edm::LogError("L1T") << "th = " << th;
657  return;
658  }
659  if (not(th != 0b11111)) // RPC hit valid when data is not all ones
660  {
661  edm::LogError("L1T") << "th = " << th;
662  return;
663  }
664  fph <<= 2; // upgrade to full CSC precision by adding 2 zeros
665  th <<= 2; // upgrade to full CSC precision by adding 2 zeros
666  th = (th == 0) ? 1 : th; // protect against invalid value
667  }
668 
669  if (verbose_ > 1) { // debug
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()
672  << " tp_sector: " << conv_hit.Sector_RPC() << " tp_subsector: " << conv_hit.Subsector_RPC()
673  << " fph: " << fph << " th: " << th << std::endl;
674  }
675 
676  // ___________________________________________________________________________
677  // Zone codes and other segment IDs
678 
679  int zone_hit = ((fph + (1 << 4)) >> 5);
680  int zone_code = get_zone_code(conv_hit, th);
681  //int phzvl = get_phzvl(conv_hit, zone_code);
682 
683  int fs_zone_code = get_fs_zone_code(conv_hit);
684  int fs_segment = get_fs_segment(conv_hit, fw_station, fw_cscid, pc_segment);
685 
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);
688 
689  // ___________________________________________________________________________
690  // Output
691 
692  conv_hit.set_phi_fp(fph); // Full-precision integer phi
693  conv_hit.set_theta_fp(th); // Full-precision integer theta
694  //conv_hit.set_phzvl ( phzvl ); // Local zone word: (1*low) + (2*mid) + (4*low) - used in FW debugging
695  //conv_hit.set_ph_hit ( ph_hit ); // Intermediate quantity in phi calculation - used in FW debugging
696  conv_hit.set_zone_hit(zone_hit); // Phi value for building patterns (0.53333 deg precision)
697  conv_hit.set_zone_code(zone_code); // Full zone word: 1*(zone 0) + 2*(zone 1) + 4*(zone 2) + 8*(zone 3)
698 
699  conv_hit.set_fs_segment(fs_segment); // Segment number used in primitive matching
700  conv_hit.set_fs_zone_code(fs_zone_code); // Zone word used in primitive matching
701 
702  conv_hit.set_bt_station(bt_station);
703  conv_hit.set_bt_segment(bt_segment);
704 
705  conv_hit.set_phi_loc(emtf::calc_phi_loc_deg(fph));
706  conv_hit.set_phi_glob(emtf::calc_phi_glob_deg(conv_hit.Phi_loc(), conv_hit.PC_sector()));
708  conv_hit.set_eta(emtf::calc_eta_from_theta_deg(conv_hit.Theta(), conv_hit.Endcap()));
709 }
void set_phi_glob(float val)
Definition: EMTFHit.h:172
int Strip_hi() const
Definition: EMTFHit.h:208
int get_bt_station(const EMTFHit &conv_hit, int fw_station, int fw_cscid, int pc_segment) const
float Phi_loc() const
Definition: EMTFHit.h:229
int get_zone_code(const EMTFHit &conv_hit, int th) const
int Phi_fp() const
Definition: EMTFHit.h:219
void set_theta(float val)
Definition: EMTFHit.h:173
float Theta() const
Definition: EMTFHit.h:231
void set_bt_station(int bits)
Definition: EMTFHit.h:169
double calc_phi_loc_deg(int bits)
Definition: TrackTools.h:165
int Roll() const
Definition: EMTFHit.h:199
int get_bt_segment(const EMTFHit &conv_hit, int fw_station, int fw_cscid, int pc_segment) const
void set_theta_fp(int bits)
Definition: EMTFHit.h:162
int PC_sector() const
Definition: EMTFHit.h:202
int PC_station() const
Definition: EMTFHit.h:203
int get_fs_segment(const EMTFHit &conv_hit, int fw_station, int fw_cscid, int pc_segment) const
double calc_theta_deg_from_int(int theta_int)
Definition: TrackTools.h:117
int Strip_low() const
Definition: EMTFHit.h:209
void set_bt_segment(int bits)
Definition: EMTFHit.h:170
int PC_segment() const
Definition: EMTFHit.h:205
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
int Subsector_RPC() const
Definition: EMTFHit.h:195
int Ring() const
Definition: EMTFHit.h:190
double calc_phi_glob_deg(double loc, int sector)
Definition: TrackTools.h:155
void set_phi_loc(float val)
Definition: EMTFHit.h:171
int Sector_RPC() const
Definition: EMTFHit.h:192
int PC_chamber() const
Definition: EMTFHit.h:204
void set_fs_segment(int bits)
Definition: EMTFHit.h:167
int Station() const
Definition: EMTFHit.h:189
double calc_eta_from_theta_deg(double theta_deg, int endcap)
Definition: TrackTools.h:102
void set_zone_code(int bits)
Definition: EMTFHit.h:166
void set_zone_hit(int bits)
Definition: EMTFHit.h:165
int Endcap() const
Definition: EMTFHit.h:188
const SectorProcessorLUT & lut() const
int get_fs_zone_code(const EMTFHit &conv_hit) const
void set_fs_zone_code(int bits)
Definition: EMTFHit.h:168
int Theta_fp() const
Definition: EMTFHit.h:220
int Neighbor() const
Definition: EMTFHit.h:200
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 set_phi_fp(int bits)
Definition: EMTFHit.h:161
void set_eta(float val)
Definition: EMTFHit.h:174
int PrimitiveConversion::get_bt_segment ( const EMTFHit conv_hit,
int  fw_station,
int  fw_cscid,
int  pc_segment 
) const

Definition at line 1057 of file PrimitiveConversion.cc.

Referenced by convert_csc_details(), convert_gem_details(), convert_rpc_details(), and lut().

1057  {
1058  // For later use in angle calculation and best track selection
1059  // (in the firmware, this happens in the best_tracks module)
1060  int bt_history = 0; // history id: not set here, to be set in primitive matching
1061  int bt_chamber = -1; // chamber id
1062  int bt_segment = pc_segment % 2; // segment id
1063 
1064  // For ME1
1065  // j = 0 is No valid LCT
1066  // j = 1 .. 9 are native sector chambers
1067  // j = 10 .. 12 are neighbor sector chambers
1068  // For ME2,3,4
1069  // j = 0 is No valid LCT
1070  // j = 1 .. 9 are native sector chambers
1071  // j = 10 .. 11 are neighbor sector chambers
1072  bt_chamber = fw_cscid + 1;
1073  if (fw_station == 0 && bt_chamber >= 13) // ME1 neighbor chambers 13,14,15 -> 10,11,12
1074  bt_chamber -= 3;
1075 
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;
1079  return 0;
1080  }
1081 
1082  // bt_segment is a 7-bit word, HHCCCCS, encoding the segment number S in the chamber (1 or 2),
1083  // the chamber number CCCC ("j" above: uniquely identifies chamber within station and ring),
1084  // and the history HH (0 for current BX, 1 for previous BX, 2 for BX before that)
1085  bt_segment = ((bt_history & 0x3) << 5) | ((bt_chamber & 0xf) << 1) | (bt_segment & 0x1);
1086  return bt_segment;
1087 }
int PrimitiveConversion::get_bt_station ( const EMTFHit conv_hit,
int  fw_station,
int  fw_cscid,
int  pc_segment 
) const

Definition at line 1052 of file PrimitiveConversion.cc.

Referenced by convert_csc_details(), convert_gem_details(), convert_rpc_details(), and lut().

1052  {
1053  int bt_station = fw_station;
1054  return bt_station;
1055 }
int PrimitiveConversion::get_fs_segment ( const EMTFHit conv_hit,
int  fw_station,
int  fw_cscid,
int  pc_segment 
) const

Definition at line 1017 of file PrimitiveConversion.cc.

References dqmiodumpmetadata::n, l1t::EMTFHit::Neighbor(), and l1t::EMTFHit::Ring().

Referenced by convert_csc_details(), convert_gem_details(), convert_rpc_details(), and lut().

1017  {
1018  // For later use in primitive matching
1019  // (in the firmware, this happens in the find_segment module)
1020  int fs_history = 0; // history id: not set here, to be set in primitive matching
1021  int fs_chamber = -1; // chamber id
1022  int fs_segment = pc_segment % 2; // segment id
1023 
1024  // For ME1
1025  // j = 0 is neighbor sector chamber
1026  // j = 1,2,3 are native subsector 1 chambers
1027  // j = 4,5,6 are native subsector 2 chambers
1028  // For ME2,3,4:
1029  // j = 0 is neighbor sector chamber
1030  // j = 1,2,3,4,5,6 are native sector chambers
1031  const bool is_neighbor = conv_hit.Neighbor();
1032  if (fw_station <= 1) { // ME1
1033  int n = fw_cscid % 3;
1034  fs_chamber = is_neighbor ? 0 : ((fw_station == 0) ? 1 + n : 4 + n);
1035  } else { // ME2,3,4
1036  int n = (conv_hit.Ring() == 1) ? fw_cscid : (fw_cscid - 3);
1037  fs_chamber = is_neighbor ? 0 : 1 + n;
1038  }
1039 
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;
1043  return 0;
1044  }
1045  // fs_segment is a 6-bit word, HHCCCS, encoding the segment number S in the chamber (1 or 2),
1046  // the chamber number CCC ("j" above: uniquely identifies chamber within station and ring),
1047  // and the history HH (0 for current BX, 1 for previous BX, 2 for BX before that)
1048  fs_segment = ((fs_history & 0x3) << 4) | ((fs_chamber & 0x7) << 1) | (fs_segment & 0x1);
1049  return fs_segment;
1050 }
int Ring() const
Definition: EMTFHit.h:190
int Neighbor() const
Definition: EMTFHit.h:200
int PrimitiveConversion::get_fs_zone_code ( const EMTFHit conv_hit) const

Definition at line 990 of file PrimitiveConversion.cc.

References l1t::EMTFHit::Ring(), l1t::EMTFHit::Station(), and useNewZones_.

Referenced by convert_csc_details(), convert_gem_details(), convert_rpc_details(), get_zone_code(), and lut().

990  {
991  static const unsigned int zone_code_table[4][3] = {
992  // map (station,ring) to zone_code
993  {0b0011, 0b0100, 0b1000}, // st1 r1: [z0,z1], r2: [z2], r3: [z3]
994  {0b0011, 0b1100, 0b1100}, // st2 r1: [z0,z1], r2: [z2,z3], r3 = r2
995  {0b0001, 0b1110, 0b1110}, // st3 r1: [z0], r2: [z1,z2,z3], r3 = r2
996  {0b0001, 0b0110, 0b0110} // st4 r1: [z0], r2: [z1,z2], r3 = r2
997  };
998 
999  static const unsigned int zone_code_table_new[4][3] = {
1000  // map (station,ring) to zone_code
1001  {0b0011, 0b0110, 0b1000}, // st1 r1: [z0,z1], r2: [z1,z2], r3: [z3]
1002  {0b0011, 0b1110, 0b1110}, // st2 r1: [z0,z1], r2: [z1,z2,z3], r3 = r2
1003  {0b0011, 0b1110, 0b1110}, // st3 r1: [z0,z1], r2: [z1,z2,z3], r3 = r2
1004  {0b0001, 0b0110, 0b0110} // st4 r1: [z0], r2: [z1,z2], r3 = r2
1005  };
1006 
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;
1011  return 0;
1012  }
1013  unsigned int zone_code = useNewZones_ ? zone_code_table_new[istation][iring] : zone_code_table[istation][iring];
1014  return zone_code;
1015 }
int Ring() const
Definition: EMTFHit.h:190
int Station() const
Definition: EMTFHit.h:189
int PrimitiveConversion::get_phzvl ( const EMTFHit conv_hit,
int  zone_code 
) const

Definition at line 971 of file PrimitiveConversion.cc.

References l1t::EMTFHit::Ring(), and l1t::EMTFHit::Station().

Referenced by convert_csc_details(), and lut().

971  {
972  // For backward compatibility, no longer needed (only explicitly used in FW)
973  // phzvl: each chamber overlaps with at most 3 zones, so this "local" zone word says
974  // which of the possible zones contain the hit: 1 for lower, 2 for middle, 4 for upper
975  int phzvl = 0;
976  if (conv_hit.Ring() == 1 || conv_hit.Ring() == 4) {
977  phzvl = (zone_code >> 0);
978  } else if (conv_hit.Ring() == 2) {
979  if (conv_hit.Station() == 3 || conv_hit.Station() == 4) {
980  phzvl = (zone_code >> 1);
981  } else if (conv_hit.Station() == 1 || conv_hit.Station() == 2) {
982  phzvl = (zone_code >> 2);
983  }
984  } else if (conv_hit.Ring() == 3) {
985  phzvl = (zone_code >> 3);
986  }
987  return phzvl;
988 }
int Ring() const
Definition: EMTFHit.h:190
int Station() const
Definition: EMTFHit.h:189
int PrimitiveConversion::get_zone_code ( const EMTFHit conv_hit,
int  th 
) const

Definition at line 941 of file PrimitiveConversion.cc.

References get_fs_zone_code(), L1TMuon::TriggerPrimitive::kCSC, emtf::NUM_ZONES, l1t::EMTFHit::Ring(), l1t::EMTFHit::Station(), l1t::EMTFHit::Subsystem(), zoneBoundaries_, and zoneOverlap_.

Referenced by convert_csc_details(), convert_gem_details(), convert_rpc_details(), and lut().

941  {
942  // ph zone boundaries for chambers that cover more than one zone
943  // bnd1 is the lower boundary, bnd2 the upper boundary
944  int zone_code = 0;
945 
946  bool is_csc = (conv_hit.Subsystem() == TriggerPrimitive::kCSC);
947  bool is_me13 = (is_csc && conv_hit.Station() == 1 && conv_hit.Ring() == 3);
948 
949  for (int izone = 0; izone < emtf::NUM_ZONES; ++izone) {
950  int zone_code_tmp = get_fs_zone_code(conv_hit);
951  if (zone_code_tmp & (1 << izone)) {
952  bool no_use_bnd1 =
953  ((izone == 0) || ((zone_code_tmp & (1 << (izone - 1))) == 0) || is_me13); // first possible zone for this hit
954  bool no_use_bnd2 = (((zone_code_tmp & (1 << (izone + 1))) == 0) || is_me13); // last possible zone for this hit
955 
956  int ph_zone_bnd1 = no_use_bnd1 ? zoneBoundaries_.at(0) : zoneBoundaries_.at(izone);
957  int ph_zone_bnd2 = no_use_bnd2 ? zoneBoundaries_.at(emtf::NUM_ZONES) : zoneBoundaries_.at(izone + 1);
958 
959  if ((th > (ph_zone_bnd1 - zoneOverlap_)) && (th <= (ph_zone_bnd2 + zoneOverlap_))) {
960  zone_code |= (1 << izone);
961  }
962  }
963  }
964  if (not(zone_code > 0)) {
965  edm::LogError("L1T") << "zone_code = " << zone_code;
966  return 0;
967  }
968  return zone_code;
969 }
int Subsystem() const
Definition: EMTFHit.h:244
int NUM_ZONES
Definition: Common.h:67
int Ring() const
Definition: EMTFHit.h:190
std::vector< int > zoneBoundaries_
int Station() const
Definition: EMTFHit.h:189
int get_fs_zone_code(const EMTFHit &conv_hit) const
bool PrimitiveConversion::is_valid_for_run2 ( const EMTFHit conv_hit) const

Referenced by lut().

const SectorProcessorLUT& PrimitiveConversion::lut ( void  ) const
inline
void PrimitiveConversion::process ( const std::map< int, TriggerPrimitiveCollection > &  selected_prim_map,
EMTFHitCollection conv_hits 
) const

Definition at line 59 of file PrimitiveConversion.cc.

References convert_csc(), convert_gem(), convert_rpc(), L1TMuon::TriggerPrimitive::kCSC, L1TMuon::TriggerPrimitive::kGEM, L1TMuon::TriggerPrimitive::kRPC, and sector_.

Referenced by SectorProcessor::process_single_bx().

60  {
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();
63 
64  for (; map_tp_it != map_tp_end; ++map_tp_it) {
65  // Unique chamber ID in FW, {0, 53} as defined in get_index_csc in src/PrimitiveSelection.cc
66  int selected = map_tp_it->first;
67  // "Primitive Conversion" sector/station/chamber ID scheme used in FW
68  int pc_sector = sector_;
69  int pc_station = selected / 9; // {0, 5} = {ME1 sub 1, ME1 sub 2, ME2, ME3, ME4, neighbor}
70  int pc_chamber = selected % 9; // Equals CSC ID - 1 for all except neighbor chambers
71  int pc_segment = 0; // Counts hits in a single chamber
72 
73  TriggerPrimitiveCollection::const_iterator tp_it = map_tp_it->second.begin();
74  TriggerPrimitiveCollection::const_iterator tp_end = map_tp_it->second.end();
75 
76  for (; tp_it != tp_end; ++tp_it) {
77  EMTFHit conv_hit;
78  if (tp_it->subsystem() == TriggerPrimitive::kCSC) {
79  convert_csc(pc_sector, pc_station, pc_chamber, pc_segment, *tp_it, conv_hit);
80  } else if (tp_it->subsystem() == TriggerPrimitive::kRPC) {
81  convert_rpc(pc_sector, pc_station, pc_chamber, pc_segment, *tp_it, conv_hit);
82  } else if (tp_it->subsystem() == TriggerPrimitive::kGEM) {
83  convert_gem(pc_sector, pc_station, pc_chamber, pc_segment, *tp_it, conv_hit);
84  } else {
85  if (not(false && "Incorrect subsystem type")) {
86  edm::LogError("L1T") << "Incorrect subsystem type";
87  return;
88  }
89  }
90  conv_hits.push_back(conv_hit);
91  pc_segment += 1;
92  }
93  }
94 }
void convert_gem(int pc_sector, int pc_station, int pc_chamber, int pc_segment, const TriggerPrimitive &muon_primitive, EMTFHit &conv_hit) const
void convert_rpc(int pc_sector, int pc_station, int pc_chamber, int pc_segment, const TriggerPrimitive &muon_primitive, EMTFHit &conv_hit) const
void convert_csc(int pc_sector, int pc_station, int pc_chamber, int pc_segment, const TriggerPrimitive &muon_primitive, EMTFHit &conv_hit) const

Member Data Documentation

bool PrimitiveConversion::bugME11Dupes_
private

Definition at line 88 of file PrimitiveConversion.h.

Referenced by configure(), and convert_csc_details().

int PrimitiveConversion::bx_
private

Definition at line 81 of file PrimitiveConversion.h.

Referenced by configure().

int PrimitiveConversion::bxShiftCSC_
private

Definition at line 83 of file PrimitiveConversion.h.

Referenced by configure(), and convert_csc().

int PrimitiveConversion::bxShiftGEM_
private

Definition at line 83 of file PrimitiveConversion.h.

Referenced by configure(), and convert_gem().

int PrimitiveConversion::bxShiftRPC_
private

Definition at line 83 of file PrimitiveConversion.h.

Referenced by configure(), and convert_rpc().

bool PrimitiveConversion::duplicateTheta_
private

Definition at line 87 of file PrimitiveConversion.h.

Referenced by configure().

int PrimitiveConversion::endcap_
private
bool PrimitiveConversion::fixME11Edges_
private

Definition at line 87 of file PrimitiveConversion.h.

Referenced by configure(), and convert_csc_details().

bool PrimitiveConversion::fixZonePhi_
private

Definition at line 87 of file PrimitiveConversion.h.

Referenced by configure(), and convert_csc_details().

const SectorProcessorLUT* PrimitiveConversion::lut_
private

Definition at line 79 of file PrimitiveConversion.h.

Referenced by configure(), and lut().

int PrimitiveConversion::sector_
private
const GeometryTranslator* PrimitiveConversion::tp_geom_
private

Definition at line 77 of file PrimitiveConversion.h.

Referenced by configure(), convert_csc(), convert_gem(), and convert_rpc().

bool PrimitiveConversion::useNewZones_
private

Definition at line 87 of file PrimitiveConversion.h.

Referenced by configure(), and get_fs_zone_code().

int PrimitiveConversion::verbose_
private
std::vector<int> PrimitiveConversion::zoneBoundaries_
private

Definition at line 85 of file PrimitiveConversion.h.

Referenced by configure(), and get_zone_code().

int PrimitiveConversion::zoneOverlap_
private

Definition at line 86 of file PrimitiveConversion.h.

Referenced by configure(), and get_zone_code().