CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
mkfit::LayerOfHits Class Reference

#include <HitStructures.h>

Classes

struct  HitInfo
 

Public Member Functions

void beginRegistrationOfHits (const HitVec &hitv)
 
void endRegistrationOfHits (bool build_original_to_internal_map)
 
int getHitIndexFromOriginal (int i) const
 
int getOriginalHitIndex (int i) const
 
float hit_phi (int i) const
 
float hit_q (int i) const
 
const HithitArray () const
 
bool is_barrel () const
 
bool is_endcap () const
 
bool is_pix_lyr () const
 
bool is_pixb_lyr () const
 
bool is_pixe_lyr () const
 
bool is_stereo () const
 
bool is_tec_lyr () const
 
bool is_tib_lyr () const
 
bool is_tid_lyr () const
 
bool is_tob_lyr () const
 
bool is_within_r_limits (float r) const
 
WSR_Result is_within_r_sensitive_region (float r, float dr) const
 
bool is_within_z_limits (float z) const
 
WSR_Result is_within_z_sensitive_region (float z, float dz) const
 
int layer_id () const
 
const LayerInfolayer_info () const
 
 LayerOfHits ()=default
 
int nHits () const
 
bool phi_bin_dead (int qi, int pi) const
 
const vecvecPhiBinDead_tphi_bin_deads () const
 
PhiBinInfo_t phi_bin_info (int qi, int pi) const
 
const vecvecPhiBinInfo_tphi_bin_infos () const
 
int phiBin (float phi) const
 
int phiBinChecked (float phi) const
 
int phiBinFine (float phi) const
 
int phiMaskApply (int in) const
 
void printBins ()
 
int qBin (float q) const
 
int qBinChecked (float q) const
 
const HitrefHit (int i) const
 
void registerHit (int idx)
 
void reset ()
 
void setupLayer (const LayerInfo &li)
 
void suckInDeads (const DeadVec &deadv)
 
void suckInHits (const HitVec &hitv)
 
const vecPhiBinInfo_tvecPhiBinInfo (float q) const
 
 ~LayerOfHits ()
 

Private Member Functions

void empty_phi_bins (int q_bin, int phi_bin_1, int phi_bin_2, uint16_t hit_count)
 
void empty_phi_bins_dead (int q_bin, int phi_bin_1, int phi_bin_2)
 
void empty_q_bins (int q_bin_1, int q_bin_2, uint16_t hit_count)
 
void empty_q_bins_dead (int q_bin_1, int q_bin_2)
 
void setup_bins (float qmin, float qmax, float dq)
 

Private Attributes

const HitVecm_ext_hits
 
std::vector< int > m_ext_idcs
 
float m_fq
 
std::vector< HitInfom_hit_infos
 
std::vector< float > m_hit_phis
 
std::vector< float > m_hit_qs
 
unsigned int * m_hit_ranks = nullptr
 
bool m_is_barrel
 
const LayerInfom_layer_info = nullptr
 
int m_max_ext_idx
 
int m_min_ext_idx
 
int m_n_hits = 0
 
int m_nq = 0
 
vecvecPhiBinDead_t m_phi_bin_deads
 
vecvecPhiBinInfo_t m_phi_bin_infos
 
float m_qmax
 
float m_qmin
 
std::vector< uint32_t > m_qphifines
 

Static Private Attributes

static constexpr float m_fphi = Config::m_nphi / Const::TwoPI
 
static constexpr float m_fphi_fine = 1024 / Const::TwoPI
 
static constexpr int m_phi_bits = 8
 
static constexpr int m_phi_bits_fine = 10
 
static constexpr int m_phi_bits_shift = m_phi_bits_fine - m_phi_bits
 
static constexpr int m_phi_fine_xmask = ~((1 << m_phi_bits_shift) - 1)
 
static constexpr int m_phi_mask = 0xff
 
static constexpr int m_phi_mask_fine = 0x3ff
 

Detailed Description

Definition at line 45 of file HitStructures.h.

Constructor & Destructor Documentation

mkfit::LayerOfHits::LayerOfHits ( )
default
mkfit::LayerOfHits::~LayerOfHits ( )

Definition at line 11 of file HitStructures.cc.

References m_hit_ranks.

11  {
12 #ifdef COPY_SORTED_HITS
13  free_hits();
14 #endif
15  operator delete[](m_hit_ranks);
16  }
unsigned int * m_hit_ranks

Member Function Documentation

void mkfit::LayerOfHits::beginRegistrationOfHits ( const HitVec hitv)

Definition at line 166 of file HitStructures.cc.

References cms::cuda::assert(), m_ext_hits, m_ext_idcs, m_hit_infos, m_max_ext_idx, m_min_ext_idx, m_n_hits, m_nq, m_qphifines, SiStripPI::max, and SiStripPI::min.

