CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
tmtt::HTrphi Class Reference

#include <HTrphi.h>

Inheritance diagram for tmtt::HTrphi:
tmtt::HTbase

Classes

struct  ErrorMonitor
 

Public Types

enum  HTshape { HTshape::square, HTshape::diamond, HTshape::hexagon, HTshape::brick }
 

Public Member Functions

std::pair< unsigned int, unsigned int > cell (const L1fittedTrack *fitTrk) const override
 
unsigned int getMbinRange (const L1track2D &trk) const
 
std::pair< float, float > helix2Dconventional (unsigned int i, unsigned int j) const override
 
std::pair< float, float > helix2Dhough (unsigned int i, unsigned int j) const override
 
 HTrphi (const Settings *settings, unsigned int iPhiSec, unsigned int iEtaReg, float etaMinSector, float etaMaxSector, float phiCentreSector, ErrorMonitor *errMon=nullptr)
 
bool mergedCell (unsigned int iQoverPtBin, unsigned int jPhiTrkBin) const
 
unsigned int nReceivedStubs () const
 
void store (Stub *stub, const std::vector< bool > &inEtaSubSecs)
 
std::pair< unsigned int, unsigned int > trueCell (const TP *tp) const override
 
 ~HTrphi () override=default
 
- Public Member Functions inherited from tmtt::HTbase
virtual const Array2D< std::unique_ptr< HTcell > > & allCells () const
 
virtual std::vector< const L1track2D * > assocTrackCands2D (const TP &tp) const
 
virtual void disableBendFilter ()
 
virtual void end ()
 
 HTbase (const Settings *settings, unsigned int iPhiSec, unsigned int iEtaReg, unsigned int nBinsX, unsigned int nBinsY)
 
virtual unsigned int numStubsExc () const
 
virtual unsigned int numStubsInc () const
 
virtual unsigned int numStubsOnTrackCands2D () const
 
virtual unsigned int numTrackCands2D () const
 
virtual void replaceTrackCands2D (const std::list< L1track2D > &newTracks)
 
virtual const std::list< L1track2D > & trackCands2D () const
 
virtual ~HTbase ()=default
 

Private Member Functions

float calcLineGradArray (float r) const
 
void countFirmwareErrors (unsigned int iQoverPtBin, unsigned int iPhiTrkBinMin, unsigned int iPhiTrkBinMax, unsigned int jPhiTrkBinMinLast, unsigned int jPhiTrkBinMaxLast)
 
std::pair< unsigned int, unsigned int > iPhiRange (const Stub *stub, unsigned int iQoverPtBin, bool debug=false) const
 
std::list< L1track2DkillTracksBusySec (const std::list< L1track2D > &tracks) const override
 
std::vector< unsigned int > rowOrder (unsigned int numRows) const override
 

Private Attributes

float binSizePhiTrkAxis_
 
float binSizeQoverPtAxis_
 
bool busyInputSectorKill_
 
unsigned int busyInputSectorNumStubs_
 
bool busySectorKill_
 
std::vector< unsigned int > busySectorMbinHigh_
 
std::vector< unsigned int > busySectorMbinLow_
 
std::vector< unsigned int > busySectorMbinOrder_
 
std::vector< unsigned int > busySectorMbinRanges_
 
unsigned int busySectorNumStubs_
 
bool busySectorUseMbinOrder_
 
bool busySectorUseMbinRanges_
 
std::vector< std::vector< std::pair< float, float > > > cellCenters_
 
float chosenRofPhi_
 
bool enableMerge2x2_
 
ErrorMonitorerrMon_
 
float invPtToDphi_
 
unsigned int killSomeHTCellsRphi_
 
float maxAbsPhiTrkAxis_
 
float maxAbsQoverPtAxis_
 
float minInvPtToMerge2x2_
 
unsigned int nBinsPhiTrkAxis_
 
unsigned int nBinsQoverPtAxis_
 
unsigned int nReceivedStubs_
 
float phiCentreSector_
 
HTshape shape_
 

Additional Inherited Members

- Protected Member Functions inherited from tmtt::HTbase
virtual std::pair< unsigned int, unsigned int > convertCoordRangeToBinRange (std::pair< float, float > coordRange, unsigned int nBinsAxis, float coordAxisMin, float coordAxisBinSize, unsigned int killSomeHTcells) const
 
- Protected Attributes inherited from tmtt::HTbase
Array2D< std::unique_ptr< HTcell > > htArray_
 
unsigned int iEtaReg_
 
unsigned int iPhiSec_
 
unsigned int nBinsX_
 
unsigned int nBinsY_
 
unsigned int optoLinkID_
 
const Settingssettings_
 
std::list< L1track2DtrackCands2D_
 

Detailed Description

Definition at line 23 of file HTrphi.h.

Member Enumeration Documentation

◆ HTshape

enum tmtt::HTrphi::HTshape
strong
Enumerator
square 
diamond 
hexagon 
brick 

Definition at line 25 of file HTrphi.h.

25 { square, diamond, hexagon, brick };
static double square(double x)

Constructor & Destructor Documentation

◆ HTrphi()

tmtt::HTrphi::HTrphi ( const Settings settings,
unsigned int  iPhiSec,
unsigned int  iEtaReg,
float  etaMinSector,
float  etaMaxSector,
float  phiCentreSector,
HTrphi::ErrorMonitor errMon = nullptr 
)

Definition at line 29 of file HTrphi.cc.

References binSizePhiTrkAxis_, binSizeQoverPtAxis_, tmtt::Settings::busyInputSectorKill(), busyInputSectorKill_, tmtt::Settings::busyInputSectorNumStubs(), busyInputSectorNumStubs_, tmtt::Settings::busySectorKill(), busySectorKill_, busySectorMbinHigh_, busySectorMbinLow_, tmtt::Settings::busySectorMbinOrder(), busySectorMbinOrder_, tmtt::Settings::busySectorMbinRanges(), busySectorMbinRanges_, tmtt::Settings::busySectorNumStubs(), busySectorNumStubs_, busySectorUseMbinOrder_, busySectorUseMbinRanges_, HltBtagPostValidation_cff::c, cellCenters_, diamond, tmtt::Settings::enableMerge2x2(), enableMerge2x2_, Exception, dqmMemoryStats::float, helix2Dconventional(), hexagon, tmtt::HTbase::htArray_, mps_fire::i, dqmiolumiharvest::j, tmtt::Settings::killSomeHTCellsRphi(), killSomeHTCellsRphi_, visualization-live-secondInstance_cfg::m, maxAbsPhiTrkAxis_, maxAbsQoverPtAxis_, tmtt::Settings::maxPtToMerge2x2(), mergedCell(), tmtt::Settings::miniHTstage(), minInvPtToMerge2x2_, nBinsPhiTrkAxis_, nBinsQoverPtAxis_, nReceivedStubs_, tmtt::HTbase::settings_, shape_, square, submitPVValidationJobs::t, and submitPVValidationJobs::text.

