source: trunk/MagicSoft/Mars/macros/RanForest2.C@ 3744

Last change on this file since 3744 was 1859, checked in by hengsteb, 22 years ago
*** empty log message ***
File size: 3.4 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 Hengstebeck, 3/2003 <mailto:hengsteb@alwa02.physik.uni-siegen.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25void RanForest2()
26{
27 //
28 // Create a empty Parameter List and an empty Task List
29 // The tasklist is identified in the eventloop by its name
30 //
31 MParList plist;
32
33 MTaskList tlist;
34 plist.AddToList(&tlist);
35 //
36 // ---------------------------------------------------------------
37 // ---------------------------------------------------------------
38 // first event loop: the trees of the random forest are read in
39 // ---------------------------------------------------------------
40 // ---------------------------------------------------------------
41 //
42 MReadTree read("Tree","RF.root");
43 read.DisableAutoScheme();
44
45 MRanForestFill rffill;
46 rffill.SetNumTrees(100);
47
48 tlist.AddToList(&read);
49 tlist.AddToList(&rffill);
50
51 //
52 // Create and setup the eventloop
53 //
54 MEvtLoop evtloop;
55 evtloop.SetParList(&plist);
56
57 //
58 // Execute tree reading (now the eventloop is actually a treeloop)
59 //
60 if (!evtloop.Eventloop())
61 return;
62
63 tlist.PrintStatistics();
64
65 // ---------------------------------------------------------------
66 // ---------------------------------------------------------------
67 // second event loop: the control sample is processed
68 // through the previously grown random forest,
69 //
70 // the histograms MHHadronness (quality of g/h-separation) and
71 // MHRanForest are created and displayed.
72 // MHRanForest shows the convergence of the classification error
73 // as function of the number of grown (and combined) trees
74 // and tells the user how many trees are actually needed in later
75 // classification tasks.
76 // ---------------------------------------------------------------
77 // ---------------------------------------------------------------
78
79 MTaskList tlist2;
80
81 plist.Replace(&tlist2);
82
83 MReadMarsFile read2("Events", "~/MagicData/data1/CT1Data/ONTest/*.root");
84 read2.DisableAutoScheme();
85 tlist2.AddToList(&read2);
86
87 MRanForestCalc calc;
88 tlist2.AddToList(&calc);
89
90 MFillH fillh2a("MHHadronness");
91 MFillH fillh2b("MHRanForest");
92
93 tlist2.AddToList(&fillh2a);
94 tlist2.AddToList(&fillh2b);
95
96 //
97 // Execute your analysis
98 //
99 MProgressBar bar;
100 evtloop.SetProgressBar(&bar);
101
102 if (!evtloop.Eventloop())
103 return;
104
105 tlist2.PrintStatistics();
106
107 plist.FindObject("MHRanForest")->DrawClone();
108 plist.FindObject("MHHadronness")->DrawClone();
109 plist.FindObject("MHHadronness")->Print();
110}
Note: See TracBrowser for help on using the repository browser.