166  {
167  assert(m_nq > 0 && "setupLayer() was not called.");
168 
169  m_ext_hits = &hitv;
170 
171  m_n_hits = 0;
172  m_hit_infos.clear();
173  m_qphifines.clear();
174  m_ext_idcs.clear();
177  }
const HitVec * m_ext_hits
assert(be >=bs)
std::vector< int > m_ext_idcs
std::vector< HitInfo > m_hit_infos
std::vector< uint32_t > m_qphifines
void mkfit::LayerOfHits::empty_phi_bins ( int  q_bin,
int  phi_bin_1,
int  phi_bin_2,
uint16_t  hit_count 
)
inlineprivate

Definition at line 156 of file HitStructures.h.

References m_phi_bin_infos.

Referenced by empty_q_bins().

156  {
157  for (int pb = phi_bin_1; pb < phi_bin_2; ++pb) {
158  m_phi_bin_infos[q_bin][pb] = {hit_count, hit_count};
159  }
160  }
vecvecPhiBinInfo_t m_phi_bin_infos
void mkfit::LayerOfHits::empty_phi_bins_dead ( int  q_bin,
int  phi_bin_1,
int  phi_bin_2 
)
inlineprivate

Definition at line 168 of file HitStructures.h.

References m_phi_bin_deads.

Referenced by empty_q_bins_dead().

168  {
169  for (int pb = phi_bin_1; pb < phi_bin_2; ++pb) {
170  m_phi_bin_deads[q_bin][pb] = false;
171  }
172  }
vecvecPhiBinDead_t m_phi_bin_deads
void mkfit::LayerOfHits::empty_q_bins ( int  q_bin_1,
int  q_bin_2,
uint16_t  hit_count 
)
inlineprivate

Definition at line 162 of file HitStructures.h.

References empty_phi_bins(), and mkfit::Config::m_nphi.

Referenced by endRegistrationOfHits(), and suckInHits().

162  {
163  for (int qb = q_bin_1; qb < q_bin_2; ++qb) {
164  empty_phi_bins(qb, 0, Config::m_nphi, hit_count);
165  }
166  }
static constexpr int m_nphi
Definition: Config.h:81
void empty_phi_bins(int q_bin, int phi_bin_1, int phi_bin_2, uint16_t hit_count)
void mkfit::LayerOfHits::empty_q_bins_dead ( int  q_bin_1,
int  q_bin_2 
)
inlineprivate

Definition at line 174 of file HitStructures.h.

References empty_phi_bins_dead(), and mkfit::Config::m_nphi.

Referenced by suckInDeads().

174  {
175  for (int qb = q_bin_1; qb < q_bin_2; ++qb) {
177  }
178  }
static constexpr int m_nphi
Definition: Config.h:81
void empty_phi_bins_dead(int q_bin, int phi_bin_1, int phi_bin_2)
void mkfit::LayerOfHits::endRegistrationOfHits ( bool  build_original_to_internal_map)

Definition at line 195 of file HitStructures.cc.

References empty_q_bins(), mps_fire::i, dqmiolumiharvest::j, isotrackApplyRegressor::k, m_ext_idcs, m_hit_infos, m_hit_phis, m_hit_qs, m_hit_ranks, m_max_ext_idx, m_min_ext_idx, m_n_hits, m_nq, m_phi_bin_infos, m_phi_bits_shift, m_phi_fine_xmask, m_phi_mask_fine, m_qphifines, gpuVertexFinder::printf(), RADIX_UNSIGNED, RadixSort::RelinquishRanks(), RadixSort::Sort(), and mkfit::Config::usePhiQArrays.

