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

Last change on this file since 1524 was 1524, 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::fCosAlphaDelta
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//
113Bool_t MHillasExt::Calc(const MGeomCam &geom, const MCerPhotEvt &evt)
114{
115 if (!MHillas::Calc(geom, evt))
116 return kFALSE;
117
118 //
119 // calculate the additional image parameters
120 // --------------------------------------------
121 //
122 // loop to get third moments along ellipse axes and two max pixels
123 //
124 // For the moments double precision is used to make sure, that
125 // the complex matrix multiplication and sum is evaluated correctly.
126 //
127 Double_t m3x = 0;
128 Double_t m3y = 0;
129
130 Float_t maxpix1 = 0; // [#phot]
131 Float_t maxpix2 = 0; // [#phot]
132
133 Int_t maxpixid = 0;
134
135 const UInt_t npixevt = evt.GetNumPixels();
136
137 const Float_t A0 = geom[0].GetA();
138
139 for (UInt_t i=0; i<npixevt; i++)
140 {
141 const MCerPhotPix &pix = evt[i];
142 if (!pix.IsPixelUsed())
143 continue;
144
145 const MGeomPix &gpix = geom[pix.GetPixId()];
146 const Double_t dx = gpix.GetX() - GetMeanX(); // [mm]
147 const Double_t dy = gpix.GetY() - GetMeanY(); // [mm]
148
149 Double_t nphot = pix.GetNumPhotons(); // [1]
150
151 const Double_t dzx = GetCosDelta()*dx + GetSinDelta()*dy; // [mm]
152 const Double_t dzy = -GetSinDelta()*dx + GetCosDelta()*dy; // [mm]
153
154 m3x += nphot * dzx*dzx*dzx; // [mm^3]
155 m3y += nphot * dzy*dzy*dzy; // [mm^3]
156
157 /*
158 //
159 // count number of photons in pixels at the edge of the camera
160 //
161 if (gpix.IsInOutermostRing())
162 edgepix1 += nphot;
163 if (gpix.IsInOuterRing())
164 edgepix2 += nphot;
165 */
166
167 //
168 // Now we are working on absolute values of nphot, which
169 // must take pixel size into account
170 //
171 const Double_t r = A0/gpix.GetA();
172 nphot *= r;
173
174 if (nphot>maxpix1)
175 {
176 maxpix2 = maxpix1;
177 maxpix1 = nphot; // [1]
178 maxpixid = pix.GetPixId();
179 continue; // [1]
180 }
181
182 if (nphot>maxpix2)
183 maxpix2 = nphot; // [1]
184
185 /*
186 //
187 // power na for calculating fAsymna;
188 // the value 1.5 was suggested by Thomas Schweizer
189 //
190 Double_t na = 1.5;
191
192 //
193 // get sums for calculating fAsymna
194 // the outer pixels are 4 times as big (in area)
195 // as the inner pixels !
196 //
197 const Double_t dummy = pow(nphot, na)/r;
198
199 sna += dummy;
200 xna += dzx*dummy;
201
202 sna1 += sna/nphot;
203 xna1 += xna/nphot;
204
205 //
206 // forward-backward asymmetry
207 //
208 fb += dzx<0 ? -nphot: nphot;
209 */
210 }
211
212 const MGeomPix &maxpix = geom[maxpixid];
213
214 fAsym = (GetMeanX()-maxpix.GetX())*GetCosDelta() +
215 (GetMeanY()-maxpix.GetY())*GetSinDelta(); // [mm]
216
217 fConc = (maxpix1+maxpix2)/GetSize(); // [ratio]
218 fConc1 = maxpix1/GetSize(); // [ratio]
219
220 /*
221 fLeakage1 = edgepix1 / GetSize();
222 fLeakage2 = edgepix2 / GetSize();
223 fAsym0 = fb / GetSize();
224
225 fAsymna = na * (sna*xna1 - sna1*xna) / (sna*sna);
226 */
227
228 //
229 // Third moments along axes get normalized
230 //
231 m3x /= GetSize();
232 m3y /= GetSize();
233
234 fM3Long = m3x<0 ? -pow(-m3x, 1./3) : pow(m3x, 1./3); // [mm]
235 fM3Trans = m3y<0 ? -pow(-m3y, 1./3) : pow(m3y, 1./3); // [mm]
236
237 SetReadyToSave();
238
239 return kTRUE;
240}
241
242// --------------------------------------------------------------------------
243//
244// This function is ment for special usage, please never try to set
245// values via this function
246//
247void MHillasExt::Set(const TArrayF &arr)
248{
249 if (arr.GetSize() != 13)
250 return;
251
252 fConc = arr.At(8); // [ratio] concentration ratio: sum of the two highest pixels / fSize
253 fConc1 = arr.At(9); // [ratio] concentration ratio: sum of the highest pixel / fSize
254 fAsym = arr.At(10); // [mm] fDist minus dist: center of ellipse, highest pixel
255 fM3Long = arr.At(11); // [mm] 3rd moment (e-weighted) along major axis
256 fM3Trans = arr.At(12); // [mm] 3rd moment (e-weighted) along minor axis
257
258 TArrayF n(arr);
259 n.Set(8);
260 MHillas::Set(n);
261}
262
263/*
264// -------------------------------------------------------------------------
265//
266void MHillasExt::AsciiRead(ifstream &fin)
267{
268 MHillas::AsciiRead(fin);
269
270 fin >> fConc;
271 fin >> fConc1;
272 fin >> fAsym;
273 fin >> fM3Long;
274 fin >> fM3Trans;
275}
276*/
277// -------------------------------------------------------------------------
278/*
279void MHillasExt::AsciiWrite(ofstream &fout) const
280{
281 MHillas::AsciiWrite(fout);
282
283 fout << " ";
284 fout << fConc << " ";
285 fout << fConc1 << " ";
286 fout << fAsym << " ";
287 fout << fM3Long << " ";
288 fout << fM3Trans;
289}
290*/
Note: See TracBrowser for help on using the repository browser.