CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
tmtt::HTbase Class Referenceabstract

#include <HTbase.h>

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

Public Member Functions

virtual const matrix< std::unique_ptr< HTcell > > & allCells () const
 
virtual std::vector< const L1track2D * > assocTrackCands2D (const TP &tp) const
 
virtual std::pair< unsigned int, unsigned int > cell (const L1fittedTrack *fitTrk) const =0
 
virtual void disableBendFilter ()
 
virtual void end ()
 
virtual std::pair< float, float > helix2Dconventional (unsigned int i, unsigned int j) const =0
 
virtual std::pair< float, float > helix2Dhough (unsigned int i, unsigned int j) const =0
 
 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 std::pair< unsigned int, unsigned int > trueCell (const TP *tp) const =0
 
virtual ~HTbase ()=default
 

Protected Member Functions

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

matrix< 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_
 

Private Member Functions

virtual unsigned int calcOptoLinkID () const
 
virtual std::list< L1track2DcalcTrackCands2D () const
 
virtual std::list< L1track2DkillTracksBusySec (const std::list< L1track2D > &tracks) const =0
 
virtual std::vector< unsigned int > rowOrder (unsigned int numRows) const =0
 

Detailed Description

Definition at line 41 of file HTbase.h.

Constructor & Destructor Documentation

◆ HTbase()

tmtt::HTbase::HTbase ( const Settings settings,
unsigned int  iPhiSec,
unsigned int  iEtaReg,
unsigned int  nBinsX,
unsigned int  nBinsY 
)

Definition at line 14 of file HTbase.cc.

16  : settings_(settings),
17  iPhiSec_(iPhiSec),
18  iEtaReg_(iEtaReg),
19  nBinsX_(nBinsX),
20  nBinsY_(nBinsY),
21  htArray_(nBinsX, nBinsY),
22  optoLinkID_(this->calcOptoLinkID()) {}

◆ ~HTbase()

virtual tmtt::HTbase::~HTbase ( )
virtualdefault

Member Function Documentation

◆ allCells()

virtual const matrix<std::unique_ptr<HTcell> >& tmtt::HTbase::allCells ( ) const
inlinevirtual

Definition at line 64 of file HTbase.h.

64 { return htArray_; }

References htArray_.

◆ assocTrackCands2D()

vector< const L1track2D * > tmtt::HTbase::assocTrackCands2D ( const TP tp) const
virtual

Definition at line 95 of file HTbase.cc.

95  {
96  vector<const L1track2D*> assocRecoTrk;
97 
98  // Loop over track candidates, looking for those associated to given TP.
99  for (const L1track2D& trk : trackCands2D_) {
100  if (trk.matchedTP() != nullptr) {
101  if (trk.matchedTP()->index() == tp.index())
102  assocRecoTrk.push_back(&trk);
103  }
104  }
105 
106  return assocRecoTrk;
107  }

References cmsswSequenceInfo::tp, and trackCands2D_.

◆ calcOptoLinkID()

virtual unsigned int tmtt::HTbase::calcOptoLinkID ( ) const
inlineprivatevirtual

Definition at line 135 of file HTbase.h.

135  {
136  unsigned int numPhiSecPerNon = settings_->numPhiSectors() / settings_->numPhiNonants();
137  return (iEtaReg_ * numPhiSecPerNon + iPhiSec_);
138  }

References iEtaReg_, iPhiSec_, tmtt::Settings::numPhiNonants(), tmtt::Settings::numPhiSectors(), and settings_.

◆ calcTrackCands2D()

list< L1track2D > tmtt::HTbase::calcTrackCands2D ( ) const
privatevirtual

Definition at line 186 of file HTbase.cc.

186  {
187  list<L1track2D> trackCands2D;
188 
189  // Check if the hardware processes rows of the HT array in a specific order when outputting track candidates.
190  // Currently this is by decreasing Pt for r-phi HT and unordered for r-z HT.
191  const vector<unsigned int> iOrder = this->rowOrder(nBinsX_);
192  bool wantOrdering = (not iOrder.empty());
193 
194  // Loop over cells in HT array.
195  for (unsigned int i = 0; i < nBinsX_; i++) {
196  // Access rows in specific order if required.
197  unsigned int iPos = wantOrdering ? iOrder[i] : i;
198 
199  for (unsigned int j = 0; j < nBinsY_; j++) {
200  if (htArray_(iPos, j)->trackCandFound()) { // track candidate found in this cell.
201 
202  // Note if this corresponds to a merged HT cell (e.g. 2x2).
203  const bool merged = htArray_(iPos, j)->mergedCell();
204 
205  // Get stubs on this track candidate.
206  const vector<Stub*>& stubs = htArray_(iPos, j)->stubs();
207 
208  // And note location of cell inside HT array.
209  const pair<unsigned int, unsigned int> cellLocation(iPos, j);
210 
211  // Get (q/Pt, phi0) or (tan_lambda, z0) corresponding to middle of this cell.
212  const pair<float, float> helixParams2D = this->helix2Dconventional(iPos, j);
213 
214  // Create track and store it.
215  trackCands2D.emplace_back(
216  settings_, stubs, cellLocation, helixParams2D, iPhiSec_, iEtaReg_, optoLinkID_, merged);
217  }
218  }
219  }
220 
221  return trackCands2D;
222  }

