CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
emtf::phase2::CSCTPConverter Class Reference

#include <CSCTPConverter.h>

Inheritance diagram for emtf::phase2::CSCTPConverter:
emtf::phase2::TPConverter

Public Member Functions

void convert (const TriggerPrimitive &, const TPInfo &, EMTFHit &) const final
 
 CSCTPConverter (const EMTFContext &, const int &, const int &)
 
 ~CSCTPConverter () override=default
 
- Public Member Functions inherited from emtf::phase2::TPConverter
 TPConverter ()=default
 
virtual ~TPConverter ()=default
 

Private Attributes

const EMTFContextcontext_
 
int endcap_
 
int sector_
 

Detailed Description

Definition at line 13 of file CSCTPConverter.h.

Constructor & Destructor Documentation

◆ CSCTPConverter()

CSCTPConverter::CSCTPConverter ( const EMTFContext context,
const int &  endcap,
const int &  sector 
)
explicit

◆ ~CSCTPConverter()

emtf::phase2::CSCTPConverter::~CSCTPConverter ( )
overridedefault

Member Function Documentation

◆ convert()

void CSCTPConverter::convert ( const TriggerPrimitive tp,
const TPInfo tp_info,
EMTFHit hit 
) const
finalvirtual

Implements emtf::phase2::TPConverter.

Definition at line 21 of file CSCTPConverter.cc.

References emtf::phase2::TPInfo::bx, emtf::phase2::tp::calcPhiInt(), emtf::phase2::tp::calcThetaInt(), emtf::phase2::TPInfo::chamber, ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), context_, emtf::phase2::TPInfo::csc_facing, emtf::phase2::TPInfo::csc_first_wire, emtf::phase2::TPInfo::csc_id, emtf::phase2::TPInfo::csc_second_wire, emtf_assert, emtf::phase2::TPInfo::endcap_pm, emtf::phase2::TPInfo::flag_substitute, emtf::phase2::EMTFContext::geometry_translator_, L1TMuon::GeometryTranslator::getGlobalPoint(), emtf::phase2::data::ZoneLut::getZones(), emtf::phase2::TPInfo::hit_id, emtf::phase2::EMTFContext::host_lut_, emtf::phase2::TPInfo::ilink, L1TMuon::kCSC, emtf::phase2::kNeighbor, emtf::phase2::csc::kRear, emtf::phase2::TPInfo::layer, emtf::phase2::data::HostLut::lookup(), emtf::phase2::data::SiteLut::lookup(), PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), emtf::phase2::tp::radToDeg(), emtf::phase2::TPInfo::ring, sector_, emtf::phase2::TPInfo::segment_id, emtf::phase2::TPInfo::selection, emtf::phase2::EMTFContext::site_lut_, emtf::phase2::TPInfo::station, emtf::phase2::TPInfo::subsector, PV3DBase< T, PVType, FrameType >::theta(), cmsswSequenceInfo::tp, Geom::Phi< T1, Range >::value(), PV3DBase< T, PVType, FrameType >::z(), and emtf::phase2::EMTFContext::zone_lut_.

21  {
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
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

Member Data Documentation

◆ context_

const EMTFContext& emtf::phase2::CSCTPConverter::context_
private

Definition at line 22 of file CSCTPConverter.h.

Referenced by convert().

◆ endcap_

int emtf::phase2::CSCTPConverter::endcap_
private

Definition at line 24 of file CSCTPConverter.h.

◆ sector_

int emtf::phase2::CSCTPConverter::sector_
private

Definition at line 24 of file CSCTPConverter.h.

Referenced by convert().