CMS 3D CMS Logo

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

#include <CandCloner.h>

Public Member Functions

void add_cand (int idx, const IdxChi2List &cand_info)
 
void begin_eta_bin (EventOfCombCandidates *e_o_ccs, std::vector< std::pair< int, int >> *update_list, std::vector< std::vector< TrackCand >> *extra_cands, int start_seed, int n_seeds)
 
void begin_iteration ()
 
void begin_layer (int lay)
 
 CandCloner ()
 
CombCandidatecombCandWithOriginalIndex (int idx)
 
void doWork (int idx)
 
void end_eta_bin ()
 
void end_iteration ()
 
void end_layer ()
 
int num_cands (int idx)
 
void processSeedRange (int is_beg, int is_end)
 
void release ()
 
void setup (const IterationParams &ip)
 

Static Public Attributes

static const int s_max_seed_range = 8
 

Private Attributes

std::vector< std::vector
< IdxChi2List > > 
m_hits_to_add
 
int m_idx_max
 
int m_idx_max_prev
 
int m_layer
 
int m_n_seeds
 
int m_start_seed
 
EventOfCombCandidatesmp_event_of_comb_candidates
 
std::vector< std::vector
< TrackCand > > * 
mp_extra_cands
 
const IterationParamsmp_iteration_params = nullptr
 
std::vector< std::pair< int,
int > > * 
mp_kalman_update_list
 
std::vector< std::vector
< TrackCand > > 
t_cands_for_next_lay
 

Detailed Description

Definition at line 16 of file CandCloner.h.

Constructor & Destructor Documentation

mkfit::CandCloner::CandCloner ( )
inline

Definition at line 21 of file CandCloner.h.

References s_max_seed_range, and t_cands_for_next_lay.

static const int s_max_seed_range
Definition: CandCloner.h:19
std::vector< std::vector< TrackCand > > t_cands_for_next_lay
Definition: CandCloner.h:71

Member Function Documentation

void mkfit::CandCloner::add_cand ( int  idx,
const IdxChi2List cand_info 
)
inline

Definition at line 34 of file CandCloner.h.

References m_hits_to_add, m_idx_max, and SiStripPI::max.

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

34  {
35  m_hits_to_add[idx].push_back(cand_info);
36 
38  }
std::vector< std::vector< IdxChi2List > > m_hits_to_add
Definition: CandCloner.h:55
void mkfit::CandCloner::begin_eta_bin ( EventOfCombCandidates e_o_ccs,
std::vector< std::pair< int, int >> *  update_list,
std::vector< std::vector< TrackCand >> *  extra_cands,
int  start_seed,
int  n_seeds 
)

Definition at line 26 of file CandCloner.cc.

References mkfit::dtime(), mps_fire::i, m_hits_to_add, m_n_seeds, m_start_seed, mp_event_of_comb_candidates, mp_extra_cands, mp_kalman_update_list, and gpuVertexFinder::printf().

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

30  {
32  mp_kalman_update_list = update_list;
33  mp_extra_cands = extra_cands;
34  m_start_seed = start_seed;
35  m_n_seeds = n_seeds;
36  m_hits_to_add.resize(n_seeds);
37 
38  for (int i = 0; i < n_seeds; ++i)
39  m_hits_to_add[i].reserve(4);
40 
41 #ifdef CC_TIME_ETA
42  printf("CandCloner::begin_eta_bin\n");
43  t_eta = dtime();
44 #endif
45  }
EventOfCombCandidates * mp_event_of_comb_candidates
Definition: CandCloner.h:58
std::vector< std::vector< IdxChi2List > > m_hits_to_add
Definition: CandCloner.h:55
std::vector< std::vector< TrackCand > > * mp_extra_cands
Definition: CandCloner.h:60
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
double dtime()
std::vector< std::pair< int, int > > * mp_kalman_update_list
Definition: CandCloner.h:59
void mkfit::CandCloner::begin_iteration ( )

