source: trunk/Mars/hawc/runranger.sh@ 19800

Last change on this file since 19800 was 19800, checked in by tbretz, 5 years ago
We can use the default mem mode... there is no issue with memory and it is not slower.
  • Property svn:executable set to *
File size: 2.6 KB
Line 
1NICE="nice -n10"
2RANGER=~/SW/ranger/build/ranger
3ROOT2CSV=~/SW/FACT++/build/root2csv
4CSV2ROOT=~/SW/FACT++/build/csv2root
5OUT=ranger.csv
6TRAINRATIO=0.7
7
8TRUEVAR="log10(Energy)"
9#TRUEVAR="Phi*TMath::RadToDeg()"
10#TRUEVAR="Theta*TMath::RadToDeg()"
11#TRUEVAR="MeanX*conv"
12#TRUEVAR="MeanY*conv"
13
14echo --------------------------------- Creating input files -------------------------
15
16cat > ${OUT}.rc <<EOF
17# Do some magic to simplify the leaf names
18auto-alias=MHillas.f/
19auto-alias=MHillasSrc.f/
20auto-alias=MHillasExt.f/
21auto-alias=MNewImagePar.f/
22auto-alias=MMcEvt.MMcEvtBasic.f/
23
24# Some cuts to remove events with strange contents
25selector=NumUsedPixels>2.5 && lgArea>-1 && abs(SlopeTrans/conv)<1
26
27# Define some alias for easier use and use in the selector
28[alias]
29conv=1.14112295210361481e-01
30lgArea=log10(TMath::TwoPi()*Width*Length*conv^2)
31
32# Add additonal columns
33[add]
34lgSize = log10(Size)
35lgArea = lgArea
36WovL = Width/Length
37Width = Width*conv
38Length = Length*conv
39Dist = Dist*conv
40Delta = Delta
41Angle = atan2(MeanX, MeanY)
42M3L = M3Long*TMath::Sign(1, CosDeltaAlpha)*conv
43M3T = M3Trans*conv
44Asym = Asym*conv
45Alpha = Alpha
46Leakage1 = Leakage1
47Leakage2 = Leakage2
48Conc1 = Conc1
49ConcCore = ConcCore
50ConcCOG = ConcCOG
51SlopeL = SlopeLong*TMath::Sign(1, CosDeltaAlpha)/conv
52SlopeT = SlopeTrans/conv
53
54TimeSpread = TimeSpread
55SlopeSpread = SlopeSpread
56
57CosDeltaAlpha = CosDeltaAlpha
58NumUsedPixels = NumUsedPixels
59
60TimeSpreadWeighted = TimeSpreadWeighted
61SlopeSpredWeighted = SlopeSpreadWeighted
62EOF
63
64# Write files
65${NICE} ${ROOT2CSV} \
66 "~/SW/data/star/*_Events.root" -o ${OUT} --config ${OUT}.rc \
67 --force --header 1 --skip \
68 --split-quantile=${TRAINRATIO} \
69 --add.True=${TRUEVAR}
70
71if [ $? != 0 ]; then
72 exit
73fi
74
75TRAIN=${OUT}-0
76TEST=${OUT}-1
77
78# Training
79echo ------------------------------------- Training ---------------------------------
80${NICE} ${RANGER} \
81 --file ${TRAIN} --outprefix ${OUT} --depvarname True \
82 --verbose --treetype 3 --impmeasure 1 --write
83
84echo ""
85cat ${OUT}.importance | sed -E 's/([^:]*): (.*)/\2: \1/g' | LC_ALL=C sort -g -r
86echo ""
87#cat ${OUT}.confusion
88#echo ""
89
90# Testing
91echo ------------------------------------- Testing ----------------------------------
92${NICE} ${RANGER} \
93 --file ${TEST} --outprefix ${OUT} --predict ${OUT}.forest \
94 --verbose --treetype 3
95
96echo --------------------------------- Creating root file ---------------------------
97${NICE} ${CSV2ROOT} ${TEST} ${OUT}.root --force
98if [ $? != 0 ]; then
99 exit
100fi
101
102${NICE} ${CSV2ROOT} ${OUT}.prediction ${OUT}.root --update
103if [ $? != 0 ]; then
104 exit
105fi
Note: See TracBrowser for help on using the repository browser.