From 2bd580c456c1da40f2a05b21eda78cd2698a0b27 Mon Sep 17 00:00:00 2001
From: Louie <louie.dartmoor.corpe@cern.ch>
Date: Thu, 10 Sep 2020 17:01:02 +0200
Subject: [PATCH] add the syst databases to data, and small tweaks to setup
 scripts

---
 Generators/PMGSystematicsTools/CMakeLists.txt             | 2 +-
 .../PMGSystematicsTools/local/bin/systematicsTool.py      | 8 ++++----
 .../PMGSystematicsTools/share/setupPMGSystematicsTool.sh  | 4 ++++
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/Generators/PMGSystematicsTools/CMakeLists.txt b/Generators/PMGSystematicsTools/CMakeLists.txt
index 261a0001caf3..db3709024d00 100644
--- a/Generators/PMGSystematicsTools/CMakeLists.txt
+++ b/Generators/PMGSystematicsTools/CMakeLists.txt
@@ -19,7 +19,7 @@ find_package( YODA )
 
 # Install files from the package:
 atlas_install_python_modules( local/bin/*.py )
-atlas_install_scripts(share/*.sh)
+atlas_install_data( data/*.yaml )
 atlas_install_scripts( local/bin/*.py )
 
 # Aliases:
diff --git a/Generators/PMGSystematicsTools/local/bin/systematicsTool.py b/Generators/PMGSystematicsTools/local/bin/systematicsTool.py
index f3a5ad6d1a8d..03528b36ff8a 100755
--- a/Generators/PMGSystematicsTools/local/bin/systematicsTool.py
+++ b/Generators/PMGSystematicsTools/local/bin/systematicsTool.py
@@ -51,7 +51,7 @@ try:
   import numpy as np
 except:
   print("[ERROR], looks like the YODA, YAML, LHAPDF or NUMPy packages are not installed. Please run this command and try again:")
-  print("setupPMGSystematicsTool.sh")
+  print("source setupPMGSystematicsTool.sh")
   exit(1)
 import cPickle as pickle
 import os, sys, re
@@ -240,7 +240,7 @@ def getXS(dsid, campaign=15, userFile=None):
     campaign=14
   # this triggers a search in the manual, local XS file
   if campaign>16 or campaign < 15:
-    dataDir=os.environ["SYSTTOOLSPATH"]+"/data/"
+    dataDir=os.environ["SYSTTOOLSPATH"]+"/data/PMGSystematicsTools"
     if userFile is None:
       pmgXSFile="%s/PMGxsecDB_manual.txt" %dataDir
     else:
@@ -1458,7 +1458,7 @@ def makeSystematicsPlotsWithROOT(mergedSystDict, outdir, nominalName="Nominal",
      aos_ratio[aoNameNoRef][fn]= arrayDictToTGraph(ao,False, setYErrorsToZero, nfr)
      
      # this is the best guess as to where the reference data might be !
-     dataDir=os.environ["SYSTTOOLSPATH"]+"/data/"
+     dataDir=os.environ["SYSTTOOLSPATH"]+"/data/PMGSystematicsTools"
      rivetAnalysis=aoName.split("/")[1] if len(aoName.split("/"))>1 else ""
      pathInRivetEnv="%s/Rivet/%s.yoda"%(RIVET_ANALYSIS_PATH ,rivetAnalysis)
      # for the first file, also get the .plot which will be needed to format
@@ -1893,7 +1893,7 @@ def getCombinationRecipe(systWeights,  combinationRecipeFile=None, combinationRe
     if combinationRecipeFile is not None:
       data=yaml.load(open(combinationRecipeFile,'r'))
     else:
-      data=yaml.load(open('%s/data/Syst_Database.yaml'%dataBaseDir,'r'))
+      data=yaml.load(open('%s/data/PMGSystematicsTools/Syst_Database.yaml'%dataBaseDir,'r'))
     for recipe, details in data.items():
       if combinationRecipeName is not None:
         if recipe==combinationRecipeName:
diff --git a/Generators/PMGSystematicsTools/share/setupPMGSystematicsTool.sh b/Generators/PMGSystematicsTools/share/setupPMGSystematicsTool.sh
index 4890cc750ccc..e45ca7521000 100644
--- a/Generators/PMGSystematicsTools/share/setupPMGSystematicsTool.sh
+++ b/Generators/PMGSystematicsTools/share/setupPMGSystematicsTool.sh
@@ -15,3 +15,7 @@ if [ -e /usr/lib64/atlas/libsatlas.so ]; then
    fi
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$workaroundLib"
 fi
+toolpath=`which systematicsTool.py`
+tooldir=`dirname $toolpath`
+export SYSTTOOLSPATH=`dirname ${tooldir}` 
+export PYTHONPATH=$PYTHONPATH:${tooldir}
-- 
GitLab