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

const PtAssignmentEngineAux & PtAssignment::aux ( ) const

Definition at line 178 of file PtAssignment.cc.

References PtAssignmentEngine::aux(), and pt_assign_engine_.

Referenced by process().

178 { return pt_assign_engine_->aux(); }
const PtAssignmentEngineAux & aux() const
PtAssignmentEngine * pt_assign_engine_
Definition: PtAssignment.h:30
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.

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

Referenced by SectorProcessor::process_single_bx().

17  {
18  if (not(pt_assign_engine != nullptr)) {
19  edm::LogError("L1T") << "pt_assign_engine == nullptr ";
20  return;
21  }
22 
23  pt_assign_engine_ = pt_assign_engine;
24 
25  verbose_ = verbose;
26  endcap_ = endcap;
27  sector_ = sector;
28  bx_ = bx;
29 
30  pt_assign_engine_->configure(verbose_, readPtLUTFile, fixMode15HighPt, bug9BitDPhi, bugMode7CLCT, bugNegPt);
31 
32  bugGMTPhi_ = bugGMTPhi;
33  promoteMode7_ = promoteMode7;
34  modeQualVer_ = modeQualVer;
35 }
void configure(int verbose, bool readPtLUTFile, bool fixMode15HighPt, bool bug9BitDPhi, bool bugMode7CLCT, bool bugNegPt)
static int verbose
PtAssignmentEngine * pt_assign_engine_
Definition: PtAssignment.h:30
bool promoteMode7_
Definition: PtAssignment.h:34
void PtAssignment::process ( EMTFTrackCollection best_tracks)

Definition at line 37 of file PtAssignment.cc.

References funct::abs(), l1t::EMTFPtLUT::address, aux(), bugGMTPhi_, PtAssignmentEngine::calculate_address(), PtAssignmentEngine::calculate_pt(), gather_cfg::cout, l1t::EMTFPtLUT::delta_ph, l1t::EMTFTrack::Endcap(), endcap_, PtAssignmentEngineAux::getGMTCharge(), PtAssignmentEngineAux::getGMTEta(), PtAssignmentEngineAux::getGMTPhi(), PtAssignmentEngineAux::getGMTPhiV2(), PtAssignmentEngineAux::getGMTPt(), PtAssignmentEngineAux::getGMTQuality(), l1t::EMTFTrack::Hits(), mps_fire::i, l1t::EMTFTrack::Mode(), modeQualVer_, emtf::NUM_STATION_PAIRS, l1t::EMTFTrack::Phi_fp(), hitfit::phidiff(), promoteMode7_, DiDispStaMuonMonitor_cfi::pt, pt_assign_engine_, l1t::EMTFTrack::PtLUT(), PtAssignmentEngine::scale_pt(), l1t::EMTFTrack::set_charge(), l1t::EMTFTrack::set_gmt_charge(), l1t::EMTFTrack::set_gmt_charge_valid(), l1t::EMTFTrack::set_gmt_eta(), l1t::EMTFTrack::set_gmt_phi(), l1t::EMTFTrack::set_gmt_pt(), l1t::EMTFTrack::set_gmt_quality(), l1t::EMTFTrack::set_pt(), l1t::EMTFTrack::set_pt_XML(), l1t::EMTFTrack::set_PtLUT(), l1t::EMTFPtLUT::sign_ph, l1t::EMTFTrack::Theta_fp(), HLT_2018_cff::track, and verbose_.

Referenced by SectorProcessor::process_single_bx().

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

Member Data Documentation

bool PtAssignment::bugGMTPhi_
private

Definition at line 34 of file PtAssignment.h.

Referenced by configure(), and process().

int PtAssignment::bx_
private

Definition at line 32 of file PtAssignment.h.

Referenced by configure().

int PtAssignment::endcap_
private

Definition at line 32 of file PtAssignment.h.

Referenced by configure(), and process().

int PtAssignment::modeQualVer_
private

Definition at line 35 of file PtAssignment.h.

Referenced by configure(), and process().

bool PtAssignment::promoteMode7_
private

Definition at line 34 of file PtAssignment.h.

Referenced by configure(), and process().

PtAssignmentEngine* PtAssignment::pt_assign_engine_
private

Definition at line 30 of file PtAssignment.h.

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

int PtAssignment::sector_
private

Definition at line 32 of file PtAssignment.h.

Referenced by configure().

int PtAssignment::verbose_
private

Definition at line 32 of file PtAssignment.h.

Referenced by configure(), and process().