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 10 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  {
179  return pt_assign_engine_->aux();
180 }
const PtAssignmentEngineAux & aux() const
PtAssignmentEngine * pt_assign_engine_
Definition: PtAssignment.h:27
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 6 of file PtAssignment.cc.

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

Referenced by SectorProcessor::process_single_bx().

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

Definition at line 34 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_, PtAssignmentEngine::get_pt_lut_version(), 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_, EnergyCorrector::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(), HiIsolationCommonParameters_cff::track, and verbose_.

Referenced by SectorProcessor::process_single_bx().

36  {
37  using address_t = PtAssignmentEngine::address_t;
38 
39  EMTFTrackCollection::iterator best_tracks_it = best_tracks.begin();
40  EMTFTrackCollection::iterator best_tracks_end = best_tracks.end();
41 
42  for (; best_tracks_it != best_tracks_end; ++best_tracks_it) {
43  EMTFTrack& track = *best_tracks_it; // pass by reference
44 
45  // Assign GMT eta and phi
46  int gmt_phi = aux().getGMTPhi(track.Phi_fp());
47 
48  if (!bugGMTPhi_) {
49  gmt_phi = aux().getGMTPhiV2(track.Phi_fp());
50  }
51 
52  int gmt_eta = aux().getGMTEta(track.Theta_fp(), track.Endcap()); // Convert to integer eta using FW LUT
53 
54  // Notes from Alex (2016-09-28):
55  //
56  // When using two's complement, you get two eta bins with zero coordinate.
57  // This peculiarity is created because positive and negative endcaps are
58  // processed by separate processors, so each of them gets its own zero bin.
59  // With simple inversion, the eta scale becomes uniform, one bin for one
60  // eta value.
61  bool use_ones_complem_gmt_eta = true;
62  if (use_ones_complem_gmt_eta) {
63  gmt_eta = (gmt_eta < 0) ? ~(-gmt_eta) : gmt_eta;
64  }
65 
66  // Assign pT
67  address_t address = 0;
68  float xmlpt = 0.;
69  float pt = 0.;
70  int gmt_pt = 0;
71  if (track.Mode() != 1) {
72  address = pt_assign_engine_->calculate_address(track);
73  xmlpt = pt_assign_engine_->calculate_pt(address);
74 
75  // Check address packing / unpacking using PtAssignmentEngine2017::calculate_pt_xml(const EMTFTrack& track)
77  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)) = "
80  << pt_assign_engine_->calculate_pt(track); }
81 
82  pt = (xmlpt < 0.) ? 1. : xmlpt; // Matt used fabs(-1) when mode is invalid
83  pt *= pt_assign_engine_->scale_pt(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  }
97  else { // Special quality for single-hit tracks from ME1/1
98  gmt_quality = track.Hits().front().Pattern() / 4;
99  }
100 
101  std::pair<int, int> gmt_charge = std::make_pair(0, 0);
102  if (track.Mode() != 1) {
103  std::vector<int> phidiffs;
104  for (int i = 0; i < emtf::NUM_STATION_PAIRS; ++i) {
105  int phidiff = (track.PtLUT().sign_ph[i] == 1) ? track.PtLUT().delta_ph[i] : -track.PtLUT().delta_ph[i];
106  phidiffs.push_back(phidiff);
107  }
108  gmt_charge = aux().getGMTCharge(track.Mode(), phidiffs);
109  }
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)) || is_in_same_bank(best_tracks.at(1), best_tracks.at(2));
159  if (same_bank) {
160  // Set worst track pT to zero
161  best_tracks.at(2).set_pt(0);
162  best_tracks.at(2).set_gmt_pt(0);
163  }
164  }
165  }
166 
167  if (verbose_ > 0) { // debug
168  for (const auto& track: best_tracks) {
169  std::cout << "track: " << track.Winner() << " pt address: " << track.PtLUT().address
170  << " GMT pt: " << track.GMT_pt() << " pt: " << track.Pt() << " mode: " << track.Mode()
171  << " GMT charge: " << track.GMT_charge() << " quality: " << track.GMT_quality()
172  << " eta: " << track.GMT_eta() << " phi: " << track.GMT_phi()
173  << std::endl;
174  }
175  }
176 }
int Theta_fp() const
Definition: EMTFTrack.h:142
virtual address_t calculate_address(const EMTFTrack &track) const
int GMT_eta() const
Definition: EMTFTrack.h:150
int NUM_STATION_PAIRS
Definition: Common.h:72
void set_gmt_eta(int bits)
Definition: EMTFTrack.h:116
virtual float calculate_pt(const address_t &address) const
uint16_t sign_ph[6]
Definition: EMTFTrack.h:24
int Endcap() const
Definition: EMTFTrack.h:123
float Pt() const
Definition: EMTFTrack.h:137
int getGMTPhiV2(int phi) const
int Phi_fp() const
Definition: EMTFTrack.h:145
void set_charge(int bits)
Definition: EMTFTrack.h:99
int getGMTEta(int theta, int endcap) const
int Winner() const
Definition: EMTFTrack.h:132
int GMT_charge() const
Definition: EMTFTrack.h:152
int GMT_quality() const
Definition: EMTFTrack.h:151
double phidiff(double phi)
Normalized difference in azimuthal angles to a range between .
Definition: fourvec.cc:230
uint16_t delta_ph[6]
Definition: EMTFTrack.h:22
void set_PtLUT(EMTFPtLUT bits)
Definition: EMTFTrack.h:89
const PtAssignmentEngineAux & aux() const
void set_gmt_phi(int bits)
Definition: EMTFTrack.h:115
void set_pt(float val)
Definition: EMTFTrack.h:103
void set_gmt_quality(int bits)
Definition: EMTFTrack.h:117
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
PtAssignmentEngine * pt_assign_engine_
Definition: PtAssignment.h:27
bool promoteMode7_
Definition: PtAssignment.h:31
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:149
void set_gmt_charge(int bits)
Definition: EMTFTrack.h:118
EMTFHitCollection Hits() const
Definition: EMTFTrack.h:81
int get_pt_lut_version() const
uint64_t address
Definition: EMTFTrack.h:17
void set_pt_XML(float val)
Definition: EMTFTrack.h:104
int GMT_pt() const
Definition: EMTFTrack.h:148
int getGMTPhi(int phi) const
int Mode() const
Definition: EMTFTrack.h:126
void set_gmt_charge_valid(int bits)
Definition: EMTFTrack.h:119
int getGMTPt(float pt) const
EMTFPtLUT PtLUT() const
Definition: EMTFTrack.h:90
void set_gmt_pt(int bits)
Definition: EMTFTrack.h:114
int getGMTQuality(int mode, int theta, bool promoteMode7, int version) const

Member Data Documentation

bool PtAssignment::bugGMTPhi_
private

Definition at line 31 of file PtAssignment.h.

Referenced by configure(), and process().

int PtAssignment::bx_
private

Definition at line 29 of file PtAssignment.h.

Referenced by configure().

int PtAssignment::endcap_
private

Definition at line 29 of file PtAssignment.h.

Referenced by configure(), and process().

int PtAssignment::modeQualVer_
private

Definition at line 32 of file PtAssignment.h.

Referenced by configure(), and process().

bool PtAssignment::promoteMode7_
private

Definition at line 31 of file PtAssignment.h.

Referenced by configure(), and process().

PtAssignmentEngine* PtAssignment::pt_assign_engine_
private

Definition at line 27 of file PtAssignment.h.

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

int PtAssignment::sector_
private

Definition at line 29 of file PtAssignment.h.

Referenced by configure().

int PtAssignment::verbose_
private

Definition at line 29 of file PtAssignment.h.

Referenced by configure(), and process().