CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
PtAssignment Class Reference

#include <PtAssignment.h>

Public Member Functions

const PtAssignmentEngineAuxaux () const
 
void configure (PtAssignmentEngine *pt_assign_engine, int verbose, int endcap, int sector, int bx, bool readPtLUTFile, bool fixMode15HighPt, bool bug9BitDPhi, bool bugMode7CLCT, bool bugNegPt, bool bugGMTPhi, bool promoteMode7, int modeQualVer)
 
void process (EMTFTrackCollection &best_tracks)
 

Private Attributes

bool bugGMTPhi_
 
int bx_
 
int endcap_
 
int modeQualVer_
 
bool promoteMode7_
 
PtAssignmentEnginept_assign_engine_
 
int sector_
 
int verbose_
 

Detailed Description

Definition at line 9 of file PtAssignment.h.

Member Function Documentation

◆ aux()

const PtAssignmentEngineAux & PtAssignment::aux ( ) const

Definition at line 176 of file PtAssignment.cc.

176 { return pt_assign_engine_->aux(); }

References PtAssignmentEngine::aux(), and pt_assign_engine_.

Referenced by process().

◆ configure()

void PtAssignment::configure ( PtAssignmentEngine pt_assign_engine,
int  verbose,
int  endcap,
int  sector,
int  bx,
bool  readPtLUTFile,
bool  fixMode15HighPt,
bool  bug9BitDPhi,
bool  bugMode7CLCT,
bool  bugNegPt,
bool  bugGMTPhi,
bool  promoteMode7,
int  modeQualVer 
)

Definition at line 5 of file PtAssignment.cc.

17  {
18  emtf_assert(pt_assign_engine != nullptr);
19 
20  pt_assign_engine_ = pt_assign_engine;
21 
22  verbose_ = verbose;
23  endcap_ = endcap;
24  sector_ = sector;
25  bx_ = bx;
26 
27  pt_assign_engine_->configure(verbose_, readPtLUTFile, fixMode15HighPt, bug9BitDPhi, bugMode7CLCT, bugNegPt);
28 
29  bugGMTPhi_ = bugGMTPhi;
30  promoteMode7_ = promoteMode7;
31  modeQualVer_ = modeQualVer;
32 }

References bugGMTPhi_, l1GtPatternGenerator_cfi::bx, bx_, PtAssignmentEngine::configure(), emtf_assert, makeMuonMisalignmentScenario::endcap, endcap_, modeQualVer_, promoteMode7_, pt_assign_engine_, sector_, verbose, and verbose_.

Referenced by SectorProcessor::process_single_bx().

◆ process()

void PtAssignment::process ( EMTFTrackCollection best_tracks)

Definition at line 34 of file PtAssignment.cc.

