source: trunk/MagicSoft/Mars/manalysis/MCT1SupercutsCalc.cc@ 2252

Last change on this file since 2252 was 2225, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 10.2 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): Wolfgang Wittek, 04/2003 <mailto:wittek@mppmu.mpg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26// //
27// MCT1SupercutsCalc //
28// //
29/////////////////////////////////////////////////////////////////////////////
30#include "MCT1SupercutsCalc.h"
31
32#include <math.h>
33#include <fstream>
34
35#include "MParList.h"
36#include "MHillasExt.h"
37#include "MHillasSrc.h"
38#include "MMcEvt.hxx"
39#include "MCerPhotEvt.h"
40#include "MGeomCam.h"
41#include "MHadronness.h"
42#include "MHMatrix.h"
43
44#include "MLog.h"
45#include "MLogManip.h"
46
47ClassImp(MCT1SupercutsCalc);
48
49using namespace std;
50
51void MCT1SupercutsCalc::InitParams()
52{
53 fLengthUp.Set(8);
54 fLengthLo.Set(8);
55 fWidthUp.Set(8);
56 fWidthLo.Set(8);
57 fDistUp.Set(8);
58 fDistLo.Set(8);
59 fAsymUp.Set(8);
60 fAsymLo.Set(8);
61 fAlphaUp.Set(8);
62
63 //---------------------------------
64 // cut parameters
65 fLengthUp[0] = 0.315585;
66 fLengthUp[1] = 0.001455;
67 fLengthUp[2] = 0.203198;
68 fLengthUp[3] = 0.005532;
69 fLengthUp[4] =-0.001670;
70 fLengthUp[5] =-0.020362;
71 fLengthUp[6] = 0.007388;
72 fLengthUp[7] =-0.013463;
73
74 fWidthUp[0] = 0.145412;
75 fWidthUp[1] =-0.001771;
76 fWidthUp[2] = 0.054462;
77 fWidthUp[3] = 0.022280;
78 fWidthUp[4] =-0.009893;
79 fWidthUp[5] = 0.056353;
80 fWidthUp[6] = 0.020711;
81 fWidthUp[7] =-0.016703;
82
83 fDistUp[0] = 1.787943;
84 fDistUp[1] = 0.;
85 fDistUp[2] = 2.942310;
86 fDistUp[3] = 0.199815;
87 fDistUp[4] = 0.;
88 fDistUp[5] = 0.249909;
89 fDistUp[6] = 0.189697;
90 fDistUp[7] = 0.;
91
92 fLengthLo[0] = 0.151530;
93 fLengthLo[1] = 0.028323;
94 fLengthLo[2] = 0.510707;
95 fLengthLo[3] = 0.053089;
96 fLengthLo[4] = 0.013708;
97 fLengthLo[5] = 2.357993;
98 fLengthLo[6] = 0.000080;
99 fLengthLo[7] =-0.007157;
100
101 fWidthLo[0] = 0.089187;
102 fWidthLo[1] =-0.006430;
103 fWidthLo[2] = 0.074442;
104 fWidthLo[3] = 0.003738;
105 fWidthLo[4] =-0.004256;
106 fWidthLo[5] =-0.014101;
107 fWidthLo[6] = 0.006126;
108 fWidthLo[7] =-0.002849;
109
110 fDistLo[0] = 0.589406;
111 fDistLo[1] = 0.;
112 fDistLo[2] =-0.083964;
113 fDistLo[3] =-0.007975;
114 fDistLo[4] = 0.;
115 fDistLo[5] = 0.045374;
116 fDistLo[6] =-0.001750;
117 fDistLo[7] = 0.;
118
119 fAsymUp[0] = 0.061267;
120 fAsymUp[1] = 0.014462;
121 fAsymUp[2] = 0.014327;
122 fAsymUp[3] = 0.014540;
123 fAsymUp[4] = 0.013391;
124 fAsymUp[5] = 0.012319;
125 fAsymUp[6] = 0.010444;
126 fAsymUp[7] = 0.008328;
127
128 fAsymLo[0] =-0.012055;
129 fAsymLo[1] = 0.009157;
130 fAsymLo[2] = 0.005441;
131 fAsymLo[3] = 0.000399;
132 fAsymLo[4] = 0.001433;
133 fAsymLo[5] =-0.002050;
134 fAsymLo[6] =-0.000104;
135 fAsymLo[7] =-0.001188;
136
137 fAlphaUp[0] = 13.123440;
138 fAlphaUp[1] = 0.;
139 fAlphaUp[2] = 0.;
140 fAlphaUp[3] = 0.;
141 fAlphaUp[4] = 0.;
142 fAlphaUp[5] = 0.;
143 fAlphaUp[6] = 0.;
144 fAlphaUp[7] = 0.;
145 //---------------------------------
146}
147
148// --------------------------------------------------------------------------
149//
150MCT1SupercutsCalc::MCT1SupercutsCalc(const char *hilname,
151 const char *hilsrcname, const char *name, const char *title)
152: fHadronnessName("MHadronness"), fHilName(hilname), fHilSrcName(hilsrcname)
153{
154 fName = name ? name : "MCT1SupercutsCalc";
155 fTitle = title ? title : "Class to evaluate the Supercuts";
156
157 InitParams();
158}
159
160// --------------------------------------------------------------------------
161//
162Int_t MCT1SupercutsCalc::PreProcess(MParList *pList)
163{
164 MGeomCam *cam = (MGeomCam*)pList->FindObject("MGeomCam");
165 if (!cam)
166 {
167 *fLog << err << "MGeomCam (Camera Geometry) not found... aborting." << endl;
168 return kFALSE;
169 }
170
171 fMm2Deg = cam->GetConvMm2Deg();
172
173 fHadronness = (MHadronness*)pList->FindCreateObj("MHadronness", fHadronnessName);
174 if (!fHadronness)
175 {
176 *fLog << err << fHadronnessName << " [MHadronness] not found... aborting." << endl;
177 return kFALSE;
178 }
179
180 if (fMatrix)
181 return kTRUE;
182
183 fHil = (MHillas*)pList->FindObject(fHilName, "MHillas");
184 if (!fHil)
185 {
186 *fLog << err << fHilName << " [MHillas] not found... aborting." << endl;
187 return kFALSE;
188 }
189
190 fHilSrc = (MHillasSrc*)pList->FindObject(fHilSrcName, "MHillasSrc");
191 if (!fHilSrc)
192 {
193 *fLog << err << fHilSrcName << " [MHillasSrc] not found... aborting." << endl;
194 return kFALSE;
195 }
196
197 fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
198 if (!fMcEvt)
199 {
200 *fLog << err << "MMcEvt not found... aborting." << endl;
201 return kFALSE;
202 }
203
204 return kTRUE;
205}
206
207// --------------------------------------------------------------------------
208//
209// Calculation of upper and lower limits
210//
211Double_t MCT1SupercutsCalc::CtsMCut(
212#if ROOT_VERSION_CODE > ROOT_VERSION(3,05,00)
213const
214#endif
215 TArrayD &a, Double_t ls, Double_t ct,
216 Double_t ls2, Double_t dd2)
217{
218 // define cut-function
219 //
220 // dNOMLOGSIZE = 4.1 (=log(60.0)
221 // dNOMCOSZA = 1.0
222 //
223 // a: array of cut parameters
224 // ls: log(SIZE) - dNOMLOGSIZE
225 // ls2: ls^2
226 // ct: Cos(ZA.) - dNOMCOSZA
227 // dd2: DIST^2
228 const Double_t limit =
229 a[0] + a[1] * dd2 + a[2] * ct +
230 ls * (a[3] + a[4] * dd2 + a[5] * ct) +
231 ls2 * (a[6] + a[7] * dd2);
232
233 //*fLog << "MCT1SupercutsCalc::CtsMCut; *a = "
234 // << *a << ", " << *(a+1) << ", " << *(a+2) << ", "
235 // << *(a+3) << ", " << *(a+4) << ", " << *(a+5) << ", "
236 // << *(a+6) << ", " << *(a+7) << endl;
237
238 //*fLog << "MCT1SupercutsCalc::CtsMCut; ls, ls2, ct, dd2, limit = " << ls
239 // << ", " << ls2 << ", " << ct << ", " << dd2 << ", "
240 // << limit << endl;
241
242 return limit;
243}
244
245// --------------------------------------------------------------------------
246//
247// Returns the mapped value from the Matrix
248//
249Double_t MCT1SupercutsCalc::GetVal(Int_t i) const
250{
251 return (*fMatrix)[fMap[i]];
252}
253
254// --------------------------------------------------------------------------
255//
256// You can use this function if you want to use a MHMatrix instead of the
257// given containers. This function adds all necessary columns to the
258// given matrix. Afterward you should fill the matrix with the corresponding
259// data (eg from a file by using MHMatrix::Fill). If you now loop
260// through the matrix (eg using MMatrixLoop) MEnergyEstParam::Process
261// will take the values from the matrix instead of the containers.
262//
263void MCT1SupercutsCalc::InitMapping(MHMatrix *mat)
264{
265 if (fMatrix)
266 return;
267
268 fMatrix = mat;
269
270 fMap[0] = fMatrix->AddColumn("MMcEvt.fTelescopeTheta");
271 fMap[1] = fMatrix->AddColumn("MHillas.fWidth");
272 fMap[2] = fMatrix->AddColumn("MHillas.fLength");
273 fMap[3] = fMatrix->AddColumn("MHillas.fSize");
274 fMap[4] = fMatrix->AddColumn("MHillas.fMeanX");
275 fMap[5] = fMatrix->AddColumn("MHillas.fMeanY");
276 fMap[6] = fMatrix->AddColumn("MHillasSrc.fDist");
277}
278
279// ---------------------------------------------------------------------------
280//
281// Evaluate dynamical supercuts for CT1 Mkn421 2001 (Daniel Kranich)
282// optimized for mkn 421 2001 data
283//
284// set hadronness to 0.25 if cuts are fullfilled
285// 0.75 otherwise
286//
287Int_t MCT1SupercutsCalc::Process()
288{
289 const Double_t kNomLogSize = 4.1;
290 const Double_t kNomCosZA = 1.0;
291
292 const Double_t theta = fMatrix ? GetVal(0) : fMcEvt->GetTelescopeTheta();
293 const Double_t width0 = fMatrix ? GetVal(1) : fHil->GetWidth();
294 const Double_t length0 = fMatrix ? GetVal(2) : fHil->GetLength();
295 const Double_t size = fMatrix ? GetVal(3) : fHil->GetSize();
296 const Double_t meanx = fMatrix ? GetVal(4) : fHil->GetMeanX();
297 const Double_t meany = fMatrix ? GetVal(5) : fHil->GetMeanY();
298 const Double_t dist0 = fMatrix ? GetVal(6) : fHilSrc->GetDist();
299
300 const Double_t newdist = dist0 * fMm2Deg;
301
302 const Double_t dist2 = meanx*meanx + meany*meany;
303 const Double_t dd2 = dist2*fMm2Deg;
304 const Double_t dist = sqrt(dist2) * fMm2Deg;
305
306 const Double_t dmls = log(size) - kNomLogSize;
307 const Double_t dmls2 = dmls * dmls;
308
309 const Double_t dmcza = cos(theta) - kNomCosZA;
310
311 const Double_t length = length0 * fMm2Deg;
312 const Double_t width = width0 * fMm2Deg;
313
314 if (newdist < 1.05 &&
315 newdist < CtsMCut (fDistUp, dmls, dmcza, dmls2, dd2) &&
316 newdist > CtsMCut (fDistLo, dmls, dmcza, dmls2, dd2) &&
317 dist < 1.05 &&
318 length < CtsMCut (fLengthUp, dmls, dmcza, dmls2, dd2) &&
319 length > CtsMCut (fLengthLo, dmls, dmcza, dmls2, dd2) &&
320 width < CtsMCut (fWidthUp, dmls, dmcza, dmls2, dd2) &&
321 width > CtsMCut (fWidthLo, dmls, dmcza, dmls2, dd2) &&
322 //asym < CtsMCut (asymup, dmls, dmcza, dmls2, dd2) &&
323 //asym > CtsMCut (asymlow, dmls, dmcza, dmls2, dd2) &&
324 dist < CtsMCut (fDistUp, dmls, dmcza, dmls2, dd2) &&
325 dist > CtsMCut (fDistLo, dmls, dmcza, dmls2, dd2) )
326 fHadronness->SetHadronness(0.25);
327 else
328 fHadronness->SetHadronness(0.75);
329
330 fHadronness->SetReadyToSave();
331
332 return kTRUE;
333}
334
335
336
337
338
339
340
341
342
343
344
345
346
Note: See TracBrowser for help on using the repository browser.