source: trunk/MagicSoft/Mars/macros/multidimdist2.C@ 1801

Last change on this file since 1801 was 1629, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 6.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 Bretz, 11/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
19! Author(s): Rudy Bock, 11/2002 <mailto:rkb@mppmu.mpg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2002
22!
23!
24\* ======================================================================== */
25
26void multidimdist2()
27{
28 //
29 // This is an example program which reads image parameters for gammas
30 // and hadrons, builds a 'matrix' of look-alike events,
31 // and then finds quality numbers and acceptances for the same sample
32
33 // Create an empty Parameter List and an empty Task List
34 // The tasklist is identified in the eventloop by its name
35 //
36 MParList plist;
37 MTaskList tlistg;
38 plist.AddToList(&tlistg);
39
40 //
41 // ------------- user attention -----------------
42 //
43
44 // cut used both for the matrices and the sample
45 // for more information see the documentation of MF and MDataChain
46 MF filterenergy("MMcEvt.fEnergy > 0");
47
48 // matrix limitation for look-alike events (approximate number)
49 MFEventSelector selector;
50 selector.SetNumSelectEvts(2000);
51
52 // setup an AND-Filterlist from the two filters to be used
53 // in the event selection for the filling of the matrices
54 MFilterList flist;
55 flist.AddToList(&filterenergy);
56 flist.AddToList(&selector);
57
58 //
59 // ---------------------------------------------------------------
60 // Now set up the tasks and tasklist (first event loop, gammas)
61 // ---------------------------------------------------------------
62 //
63
64 // --------------- user change -----------------
65 // Give the names of the star-files to be read
66 // Here you give the trainings sample(s) for
67 // the gammas
68 // ---------------------------------------------
69 MReadMarsFile readg("Events", "star_gammas.root");
70 readg.DisableAutoScheme();
71 tlistg.AddToList(&readg);
72
73 MHMatrix matrix("MatrixGammas");
74 matrix.AddColumn("MHillas.fWidth");
75 matrix.AddColumn("MHillas.fLength");
76 matrix.AddColumn("MHillas.fWidth*MHillas.fLength/MHillas.fSize");
77 matrix.AddColumn("abs(MHillas.fAsym)");
78 matrix.AddColumn("abs(MHillas.fM3Long)");
79 matrix.AddColumn("abs(MHillas.fM3Trans)");
80 matrix.AddColumn("abs(MHillasSrc.fHeadTail)");
81 matrix.AddColumn("MHillas.fConc");
82 matrix.AddColumn("MHillas.fConc1");
83 matrix.AddColumn("MHillasSrc.fDist");
84 matrix.AddColumn("log10(MHillas.fSize)");
85 matrix.AddColumn("MHillasSrc.fAlpha");
86 matrix.AddColumn("MMcEvt.fTheta");
87 plist.AddToList(&matrix);
88
89 MFillH fillmatg("MatrixGammas");
90 fillmatg.SetFilter(&flist);
91 tlistg.AddToList(&flist);
92 tlistg.AddToList(&fillmatg);
93
94 //
95 // --- Create and set up the eventloop (gammas) ---
96 //
97 MEvtLoop evtloop;
98 evtloop.SetParList(&plist);
99
100 //
101 // --- Execute matrix buildup (gammas) ---
102 //
103 if (!evtloop.Eventloop())
104 return;
105
106 tlistg.PrintStatistics();
107
108 //
109 // ------------------------------------------------------------------
110 // prepare second event loop, hadrons
111 // ------------------------------------------------------------------
112 //
113 MTaskList tlisth;
114 plist.Replace(&tlisth);
115
116 // --------------- user change -----------------
117 // Give the names of the star-files to be read
118 // Here you give the trainings sample(s) for
119 // the hadrons
120 // ---------------------------------------------
121 MReadMarsFile readh("Events", "star_protons.root");
122 readh.DisableAutoScheme();
123 tlisth.AddToList(&readh);
124
125 MHMatrix matrixh("MatrixHadrons");
126 matrixh.AddColumns(matrix.GetColumns());
127 plist.AddToList(&matrixh);
128
129 MFillH fillmath("MatrixHadrons");
130 fillmath.SetFilter(&flist); // filter list
131 tlisth.AddToList(&flist);
132 tlisth.AddToList(&fillmath);
133
134 //
135 // Create and set up the eventloop (protons)
136 //
137 MEvtLoop evtloop;
138 evtloop.SetParList(&plist);
139
140 //
141 // Execute matrix buildup (hadrons)
142 //
143 if (!evtloop.Eventloop())
144 return;
145
146 // sum up in log
147 tlistg.PrintStatistics();
148
149 matrix.Print("size");
150 matrixh.Print("size");
151
152 //
153 // ----------------------------------------------------------
154 // Go through full sample again, now for getting hadronness
155 // (third event loop)
156 // ----------------------------------------------------------
157 //
158
159 MTaskList tlist2;
160 plist.Replace(&tlist2);
161
162 // ------------------- user change --------------------
163 // Give the names of the star-files to be read as
164 // test samples you should at least have one hadron
165 // and one gamma file available
166 // ----------------------------------------------------
167 MReadMarsFile read2("Events", "star_protons.root");
168 read2.AddFile("star_gammas.root");
169 read2.DisableAutoScheme();
170 tlist2.AddToList(&read2);
171
172 // ---------------- user attention -----------------
173 // Here you may change the algorithm used
174 // You can switch from Kernel to Next Neighbor
175 // or change the number of used shortest distances
176 // For kernel you should always set this to 0 (all)
177 // -------------------------------------------------
178 MMultiDimDistCalc calc;
179 calc.SetUseNumRows(25);
180 calc.SetUseKernelMethod(kFALSE);
181 tlist2.AddToList(&calc);
182
183 MFillH fillh("MHHadronness");
184 fillh.SetFilter(&filterenergy);
185 tlist2.AddToList(&filterenergy);
186 tlist2.AddToList(&fillh);
187
188 //
189 // Execute analysis of gammas and hadrons
190 //
191 MProgressBar bar;
192 MEvtLoop evtloop;
193 evtloop.SetProgressBar(&bar);
194 evtloop.SetParList(&plist);
195
196 if (!evtloop.Eventloop())
197 return;
198
199 tlist2.PrintStatistics();
200
201 plist.FindObject("MHHadronness")->DrawClone();
202 plist.FindObject("MHHadronness")->Print();
203}
Note: See TracBrowser for help on using the repository browser.