File indexing completed on 2023-06-23 23:12:03
0001 #include "EMTFUnpackerTools.h"
0002 #include "DataFormats/L1TMuon/interface/L1TMuonSubsystems.h"
0003
0004 namespace l1t {
0005 namespace stage2 {
0006 namespace emtf {
0007
0008 void ImportME(EMTFHit& _hit, const l1t::emtf::ME _ME, const int _endcap, const int _evt_sector) {
0009 _hit.set_endcap(_endcap == 1 ? 1 : -1);
0010 _hit.set_sector_idx(_endcap == 1 ? _evt_sector - 1 : _evt_sector + 5);
0011
0012 _hit.set_wire(_ME.Wire());
0013 _hit.set_strip(_ME.Strip());
0014 _hit.set_quality(_ME.Quality());
0015 _hit.set_pattern(_ME.CLCT_pattern());
0016 _hit.set_bend((_ME.LR() == 1) ? 1 : -1);
0017 _hit.set_valid(_ME.VP());
0018 _hit.set_sync_err(_ME.SE());
0019 _hit.set_bx(_ME.TBIN() - 3);
0020 _hit.set_bc0(_ME.BC0());
0021 _hit.set_subsystem(l1tmu::kCSC);
0022
0023
0024
0025 _hit.set_strip_quart_bit(_ME.Quarter_strip());
0026 _hit.set_strip_eighth_bit(_ME.Eighth_strip());
0027 _hit.set_slope(_ME.Slope());
0028 _hit.set_pattern_run3(_ME.Run3_pattern());
0029
0030
0031 _hit.set_muon_shower_inTime(_ME.MUS_inTime());
0032 _hit.set_muon_shower_outOfTime(_ME.MUS_outOfTime());
0033 _hit.set_muon_shower_valid(_ME.MUSV());
0034
0035 _hit.set_ring(L1TMuonEndCap::calc_ring(_hit.Station(), _hit.CSC_ID(), _hit.Strip()));
0036 _hit.set_chamber(
0037 L1TMuonEndCap::calc_chamber(_hit.Station(), _hit.Sector(), _hit.Subsector(), _hit.Ring(), _hit.CSC_ID()));
0038
0039 _hit.SetCSCDetId(_hit.CreateCSCDetId());
0040
0041
0042
0043
0044
0045
0046 }
0047
0048 void ImportRPC(EMTFHit& _hit, const l1t::emtf::RPC _RPC, const int _endcap, const int _evt_sector) {
0049 _hit.set_endcap(_endcap == 1 ? 1 : -1);
0050 _hit.set_sector_idx(_endcap == 1 ? _evt_sector - 1 : _evt_sector + 5);
0051
0052 _hit.set_phi_fp(_RPC.Phi() * 4);
0053 _hit.set_theta_fp(_RPC.Theta() * 4);
0054 _hit.set_bx(_RPC.TBIN() - 3);
0055 _hit.set_valid(_RPC.VP());
0056 _hit.set_bc0(_RPC.BC0());
0057 _hit.set_subsystem(l1tmu::kRPC);
0058
0059 _hit.SetRPCDetId(_hit.CreateRPCDetId());
0060
0061
0062
0063
0064 _hit.set_phi_loc(L1TMuonEndCap::calc_phi_loc_deg(_hit.Phi_fp()));
0065 _hit.set_phi_glob(L1TMuonEndCap::calc_phi_glob_deg(_hit.Phi_loc(), _evt_sector));
0066 _hit.set_theta(L1TMuonEndCap::calc_theta_deg_from_int(_hit.Theta_fp()));
0067 _hit.set_eta(L1TMuonEndCap::calc_eta_from_theta_deg(_hit.Theta(), _hit.Endcap()));
0068
0069
0070
0071
0072 }
0073
0074 void ImportGEM(EMTFHit& _hit, const l1t::emtf::GEM& _GEM, const int _endcap, const int _evt_sector) {
0075 constexpr uint8_t GEM_MAX_CLUSTERS_PER_LAYER = 8;
0076 _hit.set_endcap(_endcap == 1 ? 1 : -1);
0077 _hit.set_sector_idx(_endcap == 1 ? _evt_sector - 1 : _evt_sector + 5);
0078
0079 _hit.set_pad(_GEM.Pad());
0080 _hit.set_pad_hi(_GEM.Pad() + (_GEM.ClusterSize() - 1));
0081 _hit.set_pad_low(_GEM.Pad());
0082 _hit.set_partition(_GEM.Partition());
0083
0084 _hit.set_layer(_GEM.ClusterID() < GEM_MAX_CLUSTERS_PER_LAYER ? 0 : 1);
0085 _hit.set_cluster_size(_GEM.ClusterSize());
0086 _hit.set_cluster_id(_GEM.ClusterID());
0087
0088 _hit.set_bx(_GEM.TBIN() - 3);
0089 _hit.set_valid(_GEM.VP());
0090 _hit.set_bc0(_GEM.BC0());
0091 _hit.set_subsystem(l1tmu::kGEM);
0092
0093 _hit.set_ring(1);
0094
0095
0096 _hit.SetGEMDetId(_hit.CreateGEMDetId());
0097
0098
0099
0100
0101
0102 }
0103
0104 void ImportSP(EMTFTrack& _track, const l1t::emtf::SP _SP, const int _endcap, const int _evt_sector) {
0105 _track.set_endcap((_endcap == 1) ? 1 : -1);
0106 _track.set_sector(_evt_sector);
0107 _track.set_sector_idx((_endcap == 1) ? _evt_sector - 1 : _evt_sector + 5);
0108 _track.set_mode(_SP.Mode());
0109 _track.set_mode_inv((((_SP.Mode() >> 0) & 1) << 3) | (((_SP.Mode() >> 1) & 1) << 2) |
0110 (((_SP.Mode() >> 2) & 1) << 1) | (((_SP.Mode() >> 3) & 1) << 0));
0111 _track.set_charge((_SP.C() == 1) ? -1 : 1);
0112 _track.set_bx(_SP.TBIN() - 3);
0113 _track.set_phi_fp(_SP.Phi_full());
0114 _track.set_phi_loc(L1TMuonEndCap::calc_phi_loc_deg(_SP.Phi_full()));
0115 _track.set_phi_glob(L1TMuonEndCap::calc_phi_glob_deg(_track.Phi_loc(), _track.Sector()));
0116 _track.set_eta(L1TMuonEndCap::calc_eta(_SP.Eta_GMT()));
0117 _track.set_pt((_SP.Pt_GMT() - 1) * 0.5);
0118 _track.set_pt_dxy((_SP.Pt_dxy_GMT() - 1));
0119
0120 _track.set_gmt_pt(_SP.Pt_GMT());
0121 _track.set_gmt_pt_dxy(_SP.Pt_dxy_GMT());
0122 _track.set_gmt_dxy(_SP.Dxy_GMT());
0123 _track.set_gmt_phi(_SP.Phi_GMT());
0124 _track.set_gmt_eta(_SP.Eta_GMT());
0125 _track.set_gmt_quality(_SP.Quality_GMT());
0126 _track.set_gmt_charge(_SP.C());
0127 _track.set_gmt_charge_valid(_SP.VC());
0128
0129 EMTFPtLUT _lut = {};
0130 _lut.address = _SP.Pt_LUT_addr();
0131 _track.set_PtLUT(_lut);
0132
0133
0134
0135
0136 }
0137
0138 }
0139 }
0140 }