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_, DummyCfis::c, cellCenters_, diamond, tmtt::Settings::enableMerge2x2(), enableMerge2x2_, Exception, ALCARECOEcalPhiSym_cff::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(printOnce, [](string t) { PrintL1trk() << t; }, text.str());
164 
165  // Note helix parameters at the centre of each HT cell.
166  cellCenters_.clear();
167  for (unsigned int m = 0; m < nBinsQoverPtAxis_; m++) {
168  std::vector<std::pair<float, float> > binCenters;
169  for (unsigned int c = 0; c < nBinsPhiTrkAxis_; c++)
170  binCenters.push_back(this->helix2Dhough(m, c));
171  cellCenters_.push_back(binCenters);
172  }
173  }
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:580
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:459
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 604 of file HTrphi.cc.

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

Referenced by store().

604  {
605  float grad = std::abs(invPtToDphi_ * (r - chosenRofPhi_));
606  // Convert it to units of bin width.
608  if (shape_ == HTshape::hexagon)
609  grad *= 3.;
610  else if (shape_ == HTshape::diamond)
611  grad *= 2.;
612  else if (shape_ == HTshape::brick)
613  grad *= 4.;
614  return grad;
615  }
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 506 of file HTrphi.cc.

References binSizePhiTrkAxis_, binSizeQoverPtAxis_, DummyCfis::c, cellCenters_, ztail::d, reco::deltaPhi(), srCondWrite_cfg::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.

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

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

Referenced by store().

382  {
383  // Only do check if stub is being stored somewhere in this HT column.
384  if (jPhiTrkBinMax >= jPhiTrkBinMin) {
385  //--- Remaining code below checks that firmware could successfully store this stub in this column.
386  // (a) Does cell lie NE, E or SE of cell filled in previous column?
387  bool OK_a = (jPhiTrkBinMin + 1 >= jPhiTrkBinMinLast) && (jPhiTrkBinMax <= jPhiTrkBinMaxLast + 1);
388  // (b) Are no more than 2 cells filled in this column
389  bool OK_b = (jPhiTrkBinMax - jPhiTrkBinMin + 1 <= 2);
390 
391  if (!OK_a)
393  if (!OK_b)
395  errMon_->numErrorsNorm++; // No. of times a stub is added to an HT column.
396  }
397  }
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 316 of file HTrphi.cc.

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

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

316  {
318  unsigned int mBin = trk.cellLocationHT().first;
319  unsigned int mBinOrder;
321  // User wants to group bins in a wierd order.
322  mBinOrder = 99999;
323  for (unsigned int k = 0; k < busySectorMbinOrder_.size(); k++) {
324  if (mBin == busySectorMbinOrder_[k])
325  mBinOrder = k;
326  }
327  if (mBinOrder == 99999)
328  throw cms::Exception("LogicError") << "HTrphi::getMbinRange() mBinOrder calculation wrong.";
329  } else {
330  // User grouping bins in numerical order 0,1,2,3,4,5...
331  mBinOrder = mBin;
332  }
333  for (unsigned int i = 0; i < busySectorMbinRanges_.size(); i++) {
334  if (mBinOrder >= busySectorMbinLow_[i] && mBinOrder <= busySectorMbinHigh_[i])
335  return i;
336  }
337  throw cms::Exception("LogicError") << "HTrphi::getMbinRange() messed up";
338  } else {
339  return 0;
340  }
341  }
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 459 of file HTrphi.cc.

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

Referenced by HTrphi().

459  {
460  // Get the helix parameters corresponding to the axes definitions of the HT.
461  pair<float, float> helix2Dht = this->helix2Dhough(i, j);
462  // Convert to the conventionally agreed pair of helix parameters, (q/pt, phi0).
463  float qOverPt = helix2Dht.first; // easy
464  // If HT defined track phi other than at r=0, must correct to get phi0. Allow for 2*pi wrapping of phi.
465  float phi0 = reco::deltaPhi(helix2Dht.second + invPtToDphi_ * chosenRofPhi_ * qOverPt, 0.);
466  return pair<float, float>(qOverPt, phi0);
467  }
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:403

◆ helix2Dhough()

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

Implements tmtt::HTbase.

Definition at line 403 of file HTrphi.cc.

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

Referenced by helix2Dconventional().

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

347  {
348  // Note q/Pt value corresponding to centre of this bin.
349  float qOverPtBin = -maxAbsQoverPtAxis_ + (iQoverPtBin + 0.5) * binSizeQoverPtAxis_;
350  // Note change in this q/Pt value needed to reach either edge of the bin.
351  float qOverPtBinVar = 0.5 * binSizeQoverPtAxis_;
352 
353  // Reducing effective bin width can reduce fake rate.
354  //qOverPtVar = 0.4*binSizeQoverPtAxis_;
355 
356  // Calculate range of track-phi that would allow a track in this q/Pt range to pass through the stub.
357  float phiTrk = stub->phi() + invPtToDphi_ * qOverPtBin * (stub->r() - chosenRofPhi_);
358  // The next line does the phiTrk calculation without the usual approximation, but it doesn't
359  // improve performance.
360  //float phiTrk = stub->phi() + asin(invPtToDphi_ * qOverPtBin * stub->r()) - asin(invPtToDphi_ * qOverPtBin * chosenRofPhi_);
361  float phiTrkVar = invPtToDphi_ * qOverPtBinVar * std::abs(stub->r() - chosenRofPhi_);
362  float phiTrkMin = phiTrk - phiTrkVar;
363  float phiTrkMax = phiTrk + phiTrkVar;
364 
365  float deltaPhiMin = reco::deltaPhi(phiTrkMin, phiCentreSector_); // Offset to centre of sector.
366  float deltaPhiMax = reco::deltaPhi(phiTrkMax, phiCentreSector_);
367  pair<float, float> phiTrkRange(deltaPhiMin, deltaPhiMax);
368 
369  // Determine which HT array cell range in track-phi this range "phiTrkRange" corresponds to.
370  pair<unsigned int, unsigned int> iPhiTrkBinRange = this->HTbase::convertCoordRangeToBinRange(
372 
373  return iPhiTrkBinRange;
374  }
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 620 of file HTrphi.cc.

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

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

◆ mergedCell()

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

Definition at line 580 of file HTrphi.cc.

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

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

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

References mps_fire::i.

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

◆ store()

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

Definition at line 178 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, WZElectronSkims53X_cff::max, maxAbsPhiTrkAxis_, maxAbsQoverPtAxis_, tmtt::HTrphi::ErrorMonitor::maxLineGradient, mergedCell(), nBinsPhiTrkAxis_, nBinsQoverPtAxis_, nReceivedStubs_, tmtt::Stub::phi(), phiCentreSector_, tmtt::Stub::r(), shape_, and square.

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

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

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

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