Skip to content

Commit

Permalink
Merge pull request cms-sw#340 from trackreco/varychi2_pr
Browse files Browse the repository at this point in the history
Vary chi2 cut per layer/iteration/kinematics, plus add lower bound to dphi cut (hit, track candidate)
  • Loading branch information
cerati authored Aug 13, 2021
2 parents 9a96f65 + 05c0e43 commit 4d97bc1
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 33 deletions.
6 changes: 3 additions & 3 deletions Config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ namespace Config
float RlgridME[Config::nBinsZME][Config::nBinsRME];
float XigridME[Config::nBinsZME][Config::nBinsRME];

float chi2Cut = 15.;
float chi2CutOverlap = 5.;
float pTCutOverlap = 0.;
//float chi2Cut = 15.;
//float chi2CutOverlap = 5.;
//float pTCutOverlap = 0.;

seedOpts seedInput = simSeeds;
cleanOpts seedCleaning = noCleaning;
Expand Down
32 changes: 16 additions & 16 deletions Geoms/CMS-2017.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace
ip.maxCandsPerSeed = 5;
ip.maxHolesPerCand = 4;
ip.maxConsecHoles = 1;
ip.chi2Cut = 30;
ip.chi2Cut_min = 10.0;
ip.chi2CutOverlap = 3.5;
ip.pTCutOverlap = 1;
}
Expand All @@ -110,7 +110,7 @@ namespace
ip.maxCandsPerSeed = 5;
ip.maxHolesPerCand = 4;
ip.maxConsecHoles = 1;
ip.chi2Cut = 30;
ip.chi2Cut_min = 10.0;
ip.chi2CutOverlap = 3.5;
ip.pTCutOverlap = 1;
}
Expand All @@ -120,7 +120,7 @@ namespace
ip.maxCandsPerSeed = 5;
ip.maxHolesPerCand = 4;
ip.maxConsecHoles = 1;
ip.chi2Cut = 30;
ip.chi2Cut_min = 10.0;
ip.chi2CutOverlap = 3.5;
ip.pTCutOverlap = 1;
}
Expand All @@ -130,7 +130,7 @@ namespace
ip.maxCandsPerSeed = 5;
ip.maxHolesPerCand = 4;
ip.maxConsecHoles = 1;
ip.chi2Cut = 30;
ip.chi2Cut_min = 10.0;
ip.chi2CutOverlap = 3.5;
ip.pTCutOverlap = 1;
}
Expand All @@ -140,7 +140,7 @@ namespace
ip.maxCandsPerSeed = 5;
ip.maxHolesPerCand = 4;
ip.maxConsecHoles = 1;
ip.chi2Cut = 30;
ip.chi2Cut_min = 10.0;
ip.chi2CutOverlap = 3.5;
ip.pTCutOverlap = 1;
}
Expand All @@ -150,7 +150,7 @@ namespace
ip.maxCandsPerSeed = 5;
ip.maxHolesPerCand = 4;
ip.maxConsecHoles = 1;
ip.chi2Cut = 30;
ip.chi2Cut_min = 10.0;
ip.chi2CutOverlap = 3.5;
ip.pTCutOverlap = 1;
}
Expand All @@ -160,7 +160,7 @@ namespace
ip.maxCandsPerSeed = 2;
ip.maxHolesPerCand = 4;
ip.maxConsecHoles = 1;
ip.chi2Cut = 30;
ip.chi2Cut_min = 10.0;
ip.chi2CutOverlap = 3.5;
ip.pTCutOverlap = 1;
}
Expand All @@ -170,7 +170,7 @@ namespace
ip.maxCandsPerSeed = 2;
ip.maxHolesPerCand = 0;
ip.maxConsecHoles = 0;
ip.chi2Cut = 30;
ip.chi2Cut_min = 10.0;
ip.chi2CutOverlap = 3.5;
ip.pTCutOverlap = 1;
}
Expand All @@ -180,19 +180,19 @@ namespace
ip.maxCandsPerSeed = 2;
ip.maxHolesPerCand = 0;
ip.maxConsecHoles = 0;
ip.chi2Cut = 30;
ip.chi2Cut_min = 10.0;
ip.chi2CutOverlap = 3.5;
ip.pTCutOverlap = 1;
}
else if (it == 9) // addign also pixel pair step - algo -> 6
{
ip.nlayers_per_seed = 2;
ip.maxCandsPerSeed = 3;
ip.maxHolesPerCand = 4;
ip.maxConsecHoles = 1;
ip.chi2Cut = 30;
ip.chi2CutOverlap = 3.5;
ip.pTCutOverlap = 1;
ip.nlayers_per_seed = 2;
ip.maxCandsPerSeed = 3;
ip.maxHolesPerCand = 4;
ip.maxConsecHoles = 1;
ip.chi2Cut_min = 10.0;
ip.chi2CutOverlap = 3.5;
ip.pTCutOverlap = 1;
}
}

