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

Last change on this file since 19812 was 19812, checked in by tbretz, 5 years ago
Improvements. Added 'Fake HAWC variables', added the possibility to train Core location on the ground, added how to change tree output name, improved selector, exit when ranger fails.
  • Property svn:executable set to *
File size: 3.0 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#TREE=Events
8
9# Classical reconstruction parameters
10TRUEVAR="log10(Energy)"
11#TRUEVAR="Phi*TMath::RadToDeg()"
12#TRUEVAR="Theta*TMath::RadToDeg()"
13#TRUEVAR="MeanX*conv"
14#TRUEVAR="MeanY*conv"
15
16# Impact on ground (We can not use GroundR here, see --no-indirection)
17#TRUEVAR="GroundR"
18#TRUEVAR="GroundPhi"
19#TRUEVAR="X"
20#TRUEVAR="Y"
21
22echo --------------------------------- Creating input files -------------------------
23
24cat > ${OUT}.rc <<EOF
25# Do some magic to simplify the leaf names
26auto-alias=MHillas.f/
27auto-alias=MHillasSrc.f/
28auto-alias=MHillasExt.f/
29auto-alias=MNewImagePar.f/
30auto-alias=MMcEvt.MMcEvtBasic.f/
31auto-alias=MCorsikaEvtHeader.f/
32
33# Some cuts to remove events with strange contents
34selector=lgArea>-1 && abs(SlopeTrans/conv)<2.5
35
36# Define some alias for easier use and use in the selector
37[alias]
38conv=1.14112295210361481e-01
39lgArea=log10(TMath::TwoPi()*Width*Length*conv^2)
40GroundR=sqrt(X*X + Y*Y)
41GroundPhi=atan2(Y, X)
42
43# Add additonal columns
44[add]
45lgSize = log10(Size)
46lgArea = lgArea
47WovL = Width/Length
48Width = Width*conv
49Length = Length*conv
50Dist = Dist*conv
51Delta = Delta
52Angle = atan2(MeanX, MeanY)
53M3L = M3Long*sign(CosDeltaAlpha)*conv
54M3T = M3Trans*conv
55Asym = Asym*conv
56Alpha = Alpha
57Leakage1 = Leakage1
58Leakage2 = Leakage2
59Conc1 = Conc1
60ConcCore = ConcCore
61ConcCOG = ConcCOG
62SlopeL = SlopeLong*sign(CosDeltaAlpha)/conv
63SlopeT = SlopeTrans/conv
64MeanX = MeanX
65MeanY = MeanY
66
67TimeSpread = TimeSpread
68SlopeSpread = SlopeSpread
69
70CosDeltaAlpha = CosDeltaAlpha
71NumUsedPixels = NumUsedPixels
72
73TimeSpreadWeighted = TimeSpreadWeighted
74SlopeSpredWeighted = SlopeSpreadWeighted
75
76# Be careful, this is true MC information
77#GroundR = GroundR
78#GroundPhi = GroundPhi
79#GroundX = X
80#GroundY = Y
81EOF
82
83# Write files
84${NICE} ${ROOT2CSV} \
85 "~/SW/data/star/*_Events.root" -o ${OUT} --config ${OUT}.rc \
86 --force --header 1 --skip \
87 --split-quantile=${TRAINRATIO} \
88 --add.True=${TRUEVAR}
89
90if [ $? != 0 ]; then
91 exit 1
92fi
93
94TRAIN=${OUT}-0
95TEST=${OUT}-1
96
97# Training
98echo ------------------------------------- Training ---------------------------------
99${NICE} ${RANGER} \
100 --file ${TRAIN} --outprefix ${OUT} --depvarname True \
101 --verbose --treetype 3 --impmeasure 1 --write
102if [ $? != 0 ]; then
103 exit 1
104fi
105
106echo ""
107cat ${OUT}.importance | sed -E 's/([^:]*): (.*)/\2: \1/g' | LC_ALL=C sort -g -r
108echo ""
109#cat ${OUT}.confusion
110#echo ""
111
112# Testing
113echo ------------------------------------- Testing ----------------------------------
114${NICE} ${RANGER} \
115 --file ${TEST} --outprefix ${OUT} --predict ${OUT}.forest \
116 --verbose --treetype 3
117if [ $? != 0 ]; then
118 exit 1
119fi
120
121echo --------------------------------- Creating root file ---------------------------
122${NICE} ${CSV2ROOT} ${TEST} ${OUT}.root ${TREE} --force
123if [ $? != 0 ]; then
124 exit 1
125fi
126
127${NICE} ${CSV2ROOT} ${OUT}.prediction ${OUT}.root ${TREE} --update
128if [ $? != 0 ]; then
129 exit 1
130fi
Note: See TracBrowser for help on using the repository browser.