27 #include "ROOT/REveJetCone.hxx" 28 #include "ROOT/REveManager.hxx" 29 #include "ROOT/REveScene.hxx" 30 #include "ROOT/REveBoxSet.hxx" 33 #include "oneapi/tbb/task_arena.h" 43 const char* b2a(
bool b) {
return b ?
"true" :
"false"; }
63 printf(
"Shell initialized but the %s, running on an empty Event.\n",
64 in_file.empty() ?
"input-file not specified" :
"requested number of events to process is 0");
77 std::vector<const char *>
argv = {
"mkFit",
"-l" };
79 gApplication =
new TRint(
"mkFit-shell", &
argc, const_cast<char**>(
argv.data()));
82 sprintf(
buf,
"mkfit::Shell &s = * (mkfit::Shell*) %p;",
this);
83 gROOT->ProcessLine(
buf);
84 printf(
"Shell &s variable is set: ");
85 gROOT->ProcessLine(
"s");
87 gApplication->Run(
true);
88 printf(
"Shell::Run finished\n");
92 printf(
"On event %d, selected iteration index %d, algo %d - %s\n" 93 " debug = %s, use_dead_modules = %s\n" 94 " clean_seeds = %s, backward_fit = %s, remove_duplicates = %s\n",
108 fprintf(
stderr,
"Requested event %d is less than 1 -- 1 is the first event, %d is total number of events in file\n",
110 throw std::runtime_error(
"event out of range");
113 fprintf(
stderr,
"Requested event %d is grater than total number of events in file %d\n",
115 throw std::runtime_error(
"event out of range");
133 printf(
"At event %d\n",
eid);
157 }
else if (seed_select ==
SS_Label &&
s.label() == selected_seed) {
167 }
else if (n_algo > 0)
172 printf(
"Shell::ProcessEvent running over %d seeds\n", (
int)
m_seeds.size());
196 printf(
"Shell::ProcessEvent post seed-cleaning: %d seeds\n", (
int)
m_seeds.size());
198 printf(
"Shell::ProcessEvent no seed-cleaning\n");
207 if (selected_seed >= 0 && selected_seed < seed_size) {
208 if (selected_seed +
count >= seed_size) {
209 count = seed_size - selected_seed;
210 printf(
" -- selected seed_index + count > seed vector size after cleaning -- trimming count to %d\n",
223 printf(
"Shell::ProcessEvent requested seed not found among seeds of the selected iteration.\n");
225 printf(
"Shell::ProcessEvent no seeds found.\n");
246 return itconf.
m_pre_bkfit_filter(tc, jb) && StdSeq::qfilter_nan_n_silly<TrackCand>(tc, jb);
250 else if (do_backward_fit)
251 pre_filter = StdSeq::qfilter_nan_n_silly<TrackCand>;
256 printf(
"Shell::ProcessEvent post pre-bkf-filter (%s) and nan-filter (%s) filter: %d comb-cands\n",
259 job.switch_to_backward();
261 if (do_backward_fit) {
273 printf(
"Shell::ProcessEvent post backward fit / search: %d comb-cands\n",
builder.
ref_eocc().
size());
280 return itconf.
m_post_bkfit_filter(tc, jb) && StdSeq::qfilter_nan_n_silly<TrackCand>(tc, jb);
283 post_filter = StdSeq::qfilter_nan_n_silly<TrackCand>;
287 printf(
"Shell::ProcessEvent post post-bkf-filter (%s) and nan-filter (true): %d comb-cands\n",
299 printf(
"Shell::ProcessEvent post remove-duplicates: %d comb-cands\n", (
int) out_tracks.size());
307 printf(
"Shell::ProcessEvent found %d tracks, number of seeds at end %d\n",
316 if (itidx < 0 || itidx >= n_algos) {
317 fprintf(
stderr,
"Requested iteration index out of range [%d, %d)", 0, n_algos);
318 throw std::runtime_error(
"iteration index out of range");
324 for (
int i = 0;
i < n_algos; ++
i) {
330 fprintf(
stderr,
"Requested algo %d not found",
algo);
331 throw std::runtime_error(
"algo not found");
335 printf(
"Shell::PrintIterations selected index = %d, %d iterations hardcoded as\n",
337 for (
int i = 0;
i < n_algos; ++
i)
366 std::map<int, int> lab_cnt;
367 for (
int hi = 0;
hi <
t.nTotalHits(); ++
hi) {
368 auto hot =
t.getHitOnTrack(
hi);
376 int max_c = -1, max_l = -1;
377 for (
auto&
x : lab_cnt) {
378 if (
x.second > max_c) {
383 bool success = max_c >= good_frac *
t.nFoundHits();
384 int relabel =
success ? max_l : -1;
402 int rec_algo_match = 0;
403 for (
auto &
t :
ev.cmsswTracks_) {
404 if (
t.algoint() != track_algo)
414 for (
auto &
t :
ev.simTracks_) {
421 for (
auto &
t :
ev.seedTracks_) {
427 for (
auto &
t :
ev.seedTracks_) {
428 if (
t.algoint() == track_algo &&
t.label() == -1) {
433 printf(
"Saved seed with label -1 -> %d\n", lab);
447 printf(
"Shell::FillByLabelMaps reporting tracks with label >= 0, algo=%d (%s): " 448 "ckf: %d of %d (same algo=%d)), sim: %d of %d, seed: %d of %d, mkfit: %d w/label of %d\n",
450 (
int)
m_ckf_map.size(), (
int)
ev.cmsswTracks_.size(), rec_algo_match,
466 if (std::find_if(lp.begin(), lp.end(), [=](
auto &
x){
return x.m_layer == hot.layer; }) == lp.end())
468 printf(
"CheckMkfLayerPlanVsCkfHits: layer %d not in layer plan for region %d, %s label=%d\n",
486 printf(
"------------------------------------------------------\n");
488 const bool print_all_def =
false;
489 int mkf_cnt=0, less_hits=0, more_hits=0;
492 int tot_cnt = 0, no_mkf_cnt = 0;
496 auto &simt = * simt_ptr;
500 bool print_all = print_all_def;
505 auto &ckf_seed =
ev.seedTracks_[ckft.label()];
506 for (
int hi = 0;
hi < ckf_seed.nTotalHits(); ++
hi) {
521 auto &mkft = * mi->second;
523 if (mkft.nFoundHits() < ckft.nFoundHits()) ++less_hits;
524 if (mkft.nFoundHits() > ckft.nFoundHits()) ++more_hits;
533 auto &ckf_seed =
ev.seedTracks_[ckft.label()];
534 auto &mkf_seed =
m_seeds[mkft.label()];
538 print(
"ckf seed", 0, ckf_seed,
ev);
539 print(
"mkf seed", 0, mkf_seed,
ev);
540 printf(
"------------------------------------------------------\n");
543 ssss.push_back(mkf_seed);
548 printf(
"------------------------------------------------------\n");
554 printf(
"\n!!!!! No mkfit track with this label.\n\n");
557 auto &ckf_seed =
ev.seedTracks_[ckft.label()];
560 print(
"ckf seed", 0, ckf_seed,
ev);
563 print(
"seed with matching label", 0, *smi->second,
ev);
564 printf(
"------------------------------------------------------\n");
568 printf(
"mkFit found %d, matching_label=%d, less_hits=%d, more_hits=%d [algo=%d (%s)]\n",
569 (
int)
ev.fitTracks_.size(), mkf_cnt, less_hits, more_hits,
573 printf(
"\ntobtec tob1/2 tot=%d no_mkf=%d (%f%%)\n",
574 tot_cnt, no_mkf_cnt, 100.0 * no_mkf_cnt / tot_cnt);
576 printf(
"\nNo CKF tracks with seed hits in TOB1/2 found (need iteration idx 8, TobTec?)\n");
579 printf(
"-------------------------------------------------------------------------------------------\n");
580 printf(
"-------------------------------------------------------------------------------------------\n");
590 void Shell::ShowTracker() {
592 auto eveMng = REX::REveManager::Create();
593 eveMng->AllowMultipleRemoteConnections(
false,
false);
596 REX::REveElement *holder =
new REX::REveElement(
"Jets");
599 TRandom &
r = *gRandom;
602 const Double_t kR_max = 250;
603 const Double_t kZ_d = 300;
604 for (
int i = 0;
i < N_Jets;
i++)
606 auto jet =
new REX::REveJetCone(Form(
"Jet_%d",
i ));
607 jet->SetCylinder(2*kR_max, 2*kZ_d);
610 jet->SetFillColor(kRed + 4);
611 jet->SetLineColor(kBlack);
612 jet->SetMainTransparency(90);
614 holder->AddElement(
jet);
616 eveMng->GetEventScene()->AddElement(holder);
620 for (
int l = 0;
l < ti.n_layers(); ++
l) {
622 auto*
bs =
new REX::REveBoxSet(Form(
"Layer %d",
l));
623 bs->Reset(REX::REveBoxSet::kBT_InstancedScaledRotated,
true, li.n_modules());
624 bs->SetMainColorPtr(
new Color_t);
625 bs->UseSingleColor();
627 bs->SetMainColor(li.is_barrel() ? kBlue - 3 : kCyan - 3);
629 bs->SetMainColor(li.is_barrel() ? kMagenta - 3 : kGreen - 3);
632 t[3] =
t[7] =
t[11] = 0;
634 for (
int m = 0;
m < li.n_modules(); ++
m) {
635 auto &mi = li.module_info(
m);
636 auto &si = li.module_shape(mi.shapeid);
639 t[0] =
x[0] * si.dx1;
640 t[1] =
x[1] * si.dx1;
641 t[2] =
x[2] * si.dx1;
642 auto y = mi.calc_ydir();
649 t[10] =
z[2] * si.dz;
655 bs->AddInstanceMat4(
t);
657 bs->SetMainTransparency(60);
660 eveMng->GetEventScene()->AddElement(
bs);
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)
TrackerInfo * tracker_info()
HitOnTrack getHitOnTrack(int posHitIdx) const