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 |
|
---|
26 | void 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 hadrons
|
---|
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 | plist.AddToList(&matrix);
|
---|
86 |
|
---|
87 | MFillH fillmatg("MatrixGammas");
|
---|
88 | fillmatg.SetFilter(&flist);
|
---|
89 | tlistg.AddToList(&flist);
|
---|
90 | tlistg.AddToList(&fillmatg);
|
---|
91 |
|
---|
92 | //
|
---|
93 | // --- Create and set up the eventloop (gammas) ---
|
---|
94 | //
|
---|
95 | MEvtLoop evtloop;
|
---|
96 | evtloop.SetParList(&plist);
|
---|
97 |
|
---|
98 | //
|
---|
99 | // --- Execute matrix buildup (gammas) ---
|
---|
100 | //
|
---|
101 | if (!evtloop.Eventloop())
|
---|
102 | return;
|
---|
103 |
|
---|
104 | tlistg.PrintStatistics();
|
---|
105 |
|
---|
106 | //
|
---|
107 | // ------------------------------------------------------------------
|
---|
108 | // prepare second event loop, hadrons
|
---|
109 | // ------------------------------------------------------------------
|
---|
110 | //
|
---|
111 | MTaskList tlisth;
|
---|
112 | plist.Replace(&tlisth);
|
---|
113 |
|
---|
114 | // --------------- user change -----------------
|
---|
115 | // Give the names of the star-files to be read
|
---|
116 | // Here you give the trainings sample(s) for
|
---|
117 | // the hadrons
|
---|
118 | // ---------------------------------------------
|
---|
119 | MReadMarsFile readh("Events", "star_protons.root");
|
---|
120 | readh.DisableAutoScheme();
|
---|
121 | tlisth.AddToList(&readh);
|
---|
122 |
|
---|
123 | MHMatrix matrixh("MatrixHadrons");
|
---|
124 | matrixh.AddColumns(matrix.GetColumns());
|
---|
125 | plist.AddToList(&matrixh);
|
---|
126 |
|
---|
127 | MFillH fillmath("MatrixHadrons");
|
---|
128 | fillmath.SetFilter(&flist); // filter list
|
---|
129 | tlisth.AddToList(&flist);
|
---|
130 | tlisth.AddToList(&fillmath);
|
---|
131 |
|
---|
132 | //
|
---|
133 | // Create and set up the eventloop (protons)
|
---|
134 | //
|
---|
135 | MEvtLoop evtloop;
|
---|
136 | evtloop.SetParList(&plist);
|
---|
137 |
|
---|
138 | //
|
---|
139 | // Execute matrix buildup (hadrons)
|
---|
140 | //
|
---|
141 | if (!evtloop.Eventloop())
|
---|
142 | return;
|
---|
143 |
|
---|
144 | // sum up in log
|
---|
145 | tlistg.PrintStatistics();
|
---|
146 |
|
---|
147 | matrix.Print("size");
|
---|
148 | matrixh.Print("size");
|
---|
149 |
|
---|
150 | //
|
---|
151 | // ----------------------------------------------------------
|
---|
152 | // Go through full sample again, now for getting hadronness
|
---|
153 | // (third event loop)
|
---|
154 | // ----------------------------------------------------------
|
---|
155 | //
|
---|
156 |
|
---|
157 | MTaskList tlist2;
|
---|
158 | plist.Replace(&tlist2);
|
---|
159 |
|
---|
160 | // ------------------- user change --------------------
|
---|
161 | // Give the names of the star-files to be read as
|
---|
162 | // test samples you should at least have one hadron
|
---|
163 | // and one gamma file available
|
---|
164 | // ----------------------------------------------------
|
---|
165 | MReadMarsFile read2("Events", "star_protons.root");
|
---|
166 | read2.AddFile("star_gammas.root");
|
---|
167 | read2.DisableAutoScheme();
|
---|
168 | tlist2.AddToList(&read2);
|
---|
169 |
|
---|
170 | // ---------------- user attention -----------------
|
---|
171 | // Here you may change the algorithm used
|
---|
172 | // You can switch from Kernel to Next Neighbor
|
---|
173 | // or change the number of used shortest distances
|
---|
174 | // For kernel you should always set this to 0 (all)
|
---|
175 | // -------------------------------------------------
|
---|
176 | MMultiDimDistCalc calc;
|
---|
177 | calc.SetUseNumRows(25);
|
---|
178 | calc.SetUseKernelMethod(kFALSE);
|
---|
179 | tlist2.AddToList(&calc);
|
---|
180 |
|
---|
181 | MFillH fillh("MHHadronness");
|
---|
182 | fillh.SetFilter(&filterenergy);
|
---|
183 | tlist2.AddToList(&filterenergy);
|
---|
184 | tlist2.AddToList(&fillh);
|
---|
185 |
|
---|
186 | //
|
---|
187 | // Execute analysis of gammas and hadrons
|
---|
188 | //
|
---|
189 | MProgressBar bar;
|
---|
190 | MEvtLoop evtloop;
|
---|
191 | evtloop.SetProgressBar(&bar);
|
---|
192 | evtloop.SetParList(&plist);
|
---|
193 |
|
---|
194 | if (!evtloop.Eventloop())
|
---|
195 | return;
|
---|
196 |
|
---|
197 | tlist2.PrintStatistics();
|
---|
198 |
|
---|
199 | plist.FindObject("MHHadronness")->DrawClone();
|
---|
200 | plist.FindObject("MHHadronness")->Print();
|
---|
201 | }
|
---|