34  {
35  using address_t = PtAssignmentEngine::address_t;
36 
37  EMTFTrackCollection::iterator best_tracks_it = best_tracks.begin();
38  EMTFTrackCollection::iterator best_tracks_end = best_tracks.end();
39 
40  for (; best_tracks_it != best_tracks_end; ++best_tracks_it) {
41  EMTFTrack& track = *best_tracks_it; // pass by reference
42 
43  // Assign GMT eta and phi
44  int gmt_phi = aux().getGMTPhi(track.Phi_fp());
45 
46  if (!bugGMTPhi_) {
47  gmt_phi = aux().getGMTPhiV2(track.Phi_fp());
48  }
49 
50  int gmt_eta = aux().getGMTEta(track.Theta_fp(), track.Endcap()); // Convert to integer eta using FW LUT
51 
52  // Notes from Alex (2016-09-28):
53  //
54  // When using two's complement, you get two eta bins with zero coordinate.
55  // This peculiarity is created because positive and negative endcaps are
56  // processed by separate processors, so each of them gets its own zero bin.
57  // With simple inversion, the eta scale becomes uniform, one bin for one
58  // eta value.
59  bool use_ones_complem_gmt_eta = true;
60  if (use_ones_complem_gmt_eta) {
61  gmt_eta = (gmt_eta < 0) ? ~(-gmt_eta) : gmt_eta;
62  }
63 
64  // Assign pT
65  address_t address = 0;
66  float xmlpt = 0.;
67  float pt = 0.;
68  int gmt_pt = 0;
69  if (track.Mode() != 1) {
71  xmlpt = pt_assign_engine_->calculate_pt(address);
72 
73  // Check address packing / unpacking using PtAssignmentEngine2017::calculate_pt_xml(const EMTFTrack& track)
75  not(fabs(xmlpt - pt_assign_engine_->calculate_pt(track)) < 0.001)) {
76  edm::LogError("L1T") << "EMTF pT assignment mismatch: xmlpt = " << xmlpt
77  << ", pt_assign_engine_->calculate_pt(track)) = "
79  }
80 
81  pt = (xmlpt < 0.) ? 1. : xmlpt; // Matt used fabs(-1) when mode is invalid
83  pt, track.Mode()); // Multiply by some factor to achieve 90% efficiency at threshold
84 
85  gmt_pt = aux().getGMTPt(pt); // Encode integer pT in GMT format
86  } // End if (track.Mode() != 1)
87  else {
88  gmt_pt = 10 - (abs(gmt_eta) / 32);
89  }
90 
91  pt = (gmt_pt <= 0) ? 0 : (gmt_pt - 1) * 0.5; // Decode integer pT (result is in 0.5 GeV step)
92 
93  int gmt_quality = 0;
94  if (track.Mode() != 1) {
95  gmt_quality = aux().getGMTQuality(track.Mode(), track.Theta_fp(), promoteMode7_, modeQualVer_);
96  } else { // Special quality for single-hit tracks from ME1/1
97  gmt_quality = track.Hits().front().Pattern() / 4;
98  }
99 
100  std::pair<int, int> gmt_charge = std::make_pair(0, 0);
101  if (track.Mode() != 1) {
102  std::vector<int> phidiffs;
103  for (int i = 0; i < emtf::NUM_STATION_PAIRS; ++i) {
104  int phidiff = (track.PtLUT().sign_ph[i] == 1) ? track.PtLUT().delta_ph[i] : -track.PtLUT().delta_ph[i];
105  phidiffs.push_back(phidiff);
106  }
107  gmt_charge = aux().getGMTCharge(track.Mode(), phidiffs);
108  } else { // Special charge assignment for single-hit tracks from ME1/1
109  int CLCT = track.Hits().front().Pattern();
110  if (CLCT != 10) {
111  if (endcap_ == 1)
112  gmt_charge = std::make_pair((CLCT % 2) == 0 ? 0 : 1, 1);
113  else
114  gmt_charge = std::make_pair((CLCT % 2) == 0 ? 1 : 0, 1);
115  }
116  }
117 
118  // _________________________________________________________________________
119  // Output
120 
121  EMTFPtLUT tmp_LUT = track.PtLUT();
122  tmp_LUT.address = address;
123 
124  track.set_PtLUT(tmp_LUT);
125  track.set_pt_XML(xmlpt);
126  track.set_pt(pt);
127  track.set_charge((gmt_charge.second == 1) ? ((gmt_charge.first == 1) ? -1 : +1) : 0);
128 
129  track.set_gmt_pt(gmt_pt);
130  track.set_gmt_phi(gmt_phi);
131  track.set_gmt_eta(gmt_eta);
132  track.set_gmt_quality(gmt_quality);
133  track.set_gmt_charge(gmt_charge.first);
134  track.set_gmt_charge_valid(gmt_charge.second);
135  }
136 
137  // Remove worst track if it addresses the same bank as one of two best tracks
138  bool disable_worst_track_in_same_bank = true;
139  if (disable_worst_track_in_same_bank) {
140  // FW macro for detecting same bank address
141  // bank and chip must match, and valid flags must be set
142  // a and b are indexes 0,1,2
143  // `define sb(a,b) (ptlut_addr[a][29:26] == ptlut_addr[b][29:26] && ptlut_addr[a][5:2] == ptlut_addr[b][5:2] && ptlut_addr_val[a] && ptlut_addr_val[b])
144  auto is_in_same_bank = [](const EMTFTrack& lhs, const EMTFTrack& rhs) {
145  unsigned lhs_addr = lhs.PtLUT().address;
146  unsigned rhs_addr = rhs.PtLUT().address;
147  unsigned lhs_addr_1 = (lhs_addr >> 26) & 0xF;
148  unsigned rhs_addr_1 = (rhs_addr >> 26) & 0xF;
149  unsigned lhs_addr_2 = (lhs_addr >> 2) & 0xF;
150  unsigned rhs_addr_2 = (rhs_addr >> 2) & 0xF;
151  return (lhs_addr_1 == rhs_addr_1) && (lhs_addr_2 == rhs_addr_2);
152  };
153 
154  emtf_assert(best_tracks.size() <= 3);
155  if (best_tracks.size() == 3) {
156  bool same_bank = is_in_same_bank(best_tracks.at(0), best_tracks.at(2)) ||
157  is_in_same_bank(best_tracks.at(1), best_tracks.at(2));
158  if (same_bank) {
159  // Set worst track pT to zero
160  best_tracks.at(2).set_pt(0);
161  best_tracks.at(2).set_gmt_pt(0);
162  }
163  }
164  }
165 
166  if (verbose_ > 0) { // debug
167  for (const auto& track : best_tracks) {
168  std::cout << "track: " << track.Winner() << " pt address: " << track.PtLUT().address
169  << " GMT pt: " << track.GMT_pt() << " pt: " << track.Pt() << " mode: " << track.Mode()
170  << " GMT charge: " << track.GMT_charge() << " quality: " << track.GMT_quality()
171  << " eta: " << track.GMT_eta() << " phi: " << track.GMT_phi() << std::endl;
172  }
173  }
174 }

