1 | NICE="nice -n10"
|
---|
2 | RANGER=~/SW/ranger/build/ranger
|
---|
3 | ROOT2CSV=~/SW/FACT++/build/root2csv
|
---|
4 | CSV2ROOT=~/SW/FACT++/build/csv2root
|
---|
5 | OUT=ranger.csv
|
---|
6 | TRAINRATIO=0.7
|
---|
7 | #TREE=Events
|
---|
8 |
|
---|
9 | # Classical reconstruction parameters
|
---|
10 | TRUEVAR="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 |
|
---|
22 | echo --------------------------------- Creating input files -------------------------
|
---|
23 |
|
---|
24 | cat > ${OUT}.rc <<EOF
|
---|
25 | # Do some magic to simplify the leaf names
|
---|
26 | auto-alias=MHillas.f/
|
---|
27 | auto-alias=MHillasSrc.f/
|
---|
28 | auto-alias=MHillasExt.f/
|
---|
29 | auto-alias=MNewImagePar.f/
|
---|
30 | auto-alias=MMcEvt.MMcEvtBasic.f/
|
---|
31 | auto-alias=MCorsikaEvtHeader.f/
|
---|
32 |
|
---|
33 | # Some cuts to remove events with strange contents
|
---|
34 | selector=lgArea>-1 && abs(SlopeTrans/conv)<2.5
|
---|
35 |
|
---|
36 | # Define some alias for easier use and use in the selector
|
---|
37 | [alias]
|
---|
38 | conv=1.14112295210361481e-01
|
---|
39 | lgArea=log10(TMath::TwoPi()*Width*Length*conv^2)
|
---|
40 | GroundR=sqrt(X*X + Y*Y)
|
---|
41 | GroundPhi=atan2(Y, X)
|
---|
42 |
|
---|
43 | # Add additonal columns
|
---|
44 | [add]
|
---|
45 | lgSize = log10(Size)
|
---|
46 | lgArea = lgArea
|
---|
47 | WovL = Width/Length
|
---|
48 | Width = Width*conv
|
---|
49 | Length = Length*conv
|
---|
50 | Dist = Dist*conv
|
---|
51 | Delta = Delta
|
---|
52 | Angle = atan2(MeanX, MeanY)
|
---|
53 | M3L = M3Long*sign(CosDeltaAlpha)*conv
|
---|
54 | M3T = M3Trans*conv
|
---|
55 | Asym = Asym*conv
|
---|
56 | Alpha = Alpha
|
---|
57 | Leakage1 = Leakage1
|
---|
58 | Leakage2 = Leakage2
|
---|
59 | Conc1 = Conc1
|
---|
60 | ConcCore = ConcCore
|
---|
61 | ConcCOG = ConcCOG
|
---|
62 | SlopeL = SlopeLong*sign(CosDeltaAlpha)/conv
|
---|
63 | SlopeT = SlopeTrans/conv
|
---|
64 | MeanX = MeanX
|
---|
65 | MeanY = MeanY
|
---|
66 |
|
---|
67 | TimeSpread = TimeSpread
|
---|
68 | SlopeSpread = SlopeSpread
|
---|
69 |
|
---|
70 | CosDeltaAlpha = CosDeltaAlpha
|
---|
71 | NumUsedPixels = NumUsedPixels
|
---|
72 |
|
---|
73 | TimeSpreadWeighted = TimeSpreadWeighted
|
---|
74 | SlopeSpredWeighted = SlopeSpreadWeighted
|
---|
75 |
|
---|
76 | # Be careful, this is true MC information
|
---|
77 | #GroundR = GroundR
|
---|
78 | #GroundPhi = GroundPhi
|
---|
79 | #GroundX = X
|
---|
80 | #GroundY = Y
|
---|
81 | EOF
|
---|
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 |
|
---|
90 | if [ $? != 0 ]; then
|
---|
91 | exit 1
|
---|
92 | fi
|
---|
93 |
|
---|
94 | TRAIN=${OUT}-0
|
---|
95 | TEST=${OUT}-1
|
---|
96 |
|
---|
97 | # Training
|
---|
98 | echo ------------------------------------- Training ---------------------------------
|
---|
99 | ${NICE} ${RANGER} \
|
---|
100 | --file ${TRAIN} --outprefix ${OUT} --depvarname True \
|
---|
101 | --verbose --treetype 3 --impmeasure 1 --write
|
---|
102 | if [ $? != 0 ]; then
|
---|
103 | exit 1
|
---|
104 | fi
|
---|
105 |
|
---|
106 | echo ""
|
---|
107 | cat ${OUT}.importance | sed -E 's/([^:]*): (.*)/\2: \1/g' | LC_ALL=C sort -g -r
|
---|
108 | echo ""
|
---|
109 | #cat ${OUT}.confusion
|
---|
110 | #echo ""
|
---|
111 |
|
---|
112 | # Testing
|
---|
113 | echo ------------------------------------- Testing ----------------------------------
|
---|
114 | ${NICE} ${RANGER} \
|
---|
115 | --file ${TEST} --outprefix ${OUT} --predict ${OUT}.forest \
|
---|
116 | --verbose --treetype 3
|
---|
117 | if [ $? != 0 ]; then
|
---|
118 | exit 1
|
---|
119 | fi
|
---|
120 |
|
---|
121 | echo --------------------------------- Creating root file ---------------------------
|
---|
122 | ${NICE} ${CSV2ROOT} ${TEST} ${OUT}.root ${TREE} --force
|
---|
123 | if [ $? != 0 ]; then
|
---|
124 | exit 1
|
---|
125 | fi
|
---|
126 |
|
---|
127 | ${NICE} ${CSV2ROOT} ${OUT}.prediction ${OUT}.root ${TREE} --update
|
---|
128 | if [ $? != 0 ]; then
|
---|
129 | exit 1
|
---|
130 | fi
|
---|