CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
Phase2L1TGMTFwdMuonTranslator Class Reference
Inheritance diagram for Phase2L1TGMTFwdMuonTranslator:
edm::stream::EDProducer<>

Public Member Functions

 Phase2L1TGMTFwdMuonTranslator (const edm::ParameterSet &)
 
 ~Phase2L1TGMTFwdMuonTranslator () override=default
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void associateStubs (l1t::SAMuon &, const l1t::MuonStubRefVector &)
 
l1t::SAMuon ConvertEMTFTrack (const l1t::phase2::EMTFTrack &track, const int bx_)
 
l1t::SAMuon Convertl1tMuon (const l1t::RegionalMuonCand &mu, const int bx_, bool isDisplaced=false)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
l1t::MuonStubRefVector selectLayerBX (const l1t::MuonStubRefVector &all, int bx, uint layer)
 

Private Attributes

edm::EDGetTokenT< l1t::phase2::EMTFTrackCollectionemtfTrackToken_
 
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollectionomtfTrackToken_
 
edm::EDGetTokenT< l1t::MuonStubCollectionstubToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 28 of file Phase2L1TGMTFwdMuonTranslator.cc.

Constructor & Destructor Documentation

◆ Phase2L1TGMTFwdMuonTranslator()

Phase2L1TGMTFwdMuonTranslator::Phase2L1TGMTFwdMuonTranslator ( const edm::ParameterSet iConfig)
explicit

Definition at line 60 of file Phase2L1TGMTFwdMuonTranslator.cc.

