CMS 3D CMS Logo

RPCTPConverter.cc
Go to the documentation of this file.
2 
15 
17 
18 using namespace emtf::phase2;
19 
21  : context_(context), endcap_(endcap), sector_(sector) {}
22 
23 void RPCTPConverter::convert(const TriggerPrimitive& tp, const TPInfo& tp_info, EMTFHit& hit) const {
24  // Unpack Id
25  const auto& tp_hit_id = tp_info.hit_id;
26  const auto& tp_segment_id = tp_info.segment_id;
27 
28  // Unpack trigger primitive
29  const auto& tp_det_id = tp.detId<RPCDetId>();
30  const auto& tp_data = tp.getRPCData();
31 
32  // Unpack detector info
33  const auto tp_subsystem = L1TMuon::kRPC;
34 
35  const int tp_raw_id = tp_det_id.rawId();
36 
37  const int tp_endcap_pm = tp_info.endcap_pm;
38  const int tp_subsector = tp_info.subsector;
39  const int tp_station = tp_info.station;
40  const int tp_ring = tp_info.ring;
41  const int tp_roll = tp_info.roll;
42  const int tp_layer = tp_info.layer;
43  const int tp_chamber = tp_info.chamber;
44 
45  const auto tp_csc_facing = tp_info.csc_facing;
46  const int tp_csc_id = tp_info.csc_id;
47  const auto tp_rpc_type = tp_info.rpc_type;
48 
49  // Unpack data
50  const int tp_strip = (tp_data.strip_low + tp_data.strip_hi) / 2; // in full-strip unit
51  const int tp_strip_lo = tp_data.strip_low;
52  const int tp_strip_hi = tp_data.strip_hi;
53  const int tp_clus_width = (tp_strip_hi - tp_strip_lo + 1);
54 
55  int tp_bend = 0; // not applicable
56 
57  const int tp_bx = tp_info.bx;
58  const float tp_time = tp_data.time;
59  float tp_subbx_f32 = tp_time - (std::round(tp_time / 25.) * 25.); // reduce range to [-12.5,12.5] ns
60  int tp_subbx = static_cast<int>(std::round(tp_subbx_f32 * 16. / 25.));
61  tp_subbx = std::clamp(tp_subbx, -8, 7); // 4-bit, signed
62  int tp_bx_check = static_cast<int>(std::round(tp_time / 25.));
63 
64  // Not sure why sometimes digi.time() returns 0?
65  emtf_assert(((not(std::abs(tp_time) < 1e-6)) and (tp_bx == tp_bx_check)) or (std::abs(tp_time) < 1e-6));
66 
67  const auto tp_selection = tp_info.selection;
68 
69  // Use cluster width as quality.
70  int tp_quality;
71 
72  if (tp_rpc_type == rpc::Type::kiRPC) {
73  tp_quality = tp_clus_width;
74  } else {
75  tp_quality = tp_clus_width * 3 / 2; // RPC strip pitch is 1.5 times the iRPC strip pitch.
76  }
77 
78  // ID scheme used in FW
79  const int tp_ilink = tp_info.ilink;
80 
81  // Get Global Coordinates
82  float glob_phi;
83  float glob_theta;
84  double glob_rho;
85  double glob_z;
86 
87  if (tp_rpc_type == rpc::Type::kiRPC) {
88  // Handle iRPC Coordinates
89  const RPCRoll* roll =
90  dynamic_cast<const RPCRoll*>(this->context_.geometry_translator_.getRPCGeometry().roll(tp_det_id));
91  const GlobalPoint& irpc_gp = roll->surface().toGlobal(LocalPoint(tp_data.x, tp_data.y, 0));
92 
93  glob_phi = tp::radToDeg(irpc_gp.phi().value());
94  glob_theta = tp::radToDeg(irpc_gp.theta().value());
95  glob_rho = irpc_gp.perp();
96  glob_z = irpc_gp.z();
97  } else {
98  // Handle RPC Coordinates
100  glob_phi = tp::radToDeg(gp.phi().value());
101  glob_theta = tp::radToDeg(gp.theta().value());
102  glob_rho = gp.perp();
103  glob_z = gp.z();
104  }
105 
106  // Calculate EMTF Values
107  const int emtf_phi = tp::calcPhiInt(sector_, glob_phi);
108  const int emtf_bend = 0;
109  const int emtf_theta = tp::calcThetaInt(tp_endcap_pm, glob_theta);
110  const int emtf_qual = 0;
111  const int emtf_site = context_.site_lut_.lookup({tp_subsystem, tp_station, tp_ring});
112  const int emtf_host = context_.host_lut_.lookup({tp_subsystem, tp_station, tp_ring});
113  const int emtf_zones = context_.zone_lut_.getZones(emtf_host, emtf_theta);
114 
115  emtf_assert((0 <= emtf_phi) and (emtf_phi < 5040));
116  emtf_assert((1 <= emtf_theta) and (emtf_theta < 128));
117 
118  // Get flags
119  const bool tp_flag_neighbor = (tp_selection == TPSelection::kNeighbor);
120  const bool tp_flag_substitute = tp_info.flag_substitute;
121  const bool tp_flag_valid = tp_data.valid;
122 
123  // Set all the variables
124  hit.setId(tp_hit_id);
125 
126  hit.setRawDetId(tp_raw_id);
127  hit.setSubsystem(tp_subsystem);
128  hit.setEndcap(tp_endcap_pm);
129  hit.setSector(sector_);
130  hit.setSubsector(tp_subsector);
131  hit.setStation(tp_station);
132  hit.setRing(tp_ring);
133  hit.setLayer(tp_layer);
134  hit.setChamber(tp_chamber);
135 
136  hit.setCscId(tp_csc_id);
137  hit.setCscFR(tp_csc_facing == csc::Facing::kRear);
138 
139  hit.setStrip(tp_strip);
140  hit.setStripLo(tp_strip_lo);
141  hit.setStripHi(tp_strip_hi);
142 
143  hit.setWire1(tp_roll);
144  hit.setWire2(0);
145 
146  hit.setBend(tp_bend);
147 
148  hit.setBx(tp_bx);
149  hit.setSubbx(tp_subbx);
150 
151  hit.setQuality(tp_quality);
152  hit.setPattern(0);
153 
154  hit.setGlobPhi(glob_phi);
155  hit.setGlobTheta(glob_theta);
156  hit.setGlobPerp(glob_rho);
157  hit.setGlobZ(glob_z);
158  hit.setGlobTime(tp_time);
159 
160  hit.setEmtfChamber(tp_ilink);
161  hit.setEmtfSegment(tp_segment_id);
162  hit.setEmtfPhi(emtf_phi);
163  hit.setEmtfBend(emtf_bend);
164  hit.setEmtfTheta1(emtf_theta);
165  hit.setEmtfTheta2(0);
166  hit.setEmtfQual1(emtf_qual);
167  hit.setEmtfQual2(0);
168  hit.setEmtfSite(emtf_site);
169  hit.setEmtfHost(emtf_host);
170  hit.setEmtfZones(emtf_zones);
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
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
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 EMTFContext & context_
const int & lookup(const std::tuple< int, int, int > &) const
Definition: SiteLut.cc:45
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
Definition: RPCGeometry.cc:50
int calcThetaInt(int, float)
Definition: TPUtils.cc:64
TPSelection selection
Definition: TPrimitives.h:21
int calcPhiInt(int, float)
Definition: TPUtils.cc:113
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
data::HostLut host_lut_
Definition: EMTFContext.h:52
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int getZones(const int &, const int &) const
Definition: ZoneLut.cc:55
const RPCGeometry & getRPCGeometry() const
RPCTPConverter(const EMTFContext &, const int &, const int &)
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