195  {
196  m_n_hits = m_ext_idcs.size();
197  if (m_n_hits == 0)
198  return;
199 
200  // radix
201  operator delete[](m_hit_ranks);
202  {
203  RadixSort sort;
205  m_hit_ranks = sort.RelinquishRanks();
206  }
207 
208  // copy q/phi
209 
210 #ifdef COPY_SORTED_HITS
211  if (m_capacity < m_n_hits) {
212  free_hits();
213  alloc_hits(m_n_hits);
214  }
215 #endif
216 
217  if (Config::usePhiQArrays) {
218  m_hit_phis.resize(m_n_hits);
219  m_hit_qs.resize(m_n_hits);
220  }
221 
222  int curr_qphi = -1;
223  empty_q_bins(0, m_nq, 0);
224 
225  for (int i = 0; i < m_n_hits; ++i) {
226  int j = m_hit_ranks[i]; // index in intermediate
227  int k = m_ext_idcs[j]; // index in external hit_vec
228 
229 #ifdef COPY_SORTED_HITS
230  memcpy(&m_hits[i], &hitv[k], sizeof(Hit));
231 #endif
232 
233  if (Config::usePhiQArrays) {
234  m_hit_phis[i] = m_hit_infos[j].phi;
235  m_hit_qs[i] = m_hit_infos[j].q;
236  }
237 
238  // Combined q-phi bin with fine part masked off
239  const int jqphi = m_qphifines[j] & m_phi_fine_xmask;
240 
241  const int phi_bin = (jqphi & m_phi_mask_fine) >> m_phi_bits_shift;
242  const int q_bin = jqphi >> 16;
243 
244  // Fill the bin info
245  if (jqphi != curr_qphi) {
246  m_phi_bin_infos[q_bin][phi_bin] = {i, i};
247  curr_qphi = jqphi;
248  }
249 
250  m_phi_bin_infos[q_bin][phi_bin].second++;
251 
252  // m_hit_ranks[i] will never be used again - use it to point to external/original index.
253  m_hit_ranks[i] = k;
254  }
255 
256  if (build_original_to_internal_map) {
257  if (m_max_ext_idx - m_min_ext_idx + 1 > 8 * m_n_hits) {
258  // If this happens we might:
259  // a) Use external indices for everything. -- *** We are now. ***
260  // b) Build these maps for seeding layers only.
261  // c) Have a flag in hit-on-track that tells us if the hit index has been remapped,
262  // essentially, if it is a seed hit. This might be smart anyway.
263  // One could use index < -256 or something similar.
264 
265  printf(
266  "LayerOfHits::endRegistrationOfHits() original_to_internal index map vector is largish: m_n_hits=%d, "
267  "map_vector_size=%d\n",
268  m_n_hits,
270  }
271 
272  m_ext_idcs.resize(m_max_ext_idx - m_min_ext_idx + 1);
273  for (int i = 0; i < m_n_hits; ++i) {
275  }
276  }
277 
278  // We can release m_hit_infos and m_qphifines -- and realloc on next BeginInput.
279  // m_qphifines could still be used as pre-selection in selectHitIndices().
280  }
std::vector< float > m_hit_phis
udword * RelinquishRanks()
static constexpr int m_phi_mask_fine
RadixSort & Sort(const udword *input, udword nb, RadixHint hint=RADIX_SIGNED)
constexpr bool usePhiQArrays
Definition: Config.h:104
static constexpr int m_phi_fine_xmask
unsigned int * m_hit_ranks
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
static constexpr int m_phi_bits_shift
std::vector< float > m_hit_qs
vecvecPhiBinInfo_t m_phi_bin_infos
Input values are unsigned.
std::vector< int > m_ext_idcs
std::vector< HitInfo > m_hit_infos
void empty_q_bins(int q_bin_1, int q_bin_2, uint16_t hit_count)
std::vector< uint32_t > m_qphifines
int mkfit::LayerOfHits::getHitIndexFromOriginal ( int  i) const
inline

Definition at line 95 of file HitStructures.h.

References m_ext_idcs, and m_min_ext_idx.

95 { return m_ext_idcs[i - m_min_ext_idx]; }
std::vector< int > m_ext_idcs
int mkfit::LayerOfHits::getOriginalHitIndex ( int  i) const
inline

Definition at line 97 of file HitStructures.h.

References mps_fire::i, and m_hit_ranks.

Referenced by mkfit::MkFinder::selectHitIndices().

97 { return m_hit_ranks[i]; }
unsigned int * m_hit_ranks
float mkfit::LayerOfHits::hit_phi ( int  i) const
inline

Definition at line 92 of file HitStructures.h.

References mps_fire::i, and m_hit_phis.

Referenced by mkfit::MkFinder::selectHitIndices().

92 { return m_hit_phis[i]; }
std::vector< float > m_hit_phis
float mkfit::LayerOfHits::hit_q ( int  i) const
inline

Definition at line 91 of file HitStructures.h.

References mps_fire::i, and m_hit_qs.

Referenced by mkfit::MkFinder::selectHitIndices().

91 { return m_hit_qs[i]; }
std::vector< float > m_hit_qs
const Hit* mkfit::LayerOfHits::hitArray ( ) const
inline

Definition at line 104 of file HitStructures.h.

References m_ext_hits.

Referenced by mkfit::MkFinder::addBestHit(), mkfit::MkFinder::findCandidates(), and mkfit::MkFinder::findCandidatesCloneEngine().

104 { return m_ext_hits->data(); }
const HitVec * m_ext_hits
bool mkfit::LayerOfHits::is_barrel ( ) const
inline
bool mkfit::LayerOfHits::is_endcap ( ) const
inline

Definition at line 119 of file HitStructures.h.

References m_is_barrel.

119 { return !m_is_barrel; }
bool mkfit::LayerOfHits::is_pix_lyr ( ) const
inline

Definition at line 137 of file HitStructures.h.

References mkfit::LayerInfo::is_pix_lyr(), and m_layer_info.

Referenced by mkfit::MkFinder::findCandidates(), and mkfit::MkFinder::findCandidatesCloneEngine().

137 { return m_layer_info->is_pix_lyr(); }
bool is_pix_lyr() const
Definition: TrackerInfo.h:62
const LayerInfo * m_layer_info
bool mkfit::LayerOfHits::is_pixb_lyr ( ) const
inline

Definition at line 135 of file HitStructures.h.

References mkfit::LayerInfo::is_pixb_lyr(), and m_layer_info.

135 { return m_layer_info->is_pixb_lyr(); }
bool is_pixb_lyr() const
Definition: TrackerInfo.h:60
const LayerInfo * m_layer_info
bool mkfit::LayerOfHits::is_pixe_lyr ( ) const
inline

Definition at line 136 of file HitStructures.h.

References mkfit::LayerInfo::is_pixe_lyr(), and m_layer_info.

136 { return m_layer_info->is_pixe_lyr(); }
bool is_pixe_lyr() const
Definition: TrackerInfo.h:61
const LayerInfo * m_layer_info
bool mkfit::LayerOfHits::is_stereo ( ) const
inline

Definition at line 132 of file HitStructures.h.

References mkfit::LayerInfo::is_stereo(), and m_layer_info.

Referenced by mkfit::MkFinder::bkFitFitTracks().

132 { return m_layer_info->is_stereo(); }
bool is_stereo() const
Definition: TrackerInfo.h:50
const LayerInfo * m_layer_info
bool mkfit::LayerOfHits::is_tec_lyr ( ) const
inline

Definition at line 141 of file HitStructures.h.

References mkfit::LayerInfo::is_tec_lyr(), and m_layer_info.

141 { return m_layer_info->is_tec_lyr(); }
bool is_tec_lyr() const
Definition: TrackerInfo.h:66
const LayerInfo * m_layer_info
bool mkfit::LayerOfHits::is_tib_lyr ( ) const
inline

Definition at line 138 of file HitStructures.h.

References mkfit::LayerInfo::is_tib_lyr(), and m_layer_info.

138 { return m_layer_info->is_tib_lyr(); }
bool is_tib_lyr() const
Definition: TrackerInfo.h:63
const LayerInfo * m_layer_info
bool mkfit::LayerOfHits::is_tid_lyr ( ) const
inline

Definition at line 140 of file HitStructures.h.

References mkfit::LayerInfo::is_tid_lyr(), and m_layer_info.

140 { return m_layer_info->is_tid_lyr(); }
bool is_tid_lyr() const
Definition: TrackerInfo.h:65
const LayerInfo * m_layer_info
bool mkfit::LayerOfHits::is_tob_lyr ( ) const
inline

Definition at line 139 of file HitStructures.h.

References mkfit::LayerInfo::is_tob_lyr(), and m_layer_info.

139 { return m_layer_info->is_tob_lyr(); }
bool is_tob_lyr() const
Definition: TrackerInfo.h:64
const LayerInfo * m_layer_info
bool mkfit::LayerOfHits::is_within_r_limits ( float  r) const
inline

Definition at line 122 of file HitStructures.h.

References mkfit::LayerInfo::is_within_r_limits(), and m_layer_info.

122 { return m_layer_info->is_within_r_limits(r); }
bool is_within_r_limits(float r) const
Definition: TrackerInfo.h:55
const LayerInfo * m_layer_info
WSR_Result mkfit::LayerOfHits::is_within_r_sensitive_region ( float  r,
float  dr 
) const
inline

Definition at line 128 of file HitStructures.h.

References mkfit::LayerInfo::is_within_r_sensitive_region(), and m_layer_info.

Referenced by mkfit::MkFinder::selectHitIndices().

128  {
130  }
WSR_Result is_within_r_sensitive_region(float r, float dr) const
Definition: TrackerInfo.h:76
const LayerInfo * m_layer_info
bool mkfit::LayerOfHits::is_within_z_limits ( float  z) const
inline

Definition at line 121 of file HitStructures.h.

References mkfit::LayerInfo::is_within_z_limits(), and m_layer_info.

121 { return m_layer_info->is_within_z_limits(z); }
bool is_within_z_limits(float z) const
Definition: TrackerInfo.h:54
const LayerInfo * m_layer_info
WSR_Result mkfit::LayerOfHits::is_within_z_sensitive_region ( float  z,
float  dz 
) const
inline

Definition at line 124 of file HitStructures.h.

References mkfit::LayerInfo::is_within_z_sensitive_region(), and m_layer_info.

Referenced by mkfit::MkFinder::selectHitIndices().

124  {
126  }
WSR_Result is_within_z_sensitive_region(float z, float dz) const
Definition: TrackerInfo.h:68
const LayerInfo * m_layer_info
int mkfit::LayerOfHits::layer_id ( ) const
inline
const LayerInfo* mkfit::LayerOfHits::layer_info ( ) const
inline
int mkfit::LayerOfHits::nHits ( void  ) const
inline
bool mkfit::LayerOfHits::phi_bin_dead ( int  qi,
int  pi 
) const
inline

Definition at line 89 of file HitStructures.h.

References m_phi_bin_deads, and pi.

Referenced by mkfit::MkFinder::selectHitIndices().

89 { return m_phi_bin_deads[qi][pi]; }
vecvecPhiBinDead_t m_phi_bin_deads
const Double_t pi
const vecvecPhiBinDead_t& mkfit::LayerOfHits::phi_bin_deads ( ) const
inline

Definition at line 87 of file HitStructures.h.

References m_phi_bin_deads.

87 { return m_phi_bin_deads; }
vecvecPhiBinDead_t m_phi_bin_deads
PhiBinInfo_t mkfit::LayerOfHits::phi_bin_info ( int  qi,
int  pi 
) const
inline

Definition at line 88 of file HitStructures.h.

References m_phi_bin_infos, and pi.

Referenced by mkfit::MkFinder::selectHitIndices().

88 { return m_phi_bin_infos[qi][pi]; }
const Double_t pi
vecvecPhiBinInfo_t m_phi_bin_infos
const vecvecPhiBinInfo_t& mkfit::LayerOfHits::phi_bin_infos ( ) const
inline

Definition at line 86 of file HitStructures.h.

References m_phi_bin_infos.

86 { return m_phi_bin_infos; }
vecvecPhiBinInfo_t m_phi_bin_infos
int mkfit::LayerOfHits::phiBin ( float  phi) const
inline

Definition at line 78 of file HitStructures.h.

References m_phi_bits_shift, and phiBinFine().

Referenced by phiBinChecked(), mkfit::MkFinder::selectHitIndices(), and suckInDeads().

78 { return phiBinFine(phi) >> m_phi_bits_shift; }
int phiBinFine(float phi) const
Definition: HitStructures.h:77
static constexpr int m_phi_bits_shift
int mkfit::LayerOfHits::phiBinChecked ( float  phi) const
inline

Definition at line 80 of file HitStructures.h.

References m_phi_mask, and phiBin().

80 { return phiBin(phi) & m_phi_mask; }
static constexpr int m_phi_mask
int phiBin(float phi) const
Definition: HitStructures.h:78
int mkfit::LayerOfHits::phiBinFine ( float  phi) const
inline

Definition at line 77 of file HitStructures.h.

References m_fphi_fine, and mkfit::Const::PI.

Referenced by phiBin(), registerHit(), and suckInHits().

77 { return std::floor(m_fphi_fine * (phi + Const::PI)); }
constexpr float PI
Definition: Config.h:42
static constexpr float m_fphi_fine
int mkfit::LayerOfHits::phiMaskApply ( int  in) const
inline

Definition at line 82 of file HitStructures.h.

References m_phi_mask.

Referenced by mkfit::MkFinder::selectHitIndices().

82 { return in & m_phi_mask; }
static constexpr int m_phi_mask
void mkfit::LayerOfHits::printBins ( )

Definition at line 355 of file HitStructures.cc.

References first, is_barrel(), mkfit::Config::m_nphi, m_nq, m_phi_bin_infos, gpuVertexFinder::printf(), and edm::second().

355  {
356  for (int qb = 0; qb < m_nq; ++qb) {
357  printf("%c bin %d\n", is_barrel() ? 'Z' : 'R', qb);
358  for (int pb = 0; pb < Config::m_nphi; ++pb) {
359  if (pb % 8 == 0)
360  printf(" Phi %4d: ", pb);
361  printf("%5d,%4d %s",
362  m_phi_bin_infos[qb][pb].first,
363  m_phi_bin_infos[qb][pb].second,
364  ((pb + 1) % 8 == 0) ? "\n" : "");
365  }
366  }
367  }
static constexpr int m_nphi
Definition: Config.h:81
U second(std::pair< T, U > const &p)
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
bool is_barrel() const
vecvecPhiBinInfo_t m_phi_bin_infos
int mkfit::LayerOfHits::qBin ( float  q) const
inline

Definition at line 72 of file HitStructures.h.

References m_fq, and m_qmin.

Referenced by qBinChecked(), and vecPhiBinInfo().

int mkfit::LayerOfHits::qBinChecked ( float  q) const
inline

Definition at line 74 of file HitStructures.h.

References m_nq, and qBin().

Referenced by registerHit(), mkfit::MkFinder::selectHitIndices(), suckInDeads(), and suckInHits().

74 { return std::clamp(qBin(q), 0, m_nq - 1); }
int qBin(float q) const
Definition: HitStructures.h:72
const Hit& mkfit::LayerOfHits::refHit ( int  i) const
inline
void mkfit::LayerOfHits::registerHit ( int  idx)

Definition at line 179 of file HitStructures.cc.

References h, m_ext_idcs, m_hit_infos, m_is_barrel, m_max_ext_idx, m_min_ext_idx, m_qphifines, SiStripPI::max, SiStripPI::min, mkfit::Hit::phi(), mkfit::LayerOfHits::HitInfo::phi, phiBinFine(), mkfit::LayerOfHits::HitInfo::q, qBinChecked(), mkfit::Hit::r(), mkfit::Config::usePhiQArrays, and mkfit::Hit::z().

179  {
180  const Hit &h = (*m_ext_hits)[idx];
181 
182  m_ext_idcs.push_back(idx);
185 
186  HitInfo hi = {h.phi(), m_is_barrel ? h.z() : h.r()};
187 
188  m_qphifines.push_back(phiBinFine(hi.phi) + (qBinChecked(hi.q) << 16));
189 
190  if (Config::usePhiQArrays) {
191  m_hit_infos.emplace_back(hi);
192  }
193  }
double z
global z - AlignmentGeometry::z0, mm
Definition: HitCollection.h:27
int phiBinFine(float phi) const
Definition: HitStructures.h:77
int qBinChecked(float q) const
Definition: HitStructures.h:74
constexpr bool usePhiQArrays
Definition: Config.h:104
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::vector< int > m_ext_idcs
std::vector< HitInfo > m_hit_infos
std::vector< uint32_t > m_qphifines
void mkfit::LayerOfHits::reset ( void  )
inline

Definition at line 55 of file HitStructures.h.

55 {}
void mkfit::LayerOfHits::setup_bins ( float  qmin,
float  qmax,
float  dq 
)
private

Definition at line 30 of file HitStructures.cc.

References reco::ceil(), m_fq, m_nq, m_phi_bin_deads, m_phi_bin_infos, m_qmax, and m_qmin.

Referenced by setupLayer().

30  {
31  // Define layer with min/max and number of bins along q.
32 
33  if (dq < 0) {
34  m_nq = (int)-dq;
35  m_qmin = qmin;
36  m_qmax = qmax;
37  } else {
38  float extent = qmax - qmin;
39  m_nq = std::ceil(extent / dq);
40  float extra = 0.5f * (m_nq * dq - extent);
41  m_qmin = qmin - extra;
42  m_qmax = qmax + extra;
43  }
44  m_fq = m_nq / (qmax - qmin); // used in e.g. qbin = (q_hit - m_qmin) * m_fq;
45 
46  m_phi_bin_infos.resize(m_nq);
47  m_phi_bin_deads.resize(m_nq);
48  }
constexpr int32_t ceil(float num)
vecvecPhiBinDead_t m_phi_bin_deads
vecvecPhiBinInfo_t m_phi_bin_infos
void mkfit::LayerOfHits::setupLayer ( const LayerInfo li)

Definition at line 50 of file HitStructures.cc.

References cms::cuda::assert(), mkfit::LayerInfo::is_barrel(), m_is_barrel, m_layer_info, mkfit::LayerInfo::q_bin(), mkfit::LayerInfo::rin(), mkfit::LayerInfo::rout(), setup_bins(), mkfit::LayerInfo::zmax(), and mkfit::LayerInfo::zmin().

50  {
51  // Note, LayerInfo::q_bin( ==> > 0 - bin width, < 0 - number of bins
52 
53  assert(m_layer_info == nullptr && "setupLayer() already called.");
54 
55  m_layer_info = &li;
56 
58 
59  if (m_is_barrel)
60  setup_bins(li.zmin(), li.zmax(), li.q_bin());
61  else
62  setup_bins(li.rin(), li.rout(), li.q_bin());
63  }
assert(be >=bs)
void setup_bins(float qmin, float qmax, float dq)
bool is_barrel() const
Definition: TrackerInfo.h:52
const LayerInfo * m_layer_info
void mkfit::LayerOfHits::suckInDeads ( const DeadVec deadv)

Definition at line 139 of file HitStructures.cc.

References cms::cuda::assert(), ztail::d, empty_q_bins_dead(), mkfit::Config::m_nphi, m_nq, m_phi_bin_deads, phiBin(), and qBinChecked().

139  {
140  assert(m_nq > 0 && "setupLayer() was not called.");
141 
143 
144  for (const auto &d : deadv) {
145  int q_bin_1 = qBinChecked(d.q1);
146  int q_bin_2 = qBinChecked(d.q2) + 1;
147  int phi_bin_1 = phiBin(d.phi1);
148  int phi_bin_2 = phiBin(d.phi2) + 1;
149  for (int q_bin = q_bin_1; q_bin < q_bin_2; q_bin++) {
150  if (phi_bin_1 > phi_bin_2) {
151  for (int pb = phi_bin_1; pb < Config::m_nphi; pb++) {
152  m_phi_bin_deads[q_bin][pb] = true;
153  }
154  for (int pb = 0; pb < phi_bin_2; pb++) {
155  m_phi_bin_deads[q_bin][pb] = true;
156  }
157  } else {
158  for (int pb = phi_bin_1; pb < phi_bin_2; pb++) {
159  m_phi_bin_deads[q_bin][pb] = true;
160  }
161  }
162  }
163  }
164  }
static constexpr int m_nphi
Definition: Config.h:81
int qBinChecked(float q) const
Definition: HitStructures.h:74
vecvecPhiBinDead_t m_phi_bin_deads
assert(be >=bs)
tuple d
Definition: ztail.py:151
int phiBin(float phi) const
Definition: HitStructures.h:78
void empty_q_bins_dead(int q_bin_1, int q_bin_2)
void mkfit::LayerOfHits::suckInHits ( const HitVec hitv)

Definition at line 67 of file HitStructures.cc.

References cms::cuda::assert(), empty_q_bins(), h, mps_fire::i, dqmiolumiharvest::j, m_ext_hits, m_hit_infos, m_hit_phis, m_hit_qs, m_hit_ranks, m_is_barrel, m_n_hits, m_nq, m_phi_bin_infos, m_phi_bits_shift, m_phi_fine_xmask, m_phi_mask_fine, m_qphifines, mkfit::Hit::phi(), mkfit::LayerOfHits::HitInfo::phi, phiBinFine(), mkfit::LayerOfHits::HitInfo::q, qBinChecked(), mkfit::Hit::r(), RADIX_UNSIGNED, RadixSort::RelinquishRanks(), RadixSort::Sort(), mkfit::Config::usePhiQArrays, and mkfit::Hit::z().

67  {
68  assert(m_nq > 0 && "setupLayer() was not called.");
69 
70  m_n_hits = hitv.size();
71  m_ext_hits = &hitv;
72 
73 #ifdef COPY_SORTED_HITS
74  if (m_capacity < m_n_hits) {
75  free_hits();
76  alloc_hits(m_n_hits);
77  }
78 #endif
79 
81  m_hit_phis.resize(m_n_hits);
82  m_hit_qs.resize(m_n_hits);
83  m_hit_infos.resize(m_n_hits);
84  }
85  m_qphifines.resize(m_n_hits);
86 
87  for (int i = 0; i < m_n_hits; ++i) {
88  const Hit &h = hitv[i];
89 
90  HitInfo hi = {h.phi(), m_is_barrel ? h.z() : h.r()};
91 
92  m_qphifines[i] = phiBinFine(hi.phi) + (qBinChecked(hi.q) << 16);
93 
95  m_hit_infos[i] = hi;
96  }
97  }
98 
99  operator delete[](m_hit_ranks);
100  {
101  RadixSort sort;
102  sort.Sort(&m_qphifines[0], m_n_hits, RADIX_UNSIGNED);
103  m_hit_ranks = sort.RelinquishRanks();
104  }
105 
106  int curr_qphi = -1;
107  empty_q_bins(0, m_nq, 0);
108 
109  for (int i = 0; i < m_n_hits; ++i) {
110  int j = m_hit_ranks[i];
111 
112 #ifdef COPY_SORTED_HITS
113  memcpy(&m_hits[i], &hitv[j], sizeof(Hit));
114 #endif
115 
116  if (Config::usePhiQArrays) {
117  m_hit_phis[i] = m_hit_infos[j].phi;
118  m_hit_qs[i] = m_hit_infos[j].q;
119  }
120 
121  // Combined q-phi bin with fine part masked off
122  const int jqphi = m_qphifines[j] & m_phi_fine_xmask;
123 
124  const int phi_bin = (jqphi & m_phi_mask_fine) >> m_phi_bits_shift;
125  const int q_bin = jqphi >> 16;
126 
127  // Fill the bin info
128  if (jqphi != curr_qphi) {
129  m_phi_bin_infos[q_bin][phi_bin] = {i, i};
130  curr_qphi = jqphi;
131  }
132 
133  m_phi_bin_infos[q_bin][phi_bin].second++;
134  }
135  }
double z
global z - AlignmentGeometry::z0, mm
Definition: HitCollection.h:27
int phiBinFine(float phi) const
Definition: HitStructures.h:77
int qBinChecked(float q) const
Definition: HitStructures.h:74
std::vector< float > m_hit_phis
udword * RelinquishRanks()
static constexpr int m_phi_mask_fine
const HitVec * m_ext_hits
RadixSort & Sort(const udword *input, udword nb, RadixHint hint=RADIX_SIGNED)
assert(be >=bs)
constexpr bool usePhiQArrays
Definition: Config.h:104
static constexpr int m_phi_fine_xmask
unsigned int * m_hit_ranks
static constexpr int m_phi_bits_shift
std::vector< float > m_hit_qs
vecvecPhiBinInfo_t m_phi_bin_infos
Input values are unsigned.
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::vector< HitInfo > m_hit_infos
void empty_q_bins(int q_bin_1, int q_bin_2, uint16_t hit_count)
std::vector< uint32_t > m_qphifines
const vecPhiBinInfo_t& mkfit::LayerOfHits::vecPhiBinInfo ( float  q) const
inline

