1 #ifndef RecoTracker_MkFitCore_interface_HitStructures_h
2 #define RecoTracker_MkFitCore_interface_HitStructures_h
99 #ifdef COPY_SORTED_HITS
100 const Hit&
refHit(
int i)
const {
return m_hits[
i]; }
154 void setup_bins(
float qmin,
float qmax,
float dq);
156 void empty_phi_bins(
int q_bin,
int phi_bin_1,
int phi_bin_2, uint16_t hit_count) {
157 for (
int pb = phi_bin_1; pb < phi_bin_2; ++pb) {
163 for (
int qb = q_bin_1; qb < q_bin_2; ++qb) {
169 for (
int pb = phi_bin_1; pb < phi_bin_2; ++pb) {
175 for (
int qb = q_bin_1; qb < q_bin_2; ++qb) {
180 #ifdef COPY_SORTED_HITS
181 void alloc_hits(
int size);
184 Hit* m_hits =
nullptr;
278 if (module_id ==
M[0].m_module_id) {
279 if (chi2 <
M[0].m_chi2) {
283 }
else if (module_id ==
M[1].m_module_id) {
284 if (chi2 <
M[1].m_chi2) {
289 if (
M[0].m_chi2 >
M[1].m_chi2) {
290 if (chi2 <
M[0].m_chi2) {
291 M[0] = {hit_idx, module_id, chi2};
294 if (chi2 <
M[1].m_chi2) {
295 M[1] = {hit_idx, module_id, chi2};
302 if (module_id ==
M[0].m_module_id) {
303 if (
M[1].m_hit_idx >= 0)
305 }
else if (module_id ==
M[1].m_module_id) {
306 if (
M[0].m_hit_idx >= 0)
309 if (
M[0].m_chi2 <=
M[1].m_chi2) {
310 if (
M[0].m_hit_idx >= 0)
313 if (
M[1].m_hit_idx >= 0)
328 if (size >
m_mem.size())
348 throw std::bad_alloc();
381 template <
class T,
class U>
451 int nMonoDecoded(
const int& encoded)
const {
return (encoded / 10000) % 100; }
454 return encoded % 100 + (encoded / 100) % 100 + (encoded / 10000) % 100 - encoded / 1000000;
489 inline float getScoreCand(
const TrackCand& cand1,
bool penalizeTailMissHits =
false,
bool inFindCandidates =
false) {
494 float pt = cand1.
pT();
499 return getScoreCalc(nfoundhits, ntailmisshits, noverlaphits, nmisshits, chi2, pt, inFindCandidates);
522 m_seed_algo(o.m_seed_algo),
523 m_seed_label(o.m_seed_label),
539 m_seed_algo(
o.m_seed_algo),
540 m_seed_label(
o.m_seed_label),
564 m_seed_algo =
o.m_seed_algo;
565 m_seed_label =
o.m_seed_label;
571 tc.setCombCandidate(
this);
587 void reset(
int max_cands_per_seed,
int expected_num_hots) {
588 std::vector<TrackCand, CcAlloc<TrackCand>>
tmp(
m_trk_cands.get_allocator());
600 m_hots.reserve(expected_num_hots);
636 int seed_algo()
const {
return m_seed_algo; }
637 int seed_label()
const {
return m_seed_label; }
651 int m_seed_label = 0;
688 if (hot_node.
m_hot.
index < 0 || !((0 <= tl && tl <= 3) || (18 <= tl && tl <= 20) || (45 <= tl && tl <= 47))) {
690 }
else if ((0 <= tl && tl <= 3) || (18 <= tl && tl <= 20) || (45 <= tl && tl <= 47)) {
707 if (thisL >= 0 && (hot_node.
m_hot.
index >= 0 || hot_node.
m_hot.
index == -9) && thisL != prevL) {
718 bool prevStereo =
false;
721 int pix = 0, stereo = 0, mono = 0, matched = 0;
722 int doubleStereo = -1;
732 doubleStereo = thisL;
736 if (prevStereo && thisL == prevL - 1)
738 else if (thisL == prevL && thisL == doubleStereo - 1)
746 return pix + 100 * stereo + 10000 * mono + 1000000 * matched;
751 bool prevStereo =
false;
754 int pix = 0, stereo = 0, mono = 0, matched = 0;
758 if (thisL >= 0 && (hot_node.
m_hot.
index >= 0 || hot_node.
m_hot.
index == -9) && thisL != prevL) {
766 if (prevStereo && thisL == prevL - 1)
774 return pix + 100 * stereo + 10000 * mono + 1000000 * matched;
786 if (hitIdx >= 0 || hitIdx == -9) {
808 std::vector<CombCandidate>
tmp;
816 void reset(
int new_capacity,
int max_cands_per_seed,
int expected_num_hots = 128) {
817 m_cc_pool.reset(new_capacity * max_cands_per_seed);
820 std::vector<CombCandidate>
tmp(new_capacity, alloc);
824 for (
int s = 0;
s < new_capacity; ++
s) {
825 m_candidates[
s].reset(max_cands_per_seed, expected_num_hots);
trk_cand_vec_type::size_type size() const
void setOriginIndex(int oi)
static constexpr int m_nphi
void endRegistrationOfHits(bool build_original_to_internal_map)
float hit_phi(int i) const
bool is_pix_lyr(int i) const
void addHitIdx(int hitIdx, int hitLyr, float chi2)
T * allocate(std::size_t n)
void reset(std::size_t size)
void deallocate(T *p, std::size_t n) noexcept
int nTailMinusOneHits() const
tuple ret
prodAgent to be discontinued
std::vector< CombCandidate > m_candidates
HitMatchPair m_overlap_hits
bool is_within_z_limits(float z) const
void reset(int max_cands_per_seed, int expected_num_hots)
int phiBinFine(float phi) const
const HoTNode & hot_node(int i) const
int qBinChecked(float q) const
void mergeCandsAndBestShortOne(const IterationParams ¶ms, bool update_score, bool sort_cands)
bool operator==(const CcAlloc< T > &a, const CcAlloc< U > &b)
void setNOverlapHits(int n)
int nTotMatchDecoded(const int &encoded) const
int getOriginalHitIndex(int i) const
void resizeAfterFiltering(int n_removed)
const TrackCand & operator[](int i) const
SeedState_e state() const
void consider_hit_for_overlap(int hit_idx, int module_id, float chi2)
const BeamSpot & refBeamSpot() const
CombCandidate * m_comb_candidate
Track exportTrack(bool remove_missing_hits=false) const
std::vector< float > m_hit_phis
CombCandidate & operator=(CombCandidate &&o)
void insertSeed(const Track &seed, int region)
void empty_phi_bins_dead(int q_bin, int phi_bin_1, int phi_bin_2)
int getLastFoundHitLyr() const
HitOnTrack getLastHitOnTrack() const
TrackCand m_best_short_cand
TrackCand(const TrackBase &base, CombCandidate *ccand)
HitMatch * findOverlap(int hit_idx, int module_id)
short int m_nInsideMinusOneHits_before_bkwsearch
int nUniqueLayers() const
void resize(trk_cand_vec_type::size_type count)
static constexpr int m_phi_mask_fine
const void * pool_id() const
const Hit * hitArray() const
void setLastCcIndex(int i)
const HitVec * m_ext_hits
void setNInsideMinusOneHits(int n)
bool phi_bin_dead(int qi, int pi) const
void setState(SeedState_e ss)
bool sortHitsByPhiMT(const Hit &h1, const Hit &h2)
HitMatch * find_overlap(int hit_idx, int module_id)
void setNFoundHits(int n)
WSR_Result is_within_r_sensitive_region(float r, float dr) const
const std::vector< CombCandidate > & refCandidates() const
WSR_Result is_within_z_sensitive_region(float z, float dz) const
float getScoreCalc(const int nfoundhits, const int ntailholes, const int noverlaphits, const int nmisshits, const float chi2, const float pt, const bool inFindCandidates=false)
std::vector< vecPhiBinDead_t > vecvecPhiBinDead_t
CombCandidate(const CombCandidate &o)
short int m_nTailMinusOneHits_before_bkwsearch
trk_cand_vec_type::reference emplace_back(TrackCand &tc)
static constexpr int m_phi_mask
int phiMaskApply(int in) const
int nLayersByTypeEncoded(const TrackerInfo &trk_inf) const
short int nTailMinusOneHits_
vecvecPhiBinDead_t m_phi_bin_deads
bool sortTrksByPhiMT(const Track &t1, const Track &t2)
CombCandidate(const allocator_type &alloc)
TrackCand & operator[](int i)
CcPool< TrackCand > m_cc_pool
int nInsideMinusOneHits() const
std::vector< vecPhiBinInfo_t > vecvecPhiBinInfo_t
int nMonoDecoded(const int &encoded) const
void setNTailMinusOneHits(int n)
HoTNode & refLastHoTNode()
void compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits)
const LayerInfo * layer_info() const
constexpr std::array< uint8_t, layerIndexSize > layer
std::array< PhiBinInfo_t, Config::m_nphi > vecPhiBinInfo_t
int nHitsByTypeEncoded(const TrackerInfo &trk_inf) const
EventOfCombCandidates(int size=0)
void setNMissingHits(int n)
static constexpr int m_phi_bits
const TrackCand & refBestShortCand() const
void setup_bins(float qmin, float qmax, float dq)
void reset(int new_capacity, int max_cands_per_seed, int expected_num_hots=128)
void setBeamSpot(const BeamSpot &bs)
static constexpr int m_phi_fine_xmask
CombCandidate & cand(int i)
bool is_within_r_limits(float r) const
int nPixelDecoded(const int &encoded) const
unsigned int * m_hit_ranks
LayerOfHits & operator[](int i)
const vecvecPhiBinDead_t & phi_bin_deads() const
CombCandidate & operator[](int i)
void considerHitForOverlap(int hit_idx, int module_id, float chi2)
float getScoreWorstPossible()
void suckInDeads(const DeadVec &deadv)
const HoTNode * hotsData() const
const vecPhiBinInfo_t & vecPhiBinInfo(float q) const
int nMatchedDecoded(const int &encoded) const
static constexpr float m_fphi_fine
int getLastFoundPixelHitLyr() const
int phiBin(float phi) const
std::vector< TrackCand, CcAlloc< TrackCand >> trk_cand_vec_type
HitOnTrack hot(int i) const
PhiBinInfo_t phi_bin_info(int qi, int pi) const
void compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits)
CombCandidate * combCandidate() const
bool is_stereo(int i) const
void empty_phi_bins(int q_bin, int phi_bin_1, int phi_bin_2, uint16_t hit_count)
std::vector< Hit > HitVec
std::array< bool, Config::m_nphi > vecPhiBinDead_t
void setupLayer(const LayerInfo &li)
float getScoreCand(const TrackCand &cand1, bool penalizeTailMissHits=false, bool inFindCandidates=false)
const SVector3 & position() const
static constexpr int m_phi_bits_shift
HoTNode & hot_node_nc(int i)
bool sortByScoreTrackCand(const TrackCand &cand1, const TrackCand &cand2)
void empty_q_bins_dead(int q_bin_1, int q_bin_2)
std::vector< CombCandidate > & refCandidates_nc()
short int m_lastHitIdx_before_bkwsearch
void setCombCandidate(CombCandidate *cc)
void deallocate(T *p, std::size_t n) noexcept
std::vector< DeadRegion > DeadVec
trk_cand_vec_type m_trk_cands
std::vector< float > m_hit_qs
WSR_Result is_within_z_sensitive_region(float z, float dz) const
void suckInHits(int layer, const HitVec &hitv)
int phiBinChecked(float phi) const
int getLastHitIdx() const
void suckInHits(const HitVec &hitv)
void beginRegistrationOfHits(const HitVec &hitv)
void importSeed(const Track &seed, int region)
EventOfHits(const TrackerInfo &trk_inf)
bool is_within_r_limits(float r) const
static constexpr int m_phi_bits_fine
const Hit & refHit(int i) const
const CombCandidate & operator[](int i) const
const vecvecPhiBinInfo_t & phi_bin_infos() const
bool is_within_z_limits(float z) const
int nStereoDecoded(const int &encoded) const
int addHit(const HitOnTrack &hot, float chi2, int prev_idx)
const LayerOfHits & operator[](int i) const
vecvecPhiBinInfo_t m_phi_bin_infos
int getHitIndexFromOriginal(int i) const
void registerHit(int idx)
const LayerInfo * m_layer_info
CombCandidate(CombCandidate &&o)
WSR_Result is_within_r_sensitive_region(float r, float dr) const
T * allocate(std::size_t n)
int getLastHitLyr() const
std::pair< uint16_t, uint16_t > PhiBinInfo_t
short int nInsideMinusOneHits_
CcPool(std::size_t size=0)
void suckInDeads(int layer, const DeadVec &deadv)
std::vector< int > m_ext_idcs
std::vector< LayerOfHits > m_layers_of_hits
std::vector< HitInfo > m_hit_infos
tuple size
Write out results.
void empty_q_bins(int q_bin_1, int q_bin_2, uint16_t hit_count)
void setBestShortCand(const TrackCand &tc)
const TrackCand & front() const
static constexpr float m_fphi
std::vector< uint32_t > m_qphifines
std::vector< HoTNode > m_hots