CMS 3D CMS Logo

MicroGMTConverter.cc
Go to the documentation of this file.
2 
4 
6 
7 void MicroGMTConverter::convert(const int global_event_BX,
8  const EMTFTrack& in_track,
9  l1t::RegionalMuonCand& out_cand) const {
11  int sector = in_track.Sector() - 1;
12 
13  out_cand.setHwPt(in_track.GMT_pt());
14  out_cand.setHwPhi(in_track.GMT_phi());
15  out_cand.setHwEta(in_track.GMT_eta());
16  out_cand.setHwSign(in_track.GMT_charge());
17  out_cand.setHwSignValid(in_track.GMT_charge_valid());
18  out_cand.setHwQual(in_track.GMT_quality());
19  out_cand.setHwHF(false); // EMTF: halo -> 1
20  out_cand.setTFIdentifiers(sector, tftype);
21 
22  const EMTFPtLUT& ptlut_data = in_track.PtLUT();
23 
24  // Form track sub addresses
25  int me1_ch_id =
26  (ptlut_data.bt_vi[0] == 0 && ptlut_data.bt_vi[1] != 0) ? ptlut_data.bt_ci[1] + 16 : ptlut_data.bt_ci[0];
27  int me2_ch_id = ptlut_data.bt_ci[2];
28  int me3_ch_id = ptlut_data.bt_ci[3];
29  int me4_ch_id = ptlut_data.bt_ci[4];
30 
31  int me1_seg_id = (ptlut_data.bt_vi[0] == 0 && ptlut_data.bt_vi[1] != 0) ? ptlut_data.bt_si[1] : ptlut_data.bt_si[0];
32  int me2_seg_id = ptlut_data.bt_si[2];
33  int me3_seg_id = ptlut_data.bt_si[3];
34  int me4_seg_id = ptlut_data.bt_si[4];
35 
36  auto get_gmt_chamber_me1 = [](int ch) {
37  int gmt_ch = 0;
38  if (ch == 10)
39  gmt_ch = 1;
40  else if (ch == 11)
41  gmt_ch = 2;
42  else if (ch == 12)
43  gmt_ch = 3;
44  else if (ch == 3 + 16)
45  gmt_ch = 4;
46  else if (ch == 6 + 16)
47  gmt_ch = 5;
48  else if (ch == 9 + 16)
49  gmt_ch = 6;
50  return gmt_ch;
51  };
52 
53  auto get_gmt_chamber = [](int ch) {
54  int gmt_ch = 0;
55  if (ch == 10)
56  gmt_ch = 1;
57  else if (ch == 11)
58  gmt_ch = 2;
59  else if (ch == 3)
60  gmt_ch = 3;
61  else if (ch == 9)
62  gmt_ch = 4;
63  return gmt_ch;
64  };
65 
66  // Truncate kBX to 11 bits and offset by 25 from global event BX in EMTF firmware
67  int EMTF_kBX = (abs(global_event_BX) % 2048) - 25 + in_track.BX();
68  if (EMTF_kBX < 0)
69  EMTF_kBX += 2048;
70 
72  out_cand.setTrackSubAddress(l1t::RegionalMuonCand::kME1Ch, get_gmt_chamber_me1(me1_ch_id));
74  out_cand.setTrackSubAddress(l1t::RegionalMuonCand::kME2Ch, get_gmt_chamber(me2_ch_id));
76  out_cand.setTrackSubAddress(l1t::RegionalMuonCand::kME3Ch, get_gmt_chamber(me3_ch_id));
78  out_cand.setTrackSubAddress(l1t::RegionalMuonCand::kME4Ch, get_gmt_chamber(me4_ch_id));
81 }
82 
84  const EMTFTrackCollection& in_tracks,
85  l1t::RegionalMuonCandBxCollection& out_cands) const {
86  int gmtMinBX = -2;
87  int gmtMaxBX = +2;
88 
89  out_cands.clear();
90  out_cands.setBXRange(gmtMinBX, gmtMaxBX);
91 
92  for (const auto& in_track : in_tracks) {
93  int bx = in_track.BX();
94 
95  if (gmtMinBX <= bx && bx <= gmtMaxBX) {
96  l1t::RegionalMuonCand out_cand;
97 
98  convert(iEvent.bunchCrossing(), in_track, out_cand);
99  out_cands.push_back(bx, out_cand);
100  }
101  }
102 
103  // Sort by processor to match uGMT unpacked order
104  emtf::sort_uGMT_muons(out_cands);
105 }
106 
107 namespace emtf {
108 
110  int minBX = cands.getFirstBX();
111  int maxBX = cands.getLastBX();
112  int emtfMinProc = 0; // ME+ sector 1
113  int emtfMaxProc = 11; // ME- sector 6
114 
115  // New collection, sorted by processor to match uGMT unpacked order
116  auto sortedCands = std::make_unique<l1t::RegionalMuonCandBxCollection>();
117  sortedCands->clear();
118  sortedCands->setBXRange(minBX, maxBX);
119  for (int iBX = minBX; iBX <= maxBX; ++iBX) {
120  for (int proc = emtfMinProc; proc <= emtfMaxProc; proc++) {
122  ++cand) {
123  int cand_proc = cand->processor();
124  if (cand->trackFinderType() == l1t::tftype::emtf_neg)
125  cand_proc += 6;
126  if (cand_proc != proc)
127  continue;
128  sortedCands->push_back(iBX, *cand);
129  }
130  }
131  }
132 
133  // Return sorted collection
134  std::swap(cands, *sortedCands);
135  sortedCands.reset();
136  }
137 
138 } // End namespace emtf
l1t::RegionalMuonCand::kME1Ch
Definition: RegionalMuonCand.h:32
l1t::RegionalMuonCand::kME3Seg
Definition: RegionalMuonCand.h:35
l1t::emtf_neg
Definition: RegionalMuonCandFwd.h:8
MicroGMTConverter::convert_all
void convert_all(const edm::Event &iEvent, const EMTFTrackCollection &in_tracks, l1t::RegionalMuonCandBxCollection &out_cands) const
Definition: MicroGMTConverter.cc:83
simKBmtfStubs_cfi.minBX
minBX
Definition: simKBmtfStubs_cfi.py:9
l1t::EMTFTrack::PtLUT
EMTFPtLUT PtLUT() const
Definition: EMTFTrack.h:111
l1t::RegionalMuonCand::kME2Ch
Definition: RegionalMuonCand.h:34
l1t::tftype
tftype
Definition: RegionalMuonCandFwd.h:8
l1t::RegionalMuonCand::setHwSign
void setHwSign(int bits)
Set charge sign bit (charge = (-1)^(sign))
Definition: RegionalMuonCand.h:136
l1t::EMTFPtLUT
Definition: EMTFTrack.h:16
l1t::RegionalMuonCand::kBX
Definition: RegionalMuonCand.h:40
BXVector< RegionalMuonCand >::const_iterator
std::vector< RegionalMuonCand >::const_iterator const_iterator
Definition: BXVector.h:18
l1t::EMTFPtLUT::bt_si
uint16_t bt_si[5]
Definition: EMTFTrack.h:31
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
l1t::RegionalMuonCand::kME1Seg
Definition: RegionalMuonCand.h:31
l1t::EMTFTrack::Sector
int Sector() const
Definition: EMTFTrack.h:144
BXVector< RegionalMuonCand >
l1t::EMTFTrack::BX
int BX() const
Definition: EMTFTrack.h:154
l1t::EMTFPtLUT::bt_vi
uint16_t bt_vi[5]
Definition: EMTFTrack.h:28
EMTFTrackCollection
l1t::EMTFTrackCollection EMTFTrackCollection
Definition: Common.h:27
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
MicroGMTConverter::~MicroGMTConverter
~MicroGMTConverter()
Definition: MicroGMTConverter.cc:5
l1t::RegionalMuonCand::setTFIdentifiers
void setTFIdentifiers(int processor, tftype trackFinder)
Set the processor ID, track-finder type. From these two, the link is set.
Definition: RegionalMuonCand.cc:5
emtf
Definition: Event.h:15
l1t::EMTFTrack::GMT_phi
int GMT_phi() const
Definition: EMTFTrack.h:169
l1t::EMTFTrack::Endcap
int Endcap() const
Definition: EMTFTrack.h:143
BXVector::clear
void clear()
l1t::RegionalMuonCand::setHwPt
void setHwPt(int bits)
Set compressed pT as transmitted by hardware LSB = 0.5 (9 bits)
Definition: RegionalMuonCand.h:126
l1t::RegionalMuonCand::setHwHF
void setHwHF(bool bit)
Set HF (halo / fine eta) bit (EMTF: halo -> 1; BMTF: fine eta -> 1)
Definition: RegionalMuonCand.h:142
l1t::EMTFTrack
Definition: EMTFTrack.h:34
l1t::EMTFTrack::GMT_quality
int GMT_quality() const
Definition: EMTFTrack.h:171
ValidateTausOnZEEFastSim_cff.proc
proc
Definition: ValidateTausOnZEEFastSim_cff.py:6
MicroGMTConverter::MicroGMTConverter
MicroGMTConverter()
Definition: MicroGMTConverter.cc:3
emtf::sort_uGMT_muons
void sort_uGMT_muons(l1t::RegionalMuonCandBxCollection &cands)
Definition: MicroGMTConverter.cc:109
l1t::RegionalMuonCand::setHwEta
void setHwEta(int bits)
Set compressed eta as transmitted by hardware LSB = 0.010875 (9 bits)
Definition: RegionalMuonCand.h:134
cand
Definition: decayParser.h:34
iEvent
int iEvent
Definition: GenABIO.cc:224
MicroGMTConverter.h
simKBmtfStubs_cfi.maxBX
maxBX
Definition: simKBmtfStubs_cfi.py:10
l1t::RegionalMuonCand::kME4Seg
Definition: RegionalMuonCand.h:37
l1t::RegionalMuonCand::setTrackSubAddress
void setTrackSubAddress(bmtfAddress subAddress, int value)
Set a part of the muon candidates track address; specialised for BMTF.
Definition: RegionalMuonCand.h:152
l1t::RegionalMuonCand::setHwQual
void setHwQual(int bits)
Set compressed quality code as transmitted by hardware (4 bits)
Definition: RegionalMuonCand.h:140
l1t::EMTFTrack::Track_num
int Track_num() const
Definition: EMTFTrack.h:174
l1t::RegionalMuonCand::setHwSignValid
void setHwSignValid(int bits)
Set whether charge measurement is valid (0 for high pT muons)
Definition: RegionalMuonCand.h:138
l1t::RegionalMuonCand::kTrkNum
Definition: RegionalMuonCand.h:39
l1t::emtf_pos
Definition: RegionalMuonCandFwd.h:8
HLT_2018_cff.cands
cands
Definition: HLT_2018_cff.py:13762
l1t::EMTFTrack::GMT_charge_valid
int GMT_charge_valid() const
Definition: EMTFTrack.h:173
l1t::RegionalMuonCand::kME2Seg
Definition: RegionalMuonCand.h:33
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
l1t::RegionalMuonCand::kME3Ch
Definition: RegionalMuonCand.h:36
l1t::RegionalMuonCand::setHwPhi
void setHwPhi(int bits)
Set compressed relative phi as transmitted by hardware LSB = 2*pi/576 (8 bits)
Definition: RegionalMuonCand.h:132
l1t::EMTFTrack::GMT_pt
int GMT_pt() const
Definition: EMTFTrack.h:168
BXVector::setBXRange
void setBXRange(int bxFirst, int bxLast)
edm::Event
Definition: Event.h:73
l1t::EMTFPtLUT::bt_ci
uint16_t bt_ci[5]
Definition: EMTFTrack.h:30
l1t::EMTFTrack::GMT_charge
int GMT_charge() const
Definition: EMTFTrack.h:172
BXVector::push_back
void push_back(int bx, T object)
l1t::EMTFTrack::GMT_eta
int GMT_eta() const
Definition: EMTFTrack.h:170
l1t::RegionalMuonCand
Definition: RegionalMuonCand.h:8
l1t::RegionalMuonCand::kME4Ch
Definition: RegionalMuonCand.h:38
MicroGMTConverter::convert
void convert(const int global_event_BX, const EMTFTrack &in_track, l1t::RegionalMuonCand &out_cand) const
Definition: MicroGMTConverter.cc:7