CMS 3D CMS Logo

Classes | Typedefs | Functions | Variables
l1ttrackjet Namespace Reference

Classes

struct  EtaPhiBin
 
struct  MaxZBin
 
struct  TrackJetEmulationEtaPhiBin
 
struct  TrackJetEmulationMaxZBin
 

Typedefs

typedef ap_uint< TTTrack_TrackWord::TrackBitWidths::kD0Size > d0_intern
 
typedef ap_fixed< TTTrack_TrackWord::TrackBitWidths::kTanlSize, ETA_INTPART_BITS, AP_TRN, AP_SAT > glbeta_intern
 
typedef ap_int< TTTrack_TrackWord::TrackBitWidths::kPhiSize+kExtraGlobalPhiBitglbphi_intern
 
typedef ap_ufixed< TTTrack_TrackWord::TrackBitWidths::kRinvSize - 1, PT_INTPART_BITS, AP_TRN, AP_SAT > pt_intern
 
typedef ap_int< TTTrack_TrackWord::TrackBitWidths::kZ0Size > z0_intern
 

Functions

const double BitToDouble (unsigned int bits, unsigned int maxBits, double step)
 
const unsigned int DoubleToBit (double value, unsigned int maxBits, double step)
 
glbphi_intern DPhi (glbphi_intern phi1, glbphi_intern phi2)
 
float DPhi (float phi1, float phi2)
 
template<typename T , typename Pt >
void Fill_L2Cluster (T &bin, Pt pt, int ntrk, int ndtrk, std::vector< unsigned int > trkidx)
 
template<typename T , typename Pt , typename Eta , typename Phi >
std::vector< TL1_clustering (T *phislice, int etaBins_, Eta etaStep_)
 
template<typename T , typename Pt , typename Eta , typename Phi >
std::vector< TL2_clustering (std::vector< std::vector< T > > &L1clusters, int phiBins_, Phi phiStep_, Eta etaStep_)
 
bool TrackQualitySelection (int trk_nstub, double trk_chi2, double trk_bendchi2, double nStubs4PromptBend_, double nStubs5PromptBend_, double nStubs4PromptChi2_, double nStubs5PromptChi2_, double nStubs4DisplacedBend_, double nStubs5DisplacedBend_, double nStubs4DisplacedChi2_, double nStubs5DisplacedChi2_, bool displaced_)
 

Variables

const unsigned int ETA_INTPART_BITS {3}
 
const unsigned int kExtraGlobalPhiBit {4}
 
const unsigned int PT_INTPART_BITS {9}
 

Typedef Documentation

◆ d0_intern

typedef ap_uint<TTTrack_TrackWord::TrackBitWidths::kD0Size> l1ttrackjet::d0_intern

Definition at line 24 of file L1TrackJetClustering.h.

◆ glbeta_intern

typedef ap_fixed<TTTrack_TrackWord::TrackBitWidths::kTanlSize, ETA_INTPART_BITS, AP_TRN, AP_SAT> l1ttrackjet::glbeta_intern

Definition at line 21 of file L1TrackJetClustering.h.

◆ glbphi_intern

typedef ap_int<TTTrack_TrackWord::TrackBitWidths::kPhiSize + kExtraGlobalPhiBit> l1ttrackjet::glbphi_intern

Definition at line 22 of file L1TrackJetClustering.h.

◆ pt_intern

typedef ap_ufixed<TTTrack_TrackWord::TrackBitWidths::kRinvSize - 1, PT_INTPART_BITS, AP_TRN, AP_SAT> l1ttrackjet::pt_intern

Definition at line 20 of file L1TrackJetClustering.h.

◆ z0_intern

typedef ap_int<TTTrack_TrackWord::TrackBitWidths::kZ0Size> l1ttrackjet::z0_intern

Definition at line 23 of file L1TrackJetClustering.h.

Function Documentation

◆ BitToDouble()

const double l1ttrackjet::BitToDouble ( unsigned int  bits,
unsigned int  maxBits,
double  step 
)
inline

Definition at line 35 of file L1TrackJetClustering.h.

References gpuClustering::pixelStatus::bits.

Referenced by L1TrackJetEmulatorProducer::produce().

35  {
36  int isign = 1;
37  unsigned int digitized_maximum = (1 << maxBits) - 1;
38  if (bits & (1 << (maxBits - 1))) { // check the sign
39  isign = -1;
40  bits = (1 << (maxBits + 1)) - bits;
41  }
42  return (double(bits & digitized_maximum) + 0.5) * step * isign;
43  }
constexpr uint32_t bits
Definition: gpuClustering.h:25
step
Definition: StallMonitor.cc:98