61  : stubToken_(consumes<l1t::MuonStubCollection>(iConfig.getParameter<edm::InputTag>("stubs"))),
62  omtfTrackToken_(consumes<l1t::RegionalMuonCandBxCollection>(iConfig.getParameter<edm::InputTag>("omtfTracks"))),
63  emtfTrackToken_(consumes<l1t::phase2::EMTFTrackCollection>(iConfig.getParameter<edm::InputTag>("emtfTracks"))) {
64  produces<std::vector<l1t::SAMuon> >("prompt").setBranchAlias("prompt");
65  produces<std::vector<l1t::SAMuon> >("displaced").setBranchAlias("displaced");
66 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< l1t::MuonStubCollection > stubToken_
edm::EDGetTokenT< l1t::phase2::EMTFTrackCollection > emtfTrackToken_
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollection > omtfTrackToken_

◆ ~Phase2L1TGMTFwdMuonTranslator()

Phase2L1TGMTFwdMuonTranslator::~Phase2L1TGMTFwdMuonTranslator ( )
overridedefault

Member Function Documentation

◆ associateStubs()

void Phase2L1TGMTFwdMuonTranslator::associateStubs ( l1t::SAMuon mu,
const l1t::MuonStubRefVector stubs 
)
private

Definition at line 219 of file Phase2L1TGMTFwdMuonTranslator.cc.

References spr::deltaEta, SiPixelRawToDigiRegional_cfi::deltaPhi, HLT_2024v14_cff::dPhi, mps_fire::i, nano_mu_digi_cff::layer, M_PI, amptDefaultParameters_cff::mu, selectLayerBX(), SimL1Emulator_cff::stubs, and parallelization::uint.

Referenced by produce().

219  {
220  for (unsigned int layer = 0; layer <= 4; ++layer) {
221  l1t::MuonStubRefVector selectedStubs = selectLayerBX(stubs, 0, layer);
222  int bestStubINT = -1;
223  float dPhi = 1000.0;
224  for (uint i = 0; i < selectedStubs.size(); ++i) {
225  const l1t::MuonStubRef& stub = selectedStubs[i];
226  float deltaPhi =
227  (stub->quality() & 0x1) ? stub->offline_coord1() - mu.p4().phi() : stub->offline_coord2() - mu.p4().phi();
228  if (deltaPhi > M_PI)
229  deltaPhi = deltaPhi - 2 * M_PI;
230  if (deltaPhi < -M_PI)
231  deltaPhi = deltaPhi + 2 * M_PI;
232  deltaPhi = fabs(deltaPhi);
233  float deltaEta = (stub->etaQuality() == 0 || (stub->etaQuality() & 0x1))
234  ? fabs(stub->offline_eta1() - mu.p4().eta())
235  : fabs(stub->offline_eta2() - mu.p4().eta());
236  if (deltaPhi < 0.3 && deltaEta < 0.3 && deltaPhi < dPhi) {
237  dPhi = deltaPhi;
238  bestStubINT = i;
239  }
240  }
241  if (bestStubINT >= 0) {
242  mu.addStub(selectedStubs[bestStubINT]);
243  }
244  }
245 }
l1t::MuonStubRefVector selectLayerBX(const l1t::MuonStubRefVector &all, int bx, uint layer)
static const double deltaEta
Definition: CaloConstants.h:8
std::vector< edm::Ref< MuonStubCollection > > MuonStubRefVector
Definition: MuonStub.h:44
#define M_PI

◆ ConvertEMTFTrack()

SAMuon Phase2L1TGMTFwdMuonTranslator::ConvertEMTFTrack ( const l1t::phase2::EMTFTrack track,
const int  bx_ 
)
private

Definition at line 247 of file Phase2L1TGMTFwdMuonTranslator.cc.

References Phase2L1GMT::BITSETA, Phase2L1GMT::BITSPHI, Phase2L1GMT::BITSPT, Phase2L1GMT::BITSSAD0, emtf::phase2::tp::calcPhiGlobRadFromLoc(), emtf::phase2::tp::calcPhiLocRadFromInt(), emtf::phase2::tp::calcThetaRadFromInt(), ALCARECOTkAlJpsiMuMu_cff::charge, d0, l1t::emtf_neg, l1t::emtf_pos, PVValHelper::eta, dqm-mbProfile::log, Phase2L1GMT::LSBeta, Phase2L1GMT::LSBphi, Phase2L1GMT::LSBpt, phi, DiDispStaMuonMonitor_cfi::pt, l1t::SAMuon::setTF(), funct::tan(), HLT_2024v14_cff::track, leptonTimeLifeInfo_common_cff::track_phi, and HLTMuonOfflineAnalyzer_cfi::z0.

Referenced by produce().

247  {
248  // Convert EMTF Phi and Theta to Global Phi and Eta
249  float track_phi =
251  float track_theta = emtf::phase2::tp::calcThetaRadFromInt(track.modelEta());
252  float track_eta = -1 * std::log(std::tan(track_theta / 2));
253 
254  track_theta *= track.endcap();
255  track_eta *= track.endcap();
256 
257  // Calculate Lorentz Vector
258  // Muon mass taken from L1Trigger/L1TMuon/plugins/L1TMuonProducer.cc
259  math::PtEtaPhiMLorentzVector p4(track.emtfPt() * LSBpt, track_eta, track_phi, 0.0);
260 
261  // Quantize Values
262  ap_uint<BITSSAQUAL> qual = track.emtfQuality(); // Quality provided by EMTF to GMT
263  int charge = track.emtfQ(); // EMTF uses the same convention
264  ap_uint<BITSGTPT> pt = track.emtfPt(); // Quantized by EMTF in the same units
265  ap_int<BITSGTPHI> phi = round(track_phi / LSBphi);
266  ap_int<BITSGTETA> eta = round(track_eta / LSBeta);
267  ap_int<BITSSAZ0> z0 = track.emtfZ0(); // Quantized by EMTF in the same units
268  ap_int<BITSSAD0> d0 = track.emtfD0(); // Quantized by EMTF in the same units
269 
270  //Here do not use the word format to GT but use the word format expected by GMT
271  int bstart = 0;
272  wordtype word(0);
273  bstart = wordconcat<wordtype>(word, bstart, 1, 1);
274  bstart = wordconcat<wordtype>(word, bstart, charge, 1);
275  bstart = wordconcat<wordtype>(word, bstart, pt, BITSPT);
276  bstart = wordconcat<wordtype>(word, bstart, phi, BITSPHI);
277  bstart = wordconcat<wordtype>(word, bstart, eta, BITSETA);
278  // bstart = wordconcat<wordtype>(word, bstart, z0, BITSSAZ0); NOT YET SUPPORTED BY GMT
279  bstart = wordconcat<wordtype>(word, bstart, d0, BITSSAD0);
280  bstart = wordconcat<wordtype>(
281  word, bstart, qual, 8); //FOR NOW 8 bits to be efficienct with Ghost busting. THIS IS ***NOT*** THE FINAL QUALITY
282 
283  SAMuon samuon(p4, charge, pt.to_uint(), eta.to_int(), phi.to_int(), z0.to_int(), d0.to_int(), qual.to_uint());
284 
285  // +1=Positive Endcap and -1=Negative Endcap
286  if (track.endcap() == 1)
287  samuon.setTF(tftype::emtf_pos);
288  else
289  samuon.setTF(tftype::emtf_neg);
290 
291  samuon.setWord(word);
292 
293  return samuon;
294 }
const float LSBphi
Definition: Constants.h:93
const int BITSSAD0
Definition: Constants.h:56
float calcPhiLocRadFromInt(int)
Definition: TPUtils.cc:99
ap_uint< 64 > wordtype
Definition: Constants.h:101
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
uint64_t word
const float LSBpt
Definition: Constants.h:92
const int BITSETA
Definition: Constants.h:26
const int BITSPT
Definition: Constants.h:24
void setTF(tftype tf)
Definition: SAMuon.h:34
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
const int BITSPHI
Definition: Constants.h:25
const float LSBeta
Definition: Constants.h:94
float calcThetaRadFromInt(int)
Definition: TPUtils.cc:50
static constexpr float d0
float calcPhiGlobRadFromLoc(int, float)
Definition: TPUtils.cc:85

◆ Convertl1tMuon()

SAMuon Phase2L1TGMTFwdMuonTranslator::Convertl1tMuon ( const l1t::RegionalMuonCand mu,
const int  bx_,
bool  isDisplaced = false 
)
private

Definition at line 160 of file Phase2L1TGMTFwdMuonTranslator.cc.

References Phase2L1GMT::BITSETA, Phase2L1GMT::BITSPHI, Phase2L1GMT::BITSPT, Phase2L1GMT::BITSSAD0, ALCARECOTkAlJpsiMuMu_cff::charge, ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), d0, PVValHelper::eta, Phase2L1GMT::LSBeta, Phase2L1GMT::LSBphi, Phase2L1GMT::LSBpt, M_PI, amptDefaultParameters_cff::mu, phi, DiDispStaMuonMonitor_cfi::pt, l1t::SAMuon::setTF(), and HLTMuonOfflineAnalyzer_cfi::z0.

