1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Thomas Bretz, 11/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2006
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== *//////////////////////////////////////////////////////////////////////////////
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // trainenergy.C
|
---|
28 | // =============
|
---|
29 | //
|
---|
30 | // Trains a random forest for energy estimation.
|
---|
31 | //
|
---|
32 | // The additional code below shows how the MagicCuts can be used in
|
---|
33 | // training and testing. There is also code which allows to change the
|
---|
34 | // slope of the input spectrum. If a min- or max-break energy is given
|
---|
35 | // the new slope is only applied in this region. Further possibilities
|
---|
36 | // for additional cuts are shown.
|
---|
37 | //
|
---|
38 | /////////////////////////////////////////////////////////////////////////////
|
---|
39 | void trainenergy()
|
---|
40 | {
|
---|
41 | MDataSet set("mcdataset.txt");
|
---|
42 | set.SetNumAnalysis(1); // Necessary
|
---|
43 |
|
---|
44 | MJTrainEnergy opt;
|
---|
45 | //opt.SetDebug();
|
---|
46 |
|
---|
47 | // ------- Parameters to train Random Forest --------
|
---|
48 | opt.AddParameter("MHillas.fSize");
|
---|
49 | opt.AddParameter("MHillasSrc.fDist");
|
---|
50 | opt.AddParameter("MPointingPos.fZd");
|
---|
51 | opt.AddParameter("MHillas.GetArea");
|
---|
52 | opt.AddParameter("MNewImagePar.fUsedArea");
|
---|
53 | opt.AddParameter("MNewImagePar.fCoreArea");
|
---|
54 | opt.AddParameter("MNewImagePar.fLeakage1");
|
---|
55 | opt.AddParameter("MNewImagePar.fLeakage2");
|
---|
56 | opt.AddParameter("MNewImagePar.fConc");
|
---|
57 | opt.AddParameter("MNewImagePar.fConc1");
|
---|
58 |
|
---|
59 | // -------------------- Run ----------------------------
|
---|
60 |
|
---|
61 | MStatusDisplay *d = new MStatusDisplay;
|
---|
62 | opt.SetDisplay(d);
|
---|
63 |
|
---|
64 | /*
|
---|
65 | -------------------- Magic-Cuts ----------------------
|
---|
66 | MFMagicCuts cuts;
|
---|
67 | cuts.SetHadronnessCut(MFMagicCuts::kArea);
|
---|
68 | cuts.SetThetaCut(MFMagicCuts::kOn);
|
---|
69 |
|
---|
70 | TArrayD arr(10);
|
---|
71 | arr[0]= 1.3245;
|
---|
72 | arr[1]= 0.208700;
|
---|
73 | arr[2]= 0.229200;
|
---|
74 | arr[3]= 5.305200;
|
---|
75 | arr[4]= 0.098930;
|
---|
76 | arr[5]= -0.082950;
|
---|
77 | arr[6]= 8.2957;
|
---|
78 | arr[7]= 0.8677;
|
---|
79 |
|
---|
80 | cuts.SetVariables(arr);
|
---|
81 |
|
---|
82 | opt.AddPreCut(&cuts);
|
---|
83 |
|
---|
84 | -------------------- Energy Slope --------------------
|
---|
85 | MFEnergySlope slope(-2.8); // New slope for mc spectrum
|
---|
86 | slope.SetMcMinEnergy(80); // Set break energy from -2.6 to -2.8
|
---|
87 | opt.AddPreCut(&slope); // throw away events to change slope
|
---|
88 |
|
---|
89 | -------------------- Other cuts ----------------------
|
---|
90 | opt.AddPreCut("MHillasSrc.fDist*MGeomCam.fConvMm2Deg<1.0");
|
---|
91 | opt.AddPreCut("MHillas.fSize>200");
|
---|
92 | */
|
---|
93 |
|
---|
94 | // Things which could be implemented in a future version
|
---|
95 | // PreCut in Energy oder Size?
|
---|
96 | // PreCut in Max Dist
|
---|
97 | // PreCut in Theta^2 (0.25 oder 0.3)
|
---|
98 | // New spectral slope
|
---|
99 | // Zenith angle distribution in OnTime
|
---|
100 |
|
---|
101 | opt.Train("rf-energy.root", set, 30000);
|
---|
102 | }
|
---|
103 | /*
|
---|
104 | // SequencesOn: Monte Carlo Sequences used for training
|
---|
105 | // SequencesOff: Monte Carlo Sequences used for testing
|
---|
106 |
|
---|
107 | // Use:
|
---|
108 | // opt.AddPreCut to use cut for test and training
|
---|
109 | // opt.AddTestCut to use cut for test only
|
---|
110 | // opt.AddTrainCut to use cut for train only
|
---|
111 | */
|
---|