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

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