CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends
mkfit::MkFinder Class Reference

#include <MkFinder.h>

Inheritance diagram for mkfit::MkFinder:
mkfit::MkBase

Public Types

using MPlexHitIdx = Matriplex::Matriplex< int, MPlexHitIdxMax, 1, NN >
 
using MPlexQHoT = Matriplex::Matriplex< HitOnTrack, 1, 1, NN >
 

Public Member Functions

void addBestHit (const LayerOfHits &layer_of_hits, const int N_proc, const FindingFoos &fnd_foos)
 
HitOnTrack bestHitLastHoT (int itrack) const
 
void bkFitFitTracks (const EventOfHits &eventofhits, const SteeringParams &st_par, const int N_proc, bool chiDebug=false)
 
void bkFitFitTracksBH (const EventOfHits &eventofhits, const SteeringParams &st_par, const int N_proc, bool chiDebug=false)
 
void bkFitInputTracks (TrackVec &cands, int beg, int end)
 
void bkFitInputTracks (EventOfCombCandidates &eocss, int beg, int end)
 
void bkFitOutputTracks (TrackVec &cands, int beg, int end, bool outputProp)
 
void bkFitOutputTracks (EventOfCombCandidates &eocss, int beg, int end, bool outputProp)
 
void bkFitPropTracksToPCA (const int N_proc)
 
void copyOutParErr (std::vector< CombCandidate > &seed_cand_vec, int N_proc, bool outputProp) const
 
void findCandidates (const LayerOfHits &layer_of_hits, std::vector< std::vector< TrackCand >> &tmp_candidates, const int offset, const int N_proc, const FindingFoos &fnd_foos)
 
void findCandidatesCloneEngine (const LayerOfHits &layer_of_hits, CandCloner &cloner, const int offset, const int N_proc, const FindingFoos &fnd_foos)
 
float getHitSelDynamicChi2Cut (const int itrk, const int ipar)
 
void getHitSelDynamicWindows (const float invpt, const float theta, float &min_dq, float &max_dq, float &min_dphi, float &max_dphi)
 
void inputTracksAndHitIdx (const std::vector< Track > &tracks, int beg, int end, bool inputProp)
 
void inputTracksAndHitIdx (const std::vector< Track > &tracks, const std::vector< int > &idxs, int beg, int end, bool inputProp, int mp_offset)
 
void inputTracksAndHitIdx (const std::vector< CombCandidate > &tracks, const std::vector< std::pair< int, int >> &idxs, int beg, int end, bool inputProp)
 
void inputTracksAndHitIdx (const std::vector< CombCandidate > &tracks, const std::vector< std::pair< int, IdxChi2List >> &idxs, int beg, int end, bool inputProp)
 
 MkFinder ()
 
void outputNonStoppedTracksAndHitIdx (std::vector< Track > &tracks, const std::vector< int > &idxs, int beg, int end, bool outputProp) const
 
void outputTrackAndHitIdx (Track &track, int itrack, bool outputProp) const
 
void outputTracksAndHitIdx (std::vector< Track > &tracks, int beg, int end, bool outputProp) const
 
void outputTracksAndHitIdx (std::vector< Track > &tracks, const std::vector< int > &idxs, int beg, int end, bool outputProp) const
 
void release ()
 
void selectHitIndices (const LayerOfHits &layer_of_hits, const int N_proc)
 
void setup (const PropagationConfig &pc, const IterationParams &ip, const IterationLayerConfig &ilc, const std::vector< bool > *ihm)
 
void setup_bkfit (const PropagationConfig &pc)
 
void updateWithLastHit (const LayerOfHits &layer_of_hits, int N_proc, const FindingFoos &fnd_foos)
 
- Public Member Functions inherited from mkfit::MkBase
float getPar (int itrack, int i, int par) const
 
 MkBase ()
 
void propagateTracksToHitR (const MPlexHV &par, const int N_proc, const PropagationFlags pf, const MPlexQI *noMatEffPtr=nullptr)
 
void propagateTracksToHitZ (const MPlexHV &par, const int N_proc, const PropagationFlags pf, const MPlexQI *noMatEffPtr=nullptr)
 
void propagateTracksToPCAZ (const int N_proc, const PropagationFlags pf)
 
void propagateTracksToR (float r, const int N_proc, const PropagationFlags pf)
 
void propagateTracksToZ (float z, const int N_proc, const PropagationFlags pf)
 
float radiusSqr (int itrack, int i) const
 

Static Public Attributes

static constexpr int MPlexHitIdxMax = 16
 
- Static Public Attributes inherited from mkfit::MkBase
static constexpr int iC = 0
 
static constexpr int iP = 1
 

Private Member Functions

void add_hit (const int mslot, int index, int layer)
 
void copy_in (const Track &trk, const int mslot, const int tslot)
 
void copy_in (const TrackCand &trk, const int mslot, const int tslot)
 
void copy_out (Track &trk, const int mslot, const int tslot) const
 
void copy_out (TrackCand &trk, const int mslot, const int tslot) const
 
int num_all_minus_one_hits (const int mslot) const
 
int num_inside_minus_one_hits (const int mslot) const
 

Private Attributes

MPlexQI m_CandIdx
 
MPlexQF m_Chi2
 
CombCandidatem_CombCand [NN]
 
int m_CurHit [NN]
 
int m_CurNode [NN]
 
const HitOnTrackm_HoTArr [NN]
 
HitOnTrack m_HoTArrs [NN][Config::nMaxTrkHits]
 
const HoTNodem_HoTNodeArr [NN]
 
const std::vector< bool > * m_iteration_hit_mask = nullptr
 
const IterationLayerConfigm_iteration_layer_config = nullptr
 
const IterationParamsm_iteration_params = nullptr
 
MPlexQI m_Label
 
MPlexQI m_LastHitCcIndex
 
HitOnTrack m_LastHoT [NN]
 
MPlexHS m_msErr
 
MPlexHV m_msPar
 
MPlexQI m_NFoundHits
 
MPlexQI m_NHits
 
MPlexQI m_NInsideMinusOneHits
 
MPlexQI m_NMissingHits
 
MPlexQI m_NOverlapHits
 
MPlexQI m_NTailMinusOneHits
 
const PropagationConfigm_prop_config = nullptr
 
MPlexQI m_SeedIdx
 
MPlexQI m_Stopped
 
TrackCandm_TrkCand [NN]
 
TrackBase::Status m_TrkStatus [NN]
 
MPlexHitIdx m_XHitArr
 
MPlexQI m_XHitSize
 
WSR_Result m_XWsrResult [NN]
 

Friends

class MkBuilder
 

Additional Inherited Members

- Protected Attributes inherited from mkfit::MkBase
MPlexQI m_Chg
 
MPlexLS m_Err [2]
 
MPlexLV m_Par [2]
 

Detailed Description

Definition at line 31 of file MkFinder.h.

Member Typedef Documentation

◆ MPlexHitIdx

Definition at line 37 of file MkFinder.h.

◆ MPlexQHoT

Definition at line 38 of file MkFinder.h.

Constructor & Destructor Documentation

◆ MkFinder()

mkfit::MkFinder::MkFinder ( )
inline

Definition at line 42 of file MkFinder.h.

42 {}

Member Function Documentation

◆ add_hit()

void mkfit::MkFinder::add_hit ( const int  mslot,
int  index,
int  layer 
)
inlineprivate

Definition at line 220 of file MkFinder.h.

References phase1PixelTopology::layer, L1DTConfigBti_cff::LH, m_HoTArrs, m_NFoundHits, m_NHits, m_NInsideMinusOneHits, m_NTailMinusOneHits, and mkfit::Config::nMaxTrkHits.

Referenced by addBestHit().

220  {
221  // Only used by BestHit.
222  // m_NInsideMinusOneHits and m_NTailMinusOneHits are maintained here but are
223  // not used and are not copied out (as Track does not have these members).
224 
225  int &n_tot_hits = m_NHits(mslot, 0, 0);
226  int &n_fnd_hits = m_NFoundHits(mslot, 0, 0);
227 
228  if (n_tot_hits < Config::nMaxTrkHits) {
229  m_HoTArrs[mslot][n_tot_hits++] = {index, layer};
230  if (index >= 0) {
231  ++n_fnd_hits;
232  m_NInsideMinusOneHits(mslot, 0, 0) += m_NTailMinusOneHits(mslot, 0, 0);
233  m_NTailMinusOneHits(mslot, 0, 0) = 0;
234  } else if (index == -1) {
235  ++m_NTailMinusOneHits(mslot, 0, 0);
236  }
237  } else {
238  // printf("WARNING MkFinder::add_hit hit-on-track limit reached for label=%d\n", label_);
239 
240  const int LH = Config::nMaxTrkHits - 1;
241 
242  if (index >= 0) {
243  if (m_HoTArrs[mslot][LH].index < 0)
244  ++n_fnd_hits;
245  m_HoTArrs[mslot][LH] = {index, layer};
246  } else if (index == -2) {
247  if (m_HoTArrs[mslot][LH].index >= 0)
248  --n_fnd_hits;
249  m_HoTArrs[mslot][LH] = {index, layer};
250  }
251  }
252  }
MPlexQI m_NFoundHits
Definition: MkFinder.h:266
HitOnTrack m_HoTArrs[NN][Config::nMaxTrkHits]
Definition: MkFinder.h:268
constexpr std::array< uint8_t, layerIndexSize > layer
LH
angular window limits for traco
MPlexQI m_NTailMinusOneHits
Definition: MkFinder.h:288
MPlexQI m_NHits
Definition: MkFinder.h:265
MPlexQI m_NInsideMinusOneHits
Definition: MkFinder.h:287
constexpr int nMaxTrkHits
Definition: Config.h:77

◆ addBestHit()

void mkfit::MkFinder::addBestHit ( const LayerOfHits layer_of_hits,
const int  N_proc,
const FindingFoos fnd_foos 
)

Definition at line 657 of file MkFinder.cc.

References funct::abs(), add_hit(), Matriplex::Matriplex< T, D1, D2, N >::At(), hltPixelTracks_cff::chi2, Matriplex::Matriplex< T, D1, D2, N >::copyIn(), Matriplex::MatriplexSym< T, D, N >::copyIn(), dprint, mkfit::PropagationConfig::finding_intra_layer_pflags, mkfit::PropagationConfig::finding_requires_propagation_to_hit_pos, getHitSelDynamicChi2Cut(), mkfit::LayerOfHits::hitArray(), mkfit::MkBase::iC, mkfit::MkBase::iP, mkfit::Hit::kHitEdgeIdx, mkfit::Hit::kHitMissIdx, mkfit::Hit::kHitStopIdx, mkfit::LayerOfHits::layer_id(), mkfit::MkBase::m_Chg, m_Chi2, mkfit::FindingFoos::m_compute_chi2_foo, mkfit::MkBase::m_Err, m_msErr, m_msPar, mkfit::MkBase::m_Par, m_prop_config, mkfit::FindingFoos::m_update_param_foo, m_XHitArr, m_XHitSize, m_XWsrResult, SiStripPI::max, reco_skim_cfg_mod::maxSize, MTVHistoProducerAlgoForTrackerBlock_cfi::minChi2, mkfit::NN, num_all_minus_one_hits(), mkfit::LayerOfHits::refHit(), Matriplex::MatriplexSym< T, D, N >::setDiagonal3x3(), mkfit::WSR_Edge, and mkfit::WSR_Outside.