Referenced by produce().

160  {
161  ap_uint<BITSSAQUAL> qual = mu.hwQual();
162  int charge = mu.hwSign();
163 
164  ap_uint<BITSGTPT> pt = 0;
165  if (!isDisplaced && mu.hwPt() > 0)
166  pt = round(mu.hwPt() * 0.5 / LSBpt); // Phase-1 LSB 0.5GeV
167  if (isDisplaced && mu.hwPtUnconstrained() > 0)
168  pt = round(mu.hwPtUnconstrained() * 1.0 / LSBpt); // Phase-1 LSB 1.0GeV!!
169 
170  // BEWARE: THIS CONVERSION IS ONLY VALID FOR OMTF
171  constexpr double p1phiLSB = 2 * M_PI / 576;
172  // From the uGMTConfiguration of OMTF. OMTF send in local phi!!
173  // all others correspond to 120 degree sectors = 192 in int-scale
174  int globPhi = mu.processor() * 192 + mu.hwPhi();
175  // first processor starts at CMS phi = 15 degrees (24 in int)... Handle wrap-around with %. Add 576 to make sure the number is positive
176  globPhi = (globPhi + 600) % 576;
177  ap_int<BITSGTPHI> phi = round(globPhi * p1phiLSB / LSBphi); // Phase-1 LSB (2*pi/576)
178  ap_int<BITSGTETA> eta = round(mu.hwEta() * 0.010875 / LSBeta); // Phase-1 LSB 0.010875
179 
180  // FIXME: Below are not well defined in phase1 GMT
181  // Using the version from Correlator for now
182  ap_int<BITSSAZ0> z0 = 0; // No tracks info in Phase 1
183  // Use 2 bits with LSB = 30cm for BMTF and 25cm for EMTF currently, but subjet to change
184  ap_int<BITSSAD0> d0 = mu.hwDXY();
185 
186  //Here do not use the word format to GT but use the word format expected by GMT
187  int bstart = 0;
188  wordtype word(0);
189  bstart = wordconcat<wordtype>(word, bstart, 1, 1);
190  bstart = wordconcat<wordtype>(word, bstart, charge, 1);
191  bstart = wordconcat<wordtype>(word, bstart, pt, BITSPT);
192  bstart = wordconcat<wordtype>(word, bstart, phi, BITSPHI);
193  bstart = wordconcat<wordtype>(word, bstart, eta, BITSETA);
194  // bstart = wordconcat<wordtype>(word, bstart, z0, BITSSAZ0); NOT YET SUPPORTED BY GMT
195  bstart = wordconcat<wordtype>(word, bstart, d0, BITSSAD0);
196  bstart = wordconcat<wordtype>(
197  word, bstart, qual, 8); //FOR NOW 8 bits to be efficienct with Ghost busting. THIS IS ***NOT*** THE FINAL QUALITY
198 
199  // Calculate Lorentz Vector
201  SAMuon samuon(p4, charge, pt.to_uint(), eta.to_int(), phi.to_int(), z0.to_int(), d0.to_int(), qual.to_uint());
202  samuon.setTF(mu.trackFinderType());
203  samuon.setWord(word);
204 
205  return samuon;
206 } // ----- end of function Phase2L1TGMTFwdMuonTranslator::Convertl1tMuon -----
const float LSBphi
Definition: Constants.h:93
const int BITSSAD0
Definition: Constants.h:56
ap_uint< 64 > wordtype
Definition: Constants.h:101
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
uint64_t word
const float LSBpt
Definition: Constants.h:92
const int BITSETA
Definition: Constants.h:26
const int BITSPT
Definition: Constants.h:24
void setTF(tftype tf)
Definition: SAMuon.h:34
const int BITSPHI
Definition: Constants.h:25
#define M_PI
const float LSBeta
Definition: Constants.h:94
static constexpr float d0