36  : HTbase(settings, iPhiSec, iEtaReg, settings->houghNbinsPt(), settings->houghNbinsPhi()),
37  invPtToDphi_((settings->invPtToDphi())),
38  shape_(static_cast<HTshape>(settings->shape())), // shape of HT cells
39 
40  //--- Specification of HT q/Pt axis.
41  maxAbsQoverPtAxis_(1. / settings->houghMinPt()), // Max. |q/Pt| covered by HT array.
42  nBinsQoverPtAxis_(settings->houghNbinsPt()), // No. of bins in HT array in q/Pt.
44 
45  //--- Specification of HT phiTrk axis
46  // (phiTrk corresponds to phi where track crosses radius = chosenRofPhi_).
47  chosenRofPhi_(settings->chosenRofPhi()),
48  phiCentreSector_(phiCentreSector), // Centre of phiTrk sector.
49  maxAbsPhiTrkAxis_(M_PI / float(settings->numPhiSectors())), // Half-width of phiTrk axis in HT array.
50  nBinsPhiTrkAxis_(settings->houghNbinsPhi()), // No. of bins in HT array phiTrk
52  errMon_(errMon) {
53  // Deal with unusually shaped HT cells.
54  if (shape_ != HTshape::square)
56  if (shape_ == HTshape::hexagon)
58  else if (shape_ == HTshape::diamond)
60 
61  // Optionally merge 2x2 neighbouring cells into a single cell at low Pt, to reduce efficiency loss due to
62  // scattering. (Do this if either of options EnableMerge2x2 or MiniHTstage are enabled.
63  // N.B These two options are never both enabled).
64  enableMerge2x2_ = (settings->enableMerge2x2() || settings->miniHTstage());
65  if (settings->miniHTstage()) {
66  // Mini-HT stage cfg: Merge all bins, irrespective of Pt.
68  } else {
69  // Merged cells cfg: Merge bins below specified Pt threshold.
70  minInvPtToMerge2x2_ = 1. / (settings->maxPtToMerge2x2());
72  enableMerge2x2_ = false;
73  }
74 
75  // Merging 2x2 cells into 1 merged cell is only allowed if HT array dimensions are even.
76  // (This restriction could be removed along q/Pt axis, since there are also unmerged cells there. But this
77  // would require correcting the code after each called to mergedCell() below, since
78  // "if (i%2 == 1) iStore = i - 1" not correct in this case).
79  if (enableMerge2x2_ && (nBinsQoverPtAxis_ % 2 != 0 || nBinsPhiTrkAxis_ % 2 != 0))
80  throw cms::Exception("BadConfig") << "HTrphi: You are not allowed to set EnableMerge2x2 or MiniHTstage = True if "
81  "you have an odd number of bins "
82  "in r-phi HT array "
84 
85  //--- Other options used when filling the HT.
86 
87  // Don't fill all HT cells nominally crossed by line corresponding to stub.
88  killSomeHTCellsRphi_ = settings->killSomeHTCellsRphi();
89 
90  // Used to kill excess stubs or tracks that can't be transmitted within time-multiplexed period.
91  nReceivedStubs_ = 0;
92  busyInputSectorKill_ = settings_->busyInputSectorKill(); // Kill excess stubs going fron GP to HT?
93  busySectorKill_ = settings_->busySectorKill(); // Kill excess tracks flowing out of HT?
94  // Max. num. of stubs that can be sent from GP to HT within TM period
96  // Max. num. of stubs that can be sent out of HT within TM period
98  // or individual m bin (=q/Pt) ranges to be output to optical links.
100  // Specifies which m bins should be grouped together by BusySectorMbinRanges. If empty, then they are grouped in order 0,1,2,3,4,5 ...
102  // m bin ranges option disabled if vector empty
105 
106  bool rescaleMbins = false;
108  // Check if the total number of bins specified in cfg option BusySectorMbinRanges corresponds
109  // to the number of m bins (q/Pt) in the HT. If not, determine how much the ranges must be scaled
110  // to make this true.
111  unsigned int nTotalBins = 0;
112  for (unsigned int j = 0; j < busySectorMbinRanges_.size(); j++) {
113  nTotalBins += busySectorMbinRanges_[j];
114  }
115  rescaleMbins = (nTotalBins != nBinsQoverPtAxis_);
116  // No rescaling allowed with MBinOrder option.
117  if (rescaleMbins && busySectorUseMbinOrder_)
118  throw cms::Exception("BadConfig") << "HTrphi: BusySectorUserMbin error";
119  float rescaleFactor = rescaleMbins ? float(nBinsQoverPtAxis_) / float(nTotalBins) : 1.;
120  // Find lower and upper inclusive limits of each m bin range to be sent to a separate optical link.
123  float mBinSum = 0.;
124  for (unsigned int i = 0; i < busySectorMbinRanges_.size(); i++) {
125  busySectorMbinLow_[i] = std::round(mBinSum);
126  busySectorMbinHigh_[i] = std::round(mBinSum + rescaleFactor * busySectorMbinRanges_[i]) - 1;
127  mBinSum += rescaleFactor * busySectorMbinRanges_[i];
128  }
129  }
130  //
131  for (unsigned int i = 0; i < nBinsQoverPtAxis_; i++) {
132  for (unsigned int j = 0; j < nBinsPhiTrkAxis_; j++) {
133  pair<float, float> helix = this->helix2Dconventional(i, j); // Get track params at centre of cell.
134  float qOverPt = helix.first;
135  // Check if this cell is merged with its neighbours (as in low Pt region).
136  bool mergedCell = false;
137  if (enableMerge2x2_ && this->mergedCell(i, j))
138  mergedCell = true;
139  // Initialize each cell in HT array.
140  HTbase::htArray_(i, j) =
141  std::make_unique<HTcell>(settings, iPhiSec, iEtaReg, etaMinSector, etaMaxSector, qOverPt, i, mergedCell);
142  }
143  }
144 
145  std::stringstream text;
146  text << "\n";
147  text << "=== R-PHI HOUGH TRANSFORM AXES RANGES: abs(q/Pt) < " << maxAbsQoverPtAxis_ << " & abs(track-phi) < "
148  << maxAbsPhiTrkAxis_ << " ===\n";
149  text << "=== R-PHI HOUGH TRANSFORM ARRAY SIZE: q/Pt bins = " << nBinsQoverPtAxis_
150  << " & track-phi bins = " << nBinsPhiTrkAxis_ << " ===\n";
151  text << "=== R-PHI HOUGH TRANSFORM BIN SIZE: BIN(q/Pt) = " << binSizeQoverPtAxis_
152  << " & BIN(track-phi) = " << binSizePhiTrkAxis_ << " ===\n\n";
153  if (busySectorKill_ && busySectorUseMbinRanges_ && rescaleMbins) {
154  text << "=== R-PHI HOUGH TRANSFORM WARNING: Rescaled m bin ranges specified by cfg parameter "
155  "BusySectorMbinRanges, as they were inconsistent with total number of m bins in HT.\n";
156  text << "=== Rescaled values for BusySectorMbinRanges =";
157  for (unsigned int i = 0; i < busySectorMbinRanges_.size(); i++) {
158  text << " " << (busySectorMbinHigh_[i] - busySectorMbinLow_[i] + 1);
159  }
160  }
161  text << "\n";
162  static std::once_flag printOnce;
163  std::call_once(
164  printOnce, [](string t) { PrintL1trk() << t; }, text.str());
165 
166  // Note helix parameters at the centre of each HT cell.
167  cellCenters_.clear();
168  for (unsigned int m = 0; m < nBinsQoverPtAxis_; m++) {
169  std::vector<std::pair<float, float> > binCenters;
170  for (unsigned int c = 0; c < nBinsPhiTrkAxis_; c++)
171  binCenters.push_back(this->helix2Dhough(m, c));
172  cellCenters_.push_back(binCenters);
173  }
174  }
std::vector< unsigned int > busySectorMbinRanges_
Definition: HTrphi.h:149
float maxAbsPhiTrkAxis_
Definition: HTrphi.h:133
float maxAbsQoverPtAxis_
Definition: HTrphi.h:127
bool enableMerge2x2_
Definition: HTrphi.h:137
bool mergedCell(unsigned int iQoverPtBin, unsigned int jPhiTrkBin) const
Definition: HTrphi.cc:581
float chosenRofPhi_
Definition: HTrphi.h:131
float binSizeQoverPtAxis_
Definition: HTrphi.h:129
std::vector< unsigned int > busySectorMbinLow_
Definition: HTrphi.h:153
std::vector< unsigned int > busySectorMbinOrder_
Definition: HTrphi.h:150
const std::vector< unsigned int > & busySectorMbinRanges() const
Definition: Settings.h:178
unsigned int killSomeHTCellsRphi_
Definition: HTrphi.h:143
unsigned int nBinsPhiTrkAxis_
Definition: HTrphi.h:134
unsigned int busyInputSectorNumStubs_
Definition: HTrphi.h:147
float invPtToDphi_
Definition: HTrphi.h:120
Array2D< std::unique_ptr< HTcell > > htArray_
Definition: HTbase.h:132
ErrorMonitor * errMon_
Definition: HTrphi.h:161
bool busySectorUseMbinOrder_
Definition: HTrphi.h:152
unsigned int busySectorNumStubs() const
Definition: Settings.h:176
const std::vector< unsigned int > & busySectorMbinOrder() const
Definition: Settings.h:181
std::pair< float, float > helix2Dconventional(unsigned int i, unsigned int j) const override
Definition: HTrphi.cc:460
bool busySectorUseMbinRanges_
Definition: HTrphi.h:151
unsigned int busyInputSectorNumStubs() const
Definition: Settings.h:185
const Settings * settings_
Definition: HTbase.h:122
#define M_PI
float minInvPtToMerge2x2_
Definition: HTrphi.h:138
bool busySectorKill_
Definition: HTrphi.h:146
unsigned int busySectorNumStubs_
Definition: HTrphi.h:148
unsigned int nReceivedStubs_
Definition: HTrphi.h:158
float binSizePhiTrkAxis_
Definition: HTrphi.h:135
HTbase(const Settings *settings, unsigned int iPhiSec, unsigned int iEtaReg, unsigned int nBinsX, unsigned int nBinsY)
Definition: HTbase.cc:14
bool busyInputSectorKill_
Definition: HTrphi.h:145
std::vector< std::vector< std::pair< float, float > > > cellCenters_
Definition: HTrphi.h:123
bool busySectorKill() const
Definition: Settings.h:175
float phiCentreSector_
Definition: HTrphi.h:132
bool busyInputSectorKill() const
Definition: Settings.h:184
HTshape shape_
Definition: HTrphi.h:122
unsigned int nBinsQoverPtAxis_
Definition: HTrphi.h:128
std::vector< unsigned int > busySectorMbinHigh_
Definition: HTrphi.h:154