Expand Down
4 changes: 2 additions & 2 deletions TTreeValidation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ void TTreeValidation::initializeConfigTree()

configtree_->Branch("nlayers_per_seed",&nlayers_per_seed_);
configtree_->Branch("maxCand",&maxCand_);
configtree_->Branch("chi2Cut",&chi2Cut_);
configtree_->Branch("chi2Cut_min",&chi2Cut_min_);
configtree_->Branch("nSigma",&nSigma_);
configtree_->Branch("minDPhi",&minDPhi_);
configtree_->Branch("maxDPhi",&maxDPhi_);
Expand Down Expand Up @@ -2379,7 +2379,7 @@ void TTreeValidation::fillConfigTree()

nlayers_per_seed_ = Config::ItrInfo[0].m_params.nlayers_per_seed;
maxCand_ = Config::ItrInfo[0].m_params.maxCandsPerSeed;
chi2Cut_ = Config::ItrInfo[0].m_params.chi2Cut;
chi2Cut_min_ = Config::ItrInfo[0].m_params.chi2Cut_min;
nSigma_ = Config::nSigma;
minDPhi_ = Config::minDPhi;
maxDPhi_ = Config::maxDPhi;
Expand Down
2 changes: 1 addition & 1 deletion TTreeValidation.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class TTreeValidation : public Validation {
float fEtaDet_=0.,fPhiFactor_=0.;
int nPhiPart_=0,nEtaPart_=0;
int nlayers_per_seed_=0,maxCand_=0;
float chi2Cut_=0.,nSigma_=0.,minDPhi_=0.,maxDPhi_=0.,minDEta_=0.,maxDEta_=0.;
float chi2Cut_min_=0.,nSigma_=0.,minDPhi_=0.,maxDPhi_=0.,minDEta_=0.,maxDEta_=0.;
float beamspotX_=0.,beamspotY_=0.,beamspotZ_=0.;
float minSimPt_=0.,maxSimPt_=0.;
float hitposerrXY_=0.,hitposerrZ_=0.,hitposerrR_=0.;
Expand Down
2 changes: 1 addition & 1 deletion mkFit/IterationConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ITCONF_DEFINE_TYPE_NON_INTRUSIVE(mkfit::IterationParams,
/* int */ maxCandsPerSeed,
/* int */ maxHolesPerCand,
/* int */ maxConsecHoles,
/* float */ chi2Cut,
/* float */ chi2Cut_min,
/* float */ chi2CutOverlap,
/* float */ pTCutOverlap,
/* float */ c_ptthr_hpt,
Expand Down
4 changes: 2 additions & 2 deletions mkFit/IterationConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class IterationLayerConfig
float c_dq_1 = 0.0;
float c_dq_2 = 0.0;
//
float c_c2_sf = 1.0;
float c_c2_sf = 1.5;
float c_c2_0 = 0.0;
float c_c2_1 = 0.0;
float c_c2_2 = 0.0;
Expand All @@ -98,7 +98,7 @@ class IterationParams
int maxCandsPerSeed = 5;
int maxHolesPerCand = 4;
int maxConsecHoles = 1;
float chi2Cut = 30;
float chi2Cut_min = 10.0;
float chi2CutOverlap = 3.5;
float pTCutOverlap = 1.0;
// NOTE: iteration params could actually become layer-dependent, e.g., chi2Cut could be larger for first layers (?)
Expand Down
46 changes: 38 additions & 8 deletions mkFit/MkFinder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,42 @@ void MkFinder::getHitSelDynamicWindows(const float invpt, const float theta, flo
float this_dphi = (ILC.c_dp_0)*invpt+(ILC.c_dp_1)*theta+(ILC.c_dp_2);
// In case layer is missing (e.g., seeding layers, or too low stats for training), leave original limits
if(this_dphi>0.f){
min_dphi = (ILC.c_dp_sf)*this_dphi;
if ((theta>0.8f && theta<1.1f) || (ILC.c_dp_sf)*this_dphi>min_dphi){
min_dphi = (ILC.c_dp_sf)*this_dphi;
}
max_dphi = 2.0f*min_dphi;
}

// For future optimization: for layer & iteration dependend hit chi2 cut
//// For future optimization: for layer & iteration dependend hit chi2 cut
//float this_c2 = (ILC.c_c2_0)*invpt+(ILC.c_c2_1)*theta+(ILC.c_c2_2);
//// In case layer is missing (e.g., seeding layers, or too low stats for training), leave original limits
//if(this_c2>0.f){
// max_c2 = (ILC.c_c2_sf)*this_c2;
//}
}


//==============================================================================
// getHitSelDynamicChi2Cut
//==============================================================================
// From HitSelectionWindows.h: track-related config on hit selection windows

inline float MkFinder::getHitSelDynamicChi2Cut(const int itrk, const int ipar)
{
const IterationLayerConfig &ILC = *m_iteration_layer_config;

const float minChi2Cut = m_iteration_params->chi2Cut_min;
const float invpt = Par[ipar].At(itrk,3,0);
const float theta = std::abs(Par[ipar].At(itrk,5,0) - Config::PIOver2);
float this_c2 = ILC.c_c2_0*invpt + ILC.c_c2_1*theta + ILC.c_c2_2;
// In case layer is missing (e.g., seeding layers, or too low stats for training), leave original limits
if (this_c2 > minChi2Cut)
return ILC.c_c2_sf*this_c2;
else
return minChi2Cut;
}


//==============================================================================
// SelectHitIndices
//==============================================================================
Expand Down Expand Up @@ -657,7 +681,7 @@ void MkFinder::AddBestHit(const LayerOfHits &layer_of_hits, const int N_proc,
int bestHit[NN];
// MT: fill_n gave me crap on MIC, NN=8,16, doing in maxSize search below.
// Must be a compiler issue.
// std::fill_n(minChi2, NN, m_iteration_params->chi2Cut);
// std::fill_n(minChi2, NN, m_iteration_params->chi2Cut_min);
// std::fill_n(bestHit, NN, -1);

int maxSize = 0;
Expand All @@ -674,7 +698,7 @@ void MkFinder::AddBestHit(const LayerOfHits &layer_of_hits, const int N_proc,
}

bestHit[it] = -1;
minChi2[it] = m_iteration_params->chi2Cut;
minChi2[it] = getHitSelDynamicChi2Cut(it, iP);
}

for (int hit_cnt = 0; hit_cnt < maxSize; ++hit_cnt)
Expand Down Expand Up @@ -847,11 +871,13 @@ void MkFinder::FindCandidates(const LayerOfHits &layer_of_hits
bool oneCandPassCut = false;
for (int itrack = 0; itrack < N_proc; ++itrack)
{
float max_c2 = getHitSelDynamicChi2Cut(itrack, iP);

if (hit_cnt < XHitSize[itrack])
{
const float chi2 = std::abs(outChi2[itrack]);//fixme negative chi2 sometimes...
dprint("chi2=" << chi2);
if (chi2 < m_iteration_params->chi2Cut)
if (chi2 < max_c2)
{
oneCandPassCut = true;
break;
Expand All @@ -870,15 +896,17 @@ void MkFinder::FindCandidates(const LayerOfHits &layer_of_hits
<< " hit position x=" << msPar.ConstAt(0, 0, 0) << " y=" << msPar.ConstAt(0, 1, 0) << std::endl
<< " updated track parameters x=" << Par[iC].ConstAt(0, 0, 0) << " y=" << Par[iC].ConstAt(0, 1, 0));

//create candidate with hit in case chi2 < m_iteration_params->chi2Cut
//create candidate with hit in case chi2 < m_iteration_params->chi2Cut_min
//fixme: please vectorize me... (not sure it's possible in this case)
for (int itrack = 0; itrack < N_proc; ++itrack)
{
float max_c2 = getHitSelDynamicChi2Cut(itrack, iP);

if (hit_cnt < XHitSize[itrack])
{
const float chi2 = std::abs(outChi2[itrack]);//fixme negative chi2 sometimes...
dprint("chi2=" << chi2);
if (chi2 < m_iteration_params->chi2Cut)
if (chi2 < max_c2)
{
nHitsAdded[itrack]++;
dprint("chi2 cut passed, creating new candidate");
Expand Down Expand Up @@ -1003,13 +1031,15 @@ void MkFinder::FindCandidatesCloneEngine(const LayerOfHits &layer_of_hits, CandC
{
// make sure the hit was in the compatiblity window for the candidate

float max_c2 = getHitSelDynamicChi2Cut(itrack, iP);

if (hit_cnt < XHitSize[itrack])
{
// XXX-NUM-ERR assert(chi2 >= 0);
const float chi2 = std::abs(outChi2[itrack]); //fixme negative chi2 sometimes...

dprint("chi2=" << chi2 << " for trkIdx=" << itrack << " hitIdx=" << XHitArr.At(itrack, hit_cnt, 0));
if (chi2 < m_iteration_params->chi2Cut)
if (chi2 < max_c2)
{
nHitsAdded[itrack]++;
const int hit_idx = XHitArr.At(itrack, hit_cnt, 0);
Expand Down
2 changes: 2 additions & 0 deletions mkFit/MkFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ class MkFinder : public MkBase

void getHitSelDynamicWindows(const float invpt, const float theta, float &min_dq, float &max_dq, float &min_dphi, float &max_dphi);

float getHitSelDynamicChi2Cut(const int itrk, const int ipar);

void SelectHitIndices(const LayerOfHits &layer_of_hits, const int N_proc);

void AddBestHit(const LayerOfHits &layer_of_hits, const int N_proc,
Expand Down

0 comments on commit 4d97bc1

Please sign in to comment.