Skip to content

Commit

Permalink
Merge pull request #374 from trackreco/removeNanNSillyCandidates
Browse files Browse the repository at this point in the history
Add filter to remove nan and silly candidates
  • Loading branch information
slava77 authored Oct 27, 2021
2 parents 89b89f0 + 50b3003 commit 9ec7037
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ namespace Config

constexpr bool nan_n_silly_check_seeds = true;
constexpr bool nan_n_silly_print_bad_seeds = false;
constexpr bool nan_n_silly_fixup_bad_seeds = true;
constexpr bool nan_n_silly_remove_bad_seeds = false;
constexpr bool nan_n_silly_fixup_bad_seeds = false;
constexpr bool nan_n_silly_remove_bad_seeds = true;

constexpr bool nan_n_silly_check_cands_every_layer = false;
constexpr bool nan_n_silly_print_bad_cands_every_layer = false;
Expand Down
19 changes: 18 additions & 1 deletion Track.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ bool TrackBase::hasSillyValues(bool dump, bool fix, const char* pref)
{
if ((i == j && state_.errors.At(i,j) < 0) || ! std::isfinite(state_.errors.At(i,j)))
{
if ( ! is_silly)
if ( ! is_silly )
{
is_silly = true;
if (dump) printf("%s (label=%d, pT=%f):", pref, label(), pT());
Expand All @@ -174,6 +174,23 @@ bool TrackBase::hasSillyValues(bool dump, bool fix, const char* pref)
return is_silly;
}

bool TrackBase::hasNanNSillyValues() const
{
bool is_silly = false;
for (int i = 0; i < LL; ++i)
{
for (int j = 0; j <= i; ++j)
{
if ((i == j && state_.errors.At(i,j) < 0) || ! std::isfinite(state_.errors.At(i,j)))
{
is_silly = true;
return is_silly;
}
}
}
return is_silly;
}

// If linearize=true, use linear estimate of d0: suitable at pT>~10 GeV (--> 10 micron error)
float TrackBase::d0BeamSpot(const float x_bs, const float y_bs, bool linearize) const
{
Expand Down
2 changes: 2 additions & 0 deletions Track.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ class TrackBase

bool hasSillyValues(bool dump, bool fix, const char* pref="");

bool hasNanNSillyValues() const;

float d0BeamSpot(const float x_bs, const float y_bs, bool linearize=false) const;

// ------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions mkFit/MkBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ void MkBuilder::score_tracks(TrackVec& tracks)
// PrepareSeeds
//------------------------------------------------------------------------------

void MkBuilder::seed_post_cleaning(TrackVec &tv, const bool fix_silly_seeds, const bool remove_silly_seeds)
void MkBuilder::seed_post_cleaning(TrackVec &tv)
{
#ifdef SELECT_SEED_LABEL
{ // Select seed with the defined label for detailed debugging.
Expand Down Expand Up @@ -1190,7 +1190,7 @@ void MkBuilder::PrepareSeeds()
}
// create_seeds_from_sim_tracks();

seed_post_cleaning(m_event->seedTracks_, true, true);
seed_post_cleaning(m_event->seedTracks_);
}
else if (Config::seedInput == cmsswSeeds)
{
Expand Down Expand Up @@ -1245,7 +1245,7 @@ void MkBuilder::PrepareSeeds()
exit(1);
}

seed_post_cleaning(m_event->seedTracks_, true, true);
seed_post_cleaning(m_event->seedTracks_);

// in rare corner cases, seed tracks could be fully cleaned out: skip mapping if so
if (m_event->seedTracks_.empty()) return;
Expand Down
2 changes: 1 addition & 1 deletion mkFit/MkBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class MkBuilder
const int start_seed, const int end_seed, const int region);

// --------
static void seed_post_cleaning(TrackVec &tv, const bool fix_silly_seeds, const bool remove_silly_seeds);
static void seed_post_cleaning(TrackVec &tv);

void PrepareSeeds();

Expand Down
6 changes: 6 additions & 0 deletions mkFit/MkStdSeqs.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ namespace StdSeq
return !( (nhits<=6 || layers<=6) && std::abs(d0BS)>d0_max );
}

template<class TRACK>
bool qfilter_nan_n_silly(const TRACK &t)
{
return !( t.hasNanNSillyValues() );
}

void find_and_remove_duplicates(TrackVec &tracks, const IterationConfig &itconf);

} // namespace StdSeq
Expand Down
18 changes: 12 additions & 6 deletions mkFit/buildtestMPlex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace
return count;
}