◆ ~HTrphi()

tmtt::HTrphi::~HTrphi ( )
overridedefault

Member Function Documentation

◆ calcLineGradArray()

float tmtt::HTrphi::calcLineGradArray ( float  r) const
private

Definition at line 605 of file HTrphi.cc.

References funct::abs(), binSizePhiTrkAxis_, binSizeQoverPtAxis_, brick, chosenRofPhi_, diamond, hexagon, invPtToDphi_, and shape_.

Referenced by store().

605  {
606  float grad = std::abs(invPtToDphi_ * (r - chosenRofPhi_));
607  // Convert it to units of bin width.
609  if (shape_ == HTshape::hexagon)
610  grad *= 3.;
611  else if (shape_ == HTshape::diamond)
612  grad *= 2.;
613  else if (shape_ == HTshape::brick)
614  grad *= 4.;
615  return grad;
616  }
float chosenRofPhi_
Definition: HTrphi.h:131
float binSizeQoverPtAxis_
Definition: HTrphi.h:129
float invPtToDphi_
Definition: HTrphi.h:120
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float binSizePhiTrkAxis_
Definition: HTrphi.h:135
HTshape shape_
Definition: HTrphi.h:122

◆ cell()

pair< unsigned int, unsigned int > tmtt::HTrphi::cell ( const L1fittedTrack fitTrk) const
overridevirtual

Implements tmtt::HTbase.

Definition at line 507 of file HTrphi.cc.

References binSizePhiTrkAxis_, binSizeQoverPtAxis_, HltBtagPostValidation_cff::c, cellCenters_, ztail::d, SiPixelRawToDigiRegional_cfi::deltaPhi, reco::deltaPhi(), tmtt::L1fittedTrack::done_bcon(), infinity, visualization-live-secondInstance_cfg::m, maxAbsPhiTrkAxis_, maxAbsQoverPtAxis_, nBinsPhiTrkAxis_, nBinsQoverPtAxis_, tmtt::L1fittedTrack::phiAtChosenR(), phiCentreSector_, funct::pow(), tmtt::L1fittedTrack::qOverPt(), tmtt::L1fittedTrack::qOverPt_bcon(), shape_, and square.

507  {
508  bool beamConstraint = fitTrk->done_bcon(); // Is beam-spot constraint available? (e.g. 5 param helix fit)
509  // Get HT axis variables corresponding to this fitted track.
510  float qOverPt = beamConstraint ? fitTrk->qOverPt_bcon() : fitTrk->qOverPt();
511  // Convert phi0 to phi at chosen radius used in HT.
512  float phiTrk = fitTrk->phiAtChosenR(beamConstraint);
513  // Measure phi relative to centre of sector.
514  float deltaPhi = reco::deltaPhi(phiTrk, phiCentreSector_);
515  // Convert to bin numbers inside HT array.
516  int iQoverPt = 999999;
517  int iPhiTrk = 999999;
518 
519  if (shape_ == HTshape::square) {
520  //--- This is a traditional HT with square cells.
521 
522  iQoverPt = floor((qOverPt - (-maxAbsQoverPtAxis_)) / binSizeQoverPtAxis_);
523  iPhiTrk = floor((deltaPhi - (-maxAbsPhiTrkAxis_)) / binSizePhiTrkAxis_);
524 
525  // Check if this cell was within the HT array.
526  if (iQoverPt >= 0 && iQoverPt < int(nBinsQoverPtAxis_) && iPhiTrk >= 0 && iPhiTrk < int(nBinsPhiTrkAxis_)) {
527  // Check if this cell is merged with its neighbours (as in low Pt region), and if so return merged cell location.
528  // New: because 2nd stage mini HT may recreate tracks from merged cells with finer cell granularity, one can't predict
529  // if a merged cell was used to create a track merely by looking at its cell location.
530  // So instead ask L1track3D, which knows if it was created from a merged HT cell or not.
531  ;
532  } else {
533  // Fitted track is not in this HT array at all. Flag this by setting "outside" bin index to 0 (Nbins-1) if outside array below (above).
534  if (iQoverPt < 0)
535  iQoverPt = 0;
536  if (iQoverPt >= int(nBinsQoverPtAxis_))
537  iQoverPt = nBinsQoverPtAxis_ - 1;
538  if (iPhiTrk < 0)
539  iPhiTrk = 0;
540  if (iPhiTrk >= int(nBinsPhiTrkAxis_))
541  iPhiTrk = nBinsPhiTrkAxis_ - 1;
542  }
543 
544  } else {
545  //--- This is are novel HT with unusual shaped cells.
546 
548  float d(0);
549  unsigned int m(0);
550  for (const auto& binCenters : cellCenters_) {
551  unsigned int c(0);
552  for (auto cellCenter : binCenters) {
553  d = std::pow((cellCenter.first - qOverPt) / (float)binSizeQoverPtAxis_, 2) +
554  std::pow((cellCenter.second - phiTrk) / (float)binSizePhiTrkAxis_, 2);
555  if (d < minD) {
556  minD = d;
557  iQoverPt = m;
558  iPhiTrk = c;
559  }
560  c++;
561  }
562  m++;
563  }
564  // Fitted track is not in this HT array at all. Flag this by setting "outside" bin index to 0 (Nbins-1) if outside array below (above).
565  if (iQoverPt < 0)
566  iQoverPt = 0;
567  if (iQoverPt >= int(nBinsQoverPtAxis_))
568  iQoverPt = nBinsQoverPtAxis_ - 1;
569  if (iPhiTrk < 0)
570  iPhiTrk = 0;
571  if (iPhiTrk >= int(nBinsPhiTrkAxis_))
572  iPhiTrk = nBinsPhiTrkAxis_ - 1;
573  }
574 
575  return pair<unsigned int, unsigned int>(iQoverPt, iPhiTrk);
576  }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
float maxAbsPhiTrkAxis_
Definition: HTrphi.h:133
float maxAbsQoverPtAxis_
Definition: HTrphi.h:127
float binSizeQoverPtAxis_
Definition: HTrphi.h:129
unsigned int nBinsPhiTrkAxis_
Definition: HTrphi.h:134
const double infinity
d
Definition: ztail.py:151
float binSizePhiTrkAxis_
Definition: HTrphi.h:135
std::vector< std::vector< std::pair< float, float > > > cellCenters_
Definition: HTrphi.h:123
float phiCentreSector_
Definition: HTrphi.h:132
HTshape shape_
Definition: HTrphi.h:122
unsigned int nBinsQoverPtAxis_
Definition: HTrphi.h:128
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ countFirmwareErrors()