Definition at line 84 of file HitStructures.h.

References m_phi_bin_infos, and qBin().

84 { return m_phi_bin_infos[qBin(q)]; }
int qBin(float q) const
Definition: HitStructures.h:72
vecvecPhiBinInfo_t m_phi_bin_infos

Member Data Documentation

const HitVec* mkfit::LayerOfHits::m_ext_hits
private

Definition at line 187 of file HitStructures.h.

Referenced by beginRegistrationOfHits(), hitArray(), refHit(), and suckInHits().

std::vector<int> mkfit::LayerOfHits::m_ext_idcs
private
constexpr float mkfit::LayerOfHits::m_fphi = Config::m_nphi / Const::TwoPI
staticprivate

Definition at line 145 of file HitStructures.h.

constexpr float mkfit::LayerOfHits::m_fphi_fine = 1024 / Const::TwoPI
staticprivate

Definition at line 148 of file HitStructures.h.

Referenced by phiBinFine().

float mkfit::LayerOfHits::m_fq
private

Definition at line 204 of file HitStructures.h.

Referenced by qBin(), and setup_bins().

std::vector<HitInfo> mkfit::LayerOfHits::m_hit_infos
private
std::vector<float> mkfit::LayerOfHits::m_hit_phis
private

Definition at line 199 of file HitStructures.h.