References funct::abs(), l1t::EMTFPtLUT::address, aux(), bugGMTPhi_, PtAssignmentEngine::calculate_address(), PtAssignmentEngine::calculate_pt(), gather_cfg::cout, emtf_assert, endcap_, PtAssignmentEngine::get_pt_lut_version(), PtAssignmentEngineAux::getGMTCharge(), PtAssignmentEngineAux::getGMTEta(), PtAssignmentEngineAux::getGMTPhi(), PtAssignmentEngineAux::getGMTPhiV2(), PtAssignmentEngineAux::getGMTPt(), PtAssignmentEngineAux::getGMTQuality(), mps_fire::i, modeQualVer_, emtf::NUM_STATION_PAIRS, hitfit::phidiff(), promoteMode7_, DiDispStaMuonMonitor_cfi::pt, pt_assign_engine_, l1t::EMTFTrack::PtLUT(), PtAssignmentEngine::scale_pt(), HLT_2018_cff::track, and verbose_.

Referenced by SectorProcessor::process_single_bx().

Member Data Documentation

◆ bugGMTPhi_

bool PtAssignment::bugGMTPhi_
private

Definition at line 34 of file PtAssignment.h.

Referenced by configure(), and process().

◆ bx_

int PtAssignment::bx_
private

Definition at line 32 of file PtAssignment.h.

Referenced by configure().

◆ endcap_

int PtAssignment::endcap_
private

Definition at line 32 of file PtAssignment.h.

Referenced by configure(), and process().

◆ modeQualVer_

int PtAssignment::modeQualVer_
private

Definition at line 35 of file PtAssignment.h.

Referenced by configure(), and process().

◆ promoteMode7_

bool PtAssignment::promoteMode7_
private

Definition at line 34 of file PtAssignment.h.

Referenced by configure(), and process().

◆ pt_assign_engine_

PtAssignmentEngine* PtAssignment::pt_assign_engine_
private

Definition at line 30 of file PtAssignment.h.

Referenced by aux(), configure(), and process().

◆ sector_

int PtAssignment::sector_
private

Definition at line 32 of file PtAssignment.h.

Referenced by configure().

◆ verbose_

int PtAssignment::verbose_
private

Definition at line 32 of file PtAssignment.h.

Referenced by configure(), and process().

