All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrainMVA.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
4 BKGFILES=''
5 JOBNAME=''
6 
7 while getopts "s:b:j:" opt; do
8  case $opt in
9  s)
10  SIGFILES="$SIGFILES $OPTARG"
11  ;;
12  b)
13  BKGFILES="$BKGFILES $OPTARG"
14  ;;
15  j)
16  JOBNAME=$OPTARG
17  ;;
18  \?)
19  echo "Invalid option: -$OPTARG" >&2
20  exit 1
21  ;;
22  :)
23  echo "Option -$OPTARG requires an argument." >&2
24  exit 1
25  ;;
26  esac
27 done
28 
29 echo "Signal files are:"
30 for i in $SIGFILES;do echo $i;done
31 echo "Background files are:"
32 for i in $BKGFILES;do echo $i;done
33 echo "Job name is $JOBNAME"
34 
35 #Hmm, when using mrb then $LARANA_DIR points to source tree, but
36 #in installed version then need to add source to path
37 if [ -d $LARANA_DIR/source ]; then
38  cp $LARANA_DIR/source/ParticleIdentification/scripts/TrainMVA.C ./
39  cp $LARANA_DIR/source/ParticleIdentification/scripts/runPID_noMVA.fcl ./
40 else
41  cp $LARANA_DIR/ParticleIdentification/scripts/TrainMVA.C ./
42  cp $LARANA_DIR/ParticleIdentification/scripts/runPID_noMVA.fcl ./
43 fi
44 
45 if [ -d $LARDATA_DIR/source ]; then
46  cp $LARDATA_DIR/source/AnalysisBase/MVAPIDResult.h ./
47 else
48  cp $LARDATA_DIR/AnalysisBase/MVAPIDResult.h ./
49 fi
50 
51 
52 ##Build CINT dictionary for the MVAResult class
53 echo '
54 #pragma link C++ class anab::MVAPIDResult+;
55 #pragma link C++ class vector<anab::MVAPIDResult>+;
56 #pragma link C++ class map<string,double>+;
57 ' > Linkdef.h
58 
59 rootcint -f MVAResultDict.cxx -c $LARDATA_DIR/AnalysisBase/MVAPIDResult.h Linkdef.h
60 g++ -shared -o MVAResultDict.so `root-config --ldflags` -fPIC -I$ROOTSYS/include MVAResultDict.cxx
61 rm -f MVAResultDict.cxx MVAResultDict.h Linkdef.h
62 
63 ROOTSCRIPT=`mktemp`
64 echo "
65 {
66 gROOT->ProcessLine(\"gSystem->Load(\\\"MVAResultDict.so\\\")\");
67 gROOT->ProcessLine(\".L TrainMVA.C\");
68 std::vector<std::string> sigFiles, bkgFiles;" > $ROOTSCRIPT
69 
70 for i in $SIGFILES
71 do
72 lar -c ./runPID_noMVA.fcl -s $i -n 100000
73 TUPLEFILE=ntuple_`basename $i`
74 mv ntuple.root $TUPLEFILE
75 echo "
76 BuildTree(\"${TUPLEFILE}\",\"train_"`basename $i`"\");
77 sigFiles.push_back(\"train_"`basename $i`"\");" >> $ROOTSCRIPT
78 done
79 
80 for i in $BKGFILES
81 do
82 mv ntuple.root ntuple_$i
83 lar -c ./runPID_noMVA.fcl -s $i -n 100000
84 TUPLEFILE=ntuple_`basename $i`
85 mv ntuple.root $TUPLEFILE
86 echo "
87 BuildTree(\"${TUPLEFILE}\",\"train_"`basename $i`"\");
88 bkgFiles.push_back(\"train_"`basename $i`"\");" >> $ROOTSCRIPT
89 done
90 
91 echo "
92 TrainMVA(sigFiles,bkgFiles,\"mvaPlots.root\",\"$JOBNAME\");
93 }
94 " >> $ROOTSCRIPT
95 
96 cat $ROOTSCRIPT
97 
98 root -l -b -q $ROOTSCRIPT
see a below echo or echo I(indirect symbol).'echo" If the symbol is local (non-external)
j JOBNAME
Definition: TrainMVA.sh:16
do source
BEGIN_PROLOG g
while getopts
BEGIN_PROLOG ntuple
Definition: genie.fcl:8
BEGIN_PROLOG dataFFTHistosEW root
SIGFILES
Definition: TrainMVA.sh:3
b BKGFILES
Definition: TrainMVA.sh:13
then shift fi
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
then echo File list $list not found else cat $list while read file do echo $file sed s
Definition: file_to_url.sh:60
do echo $i
Definition: TrainMVA.sh:30