References helix2Dconventional(), htArray_, mps_fire::i, iEtaReg_, iPhiSec_, dqmiolumiharvest::j, nBinsX_, nBinsY_, optoLinkID_, rowOrder(), settings_, and trackCands2D().

Referenced by end().

◆ cell()

virtual std::pair<unsigned int, unsigned int> tmtt::HTbase::cell ( const L1fittedTrack fitTrk) const
pure virtual

Implemented in tmtt::HTrphi.

◆ convertCoordRangeToBinRange()

pair< unsigned int, unsigned int > tmtt::HTbase::convertCoordRangeToBinRange ( std::pair< float, float >  coordRange,
unsigned int  nBinsAxis,
float  coordAxisMin,
float  coordAxisBinSize,
unsigned int  killSomeHTcells 
) const
protectedvirtual

Definition at line 122 of file HTbase.cc.

126  {
127  float coordMin = coordRange.first;
128  float coordMax = coordRange.second;
129  float coordAvg = (coordRange.first + coordRange.second) / 2.;
130 
131  int iCoordBinMin, iCoordBinMax;
132 
133  //--- There are various options for doing this.
134  //--- Option killSomeHTcells = 0 is the obvious one.
135  //--- If killSomeHTcells > 0, then some of the cells nominally associated with the stub are killed.
136 
137  if (killSomeHTcells == 0) {
138  // Take the full range of phi bins consistent with the stub.
139  iCoordBinMin = floor((coordMin - coordAxisMin) / coordAxisBinSize);
140  iCoordBinMax = floor((coordMax - coordAxisMin) / coordAxisBinSize);
141  } else if (killSomeHTcells == 1) {
142  // Use the reduced range of bins.
143  // This algorithm, proposed by Ian, should reduce the rate, at the cost of some efficiency.
144  const float fracCut = 0.3;
145  iCoordBinMin = floor((coordMin - coordAxisMin) / coordAxisBinSize);
146  iCoordBinMax = floor((coordMax - coordAxisMin) / coordAxisBinSize);
147  unsigned int nbins = iCoordBinMax - iCoordBinMin + 1;
148  if (nbins >= 2) { // Can't reduce range if already only 1 bin
149  float lower = coordAxisMin + (iCoordBinMin + 1) * coordAxisBinSize; // upper edge of lowest bin
150  float upper = coordAxisMin + (iCoordBinMax)*coordAxisBinSize; // lower edge of highest bin.
151  // Calculate fractional amount of min and max bin that this stub uses.
152  float extraLow = (lower - coordMin) / coordAxisBinSize;
153  float extraUp = (coordMax - upper) / coordAxisBinSize;
154  constexpr float small = 0.001; // allow tolerance on floating point precision.
155  if (min(extraLow, extraUp) < -small || max(extraLow, extraUp) > (1.0 + small))
156  throw cms::Exception("LogicError") << "HTbase: convertCoordRangeToBinRange error";
157  if (extraLow < fracCut && (nbins >= 3 || extraLow < extraUp))
158  iCoordBinMin += 1;
159  if (extraUp < fracCut && (nbins >= 3 || extraUp < extraLow))
160  iCoordBinMax -= 1;
161  }
162  } else if (killSomeHTcells == 2) {
163  // This corresponds to Thomas's firmware implementation, which can't fill more than one HT cell per column.
164  iCoordBinMin = floor((coordAvg - coordAxisMin) / coordAxisBinSize);
165  iCoordBinMax = iCoordBinMin;
166  } else {
167  throw cms::Exception("BadConfig") << "HT: invalid KillSomeHTCells option in cfg";
168  }
169 
170  // Limit range to dimensions of HT array.
171  iCoordBinMin = max(iCoordBinMin, 0);
172  iCoordBinMax = min(iCoordBinMax, int(nBinsAxis) - 1);
173 
174  // If whole range is outside HT array, flag this by setting range to specific values with min > max.
175  if (iCoordBinMin > int(nBinsAxis) - 1 || iCoordBinMax < 0) {
176  iCoordBinMin = int(nBinsAxis) - 1;
177  iCoordBinMax = 0;
178  }
179 
180  return pair<unsigned int, unsigned int>(iCoordBinMin, iCoordBinMax);
181  }