void check_nan_n_silly_candiates(Event &ev)
void check_nan_n_silly_candidates(Event &ev)
{
// MIMI -- nan_n_silly_per_layer_count is in MkBuilder, could be in MkJob.
// if (Config::nan_n_silly_check_cands_every_layer)
Expand Down Expand Up @@ -280,7 +280,7 @@ double runBuildingTestPlexStandard(Event& ev, const EventOfHits &eoh, MkBuilder&
__SSC_MARK(0x222); // use this to pause Intel SDE at the same point
#endif

check_nan_n_silly_candiates(ev);
check_nan_n_silly_candidates(ev);

// first store candidate tracks
builder.quality_store_tracks(ev.candidateTracks_);
Expand Down Expand Up @@ -370,7 +370,7 @@ double runBuildingTestPlexCloneEngine(Event& ev, const EventOfHits &eoh, MkBuild
__SSC_MARK(0x222); // use this to pause Intel SDE at the same point
#endif

check_nan_n_silly_candiates(ev);
check_nan_n_silly_candidates(ev);

// first store candidate tracks - needed for BH backward fit and root_validation
builder.quality_store_tracks(ev.candidateTracks_);
Expand Down Expand Up @@ -490,7 +490,7 @@ std::vector<double> runBtpCe_MultiIter(Event& ev, const EventOfHits &eoh, MkBuil
if ( itconf.m_requires_dupclean_tight )
StdSeq::clean_cms_seedtracks_iter(&seeds, itconf, eoh.m_beam_spot);

builder.seed_post_cleaning(seeds, true, true);
builder.seed_post_cleaning(seeds);

// Add protection in case no seeds are found for iteration
if (seeds.size() <= 0)
Expand Down Expand Up @@ -572,6 +572,9 @@ std::vector<double> runBtpCe_MultiIter(Event& ev, const EventOfHits &eoh, MkBuil
}
}

builder.filter_comb_cands([&](const TrackCand &t)
{ return StdSeq::qfilter_nan_n_silly(t); });

builder.select_best_comb_cands(true); // true -> clear m_tracks as they were already filled once above

StdSeq::find_and_remove_duplicates(builder.ref_tracks_nc(), itconf);
Expand All @@ -592,7 +595,7 @@ std::vector<double> runBtpCe_MultiIter(Event& ev, const EventOfHits &eoh, MkBuil
ev.seedTracks_.swap(seeds_used);
}

check_nan_n_silly_candiates(ev);
check_nan_n_silly_candidates(ev);

if (Config::backwardFit) check_nan_n_silly_bkfit(ev);

Expand Down Expand Up @@ -652,7 +655,7 @@ void run_OneIteration(const TrackerInfo& trackerInfo, const IterationConfig &itc

// Check nans in seeds -- this should not be needed when Slava fixes
// the track parameter coordinate transformation.
builder.seed_post_cleaning(seeds, true, true);
builder.seed_post_cleaning(seeds);

if (itconf.m_requires_seed_hit_sorting)
{
Expand Down Expand Up @@ -709,6 +712,9 @@ void run_OneIteration(const TrackerInfo& trackerInfo, const IterationConfig &itc
}
}

builder.filter_comb_cands([&](const TrackCand &t)
{ return StdSeq::qfilter_nan_n_silly(t); });

builder.export_best_comb_cands(out_tracks);

if (do_remove_duplicates)
Expand Down

0 comments on commit 9ec7037

Please sign in to comment.