◆ fillDescriptions()

void Phase2L1TGMTFwdMuonTranslator::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 297 of file Phase2L1TGMTFwdMuonTranslator.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

297  {
298  //The following says we do not know what parameters are allowed so do no validation
299  // Please change this to state exactly what you do use, even if it is no parameters
301 
302  // Input Collections
303  desc.add<edm::InputTag>("stubs", edm::InputTag("gmtStubs"));
304  desc.add<edm::InputTag>("emtfTracks", edm::InputTag("simEmtfDigisPhase2"));
305  desc.add<edm::InputTag>("omtfTracks", edm::InputTag("simOmtfPhase2Digis"));
306 
307  // Register
308  descriptions.add("Phase2L1TGMTFwdMuonTranslator", desc);
309 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void Phase2L1TGMTFwdMuonTranslator::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 69 of file Phase2L1TGMTFwdMuonTranslator.cc.

References associateStubs(), BXVector< T >::at(), ConvertEMTFTrack(), Convertl1tMuon(), BPHMonitor_cff::displaced, emtfTrackToken_, mps_fire::i, iEvent, eostools::move(), amptDefaultParameters_cff::mu, omtfTrackToken_, BXVector< T >::size(), SimL1Emulator_cff::stubs, stubToken_, HLT_2024v14_cff::track, and parallelization::uint.

69  {
70  using namespace edm;
71 
73  iEvent.getByToken(stubToken_, stubHandle);
74 
76  iEvent.getByToken(emtfTrackToken_, emtf_tracks);
77 
79  iEvent.getByToken(omtfTrackToken_, omtf_tracks);
80 
81  // Process Stubs
83 
84  for (uint i = 0; i < stubHandle->size(); ++i) {
85  l1t::MuonStubRef stub(stubHandle, i);
86 
87  if (stub->bxNum() == 0)
88  stubs.push_back(stub);
89  }
90 
91  // Collect Muons
92  std::vector<SAMuon> prompt;
93 
94  // TODO: Will receive hybrid stubs from OMTF/EMTF
95  std::vector<SAMuon> displaced;
96 
97  // Convert OMTF Muons to SAMuons
98  for (unsigned int i = 0; i < omtf_tracks->size(0); ++i) {
99  const l1t::RegionalMuonCand& mu = omtf_tracks->at(0, i);
100  // Since OMTF is using Phase-1 LSB, will convert to SAMuon locally
101  // We should move to passing words in future
102  l1t::SAMuon samuon;
103  if (mu.hwPt() > 0) {
104  samuon = Convertl1tMuon(mu, 0);
105  //now associate the stubs
106  associateStubs(samuon, stubs);
107  prompt.push_back(samuon);
108  }
109  if (mu.hwPtUnconstrained() > 0) {
110  samuon = Convertl1tMuon(mu, 0, true);
111  //now associate the stubs
112  associateStubs(samuon, stubs);
113  displaced.push_back(samuon);
114  }
115  }
116 
117  // Convert EMTF++ Tracks to SAMuons
118  for (unsigned int track_id = 0; track_id < emtf_tracks->size(); ++track_id) {
119  const auto& track = emtf_tracks->at(track_id);
120 
121  // Short-Circuit: Only keep valid tracks that are in BX=0
122  if ((track.valid() == 0) || (track.bx() != 0)) {
123  continue;
124  }
125 
126  // Short-Circuit: Only keep tracks with quality above 3 to avoid single hit tracks
127  if (track.emtfQuality() <= 3) {
128  continue;
129  }
130 
131  // Short-Circuit: Only keep tracks with the max relevance score (127)
132  if (track.emtfRels() != 127) {
133  continue;
134  }
135 
136  auto samuon = ConvertEMTFTrack(track, 0);
137 
138  //now associate the stubs
139  associateStubs(samuon, stubs);
140 
141  // Add To Collections
142  if (track.unconstrained()) {
143  displaced.push_back(samuon);
144  } else {
145  prompt.push_back(samuon);
146  }
147  }
148 
149  // Output Prompt Muon Collection
150  std::unique_ptr<std::vector<l1t::SAMuon> > prompt_ptr = std::make_unique<std::vector<l1t::SAMuon> >(prompt);
151  std::unique_ptr<std::vector<l1t::SAMuon> > displaced_ptr = std::make_unique<std::vector<l1t::SAMuon> >(displaced);
152  iEvent.put(std::move(prompt_ptr), "prompt");
153  iEvent.put(std::move(displaced_ptr), "displaced");
154 }
edm::EDGetTokenT< l1t::MuonStubCollection > stubToken_
std::vector< edm::Ref< MuonStubCollection > > MuonStubRefVector
Definition: MuonStub.h:44
unsigned size(int bx) const
l1t::SAMuon ConvertEMTFTrack(const l1t::phase2::EMTFTrack &track, const int bx_)
int iEvent
Definition: GenABIO.cc:224
const T & at(int bx, unsigned i) const
void associateStubs(l1t::SAMuon &, const l1t::MuonStubRefVector &)
l1t::SAMuon Convertl1tMuon(const l1t::RegionalMuonCand &mu, const int bx_, bool isDisplaced=false)
HLT enums.
edm::EDGetTokenT< l1t::phase2::EMTFTrackCollection > emtfTrackToken_
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< l1t::RegionalMuonCandBxCollection > omtfTrackToken_

◆ selectLayerBX()

l1t::MuonStubRefVector Phase2L1TGMTFwdMuonTranslator::selectLayerBX ( const l1t::MuonStubRefVector all,
int  bx,
uint  layer 
)
private

Definition at line 208 of file Phase2L1TGMTFwdMuonTranslator.cc.

References python.cmstools::all(), nano_mu_digi_cff::bx, nano_mu_digi_cff::layer, and MillePedeFileConverter_cfg::out.

Referenced by associateStubs().

210  {
212  for (const auto& stub : all) {
213  if (stub->bxNum() == bx && stub->tfLayer() == layer)
214  out.push_back(stub);
215  }
216  return out;
217 }
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
std::vector< edm::Ref< MuonStubCollection > > MuonStubRefVector
Definition: MuonStub.h:44

Member Data Documentation

◆ emtfTrackToken_

edm::EDGetTokenT<l1t::phase2::EMTFTrackCollection> Phase2L1TGMTFwdMuonTranslator::emtfTrackToken_
private

Definition at line 47 of file Phase2L1TGMTFwdMuonTranslator.cc.

Referenced by produce().

◆ omtfTrackToken_

edm::EDGetTokenT<l1t::RegionalMuonCandBxCollection> Phase2L1TGMTFwdMuonTranslator::omtfTrackToken_
private

Definition at line 46 of file Phase2L1TGMTFwdMuonTranslator.cc.

Referenced by produce().

◆ stubToken_

edm::EDGetTokenT<l1t::MuonStubCollection> Phase2L1TGMTFwdMuonTranslator::stubToken_
private

Definition at line 45 of file Phase2L1TGMTFwdMuonTranslator.cc.

Referenced by produce().