Skip to content

Commit

Permalink
Fixed seg fault bug
Browse files Browse the repository at this point in the history
- Fixed bug which caused a segmentation fault in some cases during
reweighting.
  • Loading branch information
IftachSadeh committed Oct 29, 2016
1 parent a336e14 commit a3de6e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

- Modified `subprocess.check_output()` in `examples/scripts/annz_qsub.py , fitsFuncs.py` for `Python 3.x`.

- Fixed bug which caused a segmentation fault in some cases during reweighting.

- Other minor modifications and bug fixes.

## ANNZ v2.2.0 (24/5/2016)
Expand Down
5 changes: 4 additions & 1 deletion src/CatFormat_wgtKNN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@ void CatFormat::addWgtKNNtoTree(TChain * aChainInp, TChain * aChainRef, TChain *
,(knnErrMethod[nChainNow][nFracNow]->fScaleFrac < EPS));
nKnnFracsIn++;
}

// final check on nKnnFracs - at least two knnErrModule need to be accepted
VERIFY(LOCATION,(TString)"Could not find enough objects for the KNN search."
+" Try to decrease the value of "+"minNobjInVol"+typePostfix+" ...",(nKnnFracsIn > 1));
Expand Down Expand Up @@ -659,7 +660,6 @@ void CatFormat::addWgtKNNtoTree(TChain * aChainInp, TChain * aChainRef, TChain *
// find the same number of near neighbours for each chain, and derive the distance this requires
int nObjKNN(minNobjInVol);
for(int nChainNow=0; nChainNow<2; nChainNow++) {

knnErrModule[nChainNow][0]->Find(evtNow,nObjKNN);
const TMVA::kNN::List & knnList = knnErrModule[nChainNow][0]->GetkNNList();

Expand Down Expand Up @@ -714,6 +714,7 @@ void CatFormat::addWgtKNNtoTree(TChain * aChainInp, TChain * aChainRef, TChain *
}
}
}

if(foundDist) { var_0->IncCntr("Found good weight"); weightSum += weightKNN; }
else { var_0->IncCntr("Did not find good weight"); }
}
Expand Down Expand Up @@ -744,6 +745,8 @@ void CatFormat::addWgtKNNtoTree(TChain * aChainInp, TChain * aChainRef, TChain *
bool foundDist(false);
double dist_Ref0_RefNear(0);
for(int nFracNow=0; nFracNow<nKnnFracs; nFracNow++) {
if(!knnErrModule[1][nFracNow]) break;

double wgtSum_Ref0_RefNear = 0;
double minNobjInVolWgt = minNobjInVol * wgt_Ref_Inp / pow(knnFracFact,nFracNow);

Expand Down

0 comments on commit a3de6e3

Please sign in to comment.