void tmtt::HTrphi::countFirmwareErrors ( unsigned int  iQoverPtBin,
unsigned int  iPhiTrkBinMin,
unsigned int  iPhiTrkBinMax,
unsigned int  jPhiTrkBinMinLast,
unsigned int  jPhiTrkBinMaxLast 
)
private

Definition at line 379 of file HTrphi.cc.

References errMon_, tmtt::HTrphi::ErrorMonitor::numErrorsNorm, tmtt::HTrphi::ErrorMonitor::numErrorsTypeA, and tmtt::HTrphi::ErrorMonitor::numErrorsTypeB.

Referenced by store().

383  {
384  // Only do check if stub is being stored somewhere in this HT column.
385  if (jPhiTrkBinMax >= jPhiTrkBinMin) {
386  //--- Remaining code below checks that firmware could successfully store this stub in this column.
387  // (a) Does cell lie NE, E or SE of cell filled in previous column?
388  bool OK_a = (jPhiTrkBinMin + 1 >= jPhiTrkBinMinLast) && (jPhiTrkBinMax <= jPhiTrkBinMaxLast + 1);
389  // (b) Are no more than 2 cells filled in this column
390  bool OK_b = (jPhiTrkBinMax - jPhiTrkBinMin + 1 <= 2);
391 
392  if (!OK_a)
394  if (!OK_b)
396  errMon_->numErrorsNorm++; // No. of times a stub is added to an HT column.
397  }
398  }
std::atomic< unsigned int > numErrorsNorm
Definition: HTrphi.h:37
ErrorMonitor * errMon_
Definition: HTrphi.h:161
std::atomic< unsigned int > numErrorsTypeA
Definition: HTrphi.h:33
std::atomic< unsigned int > numErrorsTypeB
Definition: HTrphi.h:35

◆ getMbinRange()

unsigned int tmtt::HTrphi::getMbinRange ( const L1track2D trk) const

Definition at line 317 of file HTrphi.cc.

References busySectorMbinHigh_, busySectorMbinLow_, busySectorMbinOrder_, busySectorMbinRanges_, busySectorUseMbinOrder_, busySectorUseMbinRanges_, tmtt::L1track2D::cellLocationHT(), Exception, mps_fire::i, and dqmdumpme::k.

Referenced by tmtt::MuxHToutputs::exec(), and killTracksBusySec().

317  {
319  unsigned int mBin = trk.cellLocationHT().first;
320  unsigned int mBinOrder;
322  // User wants to group bins in a wierd order.
323  mBinOrder = 99999;
324  for (unsigned int k = 0; k < busySectorMbinOrder_.size(); k++) {
325  if (mBin == busySectorMbinOrder_[k])
326  mBinOrder = k;
327  }
328  if (mBinOrder == 99999)
329  throw cms::Exception("LogicError") << "HTrphi::getMbinRange() mBinOrder calculation wrong.";
330  } else {
331  // User grouping bins in numerical order 0,1,2,3,4,5...
332  mBinOrder = mBin;
333  }
334  for (unsigned int i = 0; i < busySectorMbinRanges_.size(); i++) {
335  if (mBinOrder >= busySectorMbinLow_[i] && mBinOrder <= busySectorMbinHigh_[i])
336  return i;
337  }
338  throw cms::Exception("LogicError") << "HTrphi::getMbinRange() messed up";
339  } else {
340  return 0;
341  }
342  }
std::vector< unsigned int > busySectorMbinRanges_
Definition: HTrphi.h:149
std::vector< unsigned int > busySectorMbinLow_
Definition: HTrphi.h:153
std::vector< unsigned int > busySectorMbinOrder_
Definition: HTrphi.h:150
bool busySectorUseMbinOrder_
Definition: HTrphi.h:152
bool busySectorUseMbinRanges_
Definition: HTrphi.h:151
std::vector< unsigned int > busySectorMbinHigh_
Definition: HTrphi.h:154

◆ helix2Dconventional()

pair< float, float > tmtt::HTrphi::helix2Dconventional ( unsigned int  i,
unsigned int  j 
) const
overridevirtual

Implements tmtt::HTbase.

Definition at line 460 of file HTrphi.cc.

References chosenRofPhi_, reco::deltaPhi(), helix2Dhough(), invPtToDphi_, and dqmiolumiharvest::j.

Referenced by HTrphi().

460  {
461  // Get the helix parameters corresponding to the axes definitions of the HT.
462  pair<float, float> helix2Dht = this->helix2Dhough(i, j);
463  // Convert to the conventionally agreed pair of helix parameters, (q/pt, phi0).
464  float qOverPt = helix2Dht.first; // easy
465  // If HT defined track phi other than at r=0, must correct to get phi0. Allow for 2*pi wrapping of phi.
466  float phi0 = reco::deltaPhi(helix2Dht.second + invPtToDphi_ * chosenRofPhi_ * qOverPt, 0.);
467  return pair<float, float>(qOverPt, phi0);
468  }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
float chosenRofPhi_
Definition: HTrphi.h:131
float invPtToDphi_
Definition: HTrphi.h:120
std::pair< float, float > helix2Dhough(unsigned int i, unsigned int j) const override
Definition: HTrphi.cc:404

◆ helix2Dhough()

pair< float, float > tmtt::HTrphi::helix2Dhough ( unsigned int  i,
unsigned int  j 
) const
overridevirtual

Implements tmtt::HTbase.

Definition at line 404 of file HTrphi.cc.

References binSizePhiTrkAxis_, binSizeQoverPtAxis_, brick, reco::deltaPhi(), diamond, enableMerge2x2_, hexagon, mps_fire::i, dqmiolumiharvest::j, maxAbsPhiTrkAxis_, maxAbsQoverPtAxis_, mergedCell(), phiCentreSector_, shape_, and square.

Referenced by helix2Dconventional().

