source: trunk/MagicSoft/Mars/macros/multidimdist.C@ 9366

Last change on this file since 9366 was 1633, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 5.1 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, 5/2002 <mailto:tbretz@astro.uni-wuerzburg.de>
19! Author(s): Rudy Bock, 5/2002 <mailto:rkb@mppmu.mpg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2002
22!
23!
24\* ======================================================================== */
25
26void multidimdist()
27{
28 //
29 // This is a demonstration program which calculates the Hillas
30 // parameter out of a Magic root file.
31
32 //
33 // Create a empty Parameter List and an empty Task List
34 // The tasklist is identified in the eventloop by its name
35 //
36 MParList plist;
37
38 MTaskList tlist;
39 plist.AddToList(&tlist);
40
41 //
42 // This is an example program which reads image parameters for gammas
43 // and hadrons, builds a 'matrix' of look-alike events,
44 // and then finds quality numbers and acceptances for the same sample
45
46 // Create an empty Parameter List and an empty Task List
47 // The tasklist is identified in the eventloop by its name
48 //
49 MParList plist;
50 MTaskList tlistg;
51 plist.AddToList(&tlistg);
52
53 //
54 // ------------- user attention -----------------
55 //
56
57 // cut used both for the matrices and the sample
58 // for more information see the documentation of MF and MDataChain
59 MF filterenergy("MMcEvt.fEnergy > 0");
60
61 // matrix limitation for look-alike events (approximate number)
62 MFEventSelector selector;
63 selector.SetNumSelectEvts(2000);
64
65 // setup an AND-Filterlist from the two filters to be used
66 // in the event selection for the filling of the matrices
67 MFilterList flist;
68 flist.AddToList(&filterenergy);
69 flist.AddToList(&selector);
70
71 //
72 // ---------------------------------------------------------------
73 // Now set up the tasks and tasklist (first event loop, gammas)
74 // ---------------------------------------------------------------
75 //
76
77 // --------------- user change -----------------
78 // Give the names of the star-files to be read
79 // Here you give the trainings sample(s) for
80 // the hadrons
81 // ---------------------------------------------
82 MReadMarsFile read("Events");
83 read.AddFile("star_gammas.root");
84 read.AddFile("star_protons.root");
85 read.DisableAutoScheme();
86 tlistg.AddToList(&read);
87
88 MFParticleId fgamma("MMcEvt", '=', kGAMMA);
89 tlist.AddToList(&fgamma);
90
91 MFParticleId fhadrons("MMcEvt", '!', kGAMMA);
92 tlist.AddToList(&fhadrons);
93
94 MHMatrix matrix("MatrixGammas");
95 matrix.AddColumn("MHillas.fWidth");
96 matrix.AddColumn("MHillas.fLength");
97 matrix.AddColumn("MHillas.fWidth*MHillas.fLength/MHillas.fSize");
98 matrix.AddColumn("abs(MHillas.fAsym)");
99 matrix.AddColumn("abs(MHillas.fM3Long)");
100 matrix.AddColumn("abs(MHillas.fM3Trans)");
101 matrix.AddColumn("abs(MHillasSrc.fHeadTail)");
102 matrix.AddColumn("MHillas.fConc");
103 matrix.AddColumn("MHillas.fConc1");
104 matrix.AddColumn("MHillasSrc.fDist");
105 matrix.AddColumn("log10(MHillas.fSize)");
106 matrix.AddColumn("MHillasSrc.fAlpha");
107 matrix.AddColumn("MMcEvt.fTheta");
108 plist.AddToList(&matrix);
109
110 MHMatrix matrix2("MatrixHadrons");
111 matrix2.AddColumns(matrix.GetColumns());
112 plist.AddToList(&matrix2);
113
114 MFillH fillmat("MatrixGammas");
115 fillmat.SetFilter(&fgamma);
116 tlist.AddToList(&fillmat);
117
118 MFillH fillmat2("MatrixHadrons");
119 fillmat2.SetFilter(&fhadrons);
120 tlist.AddToList(&fillmat2);
121
122 //
123 // Create and setup the eventloop
124 //
125 MEvtLoop evtloop;
126 evtloop.SetParList(&plist);
127
128 //
129 // Execute your analysis
130 //
131 if (!evtloop.Eventloop())
132 return;
133
134 tlist.PrintStatistics();
135
136 matrix.Print("size");
137 matrix2.Print("size");
138
139 // ---------------------------------------------------------
140
141 MTaskList tlist2;
142
143 plist.Replace(&tlist2);
144
145 MReadMarsFile read2("Events");
146 read2.("gammas2.root");
147 read2.AddFile("hadrons2.root");
148 read2.DisableAutoScheme();
149 tlist2.AddToList(&read2);
150
151 MMultiDimDistCalc calc;
152 calc.SetUseNumRows(0);
153 calc.SetUseKernelMethod(kTRUE);
154 tlist2.AddToList(&calc);
155
156 MFillH fillh("MHHadronness");
157
158 /*
159 MF filter("MMcEvt.fEnergy < 100");
160 fillh.SetFilter(&filter);
161 tlist2.AddToList(&filter);
162 */
163
164 tlist2.AddToList(&fillh);
165
166 //
167 // Execute your analysis
168 //
169 if (!evtloop.Eventloop())
170 return;
171
172 tlist2.PrintStatistics();
173
174 plist.FindObject("MHHadronness")->DrawClone();
175 plist.FindObject("MHHadronness")->Print();
176}
Note: See TracBrowser for help on using the repository browser.