Definition at line 60 of file CandCloner.cc.

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

60  {
61  // Do nothing, "secondary" state vars updated when work completed/assigned.
62  }
void mkfit::CandCloner::begin_layer ( int  lay)

Definition at line 47 of file CandCloner.cc.

References mkfit::dtime(), m_idx_max, m_idx_max_prev, m_layer, and mp_kalman_update_list.

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

47  {
48  m_layer = lay;
49 
50  m_idx_max = 0;
51  m_idx_max_prev = 0;
52 
53  mp_kalman_update_list->clear();
54 
55 #ifdef CC_TIME_LAYER
56  t_lay = dtime();
57 #endif
58  }
double dtime()
std::vector< std::pair< int, int > > * mp_kalman_update_list
Definition: CandCloner.h:59
CombCandidate& mkfit::CandCloner::combCandWithOriginalIndex ( int  idx)
inline

Definition at line 51 of file CandCloner.h.

References mkfit::EventOfCombCandidates::cand(), and mp_event_of_comb_candidates.

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

51 { return mp_event_of_comb_candidates->cand(idx); }
EventOfCombCandidates * mp_event_of_comb_candidates
Definition: CandCloner.h:58
CombCandidate & cand(int i)
void mkfit::CandCloner::doWork ( int  idx)

Definition at line 102 of file CandCloner.cc.

References dprintf, dataset::end, m_idx_max_prev, SiStripPI::min, processSeedRange(), and s_max_seed_range.

Referenced by end_iteration(), and end_layer().

102  {
103  dprintf("CandCloner::DoWork assigning work from seed %d to %d\n", m_idx_max_prev, idx);
104 
105  int beg = m_idx_max_prev;
106  int the_end = idx;
107 
108  dprintf("CandCloner::DoWork working on beg=%d to the_end=%d\n", beg, the_end);
109 
110  while (beg != the_end) {
111  int end = std::min(beg + s_max_seed_range, the_end);
112 
113  dprintf("CandCloner::DoWork processing %4d -> %4d\n", beg, end);
114 
115  processSeedRange(beg, end);
116 
117  beg = end;
118  }
119 
120  m_idx_max_prev = idx;
121  }
static const int s_max_seed_range
Definition: CandCloner.h:19
void processSeedRange(int is_beg, int is_end)
Definition: CandCloner.cc:125
string end
Definition: dataset.py:937
#define dprintf(...)
Definition: Debug.h:93
void mkfit::CandCloner::end_eta_bin ( )

Definition at line 94 of file CandCloner.cc.

References mkfit::dtime(), and gpuVertexFinder::printf().

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

94  {
95 #ifdef CC_TIME_ETA
96  t_eta = dtime() - t_eta;
97  printf("CandCloner::end_eta_bin t_eta=%8.6f\n", t_eta);
98 #endif
99  }
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
double dtime()
void mkfit::CandCloner::end_iteration ( )

Definition at line 64 of file CandCloner.cc.

References doWork(), dprintf, m_idx_max, m_idx_max_prev, and s_max_seed_range.

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

64  {
65  int proc_n = m_idx_max - m_idx_max_prev;
66 
67  dprintf("CandCloner::end_iteration process %d, max_prev=%d, max=%d\n", proc_n, m_idx_max_prev, m_idx_max);
68 
69  if (proc_n >= s_max_seed_range) {
70  // Round to multiple of s_max_seed_range.
72  }
73  }
static const int s_max_seed_range
Definition: CandCloner.h:19
void doWork(int idx)
Definition: CandCloner.cc:102
#define dprintf(...)
Definition: Debug.h:93
void mkfit::CandCloner::end_layer ( )

Definition at line 75 of file CandCloner.cc.

References doWork(), mkfit::dtime(), mps_fire::i, m_hits_to_add, m_idx_max, m_idx_max_prev, m_layer, m_n_seeds, and gpuVertexFinder::printf().

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