404  {
405  unsigned int qOverPtBin = i;
406  unsigned int phiTrkBin = j;
407 
408  // If using merged 2x2 cells in low Pt parts of array, must correct for this.
409  bool merged = false;
410  if (enableMerge2x2_) {
411  // Check if this cell is merged with its neighbours (as in low Pt region).
412  if (this->mergedCell(i, j)) {
413  merged = true;
414  // Get location of cell that this cell is merged into (iStore, jStore).
415  // Calculation assumes HT array has even number of bins in both dimensions.
416  if (i % 2 == 1)
417  qOverPtBin = i - 1;
418  if (j % 2 == 1)
419  phiTrkBin = j - 1;
420  }
421  }
422 
423  float qOverPtBinCenter = .5;
424  float phiTrkBinCenter = .5;
425 
426  if (shape_ != HTshape::square) {
427  qOverPtBinCenter = 0.;
428 
429  float evenPhiPos = 0., oddPhiPos = 0.;
430  if (shape_ == HTshape::hexagon) {
431  evenPhiPos = 1. / 6.;
432  oddPhiPos = 2. / 3.;
433  } else if (shape_ == HTshape::diamond) {
434  evenPhiPos = 0.;
435  oddPhiPos = 0.5;
436  } else if (shape_ == HTshape::brick) {
437  evenPhiPos = 0.25;
438  oddPhiPos = 0.75;
439  }
440  phiTrkBinCenter = (qOverPtBin % 2 == 0) ? evenPhiPos : oddPhiPos;
441  }
442 
443  float qOverPt = -maxAbsQoverPtAxis_ + (qOverPtBin + qOverPtBinCenter) * binSizeQoverPtAxis_;
444  float phiTrk = -maxAbsPhiTrkAxis_ + (phiTrkBin + phiTrkBinCenter) * binSizePhiTrkAxis_;
445 
446  if (merged) {
447  qOverPt += 0.5 * binSizeQoverPtAxis_;
448  phiTrk += 0.5 * binSizePhiTrkAxis_;
449  }
450 
451  // Correct phiTrk to centre of sector, taking care of 2*pi wrapping
452  phiTrk = reco::deltaPhi(phiTrk + phiCentreSector_, 0.);
453  return pair<float, float>(qOverPt, phiTrk);
454  }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
float maxAbsPhiTrkAxis_
Definition: HTrphi.h:133
float maxAbsQoverPtAxis_
Definition: HTrphi.h:127
bool enableMerge2x2_
Definition: HTrphi.h:137
bool mergedCell(unsigned int iQoverPtBin, unsigned int jPhiTrkBin) const
Definition: HTrphi.cc:581
float binSizeQoverPtAxis_
Definition: HTrphi.h:129
float binSizePhiTrkAxis_
Definition: HTrphi.h:135
float phiCentreSector_
Definition: HTrphi.h:132
HTshape shape_
Definition: HTrphi.h:122

◆ iPhiRange()

pair< unsigned int, unsigned int > tmtt::HTrphi::iPhiRange ( const Stub stub,
unsigned int  iQoverPtBin,
bool  debug = false 
) const
private

Definition at line 348 of file HTrphi.cc.

References funct::abs(), binSizePhiTrkAxis_, binSizeQoverPtAxis_, chosenRofPhi_, tmtt::HTbase::convertCoordRangeToBinRange(), reco::deltaPhi(), invPtToDphi_, killSomeHTCellsRphi_, maxAbsPhiTrkAxis_, maxAbsQoverPtAxis_, nBinsPhiTrkAxis_, tmtt::Stub::phi(), phiCentreSector_, and tmtt::Stub::r().

Referenced by store().

