Skip to content

Commit

Permalink
ANNZ v2.3.2
Browse files Browse the repository at this point in the history
Bug fixes for root v6.22
  • Loading branch information
IftachSadeh committed Dec 15, 2020
1 parent 88e2759 commit dd4ed16
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## ANNZ v2.3.2 (15/12/2020)

- Fixed bugs related to ROOT v6.22/06 upgrade.

## ANNZ v2.3.1 (12/12/2018)

- Updated `py/ANNZ.py` and `scripts/annz_evalWrapper.py` for `python-3.6` compatibility.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ANNZ v2.3.1
# ANNZ v2.3.2

## Introduction
ANNZ uses both regression and classification techniques for estimation of single-value photo-z (or any regression problem) solutions and PDFs. In addition it is suitable for classification problems, such as star/galaxy classification.
Expand Down Expand Up @@ -81,7 +81,7 @@ useDefinedROOTSYS = True

It is also recommended to add the installation directory to the `PYTHONPATH` system variable:
```bash
export PYTHONPATH=/home/work/annz:$PYTHONPATH
export PYTHONPATH=/home/work/annz:/home/work/annz/examples:$PYTHONPATH
```
This may be needed for `python` to recognize the sub-directory package structure, where scripts are imported with e.g., `from scripts.helperFuncs import *` statements.

Expand Down
5 changes: 5 additions & 0 deletions examples/scripts/annz_rndReg_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@
glob.annz["max_bias_PDF"] = 0.01
glob.annz["max_frac68_PDF"] = 0.10

# --------------------------------------------------------------------------------------------------
# set the minimal acceptable number of MLMs used to generate PDFs
# (in practice, it's recommended to keep this number high...)
# --------------------------------------------------------------------------------------------------
glob.annz["minAcptMLMsForPDFs"] = 3

# --------------------------------------------------------------------------------------------------
# optimization
Expand Down
2 changes: 1 addition & 1 deletion examples/scripts/helperFuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def runANNZ():
# --------------------------------------------------------------------------------------------------
if glob.annz["doTrain"]:
# set random seed if not already set
setSeed = (not glob.annz.has_key("initSeedRnd"))
setSeed = "initSeedRnd" not in glob.annz.keys()
if not setSeed: setSeed = (glob.annz["initSeedRnd"] < 1)
if setSeed: glob.annz["initSeedRnd"] = 198876

Expand Down
5 changes: 3 additions & 2 deletions src/ANNZ_regEval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,10 @@ void ANNZ::evalRegSetup() {
for(int nBinXnow=1; nBinXnow<nPDFbins+1; nBinXnow++) {
hisName = (TString)hisPdfBiasCorV[nPDFnow]->GetName()+"_"+utils->intToStr(nBinXnow);

double intgr = hisPdfBiasCorV[nPDFnow]->Integral(nBinXnow,nBinXnow); if(intgr < EPS) continue;

TH1 * his1 = (TH1*)hisPdfBiasCorV[nPDFnow]->ProjectionY(hisName,nBinXnow,nBinXnow,"e");

double intgr = his1->Integral(); if(intgr < EPS) continue;

his1->Scale(1/intgr);

for(int nBinYnow=1; nBinYnow<his1->GetNbinsX()+1; nBinYnow++) {
Expand Down
32 changes: 17 additions & 15 deletions src/VarMaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ void VarMaps::connectTreeBranches(TTree * tree, vector <TString> * excludedBranc
TString brnchTitle = aBranch->GetTitle();
TString brnchType = (brnchTitle.Length() > 2) ? brnchTitle(brnchTitle.Length()-2,brnchTitle.Length()) : (TString)"";

bool skipBranch(false);
bool skipBranch(false), registerBranch(true);
// cout <<"XXXXXXXXXX "<< nBrnchNow <<CT<< brnchName<<endl;

// test for array variables, which e.g., have the format "varName[4]/D"
Expand All @@ -1084,15 +1084,6 @@ void VarMaps::connectTreeBranches(TTree * tree, vector <TString> * excludedBranc
skipBranch = true;
}

if(!skipBranch) {
// count number of times a branch is accepted
nBranchesVar[brnchName]++;
// exclude repeate variables from tree friends
// -----------------------------------------------------------------------------------------------------------
if(nTreeNow > 0 && nBranchesVar[brnchName] > 1) {
skipBranch = true; nBranchesVar[brnchName]--; assert(nBranchesVar[brnchName] == 1);
}
}
if(debug) {
if(skipBranch) {
aCustomLOG("connectTreeBranches()") <<coutPurple<<"Skip connect branch: "<<coutRed<<std::setw(width)<<brnchName
Expand All @@ -1103,16 +1094,26 @@ void VarMaps::connectTreeBranches(TTree * tree, vector <TString> * excludedBranc
<<CT<<coutBlue<<std::setw(width)<<brnchTitle<<CT<<brnchType<<coutDef<<endl;
}
}

if(skipBranch) treeNow->SetBranchStatus(brnchName,0);
else treeNow->SetBranchStatus(brnchName,1);

treeNow->SetBranchStatus(brnchName, skipBranch ? 0 : 1);

// -----------------------------------------------------------------------------------------------------------
// exclude repeate variables from being registered multiple times
// -----------------------------------------------------------------------------------------------------------
if(!skipBranch) {
// count number of times a branch is accepted
nBranchesVar[brnchName]++;
if(nTreeNow > 0 && nBranchesVar[brnchName] > 1) {
registerBranch = false; nBranchesVar[brnchName]--; assert(nBranchesVar[brnchName] == 1);
}
}

// -----------------------------------------------------------------------------------------------------------
// make sure all variables which will be connected to the tree are declared first. this is done
// before actually setting any branch address in order to avoid changes of variable address as
// the maps are filled up.
// -----------------------------------------------------------------------------------------------------------
if(!skipBranch) {
if(registerBranch) {
if (brnchType == "/I") NewVarI_ (brnchName,DefOpts::DefI);
else if(brnchType == "/F") NewVarF_ (brnchName,DefOpts::DefF);
else if(brnchType == "/O") NewVarB_ (brnchName,DefOpts::DefB);
Expand All @@ -1131,8 +1132,9 @@ void VarMaps::connectTreeBranches(TTree * tree, vector <TString> * excludedBranc
}
NewVarC_(brnchName,DefOpts::DefC);
}

registeredBranches[nTreeNow].push_back(brnchName);
}
if(!skipBranch) registeredBranches[nTreeNow].push_back(brnchName);
}
}
}
Expand Down

0 comments on commit dd4ed16

Please sign in to comment.