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

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