source: trunk/MagicSoft/Mars/mimage/MHillasExt.cc@ 6858

Last change on this file since 6858 was 6855, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 7.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): Thomas Bretz 12/2000 <mailto:tbretz@astro.uni-wuerzburg.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-2004
23!
24!
25\* ======================================================================== */
26
27/////////////////////////////////////////////////////////////////////////////
28//
29// MHillasExt
30//
31// Storage Container for extended image parameters
32//
33// extended image parameters
34//
35//
36// Version 1:
37// ----------
38// fConc ratio of sum of two highest pixels over fSize
39// fConc1 ratio of highest pixel over fSize
40// fAsym distance from highest pixel to center, projected onto major axis
41// fM3Long third moment along major axis
42// fM3Trans third moment along minor axis
43//
44// Version 2:
45// ----------
46// fConc removed
47// fConc1 removed
48//
49// Version 3:
50// ----------
51// fMaxDist added. Distance between center and most distant used pixel
52//
53//
54// WARNING: Before you can use fAsym, fM3Long and fM3Trans you must
55// multiply by the sign of MHillasSrc::fCosDeltaAlpha
56//
57////////////////////////////////////////////////////////////////////////////
58/*
59 // fAsymna d/(d na) of ( sum(x*q^na)/sum(q^na), sum(y*q^na)/sum(q^na) )
60 // projected onto the major axis
61 // fAsym0 (F-B)/(F+B) along the major axis
62 */
63#include "MHillasExt.h"
64
65#include <TArrayF.h>
66
67#include "MGeomPix.h"
68#include "MGeomCam.h"
69
70#include "MSignalPix.h"
71#include "MSignalCam.h"
72
73#include "MLog.h"
74#include "MLogManip.h"
75
76#include "MHillas.h"
77
78ClassImp(MHillasExt);
79
80using namespace std;
81
82// -------------------------------------------------------------------------
83//
84// Default constructor.
85//
86MHillasExt::MHillasExt(const char *name, const char *title)
87{
88 fName = name ? name : "MHillasExt";
89 fTitle = title ? title : "Storage container for extended parameter set of one event";
90
91 Reset();
92}
93
94// -------------------------------------------------------------------------
95//
96void MHillasExt::Reset()
97{
98 fAsym = 0;
99 fM3Long = 0;
100 fM3Trans = 0;
101
102 fMaxDist = 0;
103}
104
105// -------------------------------------------------------------------------
106//
107// Print contents of MHillasExt to *fLog.
108//
109void MHillasExt::Print(Option_t *) const
110{
111 *fLog << all;
112 *fLog << "Extended Image Parameters (" << GetName() << ")" << endl;
113 *fLog << " - Asymmetry = " << fAsym << endl;
114 *fLog << " - 3.Moment Long [mm] = " << fM3Long << endl;
115 *fLog << " - 3.Moment Trans [mm] = " << fM3Trans << endl;
116 *fLog << " - Max.Dist [mm] = " << fMaxDist << endl;
117}
118
119// -------------------------------------------------------------------------
120//
121// Print contents of MHillasExt to *fLog, depending on the geometry in
122// units of deg.
123//
124void MHillasExt::Print(const MGeomCam &geom) const
125{
126 *fLog << all;
127 *fLog << "Extended Image Parameters (" << GetName() << ")" << endl;
128 *fLog << " - Asymmetry = " << fAsym *geom.GetConvMm2Deg() << endl;
129 *fLog << " - 3.Moment Long [deg] = " << fM3Long *geom.GetConvMm2Deg() << endl;
130 *fLog << " - 3.Moment Trans [deg] = " << fM3Trans*geom.GetConvMm2Deg() << endl;
131 *fLog << " - Max.Dist [deg] = " << fMaxDist*geom.GetConvMm2Deg() << endl;
132}
133
134// -------------------------------------------------------------------------
135//
136// calculation of additional parameters based on the camera geometry
137// and the cerenkov photon event
138//
139Int_t MHillasExt::Calc(const MGeomCam &geom, const MSignalCam &evt, const MHillas &hil, Int_t island)
140{
141 //
142 // calculate the additional image parameters
143 // --------------------------------------------
144 //
145 // loop to get third moments along ellipse axes and two max pixels
146 //
147 // For the moments double precision is used to make sure, that
148 // the complex matrix multiplication and sum is evaluated correctly.
149 //
150 Double_t m3x = 0;
151 Double_t m3y = 0;
152
153 Int_t maxpixid = 0;
154 Float_t maxpix = 0;
155 Float_t maxdist = 0;
156
157 // MSignalPix *pix = 0;
158 // TIter Next(evt);
159 // while ((pix=(MSignalPix*)Next()))
160
161 const UInt_t npix = evt.GetNumPixels();
162 for (UInt_t i=0; i<npix; i++)
163 {
164 const MSignalPix &pix = evt[i];
165 if (!pix.IsPixelUsed())
166 continue;
167
168 if (island>=0 && pix.GetIdxIsland()!=island)
169 continue;
170
171 //const Int_t pixid = pix->GetPixId();
172
173 const MGeomPix &gpix = geom[i/*pixid*/];
174 const Double_t dx = gpix.GetX() - hil.GetMeanX(); // [mm]
175 const Double_t dy = gpix.GetY() - hil.GetMeanY(); // [mm]
176
177 Double_t nphot = pix.GetNumPhotons(); // [1]
178
179 const Double_t dzx = hil.GetCosDelta()*dx + hil.GetSinDelta()*dy; // [mm]
180 const Double_t dzy = -hil.GetSinDelta()*dx + hil.GetCosDelta()*dy; // [mm]
181
182 const Double_t dist = dx*dx+dy*dy;
183 if (TMath::Abs(dist)>TMath::Abs(maxdist))
184 maxdist = dzx<0 ? -dist : dist; // [mm^2]
185
186 m3x += nphot * dzx*dzx*dzx; // [mm^3]
187 m3y += nphot * dzy*dzy*dzy; // [mm^3]
188
189 //
190 // Now we are working on absolute values of nphot, which
191 // must take pixel size into account
192 //
193 nphot *= geom.GetPixRatio(i/*pixid*/);
194
195 if (nphot>maxpix)
196 {
197 maxpix = nphot; // [1]
198 maxpixid = i;//pixid;
199 continue; // [1]
200 }
201 }
202
203 const MGeomPix &maxp = geom[maxpixid];
204
205 fAsym = (hil.GetMeanX()-maxp.GetX())*hil.GetCosDelta() +
206 (hil.GetMeanY()-maxp.GetY())*hil.GetSinDelta(); // [mm]
207
208 //
209 // Third moments along axes get normalized
210 //
211 m3x /= hil.GetSize();
212 m3y /= hil.GetSize();
213
214 fM3Long = m3x<0 ? -pow(-m3x, 1./3) : pow(m3x, 1./3); // [mm]
215 fM3Trans = m3y<0 ? -pow(-m3y, 1./3) : pow(m3y, 1./3); // [mm]
216
217 const Double_t md = TMath::Sqrt(TMath::Abs(maxdist));
218 fMaxDist = maxdist<0 ? -md : md; // [mm]
219
220 SetReadyToSave();
221
222 return 0;
223}
224
225// --------------------------------------------------------------------------
226//
227// This function is ment for special usage, please never try to set
228// values via this function
229//
230void MHillasExt::Set(const TArrayF &arr)
231{
232 if (arr.GetSize() != 4)
233 return;
234
235 fAsym = arr.At(0);
236 fM3Long = arr.At(1);
237 fM3Trans = arr.At(2);
238 fMaxDist = arr.At(3);
239}
Note: See TracBrowser for help on using the repository browser.