source: trunk/MagicSoft/Mars/manalysis/MHillasExt.cc@ 1578

Last change on this file since 1578 was 1574, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 8.6 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 12/2000 <mailto:tbretz@uni-sw.gwdg.de>
19! Author(s): Rudolf Bock 10/2001 <mailto:Rudolf.Bock@cern.ch>
20! Author(s): Wolfgang Wittek 06/2002 <mailto:wittek@mppmu.mpg.de>
21!
22! Copyright: MAGIC Software Development, 2000-2002
23!
24!
25\* ======================================================================== */
26
27/////////////////////////////////////////////////////////////////////////////
28//
29// MHillasExt
30//
31// Storage Container for extended image parameters
32//
33// extended image parameters
34// fConc ratio of sum of two highest pixels over fSize
35// fConc1 ratio of highest pixel over fSize
36// fAsym distance from highest pixel to center, projected onto major axis
37// fM3Long third moment along major axis
38// fM3Trans third moment along minor axis
39//
40// WARNING: Before you can use fAsym, fM3Long and fM3Trans you must
41// multiply by the sign of MHillasSrc::fCosDeltaAlpha
42//
43////////////////////////////////////////////////////////////////////////////
44/*
45 // fLeakage1 ratio : (photons in most outer ring of pixels) over fSize
46 // fLeakage2 ratio : (photons in the 2 outer rings of pixels) over fSize
47 //
48 // fAsymna d/(d na) of ( sum(x*q^na)/sum(q^na), sum(y*q^na)/sum(q^na) )
49 // projected onto the major axis
50 // fAsym0 (F-B)/(F+B) along the major axis
51 */
52#include "MHillasExt.h"
53
54#include <fstream.h>
55#include <TArrayF.h>
56
57#include "MGeomPix.h"
58#include "MGeomCam.h"
59
60#include "MCerPhotPix.h"
61#include "MCerPhotEvt.h"
62
63#include "MLog.h"
64#include "MLogManip.h"
65
66ClassImp(MHillasExt);
67
68// -------------------------------------------------------------------------
69//
70// Default constructor.
71//
72MHillasExt::MHillasExt(const char *name, const char *title)
73{
74 fName = name ? name : "MHillas";
75 fTitle = title ? title : "Storage container for extended parameter set of one event";
76
77 Reset();
78 // FIXME: (intelligent) initialization of values missing
79}
80
81// -------------------------------------------------------------------------
82//
83void MHillasExt::Reset()
84{
85 MHillas::Reset();
86
87 fConc = -1;
88 fConc1 = -1;
89 fAsym = 0;
90 fM3Long = 0;
91 fM3Trans = 0;
92}
93
94// -------------------------------------------------------------------------
95//
96void MHillasExt::Print(Option_t *) const
97{
98 MHillas::Print();
99
100 *fLog << "Extended Image Parameters (" << GetName() << ")" << endl;
101 *fLog << " - Conc = " << fConc << " (ratio)" << endl;
102 *fLog << " - Conc1 = " << fConc1 << " (ratio)" << endl;
103 *fLog << " - Asymmetry = " << fAsym << " mm" << endl;
104 *fLog << " - 3rd Moment Long = " << fM3Long << " mm" << endl;
105 *fLog << " - 3rd Moment Trans = " << fM3Trans << " mm" << endl;
106}
107
108// -------------------------------------------------------------------------
109//
110// calculation of additional parameters based on the camera geometry
111// and the cerenkov photon event
112//
113Int_t MHillasExt::Calc(const MGeomCam &geom, const MCerPhotEvt &evt)
114{
115 const Int_t rc = MHillas::Calc(geom, evt);
116 if (rc>0)
117 return rc;
118
119 //
120 // calculate the additional image parameters
121 // --------------------------------------------
122 //
123 // loop to get third moments along ellipse axes and two max pixels
124 //
125 // For the moments double precision is used to make sure, that
126 // the complex matrix multiplication and sum is evaluated correctly.
127 //
128 Double_t m3x = 0;
129 Double_t m3y = 0;
130
131 Float_t maxpix1 = 0; // [#phot]
132 Float_t maxpix2 = 0; // [#phot]
133
134 Int_t maxpixid = 0;
135
136 const UInt_t npixevt = evt.GetNumPixels();
137
138 const Float_t A0 = geom[0].GetA();
139
140 for (UInt_t i=0; i<npixevt; i++)
141 {
142 const MCerPhotPix &pix = evt[i];
143 if (!pix.IsPixelUsed())
144 continue;
145
146 const MGeomPix &gpix = geom[pix.GetPixId()];
147 const Double_t dx = gpix.GetX() - GetMeanX(); // [mm]
148 const Double_t dy = gpix.GetY() - GetMeanY(); // [mm]
149
150 Double_t nphot = pix.GetNumPhotons(); // [1]
151
152 const Double_t dzx = GetCosDelta()*dx + GetSinDelta()*dy; // [mm]
153 const Double_t dzy = -GetSinDelta()*dx + GetCosDelta()*dy; // [mm]
154
155 m3x += nphot * dzx*dzx*dzx; // [mm^3]
156 m3y += nphot * dzy*dzy*dzy; // [mm^3]
157
158 /*
159 //
160 // count number of photons in pixels at the edge of the camera
161 //
162 if (gpix.IsInOutermostRing())
163 edgepix1 += nphot;
164 if (gpix.IsInOuterRing())
165 edgepix2 += nphot;
166 */
167
168 //
169 // Now we are working on absolute values of nphot, which
170 // must take pixel size into account
171 //
172 const Double_t r = A0/gpix.GetA();
173 nphot *= r;
174
175 if (nphot>maxpix1)
176 {
177 maxpix2 = maxpix1;
178 maxpix1 = nphot; // [1]
179 maxpixid = pix.GetPixId();
180 continue; // [1]
181 }
182
183 if (nphot>maxpix2)
184 maxpix2 = nphot; // [1]
185
186 /*
187 //
188 // power na for calculating fAsymna;
189 // the value 1.5 was suggested by Thomas Schweizer
190 //
191 Double_t na = 1.5;
192
193 //
194 // get sums for calculating fAsymna
195 // the outer pixels are 4 times as big (in area)
196 // as the inner pixels !
197 //
198 const Double_t dummy = pow(nphot, na)/r;
199
200 sna += dummy;
201 xna += dzx*dummy;
202
203 sna1 += sna/nphot;
204 xna1 += xna/nphot;
205
206 //
207 // forward-backward asymmetry
208 //
209 fb += dzx<0 ? -nphot: nphot;
210 */
211 }
212
213 const MGeomPix &maxpix = geom[maxpixid];
214
215 fAsym = (GetMeanX()-maxpix.GetX())*GetCosDelta() +
216 (GetMeanY()-maxpix.GetY())*GetSinDelta(); // [mm]
217
218 fConc = (maxpix1+maxpix2)/GetSize(); // [ratio]
219 fConc1 = maxpix1/GetSize(); // [ratio]
220
221 /*
222 fLeakage1 = edgepix1 / GetSize();
223 fLeakage2 = edgepix2 / GetSize();
224 fAsym0 = fb / GetSize();
225
226 fAsymna = na * (sna*xna1 - sna1*xna) / (sna*sna);
227 */
228
229 //
230 // Third moments along axes get normalized
231 //
232 m3x /= GetSize();
233 m3y /= GetSize();
234
235 fM3Long = m3x<0 ? -pow(-m3x, 1./3) : pow(m3x, 1./3); // [mm]
236 fM3Trans = m3y<0 ? -pow(-m3y, 1./3) : pow(m3y, 1./3); // [mm]
237
238 SetReadyToSave();
239
240 return 0;
241}
242
243// --------------------------------------------------------------------------
244//
245// This function is ment for special usage, please never try to set
246// values via this function
247//
248void MHillasExt::Set(const TArrayF &arr)
249{
250 if (arr.GetSize() != 13)
251 return;
252
253 fConc = arr.At(8); // [ratio] concentration ratio: sum of the two highest pixels / fSize
254 fConc1 = arr.At(9); // [ratio] concentration ratio: sum of the highest pixel / fSize
255 fAsym = arr.At(10); // [mm] fDist minus dist: center of ellipse, highest pixel
256 fM3Long = arr.At(11); // [mm] 3rd moment (e-weighted) along major axis
257 fM3Trans = arr.At(12); // [mm] 3rd moment (e-weighted) along minor axis
258
259 TArrayF n(arr);
260 n.Set(8);
261 MHillas::Set(n);
262}
263
264/*
265// -------------------------------------------------------------------------
266//
267void MHillasExt::AsciiRead(ifstream &fin)
268{
269 MHillas::AsciiRead(fin);
270
271 fin >> fConc;
272 fin >> fConc1;
273 fin >> fAsym;
274 fin >> fM3Long;
275 fin >> fM3Trans;
276}
277*/
278// -------------------------------------------------------------------------
279/*
280void MHillasExt::AsciiWrite(ofstream &fout) const
281{
282 MHillas::AsciiWrite(fout);
283
284 fout << " ";
285 fout << fConc << " ";
286 fout << fConc1 << " ";
287 fout << fAsym << " ";
288 fout << fM3Long << " ";
289 fout << fM3Trans;
290}
291*/
Note: See TracBrowser for help on using the repository browser.