25 #include "oneapi/tbb/task_arena.h" 35 const char* b2a(
bool b) {
return b ?
"true" :
"false"; }
57 std::vector<const char *>
argv = {
"mkFit",
"-l" };
59 TRint rint(
"mkFit-shell", &
argc, const_cast<char**>(
argv.data()));
62 sprintf(
buf,
"mkfit::Shell &s = * (mkfit::Shell*) %p;",
this);
63 gROOT->ProcessLine(
buf);
64 printf(
"Shell &s variable is set\n");
67 printf(
"Shell::Run finished\n");
69 printf(
"Shell::Run() no root, we rot -- erroring out. Recompile with WITH_ROOT=1\n");
75 printf(
"On event %d, selected iteration index %d, algo %d - %s\n" 76 " debug = %s, use_dead_modules = %s\n" 77 " clean_seeds = %s, backward_fit = %s, remove_duplicates = %s\n",
89 fprintf(
stderr,
"Requested event %d is less than 1 -- 1 is the first event, %d is total number of events in file\n",
91 throw std::runtime_error(
"event out of range");
94 fprintf(
stderr,
"Requested event %d is grater than total number of events in file %d\n",
96 throw std::runtime_error(
"event out of range");
114 printf(
"At event %d\n",
eid);
138 }
else if (seed_select ==
SS_Label &&
s.label() == selected_seed) {
147 }
else if (n_algo > 0)
152 printf(
"Shell::ProcessEvent running over %d seeds\n", (
int)
m_seeds.size());
176 printf(
"Shell::ProcessEvent post seed-cleaning: %d seeds\n", (
int)
m_seeds.size());
178 printf(
"Shell::ProcessEvent no seed-cleaning\n");
187 if (selected_seed >= 0 && selected_seed < seed_size) {
188 if (selected_seed +
count >= seed_size) {
189 count = seed_size - selected_seed;
190 printf(
" -- selected seed_index + count > seed vector size after cleaning -- trimming count to %d\n",
203 printf(
"Shell::ProcessEvent requested seed not found among seeds of the selected iteration.\n");
205 printf(
"Shell::ProcessEvent no seeds found.\n");
226 return itconf.
m_pre_bkfit_filter(tc, jb) && StdSeq::qfilter_nan_n_silly<TrackCand>(tc, jb);
230 else if (do_backward_fit)
231 pre_filter = StdSeq::qfilter_nan_n_silly<TrackCand>;
236 printf(
"Shell::ProcessEvent post pre-bkf-filter (%s) and nan-filter (%s) filter: %d comb-cands\n",
239 job.switch_to_backward();
241 if (do_backward_fit) {
253 printf(
"Shell::ProcessEvent post backward fit / search: %d comb-cands\n",
builder.
ref_eocc().
size());
260 return itconf.
m_post_bkfit_filter(tc, jb) && StdSeq::qfilter_nan_n_silly<TrackCand>(tc, jb);
263 post_filter = StdSeq::qfilter_nan_n_silly<TrackCand>;
267 printf(
"Shell::ProcessEvent post post-bkf-filter (%s) and nan-filter (true): %d comb-cands\n",
279 printf(
"Shell::ProcessEvent post remove-duplicates: %d comb-cands\n", (
int) out_tracks.size());
287 printf(
"Shell::ProcessEvent found %d tracks, number of seeds at end %d\n",
296 if (itidx < 0 || itidx >= n_algos) {
297 fprintf(
stderr,
"Requested iteration index out of range [%d, %d)", 0, n_algos);
298 throw std::runtime_error(
"iteration index out of range");
304 for (
int i = 0;
i < n_algos; ++
i) {
310 fprintf(
stderr,
"Requested algo %d not found",
algo);
311 throw std::runtime_error(
"algo not found");
315 printf(
"Shell::PrintIterations selected index = %d, %d iterations hardcoded as\n",
317 for (
int i = 0;
i < n_algos; ++
i)
346 std::map<int, int> lab_cnt;
347 for (
int hi = 0;
hi <
t.nTotalHits(); ++
hi) {
348 auto hot =
t.getHitOnTrack(
hi);
356 int max_c = -1, max_l = -1;
357 for (
auto&
x : lab_cnt) {
358 if (
x.second > max_c) {
363 bool success = max_c >= good_frac *
t.nFoundHits();
364 int relabel =
success ? max_l : -1;
382 int rec_algo_match = 0;
383 for (
auto &
t :
ev.cmsswTracks_) {
384 if (
t.algoint() != track_algo)
394 for (
auto &
t :
ev.simTracks_) {
401 for (
auto &
t :
ev.seedTracks_) {
407 for (
auto &
t :
ev.seedTracks_) {
408 if (
t.algoint() == track_algo &&
t.label() == -1) {
413 printf(
"Saved seed with label -1 -> %d\n", lab);
427 printf(
"Shell::FillByLabelMaps reporting tracks with label >= 0, algo=%d (%s): " 428 "ckf: %d of %d (same algo=%d)), sim: %d of %d, seed: %d of %d, mkfit: %d w/label of %d\n",
430 (
int)
m_ckf_map.size(), (
int)
ev.cmsswTracks_.size(), rec_algo_match,
446 if (std::find_if(lp.begin(), lp.end(), [=](
auto &
x){
return x.m_layer == hot.layer; }) == lp.end())
448 printf(
"CheckMkfLayerPlanVsCkfHits: layer %d not in layer plan for region %d, %s label=%d\n",
466 printf(
"------------------------------------------------------\n");
468 const bool print_all_def =
false;
469 int mkf_cnt=0, less_hits=0, more_hits=0;
472 int tot_cnt = 0, no_mkf_cnt = 0;
476 auto &simt = * simt_ptr;
480 bool print_all = print_all_def;
485 auto &ckf_seed =
ev.seedTracks_[ckft.label()];
486 for (
int hi = 0;
hi < ckf_seed.nTotalHits(); ++
hi) {
501 auto &mkft = * mi->second;
503 if (mkft.nFoundHits() < ckft.nFoundHits()) ++less_hits;
504 if (mkft.nFoundHits() > ckft.nFoundHits()) ++more_hits;
513 auto &ckf_seed =
ev.seedTracks_[ckft.label()];
514 auto &mkf_seed =
m_seeds[mkft.label()];
518 print(
"ckf seed", 0, ckf_seed,
ev);
519 print(
"mkf seed", 0, mkf_seed,
ev);
520 printf(
"------------------------------------------------------\n");
523 ssss.push_back(mkf_seed);
528 printf(
"------------------------------------------------------\n");
534 printf(
"\n!!!!! No mkfit track with this label.\n\n");
537 auto &ckf_seed =
ev.seedTracks_[ckft.label()];
540 print(
"ckf seed", 0, ckf_seed,
ev);
543 print(
"seed with matching label", 0, *smi->second,
ev);
544 printf(
"------------------------------------------------------\n");
548 printf(
"mkFit found %d, matching_label=%d, less_hits=%d, more_hits=%d [algo=%d (%s)]\n",
549 (
int)
ev.fitTracks_.size(), mkf_cnt, less_hits, more_hits,
553 printf(
"\ntobtec tob1/2 tot=%d no_mkf=%d (%f%%)\n",
554 tot_cnt, no_mkf_cnt, 100.0 * no_mkf_cnt / tot_cnt);
556 printf(
"\nNo CKF tracks with seed hits in TOB1/2 found (need iteration idx 8, TobTec?)\n");
559 printf(
"-------------------------------------------------------------------------------------------\n");
560 printf(
"-------------------------------------------------------------------------------------------\n");
std::map< int, Track * > m_sim_map
void ProcessEvent(SeedSelect_e seed_select=SS_UseAll, int selected_seed=-1, int count=1)
const EventOfCombCandidates & ref_eocc() const
Shell(std::vector< DeadVec > &dv, const std::string &in_file, int start_ev)
int openRead(const std::string &fname, int expected_n_layers)
const BeamSpot & refBeamSpot() const
ret
prodAgent to be discontinued
void compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits)
def replace(string, replacements)
void findTracksCloneEngine(SteeringParams::IterationType_e iteration_dir=SteeringParams::IT_FwdSearch)
std::map< int, Track * > m_mkf_map
bool CheckMkFitLayerPlanVsReferenceHits(const Track &mkft, const Track &reft, const std::string &name)
bool m_backward_drop_seed_hits
void begin_event(MkJob *job, Event *ev, const char *build_type)
void resetCurrentSeedTracks()
clean_seeds_func m_seed_cleaner
void SelectIterationIndex(int itidx)
TEMPL(T2) struct Divides void
std::vector< DeadVec > & m_deadvectors
void loadHitsAndBeamSpot(Event &ev, EventOfHits &eoh)
void FillByLabelMaps_CkfBase()
void skipNEvents(int n_to_skip)
std::function< filter_candidates_cf > filter_candidates_func
void find_tracks_load_seeds(const TrackVec &in_seeds, const bool seeds_sorted)
void setCurrentSeedTracks(const TrackVec &seeds)
const TrackVec & seeds() const
static partition_seeds_func get_seed_partitioner(const std::string &name)
void SetCleanSeeds(bool b)
void loadDeads(EventOfHits &eoh, const std::vector< DeadVec > &deadvectors)
void seed_post_cleaning(TrackVec &tv)
void SetRemoveDuplicates(bool b)
void fill_hitmask_bool_vectors(int track_algo, std::vector< std::vector< bool >> &layer_masks)
MCHitInfoVec simHitsInfo_
int filter_comb_cands(filter_candidates_func filter, bool attempt_all_cands)
void NextEvent(int skip=1)
int m_backward_fit_min_hits
std::vector< HitVec > layerHits_
static const char * algoint_to_cstr(int algo)
filter_candidates_func m_post_bkfit_filter
std::vector< Track > TrackVec
clean_duplicates_func m_duplicate_cleaner
void print(std::string_view label, const MeasurementState &s)
void export_best_comb_cands(TrackVec &out_vec, bool remove_missing_hits=false)
void SetBackwardFit(bool b)
int LabelFromHits(Track &t, bool replace, float good_frac)
void SetUseDeadModules(bool b)
std::vector< std::vector< bool > > m_mask_vector
void SelectIterationAlgo(int algo)
filter_candidates_func m_pre_bkfit_filter
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
std::map< int, Track * > m_ckf_map
std::vector< SteeringParams > m_steering_params
bool m_requires_seed_hit_sorting
std::map< int, Track * > m_seed_map
void read_in(DataFile &data_file, FILE *in_fp=0)
HitOnTrack getHitOnTrack(int posHitIdx) const