CMS 3D CMS Logo

CSCTPConverter.cc
Go to the documentation of this file.
2 
13 
15 
16 using namespace emtf::phase2;
17 
19  : context_(context), endcap_(endcap), sector_(sector) {}
20 
21 void CSCTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, EMTFHit& hit) const {
22  // Unpack Id
23  const auto& tp_hit_id = tp_info.hit_id;
24  const auto& tp_segment_id = tp_info.segment_id;
25 
26  // Unpack trigger primitive
27  const auto& tp_det_id = tp.detId<CSCDetId>();
28  const auto& tp_data = tp.getCSCData();
29 
30  // Unpack detector info
31  const auto tp_subsystem = L1TMuon::kCSC;
32 
33  const int tp_raw_id = tp_det_id.rawId();
34 
35  const int tp_endcap_pm = tp_info.endcap_pm;
36  const int tp_subsector = tp_info.subsector;
37  const int tp_chamber = tp_info.chamber;
38  const int tp_station = tp_info.station;
39  const int tp_ring = tp_info.ring;
40  const int tp_layer = tp_info.layer;
41 
42  const int tp_csc_id = tp_info.csc_id;
43  const auto tp_csc_facing = tp_info.csc_facing;
44 
45  // Unpack data
46  const int tp_strip = tp_data.strip;
47  const int tp_strip_quart_bit = tp_data.strip_quart_bit;
48  const int tp_strip_eighth_bit = tp_data.strip_eighth_bit;
49  const int tp_strip_quart = tp_data.strip_quart;
50  const int tp_strip_eighth = tp_data.strip_eighth;
51 
52  const int tp_wire1 = tp_info.csc_first_wire;
53  const int tp_wire2 = tp_info.csc_second_wire;
54 
55  int tp_bend;
56  const int tp_slope = tp_data.slope;
57 
58  const int tp_bx = tp_info.bx;
59  const int tp_subbx = 0; // no fine resolution timing
60  const float tp_time = 0; // no fine resolution timing. Note: Check with Efe, Jia Fu gets this from digi directly.
61 
62  const auto tp_selection = tp_info.selection;
63 
64  const int tp_pattern = tp_data.pattern;
65  const int tp_quality = 6;
66 
67  // Apply CSC Run 2 pattern -> bend conversion
68  // Override tp_bend
69  constexpr int tp_bend_lut_size = 11;
70  constexpr int tp_bend_lut[tp_bend_lut_size] = {-5, 5, -4, 4, -3, 3, -2, 2, -1, 1, 0};
71  emtf_assert(tp_pattern < tp_bend_lut_size);
72  tp_bend = tp_bend_lut[tp_pattern];
73  tp_bend *= tp_endcap_pm; // sign flip depending on endcap
74 
75  // ID scheme used in FW
76  const int tp_ilink = tp_info.ilink;
77 
78  // Get Global Coordinates
80  const float glob_phi_w1 = tp::radToDeg(gp_w1.phi().value());
81  const float glob_theta_w1 = tp::radToDeg(gp_w1.theta().value());
82  const double glob_rho_w1 = gp_w1.perp();
83  const double glob_z_w1 = gp_w1.z();
84 
85  // Calculate EMTF Values
86  const int emtf_phi_w1 = tp::calcPhiInt(sector_, glob_phi_w1);
87  const int emtf_bend_w1 = std::clamp(tp_bend * 4, -16, 15); // 5-bit, signed
88  const int emtf_theta_w1 = tp::calcThetaInt(tp_endcap_pm, glob_theta_w1);
89  const int emtf_qual_w1 = std::clamp(tp_quality, 0, 15); // 4-bit, unsigned
90  const int emtf_site_w1 = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring});
91  const int emtf_host_w1 = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring});
92  const int emtf_zones_w1 = context_.zone_lut_.getZones(emtf_host_w1, emtf_theta_w1);
93 
94  // Calculated Ambiguous Info
95  int emtf_theta_w2 = 0;
96  int emtf_qual_w2 = tp_pattern;
97 
98  if (tp_wire2 > -1) {
99  auto tp_w2 = tp;
100 
101  tp_w2.accessCSCData().keywire = tp_wire2;
102 
103  const GlobalPoint& gp_w2 = this->context_.geometry_translator_.getGlobalPoint(tp_w2);
104  const double glob_theta_w2 = tp::radToDeg(gp_w2.theta().value());
105 
106  emtf_theta_w2 = tp::calcThetaInt(tp_endcap_pm, glob_theta_w2);
107  }
108 
109  emtf_assert((0 <= emtf_phi_w1) and (emtf_phi_w1 < 5040));
110  emtf_assert((1 <= emtf_theta_w1) and (emtf_theta_w1 < 128));
111  emtf_assert((0 <= emtf_theta_w2) and (emtf_theta_w2 < 128));
112 
113  // Get flags
114  const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor);
115  const bool tp_flag_substitute = tp_info.flag_substitute;
116  const bool tp_flag_valid = tp_data.valid;
117 
118  // Set properties
119  hit.setId(tp_hit_id);
120 
121  hit.setRawDetId(tp_raw_id);
122  hit.setSubsystem(L1TMuon::kCSC);
123  hit.setEndcap(tp_endcap_pm);
124  hit.setSector(sector_);
125  hit.setSubsector(tp_subsector);
126  hit.setStation(tp_station);
127  hit.setRing(tp_ring);
128  hit.setLayer(tp_layer);
129  hit.setChamber(tp_chamber);
130 
131  hit.setCscId(tp_csc_id);
132  hit.setCscFR(tp_csc_facing == csc::Facing::kRear);
133 
134  hit.setStrip(tp_strip);
135  hit.setStripLo(tp_strip);
136  hit.setStripHi(tp_strip);
137  hit.setStripQuart(tp_strip_quart);
138  hit.setStripEighth(tp_strip_eighth);
139  hit.setStripQuartBit(tp_strip_quart_bit);
140  hit.setStripEighthBit(tp_strip_eighth_bit);
141 
142  hit.setWire1(tp_wire1);
143  hit.setWire2(tp_wire2);
144 
145  hit.setBend(tp_bend);
146  hit.setSlope(tp_slope);
147 
148  hit.setBx(tp_bx);
149  hit.setSubbx(tp_subbx);
150 
151  hit.setQuality(tp_quality);
152  hit.setPattern(tp_pattern);
153 
154  hit.setGlobPhi(glob_phi_w1);
155  hit.setGlobTheta(glob_theta_w1);
156  hit.setGlobPerp(glob_rho_w1);
157  hit.setGlobZ(glob_z_w1);
158  hit.setGlobTime(tp_time);
159 
160  hit.setEmtfChamber(tp_ilink);
161  hit.setEmtfSegment(tp_segment_id);
162  hit.setEmtfPhi(emtf_phi_w1);
163  hit.setEmtfBend(emtf_bend_w1);
164  hit.setEmtfTheta1(emtf_theta_w1);
165  hit.setEmtfTheta2(emtf_theta_w2);
166  hit.setEmtfQual1(emtf_qual_w1);
167  hit.setEmtfQual2(emtf_qual_w2);
168  hit.setEmtfSite(emtf_site_w1);
169  hit.setEmtfHost(emtf_host_w1);
170  hit.setEmtfZones(emtf_zones_w1);
171 
172  hit.setFlagNeighbor(tp_flag_neighbor);
173  hit.setFlagSubstitute(tp_flag_substitute);
174  hit.setFlagValid(tp_flag_valid);
175 }
T perp() const
Definition: PV3DBase.h:69
T z() const
Definition: PV3DBase.h:61
GlobalPoint getGlobalPoint(const TriggerPrimitive &) const
csc::Facing csc_facing
Definition: TPrimitives.h:39
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
const int & lookup(const std::tuple< int, int, int > &) const
Definition: SiteLut.cc:45
int calcThetaInt(int, float)
Definition: TPUtils.cc:64
CSCTPConverter(const EMTFContext &, const int &, const int &)
TPSelection selection
Definition: TPrimitives.h:21
int calcPhiInt(int, float)
Definition: TPUtils.cc:113
data::HostLut host_lut_
Definition: EMTFContext.h:52
const EMTFContext & context_
int getZones(const int &, const int &) const
Definition: ZoneLut.cc:55
float radToDeg(float rad)
Definition: TPUtils.cc:14
data::ZoneLut zone_lut_
Definition: EMTFContext.h:53
const int & lookup(const std::tuple< int, int, int > &) const
Definition: HostLut.cc:45
#define emtf_assert(expr)
Definition: DebugTools.h:18
data::SiteLut site_lut_
Definition: EMTFContext.h:51
GeometryTranslator geometry_translator_
Definition: EMTFContext.h:36
T1 value() const
Explicit access to value in case implicit conversion not OK.
Definition: Phi.h:75
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
void convert(const TriggerPrimitive &, const TPInfo &, EMTFHit &) const final