CMS 3D CMS Logo

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