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");
113 printf(
"At event %d\n",
eid);
137 }
else if (seed_select ==
SS_Label &&
s.label() == selected_seed) {
146 }
else if (n_algo > 0)
151 printf(
"Shell::ProcessEvent running over %d seeds\n", (
int)
m_seeds.size());
181 if (selected_seed >= 0 && selected_seed < (
int)
seeds.size()) {
192 printf(
"Shell::ProcessEvent requested seed not found among seeds of the selected iteration.\n");
194 printf(
"Shell::ProcessEvent no seeds found.\n");
215 return itconf.
m_pre_bkfit_filter(tc, jb) && StdSeq::qfilter_nan_n_silly<TrackCand>(tc, jb);
219 else if (do_backward_fit)
220 pre_filter = StdSeq::qfilter_nan_n_silly<TrackCand>;
225 printf(
"Shell::ProcessEvent post pre-bkf-filter (%s) and nan-filter (%s) filter: %d comb-cands\n",
228 job.switch_to_backward();
230 if (do_backward_fit) {
242 printf(
"Shell::ProcessEvent post backward fit / search: %d comb-cands\n",
builder.
ref_eocc().
size());
249 return itconf.
m_post_bkfit_filter(tc, jb) && StdSeq::qfilter_nan_n_silly<TrackCand>(tc, jb);
252 post_filter = StdSeq::qfilter_nan_n_silly<TrackCand>;
256 printf(
"Shell::ProcessEvent post post-bkf-filter (%s) and nan-filter (true): %d comb-cands\n",
268 printf(
"Shell::ProcessEvent post remove-duplicates: %d comb-cands\n", (
int) out_tracks.size());
275 printf(
"Shell::ProcessEvent found %d tracks, number of seeds at end %d\n",
284 if (itidx < 0 || itidx >= n_algos) {
285 fprintf(
stderr,
"Requested iteration index out of range [%d, %d)", 0, n_algos);
286 throw std::runtime_error(
"iteration index out of range");
292 for (
int i = 0;
i < n_algos; ++
i) {
298 fprintf(
stderr,
"Requested algo %d not found",
algo);
299 throw std::runtime_error(
"algo not found");
303 printf(
"Shell::PrintIterations selected index = %d, %d iterations hardcoded as\n",
305 for (
int i = 0;
i < n_algos; ++
i)
334 std::map<int, int> lab_cnt;
335 for (
int hi = 0;
hi <
t.nTotalHits(); ++
hi) {
336 auto hot =
t.getHitOnTrack(
hi);
344 int max_c = -1, max_l = -1;
345 for (
auto&
x : lab_cnt) {
346 if (
x.second > max_c) {
351 bool success = max_c >= good_frac *
t.nFoundHits();
352 int relabel =
success ? max_l : -1;
370 int rec_algo_match = 0;
371 for (
auto &
t :
ev.cmsswTracks_) {
372 if (
t.algoint() != track_algo)
382 for (
auto &
t :
ev.simTracks_) {
389 for (
auto &
t :
ev.seedTracks_) {
395 for (
auto &
t :
ev.seedTracks_) {
396 if (
t.algoint() == track_algo &&
t.label() == -1) {
401 printf(
"Saved seed with label -1 -> %d\n", lab);
415 printf(
"Shell::FillByLabelMaps reporting tracks with label >= 0, algo=%d (%s): " 416 "ckf: %d of %d (same algo=%d)), sim: %d of %d, seed: %d of %d, mkfit: %d w/label of %d\n",
418 (
int)
m_ckf_map.size(), (
int)
ev.cmsswTracks_.size(), rec_algo_match,
434 if (std::find_if(lp.begin(), lp.end(), [=](
auto &
x){
return x.m_layer == hot.layer; }) == lp.end())
436 printf(
"CheckMkfLayerPlanVsCkfHits: layer %d not in layer plan for region %d, %s label=%d\n",
454 printf(
"------------------------------------------------------\n");
456 const bool print_all_def =
false;
457 int mkf_cnt=0, less_hits=0, more_hits=0;
460 int tot_cnt = 0, no_mkf_cnt = 0;
464 auto &simt = * simt_ptr;
468 bool print_all = print_all_def;
473 auto &ckf_seed =
ev.seedTracks_[ckft.label()];
474 for (
int hi = 0;
hi < ckf_seed.nTotalHits(); ++
hi) {
489 auto &mkft = * mi->second;
491 if (mkft.nFoundHits() < ckft.nFoundHits()) ++less_hits;
492 if (mkft.nFoundHits() > ckft.nFoundHits()) ++more_hits;
501 auto &ckf_seed =
ev.seedTracks_[ckft.label()];
502 auto &mkf_seed =
m_seeds[mkft.label()];
506 print(
"ckf seed", 0, ckf_seed,
ev);
507 print(
"mkf seed", 0, mkf_seed,
ev);
508 printf(
"------------------------------------------------------\n");
511 ssss.push_back(mkf_seed);
516 printf(
"------------------------------------------------------\n");
522 printf(
"\n!!!!! No mkfit track with this label.\n\n");
525 auto &ckf_seed =
ev.seedTracks_[ckft.label()];
528 print(
"ckf seed", 0, ckf_seed,
ev);
531 print(
"seed with matching label", 0, *smi->second,
ev);
532 printf(
"------------------------------------------------------\n");
536 printf(
"mkFit found %d, matching_label=%d, less_hits=%d, more_hits=%d [algo=%d (%s)]\n",
537 (
int)
ev.fitTracks_.size(), mkf_cnt, less_hits, more_hits,
541 printf(
"\ntobtec tob1/2 tot=%d no_mkf=%d (%f%%)\n",
542 tot_cnt, no_mkf_cnt, 100.0 * no_mkf_cnt / tot_cnt);
544 printf(
"\nNo CKF tracks with seed hits in TOB1/2 found (need iteration idx 8, TobTec?)\n");
547 printf(
"-------------------------------------------------------------------------------------------\n");
548 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)
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