657  {
658  // debug = true;
659 
660  MatriplexHitPacker mhp(layer_of_hits.hitArray());
661 
662  float minChi2[NN];
663  int bestHit[NN];
664  int maxSize = 0;
665 
666  // Determine maximum number of hits for tracks in the collection.
667  for (int it = 0; it < NN; ++it) {
668  if (it < N_proc) {
669  if (m_XHitSize[it] > 0) {
671  }
672  }
673 
674  bestHit[it] = -1;
676  }
677 
678  for (int hit_cnt = 0; hit_cnt < maxSize; ++hit_cnt) {
679  //fixme what if size is zero???
680 
681  mhp.reset();
682 
683 #pragma omp simd
684  for (int itrack = 0; itrack < N_proc; ++itrack) {
685  if (hit_cnt < m_XHitSize[itrack]) {
686  mhp.addInputAt(itrack, layer_of_hits.refHit(m_XHitArr.At(itrack, hit_cnt, 0)));
687  }
688  }
689 
690  mhp.pack(m_msErr, m_msPar);
691 
692  //now compute the chi2 of track state vs hit
693  MPlexQF outChi2;
694  MPlexLV tmpPropPar;
695  (*fnd_foos.m_compute_chi2_foo)(m_Err[iP],
696  m_Par[iP],
697  m_Chg,
698  m_msErr,
699  m_msPar,
700  outChi2,
701  tmpPropPar,
702  N_proc,
705 
706  //update best hit in case chi2<minChi2
707 #pragma omp simd
708  for (int itrack = 0; itrack < N_proc; ++itrack) {
709  if (hit_cnt < m_XHitSize[itrack]) {
710  const float chi2 = std::abs(outChi2[itrack]); //fixme negative chi2 sometimes...
711  dprint("chi2=" << chi2 << " minChi2[itrack]=" << minChi2[itrack]);
712  if (chi2 < minChi2[itrack]) {
713  minChi2[itrack] = chi2;
714  bestHit[itrack] = m_XHitArr.At(itrack, hit_cnt, 0);
715  }
716  }
717  }
718  } // end loop over hits
719 
720  //#pragma omp simd
721  for (int itrack = 0; itrack < N_proc; ++itrack) {
722  if (m_XWsrResult[itrack].m_wsr == WSR_Outside) {
723  // Why am I doing this?
724  m_msErr.setDiagonal3x3(itrack, 666);
725  m_msPar(itrack, 0, 0) = m_Par[iP](itrack, 0, 0);
726  m_msPar(itrack, 1, 0) = m_Par[iP](itrack, 1, 0);
727  m_msPar(itrack, 2, 0) = m_Par[iP](itrack, 2, 0);
728 
729  // XXXX If not in gap, should get back the old track params. But they are gone ...
730  // Would actually have to do it right after SelectHitIndices where updated params are still ok.
731  // Here they got screwed during hit matching.
732  // So, I'd store them there (into propagated params) and retrieve them here.
733  // Or we decide not to care ...
734 
735  continue;
736  }
737 
738  //fixme decide what to do in case no hit found
739  if (bestHit[itrack] >= 0) {
740  const Hit &hit = layer_of_hits.refHit(bestHit[itrack]);
741  const float chi2 = minChi2[itrack];
742 
743  dprint("ADD BEST HIT FOR TRACK #"
744  << itrack << std::endl
745  << "prop x=" << m_Par[iP].constAt(itrack, 0, 0) << " y=" << m_Par[iP].constAt(itrack, 1, 0) << std::endl
746  << "copy in hit #" << bestHit[itrack] << " x=" << hit.position()[0] << " y=" << hit.position()[1]);
747 
748  m_msErr.copyIn(itrack, hit.errArray());
749  m_msPar.copyIn(itrack, hit.posArray());
750  m_Chi2(itrack, 0, 0) += chi2;
751 
752  add_hit(itrack, bestHit[itrack], layer_of_hits.layer_id());
753  } else {
754  int fake_hit_idx = Hit::kHitMissIdx;
755 
756  if (m_XWsrResult[itrack].m_wsr == WSR_Edge) {
757  // YYYYYY Config::store_missed_layers
758  fake_hit_idx = Hit::kHitEdgeIdx;
759  } else if (num_all_minus_one_hits(itrack)) {
760  fake_hit_idx = Hit::kHitStopIdx;
761  }
762 
763  dprint("ADD FAKE HIT FOR TRACK #" << itrack << " withinBounds=" << (fake_hit_idx != Hit::kHitEdgeIdx)
764  << " r=" << std::hypot(m_Par[iP](itrack, 0, 0), m_Par[iP](itrack, 1, 0)));
765 
766  m_msErr.setDiagonal3x3(itrack, 666);
767  m_msPar(itrack, 0, 0) = m_Par[iP](itrack, 0, 0);
768  m_msPar(itrack, 1, 0) = m_Par[iP](itrack, 1, 0);
769  m_msPar(itrack, 2, 0) = m_Par[iP](itrack, 2, 0);
770  // Don't update chi2
771 
772  add_hit(itrack, fake_hit_idx, layer_of_hits.layer_id());
773  }
774  }
775 
776  // Update the track parameters with this hit. (Note that some calculations
777  // are already done when computing chi2. Not sure it's worth caching them?)
778 
779  dprint("update parameters");
780  (*fnd_foos.m_update_param_foo)(m_Err[iP],
781  m_Par[iP],
782  m_Chg,
783  m_msErr,
784  m_msPar,
785  m_Err[iC],
786  m_Par[iC],
787  N_proc,
790 
791  dprint("m_Par[iP](0,0,0)=" << m_Par[iP](0, 0, 0) << " m_Par[iC](0,0,0)=" << m_Par[iC](0, 0, 0));
792  }
MPlexQI m_Chg
Definition: MkBase.h:96
static constexpr int iC
Definition: MkBase.h:16
void setDiagonal3x3(idx_t n, T d)
Definition: MatriplexSym.h:201
static constexpr int iP
Definition: MkBase.h:17
void copyIn(idx_t n, const T *arr)
Definition: Matriplex.h:70
MPlexLV m_Par[2]
Definition: MkBase.h:95
void add_hit(const int mslot, int index, int layer)
Definition: MkFinder.h:220
Matriplex::Matriplex< float, LL, 1, NN > MPlexLV
Definition: Matrix.h:49
static constexpr int kHitStopIdx
Definition: Hit.h:194
MPlexLS m_Err[2]
Definition: MkBase.h:94
const PropagationConfig * m_prop_config
Definition: MkFinder.h:313
MatriplexErrParPackerSlurpIn< Hit, float > MatriplexHitPacker
int num_all_minus_one_hits(const int mslot) const
Definition: MkFinder.h:254
constexpr Matriplex::idx_t NN
Definition: Matrix.h:43
MPlexQI m_XHitSize
Definition: MkFinder.h:299
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MPlexHV m_msPar
Definition: MkFinder.h:304
bool finding_requires_propagation_to_hit_pos
Definition: Config.h:23
MPlexHS m_msErr
Definition: MkFinder.h:303
Matriplex::Matriplex< float, 1, 1, NN > MPlexQF
Definition: Matrix.h:65
MPlexHitIdx m_XHitArr
Definition: MkFinder.h:300
#define dprint(x)
Definition: Debug.h:90
MPlexQF m_Chi2
Definition: MkFinder.h:262
void copyIn(idx_t n, const T *arr)
Definition: MatriplexSym.h:87
PropagationFlags finding_intra_layer_pflags
Definition: Config.h:25
float getHitSelDynamicChi2Cut(const int itrk, const int ipar)
Definition: MkFinder.cc:205
static constexpr int kHitMissIdx
Definition: Hit.h:193
WSR_Result m_XWsrResult[NN]
Definition: MkFinder.h:298
static constexpr int kHitEdgeIdx
Definition: Hit.h:195
T & At(idx_t n, idx_t i, idx_t j)
Definition: Matriplex.h:54

◆ bestHitLastHoT()

HitOnTrack mkfit::MkFinder::bestHitLastHoT ( int  itrack) const
inline

Definition at line 93 of file MkFinder.h.

References m_HoTArrs, and m_NHits.

93 { return m_HoTArrs[itrack][m_NHits(itrack, 0, 0) - 1]; }
HitOnTrack m_HoTArrs[NN][Config::nMaxTrkHits]
Definition: MkFinder.h:268
MPlexQI m_NHits
Definition: MkFinder.h:265

◆ bkFitFitTracks()

void mkfit::MkFinder::bkFitFitTracks ( const EventOfHits eventofhits,
const SteeringParams st_par,
const int  N_proc,
bool  chiDebug = false 
)

Definition at line 1582 of file MkFinder.cc.

References Matriplex::Matriplex< T, D1, D2, N >::add(), Matriplex::Matriplex< T, D1, D2, N >::At(), mkfit::PropagationConfig::backward_fit_pflags, Matriplex::Matriplex< T, D1, D2, N >::copyIn(), Matriplex::MatriplexSym< T, D, N >::copyIn(), mps_fire::i, mkfit::MkBase::iC, createfilelist::int, mkfit::MkBase::iP, mkfit::LayerInfo::is_barrel(), mkfit::SteeringParams::iterator::is_valid(), mkfit::TrackBase::isFindable(), CommonMethods::isnan(), mkfit::SteeringParams::IT_BkwFit, mkfit::kalmanOperation(), mkfit::kalmanOperationEndcap(), mkfit::KFO_Calculate_Chi2, mkfit::KFO_Update_Params, dttmaxenums::L, mkfit::TrackBase::label(), phase1PixelTopology::layer, mkfit::MkBase::m_Chg, m_Chi2, m_CurNode, mkfit::MkBase::m_Err, m_HoTNodeArr, m_msErr, m_msPar, mkfit::MkBase::m_Par, mkfit::HoTNode::m_prev_idx, m_prop_config, m_TrkCand, mkfit::SteeringParams::make_iterator(), mkfit::Hit::mcHitID(), mkfit::MCHitInfo::mcTrackID(), dqmiodumpmetadata::n, mkfit::NN, mkfit::TrackBase::posEta(), mkfit::TrackBase::posPhi(), mkfit::TrackBase::prodType(), mkfit::MkBase::propagateTracksToHitR(), mkfit::MkBase::propagateTracksToHitZ(), mkfit::TrackBase::pT(), and Matriplex::Matriplex< T, D1, D2, N >::setVal().

Referenced by mkfit::MkBuilder::fit_cands().

1585  {
1586  // Prototyping final backward fit.
1587  // This works with track-finding indices, before remapping.
1588  //
1589  // Layers should be collected during track finding and list all layers that have actual hits.
1590  // Then we could avoid checking which layers actually do have hits.
1591 
1592  MPlexQF tmp_chi2;
1593  MPlexQI no_mat_effs;
1594  float tmp_err[6] = {666, 0, 666, 0, 0, 666};
1595  float tmp_pos[3];
1596 
1597  for (auto lp_iter = st_par.make_iterator(SteeringParams::IT_BkwFit); lp_iter.is_valid(); ++lp_iter) {
1598  const int layer = lp_iter.layer();
1599 
1600  const LayerOfHits &L = eventofhits[layer];
1601  const LayerInfo &LI = *L.layer_info();
1602 
1603  // XXXX
1604 #if defined(DEBUG_BACKWARD_FIT)
1605  const Hit *last_hit_ptr[NN];
1606 #endif
1607 
1608  no_mat_effs.setVal(0);
1609  int done_count = 0;
1610  int here_count = 0;
1611  for (int i = 0; i < N_proc; ++i) {
1612  while (m_CurNode[i] >= 0 && m_HoTNodeArr[i][m_CurNode[i]].m_hot.index < 0) {
1614  }
1615 
1616  if (m_CurNode[i] < 0)
1617  ++done_count;
1618 
1619  if (m_CurNode[i] >= 0 && m_HoTNodeArr[i][m_CurNode[i]].m_hot.layer == layer) {
1620  // Skip the overlap hits -- if they exist.
1621  // 1. Overlap hit gets placed *after* the original hit in TrackCand::exportTrack()
1622  // which is *before* in the reverse iteration that we are doing here.
1623  // 2. Seed-hit merging can result in more than two hits per layer.
1624  // while (m_CurHit[i] > 0 && m_HoTArr[ i ][ m_CurHit[i] - 1 ].layer == layer) --m_CurHit[i];
1625  while (m_HoTNodeArr[i][m_CurNode[i]].m_prev_idx >= 0 &&
1626  m_HoTNodeArr[i][m_HoTNodeArr[i][m_CurNode[i]].m_prev_idx].m_hot.layer == layer)
1628 
1629  const Hit &hit = L.refHit(m_HoTNodeArr[i][m_CurNode[i]].m_hot.index);
1630 
1631 #ifdef DEBUG_BACKWARD_FIT
1632  last_hit_ptr[i] = &hit;
1633 #endif
1634  m_msErr.copyIn(i, hit.errArray());
1635  m_msPar.copyIn(i, hit.posArray());
1636  ++here_count;
1637 
1639  } else {
1640 #ifdef DEBUG_BACKWARD_FIT
1641  last_hit_ptr[i] = nullptr;
1642 #endif
1643  no_mat_effs[i] = 1;
1644  tmp_pos[0] = m_Par[iC](i, 0, 0);
1645  tmp_pos[1] = m_Par[iC](i, 1, 0);
1646  tmp_pos[2] = m_Par[iC](i, 2, 0);
1647  m_msErr.copyIn(i, tmp_err);
1648  m_msPar.copyIn(i, tmp_pos);
1649  }
1650  }
1651 
1652  if (done_count == N_proc)
1653  break;
1654  if (here_count == 0)
1655  continue;
1656 
1657  // ZZZ Could add missing hits here, only if there are any actual matches.
1658 
1659  if (LI.is_barrel()) {
1661 
1663  m_Err[iP],
1664  m_Par[iP],
1665  m_msErr,
1666  m_msPar,
1667  m_Err[iC],
1668  m_Par[iC],
1669  tmp_chi2,
1670  N_proc);
1671  } else {
1673 
1675  m_Err[iP],
1676  m_Par[iP],
1677  m_msErr,
1678  m_msPar,
1679  m_Err[iC],
1680  m_Par[iC],
1681  tmp_chi2,
1682  N_proc);
1683  }
1684 
1685  //fixup invpt sign and charge
1686  for (int n = 0; n < N_proc; ++n) {
1687  if (m_Par[iC].At(n, 3, 0) < 0) {
1688  m_Chg.At(n, 0, 0) = -m_Chg.At(n, 0, 0);
1689  m_Par[iC].At(n, 3, 0) = -m_Par[iC].At(n, 3, 0);
1690  }
1691  }
1692 
1693  for (int i = 0; i < N_proc; ++i) {
1694 #if defined(DEBUG_BACKWARD_FIT)
1695  if (chiDebug && last_hit_ptr[i]) {
1696  TrackCand &bb = *m_TrkCand[i];
1697  int ti = iP;
1698  float chi = tmp_chi2.At(i, 0, 0);
1699  float chi_prnt = std::isfinite(chi) ? chi : -9;
1700 
1701 #if defined(MKFIT_STANDALONE)
1702  const MCHitInfo &mchi = m_event->simHitsInfo_[last_hit_ptr[i]->mcHitID()];
1703 
1704  printf(
1705  "BKF_OVERLAP %d %d %d %d %d %d %d "
1706  "%f %f %f %f %d %d %d %d "
1707  "%f %f %f %f %f\n",
1708  m_event->evtID(),
1709 #else
1710  printf(
1711  "BKF_OVERLAP %d %d %d %d %d %d "
1712  "%f %f %f %f %d %d %d "
1713  "%f %f %f %f %f\n",
1714 #endif
1715  bb.label(),
1716  (int)bb.prodType(),
1717  bb.isFindable(),
1718  layer,
1719  L.is_stereo(),
1720  L.is_barrel(),
1721  bb.pT(),
1722  bb.posEta(),
1723  bb.posPhi(),
1724  chi_prnt,
1725  std::isnan(chi),
1726  std::isfinite(chi),
1727  chi > 0,
1728 #if defined(MKFIT_STANDALONE)
1729  mchi.mcTrackID(),
1730 #endif
1731  e2s(m_Err[ti].At(i, 0, 0)),
1732  e2s(m_Err[ti].At(i, 1, 1)),
1733  e2s(m_Err[ti].At(i, 2, 2)), // sx_t sy_t sz_t -- track errors
1734  1e4f * std::hypot(m_msPar.At(i, 0, 0) - m_Par[ti].At(i, 0, 0),
1735  m_msPar.At(i, 1, 0) - m_Par[ti].At(i, 1, 0)), // d_xy
1736  1e4f * (m_msPar.At(i, 2, 0) - m_Par[ti].At(i, 2, 0)) // d_z
1737  );
1738  }
1739 #endif
1740  }
1741 
1742  // update chi2
1743  m_Chi2.add(tmp_chi2);
1744  }
1745  }
def isnan(num)
MPlexQI m_Chg
Definition: MkBase.h:96
static constexpr int iC
Definition: MkBase.h:16
static constexpr int iP
Definition: MkBase.h:17
void kalmanOperationEndcap(const int kfOp, const MPlexLS &psErr, const MPlexLV &psPar, const MPlexHS &msErr, const MPlexHV &msPar, MPlexLS &outErr, MPlexLV &outPar, MPlexQF &outChi2, const int N_proc)
void copyIn(idx_t n, const T *arr)
Definition: Matriplex.h:70
MPlexLV m_Par[2]
Definition: MkBase.h:95
PropagationFlags backward_fit_pflags
Definition: Config.h:26
constexpr std::array< uint8_t, layerIndexSize > layer
MPlexLS m_Err[2]
Definition: MkBase.h:94
void kalmanOperation(const int kfOp, const MPlexLS &psErr, const MPlexLV &psPar, const MPlexHS &msErr, const MPlexHV &msPar, MPlexLS &outErr, MPlexLV &outPar, MPlexQF &outChi2, const int N_proc)
void add(const Matriplex &v)
Definition: Matriplex.h:37
const PropagationConfig * m_prop_config
Definition: MkFinder.h:313
constexpr Matriplex::idx_t NN
Definition: Matrix.h:43
MPlexHV m_msPar
Definition: MkFinder.h:304
void propagateTracksToHitR(const MPlexHV &par, const int N_proc, const PropagationFlags pf, const MPlexQI *noMatEffPtr=nullptr)
Definition: MkBase.h:39
int m_CurNode[NN]
Definition: MkFinder.h:321
MPlexHS m_msErr
Definition: MkFinder.h:303
Matriplex::Matriplex< int, 1, 1, NN > MPlexQI
Definition: Matrix.h:66
TrackCand * m_TrkCand[NN]
Definition: MkFinder.h:295
Matriplex::Matriplex< float, 1, 1, NN > MPlexQF
Definition: Matrix.h:65
MPlexQF m_Chi2
Definition: MkFinder.h:262
void copyIn(idx_t n, const T *arr)
Definition: MatriplexSym.h:87
const HoTNode * m_HoTNodeArr[NN]
Definition: MkFinder.h:322
T & At(idx_t n, idx_t i, idx_t j)
Definition: Matriplex.h:54
void propagateTracksToHitZ(const MPlexHV &par, const int N_proc, const PropagationFlags pf, const MPlexQI *noMatEffPtr=nullptr)
Definition: MkBase.h:64

◆ bkFitFitTracksBH()

void mkfit::MkFinder::bkFitFitTracksBH ( const EventOfHits eventofhits,
const SteeringParams st_par,
const int  N_proc,
bool  chiDebug = false 
)

Definition at line 1445 of file MkFinder.cc.

References Matriplex::Matriplex< T, D1, D2, N >::add(), Matriplex::Matriplex< T, D1, D2, N >::At(), Matriplex::MatriplexSym< T, D, N >::At(), mkfit::PropagationConfig::backward_fit_pflags, Matriplex::Matriplex< T, D1, D2, N >::copyIn(), Matriplex::MatriplexSym< T, D, N >::copyIn(), submitPVResolutionJobs::count, mps_fire::i, mkfit::MkBase::iC, mkfit::MkBase::iP, mkfit::LayerInfo::is_barrel(), mkfit::kalmanOperation(), mkfit::kalmanOperationEndcap(), mkfit::KFO_Calculate_Chi2, mkfit::KFO_Update_Params, dttmaxenums::L, phase1PixelTopology::layer, mkfit::MkBase::m_Chg, m_Chi2, m_CurHit, mkfit::MkBase::m_Err, m_HoTArr, mkfit::SteeringParams::m_layer_plan, m_msErr, m_msPar, mkfit::MkBase::m_Par, m_prop_config, dqmiodumpmetadata::n, mkfit::MkBase::propagateTracksToHitR(), and mkfit::MkBase::propagateTracksToHitZ().

Referenced by mkfit::MkBuilder::fit_cands_BH().

1448  {
1449  // Prototyping final backward fit.
1450  // This works with track-finding indices, before remapping.
1451  //
1452  // Layers should be collected during track finding and list all layers that have actual hits.
1453  // Then we could avoid checking which layers actually do have hits.
1454 
1455  MPlexQF tmp_chi2;
1456  float tmp_err[6] = {666, 0, 666, 0, 0, 666};
1457  float tmp_pos[3];
1458 
1459  for (auto lp_iter = st_par.m_layer_plan.rbegin(); lp_iter != st_par.m_layer_plan.rend(); ++lp_iter) {
1460  const int layer = lp_iter->m_layer;
1461 
1462  const LayerOfHits &L = eventofhits[layer];
1463  const LayerInfo &LI = *L.layer_info();
1464 
1465  int count = 0;
1466  for (int i = 0; i < N_proc; ++i) {
1467  while (m_CurHit[i] >= 0 && m_HoTArr[i][m_CurHit[i]].index < 0)
1468  --m_CurHit[i];
1469 
1470  if (m_CurHit[i] >= 0 && m_HoTArr[i][m_CurHit[i]].layer == layer) {
1471  // Skip the overlap hits -- if they exist.
1472  // 1. Overlap hit gets placed *after* the original hit in TrackCand::exportTrack()
1473  // which is *before* in the reverse iteration that we are doing here.
1474  // 2. Seed-hit merging can result in more than two hits per layer.
1475  while (m_CurHit[i] > 0 && m_HoTArr[i][m_CurHit[i] - 1].layer == layer)
1476  --m_CurHit[i];
1477 
1478  const Hit &hit = L.refHit(m_HoTArr[i][m_CurHit[i]].index);
1479  m_msErr.copyIn(i, hit.errArray());
1480  m_msPar.copyIn(i, hit.posArray());
1481  ++count;
1482  --m_CurHit[i];
1483  } else {
1484  tmp_pos[0] = m_Par[iC](i, 0, 0);
1485  tmp_pos[1] = m_Par[iC](i, 1, 0);
1486  tmp_pos[2] = m_Par[iC](i, 2, 0);
1487  m_msErr.copyIn(i, tmp_err);
1488  m_msPar.copyIn(i, tmp_pos);
1489  }
1490  }
1491 
1492  if (count == 0)
1493  continue;
1494 
1495  // ZZZ Could add missing hits here, only if there are any actual matches.
1496 
1497  if (LI.is_barrel()) {
1499 
1501  m_Err[iP],
1502  m_Par[iP],
1503  m_msErr,
1504  m_msPar,
1505  m_Err[iC],
1506  m_Par[iC],
1507  tmp_chi2,
1508  N_proc);
1509  } else {
1511 
1513  m_Err[iP],
1514  m_Par[iP],
1515  m_msErr,
1516  m_msPar,
1517  m_Err[iC],
1518  m_Par[iC],
1519  tmp_chi2,
1520  N_proc);
1521  }
1522 
1523  //fixup invpt sign and charge
1524  for (int n = 0; n < N_proc; ++n) {
1525  if (m_Par[iC].At(n, 3, 0) < 0) {
1526  m_Chg.At(n, 0, 0) = -m_Chg.At(n, 0, 0);
1527  m_Par[iC].At(n, 3, 0) = -m_Par[iC].At(n, 3, 0);
1528  }
1529  }
1530 
1531 #ifdef DEBUG_BACKWARD_FIT_BH
1532  // Dump per hit chi2
1533  for (int i = 0; i < N_proc; ++i) {
1534  float r_h = std::hypot(m_msPar.At(i, 0, 0), m_msPar.At(i, 1, 0));
1535  float r_t = std::hypot(m_Par[iC].At(i, 0, 0), m_Par[iC].At(i, 1, 0));
1536 
1537  // if ((std::isnan(tmp_chi2[i]) || std::isnan(r_t)))
1538  // if ( ! std::isnan(tmp_chi2[i]) && tmp_chi2[i] > 0) // && tmp_chi2[i] > 30)
1539  if (chiDebug) {
1540  int ti = iP;
1541  printf(
1542  "CHIHIT %3d %10g %10g %10g %10g %10g %11.5g %11.5g %11.5g %10g %10g %10g %10g %11.5g %11.5g %11.5g %10g "
1543  "%10g %10g %10g %10g %11.5g %11.5g\n",
1544  layer,
1545  tmp_chi2[i],
1546  m_msPar.At(i, 0, 0),
1547  m_msPar.At(i, 1, 0),
1548  m_msPar.At(i, 2, 0),
1549  r_h, // x_h y_h z_h r_h -- hit pos
1550  e2s(m_msErr.At(i, 0, 0)),
1551  e2s(m_msErr.At(i, 1, 1)),
1552  e2s(m_msErr.At(i, 2, 2)), // ex_h ey_h ez_h -- hit errors
1553  m_Par[ti].At(i, 0, 0),
1554  m_Par[ti].At(i, 1, 0),
1555  m_Par[ti].At(i, 2, 0),
1556  r_t, // x_t y_t z_t r_t -- track pos
1557  e2s(m_Err[ti].At(i, 0, 0)),
1558  e2s(m_Err[ti].At(i, 1, 1)),
1559  e2s(m_Err[ti].At(i, 2, 2)), // ex_t ey_t ez_t -- track errors
1560  1.0f / m_Par[ti].At(i, 3, 0),
1561  m_Par[ti].At(i, 4, 0),
1562  m_Par[ti].At(i, 5, 0), // pt, phi, theta
1563  std::atan2(m_msPar.At(i, 1, 0), m_msPar.At(i, 0, 0)), // phi_h
1564  std::atan2(m_Par[ti].At(i, 1, 0), m_Par[ti].At(i, 0, 0)), // phi_t
1565  1e4f * std::hypot(m_msPar.At(i, 0, 0) - m_Par[ti].At(i, 0, 0),
1566  m_msPar.At(i, 1, 0) - m_Par[ti].At(i, 1, 0)), // d_xy
1567  1e4f * (m_msPar.At(i, 2, 0) - m_Par[ti].At(i, 2, 0)) // d_z
1568  // e2s((m_msErr.At(i,0,0) + m_msErr.At(i,1,1)) / (r_h * r_h)), // ephi_h
1569  // e2s((m_Err[ti].At(i,0,0) + m_Err[ti].At(i,1,1)) / (r_t * r_t)) // ephi_t
1570  );
1571  }
1572  }
1573 #endif
1574 
1575  // update chi2
1576  m_Chi2.add(tmp_chi2);
1577  }
1578  }
MPlexQI m_Chg
Definition: MkBase.h:96
static constexpr int iC
Definition: MkBase.h:16
const HitOnTrack * m_HoTArr[NN]
Definition: MkFinder.h:320
static constexpr int iP
Definition: MkBase.h:17
void kalmanOperationEndcap(const int kfOp, const MPlexLS &psErr, const MPlexLV &psPar, const MPlexHS &msErr, const MPlexHV &msPar, MPlexLS &outErr, MPlexLV &outPar, MPlexQF &outChi2, const int N_proc)
void copyIn(idx_t n, const T *arr)
Definition: Matriplex.h:70
MPlexLV m_Par[2]
Definition: MkBase.h:95
PropagationFlags backward_fit_pflags
Definition: Config.h:26
T & At(idx_t n, idx_t i, idx_t j)
Definition: MatriplexSym.h:71
constexpr std::array< uint8_t, layerIndexSize > layer
MPlexLS m_Err[2]
Definition: MkBase.h:94
void kalmanOperation(const int kfOp, const MPlexLS &psErr, const MPlexLV &psPar, const MPlexHS &msErr, const MPlexHV &msPar, MPlexLS &outErr, MPlexLV &outPar, MPlexQF &outChi2, const int N_proc)
void add(const Matriplex &v)
Definition: Matriplex.h:37
const PropagationConfig * m_prop_config
Definition: MkFinder.h:313
MPlexHV m_msPar
Definition: MkFinder.h:304
void propagateTracksToHitR(const MPlexHV &par, const int N_proc, const PropagationFlags pf, const MPlexQI *noMatEffPtr=nullptr)
Definition: MkBase.h:39
MPlexHS m_msErr
Definition: MkFinder.h:303
Matriplex::Matriplex< float, 1, 1, NN > MPlexQF
Definition: Matrix.h:65
int m_CurHit[NN]
Definition: MkFinder.h:319
MPlexQF m_Chi2
Definition: MkFinder.h:262
void copyIn(idx_t n, const T *arr)
Definition: MatriplexSym.h:87
T & At(idx_t n, idx_t i, idx_t j)
Definition: Matriplex.h:54
void propagateTracksToHitZ(const MPlexHV &par, const int N_proc, const PropagationFlags pf, const MPlexQI *noMatEffPtr=nullptr)
Definition: MkBase.h:64