348  {
349  // Note q/Pt value corresponding to centre of this bin.
350  float qOverPtBin = -maxAbsQoverPtAxis_ + (iQoverPtBin + 0.5) * binSizeQoverPtAxis_;
351  // Note change in this q/Pt value needed to reach either edge of the bin.
352  float qOverPtBinVar = 0.5 * binSizeQoverPtAxis_;
353 
354  // Reducing effective bin width can reduce fake rate.
355  //qOverPtVar = 0.4*binSizeQoverPtAxis_;
356 
357  // Calculate range of track-phi that would allow a track in this q/Pt range to pass through the stub.
358  float phiTrk = stub->phi() + invPtToDphi_ * qOverPtBin * (stub->r() - chosenRofPhi_);
359  // The next line does the phiTrk calculation without the usual approximation, but it doesn't
360  // improve performance.
361  //float phiTrk = stub->phi() + asin(invPtToDphi_ * qOverPtBin * stub->r()) - asin(invPtToDphi_ * qOverPtBin * chosenRofPhi_);
362  float phiTrkVar = invPtToDphi_ * qOverPtBinVar * std::abs(stub->r() - chosenRofPhi_);
363  float phiTrkMin = phiTrk - phiTrkVar;
364  float phiTrkMax = phiTrk + phiTrkVar;
365 
366  float deltaPhiMin = reco::deltaPhi(phiTrkMin, phiCentreSector_); // Offset to centre of sector.
367  float deltaPhiMax = reco::deltaPhi(phiTrkMax, phiCentreSector_);
368  pair<float, float> phiTrkRange(deltaPhiMin, deltaPhiMax);
369 
370  // Determine which HT array cell range in track-phi this range "phiTrkRange" corresponds to.
371  pair<unsigned int, unsigned int> iPhiTrkBinRange = this->HTbase::convertCoordRangeToBinRange(
373 
374  return iPhiTrkBinRange;
375  }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
float maxAbsPhiTrkAxis_
Definition: HTrphi.h:133
float maxAbsQoverPtAxis_
Definition: HTrphi.h:127
float chosenRofPhi_
Definition: HTrphi.h:131
float binSizeQoverPtAxis_
Definition: HTrphi.h:129
virtual std::pair< unsigned int, unsigned int > convertCoordRangeToBinRange(std::pair< float, float > coordRange, unsigned int nBinsAxis, float coordAxisMin, float coordAxisBinSize, unsigned int killSomeHTcells) const
Definition: HTbase.cc:122
unsigned int killSomeHTCellsRphi_
Definition: HTrphi.h:143
unsigned int nBinsPhiTrkAxis_
Definition: HTrphi.h:134
float invPtToDphi_
Definition: HTrphi.h:120
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float binSizePhiTrkAxis_
Definition: HTrphi.h:135
float phiCentreSector_
Definition: HTrphi.h:132

◆ killTracksBusySec()

list< L1track2D > tmtt::HTrphi::killTracksBusySec ( const std::list< L1track2D > &  tracks) const
overrideprivatevirtual

Implements tmtt::HTbase.

Definition at line 621 of file HTrphi.cc.

References busySectorKill_, busySectorMbinRanges_, busySectorNumStubs_, busySectorUseMbinRanges_, getMbinRange(), runTheMatrix::keep, and pwdgSkimBPark_cfi::tracks.

621  {
622  list<L1track2D> outTracks;
623 
624  if (busySectorKill_) {
625  unsigned int nStubsOut = 0; // #stubs assigned to tracks in this sector.
626  // #stubs assigned to each m bin range in this sector.
627  vector<unsigned int> nStubsOutInRange(busySectorMbinRanges_.size(), 0);
628 
629  for (const L1track2D& trk : tracks) {
630  bool keep = true;
631  unsigned int nStubs = trk.numStubs(); // #stubs on this track.
632  if (busySectorUseMbinRanges_) { // Are tracks from different m bin ranges output seperately to increase bandwidth?
633  unsigned int mBinRange = this->getMbinRange(trk); // Which m bin range is this track in?
634  nStubsOutInRange[mBinRange] += nStubs;
635  if (nStubsOutInRange[mBinRange] > busySectorNumStubs_)
636  keep = false;
637  } else {
638  nStubsOut += nStubs;
639  if (nStubsOut > busySectorNumStubs_)
640  keep = false;
641  }
642 
643  if (keep)
644  outTracks.push_back(trk);
645  }
646 
647  } else {
648  outTracks = tracks;
649  }
650 
651  return outTracks;
652  }
std::vector< unsigned int > busySectorMbinRanges_
Definition: HTrphi.h:149
bool busySectorUseMbinRanges_
Definition: HTrphi.h:151
bool busySectorKill_
Definition: HTrphi.h:146
unsigned int busySectorNumStubs_
Definition: HTrphi.h:148
unsigned int getMbinRange(const L1track2D &trk) const
Definition: HTrphi.cc:317

◆ mergedCell()

bool tmtt::HTrphi::mergedCell ( unsigned int  iQoverPtBin,
unsigned int  jPhiTrkBin 
) const

Definition at line 581 of file HTrphi.cc.

References binSizeQoverPtAxis_, enableMerge2x2_, mps_fire::i, maxAbsQoverPtAxis_, merge(), SiStripPI::min, minInvPtToMerge2x2_, and nBinsQoverPtAxis_.

Referenced by helix2Dhough(), HTrphi(), and store().

581  {
582  bool merge = false;
583 
584  if (enableMerge2x2_) {
585  unsigned int i = iQoverPtBin;
586  //unsigned int j = jPhiTrkBin;
587 
588  // Calculate number of merged bins on each q/Pt side of array.
589  float fMergeBins = (maxAbsQoverPtAxis_ - minInvPtToMerge2x2_) / (2. * binSizeQoverPtAxis_);
590  // Number of unmerged bins this corresponds to, which must be even, since each merged bin comprises two normal q/pt bins.
591  unsigned int numQoverPtBinsToMerge = 2 * min((unsigned int)(std::round(fMergeBins)), (nBinsQoverPtAxis_ / 4));
592  const float small = 0.001;
593  if (minInvPtToMerge2x2_ < small && (unsigned int)(std::round(2. * fMergeBins)) % 2 == 1)
594  numQoverPtBinsToMerge++;
595  unsigned int iB = (nBinsQoverPtAxis_ - 1) - i; // Count backwards across array.
596  if (min(i, iB) < numQoverPtBinsToMerge)
597  merge = true;
598  }
599 
600  return merge;
601  }
Definition: merge.py:1
float maxAbsQoverPtAxis_
Definition: HTrphi.h:127
bool enableMerge2x2_
Definition: HTrphi.h:137
float binSizeQoverPtAxis_
Definition: HTrphi.h:129
int merge(int argc, char *argv[])
Definition: DMRmerge.cc:37
float minInvPtToMerge2x2_
Definition: HTrphi.h:138
unsigned int nBinsQoverPtAxis_
Definition: HTrphi.h:128

◆ nReceivedStubs()

unsigned int tmtt::HTrphi::nReceivedStubs ( ) const
inline

Definition at line 89 of file HTrphi.h.

References nReceivedStubs_.

89 { return nReceivedStubs_; }
unsigned int nReceivedStubs_
Definition: HTrphi.h:158

◆ rowOrder()

vector< unsigned int > tmtt::HTrphi::rowOrder ( unsigned int  numRows) const
overrideprivatevirtual

Implements tmtt::HTbase.

Definition at line 658 of file HTrphi.cc.

References mps_fire::i.

658  {
659  vector<unsigned int> iOrder;
660 
661  // Logic slightly different depending on whether HT array has even or odd number of rows.
662  const bool oddNumRows = (numRows % 2 == 1);
663 
664  // This selects middle rows first before moving to exterior ones.
665  if (oddNumRows) {
666  unsigned int middleRow = (numRows - 1) / 2;
667  iOrder.push_back(middleRow);
668  for (unsigned int i = 1; i <= (numRows - 1) / 2; i++) {
669  iOrder.push_back(middleRow - i); // -ve charge
670  iOrder.push_back(middleRow + i); // +ve charge
671  }
672  } else {
673  unsigned int startRowPos = numRows / 2;
674  unsigned int startRowNeg = startRowPos - 1;
675  for (unsigned int i = 0; i < numRows / 2; i++) {
676  iOrder.push_back(startRowNeg - i); // -ve charge
677  iOrder.push_back(startRowPos + i); // +ve charge
678  }
679  }
680 
681  return iOrder;
682  }

◆ store()

void tmtt::HTrphi::store ( Stub stub,
const std::vector< bool > &  inEtaSubSecs 
)

Definition at line 179 of file HTrphi.cc.

References funct::abs(), spclusmultinvestigator_cfi::binMax, binMin, binSizePhiTrkAxis_, binSizeQoverPtAxis_, brick, busyInputSectorKill_, busyInputSectorNumStubs_, calcLineGradArray(), chosenRofPhi_, countFirmwareErrors(), reco::deltaPhi(), diamond, enableMerge2x2_, errMon_, hexagon, tmtt::HTbase::htArray_, mps_fire::i, invPtToDphi_, iPhiRange(), dqmiolumiharvest::j, SiStripPI::max, maxAbsPhiTrkAxis_, maxAbsQoverPtAxis_, tmtt::HTrphi::ErrorMonitor::maxLineGradient, mergedCell(), nBinsPhiTrkAxis_, nBinsQoverPtAxis_, nReceivedStubs_, tmtt::Stub::phi(), phiCentreSector_, tmtt::Stub::r(), shape_, and square.

179  {
180  // Optionally, only store stubs that can be sent from GP to HT within TM period.
182  nReceivedStubs_++;
183 
184  unsigned int jPhiTrkBinMinLast = 0; // Used for error checking
185  unsigned int jPhiTrkBinMaxLast = 99999;
186 
187  // Loop over q/Pt related bins in HT array.
188  for (unsigned int i = 0; i < nBinsQoverPtAxis_; i++) {
189  if (shape_ == HTshape::square) {
190  //--- This is a traditional HT with square cells.
191 
192  // In this q/Pt bin, find the range of phi bins that this stub is consistent with.
193  pair<unsigned int, unsigned int> jRange = this->iPhiRange(stub, i);
194  unsigned int jPhiTrkBinMin = jRange.first;
195  unsigned int jPhiTrkBinMax = jRange.second;
196 
197  // Store stubs in these cells.
198  for (unsigned int j = jPhiTrkBinMin; j <= jPhiTrkBinMax; j++) {
199  bool canStoreStub = true;
200  unsigned int iStore = i;
201  unsigned int jStore = j;
202 
203  // Optionally merge 2x2 neighbouring cells into a single cell at low Pt, to reduce efficiency loss
204  // due to scattering.
205  if (enableMerge2x2_) {
206  // Check if this cell is merged with its neighbours (as in low Pt region).
207  if (this->mergedCell(i, j)) {
208  // Get location of cell that this cell is merged into (iStore, jStore).
209  // Calculation assumes HT array has even number of bins in both dimensions.
210  if (i % 2 == 1)
211  iStore = i - 1;
212  if (j % 2 == 1)
213  jStore = j - 1;
214  // If this stub was already stored in this merged 2x2 cell, then don't store it again.
215  if (HTbase::htArray_(iStore, jStore)->stubStoredInCell(stub))
216  canStoreStub = false;
217  }
218  }
219 
220  if (canStoreStub)
221  HTbase::htArray_(iStore, jStore)->store(stub, inEtaSubSecs); // Calls HTcell::store()
222  }
223 
224  // Check that limitations of firmware would not prevent stub being stored correctly in this HT column.
225  if (errMon_ != nullptr) {
226  this->countFirmwareErrors(i, jPhiTrkBinMin, jPhiTrkBinMax, jPhiTrkBinMinLast, jPhiTrkBinMaxLast);
227  jPhiTrkBinMinLast = jPhiTrkBinMin;
228  jPhiTrkBinMaxLast = jPhiTrkBinMax;
229  }
230 
231  } else {
232  //--- This is are novel HT with unusual shaped cells.
233 
234  if (shape_ == HTshape::diamond) {
235  //--- This HT has diamond shaped cells.
236 
237  float qOverPtBin = -maxAbsQoverPtAxis_ + i * binSizeQoverPtAxis_;
238  float phiTrk = reco::deltaPhi(stub->phi(), phiCentreSector_) +
239  invPtToDphi_ * qOverPtBin * (stub->r() - chosenRofPhi_) + maxAbsPhiTrkAxis_;
240  if (i % 2 == 0)
241  phiTrk += binSizePhiTrkAxis_ / 2.;
242  unsigned int binCenter = std::floor(phiTrk / binSizePhiTrkAxis_);
243  if (binCenter < nBinsPhiTrkAxis_)
244  HTbase::htArray_(i, binCenter)->store(stub, inEtaSubSecs);
245 
246  } else if (shape_ == HTshape::hexagon) {
247  //--- This HT has hexagonal cells (with two of its sides parallel to the phi axis).
248 
249  float qOverPtBin = -maxAbsQoverPtAxis_ + i * binSizeQoverPtAxis_;
250  float qOverPtBinVar = binSizeQoverPtAxis_;
251  float phiTrk = reco::deltaPhi(stub->phi(), phiCentreSector_) +
252  invPtToDphi_ * qOverPtBin * (stub->r() - chosenRofPhi_) + maxAbsPhiTrkAxis_;
253  float phiTrkVar = invPtToDphi_ * qOverPtBinVar * std::abs(stub->r() - chosenRofPhi_);
254  float phiTrkMin = phiTrk - phiTrkVar;
255  float phiTrkMax = phiTrk + phiTrkVar;
256  if (i % 2 == 0)
257  phiTrk += binSizePhiTrkAxis_ / 6.;
258  else {
259  phiTrk -= binSizePhiTrkAxis_ / 3.;
260  phiTrkMin -= binSizePhiTrkAxis_ / 2.;
261  phiTrkMax -= binSizePhiTrkAxis_ / 2.;
262  }
263  unsigned int iCenter = std::floor(phiTrk / binSizePhiTrkAxis_ * 3.);
264  unsigned int iMin = std::floor(phiTrkMin / binSizePhiTrkAxis_ * 3.);
265  unsigned int iMax = std::floor(phiTrkMax / binSizePhiTrkAxis_ * 3.);
266  std::pair<bool, unsigned int> binCenter;
267  std::pair<bool, unsigned int> binMin;
268  std::pair<bool, unsigned int> binMax;
269  binCenter.second = iCenter / 3;
270  binMin.second = iMin / 3;
271  binMax.second = iMax / 3;
272  binCenter.first = !(iCenter % 3 == 2);
273  binMin.first = (iMin % 3 == 0);
274  binMax.first = (iMax % 3 == 0);
275  if (binCenter.first && binCenter.second < nBinsPhiTrkAxis_)
276  HTbase::htArray_(i, binCenter.second)->store(stub, inEtaSubSecs);
277  else if (binMin.first && binMin.second < nBinsPhiTrkAxis_)
278  HTbase::htArray_(i, binMin.second)->store(stub, inEtaSubSecs);
279  else if (binMax.first && binMax.second < nBinsPhiTrkAxis_)
280  HTbase::htArray_(i, binMax.second)->store(stub, inEtaSubSecs);
281 
282  } else if (shape_ == HTshape::brick) {
283  //--- This HT has square cells with alternate rows shifted horizontally by 0.5*cell_width.
284 
285  float qOverPtBin = -maxAbsQoverPtAxis_ + i * binSizeQoverPtAxis_;
286  float qOverPtBinVar = binSizeQoverPtAxis_;
287  float phiTrk = reco::deltaPhi(stub->phi(), phiCentreSector_) +
288  invPtToDphi_ * qOverPtBin * (stub->r() - chosenRofPhi_) + maxAbsPhiTrkAxis_;
289  float phiTrkVar = invPtToDphi_ * qOverPtBinVar * std::abs(stub->r() - chosenRofPhi_);
290  float phiTrkMin = phiTrk - phiTrkVar;
291  float phiTrkMax = phiTrk + phiTrkVar;
292  unsigned int iMin = std::floor(phiTrkMin / binSizePhiTrkAxis_ * 2.);
293  unsigned int iMax = std::floor(phiTrkMax / binSizePhiTrkAxis_ * 2.);
294  std::pair<bool, unsigned int> binMin;
295  std::pair<bool, unsigned int> binMax;
296  binMin.second = iMin / 2;
297  binMax.second = iMax / 2;
298  binMin.first = (iMin % 2 == i % 2);
299  binMax.first = (iMax % 2 == i % 2);
300  if (binMin.first && binMin.second < nBinsPhiTrkAxis_)
301  HTbase::htArray_(i, binMin.second)->store(stub, inEtaSubSecs);
302  else if (binMax.first && binMax.second < nBinsPhiTrkAxis_)
303  HTbase::htArray_(i, binMax.second)->store(stub, inEtaSubSecs);
304  }
305  }
306  }
307  // Note max. |gradient| that the line corresponding to any stub in any of the r-phi HT arrays could have.
308  // Firmware assumes this should not exceed 1.0;
309  if (errMon_ != nullptr) {
310  errMon_->maxLineGradient = max(errMon_->maxLineGradient.load(), this->calcLineGradArray(stub->r()));
311  }
312  }
313  }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
float maxAbsPhiTrkAxis_
Definition: HTrphi.h:133
float maxAbsQoverPtAxis_
Definition: HTrphi.h:127
bool enableMerge2x2_
Definition: HTrphi.h:137
bool mergedCell(unsigned int iQoverPtBin, unsigned int jPhiTrkBin) const
Definition: HTrphi.cc:581
float chosenRofPhi_
Definition: HTrphi.h:131
float binSizeQoverPtAxis_
Definition: HTrphi.h:129
unsigned int nBinsPhiTrkAxis_
Definition: HTrphi.h:134
unsigned int busyInputSectorNumStubs_
Definition: HTrphi.h:147
std::pair< unsigned int, unsigned int > iPhiRange(const Stub *stub, unsigned int iQoverPtBin, bool debug=false) const
Definition: HTrphi.cc:348
std::atomic< float > maxLineGradient
Definition: HTrphi.h:31
float invPtToDphi_
Definition: HTrphi.h:120
Array2D< std::unique_ptr< HTcell > > htArray_
Definition: HTbase.h:132
ErrorMonitor * errMon_
Definition: HTrphi.h:161
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void countFirmwareErrors(unsigned int iQoverPtBin, unsigned int iPhiTrkBinMin, unsigned int iPhiTrkBinMax, unsigned int jPhiTrkBinMinLast, unsigned int jPhiTrkBinMaxLast)
Definition: HTrphi.cc:379
unsigned int nReceivedStubs_
Definition: HTrphi.h:158
float binSizePhiTrkAxis_
Definition: HTrphi.h:135
const float binMin[32]
bool busyInputSectorKill_
Definition: HTrphi.h:145
float phiCentreSector_
Definition: HTrphi.h:132
float calcLineGradArray(float r) const
Definition: HTrphi.cc:605
HTshape shape_
Definition: HTrphi.h:122
unsigned int nBinsQoverPtAxis_
Definition: HTrphi.h:128

