source: trunk/MagicSoft/Mars/macros/train/trainenergy.C@ 8634

Last change on this file since 8634 was 8634, checked in by tbretz, 17 years ago
*** empty log message ***
File size: 3.9 KB
Line 
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/////////////////////////////////////////////////////////////////////////////
39void trainenergy()
40{
41 MDataSet set("mcdataset.txt");
42 set.SetNumAnalysis(1); // Necessary
43
44 // alternatively use:
45 //MDataSet set("mcctesttrain.txt", "/magic/montacrlo/sequences", "/magic/montecarlo/star");
46
47 MJTrainEnergy opt;
48 //opt.SetDebug();
49
50 // ------- Parameters to train Random Forest --------
51 opt.AddParameter("MHillas.fSize");
52 opt.AddParameter("MHillasSrc.fDist");
53 opt.AddParameter("MPointingPos.fZd");
54 opt.AddParameter("MHillas.GetArea");
55 opt.AddParameter("MNewImagePar.fUsedArea");
56 opt.AddParameter("MNewImagePar.fCoreArea");
57 opt.AddParameter("MNewImagePar.fLeakage1");
58 opt.AddParameter("MNewImagePar.fLeakage2");
59 opt.AddParameter("MNewImagePar.fConc");
60 opt.AddParameter("MNewImagePar.fConc1");
61
62 // -------------------- Run ----------------------------
63
64 MStatusDisplay *d = new MStatusDisplay;
65 opt.SetDisplay(d);
66
67 /*
68 -------------------- Magic-Cuts ----------------------
69 MFMagicCuts cuts;
70 cuts.SetHadronnessCut(MFMagicCuts::kArea);
71 cuts.SetThetaCut(MFMagicCuts::kOn);
72
73 TArrayD arr(10);
74 arr[0]= 1.3245;
75 arr[1]= 0.208700;
76 arr[2]= 0.229200;
77 arr[3]= 5.305200;
78 arr[4]= 0.098930;
79 arr[5]= -0.082950;
80 arr[6]= 8.2957;
81 arr[7]= 0.8677;
82
83 cuts.SetVariables(arr);
84
85 opt.AddPreCut(&cuts);
86
87 -------------------- Energy Slope --------------------
88 MFEnergySlope slope(-2.8); // New slope for mc spectrum
89 slope.SetMcMinEnergy(80); // Set break energy from -2.6 to -2.8
90 opt.AddPreCut(&slope); // throw away events to change slope
91
92 -------------------- Other cuts ----------------------
93 opt.AddPreCut("MHillasSrc.fDist*MGeomCam.fConvMm2Deg<1.0");
94 opt.AddPreCut("MHillas.fSize>200");
95 */
96
97 // Things which could be implemented in a future version
98 // PreCut in Energy oder Size?
99 // PreCut in Max Dist
100 // PreCut in Theta^2 (0.25 oder 0.3)
101 // New spectral slope
102 // Zenith angle distribution in OnTime
103
104 opt.Train("rf-energy.root", set, 30000);
105}
106/*
107 // SequencesOn: Monte Carlo Sequences used for training
108 // SequencesOff: Monte Carlo Sequences used for testing
109
110 // Use:
111 // opt.AddPreCut to use cut for test and training
112 // opt.AddTestCut to use cut for test only
113 // opt.AddTrainCut to use cut for train only
114 */
Note: See TracBrowser for help on using the repository browser.