◆ bkFitInputTracks() [1/2]

void mkfit::MkFinder::bkFitInputTracks ( TrackVec cands,
int  beg,
int  end 
)

Definition at line 1340 of file MkFinder.cc.

References mkfit::MatriplexErrParPackerSlurpIn< T, D >::addInput(), HLT_2022v11_cff::cands, mkfit::TrackBase::charge(), mps_fire::end, f, mkfit::Track::getHitsOnTrackArray(), mps_fire::i, mkfit::MkBase::iC, mkfit::MkBase::m_Chg, m_Chi2, m_CurHit, mkfit::MkBase::m_Err, m_HoTArr, mkfit::MkBase::m_Par, mkfit::Track::nTotalHits(), mkfit::MatriplexErrParPackerSlurpIn< T, D >::pack(), Matriplex::MatriplexSym< T, D, N >::scale(), and Matriplex::Matriplex< T, D1, D2, N >::setVal().

Referenced by mkfit::MkBuilder::fit_cands(), and mkfit::MkBuilder::fit_cands_BH().

1340  {
1341  // Uses HitOnTrack vector from Track directly + a local cursor array to current hit.
1342 
1343  MatriplexTrackPacker mtp(&cands[beg]);
1344 
1345  int itrack = 0;
1346 
1347  for (int i = beg; i < end; ++i, ++itrack) {
1348  const Track &trk = cands[i];
1349 
1350  m_Chg(itrack, 0, 0) = trk.charge();
1351  m_CurHit[itrack] = trk.nTotalHits() - 1;
1352  m_HoTArr[itrack] = trk.getHitsOnTrackArray();
1353 
1354  mtp.addInput(trk);
1355  }
1356 
1357  m_Chi2.setVal(0);
1358 
1359  mtp.pack(m_Err[iC], m_Par[iC]);
1360 
1361  m_Err[iC].scale(100.0f);
1362  }
MPlexQI m_Chg
Definition: MkBase.h:96
static constexpr int iC
Definition: MkBase.h:16
const HitOnTrack * m_HoTArr[NN]
Definition: MkFinder.h:320
MPlexLV m_Par[2]
Definition: MkBase.h:95
MPlexLS m_Err[2]
Definition: MkBase.h:94
MatriplexErrParPackerSlurpIn< TrackBase, float > MatriplexTrackPacker
double f[11][100]
int m_CurHit[NN]
Definition: MkFinder.h:319
MPlexQF m_Chi2
Definition: MkFinder.h:262
void setVal(T v)
Definition: Matriplex.h:31

◆ bkFitInputTracks() [2/2]

void mkfit::MkFinder::bkFitInputTracks ( EventOfCombCandidates eocss,
int  beg,
int  end 
)

Definition at line 1364 of file MkFinder.cc.

References mkfit::MatriplexErrParPackerSlurpIn< T, D >::addInput(), mkfit::TrackBase::charge(), mkfit::TrackCand::combCandidate(), mps_fire::end, f, mkfit::CombCandidate::hotsData(), mps_fire::i, mkfit::MkBase::iC, mkfit::TrackCand::lastCcIndex(), mkfit::MkBase::m_Chg, m_Chi2, m_CurNode, mkfit::MkBase::m_Err, m_HoTNodeArr, mkfit::MkBase::m_Par, m_TrkCand, mkfit::MatriplexErrParPackerSlurpIn< T, D >::pack(), Matriplex::MatriplexSym< T, D, N >::scale(), and Matriplex::Matriplex< T, D1, D2, N >::setVal().

1364  {
1365  // Could as well use HotArrays from tracks directly + a local cursor array to last hit.
1366 
1367  // XXXX - shall we assume only TrackCand-zero is needed and that we can freely
1368  // bork the HoTNode array?
1369 
1370  MatriplexTrackPacker mtp(&eocss[beg][0]);
1371 
1372  int itrack = 0;
1373 
1374  for (int i = beg; i < end; ++i, ++itrack) {
1375  const TrackCand &trk = eocss[i][0];
1376 
1377  m_Chg(itrack, 0, 0) = trk.charge();
1378  m_CurNode[itrack] = trk.lastCcIndex();
1379  m_HoTNodeArr[itrack] = trk.combCandidate()->hotsData();
1380 
1381  // XXXX Need TrackCand* to update num-hits. Unless I collect info elsewhere
1382  // and fix it in BkFitOutputTracks.
1383  m_TrkCand[itrack] = &eocss[i][0];
1384 
1385  mtp.addInput(trk);
1386  }
1387 
1388  m_Chi2.setVal(0);
1389 
1390  mtp.pack(m_Err[iC], m_Par[iC]);
1391 
1392  m_Err[iC].scale(100.0f);
1393  }
MPlexQI m_Chg
Definition: MkBase.h:96
static constexpr int iC
Definition: MkBase.h:16
MPlexLV m_Par[2]
Definition: MkBase.h:95
MPlexLS m_Err[2]
Definition: MkBase.h:94
MatriplexErrParPackerSlurpIn< TrackBase, float > MatriplexTrackPacker
double f[11][100]
int m_CurNode[NN]
Definition: MkFinder.h:321
TrackCand * m_TrkCand[NN]
Definition: MkFinder.h:295
MPlexQF m_Chi2
Definition: MkFinder.h:262
void setVal(T v)
Definition: Matriplex.h:31
const HoTNode * m_HoTNodeArr[NN]
Definition: MkFinder.h:322

◆ bkFitOutputTracks() [1/2]

void mkfit::MkFinder::bkFitOutputTracks ( TrackVec cands,
int  beg,
int  end,
bool  outputProp 
)

Definition at line 1397 of file MkFinder.cc.

References HLT_2022v11_cff::cands, mkfit::TrackBase::chi2(), Matriplex::Matriplex< T, D1, D2, N >::copyOut(), Matriplex::MatriplexSym< T, D, N >::copyOut(), mps_fire::end, mkfit::TrackBase::errors_nc(), mkfit::getScoreCand(), mps_fire::i, mkfit::MkBase::iC, mkfit::MkBase::iP, edm::isFinite(), m_Chi2, mkfit::MkBase::m_Err, mkfit::MkBase::m_Par, mkfit::TrackBase::parameters_nc(), mkfit::TrackBase::setChi2(), and mkfit::TrackBase::setScore().

Referenced by mkfit::MkBuilder::fit_cands(), and mkfit::MkBuilder::fit_cands_BH().

1397  {
1398  // Only copy out track params / errors / chi2, all the rest is ok.
1399 
1400  const int iO = outputProp ? iP : iC;
1401 
1402  int itrack = 0;
1403  for (int i = beg; i < end; ++i, ++itrack) {
1404  Track &trk = cands[i];
1405 
1406  m_Err[iO].copyOut(itrack, trk.errors_nc().Array());
1407  m_Par[iO].copyOut(itrack, trk.parameters_nc().Array());
1408 
1409  trk.setChi2(m_Chi2(itrack, 0, 0));
1410  if (isFinite(trk.chi2())) {
1411  trk.setScore(getScoreCand(trk));
1412  }
1413  }
1414  }
static constexpr int iC
Definition: MkBase.h:16
static constexpr int iP
Definition: MkBase.h:17
MPlexLV m_Par[2]
Definition: MkBase.h:95
constexpr bool isFinite(T x)
MPlexLS m_Err[2]
Definition: MkBase.h:94
float getScoreCand(const Track &cand1, bool penalizeTailMissHits=false, bool inFindCandidates=false)
Definition: Track.h:630
void copyOut(idx_t n, T *arr) const
Definition: MatriplexSym.h:195
MPlexQF m_Chi2
Definition: MkFinder.h:262
void copyOut(idx_t n, T *arr) const
Definition: Matriplex.h:180

◆ bkFitOutputTracks() [2/2]

void mkfit::MkFinder::bkFitOutputTracks ( EventOfCombCandidates eocss,
int  beg,
int  end,
bool  outputProp 
)

Definition at line 1416 of file MkFinder.cc.

References mkfit::TrackBase::chi2(), Matriplex::Matriplex< T, D1, D2, N >::copyOut(), Matriplex::MatriplexSym< T, D, N >::copyOut(), mps_fire::end, mkfit::TrackBase::errors_nc(), mkfit::getScoreCand(), mps_fire::i, mkfit::MkBase::iC, mkfit::MkBase::iP, edm::isFinite(), m_Chi2, mkfit::MkBase::m_Err, mkfit::MkBase::m_Par, mkfit::TrackBase::parameters_nc(), mkfit::TrackBase::setChi2(), and mkfit::TrackBase::setScore().

1416  {
1417  // Only copy out track params / errors / chi2, all the rest is ok.
1418 
1419  // XXXX - where will rejected hits get removed?
1420 
1421  const int iO = outputProp ? iP : iC;
1422 
1423  int itrack = 0;
1424  for (int i = beg; i < end; ++i, ++itrack) {
1425  TrackCand &trk = eocss[i][0];
1426 
1427  m_Err[iO].copyOut(itrack, trk.errors_nc().Array());
1428  m_Par[iO].copyOut(itrack, trk.parameters_nc().Array());
1429 
1430  trk.setChi2(m_Chi2(itrack, 0, 0));
1431  if (isFinite(trk.chi2())) {
1432  trk.setScore(getScoreCand(trk));
1433  }
1434  }
1435  }
static constexpr int iC
Definition: MkBase.h:16
static constexpr int iP
Definition: MkBase.h:17
MPlexLV m_Par[2]
Definition: MkBase.h:95
constexpr bool isFinite(T x)
MPlexLS m_Err[2]
Definition: MkBase.h:94
float getScoreCand(const Track &cand1, bool penalizeTailMissHits=false, bool inFindCandidates=false)
Definition: Track.h:630
void copyOut(idx_t n, T *arr) const
Definition: MatriplexSym.h:195
MPlexQF m_Chi2
Definition: MkFinder.h:262
void copyOut(idx_t n, T *arr) const
Definition: Matriplex.h:180

◆ bkFitPropTracksToPCA()

void mkfit::MkFinder::bkFitPropTracksToPCA ( const int  N_proc)

Definition at line 1749 of file MkFinder.cc.

References m_prop_config, mkfit::PropagationConfig::pca_prop_pflags, and mkfit::MkBase::propagateTracksToPCAZ().

Referenced by mkfit::MkBuilder::fit_cands(), and mkfit::MkBuilder::fit_cands_BH().

1749  {
1751  }
const PropagationConfig * m_prop_config
Definition: MkFinder.h:313
PropagationFlags pca_prop_pflags
Definition: Config.h:29
void propagateTracksToPCAZ(const int N_proc, const PropagationFlags pf)
Definition: MkBase.h:77

◆ copy_in() [1/2]

void mkfit::MkFinder::copy_in ( const Track trk,
const int  mslot,
const int  tslot 
)
inlineprivate

Definition at line 150 of file MkFinder.h.

References mkfit::Track::beginHitsOnTrack(), mkfit::TrackBase::charge(), mkfit::TrackBase::chi2(), filterCSVwithJSON::copy, Matriplex::Matriplex< T, D1, D2, N >::copyIn(), Matriplex::MatriplexSym< T, D, N >::copyIn(), mkfit::Track::endHitsOnTrack(), mkfit::TrackBase::errors(), mkfit::TrackBase::label(), mkfit::MkBase::m_Chg, m_Chi2, mkfit::MkBase::m_Err, m_HoTArrs, m_Label, m_NFoundHits, m_NHits, m_NInsideMinusOneHits, m_NTailMinusOneHits, mkfit::MkBase::m_Par, mkfit::Track::nFoundHits(), mkfit::Track::nInsideMinusOneHits(), mkfit::Track::nTailMinusOneHits(), mkfit::Track::nTotalHits(), and mkfit::TrackBase::parameters().

Referenced by inputTracksAndHitIdx().

150  {
151  m_Err[tslot].copyIn(mslot, trk.errors().Array());
152  m_Par[tslot].copyIn(mslot, trk.parameters().Array());
153 
154  m_Chg(mslot, 0, 0) = trk.charge();
155  m_Chi2(mslot, 0, 0) = trk.chi2();
156  m_Label(mslot, 0, 0) = trk.label();
157 
158  m_NHits(mslot, 0, 0) = trk.nTotalHits();
159  m_NFoundHits(mslot, 0, 0) = trk.nFoundHits();
160 
161  m_NInsideMinusOneHits(mslot, 0, 0) = trk.nInsideMinusOneHits();
162  m_NTailMinusOneHits(mslot, 0, 0) = trk.nTailMinusOneHits();
163 
164  std::copy(trk.beginHitsOnTrack(), trk.endHitsOnTrack(), m_HoTArrs[mslot]);
165  }
MPlexQI m_Chg
Definition: MkBase.h:96
MPlexQI m_NFoundHits
Definition: MkFinder.h:266
void copyIn(idx_t n, const T *arr)
Definition: Matriplex.h:70
HitOnTrack m_HoTArrs[NN][Config::nMaxTrkHits]
Definition: MkFinder.h:268
MPlexLV m_Par[2]
Definition: MkBase.h:95
MPlexLS m_Err[2]
Definition: MkBase.h:94
MPlexQI m_NTailMinusOneHits
Definition: MkFinder.h:288
MPlexQI m_NHits
Definition: MkFinder.h:265
MPlexQF m_Chi2
Definition: MkFinder.h:262
void copyIn(idx_t n, const T *arr)
Definition: MatriplexSym.h:87
MPlexQI m_NInsideMinusOneHits
Definition: MkFinder.h:287
MPlexQI m_Label
Definition: MkFinder.h:263

◆ copy_in() [2/2]

void mkfit::MkFinder::copy_in ( const TrackCand trk,
const int  mslot,
const int  tslot 
)
inlineprivate

Definition at line 179 of file MkFinder.h.

References mkfit::TrackBase::charge(), mkfit::TrackBase::chi2(), mkfit::TrackCand::combCandidate(), Matriplex::Matriplex< T, D1, D2, N >::copyIn(), Matriplex::MatriplexSym< T, D, N >::copyIn(), mkfit::TrackBase::errors(), mkfit::TrackCand::getLastHitOnTrack(), mkfit::TrackBase::getStatus(), mkfit::TrackBase::label(), mkfit::TrackCand::lastCcIndex(), mkfit::MkBase::m_Chg, m_Chi2, m_CombCand, mkfit::MkBase::m_Err, m_Label, m_LastHitCcIndex, m_LastHoT, m_NFoundHits, m_NInsideMinusOneHits, m_NMissingHits, m_NOverlapHits, m_NTailMinusOneHits, mkfit::MkBase::m_Par, m_TrkStatus, mkfit::TrackCand::nFoundHits(), mkfit::TrackCand::nInsideMinusOneHits(), mkfit::TrackCand::nMissingHits(), mkfit::TrackCand::nOverlapHits(), mkfit::TrackCand::nTailMinusOneHits(), and mkfit::TrackBase::parameters().