75  {
76  if (m_n_seeds > m_idx_max_prev) {
78  }
79 
80  for (int i = 0; i < m_n_seeds; ++i) {
81  m_hits_to_add[i].clear();
82  }
83 
84 #ifdef CC_TIME_LAYER
85  t_lay = dtime() - t_lay;
86  printf("CandCloner::end_layer %d -- t_lay=%8.6f\n", m_layer, t_lay);
87  printf(" m_idx_max=%d, m_idx_max_prev=%d, issued work=%d\n",
88  m_idx_max,
91 #endif
92  }
std::vector< std::vector< IdxChi2List > > m_hits_to_add
Definition: CandCloner.h:55
printf("params %d %f %f %f\n", minT, eps, errmax, chi2max)
void doWork(int idx)
Definition: CandCloner.cc:102
double dtime()
int mkfit::CandCloner::num_cands ( int  idx)
inline

Definition at line 40 of file CandCloner.h.

References m_hits_to_add.

40 { return m_hits_to_add[idx].size(); }
std::vector< std::vector< IdxChi2List > > m_hits_to_add
Definition: CandCloner.h:55
void mkfit::CandCloner::processSeedRange ( int  is_beg,
int  is_end 
)

Definition at line 125 of file CandCloner.cc.

References mkfit::TrackCand::addHitIdx(), mkfit::EventOfCombCandidates::cand(), HLT_FULL_cff::chi2, mkfit::IdxChi2List::chi2_hit, mkfit::CombCandidate::clear(), cuy::cv, dprint, dprintf, mkfit::CombCandidate::emplace_back(), mkfit::CombCandidate::Finding, mkfit::IdxChi2List::hitIdx, cuy::ii, mkfit::TrackCand::incOverlapCount(), mkfit::HitMatch::m_chi2, mkfit::HitMatch::m_hit_idx, m_hits_to_add, m_layer, m_start_seed, mkfit::IterationParams::maxCandsPerSeed, SiStripPI::min, mkfit::IdxChi2List::module, mp_event_of_comb_candidates, mp_iteration_params, mp_kalman_update_list, PVValHelper::pT, mkfit::TrackBase::pT(), mkfit::IterationParams::pTCutOverlap, mkfit::CombCandidate::refBestShortCand(), mkfit::CombCandidate::resize(), mkfit::IdxChi2List::score, mkfit::TrackBase::score(), mkfit::CombCandidate::setBestShortCand(), mkfit::TrackBase::setScore(), mkfit::sortByScoreTrackCand(), mkfit::CombCandidate::state(), t_cands_for_next_lay, and mkfit::IdxChi2List::trkIdx.

Referenced by doWork().

125  {
126  // Process new hits for a range of seeds.
127 
128  // bool debug = true;
129 
130  dprintf("\nCandCloner::ProcessSeedRange is_beg=%d, is_end=%d\n", is_beg, is_end);
131 
132  //1) sort the candidates
133  for (int is = is_beg; is < is_end; ++is) {
134  std::vector<IdxChi2List> &hitsForSeed = m_hits_to_add[is];
135 
136  CombCandidate &ccand = mp_event_of_comb_candidates->cand(m_start_seed + is);
137  std::vector<TrackCand> &extras = (*mp_extra_cands)[is];
138  auto extra_i = extras.begin();
139  auto extra_e = extras.end();
140 
141  // Extras are sorted by candScore.
142 
143 #ifdef DEBUG
144  dprint(" seed n " << is << " with input candidates=" << hitsForSeed.size());
145  for (int ih = 0; ih < (int)hitsForSeed.size(); ih++) {
146  dprint("trkIdx=" << hitsForSeed[ih].trkIdx << " hitIdx=" << hitsForSeed[ih].hitIdx
147  << " chi2=" << hitsForSeed[ih].chi2 << std::endl
148  << " "
149  << "original pt=" << ccand[hitsForSeed[ih].trkIdx].pT() << " "
150  << "nTotalHits=" << ccand[hitsForSeed[ih].trkIdx].nTotalHits() << " "
151  << "nFoundHits=" << ccand[hitsForSeed[ih].trkIdx].nFoundHits() << " "
152  << "chi2=" << ccand[hitsForSeed[ih].trkIdx].chi2());
153  }
154 #endif
155 
156  if (!hitsForSeed.empty()) {
157  //sort the new hits
158  std::sort(hitsForSeed.begin(), hitsForSeed.end(), sortCandListByScore);
159 
160  int num_hits = std::min((int)hitsForSeed.size(), mp_iteration_params->maxCandsPerSeed);
161 
162  // This is from buffer, we know it was cleared after last usage.
163  std::vector<TrackCand> &cv = t_cands_for_next_lay[is - is_beg];
164 
165  int n_pushed = 0;
166 
167  for (int ih = 0; ih < num_hits; ih++) {
168  const IdxChi2List &h2a = hitsForSeed[ih];
169 
170  TrackCand tc(ccand[h2a.trkIdx]);
171  tc.addHitIdx(h2a.hitIdx, m_layer, h2a.chi2_hit);
172  tc.setScore(h2a.score);
173 
174  if (h2a.hitIdx == -2) {
175  if (h2a.score > ccand.refBestShortCand().score()) {
176  ccand.setBestShortCand(tc);
177  }
178  continue;
179  }
180 
181  // Could also skip storing of cands with last -3 hit.
182 
183  // Squeeze in extra tracks that are better than current one.
184  while (extra_i != extra_e && sortByScoreTrackCand(*extra_i, tc) &&
185  n_pushed < mp_iteration_params->maxCandsPerSeed) {
186  cv.emplace_back(*extra_i);
187  ++n_pushed;
188  ++extra_i;
189  }
190 
191  if (n_pushed >= mp_iteration_params->maxCandsPerSeed)
192  break;
193 
194  // set the overlap if we have a true hit and pT > pTCutOverlap
195  HitMatch *hm;
196  if (tc.pT() > mp_iteration_params->pTCutOverlap && h2a.hitIdx >= 0 &&
197  (hm = ccand[h2a.trkIdx].findOverlap(h2a.hitIdx, h2a.module))) {
198  tc.addHitIdx(hm->m_hit_idx, m_layer, hm->m_chi2);
199  tc.incOverlapCount();
200  }
201 
202  cv.emplace_back(tc);
203  ++n_pushed;
204 
205  if (h2a.hitIdx >= 0) {
206  mp_kalman_update_list->push_back(std::pair<int, int>(m_start_seed + is, n_pushed - 1));
207  }
208  }
209 
210  // Add remaining extras as long as there is still room for them.
211  while (extra_i != extra_e && n_pushed < mp_iteration_params->maxCandsPerSeed) {
212  cv.emplace_back(*extra_i);
213  ++n_pushed;
214  ++extra_i;
215  }
216 
217  // Can not use ccand.swap(cv) -- allocations for TrackCand vectors need to be
218  // in the same memory segment for gather operation to work in backward-fit.
219  ccand.resize(cv.size());
220  for (size_t ii = 0; ii < cv.size(); ++ii) {
221  ccand[ii] = cv[ii];
222  }
223  cv.clear();
224  } else // hitsForSeed.empty()
225  {
226  if (ccand.state() == CombCandidate::Finding) {
227  ccand.clear();
228 
229  while (extra_i != extra_e) {
230  ccand.emplace_back(*extra_i);
231  ++extra_i;
232  }
233  }
234  }
235 
236  extras.clear();
237  }
238  }
EventOfCombCandidates * mp_event_of_comb_candidates
Definition: CandCloner.h:58
std::vector< std::vector< IdxChi2List > > m_hits_to_add
Definition: CandCloner.h:55
std::vector< std::vector< TrackCand > > t_cands_for_next_lay
Definition: CandCloner.h:71
int ii
Definition: cuy.py:589
const IterationParams * mp_iteration_params
Definition: CandCloner.h:57
CombCandidate & cand(int i)
dictionary cv
Definition: cuy.py:363
bool sortByScoreTrackCand(const TrackCand &cand1, const TrackCand &cand2)
#define dprint(x)
Definition: Debug.h:90
std::vector< std::pair< int, int > > * mp_kalman_update_list
Definition: CandCloner.h:59
#define dprintf(...)
Definition: Debug.h:93
void mkfit::CandCloner::release ( )

Definition at line 24 of file CandCloner.cc.

References mp_iteration_params.

24 { mp_iteration_params = nullptr; }
const IterationParams * mp_iteration_params
Definition: CandCloner.h:57
void mkfit::CandCloner::setup ( const IterationParams ip)

Definition at line 17 of file CandCloner.cc.

References iseed, mkfit::IterationParams::maxCandsPerSeed, mp_iteration_params, s_max_seed_range, and t_cands_for_next_lay.

17  {
18  mp_iteration_params = &ip;
19  for (int iseed = 0; iseed < s_max_seed_range; ++iseed) {
21  }
22  }
static const int s_max_seed_range
Definition: CandCloner.h:19
std::vector< std::vector< TrackCand > > t_cands_for_next_lay
Definition: CandCloner.h:71
const IterationParams * mp_iteration_params
Definition: CandCloner.h:57
int iseed
Definition: AMPTWrapper.h:134

Member Data Documentation

std::vector<std::vector<IdxChi2List> > mkfit::CandCloner::m_hits_to_add
private

Definition at line 55 of file CandCloner.h.

Referenced by add_cand(), begin_eta_bin(), end_layer(), num_cands(), and processSeedRange().

int mkfit::CandCloner::m_idx_max
private

Definition at line 54 of file CandCloner.h.

Referenced by add_cand(), begin_layer(), end_iteration(), and end_layer().

int mkfit::CandCloner::m_idx_max_prev
private

Definition at line 54 of file CandCloner.h.

Referenced by begin_layer(), doWork(), end_iteration(), and end_layer().

int mkfit::CandCloner::m_layer
private

Definition at line 67 of file CandCloner.h.

Referenced by begin_layer(), end_layer(), and processSeedRange().

int mkfit::CandCloner::m_n_seeds
private

Definition at line 66 of file CandCloner.h.

Referenced by begin_eta_bin(), and end_layer().

int mkfit::CandCloner::m_start_seed
private

Definition at line 66 of file CandCloner.h.

Referenced by begin_eta_bin(), and processSeedRange().

EventOfCombCandidates* mkfit::CandCloner::mp_event_of_comb_candidates
private

Definition at line 58 of file CandCloner.h.

Referenced by begin_eta_bin(), combCandWithOriginalIndex(), and processSeedRange().

std::vector<std::vector<TrackCand> >* mkfit::CandCloner::mp_extra_cands
private

Definition at line 60 of file CandCloner.h.

Referenced by begin_eta_bin().

const IterationParams* mkfit::CandCloner::mp_iteration_params = nullptr
private

Definition at line 57 of file CandCloner.h.

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

std::vector<std::pair<int, int> >* mkfit::CandCloner::mp_kalman_update_list
private

Definition at line 59 of file CandCloner.h.

Referenced by begin_eta_bin(), begin_layer(), and processSeedRange().

const int mkfit::CandCloner::s_max_seed_range = 8
static

Definition at line 19 of file CandCloner.h.

Referenced by CandCloner(), doWork(), end_iteration(), and setup().

std::vector<std::vector<TrackCand> > mkfit::CandCloner::t_cands_for_next_lay
private

Definition at line 71 of file CandCloner.h.

Referenced by CandCloner(), processSeedRange(), and setup().