◆ trueCell()

pair< unsigned int, unsigned int > tmtt::HTrphi::trueCell ( const TP tp) const
overridevirtual

Implements tmtt::HTbase.

Definition at line 473 of file HTrphi.cc.

References binSizePhiTrkAxis_, binSizeQoverPtAxis_, chosenRofPhi_, SiPixelRawToDigiRegional_cfi::deltaPhi, reco::deltaPhi(), maxAbsPhiTrkAxis_, maxAbsQoverPtAxis_, nBinsPhiTrkAxis_, nBinsQoverPtAxis_, phiCentreSector_, and cmsswSequenceInfo::tp.

Referenced by tmtt::L1track3D::cheat().

473  {
474  // Get HT axis variables corresponding to this TP.
475  float qOverPt = tp->qOverPt();
476  float phiTrk = tp->trkPhiAtR(chosenRofPhi_);
477  // Measure phi relative to centre of sector.
478  float deltaPhi = reco::deltaPhi(phiTrk, phiCentreSector_);
479  // Convert to bin numbers inside HT array.
480  int iQoverPt = floor((qOverPt - (-maxAbsQoverPtAxis_)) / binSizeQoverPtAxis_);
481  int iPhiTrk = floor((deltaPhi - (-maxAbsPhiTrkAxis_)) / binSizePhiTrkAxis_);
482  // Check if this cell was within the HT array.
483  if (iQoverPt >= 0 && iQoverPt < int(nBinsQoverPtAxis_) && iPhiTrk >= 0 && iPhiTrk < int(nBinsPhiTrkAxis_)) {
484  // Check if this cell is merged with its neighbours (as in low Pt region), and if so return merged cell location.
485  // New: because 2nd stage mini HT may recreate tracks from merged cells with finer cell granularity, one can't predict
486  // if a merged cell was used to create a track merely by looking at its cell location.
487  // So instead ask L1track3D, which knows if it was created from a merged HT cell or not.
488  ;
489  } else {
490  // TP is not in this HT array at all. Flag this by setting "outside" bin index to 0 (Nbins) if outside array below (above).
491  if (iQoverPt < 0)
492  iQoverPt = 0;
493  if (iQoverPt >= int(nBinsQoverPtAxis_))
494  iQoverPt = nBinsQoverPtAxis_ - 1;
495  if (iPhiTrk < 0)
496  iPhiTrk = 0;
497  if (iPhiTrk >= int(nBinsPhiTrkAxis_))
498  iPhiTrk = nBinsPhiTrkAxis_ - 1;
499  }
500  return pair<unsigned int, unsigned int>(iQoverPt, iPhiTrk);
501  }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
float maxAbsPhiTrkAxis_
Definition: HTrphi.h:133
float maxAbsQoverPtAxis_
Definition: HTrphi.h:127
float chosenRofPhi_
Definition: HTrphi.h:131
float binSizeQoverPtAxis_
Definition: HTrphi.h:129
unsigned int nBinsPhiTrkAxis_
Definition: HTrphi.h:134
float binSizePhiTrkAxis_
Definition: HTrphi.h:135
float phiCentreSector_
Definition: HTrphi.h:132
unsigned int nBinsQoverPtAxis_
Definition: HTrphi.h:128