PtAssignmentEngineAux::getGMTPt
int getGMTPt(float pt) const
Definition: PtAssignmentEngineAux.cc:12
mps_fire.i
i
Definition: mps_fire.py:355
l1t::EMTFTrack::PtLUT
EMTFPtLUT PtLUT() const
Definition: EMTFTrack.h:111
PtAssignmentEngine::calculate_pt
virtual float calculate_pt(const address_t &address) const
Definition: PtAssignmentEngine.cc:100
PtAssignment::sector_
int sector_
Definition: PtAssignment.h:32
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
l1t::EMTFPtLUT
Definition: EMTFTrack.h:16
PtAssignment::aux
const PtAssignmentEngineAux & aux() const
Definition: PtAssignment.cc:176
gather_cfg.cout
cout
Definition: gather_cfg.py:144
PtAssignmentEngineAux::getGMTCharge
std::pair< int, int > getGMTCharge(int mode, const std::vector< int > &phidiffs) const
Definition: PtAssignmentEngineAux.cc:166
l1GtPatternGenerator_cfi.bx
bx
Definition: l1GtPatternGenerator_cfi.py:18
makeMuonMisalignmentScenario.endcap
endcap
Definition: makeMuonMisalignmentScenario.py:320
PtAssignmentEngine::scale_pt
virtual float scale_pt(const float pt, const int mode=15) const =0
PtAssignment::bugGMTPhi_
bool bugGMTPhi_
Definition: PtAssignment.h:34
PtAssignmentEngine::configure
void configure(int verbose, bool readPtLUTFile, bool fixMode15HighPt, bool bug9BitDPhi, bool bugMode7CLCT, bool bugNegPt)
Definition: PtAssignmentEngine.cc:72
PtAssignmentEngineAux::getGMTEta
int getGMTEta(int theta, int endcap) const
Definition: PtAssignmentEngineAux.cc:44
PtAssignmentEngine::address_t
uint64_t address_t
Definition: PtAssignmentEngine.h:21
PtAssignmentEngineAux::getGMTPhiV2
int getGMTPhiV2(int phi) const
Definition: PtAssignmentEngineAux.cc:36
PtAssignmentEngine::calculate_address
virtual address_t calculate_address(const EMTFTrack &track) const
Definition: PtAssignmentEngine.h:40
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
l1t::EMTFTrack
Definition: EMTFTrack.h:34
edm::LogError
Definition: MessageLogger.h:183
l1t::EMTFPtLUT::address
uint64_t address
Definition: EMTFTrack.h:17
hitfit::phidiff
double phidiff(double phi)
Normalized difference in azimuthal angles to a range between .
Definition: fourvec.cc:220
PtAssignment::endcap_
int endcap_
Definition: PtAssignment.h:32
PtAssignmentEngine::aux
const PtAssignmentEngineAux & aux() const
Definition: PtAssignmentEngine.cc:95
PtAssignmentEngineAux::getGMTQuality
int getGMTQuality(int mode, int theta, bool promoteMode7, int version) const
Definition: PtAssignmentEngineAux.cc:58
PtAssignment::verbose_
int verbose_
Definition: PtAssignment.h:32
PtAssignmentEngineAux::getGMTPhi
int getGMTPhi(int phi) const
Definition: PtAssignmentEngineAux.cc:24
PtAssignment::bx_
int bx_
Definition: PtAssignment.h:32
PtAssignmentEngine::get_pt_lut_version
int get_pt_lut_version() const
Definition: PtAssignmentEngine.h:28
PtAssignment::promoteMode7_
bool promoteMode7_
Definition: PtAssignment.h:34
emtf::NUM_STATION_PAIRS
constexpr int NUM_STATION_PAIRS
Definition: Common.h:59
PtAssignment::pt_assign_engine_
PtAssignmentEngine * pt_assign_engine_
Definition: PtAssignment.h:30
emtf_assert
#define emtf_assert(expr)
Definition: DebugTools.h:18
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
PtAssignment::modeQualVer_
int modeQualVer_
Definition: PtAssignment.h:35