◆ DoubleToBit()

const unsigned int l1ttrackjet::DoubleToBit ( double  value,
unsigned int  maxBits,
double  step 
)
inline

Definition at line 26 of file L1TrackJetClustering.h.

References funct::abs().

Referenced by DPhi(), L1TrackJetEmulatorProducer::L1TrackJetEmulatorProducer(), and L1TrackJetEmulatorProducer::produce().

26  {
27  unsigned int digitized_value = std::floor(std::abs(value) / step);
28  unsigned int digitized_maximum = (1 << (maxBits - 1)) - 1; // The remove 1 bit from nBits to account for the sign
29  if (digitized_value > digitized_maximum)
30  digitized_value = digitized_maximum;
31  if (value < 0)
32  digitized_value = (1 << maxBits) - digitized_value; // two's complement encoding
33  return digitized_value;
34  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Definition: value.py:1
step
Definition: StallMonitor.cc:98

◆ DPhi() [1/2]

glbphi_intern l1ttrackjet::DPhi ( glbphi_intern  phi1,
glbphi_intern  phi2 
)
inline

Definition at line 218 of file L1TrackJetClustering.h.

References DoubleToBit(), kExtraGlobalPhiBit, M_PI, TTTrack_TrackWord::stepPhi0, and x.

Referenced by L2_clustering().

218  {
219  glbphi_intern x = phi1 - phi2;
220  if (x >= DoubleToBit(
221  M_PI, TTTrack_TrackWord::TrackBitWidths::kPhiSize + kExtraGlobalPhiBit, TTTrack_TrackWord::stepPhi0))
222  x -= DoubleToBit(
223  2 * M_PI, TTTrack_TrackWord::TrackBitWidths::kPhiSize + kExtraGlobalPhiBit, TTTrack_TrackWord::stepPhi0);
224  if (x < DoubleToBit(-1 * M_PI,
225  TTTrack_TrackWord::TrackBitWidths::kPhiSize + kExtraGlobalPhiBit,
227  x += DoubleToBit(
228  2 * M_PI, TTTrack_TrackWord::TrackBitWidths::kPhiSize + kExtraGlobalPhiBit, TTTrack_TrackWord::stepPhi0);
229  return x;
230  }
const unsigned int kExtraGlobalPhiBit
const unsigned int DoubleToBit(double value, unsigned int maxBits, double step)
#define M_PI
ap_int< TTTrack_TrackWord::TrackBitWidths::kPhiSize+kExtraGlobalPhiBit > glbphi_intern
static constexpr double stepPhi0
float x

◆ DPhi() [2/2]

float l1ttrackjet::DPhi ( float  phi1,
float  phi2 
)
inline

Definition at line 232 of file L1TrackJetClustering.h.

References M_PI, and x.

232  {
233  float x = phi1 - phi2;
234  if (x >= M_PI)
235  x -= 2 * M_PI;
236  if (x < -1 * M_PI)
237  x += 2 * M_PI;
238  return x;
239  }
#define M_PI
float x

◆ Fill_L2Cluster()

template<typename T , typename Pt >
void l1ttrackjet::Fill_L2Cluster ( T bin,
Pt  pt,
int  ntrk,
int  ndtrk,
std::vector< unsigned int >  trkidx 
)
inline

Definition at line 210 of file L1TrackJetClustering.h.

References newFWLiteAna::bin, and DiDispStaMuonMonitor_cfi::pt.

210  {
211  bin.pTtot += pt;
212  bin.ntracks += ntrk;
213  bin.nxtracks += ndtrk;
214  for (unsigned int itrk = 0; itrk < trkidx.size(); itrk++)
215  bin.trackidx.push_back(trkidx[itrk]);
216  }

◆ L1_clustering()

template<typename T , typename Pt , typename Eta , typename Phi >
std::vector<T> l1ttrackjet::L1_clustering ( T phislice,
int  etaBins_,
Eta  etaStep_ 
)
inline

Definition at line 118 of file L1TrackJetClustering.h.

References bsc_activity_cfg::clusters, PVValHelper::eta, visualization-live-secondInstance_cfg::m, and DeadROCCounter::nclust.

118  {
119  std::vector<T> clusters;
120  // Find eta bin with maxpT, make center of cluster, add neighbors if not already used
121  int nclust = 0;
122 
123  // get tracks in eta bins in increasing eta order
124  for (int etabin = 0; etabin < etaBins_; ++etabin) {
125  Pt my_pt = 0;
126  Pt previousbin_pt = 0;
127  Pt nextbin_pt = 0;
128  Pt nextbin2_pt = 0;
129 
130  // skip (already) used tracks
131  if (phislice[etabin].used)
132  continue;
133 
134  my_pt = phislice[etabin].pTtot;
135  if (my_pt == 0)
136  continue;
137 
138  //get previous bin pT
139  if (etabin > 0 && !phislice[etabin - 1].used)
140  previousbin_pt = phislice[etabin - 1].pTtot;
141 
142  // get next bins pt
143  if (etabin < etaBins_ - 1 && !phislice[etabin + 1].used) {
144  nextbin_pt = phislice[etabin + 1].pTtot;
145  if (etabin < etaBins_ - 2 && !phislice[etabin + 2].used) {
146  nextbin2_pt = phislice[etabin + 2].pTtot;
147  }
148  }
149  // check if pT of current cluster is higher than neighbors
150  if (my_pt < previousbin_pt || my_pt <= nextbin_pt) {
151  // if unused pT in the left neighbor, spit it out as a cluster
152  if (previousbin_pt > 0) {
153  clusters.push_back(phislice[etabin - 1]);
154  phislice[etabin - 1].used = true;
155  nclust++;
156  }
157  continue; //if it is not the local max pT skip
158  }
159  // here reach only unused local max clusters
160  clusters.push_back(phislice[etabin]);
161  phislice[etabin].used = true; //if current bin a cluster
162  if (previousbin_pt > 0) {
163  clusters[nclust].pTtot += previousbin_pt;
164  clusters[nclust].ntracks += phislice[etabin - 1].ntracks;
165  clusters[nclust].nxtracks += phislice[etabin - 1].nxtracks;
166  for (unsigned int itrk = 0; itrk < phislice[etabin - 1].trackidx.size(); itrk++)
167  clusters[nclust].trackidx.push_back(phislice[etabin - 1].trackidx[itrk]);
168  }
169 
170  if (my_pt >= nextbin2_pt && nextbin_pt > 0) {
171  clusters[nclust].pTtot += nextbin_pt;
172  clusters[nclust].ntracks += phislice[etabin + 1].ntracks;
173  clusters[nclust].nxtracks += phislice[etabin + 1].nxtracks;
174  for (unsigned int itrk = 0; itrk < phislice[etabin + 1].trackidx.size(); itrk++)
175  clusters[nclust].trackidx.push_back(phislice[etabin + 1].trackidx[itrk]);
176  phislice[etabin + 1].used = true;
177  }
178 
179  nclust++;
180 
181  } // for each etabin
182 
183  // Merge close-by clusters
184  for (int m = 0; m < nclust - 1; ++m) {
185  if (((clusters[m + 1].eta - clusters[m].eta) < (3 * etaStep_) / 2) &&
186  (-(3 * etaStep_) / 2 < (clusters[m + 1].eta - clusters[m].eta))) {
187  if (clusters[m + 1].pTtot > clusters[m].pTtot) {
188  clusters[m].eta = clusters[m + 1].eta;
189  }
190  clusters[m].pTtot += clusters[m + 1].pTtot;
191  clusters[m].ntracks += clusters[m + 1].ntracks; // total ntrk
192  clusters[m].nxtracks += clusters[m + 1].nxtracks; // total ndisp
193  for (unsigned int itrk = 0; itrk < clusters[m + 1].trackidx.size(); itrk++)
194  clusters[m].trackidx.push_back(clusters[m + 1].trackidx[itrk]);
195 
196  // if remove the merged cluster - all the others must be closer to 0
197  for (int m1 = m + 1; m1 < nclust - 1; ++m1)
198  clusters[m1] = clusters[m1 + 1];
199 
200  clusters.erase(clusters.begin() + nclust);
201  nclust--;
202  } // end if for cluster merging
203  } // end for (m) loop
204 
205  return clusters;
206  }

◆ L2_clustering()

template<typename T , typename Pt , typename Eta , typename Phi >
std::vector<T> l1ttrackjet::L2_clustering ( std::vector< std::vector< T > > &  L1clusters,
int  phiBins_,
Phi  phiStep_,
Eta  etaStep_ 
)
inline

Definition at line 243 of file L1TrackJetClustering.h.

References a, b, bsc_activity_cfg::clusters, DPhi(), relativeConstraints::empty, PVValHelper::eta, visualization-live-secondInstance_cfg::m, dqmiodumpmetadata::n, DeadROCCounter::nclust, and jetUpdater_cfi::sort.

246  {
247  std::vector<T> clusters;
248  for (int phibin = 0; phibin < phiBins_; ++phibin) { //Find eta-phibin with highest pT
249  if (L1clusters[phibin].empty())
250  continue;
251 
252  // sort L1 clusters max -> min
253  sort(L1clusters[phibin].begin(), L1clusters[phibin].end(), [](T &a, T &b) { return a.pTtot > b.pTtot; });
254 
255  for (unsigned int imax = 0; imax < L1clusters[phibin].size(); ++imax) {
256  if (L1clusters[phibin][imax].used)
257  continue;
258  Pt pt_current = L1clusters[phibin][imax].pTtot; //current cluster (pt0)
259  Pt pt_next = 0; // next phi bin (pt1)
260  Pt pt_next2 = 0; // next to next phi bin2 (pt2)
261  int trk1 = 0;
262  int trk2 = 0;
263  int tdtrk1 = 0;
264  int tdtrk2 = 0;
265  std::vector<unsigned int> trkidx1;
266  std::vector<unsigned int> trkidx2;
267  clusters.push_back(L1clusters[phibin][imax]);
268 
269  L1clusters[phibin][imax].used = true;
270 
271  // if we are in the last phi bin, dont check phi+1 phi+2
272  if (phibin == phiBins_ - 1)
273  continue;
274 
275  std::vector<unsigned int> used_already; //keep phi+1 clusters that have been used
276  for (unsigned int icluster = 0; icluster < L1clusters[phibin + 1].size(); ++icluster) {
277  if (L1clusters[phibin + 1][icluster].used)
278  continue;
279 
280  if (((L1clusters[phibin + 1][icluster].eta - L1clusters[phibin][imax].eta) > (3 * etaStep_) / 2) ||
281  ((L1clusters[phibin + 1][icluster].eta - L1clusters[phibin][imax].eta) < -(3 * etaStep_) / 2))
282  continue;
283 
284  pt_next += L1clusters[phibin + 1][icluster].pTtot;
285  trk1 += L1clusters[phibin + 1][icluster].ntracks;
286  tdtrk1 += L1clusters[phibin + 1][icluster].nxtracks;
287 
288  for (unsigned int itrk = 0; itrk < L1clusters[phibin + 1][icluster].trackidx.size(); itrk++)
289  trkidx1.push_back(L1clusters[phibin + 1][icluster].trackidx[itrk]);
290  used_already.push_back(icluster);
291  }
292 
293  if (pt_next < pt_current) { // if pt1<pt1, merge both clusters
294  Fill_L2Cluster<T, Pt>(clusters[clusters.size() - 1], pt_next, trk1, tdtrk1, trkidx1);
295  for (unsigned int iused : used_already)
296  L1clusters[phibin + 1][iused].used = true;
297  continue;
298  }
299  // if phi = next to last bin there is no "next to next"
300  if (phibin == phiBins_ - 2) {
301  Fill_L2Cluster<T, Pt>(clusters[clusters.size() - 1], pt_next, trk1, tdtrk1, trkidx1);
302  clusters[clusters.size() - 1].phi = L1clusters[phibin + 1][used_already[0]].phi;
303  for (unsigned int iused : used_already)
304  L1clusters[phibin + 1][iused].used = true;
305  continue;
306  }
307  std::vector<int> used_already2; //keep used clusters in phi+2
308  for (unsigned int icluster = 0; icluster < L1clusters[phibin + 2].size(); ++icluster) {
309  if (L1clusters[phibin + 2][icluster].used)
310  continue;
311  if (((L1clusters[phibin + 2][icluster].eta - L1clusters[phibin][imax].eta) > (3 * etaStep_) / 2) ||
312  ((L1clusters[phibin + 2][icluster].eta - L1clusters[phibin][imax].eta) < -(3 * etaStep_) / 2))
313  continue;
314  pt_next2 += L1clusters[phibin + 2][icluster].pTtot;
315  trk2 += L1clusters[phibin + 2][icluster].ntracks;
316  tdtrk2 += L1clusters[phibin + 2][icluster].nxtracks;
317 
318  for (unsigned int itrk = 0; itrk < L1clusters[phibin + 2][icluster].trackidx.size(); itrk++)
319  trkidx2.push_back(L1clusters[phibin + 2][icluster].trackidx[itrk]);
320  used_already2.push_back(icluster);
321  }
322  if (pt_next2 < pt_next) {
323  std::vector<unsigned int> trkidx_both;
324  trkidx_both.reserve(trkidx1.size() + trkidx2.size());
325  trkidx_both.insert(trkidx_both.end(), trkidx1.begin(), trkidx1.end());
326  trkidx_both.insert(trkidx_both.end(), trkidx2.begin(), trkidx2.end());
327  Fill_L2Cluster<T, Pt>(
328  clusters[clusters.size() - 1], pt_next + pt_next2, trk1 + trk2, tdtrk1 + tdtrk2, trkidx_both);
329  clusters[clusters.size() - 1].phi = L1clusters[phibin + 1][used_already[0]].phi;
330  for (unsigned int iused : used_already)
331  L1clusters[phibin + 1][iused].used = true;
332  for (unsigned int iused : used_already2)
333  L1clusters[phibin + 2][iused].used = true;
334  }
335  } // for each L1 cluster
336  } // for each phibin
337 
338  int nclust = clusters.size();
339 
340  // merge close-by clusters
341  for (int m = 0; m < nclust - 1; ++m) {
342  for (int n = m + 1; n < nclust; ++n) {
343  if (clusters[n].eta != clusters[m].eta)
344  continue;
345  if ((DPhi(clusters[n].phi, clusters[m].phi) > (3 * phiStep_) / 2) ||
346  (DPhi(clusters[n].phi, clusters[m].phi) < -(3 * phiStep_) / 2))
347  continue;
348  if (clusters[n].pTtot > clusters[m].pTtot)
349  clusters[m].phi = clusters[n].phi;
350  clusters[m].pTtot += clusters[n].pTtot;
351  clusters[m].ntracks += clusters[n].ntracks;
352  clusters[m].nxtracks += clusters[n].nxtracks;
353  for (unsigned int itrk = 0; itrk < clusters[n].trackidx.size(); itrk++)
354  clusters[m].trackidx.push_back(clusters[n].trackidx[itrk]);
355  for (int m1 = n; m1 < nclust - 1; ++m1)
356  clusters[m1] = clusters[m1 + 1];
357  clusters.erase(clusters.begin() + nclust);
358 
359  nclust--;
360  } // end of n-loop
361  } // end of m-loop
362  return clusters;
363  }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
long double T
float DPhi(float phi1, float phi2)

◆ TrackQualitySelection()

bool l1ttrackjet::TrackQualitySelection ( int  trk_nstub,
double  trk_chi2,
double  trk_bendchi2,
double  nStubs4PromptBend_,
double  nStubs5PromptBend_,
double  nStubs4PromptChi2_,
double  nStubs5PromptChi2_,
double  nStubs4DisplacedBend_,
double  nStubs5DisplacedBend_,
double  nStubs4DisplacedChi2_,
double  nStubs5DisplacedChi2_,
bool  displaced_ 
)
inline

Definition at line 85 of file L1TrackJetClustering.h.

Referenced by L1TrackJetProducer::produce(), and L1TrackJetEmulatorProducer::produce().

96  {
97  bool PassQuality = false;
98  if (!displaced_) {
99  if (trk_nstub == 4 && trk_bendchi2 < nStubs4PromptBend_ &&
100  trk_chi2 < nStubs4PromptChi2_) // 4 stubs are the lowest track quality and have different cuts
101  PassQuality = true;
102  if (trk_nstub > 4 && trk_bendchi2 < nStubs5PromptBend_ &&
103  trk_chi2 < nStubs5PromptChi2_) // above 4 stubs diffent selection imposed (genrally looser)
104  PassQuality = true;
105  } else {
106  if (trk_nstub == 4 && trk_bendchi2 < nStubs4DisplacedBend_ &&
107  trk_chi2 < nStubs4DisplacedChi2_) // 4 stubs are the lowest track quality and have different cuts
108  PassQuality = true;
109  if (trk_nstub > 4 && trk_bendchi2 < nStubs5DisplacedBend_ &&
110  trk_chi2 < nStubs5DisplacedChi2_) // above 4 stubs diffent selection imposed (genrally looser)
111  PassQuality = true;
112  }
113  return PassQuality;
114  }

Variable Documentation

◆ ETA_INTPART_BITS

const unsigned int l1ttrackjet::ETA_INTPART_BITS {3}

Definition at line 17 of file L1TrackJetClustering.h.

◆ kExtraGlobalPhiBit

const unsigned int l1ttrackjet::kExtraGlobalPhiBit {4}

◆ PT_INTPART_BITS

const unsigned int l1ttrackjet::PT_INTPART_BITS {9}

Definition at line 16 of file L1TrackJetClustering.h.