References Exception, createfilelist::int, SiStripPI::max, min(), LaserClient_cfi::nbins, and pileupCalc::upper.

Referenced by tmtt::HTrphi::iPhiRange().

◆ disableBendFilter()

void tmtt::HTbase::disableBendFilter ( )
virtual

Definition at line 111 of file HTbase.cc.

111  {
112  // Loop over cells in HT array.
113  for (unsigned int i = 0; i < nBinsX_; i++) {
114  for (unsigned int j = 0; j < nBinsY_; j++) {
115  htArray_(i, j)->disableBendFilter();
116  }
117  }
118  }

References htArray_, mps_fire::i, dqmiolumiharvest::j, nBinsX_, and nBinsY_.

◆ end()

void tmtt::HTbase::end ( void  )
virtual

Definition at line 26 of file HTbase.cc.

26  {
27  // Calculate useful info about each cell in array.
28  for (unsigned int i = 0; i < nBinsX_; i++) {
29  for (unsigned int j = 0; j < nBinsY_; j++) {
30  htArray_(i, j)->end(); // Calls HTcell::end()
31  }
32  }
33 
34  // Produce a list of all track candidates found in this array, each containing all the stubs on each one
35  // and the track helix parameters, plus the associated truth particle (if any).
37 
38  // If requested, kill those tracks in this sector that can't be read out during the time-multiplexed period, because
39  // the HT has associated too many stubs to tracks.
40  if (settings_->busySectorKill()) {
42  }
43  }

References tmtt::Settings::busySectorKill(), calcTrackCands2D(), htArray_, mps_fire::i, dqmiolumiharvest::j, killTracksBusySec(), nBinsX_, nBinsY_, settings_, and trackCands2D_.

◆ helix2Dconventional()

virtual std::pair<float, float> tmtt::HTbase::helix2Dconventional ( unsigned int  i,
unsigned int  j 
) const
pure virtual

Implemented in tmtt::HTrphi.

Referenced by calcTrackCands2D().

◆ helix2Dhough()

virtual std::pair<float, float> tmtt::HTbase::helix2Dhough ( unsigned int  i,
unsigned int  j 
) const
pure virtual

Implemented in tmtt::HTrphi.

◆ killTracksBusySec()

virtual std::list<L1track2D> tmtt::HTbase::killTracksBusySec ( const std::list< L1track2D > &  tracks) const
privatepure virtual

Implemented in tmtt::HTrphi.

Referenced by end().

◆ numStubsExc()

unsigned int tmtt::HTbase::numStubsExc ( ) const
virtual

Definition at line 62 of file HTbase.cc.

62  {
63  unordered_set<unsigned int> stubIDs; // Each ID stored only once, no matter how often it is added.
64 
65  // Loop over cells in HT array.
66  for (unsigned int i = 0; i < nBinsX_; i++) {
67  for (unsigned int j = 0; j < nBinsY_; j++) {
68  // Loop over stubs in each cells, storing their IDs.
69  const vector<Stub*>& vStubs = htArray_(i, j)->stubs(); // Calls HTcell::stubs()
70  for (const Stub* stub : vStubs) {
71  stubIDs.insert(stub->index());
72  }
73  }
74  }
75 
76  return stubIDs.size();
77  }

References htArray_, mps_fire::i, dqmiolumiharvest::j, nBinsX_, and nBinsY_.

◆ numStubsInc()

unsigned int tmtt::HTbase::numStubsInc ( ) const
virtual

Definition at line 47 of file HTbase.cc.

47  {
48  unsigned int nStubs = 0;
49 
50  // Loop over cells in HT array.
51  for (unsigned int i = 0; i < nBinsX_; i++) {
52  for (unsigned int j = 0; j < nBinsY_; j++) {
53  nStubs += htArray_(i, j)->numStubs(); // Calls HTcell::numStubs()
54  }
55  }
56 
57  return nStubs;
58  }

References htArray_, mps_fire::i, dqmiolumiharvest::j, nBinsX_, and nBinsY_.

◆ numStubsOnTrackCands2D()

unsigned int tmtt::HTbase::numStubsOnTrackCands2D ( ) const
virtual

Definition at line 81 of file HTbase.cc.

81  {
82  unsigned int nStubs = 0;
83 
84  // Loop over track candidates
85  for (const L1track2D& trk : trackCands2D_) {
86  nStubs += trk.stubs().size();
87  }
88 
89  return nStubs;
90  }

References trackCands2D_.

◆ numTrackCands2D()

virtual unsigned int tmtt::HTbase::numTrackCands2D ( ) const
inlinevirtual

Definition at line 77 of file HTbase.h.

77 { return trackCands2D_.size(); }

References trackCands2D_.

◆ replaceTrackCands2D()

