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

Last change on this file since 8038 was 2124, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 6.5 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 // If you have only _one_ single Theta
69 // remove MMcEvt.fTheta!
70 // ---------------------------------------------
71 MReadMarsFile readg("Events", "star_gammas0.root");
72 readg.DisableAutoScheme();
73 tlistg.AddToList(&readg);
74
75 MHMatrix matrix("MatrixGammas");
76 matrix.AddColumn("MHillas.fWidth");
77 matrix.AddColumn("MHillas.fLength");
78 matrix.AddColumn("MHillas.fWidth*MHillas.fLength/MHillas.fSize");
79 matrix.AddColumn("abs(MHillas.fAsym)");
80 matrix.AddColumn("abs(MHillas.fM3Long)");
81 matrix.AddColumn("abs(MHillas.fM3Trans)");
82 matrix.AddColumn("abs(MHillasSrc.fHeadTail)");
83 matrix.AddColumn("MHillas.fConc");
84 matrix.AddColumn("MHillas.fConc1");
85 matrix.AddColumn("MHillasSrc.fDist");
86 matrix.AddColumn("log10(MHillas.fSize)");
87 matrix.AddColumn("MHillasSrc.fAlpha");
88 matrix.AddColumn("MMcEvt.fTheta");
89 plist.AddToList(&matrix);
90
91 MFillH fillmatg("MatrixGammas");
92 fillmatg.SetFilter(&flist);
93 tlistg.AddToList(&flist);
94 tlistg.AddToList(&fillmatg);
95
96 //
97 // --- Create and set up the eventloop (gammas) ---
98 //
99 MEvtLoop evtloop1;
100 evtloop1.SetParList(&plist);
101
102 //
103 // --- Execute matrix buildup (gammas) ---
104 //
105 if (!evtloop1.Eventloop())
106 return;
107
108 tlistg.PrintStatistics();
109
110 //
111 // ------------------------------------------------------------------
112 // prepare second event loop, hadrons
113 // ------------------------------------------------------------------
114 //
115 MTaskList tlisth;
116 plist.Replace(&tlisth);
117
118 // --------------- user change -----------------
119 // Give the names of the star-files to be read
120 // Here you give the trainings sample(s) for
121 // the hadrons
122 // ---------------------------------------------
123 MReadMarsFile readh("Events", "star_protons0.root");
124 readh.DisableAutoScheme();
125 tlisth.AddToList(&readh);
126
127 MHMatrix matrixh("MatrixHadrons");
128 matrixh.AddColumns(matrix.GetColumns());
129 plist.AddToList(&matrixh);
130
131 MFillH fillmath("MatrixHadrons");
132 fillmath.SetFilter(&flist); // filter list
133 tlisth.AddToList(&flist);
134 tlisth.AddToList(&fillmath);
135
136 //
137 // Create and set up the eventloop (protons)
138 //
139 MEvtLoop evtloop2;
140 evtloop2.SetParList(&plist);
141
142 //
143 // Execute matrix buildup (hadrons)
144 //
145 if (!evtloop2.Eventloop())
146 return;
147
148 // sum up in log
149 tlisth.PrintStatistics();
150
151 matrix.Print("size");
152 matrixh.Print("size");
153
154 //
155 // ----------------------------------------------------------
156 // Go through full sample again, now for getting hadronness
157 // (third event loop)
158 // ----------------------------------------------------------
159 //
160
161 MTaskList tlist2;
162 plist.Replace(&tlist2);
163
164 // ------------------- user change --------------------
165 // Give the names of the star-files to be read as
166 // test samples you should at least have one hadron
167 // and one gamma file available
168 // ----------------------------------------------------
169 MReadMarsFile read2("Events", "star_gammas0.root");
170 read2.AddFile("star_protons0.root");
171 read2.DisableAutoScheme();
172 tlist2.AddToList(&read2);
173
174 // ---------------- user attention -----------------
175 // Here you may change the algorithm used
176 // You can switch from Kernel to Next Neighbor
177 // or change the number of used shortest distances
178 // For kernel you should always set this to 0 (all)
179 // -------------------------------------------------
180 MMultiDimDistCalc calc;
181 calc.SetUseNumRows(25);
182 calc.SetUseKernelMethod(kFALSE);
183 tlist2.AddToList(&calc);
184
185 MFillH fillh("MHHadronness");
186 fillh.SetFilter(&filterenergy);
187 tlist2.AddToList(&filterenergy);
188 tlist2.AddToList(&fillh);
189
190 //
191 // Execute analysis of gammas and hadrons
192 //
193 MProgressBar bar;
194 MEvtLoop evtloop3;
195 evtloop3.SetProgressBar(&bar);
196 evtloop3.SetParList(&plist);
197
198 if (!evtloop3.Eventloop())
199 return;
200
201 tlist2.PrintStatistics();
202
203 plist.FindObject("MHHadronness")->DrawClone();
204 plist.FindObject("MHHadronness")->Print();
205}
Note: See TracBrowser for help on using the repository browser.