Member Data Documentation

◆ binSizePhiTrkAxis_

float tmtt::HTrphi::binSizePhiTrkAxis_
private

Definition at line 135 of file HTrphi.h.

Referenced by calcLineGradArray(), cell(), helix2Dhough(), HTrphi(), iPhiRange(), store(), and trueCell().

◆ binSizeQoverPtAxis_

float tmtt::HTrphi::binSizeQoverPtAxis_
private

◆ busyInputSectorKill_

bool tmtt::HTrphi::busyInputSectorKill_
private

Definition at line 145 of file HTrphi.h.

Referenced by HTrphi(), and store().

◆ busyInputSectorNumStubs_

unsigned int tmtt::HTrphi::busyInputSectorNumStubs_
private

Definition at line 147 of file HTrphi.h.

Referenced by HTrphi(), and store().

◆ busySectorKill_

bool tmtt::HTrphi::busySectorKill_
private

Definition at line 146 of file HTrphi.h.

Referenced by HTrphi(), and killTracksBusySec().

◆ busySectorMbinHigh_

std::vector<unsigned int> tmtt::HTrphi::busySectorMbinHigh_
private

Definition at line 154 of file HTrphi.h.

Referenced by getMbinRange(), and HTrphi().

◆ busySectorMbinLow_

std::vector<unsigned int> tmtt::HTrphi::busySectorMbinLow_
private

Definition at line 153 of file HTrphi.h.

Referenced by getMbinRange(), and HTrphi().

◆ busySectorMbinOrder_

std::vector<unsigned int> tmtt::HTrphi::busySectorMbinOrder_
private

Definition at line 150 of file HTrphi.h.

Referenced by getMbinRange(), and HTrphi().

◆ busySectorMbinRanges_

std::vector<unsigned int> tmtt::HTrphi::busySectorMbinRanges_
private

Definition at line 149 of file HTrphi.h.

Referenced by getMbinRange(), HTrphi(), and killTracksBusySec().

◆ busySectorNumStubs_

unsigned int tmtt::HTrphi::busySectorNumStubs_
private

Definition at line 148 of file HTrphi.h.

Referenced by HTrphi(), and killTracksBusySec().

◆ busySectorUseMbinOrder_

bool tmtt::HTrphi::busySectorUseMbinOrder_
private

Definition at line 152 of file HTrphi.h.

Referenced by getMbinRange(), and HTrphi().

◆ busySectorUseMbinRanges_

bool tmtt::HTrphi::busySectorUseMbinRanges_
private

Definition at line 151 of file HTrphi.h.

Referenced by getMbinRange(), HTrphi(), and killTracksBusySec().

◆ cellCenters_

std::vector<std::vector<std::pair<float, float> > > tmtt::HTrphi::cellCenters_
private

Definition at line 123 of file HTrphi.h.

Referenced by cell(), and HTrphi().

◆ chosenRofPhi_

float tmtt::HTrphi::chosenRofPhi_
private

Definition at line 131 of file HTrphi.h.

Referenced by calcLineGradArray(), helix2Dconventional(), iPhiRange(), store(), and trueCell().

◆ enableMerge2x2_

bool tmtt::HTrphi::enableMerge2x2_
private

Definition at line 137 of file HTrphi.h.

Referenced by helix2Dhough(), HTrphi(), mergedCell(), and store().

◆ errMon_

ErrorMonitor* tmtt::HTrphi::errMon_
private

Definition at line 161 of file HTrphi.h.

Referenced by countFirmwareErrors(), and store().

◆ invPtToDphi_

float tmtt::HTrphi::invPtToDphi_
private

Definition at line 120 of file HTrphi.h.

Referenced by calcLineGradArray(), helix2Dconventional(), iPhiRange(), and store().

◆ killSomeHTCellsRphi_

unsigned int tmtt::HTrphi::killSomeHTCellsRphi_
private

Definition at line 143 of file HTrphi.h.

Referenced by HTrphi(), and iPhiRange().

◆ maxAbsPhiTrkAxis_

float tmtt::HTrphi::maxAbsPhiTrkAxis_
private

Definition at line 133 of file HTrphi.h.

Referenced by cell(), helix2Dhough(), HTrphi(), iPhiRange(), store(), and trueCell().

◆ maxAbsQoverPtAxis_

float tmtt::HTrphi::maxAbsQoverPtAxis_
private

Definition at line 127 of file HTrphi.h.

Referenced by cell(), helix2Dhough(), HTrphi(), iPhiRange(), mergedCell(), store(), and trueCell().

◆ minInvPtToMerge2x2_

float tmtt::HTrphi::minInvPtToMerge2x2_
private

Definition at line 138 of file HTrphi.h.

Referenced by HTrphi(), and mergedCell().

◆ nBinsPhiTrkAxis_

unsigned int tmtt::HTrphi::nBinsPhiTrkAxis_
private

Definition at line 134 of file HTrphi.h.

Referenced by cell(), HTrphi(), iPhiRange(), store(), and trueCell().

◆ nBinsQoverPtAxis_

unsigned int tmtt::HTrphi::nBinsQoverPtAxis_
private

Definition at line 128 of file HTrphi.h.

Referenced by cell(), HTrphi(), mergedCell(), store(), and trueCell().

◆ nReceivedStubs_

unsigned int tmtt::HTrphi::nReceivedStubs_
private

Definition at line 158 of file HTrphi.h.

Referenced by HTrphi(), nReceivedStubs(), and store().

◆ phiCentreSector_

float tmtt::HTrphi::phiCentreSector_
private

Definition at line 132 of file HTrphi.h.

Referenced by cell(), helix2Dhough(), iPhiRange(), store(), and trueCell().

◆ shape_

HTshape tmtt::HTrphi::shape_
private

Definition at line 122 of file HTrphi.h.

Referenced by calcLineGradArray(), cell(), helix2Dhough(), HTrphi(), and store().