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

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