virtual void tmtt::HTbase::replaceTrackCands2D ( const std::list< L1track2D > &  newTracks)
inlinevirtual

Definition at line 89 of file HTbase.h.

89 { trackCands2D_ = newTracks; }

References trackCands2D_.

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

◆ rowOrder()

virtual std::vector<unsigned int> tmtt::HTbase::rowOrder ( unsigned int  numRows) const
privatepure virtual

Implemented in tmtt::HTrphi.

Referenced by calcTrackCands2D().

◆ trackCands2D()

virtual const std::list<L1track2D>& tmtt::HTbase::trackCands2D ( ) const
inlinevirtual

◆ trueCell()

virtual std::pair<unsigned int, unsigned int> tmtt::HTbase::trueCell ( const TP tp) const
pure virtual

Implemented in tmtt::HTrphi.

Member Data Documentation

◆ htArray_

matrix<std::unique_ptr<HTcell> > tmtt::HTbase::htArray_
protected

◆ iEtaReg_

unsigned int tmtt::HTbase::iEtaReg_
protected

Definition at line 144 of file HTbase.h.

Referenced by calcOptoLinkID(), and calcTrackCands2D().

◆ iPhiSec_

unsigned int tmtt::HTbase::iPhiSec_
protected

Definition at line 143 of file HTbase.h.

Referenced by calcOptoLinkID(), and calcTrackCands2D().

◆ nBinsX_

unsigned int tmtt::HTbase::nBinsX_
protected

Definition at line 146 of file HTbase.h.

Referenced by calcTrackCands2D(), disableBendFilter(), end(), numStubsExc(), and numStubsInc().

◆ nBinsY_

unsigned int tmtt::HTbase::nBinsY_
protected

Definition at line 147 of file HTbase.h.

Referenced by calcTrackCands2D(), disableBendFilter(), end(), numStubsExc(), and numStubsInc().

◆ optoLinkID_

unsigned int tmtt::HTbase::optoLinkID_
protected

Definition at line 153 of file HTbase.h.

Referenced by calcTrackCands2D().

◆ settings_

const Settings* tmtt::HTbase::settings_
protected

Definition at line 141 of file HTbase.h.

Referenced by calcOptoLinkID(), calcTrackCands2D(), end(), and tmtt::HTrphi::HTrphi().

◆ trackCands2D_

std::list<L1track2D> tmtt::HTbase::trackCands2D_
protected
tmtt::HTbase::calcTrackCands2D
virtual std::list< L1track2D > calcTrackCands2D() const
Definition: HTbase.cc:186
tmtt::HTbase::htArray_
matrix< std::unique_ptr< HTcell > > htArray_
Definition: HTbase.h:151
mps_fire.i
i
Definition: mps_fire.py:428
tmtt::Settings::numPhiNonants
unsigned int numPhiNonants() const
Definition: Settings.h:109
min
T min(T a, T b)
Definition: MathUtil.h:58
tmtt::HTbase::trackCands2D
virtual const std::list< L1track2D > & trackCands2D() const
Definition: HTbase.h:73
tmtt::HTbase::settings_
const Settings * settings_
Definition: HTbase.h:141
tmtt::HTbase::rowOrder
virtual std::vector< unsigned int > rowOrder(unsigned int numRows) const =0
tmtt::HTbase::helix2Dconventional
virtual std::pair< float, float > helix2Dconventional(unsigned int i, unsigned int j) const =0
tmtt::HTbase::optoLinkID_
unsigned int optoLinkID_
Definition: HTbase.h:153
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
tmtt::HTbase::nBinsX_
unsigned int nBinsX_
Definition: HTbase.h:146
tmtt::HTbase::killTracksBusySec
virtual std::list< L1track2D > killTracksBusySec(const std::list< L1track2D > &tracks) const =0
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
tmtt::HTbase::calcOptoLinkID
virtual unsigned int calcOptoLinkID() const
Definition: HTbase.h:135
createfilelist.int
int
Definition: createfilelist.py:10
tmtt::Settings::numPhiSectors
unsigned int numPhiSectors() const
Definition: Settings.h:110
tmtt::HTbase::trackCands2D_
std::list< L1track2D > trackCands2D_
Definition: HTbase.h:158
tmtt::Settings::busySectorKill
bool busySectorKill() const
Definition: Settings.h:175
tmtt::HTbase::iPhiSec_
unsigned int iPhiSec_
Definition: HTbase.h:143
tmtt::HTbase::nBinsY_
unsigned int nBinsY_
Definition: HTbase.h:147
Exception
Definition: hltDiff.cc:246
pileupCalc.upper
upper
Definition: pileupCalc.py:214
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
tmtt::HTbase::iEtaReg_
unsigned int iEtaReg_
Definition: HTbase.h:144