179  {
180  m_Err[tslot].copyIn(mslot, trk.errors().Array());
181  m_Par[tslot].copyIn(mslot, trk.parameters().Array());
182 
183  m_Chg(mslot, 0, 0) = trk.charge();
184  m_Chi2(mslot, 0, 0) = trk.chi2();
185  m_Label(mslot, 0, 0) = trk.label();
186 
187  m_LastHitCcIndex(mslot, 0, 0) = trk.lastCcIndex();
188  m_NFoundHits(mslot, 0, 0) = trk.nFoundHits();
189  m_NMissingHits(mslot, 0, 0) = trk.nMissingHits();
190  m_NOverlapHits(mslot, 0, 0) = trk.nOverlapHits();
191 
192  m_NInsideMinusOneHits(mslot, 0, 0) = trk.nInsideMinusOneHits();
193  m_NTailMinusOneHits(mslot, 0, 0) = trk.nTailMinusOneHits();
194 
195  m_LastHoT[mslot] = trk.getLastHitOnTrack();
196  m_CombCand[mslot] = trk.combCandidate();
197  m_TrkStatus[mslot] = trk.getStatus();
198  }
MPlexQI m_Chg
Definition: MkBase.h:96
MPlexQI m_NFoundHits
Definition: MkFinder.h:266
void copyIn(idx_t n, const T *arr)
Definition: Matriplex.h:70
MPlexLV m_Par[2]
Definition: MkBase.h:95
MPlexQI m_NMissingHits
Definition: MkFinder.h:285
MPlexLS m_Err[2]
Definition: MkBase.h:94
TrackBase::Status m_TrkStatus[NN]
Definition: MkFinder.h:290
MPlexQI m_NTailMinusOneHits
Definition: MkFinder.h:288
MPlexQI m_LastHitCcIndex
Definition: MkFinder.h:289
CombCandidate * m_CombCand[NN]
Definition: MkFinder.h:292
HitOnTrack m_LastHoT[NN]
Definition: MkFinder.h:291
MPlexQI m_NOverlapHits
Definition: MkFinder.h:286
MPlexQF m_Chi2
Definition: MkFinder.h:262
void copyIn(idx_t n, const T *arr)
Definition: MatriplexSym.h:87
MPlexQI m_NInsideMinusOneHits
Definition: MkFinder.h:287
MPlexQI m_Label
Definition: MkFinder.h:263

◆ copy_out() [1/2]

void mkfit::MkFinder::copy_out ( Track trk,
const int  mslot,
const int  tslot 
) const
inlineprivate

Definition at line 167 of file MkFinder.h.

References mkfit::Track::beginHitsOnTrack_nc(), filterCSVwithJSON::copy, Matriplex::Matriplex< T, D1, D2, N >::copyOut(), Matriplex::MatriplexSym< T, D, N >::copyOut(), mkfit::TrackBase::errors_nc(), mkfit::MkBase::m_Chg, m_Chi2, mkfit::MkBase::m_Err, m_HoTArrs, m_Label, m_NFoundHits, m_NHits, mkfit::MkBase::m_Par, mkfit::TrackBase::parameters_nc(), mkfit::Track::resizeHits(), mkfit::TrackBase::setCharge(), mkfit::TrackBase::setChi2(), and mkfit::TrackBase::setLabel().

Referenced by findCandidates(), outputNonStoppedTracksAndHitIdx(), outputTrackAndHitIdx(), and outputTracksAndHitIdx().

167  {
168  m_Err[tslot].copyOut(mslot, trk.errors_nc().Array());
169  m_Par[tslot].copyOut(mslot, trk.parameters_nc().Array());
170 
171  trk.setCharge(m_Chg(mslot, 0, 0));
172  trk.setChi2(m_Chi2(mslot, 0, 0));
173  trk.setLabel(m_Label(mslot, 0, 0));
174 
175  trk.resizeHits(m_NHits(mslot, 0, 0), m_NFoundHits(mslot, 0, 0));
176  std::copy(m_HoTArrs[mslot], &m_HoTArrs[mslot][m_NHits(mslot, 0, 0)], trk.beginHitsOnTrack_nc());
177  }
MPlexQI m_Chg
Definition: MkBase.h:96
MPlexQI m_NFoundHits
Definition: MkFinder.h:266
HitOnTrack m_HoTArrs[NN][Config::nMaxTrkHits]
Definition: MkFinder.h:268
MPlexLV m_Par[2]
Definition: MkBase.h:95
MPlexLS m_Err[2]
Definition: MkBase.h:94
void copyOut(idx_t n, T *arr) const
Definition: MatriplexSym.h:195
MPlexQI m_NHits
Definition: MkFinder.h:265
MPlexQF m_Chi2
Definition: MkFinder.h:262
void copyOut(idx_t n, T *arr) const
Definition: Matriplex.h:180
MPlexQI m_Label
Definition: MkFinder.h:263

◆ copy_out() [2/2]

void mkfit::MkFinder::copy_out ( TrackCand trk,
const int  mslot,
const int  tslot 
) const
inlineprivate

Definition at line 200 of file MkFinder.h.

References Matriplex::Matriplex< T, D1, D2, N >::copyOut(), Matriplex::MatriplexSym< T, D, N >::copyOut(), mkfit::TrackBase::errors_nc(), mkfit::MkBase::m_Chg, m_Chi2, m_CombCand, mkfit::MkBase::m_Err, m_Label, m_LastHitCcIndex, m_NFoundHits, m_NInsideMinusOneHits, m_NMissingHits, m_NOverlapHits, m_NTailMinusOneHits, mkfit::MkBase::m_Par, m_TrkStatus, mkfit::TrackBase::parameters_nc(), mkfit::TrackBase::setCharge(), mkfit::TrackBase::setChi2(), mkfit::TrackCand::setCombCandidate(), mkfit::TrackBase::setLabel(), mkfit::TrackCand::setLastCcIndex(), mkfit::TrackCand::setNFoundHits(), mkfit::TrackCand::setNInsideMinusOneHits(), mkfit::TrackCand::setNMissingHits(), mkfit::TrackCand::setNOverlapHits(), mkfit::TrackCand::setNTailMinusOneHits(), and mkfit::TrackBase::setStatus().

200  {
201  m_Err[tslot].copyOut(mslot, trk.errors_nc().Array());
202  m_Par[tslot].copyOut(mslot, trk.parameters_nc().Array());
203 
204  trk.setCharge(m_Chg(mslot, 0, 0));
205  trk.setChi2(m_Chi2(mslot, 0, 0));
206  trk.setLabel(m_Label(mslot, 0, 0));
207 
208  trk.setLastCcIndex(m_LastHitCcIndex(mslot, 0, 0));
209  trk.setNFoundHits(m_NFoundHits(mslot, 0, 0));
210  trk.setNMissingHits(m_NMissingHits(mslot, 0, 0));
211  trk.setNOverlapHits(m_NOverlapHits(mslot, 0, 0));
212 
213  trk.setNInsideMinusOneHits(m_NInsideMinusOneHits(mslot, 0, 0));
214  trk.setNTailMinusOneHits(m_NTailMinusOneHits(mslot, 0, 0));
215 
216  trk.setCombCandidate(m_CombCand[mslot]);
217  trk.setStatus(m_TrkStatus[mslot]);
218  }
MPlexQI m_Chg
Definition: MkBase.h:96
MPlexQI m_NFoundHits
Definition: MkFinder.h:266
MPlexLV m_Par[2]
Definition: MkBase.h:95
MPlexQI m_NMissingHits
Definition: MkFinder.h:285
MPlexLS m_Err[2]
Definition: MkBase.h:94
TrackBase::Status m_TrkStatus[NN]
Definition: MkFinder.h:290
MPlexQI m_NTailMinusOneHits
Definition: MkFinder.h:288
void copyOut(idx_t n, T *arr) const
Definition: MatriplexSym.h:195
MPlexQI m_LastHitCcIndex
Definition: MkFinder.h:289
CombCandidate * m_CombCand[NN]
Definition: MkFinder.h:292
MPlexQI m_NOverlapHits
Definition: MkFinder.h:286
MPlexQF m_Chi2
Definition: MkFinder.h:262
void copyOut(idx_t n, T *arr) const
Definition: Matriplex.h:180
MPlexQI m_NInsideMinusOneHits
Definition: MkFinder.h:287
MPlexQI m_Label
Definition: MkFinder.h:263

◆ copyOutParErr()

void mkfit::MkFinder::copyOutParErr ( std::vector< CombCandidate > &  seed_cand_vec,
int  N_proc,
bool  outputProp 
) const

Definition at line 1319 of file MkFinder.cc.

References Matriplex::Matriplex< T, D1, D2, N >::copyOut(), Matriplex::MatriplexSym< T, D, N >::copyOut(), dprint, mps_fire::i, mkfit::MkBase::iC, mkfit::MkBase::iP, m_CandIdx, mkfit::MkBase::m_Chg, mkfit::MkBase::m_Err, mkfit::MkBase::m_Par, and m_SeedIdx.

Referenced by mkfit::MkBuilder::find_tracks_in_layers().

1319  {
1320  const int iO = outputProp ? iP : iC;
1321 
1322  for (int i = 0; i < N_proc; ++i) {
1323  TrackCand &cand = seed_cand_vec[m_SeedIdx(i, 0, 0)][m_CandIdx(i, 0, 0)];
1324 
1325  // Set the track state to the updated parameters
1326  m_Err[iO].copyOut(i, cand.errors_nc().Array());
1327  m_Par[iO].copyOut(i, cand.parameters_nc().Array());
1328  cand.setCharge(m_Chg(i, 0, 0));
1329 
1330  dprint((outputProp ? "propagated" : "updated")
1331  << " track parameters x=" << cand.parameters()[0] << " y=" << cand.parameters()[1]
1332  << " z=" << cand.parameters()[2] << " pt=" << 1. / cand.parameters()[3] << " posEta=" << cand.posEta());
1333  }
1334  }
MPlexQI m_Chg
Definition: MkBase.h:96
static constexpr int iC
Definition: MkBase.h:16
static constexpr int iP
Definition: MkBase.h:17
MPlexLV m_Par[2]
Definition: MkBase.h:95
MPlexLS m_Err[2]
Definition: MkBase.h:94
void copyOut(idx_t n, T *arr) const
Definition: MatriplexSym.h:195
#define dprint(x)
Definition: Debug.h:90
MPlexQI m_CandIdx
Definition: MkFinder.h:277
MPlexQI m_SeedIdx
Definition: MkFinder.h:276
void copyOut(idx_t n, T *arr) const
Definition: Matriplex.h:180

◆ findCandidates()

void mkfit::MkFinder::findCandidates ( const LayerOfHits layer_of_hits,
std::vector< std::vector< TrackCand >> &  tmp_candidates,
const int  offset,
const int  N_proc,
const FindingFoos fnd_foos 
)

Definition at line 865 of file MkFinder.cc.

References funct::abs(), mkfit::TrackCand::addHitIdx(), Matriplex::Matriplex< T, D1, D2, N >::At(), hltPixelTracks_cff::chi2, mkfit::TrackCand::combCandidate(), Matriplex::Matriplex< T, D1, D2, N >::constAt(), copy_out(), mkfit::Hit::detIDinLayer(), dprint, dprintf, mkfit::PropagationConfig::finding_intra_layer_pflags, mkfit::PropagationConfig::finding_requires_propagation_to_hit_pos, getHitSelDynamicChi2Cut(), mkfit::getScoreCand(), mkfit::LayerOfHits::hitArray(), mps_fire::i, mkfit::MkBase::iC, mkfit::MkBase::iP, mkfit::LayerOfHits::is_barrel(), mkfit::LayerOfHits::is_pixel(), mkfit::isStripQCompatible(), mkfit::Hit::kHitEdgeIdx, mkfit::Hit::kHitInGapIdx, mkfit::Hit::kHitMaxClusterIdx, mkfit::Hit::kHitMissIdx, mkfit::Hit::kHitStopIdx, phase1PixelTopology::layer, mkfit::LayerOfHits::layer_id(), m_CandIdx, mkfit::MkBase::m_Chg, mkfit::FindingFoos::m_compute_chi2_foo, mkfit::MkBase::m_Err, m_HoTArrs, m_iteration_params, m_msErr, m_msPar, m_NFoundHits, m_NTailMinusOneHits, mkfit::MkBase::m_Par, m_prop_config, m_SeedIdx, mkfit::FindingFoos::m_update_param_foo, m_XHitArr, m_XHitSize, m_XWsrResult, SiStripPI::max, mkfit::IterationParams::maxClusterSize, mkfit::IterationParams::maxConsecHoles, NuclearSeed_cfi::maxHits, mkfit::IterationParams::maxHolesPerCand, reco_skim_cfg_mod::maxSize, mkfit::Hit::minChargePerCM(), mkfit::NN, num_all_minus_one_hits(), hltrates_dqm_sourceclient-live_cfg::offset, mkfit::TrackBase::parameters(), mkfit::passStripChargePCMfromTrack(), mkfit::LayerOfHits::refHit(), mkfit::TrackBase::setCharge(), mkfit::TrackCand::setOriginIndex(), mkfit::TrackBase::setScore(), mkfit::WSR_Edge, and mkfit::WSR_Outside.

