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, 8/2010 <mailto:thomas.bretz@epfl.ch>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2010
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | /////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // traincuts.C
|
---|
28 | // ===========
|
---|
29 | //
|
---|
30 | // For more details see the class description of MJTrainCuts
|
---|
31 | //
|
---|
32 | /////////////////////////////////////////////////////////////////////////////
|
---|
33 | void traincuts()
|
---|
34 | {
|
---|
35 | // Instantiate class
|
---|
36 | MJTrainCuts opt;
|
---|
37 | //opt.SetDebug();
|
---|
38 |
|
---|
39 | // These are control parameters how to train the random forest (use with care!)
|
---|
40 | //opt.SetNumTrees(100);
|
---|
41 | //opt.SetNdSize(5);
|
---|
42 | //opt.SetNumTry(0);
|
---|
43 |
|
---|
44 | // Setup datasets
|
---|
45 | MDataSet seton ("dataset_on.txt");
|
---|
46 | MDataSet setoff("dataset_off.txt");
|
---|
47 |
|
---|
48 | opt.SetDataSetOn(seton);
|
---|
49 | opt.SetDataSetOff(setmix);
|
---|
50 |
|
---|
51 | // Define the parameters you want the random forest to use
|
---|
52 | Int_t p00 = opt.AddParameter("MHillas.fSize");
|
---|
53 | Int_t p01 = opt.AddParameter("MHillas.GetArea*MGeomCam.fConvMm2Deg^2");
|
---|
54 | Int_t p02 = opt.AddParameter("MHillasSrc.fDist*MGeomCam.fConvMm2Deg");
|
---|
55 | Int_t p03 = opt.AddParameter("MHillasExt.fTimeSpreadWeighted");
|
---|
56 | Int_t p04 = opt.AddParameter("MHillasExt.fSlopeSpreadWeighted");
|
---|
57 |
|
---|
58 | Int_t p05 = opt.AddParameter("MHillasExt.fSlopeLong*sign(MHillasSrc.fCosDeltaAlpha)/MGeomCam.fConvMm2Deg");
|
---|
59 | Int_t p06 = opt.AddParameter("MHillasExt.fM3Long*sign(MHillasSrc.fCosDeltaAlpha)*MGeomCam.fConvMm2Deg");
|
---|
60 |
|
---|
61 | // A selection of more parameters
|
---|
62 | // Int_t p07 = opt.AddParameter("MNewImagePar.fLeakage1");
|
---|
63 | // Int_t p08 = opt.AddParameter("MNewImagePar.fLeakage2");
|
---|
64 | // Int_t p09 = opt.AddParameter("MNewImagePar.fConcCOG");
|
---|
65 | // Int_t p10 = opt.AddParameter("MNewImagePar.fConcCore");
|
---|
66 | // Int_t p11 = opt.AddParameter("MNewImagePar.fConc1");
|
---|
67 | // Int_t p12 = opt.AddParameter("MNewImagePar.fUsedArea*MGeomCam.fConvMm2Deg^2");
|
---|
68 | // Int_t p13 = opt.AddParameter("MNewImagePar.fCoreArea*MGeomCam.fConvMm2Deg^2");
|
---|
69 |
|
---|
70 | // Define the binning for all the parameters
|
---|
71 | // opt.AddBinning(p00, MBinning(40, 10, 10000, "", "log")); // Size
|
---|
72 | // opt.AddBinning(p01, MBinning(40, 0, 0.3)); // Area
|
---|
73 | // opt.AddBinning(p02, MBinning(50, 0, 2.5)); // Dist
|
---|
74 | // opt.AddBinning(p03, MBinning(50, 0, 2.5)); // TimeSpreadW
|
---|
75 | // opt.AddBinning(p04, MBinning(50, 0, 1.0)); // SlopeSpreadW
|
---|
76 | // opt.AddBinning(p05, MBinning(51, -12, 12)); // SlopeLong
|
---|
77 | // opt.AddBinning(p06, MBinning(51, -0.5, 0.5)); // M3Long
|
---|
78 | // opt.AddBinning(p07, MBinning(50, 0, 0.5)); // Leakage1
|
---|
79 | // opt.AddBinning(p08, MBinning(50, 0, 0.5)); // Leakage2
|
---|
80 | // opt.AddBinning(p09, MBinning(50, 0, 1)); // ConcCOG
|
---|
81 | // opt.AddBinning(p10, MBinning(50, 0, 1)); // ConcCore
|
---|
82 | // opt.AddBinning(p11, MBinning(50, 0, 1)); // Conc1
|
---|
83 | // opt.AddBinning(p12, MBinning(50, 0, 0.3)); // UsedArea
|
---|
84 | // opt.AddBinning(p13, MBinning(50, 0, 0.3)); // CoreArea
|
---|
85 |
|
---|
86 | // Define the histograms you want to see by AddHist(x[,y[,z]]);
|
---|
87 | opt.AddHist(p00, p01); // Area vs Size
|
---|
88 | opt.AddHist(p02, p03); // TimeSpreadW vs Dist
|
---|
89 | opt.AddHist(p02, p04); // SlopeSpreadW vs Dist
|
---|
90 | // opt.AddHist(p09);; // ConcCOG
|
---|
91 |
|
---|
92 | // Define additional cuts which are applied after reading the data
|
---|
93 | //opt.AddPreCut("MNewImagePar.fConcCOG>0.1");
|
---|
94 | //opt.AddPreCut("MHillasSrc.fDist*MGeomCam.fConvMm2Deg<2.0");
|
---|
95 |
|
---|
96 | // -------------------- Run ----------------------------
|
---|
97 |
|
---|
98 | MStatusDisplay *d = new MStatusDisplay;
|
---|
99 | opt.SetDisplay(d);
|
---|
100 |
|
---|
101 | // ------------------------------------------------------
|
---|
102 |
|
---|
103 | // Use random forest regression method
|
---|
104 | // opt.EnableRegression();
|
---|
105 |
|
---|
106 | // Allows overwrite of existing files
|
---|
107 | // opt.SetOverwrite();
|
---|
108 | opt.Process("rf-cuts.root");
|
---|
109 | }
|
---|