Referenced by endRegistrationOfHits(), hit_phi(), and suckInHits().

std::vector<float> mkfit::LayerOfHits::m_hit_qs
private

Definition at line 200 of file HitStructures.h.

Referenced by endRegistrationOfHits(), hit_q(), and suckInHits().

unsigned int* mkfit::LayerOfHits::m_hit_ranks = nullptr
private
bool mkfit::LayerOfHits::m_is_barrel
private

Definition at line 206 of file HitStructures.h.

Referenced by is_barrel(), is_endcap(), registerHit(), setupLayer(), and suckInHits().

const LayerInfo* mkfit::LayerOfHits::m_layer_info = nullptr
private
int mkfit::LayerOfHits::m_max_ext_idx
private

Definition at line 191 of file HitStructures.h.

Referenced by beginRegistrationOfHits(), endRegistrationOfHits(), and registerHit().

int mkfit::LayerOfHits::m_min_ext_idx
private
int mkfit::LayerOfHits::m_n_hits = 0
private

Definition at line 192 of file HitStructures.h.

Referenced by beginRegistrationOfHits(), endRegistrationOfHits(), nHits(), and suckInHits().

int mkfit::LayerOfHits::m_nq = 0
private
vecvecPhiBinDead_t mkfit::LayerOfHits::m_phi_bin_deads
private
vecvecPhiBinInfo_t mkfit::LayerOfHits::m_phi_bin_infos
private
constexpr int mkfit::LayerOfHits::m_phi_bits = 8
staticprivate