869  {
870  // bool debug = true;
871 
872  MatriplexHitPacker mhp(layer_of_hits.hitArray());
873 
874  int maxSize = 0;
875 
876  // Determine maximum number of hits for tracks in the collection.
877  for (int it = 0; it < NN; ++it) {
878  if (it < N_proc) {
879  if (m_XHitSize[it] > 0) {
881  }
882  }
883  }
884 
885  dprintf("FindCandidates max hits to process=%d\n", maxSize);
886 
887  int nHitsAdded[NN]{};
888  bool isTooLargeCluster[NN]{false};
889 
890  for (int hit_cnt = 0; hit_cnt < maxSize; ++hit_cnt) {
891  mhp.reset();
892 
893  int charge_pcm[NN];
894 
895 #pragma omp simd
896  for (int itrack = 0; itrack < N_proc; ++itrack) {
897  if (hit_cnt < m_XHitSize[itrack]) {
898  const auto &hit = layer_of_hits.refHit(m_XHitArr.At(itrack, hit_cnt, 0));
899  mhp.addInputAt(itrack, hit);
900  charge_pcm[itrack] = hit.chargePerCM();
901  }
902  }
903 
904  mhp.pack(m_msErr, m_msPar);
905 
906  //now compute the chi2 of track state vs hit
907  MPlexQF outChi2;
908  MPlexLV propPar;
909  (*fnd_foos.m_compute_chi2_foo)(m_Err[iP],
910  m_Par[iP],
911  m_Chg,
912  m_msErr,
913  m_msPar,
914  outChi2,
915  propPar,
916  N_proc,
919 
920  // Now update the track parameters with this hit (note that some
921  // calculations are already done when computing chi2, to be optimized).
922  // 1. This is not needed for candidates the hit is not added to, but it's
923  // vectorized so doing it serially below should take the same time.
924  // 2. Still it's a waste of time in case the hit is not added to any of the
925  // candidates, so check beforehand that at least one cand needs update.
926  bool oneCandPassCut = false;
927  for (int itrack = 0; itrack < N_proc; ++itrack) {
928  float max_c2 = getHitSelDynamicChi2Cut(itrack, iP);
929 
930  if (hit_cnt < m_XHitSize[itrack]) {
931  const float chi2 = std::abs(outChi2[itrack]); //fixme negative chi2 sometimes...
932  dprint("chi2=" << chi2);
933  if (chi2 < max_c2) {
934  bool isCompatible = true;
935  if (!layer_of_hits.is_pixel()) {
936  //check module compatibility via long strip side = L/sqrt(12)
937  isCompatible =
938  isStripQCompatible(itrack, layer_of_hits.is_barrel(), m_Err[iP], propPar, m_msErr, m_msPar);
939 
940  //rescale strip charge to track parameters and reapply the cut
941  isCompatible &= passStripChargePCMfromTrack(
942  itrack, layer_of_hits.is_barrel(), charge_pcm[itrack], Hit::minChargePerCM(), propPar, m_msErr);
943  }
944  // Select only SiStrip hits with cluster size < maxClusterSize
945  if (!layer_of_hits.is_pixel()) {
946  if (layer_of_hits.refHit(m_XHitArr.At(itrack, hit_cnt, 0)).spanRows() >=
948  isTooLargeCluster[itrack] = true;
949  isCompatible = false;
950  }
951  }
952 
953  if (isCompatible) {
954  oneCandPassCut = true;
955  break;
956  }
957  }
958  }
959  }
960 
961  if (oneCandPassCut) {
962  MPlexQI tmpChg = m_Chg;
963  (*fnd_foos.m_update_param_foo)(m_Err[iP],
964  m_Par[iP],
965  tmpChg,
966  m_msErr,
967  m_msPar,
968  m_Err[iC],
969  m_Par[iC],
970  N_proc,
973 
974  dprint("update parameters" << std::endl
975  << "propagated track parameters x=" << m_Par[iP].constAt(0, 0, 0)
976  << " y=" << m_Par[iP].constAt(0, 1, 0) << std::endl
977  << " hit position x=" << m_msPar.constAt(0, 0, 0)
978  << " y=" << m_msPar.constAt(0, 1, 0) << std::endl
979  << " updated track parameters x=" << m_Par[iC].constAt(0, 0, 0)
980  << " y=" << m_Par[iC].constAt(0, 1, 0));
981 
982  //create candidate with hit in case chi2 < max_c2
983  //fixme: please vectorize me... (not sure it's possible in this case)
984  for (int itrack = 0; itrack < N_proc; ++itrack) {
985  float max_c2 = getHitSelDynamicChi2Cut(itrack, iP);
986 
987  if (hit_cnt < m_XHitSize[itrack]) {
988  const float chi2 = std::abs(outChi2[itrack]); //fixme negative chi2 sometimes...
989  dprint("chi2=" << chi2);
990  if (chi2 < max_c2) {
991  bool isCompatible = true;
992  if (!layer_of_hits.is_pixel()) {
993  //check module compatibility via long strip side = L/sqrt(12)
994  isCompatible =
995  isStripQCompatible(itrack, layer_of_hits.is_barrel(), m_Err[iP], propPar, m_msErr, m_msPar);
996 
997  //rescale strip charge to track parameters and reapply the cut
998  isCompatible &= passStripChargePCMfromTrack(
999  itrack, layer_of_hits.is_barrel(), charge_pcm[itrack], Hit::minChargePerCM(), propPar, m_msErr);
1000  }
1001  // Select only SiStrip hits with cluster size < maxClusterSize
1002  if (!layer_of_hits.is_pixel()) {
1003  if (layer_of_hits.refHit(m_XHitArr.At(itrack, hit_cnt, 0)).spanRows() >=
1005  isCompatible = false;
1006  }
1007 
1008  if (isCompatible) {
1009  bool hitExists = false;
1010  int maxHits = m_NFoundHits(itrack, 0, 0);
1011  if (layer_of_hits.is_pixel()) {
1012  for (int i = 0; i <= maxHits; ++i) {
1013  if (i > 2)
1014  break;
1015  if (m_HoTArrs[itrack][i].layer == layer_of_hits.layer_id()) {
1016  hitExists = true;
1017  break;
1018  }
1019  }
1020  }
1021  if (hitExists)
1022  continue;
1023 
1024  nHitsAdded[itrack]++;
1025  dprint("chi2 cut passed, creating new candidate");
1026  // Create a new candidate and fill the tmp_candidates output vector.
1027  // QQQ only instantiate if it will pass, be better than N_best
1028 
1029  const int hit_idx = m_XHitArr.At(itrack, hit_cnt, 0);
1030 
1031  TrackCand newcand;
1032  copy_out(newcand, itrack, iC);
1033  newcand.setCharge(tmpChg(itrack, 0, 0));
1034  newcand.addHitIdx(hit_idx, layer_of_hits.layer_id(), chi2);
1035  newcand.setScore(getScoreCand(newcand, true /*penalizeTailMissHits*/, true /*inFindCandidates*/));
1036  newcand.setOriginIndex(m_CandIdx(itrack, 0, 0));
1037 
1038  // To apply a fixed cut instead of dynamic cut for overlap: m_iteration_params->chi2CutOverlap
1039  if (chi2 < max_c2) {
1040  CombCandidate &ccand = *newcand.combCandidate();
1041  ccand[m_CandIdx(itrack, 0, 0)].considerHitForOverlap(
1042  hit_idx, layer_of_hits.refHit(hit_idx).detIDinLayer(), chi2);
1043  }
1044 
1045  dprint("updated track parameters x=" << newcand.parameters()[0] << " y=" << newcand.parameters()[1]
1046  << " z=" << newcand.parameters()[2]
1047  << " pt=" << 1. / newcand.parameters()[3]);
1048 
1049  tmp_candidates[m_SeedIdx(itrack, 0, 0) - offset].emplace_back(newcand);
1050  }
1051  }
1052  }
1053  }
1054  } //end if (oneCandPassCut)
1055 
1056  } //end loop over hits
1057 
1058  //now add invalid hit
1059  //fixme: please vectorize me...
1060  for (int itrack = 0; itrack < N_proc; ++itrack) {
1061  // Cands that miss the layer are stashed away in MkBuilder(), before propagation,
1062  // and then merged back afterwards.
1063  if (m_XWsrResult[itrack].m_wsr == WSR_Outside) {
1064  continue;
1065  }
1066 
1067  int fake_hit_idx = ((num_all_minus_one_hits(itrack) < m_iteration_params->maxHolesPerCand) &&
1070  : Hit::kHitStopIdx;
1071 
1072  if (m_XWsrResult[itrack].m_wsr == WSR_Edge) {
1073  // YYYYYY m_iteration_params->store_missed_layers
1074  fake_hit_idx = Hit::kHitEdgeIdx;
1075  }
1076  //now add fake hit for tracks that passsed through inactive modules
1077  else if (m_XWsrResult[itrack].m_in_gap == true && nHitsAdded[itrack] == 0) {
1078  fake_hit_idx = Hit::kHitInGapIdx;
1079  }
1080  //now add fake hit for cases where hit cluster size is larger than maxClusterSize
1081  else if (isTooLargeCluster[itrack] == true && nHitsAdded[itrack] == 0) {
1082  fake_hit_idx = Hit::kHitMaxClusterIdx;
1083  }
1084 
1085  dprint("ADD FAKE HIT FOR TRACK #" << itrack << " withinBounds=" << (fake_hit_idx != Hit::kHitEdgeIdx)
1086  << " r=" << std::hypot(m_Par[iP](itrack, 0, 0), m_Par[iP](itrack, 1, 0)));
1087 
1088  // QQQ as above, only create and add if score better
1089  TrackCand newcand;
1090  copy_out(newcand, itrack, iP);
1091  newcand.addHitIdx(fake_hit_idx, layer_of_hits.layer_id(), 0.);
1092  newcand.setScore(getScoreCand(newcand, true /*penalizeTailMissHits*/, true /*inFindCandidates*/));
1093  // Only relevant when we actually add a hit
1094  // newcand.setOriginIndex(m_CandIdx(itrack, 0, 0));
1095  tmp_candidates[m_SeedIdx(itrack, 0, 0) - offset].emplace_back(newcand);
1096  }
1097  }
MPlexQI m_Chg
Definition: MkBase.h:96
static constexpr int iC
Definition: MkBase.h:16
MPlexQI m_NFoundHits
Definition: MkFinder.h:266
static constexpr int iP
Definition: MkBase.h:17
void copy_out(Track &trk, const int mslot, const int tslot) const
Definition: MkFinder.h:167
HitOnTrack m_HoTArrs[NN][Config::nMaxTrkHits]
Definition: MkFinder.h:268
const T & constAt(idx_t n, idx_t i, idx_t j) const
Definition: Matriplex.h:52
MPlexLV m_Par[2]
Definition: MkBase.h:95
Matriplex::Matriplex< float, LL, 1, NN > MPlexLV
Definition: Matrix.h:49
static constexpr int kHitStopIdx
Definition: Hit.h:194
const IterationParams * m_iteration_params
Definition: MkFinder.h:314
constexpr std::array< uint8_t, layerIndexSize > layer
MPlexLS m_Err[2]
Definition: MkBase.h:94
static constexpr int kHitInGapIdx
Definition: Hit.h:197
bool isStripQCompatible(int itrack, bool isBarrel, const MPlexLS &pErr, const MPlexLV &pPar, const MPlexHS &msErr, const MPlexHV &msPar)
Definition: MkFinder.cc:797
const PropagationConfig * m_prop_config
Definition: MkFinder.h:313
MatriplexErrParPackerSlurpIn< Hit, float > MatriplexHitPacker
int num_all_minus_one_hits(const int mslot) const
Definition: MkFinder.h:254
float getScoreCand(const Track &cand1, bool penalizeTailMissHits=false, bool inFindCandidates=false)
Definition: Track.h:630
constexpr Matriplex::idx_t NN
Definition: Matrix.h:43
MPlexQI m_XHitSize
Definition: MkFinder.h:299
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MPlexHV m_msPar
Definition: MkFinder.h:304
MPlexQI m_NTailMinusOneHits
Definition: MkFinder.h:288
bool finding_requires_propagation_to_hit_pos
Definition: Config.h:23
MPlexHS m_msErr
Definition: MkFinder.h:303
Matriplex::Matriplex< int, 1, 1, NN > MPlexQI
Definition: Matrix.h:66
Matriplex::Matriplex< float, 1, 1, NN > MPlexQF
Definition: Matrix.h:65
bool passStripChargePCMfromTrack(int itrack, bool isBarrel, unsigned int pcm, unsigned int pcmMin, const MPlexLV &pPar, const MPlexHS &msErr)
Definition: MkFinder.cc:829
MPlexHitIdx m_XHitArr
Definition: MkFinder.h:300
#define dprint(x)
Definition: Debug.h:90
static constexpr int kHitMaxClusterIdx
Definition: Hit.h:196
MPlexQI m_CandIdx
Definition: MkFinder.h:277
MPlexQI m_SeedIdx
Definition: MkFinder.h:276
PropagationFlags finding_intra_layer_pflags
Definition: Config.h:25
float getHitSelDynamicChi2Cut(const int itrk, const int ipar)
Definition: MkFinder.cc:205
static constexpr int kHitMissIdx
Definition: Hit.h:193
WSR_Result m_XWsrResult[NN]
Definition: MkFinder.h:298
static constexpr int kHitEdgeIdx
Definition: Hit.h:195
T & At(idx_t n, idx_t i, idx_t j)
Definition: Matriplex.h:54
static unsigned int minChargePerCM()
Definition: Hit.h:233
#define dprintf(...)
Definition: Debug.h:93

◆ findCandidatesCloneEngine()

void mkfit::MkFinder::findCandidatesCloneEngine ( const LayerOfHits layer_of_hits,
CandCloner cloner,
const int  offset,
const int  N_proc,
const FindingFoos fnd_foos 
)

Definition at line 1103 of file MkFinder.cc.

References funct::abs(), mkfit::CandCloner::add_cand(), Matriplex::Matriplex< T, D1, D2, N >::At(), hltPixelTracks_cff::chi2, mkfit::IdxChi2List::chi2, mkfit::IdxChi2List::chi2_hit, mkfit::CandCloner::combCandWithOriginalIndex(), mkfit::Hit::detIDinLayer(), dprint, dprintf, f, mkfit::PropagationConfig::finding_intra_layer_pflags, mkfit::PropagationConfig::finding_requires_propagation_to_hit_pos, getHitSelDynamicChi2Cut(), mkfit::getScoreStruct(), mkfit::LayerOfHits::hitArray(), mkfit::IdxChi2List::hitIdx, mkfit::CombCandidate::hot(), mps_fire::i, mkfit::MkBase::iP, mkfit::LayerOfHits::is_barrel(), mkfit::LayerOfHits::is_pixel(), mkfit::isStripQCompatible(), mkfit::Hit::kHitEdgeIdx, mkfit::Hit::kHitInGapIdx, mkfit::Hit::kHitMaxClusterIdx, mkfit::Hit::kHitMissIdx, mkfit::Hit::kHitStopIdx, mkfit::HitOnTrack::layer, mkfit::LayerOfHits::layer_id(), m_CandIdx, mkfit::MkBase::m_Chg, m_Chi2, mkfit::FindingFoos::m_compute_chi2_foo, mkfit::MkBase::m_Err, m_iteration_params, m_Label, m_msErr, m_msPar, m_NFoundHits, m_NOverlapHits, m_NTailMinusOneHits, mkfit::MkBase::m_Par, m_prop_config, m_SeedIdx, m_XHitArr, m_XHitSize, m_XWsrResult, SiStripPI::max, mkfit::IterationParams::maxClusterSize, mkfit::IterationParams::maxConsecHoles, NuclearSeed_cfi::maxHits, mkfit::IterationParams::maxHolesPerCand, reco_skim_cfg_mod::maxSize, mkfit::Hit::minChargePerCM(), mkfit::IdxChi2List::module, mkfit::IdxChi2List::nhits, mkfit::IdxChi2List::nholes, mkfit::NN, mkfit::IdxChi2List::noverlaps, mkfit::IdxChi2List::ntailholes, num_all_minus_one_hits(), num_inside_minus_one_hits(), hltrates_dqm_sourceclient-live_cfg::offset, mkfit::passStripChargePCMfromTrack(), mkfit::IdxChi2List::pt, mkfit::LayerOfHits::refHit(), mkfit::IdxChi2List::score, mkfit::IdxChi2List::trkIdx, mkfit::WSR_Edge, and mkfit::WSR_Outside.

Referenced by mkfit::MkBuilder::find_tracks_in_layers().

1107  {
1108  // bool debug = true;
1109 
1110  MatriplexHitPacker mhp(layer_of_hits.hitArray());
1111 
1112  int maxSize = 0;
1113 
1114  // Determine maximum number of hits for tracks in the collection.
1115 #pragma omp simd
1116  for (int it = 0; it < NN; ++it) {
1117  if (it < N_proc) {
1118  if (m_XHitSize[it] > 0) {
1120  }
1121  }
1122  }
1123 
1124  dprintf("FindCandidatesCloneEngine max hits to process=%d\n", maxSize);
1125 
1126  int nHitsAdded[NN]{};
1127  bool isTooLargeCluster[NN]{false};
1128 
1129  for (int hit_cnt = 0; hit_cnt < maxSize; ++hit_cnt) {
1130  mhp.reset();
1131 
1132  int charge_pcm[NN];
1133 
1134 #pragma omp simd
1135  for (int itrack = 0; itrack < N_proc; ++itrack) {
1136  if (hit_cnt < m_XHitSize[itrack]) {
1137  const auto &hit = layer_of_hits.refHit(m_XHitArr.At(itrack, hit_cnt, 0));
1138  mhp.addInputAt(itrack, hit);
1139  charge_pcm[itrack] = hit.chargePerCM();
1140  }
1141  }
1142 
1143  mhp.pack(m_msErr, m_msPar);
1144 
1145  //now compute the chi2 of track state vs hit
1146  MPlexQF outChi2;
1147  MPlexLV propPar;
1148  (*fnd_foos.m_compute_chi2_foo)(m_Err[iP],
1149  m_Par[iP],
1150  m_Chg,
1151  m_msErr,
1152  m_msPar,
1153  outChi2,
1154  propPar,
1155  N_proc,
1158 
1159 #pragma omp simd // DOES NOT VECTORIZE AS IT IS NOW
1160  for (int itrack = 0; itrack < N_proc; ++itrack) {
1161  // make sure the hit was in the compatiblity window for the candidate
1162 
1163  float max_c2 = getHitSelDynamicChi2Cut(itrack, iP);
1164 
1165  if (hit_cnt < m_XHitSize[itrack]) {
1166  // XXX-NUM-ERR assert(chi2 >= 0);
1167  const float chi2 = std::abs(outChi2[itrack]); //fixme negative chi2 sometimes...
1168 
1169  dprint("chi2=" << chi2 << " for trkIdx=" << itrack << " hitIdx=" << m_XHitArr.At(itrack, hit_cnt, 0));
1170  if (chi2 < max_c2) {
1171  bool isCompatible = true;
1172  if (!layer_of_hits.is_pixel()) {
1173  //check module compatibility via long strip side = L/sqrt(12)
1174  isCompatible =
1175  isStripQCompatible(itrack, layer_of_hits.is_barrel(), m_Err[iP], propPar, m_msErr, m_msPar);
1176 
1177  //rescale strip charge to track parameters and reapply the cut
1178  isCompatible &= passStripChargePCMfromTrack(
1179  itrack, layer_of_hits.is_barrel(), charge_pcm[itrack], Hit::minChargePerCM(), propPar, m_msErr);
1180  }
1181 
1182  // Select only SiStrip hits with cluster size < maxClusterSize
1183  if (!layer_of_hits.is_pixel()) {
1184  if (layer_of_hits.refHit(m_XHitArr.At(itrack, hit_cnt, 0)).spanRows() >=
1186  isTooLargeCluster[itrack] = true;
1187  isCompatible = false;
1188  }
1189  }
1190 
1191  if (isCompatible) {
1192  CombCandidate &ccand = cloner.combCandWithOriginalIndex(m_SeedIdx(itrack, 0, 0));
1193  bool hitExists = false;
1194  int maxHits = m_NFoundHits(itrack, 0, 0);
1195  if (layer_of_hits.is_pixel()) {
1196  for (int i = 0; i <= maxHits; ++i) {
1197  if (i > 2)
1198  break;
1199  if (ccand.hot(i).layer == layer_of_hits.layer_id()) {
1200  hitExists = true;
1201  break;
1202  }
1203  }
1204  }
1205  if (hitExists)
1206  continue;
1207 
1208  nHitsAdded[itrack]++;
1209  const int hit_idx = m_XHitArr.At(itrack, hit_cnt, 0);
1210 
1211  // Register hit for overlap consideration, if chi2 cut is passed
1212  // To apply a fixed cut instead of dynamic cut for overlap: m_iteration_params->chi2CutOverlap
1213  if (chi2 < max_c2) {
1214  ccand[m_CandIdx(itrack, 0, 0)].considerHitForOverlap(
1215  hit_idx, layer_of_hits.refHit(hit_idx).detIDinLayer(), chi2);
1216  }
1217 
1218  IdxChi2List tmpList;
1219  tmpList.trkIdx = m_CandIdx(itrack, 0, 0);
1220  tmpList.hitIdx = hit_idx;
1221  tmpList.module = layer_of_hits.refHit(hit_idx).detIDinLayer();
1222  tmpList.nhits = m_NFoundHits(itrack, 0, 0) + 1;
1223  tmpList.ntailholes = 0;
1224  tmpList.noverlaps = m_NOverlapHits(itrack, 0, 0);
1225  tmpList.nholes = num_all_minus_one_hits(itrack);
1226  tmpList.pt = std::abs(1.0f / m_Par[iP].At(itrack, 3, 0));
1227  tmpList.chi2 = m_Chi2(itrack, 0, 0) + chi2;
1228  tmpList.chi2_hit = chi2;
1229  tmpList.score = getScoreStruct(tmpList);
1230  cloner.add_cand(m_SeedIdx(itrack, 0, 0) - offset, tmpList);
1231 
1232  dprint(" adding hit with hit_cnt=" << hit_cnt << " for trkIdx=" << tmpList.trkIdx
1233  << " orig Seed=" << m_Label(itrack, 0, 0));
1234  }
1235  }
1236  }
1237  }
1238 
1239  } //end loop over hits
1240 
1241  //now add invalid hit
1242  for (int itrack = 0; itrack < N_proc; ++itrack) {
1243  dprint("num_all_minus_one_hits(" << itrack << ")=" << num_all_minus_one_hits(itrack));
1244 
1245  // Cands that miss the layer are stashed away in MkBuilder(), before propagation,
1246  // and then merged back afterwards.
1247  if (m_XWsrResult[itrack].m_wsr == WSR_Outside) {
1248  continue;
1249  }
1250 
1251  // int fake_hit_idx = num_all_minus_one_hits(itrack) < m_iteration_params->maxHolesPerCand ? -1 : -2;
1252  int fake_hit_idx = ((num_all_minus_one_hits(itrack) < m_iteration_params->maxHolesPerCand) &&
1255  : Hit::kHitStopIdx;
1256 
1257  if (m_XWsrResult[itrack].m_wsr == WSR_Edge) {
1258  fake_hit_idx = Hit::kHitEdgeIdx;
1259  }
1260  //now add fake hit for tracks that passsed through inactive modules
1261  else if (m_XWsrResult[itrack].m_in_gap == true && nHitsAdded[itrack] == 0) {
1262  fake_hit_idx = Hit::kHitInGapIdx;
1263  }
1264  //now add fake hit for cases where hit cluster size is larger than maxClusterSize
1265  else if (isTooLargeCluster[itrack] == true && nHitsAdded[itrack] == 0) {
1266  fake_hit_idx = Hit::kHitMaxClusterIdx;
1267  }
1268 
1269  IdxChi2List tmpList;
1270  tmpList.trkIdx = m_CandIdx(itrack, 0, 0);
1271  tmpList.hitIdx = fake_hit_idx;
1272  tmpList.module = -1;
1273  tmpList.nhits = m_NFoundHits(itrack, 0, 0);
1274  tmpList.ntailholes = (fake_hit_idx == Hit::kHitMissIdx ? m_NTailMinusOneHits(itrack, 0, 0) + 1
1275  : m_NTailMinusOneHits(itrack, 0, 0));
1276  tmpList.noverlaps = m_NOverlapHits(itrack, 0, 0);
1277  tmpList.nholes = num_inside_minus_one_hits(itrack);
1278  tmpList.pt = std::abs(1.0f / m_Par[iP].At(itrack, 3, 0));
1279  tmpList.chi2 = m_Chi2(itrack, 0, 0);
1280  tmpList.chi2_hit = 0;
1281  tmpList.score = getScoreStruct(tmpList);
1282  cloner.add_cand(m_SeedIdx(itrack, 0, 0) - offset, tmpList);
1283  dprint("adding invalid hit " << fake_hit_idx);
1284  }
1285  }
MPlexQI m_Chg
Definition: MkBase.h:96
MPlexQI m_NFoundHits
Definition: MkFinder.h:266
static constexpr int iP
Definition: MkBase.h:17
MPlexLV m_Par[2]
Definition: MkBase.h:95
Matriplex::Matriplex< float, LL, 1, NN > MPlexLV
Definition: Matrix.h:49
static constexpr int kHitStopIdx
Definition: Hit.h:194
const IterationParams * m_iteration_params
Definition: MkFinder.h:314
MPlexLS m_Err[2]
Definition: MkBase.h:94
static constexpr int kHitInGapIdx
Definition: Hit.h:197
bool isStripQCompatible(int itrack, bool isBarrel, const MPlexLS &pErr, const MPlexLV &pPar, const MPlexHS &msErr, const MPlexHV &msPar)
Definition: MkFinder.cc:797
const PropagationConfig * m_prop_config
Definition: MkFinder.h:313
MatriplexErrParPackerSlurpIn< Hit, float > MatriplexHitPacker
int num_all_minus_one_hits(const int mslot) const
Definition: MkFinder.h:254
float getScoreStruct(const IdxChi2List &cand1)
Definition: Track.h:643
constexpr Matriplex::idx_t NN
Definition: Matrix.h:43
MPlexQI m_XHitSize
Definition: MkFinder.h:299
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MPlexHV m_msPar
Definition: MkFinder.h:304
MPlexQI m_NTailMinusOneHits
Definition: MkFinder.h:288
double f[11][100]
bool finding_requires_propagation_to_hit_pos
Definition: Config.h:23
MPlexHS m_msErr
Definition: MkFinder.h:303
Matriplex::Matriplex< float, 1, 1, NN > MPlexQF
Definition: Matrix.h:65
MPlexQI m_NOverlapHits
Definition: MkFinder.h:286
bool passStripChargePCMfromTrack(int itrack, bool isBarrel, unsigned int pcm, unsigned int pcmMin, const MPlexLV &pPar, const MPlexHS &msErr)
Definition: MkFinder.cc:829
MPlexHitIdx m_XHitArr
Definition: MkFinder.h:300
#define dprint(x)
Definition: Debug.h:90
MPlexQF m_Chi2
Definition: MkFinder.h:262
static constexpr int kHitMaxClusterIdx
Definition: Hit.h:196
MPlexQI m_CandIdx
Definition: MkFinder.h:277
MPlexQI m_SeedIdx
Definition: MkFinder.h:276
int num_inside_minus_one_hits(const int mslot) const
Definition: MkFinder.h:258
PropagationFlags finding_intra_layer_pflags
Definition: Config.h:25
float getHitSelDynamicChi2Cut(const int itrk, const int ipar)
Definition: MkFinder.cc:205
static constexpr int kHitMissIdx
Definition: Hit.h:193
WSR_Result m_XWsrResult[NN]
Definition: MkFinder.h:298
static constexpr int kHitEdgeIdx
Definition: Hit.h:195
T & At(idx_t n, idx_t i, idx_t j)
Definition: Matriplex.h:54
static unsigned int minChargePerCM()
Definition: Hit.h:233
#define dprintf(...)
Definition: Debug.h:93
MPlexQI m_Label
Definition: MkFinder.h:263

◆ getHitSelDynamicChi2Cut()

float mkfit::MkFinder::getHitSelDynamicChi2Cut ( const int  itrk,
const int  ipar 
)
inline

Definition at line 205 of file MkFinder.cc.

References funct::abs(), Matriplex::Matriplex< T, D1, D2, N >::At(), mkfit::IterationLayerConfig::c_c2_0, mkfit::IterationLayerConfig::c_c2_1, mkfit::IterationLayerConfig::c_c2_2, mkfit::IterationLayerConfig::c_c2_sf, mkfit::IterationParams::chi2Cut_min, m_iteration_layer_config, m_iteration_params, mkfit::MkBase::m_Par, mkfit::Const::PIOver2, and theta().

Referenced by addBestHit(), findCandidates(), and findCandidatesCloneEngine().

205  {
206  const IterationLayerConfig &ILC = *m_iteration_layer_config;
207 
208  const float minChi2Cut = m_iteration_params->chi2Cut_min;
209  const float invpt = m_Par[ipar].At(itrk, 3, 0);
210  const float theta = std::abs(m_Par[ipar].At(itrk, 5, 0) - Const::PIOver2);
211 
212  float max_invpt = invpt;
213  if (invpt > 10.0)
214  max_invpt = 10.0;
215 
216  float this_c2 = ILC.c_c2_0 * max_invpt + ILC.c_c2_1 * theta + ILC.c_c2_2;
217  // In case layer is missing (e.g., seeding layers, or too low stats for training), leave original limits
218  if ((ILC.c_c2_sf) * this_c2 > minChi2Cut)
219  return ILC.c_c2_sf * this_c2;
220  else
221  return minChi2Cut;
222  }
const IterationLayerConfig * m_iteration_layer_config
Definition: MkFinder.h:315
MPlexLV m_Par[2]
Definition: MkBase.h:95
constexpr float PIOver2
Definition: Config.h:44
const IterationParams * m_iteration_params
Definition: MkFinder.h:314
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Geom::Theta< T > theta() const
T & At(idx_t n, idx_t i, idx_t j)
Definition: Matriplex.h:54

◆ getHitSelDynamicWindows()

void mkfit::MkFinder::getHitSelDynamicWindows ( const float  invpt,
const float  theta,
float &  min_dq,
float &  max_dq,
float &  min_dphi,
float &  max_dphi 
)

Definition at line 168 of file MkFinder.cc.

References mkfit::IterationLayerConfig::c_dp_0, mkfit::IterationLayerConfig::c_dp_1, mkfit::IterationLayerConfig::c_dp_2, mkfit::IterationLayerConfig::c_dp_sf, mkfit::IterationLayerConfig::c_dq_0, mkfit::IterationLayerConfig::c_dq_1, mkfit::IterationLayerConfig::c_dq_2, mkfit::IterationLayerConfig::c_dq_sf, m_iteration_layer_config, and theta().

Referenced by selectHitIndices().

169  {
170  const IterationLayerConfig &ILC = *m_iteration_layer_config;
171 
172  float max_invpt = invpt;
173  if (invpt > 10.0)
174  max_invpt = 10.0; // => pT>0.1 GeV
175 
176  // dq hit selection window
177  float this_dq = (ILC.c_dq_0) * max_invpt + (ILC.c_dq_1) * theta + (ILC.c_dq_2);
178  // In case layer is missing (e.g., seeding layers, or too low stats for training), leave original limits
179  if ((ILC.c_dq_sf) * this_dq > 0.f) {
180  min_dq = (ILC.c_dq_sf) * this_dq;
181  max_dq = 2.0f * min_dq;
182  }
183 
184  // dphi hit selection window
185  float this_dphi = (ILC.c_dp_0) * max_invpt + (ILC.c_dp_1) * theta + (ILC.c_dp_2);
186  // In case layer is missing (e.g., seeding layers, or too low stats for training), leave original limits
187  if ((ILC.c_dp_sf) * this_dphi > min_dphi) {
188  min_dphi = (ILC.c_dp_sf) * this_dphi;
189  max_dphi = 2.0f * min_dphi;
190  }
191 
193  //float this_c2 = (ILC.c_c2_0)*invpt+(ILC.c_c2_1)*theta+(ILC.c_c2_2);
195  //if(this_c2>0.f){
196  // max_c2 = (ILC.c_c2_sf)*this_c2;
197  //}
198  }
const IterationLayerConfig * m_iteration_layer_config
Definition: MkFinder.h:315
Geom::Theta< T > theta() const

◆ inputTracksAndHitIdx() [1/4]

void mkfit::MkFinder::inputTracksAndHitIdx ( const std::vector< Track > &  tracks,
int  beg,
int  end,
bool  inputProp 
)

Definition at line 59 of file MkFinder.cc.

References copy_in(), mps_fire::end, mps_fire::i, mkfit::MkBase::iC, mkfit::MkBase::iP, and tracks.

Referenced by mkfit::MkBuilder::find_tracks_in_layers().

59  {
60  // Assign track parameters to initial state and copy hit values in.
61 
62  // This might not be true for the last chunk!
63  // assert(end - beg == NN);
64 
65  const int iI = inputProp ? iP : iC;
66 
67  for (int i = beg, imp = 0; i < end; ++i, ++imp) {
68  copy_in(tracks[i], imp, iI);
69  }
70  }
static constexpr int iC
Definition: MkBase.h:16
void copy_in(const Track &trk, const int mslot, const int tslot)
Definition: MkFinder.h:150
static constexpr int iP
Definition: MkBase.h:17
auto const & tracks
cannot be loose

◆ inputTracksAndHitIdx() [2/4]

void mkfit::MkFinder::inputTracksAndHitIdx ( const std::vector< Track > &  tracks,
const std::vector< int > &  idxs,
int  beg,
int  end,
bool  inputProp,
int  mp_offset 
)

Definition at line 72 of file MkFinder.cc.

References copy_in(), mps_fire::end, mps_fire::i, mkfit::MkBase::iC, mkfit::MkBase::iP, and tracks.

73  {
74  // Assign track parameters to initial state and copy hit values in.
75 
76  // This might not be true for the last chunk!
77  // assert(end - beg == NN);
78 
79  const int iI = inputProp ? iP : iC;
80 
81  for (int i = beg, imp = mp_offset; i < end; ++i, ++imp) {
82  copy_in(tracks[idxs[i]], imp, iI);
83  }
84  }
static constexpr int iC
Definition: MkBase.h:16
void copy_in(const Track &trk, const int mslot, const int tslot)
Definition: MkFinder.h:150
static constexpr int iP
Definition: MkBase.h:17
auto const & tracks
cannot be loose

◆ inputTracksAndHitIdx() [3/4]

void mkfit::MkFinder::inputTracksAndHitIdx ( const std::vector< CombCandidate > &  tracks,
const std::vector< std::pair< int, int >> &  idxs,
int  beg,
int  end,
bool  inputProp 
)

Definition at line 86 of file MkFinder.cc.

References copy_in(), mps_fire::end, mps_fire::i, mkfit::MkBase::iC, mkfit::MkBase::iP, m_CandIdx, m_SeedIdx, and tracks.

90  {
91  // Assign track parameters to initial state and copy hit values in.
92 
93  // This might not be true for the last chunk!
94  // assert(end - beg == NN);
95 
96  const int iI = inputProp ? iP : iC;
97 
98  for (int i = beg, imp = 0; i < end; ++i, ++imp) {
99  const TrackCand &trk = tracks[idxs[i].first][idxs[i].second];
100 
101  copy_in(trk, imp, iI);
102 
103 #ifdef DUMPHITWINDOW
104  m_SeedAlgo(imp, 0, 0) = tracks[idxs[i].first].seed_algo();
105  m_SeedLabel(imp, 0, 0) = tracks[idxs[i].first].seed_label();
106 #endif
107 
108  m_SeedIdx(imp, 0, 0) = idxs[i].first;
109  m_CandIdx(imp, 0, 0) = idxs[i].second;
110  }
111  }
static constexpr int iC
Definition: MkBase.h:16
void copy_in(const Track &trk, const int mslot, const int tslot)
Definition: MkFinder.h:150
static constexpr int iP
Definition: MkBase.h:17
auto const & tracks
cannot be loose
MPlexQI m_CandIdx
Definition: MkFinder.h:277
MPlexQI m_SeedIdx
Definition: MkFinder.h:276

◆ inputTracksAndHitIdx() [4/4]

void mkfit::MkFinder::inputTracksAndHitIdx ( const std::vector< CombCandidate > &  tracks,
const std::vector< std::pair< int, IdxChi2List >> &  idxs,
int  beg,
int  end,
bool  inputProp 
)

Definition at line 113 of file MkFinder.cc.

References copy_in(), mps_fire::end, mps_fire::i, mkfit::MkBase::iC, mkfit::MkBase::iP, m_CandIdx, m_SeedIdx, and tracks.

117  {
118  // Assign track parameters to initial state and copy hit values in.
119 
120  // This might not be true for the last chunk!
121  // assert(end - beg == NN);
122 
123  const int iI = inputProp ? iP : iC;
124 
125  for (int i = beg, imp = 0; i < end; ++i, ++imp) {
126  const TrackCand &trk = tracks[idxs[i].first][idxs[i].second.trkIdx];
127 
128  copy_in(trk, imp, iI);
129 
130 #ifdef DUMPHITWINDOW
131  m_SeedAlgo(imp, 0, 0) = tracks[idxs[i].first].seed_algo();
132  m_SeedLabel(imp, 0, 0) = tracks[idxs[i].first].seed_label();
133 #endif
134 
135  m_SeedIdx(imp, 0, 0) = idxs[i].first;
136  m_CandIdx(imp, 0, 0) = idxs[i].second.trkIdx;
137  }
138  }
static constexpr int iC
Definition: MkBase.h:16
void copy_in(const Track &trk, const int mslot, const int tslot)
Definition: MkFinder.h:150
static constexpr int iP
Definition: MkBase.h:17
auto const & tracks
cannot be loose
MPlexQI m_CandIdx
Definition: MkFinder.h:277
MPlexQI m_SeedIdx
Definition: MkFinder.h:276

◆ num_all_minus_one_hits()

int mkfit::MkFinder::num_all_minus_one_hits ( const int  mslot) const
inlineprivate

Definition at line 254 of file MkFinder.h.

References m_NInsideMinusOneHits, and m_NTailMinusOneHits.

Referenced by addBestHit(), findCandidates(), and findCandidatesCloneEngine().

254  {
255  return m_NInsideMinusOneHits(mslot, 0, 0) + m_NTailMinusOneHits(mslot, 0, 0);
256  }
MPlexQI m_NTailMinusOneHits
Definition: MkFinder.h:288
MPlexQI m_NInsideMinusOneHits
Definition: MkFinder.h:287

◆ num_inside_minus_one_hits()

int mkfit::MkFinder::num_inside_minus_one_hits ( const int  mslot) const
inlineprivate

Definition at line 258 of file MkFinder.h.

References m_NInsideMinusOneHits.

Referenced by findCandidatesCloneEngine().

258 { return m_NInsideMinusOneHits(mslot, 0, 0); }
MPlexQI m_NInsideMinusOneHits
Definition: MkFinder.h:287

◆ outputNonStoppedTracksAndHitIdx()

void mkfit::MkFinder::outputNonStoppedTracksAndHitIdx ( std::vector< Track > &  tracks,
const std::vector< int > &  idxs,
int  beg,
int  end,
bool  outputProp 
) const
inline

Definition at line 84 of file MkFinder.h.

References copy_out(), mps_fire::end, mps_fire::i, mkfit::MkBase::iC, mkfit::MkBase::iP, m_Stopped, and tracks.

85  {
86  const int iO = outputProp ? iP : iC;
87  for (int i = beg, imp = 0; i < end; ++i, ++imp) {
88  if (!m_Stopped[imp])
89  copy_out(tracks[idxs[i]], imp, iO);
90  }
91  }
static constexpr int iC
Definition: MkBase.h:16
static constexpr int iP
Definition: MkBase.h:17
void copy_out(Track &trk, const int mslot, const int tslot) const
Definition: MkFinder.h:167
auto const & tracks
cannot be loose
MPlexQI m_Stopped
Definition: MkFinder.h:279

◆ outputTrackAndHitIdx()

void mkfit::MkFinder::outputTrackAndHitIdx ( Track track,
int  itrack,
bool  outputProp 
) const
inline

Definition at line 79 of file MkFinder.h.

References copy_out(), mkfit::MkBase::iC, mkfit::MkBase::iP, and HLT_2022v11_cff::track.

79  {
80  const int iO = outputProp ? iP : iC;
81  copy_out(track, itrack, iO);
82  }
static constexpr int iC
Definition: MkBase.h:16
static constexpr int iP
Definition: MkBase.h:17
void copy_out(Track &trk, const int mslot, const int tslot) const
Definition: MkFinder.h:167

◆ outputTracksAndHitIdx() [1/2]

void mkfit::MkFinder::outputTracksAndHitIdx ( std::vector< Track > &  tracks,
int  beg,
int  end,
bool  outputProp 
) const

Definition at line 140 of file MkFinder.cc.

References copy_out(), mps_fire::end, mps_fire::i, mkfit::MkBase::iC, mkfit::MkBase::iP, and tracks.

140  {
141  // Copies requested track parameters into Track objects.
142  // The tracks vector should be resized to allow direct copying.
143 
144  const int iO = outputProp ? iP : iC;
145 
146  for (int i = beg, imp = 0; i < end; ++i, ++imp) {
147  copy_out(tracks[i], imp, iO);
148  }
149  }
static constexpr int iC
Definition: MkBase.h:16
static constexpr int iP
Definition: MkBase.h:17
void copy_out(Track &trk, const int mslot, const int tslot) const
Definition: MkFinder.h:167
auto const & tracks
cannot be loose

◆ outputTracksAndHitIdx() [2/2]

void mkfit::MkFinder::outputTracksAndHitIdx ( std::vector< Track > &  tracks,
const std::vector< int > &  idxs,
int  beg,
int  end,
bool  outputProp 
) const

Definition at line 151 of file MkFinder.cc.

References copy_out(), mps_fire::end, mps_fire::i, mkfit::MkBase::iC, mkfit::MkBase::iP, and tracks.

152  {
153  // Copies requested track parameters into Track objects.
154  // The tracks vector should be resized to allow direct copying.
155 
156  const int iO = outputProp ? iP : iC;
157 
158  for (int i = beg, imp = 0; i < end; ++i, ++imp) {
159  copy_out(tracks[idxs[i]], imp, iO);
160  }
161  }
static constexpr int iC
Definition: MkBase.h:16
static constexpr int iP
Definition: MkBase.h:17
void copy_out(Track &trk, const int mslot, const int tslot) const
Definition: MkFinder.h:167
auto const & tracks
cannot be loose

◆ release()

void mkfit::MkFinder::release ( )

Definition at line 48 of file MkFinder.cc.

References m_iteration_hit_mask, m_iteration_layer_config, m_iteration_params, and m_prop_config.

Referenced by mkfit::MkBuilder::fit_cands().

48  {
49  m_prop_config = nullptr;
50  m_iteration_params = nullptr;
51  m_iteration_layer_config = nullptr;
52  m_iteration_hit_mask = nullptr;
53  }
const IterationLayerConfig * m_iteration_layer_config
Definition: MkFinder.h:315
const IterationParams * m_iteration_params
Definition: MkFinder.h:314
const PropagationConfig * m_prop_config
Definition: MkFinder.h:313
const std::vector< bool > * m_iteration_hit_mask
Definition: MkFinder.h:316

◆ selectHitIndices()

void mkfit::MkFinder::selectHitIndices ( const LayerOfHits layer_of_hits,
const int  N_proc 
)

Definition at line 228 of file MkFinder.cc.

References funct::abs(), cms::cuda::assert(), Matriplex::Matriplex< T, D1, D2, N >::At(), Matriplex::MatriplexSym< T, D, N >::At(), mkfit::cdist(), mkfit::TrackBase::charge(), Matriplex::Matriplex< T, D1, D2, N >::constAt(), Matriplex::MatriplexSym< T, D, N >::constAt(), Matriplex::Matriplex< T, D1, D2, N >::copyIn(), Matriplex::MatriplexSym< T, D, N >::copyIn(), dprint, dprintf, flavorHistoryFilter_cfi::dr, PVValHelper::dz, mkfit::Hit::ephi(), mkfit::Hit::errArray(), mkfit::Hit::exx(), mkfit::Hit::eyy(), mkfit::Hit::ezz(), f, mkfit::PropagationConfig::finding_intra_layer_pflags, mkfit::PropagationConfig::finding_requires_propagation_to_hit_pos, first, mkfit::FindingFoos::get_finding_foos(), mkfit::getEta(), getHitSelDynamicWindows(), mkfit::getPhi(), mps_fire::i, createfilelist::int, mkfit::MkBase::iP, mkfit::TrackBase::isFindable(), CommonMethods::isnan(), dttmaxenums::L, mkfit::TrackBase::label(), m_CandIdx, mkfit::MkBase::m_Chg, m_Chi2, mkfit::FindingFoos::m_compute_chi2_foo, mkfit::MkBase::m_Err, mkfit::WSR_Result::m_in_gap, m_iteration_hit_mask, m_iteration_layer_config, m_Label, m_msErr, m_msPar, m_NFoundHits, mkfit::MkBase::m_Par, m_prop_config, m_SeedIdx, m_XHitArr, m_XHitSize, m_XWsrResult, SiStripPI::max, mkfit::IterationLayerConfig::max_dphi(), mkfit::IterationLayerConfig::max_dq(), mkfit::MCHitInfo::mcTrackID(), mkfit::IterationLayerConfig::min_dphi(), mkfit::IterationLayerConfig::min_dq(), mkfit::TrackBase::momEta(), mkfit::TrackBase::momPhi(), MPlexHitIdxMax, mkfit::NN, nSigmaPhi, HLT_2022v11_cff::nSigmaZ, mkfit::Track::nTotalHits(), pi, mkfit::Const::PIOver2, mkfit::Hit::posArray(), mkfit::TrackBase::posR(), mkfit::TrackBase::prodType(), mkfit::TrackBase::pT(), submitPVResolutionJobs::q, alignCSCRings::r, diffTwoXMLs::r2, mathSSE::sqrt(), funct::tan(), cuy::tex, theta(), mkfit::Config::usePhiQArrays, mkfit::WSR_Outside, x, mkfit::Hit::x(), mkfit::Hit::y(), mkfit::TrackBase::z(), and mkfit::Hit::z().

Referenced by mkfit::MkBuilder::find_tracks_in_layers().

228  {
229  // bool debug = true;
230  using bidx_t = LayerOfHits::bin_index_t;
231  using bcnt_t = LayerOfHits::bin_content_t;
232  const LayerOfHits &L = layer_of_hits;
233  const IterationLayerConfig &ILC = *m_iteration_layer_config;
234 
235  const int iI = iP;
236  const float nSigmaPhi = 3;
237  const float nSigmaZ = 3;
238  const float nSigmaR = 3;
239 
240  dprintf("LayerOfHits::SelectHitIndices %s layer=%d N_proc=%d\n",
241  L.is_barrel() ? "barrel" : "endcap",
242  L.layer_id(),
243  N_proc);
244 
245  float dqv[NN], dphiv[NN], qv[NN], phiv[NN];
246  bidx_t qb1v[NN], qb2v[NN], qbv[NN], pb1v[NN], pb2v[NN];
247 
248  const auto assignbins = [&](int itrack,
249  float q,
250  float dq,
251  float phi,
252  float dphi,
253  float min_dq,
254  float max_dq,
255  float min_dphi,
256  float max_dphi) {
257  dphi = std::clamp(std::abs(dphi), min_dphi, max_dphi);
258  dq = std::clamp(dq, min_dq, max_dq);
259  //
260  qv[itrack] = q;
261  phiv[itrack] = phi;
262  dphiv[itrack] = dphi;
263  dqv[itrack] = dq;
264  //
265  qbv[itrack] = L.qBinChecked(q);
266  qb1v[itrack] = L.qBinChecked(q - dq);
267  qb2v[itrack] = L.qBinChecked(q + dq) + 1;
268  pb1v[itrack] = L.phiBinChecked(phi - dphi);
269  pb2v[itrack] = L.phiMaskApply(L.phiBin(phi + dphi) + 1);
270  };
271 
272  const auto calcdphi2 = [&](int itrack, float dphidx, float dphidy) {
273  return dphidx * dphidx * m_Err[iI].constAt(itrack, 0, 0) + dphidy * dphidy * m_Err[iI].constAt(itrack, 1, 1) +
274  2 * dphidx * dphidy * m_Err[iI].constAt(itrack, 0, 1);
275  };
276 
277  const auto calcdphi = [&](float dphi2, float min_dphi) {
278  return std::max(nSigmaPhi * std::sqrt(std::abs(dphi2)), min_dphi);
279  };
280 
281  if (L.is_barrel()) {
282  // Pull out the part of the loop that vectorizes
283 #pragma omp simd
284  for (int itrack = 0; itrack < NN; ++itrack) {
285  m_XHitSize[itrack] = 0;
286 
287  float min_dq = ILC.min_dq();
288  float max_dq = ILC.max_dq();
289  float min_dphi = ILC.min_dphi();
290  float max_dphi = ILC.max_dphi();
291 
292  const float invpt = m_Par[iI].At(itrack, 3, 0);
293  const float theta = std::fabs(m_Par[iI].At(itrack, 5, 0) - Const::PIOver2);
294  getHitSelDynamicWindows(invpt, theta, min_dq, max_dq, min_dphi, max_dphi);
295 
296  const float x = m_Par[iI].constAt(itrack, 0, 0);
297  const float y = m_Par[iI].constAt(itrack, 1, 0);
298  const float r2 = x * x + y * y;
299  const float dphidx = -y / r2, dphidy = x / r2;
300  const float dphi2 = calcdphi2(itrack, dphidx, dphidy);
301 #ifdef HARD_CHECK
302  assert(dphi2 >= 0);
303 #endif
304 
305  const float phi = getPhi(x, y);
306  float dphi = calcdphi(dphi2, min_dphi);
307 
308  const float z = m_Par[iI].constAt(itrack, 2, 0);
309  const float dz = std::abs(nSigmaZ * std::sqrt(m_Err[iI].constAt(itrack, 2, 2)));
310  const float edgeCorr = std::abs(0.5f * (L.layer_info()->rout() - L.layer_info()->rin()) /
311  std::tan(m_Par[iI].constAt(itrack, 5, 0)));
312  // XXX-NUM-ERR above, m_Err(2,2) gets negative!
313 
314  m_XWsrResult[itrack] = L.is_within_z_sensitive_region(z, std::sqrt(dz * dz + edgeCorr * edgeCorr));
315  assignbins(itrack, z, dz, phi, dphi, min_dq, max_dq, min_dphi, max_dphi);
316  }
317  } else // endcap
318  {
319  // Pull out the part of the loop that vectorizes
320 #pragma omp simd
321  for (int itrack = 0; itrack < NN; ++itrack) {
322  m_XHitSize[itrack] = 0;
323 
324  float min_dq = ILC.min_dq();
325  float max_dq = ILC.max_dq();
326  float min_dphi = ILC.min_dphi();
327  float max_dphi = ILC.max_dphi();
328 
329  const float invpt = m_Par[iI].At(itrack, 3, 0);
330  const float theta = std::fabs(m_Par[iI].At(itrack, 5, 0) - Const::PIOver2);
331  getHitSelDynamicWindows(invpt, theta, min_dq, max_dq, min_dphi, max_dphi);
332 
333  const float x = m_Par[iI].constAt(itrack, 0, 0);
334  const float y = m_Par[iI].constAt(itrack, 1, 0);
335  const float r2 = x * x + y * y;
336  const float dphidx = -y / r2, dphidy = x / r2;
337  const float dphi2 = calcdphi2(itrack, dphidx, dphidy);
338 #ifdef HARD_CHECK
339  assert(dphi2 >= 0);
340 #endif
341 
342  const float phi = getPhi(x, y);
343  float dphi = calcdphi(dphi2, min_dphi);
344 
345  const float r = std::sqrt(r2);
346  const float dr = nSigmaR * std::sqrt(std::abs(x * x * m_Err[iI].constAt(itrack, 0, 0) +
347  y * y * m_Err[iI].constAt(itrack, 1, 1) +
348  2 * x * y * m_Err[iI].constAt(itrack, 0, 1)) /
349  r2);
350  const float edgeCorr = std::abs(0.5f * (L.layer_info()->zmax() - L.layer_info()->zmin()) *
351  std::tan(m_Par[iI].constAt(itrack, 5, 0)));
352 
353  m_XWsrResult[itrack] = L.is_within_r_sensitive_region(r, std::sqrt(dr * dr + edgeCorr * edgeCorr));
354  assignbins(itrack, r, dr, phi, dphi, min_dq, max_dq, min_dphi, max_dphi);
355  }
356  }
357 
358  // Vectorizing this makes it run slower!
359  //#pragma omp simd
360  for (int itrack = 0; itrack < N_proc; ++itrack) {
361  if (m_XWsrResult[itrack].m_wsr == WSR_Outside) {
362  m_XHitSize[itrack] = -1;
363  continue;
364  }
365 
366  const bidx_t qb = qbv[itrack];
367  const bidx_t qb1 = qb1v[itrack];
368  const bidx_t qb2 = qb2v[itrack];
369  const bidx_t pb1 = pb1v[itrack];
370  const bidx_t pb2 = pb2v[itrack];
371 
372  // Used only by usePhiQArrays
373  const float q = qv[itrack];
374  const float phi = phiv[itrack];
375  const float dphi = dphiv[itrack];
376  const float dq = dqv[itrack];
377  // clang-format off
378  dprintf(" %2d/%2d: %6.3f %6.3f %6.6f %7.5f %3u %3u %4u %4u\n",
379  L.layer_id(), itrack, q, phi, dq, dphi,
380  qb1, qb2, pb1, pb2);
381  // clang-format on
382  // MT: One could iterate in "spiral" order, to pick hits close to the center.
383  // http://stackoverflow.com/questions/398299/looping-in-a-spiral
384  // This would then work best with relatively small bin sizes.
385  // Or, set them up so I can always take 3x3 array around the intersection.
386 
387 #if defined(DUMPHITWINDOW) && defined(MKFIT_STANDALONE)
388  int thisseedmcid = -999999;
389  {
390  int seedlabel = m_SeedLabel(itrack, 0, 0);
391  TrackVec &seedtracks = m_event->seedTracks_;
392  int thisidx = -999999;
393  for (int i = 0; i < int(seedtracks.size()); ++i) {
394  auto &thisseed = seedtracks[i];
395  if (thisseed.label() == seedlabel) {
396  thisidx = i;
397  break;
398  }
399  }
400  if (thisidx > -999999) {
401  auto &seedtrack = m_event->seedTracks_[thisidx];
402  std::vector<int> thismcHitIDs;
403  seedtrack.mcHitIDsVec(m_event->layerHits_, m_event->simHitsInfo_, thismcHitIDs);
404  if (std::adjacent_find(thismcHitIDs.begin(), thismcHitIDs.end(), std::not_equal_to<>()) ==
405  thismcHitIDs.end()) {
406  thisseedmcid = thismcHitIDs.at(0);
407  }
408  }
409  }
410 #endif
411 
412  for (bidx_t qi = qb1; qi != qb2; ++qi) {
413  for (bidx_t pi = pb1; pi != pb2; pi = L.phiMaskApply(pi + 1)) {
414  // Limit to central Q-bin
415  if (qi == qb && L.isBinDead(pi, qi) == true) {
416  dprint("dead module for track in layer=" << L.layer_id() << " qb=" << qi << " pi=" << pi << " q=" << q
417  << " phi=" << phi);
418  m_XWsrResult[itrack].m_in_gap = true;
419  }
420 
421  // MT: The following line is the biggest hog (4% total run time).
422  // This comes from cache misses, I presume.
423  // It might make sense to make first loop to extract bin indices
424  // and issue prefetches at the same time.
425  // Then enter vectorized loop to actually collect the hits in proper order.
426 
427  //SK: ~20x1024 bin sizes give mostly 1 hit per bin. Commented out for 128 bins or less
428  // #pragma nounroll
429  auto pbi = L.phiQBinContent(pi, qi);
430  for (bcnt_t hi = pbi.begin(); hi < pbi.end(); ++hi) {
431  // MT: Access into m_hit_zs and m_hit_phis is 1% run-time each.
432 
433  unsigned int hi_orig = L.getOriginalHitIndex(hi);
434 
435  if (m_iteration_hit_mask && (*m_iteration_hit_mask)[hi_orig]) {
436  dprintf(
437  "Yay, denying masked hit on layer %u, hi %u, orig idx %u\n", L.layer_info()->layer_id(), hi, hi_orig);
438  continue;
439  }
440 
441  if (Config::usePhiQArrays) {
442  if (m_XHitSize[itrack] >= MPlexHitIdxMax)
443  break;
444 
445  const float ddq = std::abs(q - L.hit_q(hi));
446  const float ddphi = cdist(std::abs(phi - L.hit_phi(hi)));
447 
448 #if defined(DUMPHITWINDOW) && defined(MKFIT_STANDALONE)
449  {
450  const MCHitInfo &mchinfo = m_event->simHitsInfo_[L.refHit(hi).mcHitID()];
451  int mchid = mchinfo.mcTrackID();
452  int st_isfindable = 0;
453  int st_label = -999999;
454  int st_prodtype = 0;
455  int st_nhits = -1;
456  int st_charge = 0;
457  float st_r = -999.;
458  float st_z = -999.;
459  float st_pt = -999.;
460  float st_eta = -999.;
461  float st_phi = -999.;
462  if (mchid >= 0) {
463  Track simtrack = m_event->simTracks_[mchid];
464  st_isfindable = (int)simtrack.isFindable();
465  st_label = simtrack.label();
466  st_prodtype = (int)simtrack.prodType();
467  st_pt = simtrack.pT();
468  st_eta = simtrack.momEta();
469  st_phi = simtrack.momPhi();
470  st_nhits = simtrack.nTotalHits();
471  st_charge = simtrack.charge();
472  st_r = simtrack.posR();
473  st_z = simtrack.z();
474  }
475 
476  const Hit &thishit = L.refHit(hi);
477  m_msErr.copyIn(itrack, thishit.errArray());
478  m_msPar.copyIn(itrack, thishit.posArray());
479 
480  MPlexQF thisOutChi2;
481  MPlexLV tmpPropPar;
482  const FindingFoos &fnd_foos = FindingFoos::get_finding_foos(L.is_barrel());
483  (*fnd_foos.m_compute_chi2_foo)(m_Err[iI],
484  m_Par[iI],
485  m_Chg,
486  m_msErr,
487  m_msPar,
488  thisOutChi2,
489  tmpPropPar,
490  N_proc,
493 
494  float hx = thishit.x();
495  float hy = thishit.y();
496  float hz = thishit.z();
497  float hr = std::hypot(hx, hy);
498  float hphi = std::atan2(hy, hx);
499  float hex = std::sqrt(thishit.exx());
500  if (std::isnan(hex))
501  hex = -999.;
502  float hey = std::sqrt(thishit.eyy());
503  if (std::isnan(hey))
504  hey = -999.;
505  float hez = std::sqrt(thishit.ezz());
506  if (std::isnan(hez))
507  hez = -999.;
508  float her = std::sqrt(
509  (hx * hx * thishit.exx() + hy * hy * thishit.eyy() + 2.0f * hx * hy * m_msErr.At(itrack, 0, 1)) /
510  (hr * hr));
511  if (std::isnan(her))
512  her = -999.;
513  float hephi = std::sqrt(thishit.ephi());
514  if (std::isnan(hephi))
515  hephi = -999.;
516  float hchi2 = thisOutChi2[itrack];
517  if (std::isnan(hchi2))
518  hchi2 = -999.;
519  float tx = m_Par[iI].At(itrack, 0, 0);
520  float ty = m_Par[iI].At(itrack, 1, 0);
521  float tz = m_Par[iI].At(itrack, 2, 0);
522  float tr = std::hypot(tx, ty);
523  float tphi = std::atan2(ty, tx);
524  float tchi2 = m_Chi2(itrack, 0, 0);
525  if (std::isnan(tchi2))
526  tchi2 = -999.;
527  float tex = std::sqrt(m_Err[iI].At(itrack, 0, 0));
528  if (std::isnan(tex))
529  tex = -999.;
530  float tey = std::sqrt(m_Err[iI].At(itrack, 1, 1));
531  if (std::isnan(tey))
532  tey = -999.;
533  float tez = std::sqrt(m_Err[iI].At(itrack, 2, 2));
534  if (std::isnan(tez))
535  tez = -999.;
536  float ter = std::sqrt(
537  (tx * tx * tex * tex + ty * ty * tey * tey + 2.0f * tx * ty * m_Err[iI].At(itrack, 0, 1)) /
538  (tr * tr));
539  if (std::isnan(ter))
540  ter = -999.;
541  float tephi = std::sqrt(
542  (ty * ty * tex * tex + tx * tx * tey * tey - 2.0f * tx * ty * m_Err[iI].At(itrack, 0, 1)) /
543  (tr * tr * tr * tr));
544  if (std::isnan(tephi))
545  tephi = -999.;
546  float ht_dxy = std::hypot(hx - tx, hy - ty);
547  float ht_dz = hz - tz;
548  float ht_dphi = cdist(std::abs(hphi - tphi));
549 
550  static bool first = true;
551  if (first) {
552  printf(
553  "HITWINDOWSEL "
554  "evt_id/I:"
555  "lyr_id/I:lyr_isbrl/I:hit_idx/I:"
556  "trk_cnt/I:trk_idx/I:trk_label/I:"
557  "trk_pt/F:trk_eta/F:trk_mphi/F:trk_chi2/F:"
558  "nhits/I:"
559  "seed_idx/I:seed_label/I:seed_algo/I:seed_mcid/I:"
560  "hit_mcid/I:"
561  "st_isfindable/I:st_prodtype/I:st_label/I:"
562  "st_pt/F:st_eta/F:st_phi/F:"
563  "st_nhits/I:st_charge/I:st_r/F:st_z/F:"
564  "trk_q/F:hit_q/F:dq_trkhit/F:dq_cut/F:trk_phi/F:hit_phi/F:dphi_trkhit/F:dphi_cut/F:"
565  "t_x/F:t_y/F:t_r/F:t_phi/F:t_z/F:"
566  "t_ex/F:t_ey/F:t_er/F:t_ephi/F:t_ez/F:"
567  "h_x/F:h_y/F:h_r/F:h_phi/F:h_z/F:"
568  "h_ex/F:h_ey/F:h_er/F:h_ephi/F:h_ez/F:"
569  "ht_dxy/F:ht_dz/F:ht_dphi/F:"
570  "h_chi2/F"
571  "\n");
572  first = false;
573  }
574 
575  if (!(std::isnan(phi)) && !(std::isnan(getEta(m_Par[iI].At(itrack, 5, 0))))) {
576  //|| std::isnan(ter) || std::isnan(her) || std::isnan(m_Chi2(itrack, 0, 0)) || std::isnan(hchi2)))
577  // clang-format off
578  printf("HITWINDOWSEL "
579  "%d "
580  "%d %d %d "
581  "%d %d %d "
582  "%6.3f %6.3f %6.3f %6.3f "
583  "%d "
584  "%d %d %d %d "
585  "%d "
586  "%d %d %d "
587  "%6.3f %6.3f %6.3f "
588  "%d %d %6.3f %6.3f "
589  "%6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f "
590  "%6.3f %6.3f %6.3f %6.3f %6.3f "
591  "%6.6f %6.6f %6.6f %6.6f %6.6f "
592  "%6.3f %6.3f %6.3f %6.3f %6.3f "
593  "%6.6f %6.6f %6.6f %6.6f %6.6f "
594  "%6.3f %6.3f %6.3f "
595  "%6.3f"
596  "\n",
597  m_event->evtID(),
598  L.layer_id(), L.is_barrel(), L.getOriginalHitIndex(hi),
599  itrack, m_CandIdx(itrack, 0, 0), m_Label(itrack, 0, 0),
600  1.0f / m_Par[iI].At(itrack, 3, 0), getEta(m_Par[iI].At(itrack, 5, 0)), m_Par[iI].At(itrack, 4, 0), m_Chi2(itrack, 0, 0),
601  m_NFoundHits(itrack, 0, 0),
602  m_SeedIdx(itrack, 0, 0), m_SeedLabel(itrack, 0, 0), m_SeedAlgo(itrack, 0, 0), thisseedmcid,
603  mchid,
604  st_isfindable, st_prodtype, st_label,
605  st_pt, st_eta, st_phi,
606  st_nhits, st_charge, st_r, st_z,
607  q, L.hit_q(hi), ddq, dq, phi, L.hit_phi(hi), ddphi, dphi,
608  tx, ty, tr, tphi, tz,
609  tex, tey, ter, tephi, tez,
610  hx, hy, hr, hphi, hz,
611  hex, hey, her, hephi, hez,
612  ht_dxy, ht_dz, ht_dphi,
613  hchi2);
614  // clang-format on
615  }
616  }
617 #endif
618 
619  if (ddq >= dq)
620  continue;
621  if (ddphi >= dphi)
622  continue;
623  // clang-format off
624  dprintf(" SHI %3u %4u %5u %6.3f %6.3f %6.4f %7.5f %s\n",
625  qi, pi, hi, L.hit_q(hi), L.hit_phi(hi),
626  ddq, ddphi, (ddq < dq && ddphi < dphi) ? "PASS" : "FAIL");
627  // clang-format on
628 
629  // MT: Removing extra check gives full efficiency ...
630  // and means our error estimations are wrong!
631  // Avi says we should have *minimal* search windows per layer.
632  // Also ... if bins are sufficiently small, we do not need the extra
633  // checks, see above.
634  m_XHitArr.At(itrack, m_XHitSize[itrack]++, 0) = hi_orig;
635  } else {
636  // MT: The following check alone makes more sense with spiral traversal,
637  // we'd be taking in closest hits first.
638 
639  // Hmmh -- there used to be some more checks here.
640  // Or, at least, the phi binning was much smaller and no further checks were done.
641  assert(false && "this code has not been used in a while -- see comments in code");
642 
643  if (m_XHitSize[itrack] < MPlexHitIdxMax) {
644  m_XHitArr.At(itrack, m_XHitSize[itrack]++, 0) = hi_orig;
645  }
646  }
647  } //hi
648  } //pi
649  } //qi
650  } //itrack
651  }
def isnan(num)
MPlexQI m_Chg
Definition: MkBase.h:96
static constexpr int MPlexHitIdxMax
Definition: MkFinder.h:35
double z
global z - AlignmentGeometry::z0, mm
Definition: HitCollection.h:27
MPlexQI m_NFoundHits
Definition: MkFinder.h:266
const IterationLayerConfig * m_iteration_layer_config
Definition: MkFinder.h:315
static constexpr int iP
Definition: MkBase.h:17
void copyIn(idx_t n, const T *arr)
Definition: Matriplex.h:70
const T & constAt(idx_t n, idx_t i, idx_t j) const
Definition: Matriplex.h:52
MPlexLV m_Par[2]
Definition: MkBase.h:95
T & At(idx_t n, idx_t i, idx_t j)
Definition: MatriplexSym.h:71
constexpr float PIOver2
Definition: Config.h:44
Matriplex::Matriplex< float, LL, 1, NN > MPlexLV
Definition: Matrix.h:49
float getEta(float r, float z)
Definition: Hit.h:38
assert(be >=bs)
MPlexLS m_Err[2]
Definition: MkBase.h:94
const Double_t pi
constexpr bool usePhiQArrays
Definition: Config.h:104
const PropagationConfig * m_prop_config
Definition: MkFinder.h:313
const T & constAt(idx_t n, idx_t i, idx_t j) const
Definition: MatriplexSym.h:69
Definition: EPCuts.h:4
tex
Definition: cuy.py:773
T sqrt(T t)
Definition: SSEVec.h:19
constexpr Matriplex::idx_t NN
Definition: Matrix.h:43
unsigned int bin_content_t
Definition: HitStructures.h:27
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
MPlexQI m_XHitSize
Definition: MkFinder.h:299
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MPlexHV m_msPar
Definition: MkFinder.h:304
double f[11][100]
bool finding_requires_propagation_to_hit_pos
Definition: Config.h:23
constexpr float nSigmaPhi
float cdist(float a)
Definition: Config.h:67
MPlexHS m_msErr
Definition: MkFinder.h:303
std::vector< Track > TrackVec
Matriplex::Matriplex< float, 1, 1, NN > MPlexQF
Definition: Matrix.h:65
static const FindingFoos & get_finding_foos(bool is_barrel)
Definition: FindingFoos.cc:18
float getPhi(float x, float y)
Definition: Hit.h:34
MPlexHitIdx m_XHitArr
Definition: MkFinder.h:300
#define dprint(x)
Definition: Debug.h:90
MPlexQF m_Chi2
Definition: MkFinder.h:262
void copyIn(idx_t n, const T *arr)
Definition: MatriplexSym.h:87
MPlexQI m_CandIdx
Definition: MkFinder.h:277
MPlexQI m_SeedIdx
Definition: MkFinder.h:276
const std::vector< bool > * m_iteration_hit_mask
Definition: MkFinder.h:316
PropagationFlags finding_intra_layer_pflags
Definition: Config.h:25
unsigned short bin_index_t
Definition: HitStructures.h:26
WSR_Result m_XWsrResult[NN]
Definition: MkFinder.h:298
void getHitSelDynamicWindows(const float invpt, const float theta, float &min_dq, float &max_dq, float &min_dphi, float &max_dphi)
Definition: MkFinder.cc:168
Geom::Theta< T > theta() const
T & At(idx_t n, idx_t i, idx_t j)
Definition: Matriplex.h:54
#define dprintf(...)
Definition: Debug.h:93
MPlexQI m_Label
Definition: MkFinder.h:263

◆ setup()

void mkfit::MkFinder::setup ( const PropagationConfig pc,
const IterationParams ip,
const IterationLayerConfig ilc,
const std::vector< bool > *  ihm 
)

Definition at line 36 of file MkFinder.cc.

References m_iteration_hit_mask, m_iteration_layer_config, m_iteration_params, and m_prop_config.

Referenced by mkfit::MkBuilder::find_tracks_in_layers().

39  {
40  m_prop_config = &pc;
41  m_iteration_params = &ip;
44  }
const IterationLayerConfig * m_iteration_layer_config
Definition: MkFinder.h:315
const IterationParams * m_iteration_params
Definition: MkFinder.h:314
const PropagationConfig * m_prop_config
Definition: MkFinder.h:313
const std::vector< bool > * m_iteration_hit_mask
Definition: MkFinder.h:316

◆ setup_bkfit()

void mkfit::MkFinder::setup_bkfit ( const PropagationConfig pc)

Definition at line 46 of file MkFinder.cc.

References m_prop_config.

Referenced by mkfit::MkBuilder::fit_cands().

46 { m_prop_config = &pc; }
const PropagationConfig * m_prop_config
Definition: MkFinder.h:313

◆ updateWithLastHit()

void mkfit::MkFinder::updateWithLastHit ( const LayerOfHits layer_of_hits,
int  N_proc,
const FindingFoos fnd_foos 
)

Definition at line 1291 of file MkFinder.cc.

References Matriplex::Matriplex< T, D1, D2, N >::copyIn(), Matriplex::MatriplexSym< T, D, N >::copyIn(), mkfit::PropagationConfig::finding_inter_layer_pflags, mkfit::PropagationConfig::finding_requires_propagation_to_hit_pos, mps_fire::i, mkfit::MkBase::iC, mkfit::HitOnTrack::index, mkfit::MkBase::iP, mkfit::MkBase::m_Chg, mkfit::MkBase::m_Err, m_LastHoT, m_msErr, m_msPar, mkfit::MkBase::m_Par, m_prop_config, mkfit::FindingFoos::m_update_param_foo, and mkfit::LayerOfHits::refHit().

Referenced by mkfit::MkBuilder::find_tracks_in_layers().

1291  {
1292  for (int i = 0; i < N_proc; ++i) {
1293  const HitOnTrack &hot = m_LastHoT[i];
1294 
1295  const Hit &hit = layer_of_hits.refHit(hot.index);
1296 
1297  m_msErr.copyIn(i, hit.errArray());
1298  m_msPar.copyIn(i, hit.posArray());
1299  }
1300 
1301  // See comment in MkBuilder::find_tracks_in_layer() about intra / inter flags used here
1302  // for propagation to the hit.
1303  (*fnd_foos.m_update_param_foo)(m_Err[iP],
1304  m_Par[iP],
1305  m_Chg,
1306  m_msErr,
1307  m_msPar,
1308  m_Err[iC],
1309  m_Par[iC],
1310  N_proc,
1313  }
MPlexQI m_Chg
Definition: MkBase.h:96
static constexpr int iC
Definition: MkBase.h:16
static constexpr int iP
Definition: MkBase.h:17
void copyIn(idx_t n, const T *arr)
Definition: Matriplex.h:70
MPlexLV m_Par[2]
Definition: MkBase.h:95
MPlexLS m_Err[2]
Definition: MkBase.h:94
PropagationFlags finding_inter_layer_pflags
Definition: Config.h:24
const PropagationConfig * m_prop_config
Definition: MkFinder.h:313
MPlexHV m_msPar
Definition: MkFinder.h:304
bool finding_requires_propagation_to_hit_pos
Definition: Config.h:23
MPlexHS m_msErr
Definition: MkFinder.h:303
HitOnTrack m_LastHoT[NN]
Definition: MkFinder.h:291
void copyIn(idx_t n, const T *arr)
Definition: MatriplexSym.h:87

Friends And Related Function Documentation

◆ MkBuilder

friend class MkBuilder
friend

Definition at line 32 of file MkFinder.h.

Member Data Documentation

◆ m_CandIdx

MPlexQI mkfit::MkFinder::m_CandIdx
private

◆ m_Chi2

MPlexQF mkfit::MkFinder::m_Chi2
private

◆ m_CombCand

CombCandidate* mkfit::MkFinder::m_CombCand[NN]
private

Definition at line 292 of file MkFinder.h.

Referenced by copy_in(), and copy_out().

◆ m_CurHit

int mkfit::MkFinder::m_CurHit[NN]
private

Definition at line 319 of file MkFinder.h.

Referenced by bkFitFitTracksBH(), and bkFitInputTracks().

◆ m_CurNode

int mkfit::MkFinder::m_CurNode[NN]
private

Definition at line 321 of file MkFinder.h.

Referenced by bkFitFitTracks(), and bkFitInputTracks().

◆ m_HoTArr

const HitOnTrack* mkfit::MkFinder::m_HoTArr[NN]
private

Definition at line 320 of file MkFinder.h.

Referenced by bkFitFitTracksBH(), and bkFitInputTracks().

◆ m_HoTArrs

HitOnTrack mkfit::MkFinder::m_HoTArrs[NN][Config::nMaxTrkHits]
private

Definition at line 268 of file MkFinder.h.

Referenced by add_hit(), bestHitLastHoT(), copy_in(), copy_out(), and findCandidates().

◆ m_HoTNodeArr

const HoTNode* mkfit::MkFinder::m_HoTNodeArr[NN]
private

Definition at line 322 of file MkFinder.h.

Referenced by bkFitFitTracks(), and bkFitInputTracks().

◆ m_iteration_hit_mask

const std::vector<bool>* mkfit::MkFinder::m_iteration_hit_mask = nullptr
private

Definition at line 316 of file MkFinder.h.

Referenced by release(), selectHitIndices(), and setup().

◆ m_iteration_layer_config

const IterationLayerConfig* mkfit::MkFinder::m_iteration_layer_config = nullptr
private

◆ m_iteration_params

const IterationParams* mkfit::MkFinder::m_iteration_params = nullptr
private

◆ m_Label

MPlexQI mkfit::MkFinder::m_Label
private

◆ m_LastHitCcIndex

MPlexQI mkfit::MkFinder::m_LastHitCcIndex
private

Definition at line 289 of file MkFinder.h.

Referenced by copy_in(), and copy_out().

◆ m_LastHoT

HitOnTrack mkfit::MkFinder::m_LastHoT[NN]
private

Definition at line 291 of file MkFinder.h.

Referenced by copy_in(), and updateWithLastHit().

◆ m_msErr

MPlexHS mkfit::MkFinder::m_msErr
private

◆ m_msPar

MPlexHV mkfit::MkFinder::m_msPar
private

◆ m_NFoundHits

MPlexQI mkfit::MkFinder::m_NFoundHits
private

◆ m_NHits

MPlexQI mkfit::MkFinder::m_NHits
private

Definition at line 265 of file MkFinder.h.

Referenced by add_hit(), bestHitLastHoT(), copy_in(), and copy_out().

◆ m_NInsideMinusOneHits

MPlexQI mkfit::MkFinder::m_NInsideMinusOneHits
private

◆ m_NMissingHits

MPlexQI mkfit::MkFinder::m_NMissingHits
private

Definition at line 285 of file MkFinder.h.

Referenced by copy_in(), and copy_out().

◆ m_NOverlapHits

MPlexQI mkfit::MkFinder::m_NOverlapHits
private

Definition at line 286 of file MkFinder.h.

Referenced by copy_in(), copy_out(), and findCandidatesCloneEngine().

◆ m_NTailMinusOneHits

MPlexQI mkfit::MkFinder::m_NTailMinusOneHits
private

◆ m_prop_config

const PropagationConfig* mkfit::MkFinder::m_prop_config = nullptr
private

◆ m_SeedIdx

MPlexQI mkfit::MkFinder::m_SeedIdx
private

◆ m_Stopped

MPlexQI mkfit::MkFinder::m_Stopped
private

Definition at line 279 of file MkFinder.h.

Referenced by outputNonStoppedTracksAndHitIdx().

◆ m_TrkCand

TrackCand* mkfit::MkFinder::m_TrkCand[NN]
private

Definition at line 295 of file MkFinder.h.

Referenced by bkFitFitTracks(), and bkFitInputTracks().

◆ m_TrkStatus

TrackBase::Status mkfit::MkFinder::m_TrkStatus[NN]
private

Definition at line 290 of file MkFinder.h.

Referenced by copy_in(), and copy_out().

◆ m_XHitArr

MPlexHitIdx mkfit::MkFinder::m_XHitArr
private

◆ m_XHitSize

MPlexQI mkfit::MkFinder::m_XHitSize
private

◆ m_XWsrResult

WSR_Result mkfit::MkFinder::m_XWsrResult[NN]
private

◆ MPlexHitIdxMax

constexpr int mkfit::MkFinder::MPlexHitIdxMax = 16
static

Definition at line 35 of file MkFinder.h.

Referenced by selectHitIndices().