Definition at line 147 of file HitStructures.h.

constexpr int mkfit::LayerOfHits::m_phi_bits_fine = 10
staticprivate

Definition at line 150 of file HitStructures.h.

constexpr int mkfit::LayerOfHits::m_phi_bits_shift = m_phi_bits_fine - m_phi_bits
staticprivate

Definition at line 151 of file HitStructures.h.

Referenced by endRegistrationOfHits(), phiBin(), and suckInHits().

constexpr int mkfit::LayerOfHits::m_phi_fine_xmask = ~((1 << m_phi_bits_shift) - 1)
staticprivate

Definition at line 152 of file HitStructures.h.

Referenced by endRegistrationOfHits(), and suckInHits().

constexpr int mkfit::LayerOfHits::m_phi_mask = 0xff
staticprivate

Definition at line 146 of file HitStructures.h.

Referenced by phiBinChecked(), and phiMaskApply().

constexpr int mkfit::LayerOfHits::m_phi_mask_fine = 0x3ff
staticprivate

Definition at line 149 of file HitStructures.h.

Referenced by endRegistrationOfHits(), and suckInHits().

float mkfit::LayerOfHits::m_qmax
private

Definition at line 204 of file HitStructures.h.

Referenced by setup_bins().

float mkfit::LayerOfHits::m_qmin
private

Definition at line 204 of file HitStructures.h.

Referenced by qBin(), and setup_bins().

std::vector<uint32_t> mkfit::LayerOfHits::m_qphifines
private