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

Last change on this file since 5814 was 4826, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 7.0 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 "MCerPhotPix.h"
71#include "MCerPhotEvt.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 MCerPhotEvt &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 MCerPhotPix *pix = 0;
158
159 TIter Next(evt);
160 while ((pix=(MCerPhotPix*)Next()))
161 {
162 if (island>=0 && pix->GetIdxIsland()!=island)
163 continue;
164
165 const Int_t pixid = pix->GetPixId();
166
167 const MGeomPix &gpix = geom[pixid];
168 const Double_t dx = gpix.GetX() - hil.GetMeanX(); // [mm]
169 const Double_t dy = gpix.GetY() - hil.GetMeanY(); // [mm]
170
171 Double_t nphot = pix->GetNumPhotons(); // [1]
172
173 const Double_t dzx = hil.GetCosDelta()*dx + hil.GetSinDelta()*dy; // [mm]
174 const Double_t dzy = -hil.GetSinDelta()*dx + hil.GetCosDelta()*dy; // [mm]
175
176 const Double_t dist = dx*dx+dy*dy;
177 if (TMath::Abs(dist)>TMath::Abs(maxdist))
178 maxdist = dzx<0 ? -dist : dist; // [mm^2]
179
180 m3x += nphot * dzx*dzx*dzx; // [mm^3]
181 m3y += nphot * dzy*dzy*dzy; // [mm^3]
182
183 //
184 // Now we are working on absolute values of nphot, which
185 // must take pixel size into account
186 //
187 nphot *= geom.GetPixRatio(pixid);
188
189 if (nphot>maxpix)
190 {
191 maxpix = nphot; // [1]
192 maxpixid = pixid;
193 continue; // [1]
194 }
195 }
196
197 const MGeomPix &maxp = geom[maxpixid];
198
199 fAsym = (hil.GetMeanX()-maxp.GetX())*hil.GetCosDelta() +
200 (hil.GetMeanY()-maxp.GetY())*hil.GetSinDelta(); // [mm]
201
202 //
203 // Third moments along axes get normalized
204 //
205 m3x /= hil.GetSize();
206 m3y /= hil.GetSize();
207
208 fM3Long = m3x<0 ? -pow(-m3x, 1./3) : pow(m3x, 1./3); // [mm]
209 fM3Trans = m3y<0 ? -pow(-m3y, 1./3) : pow(m3y, 1./3); // [mm]
210
211 const Double_t md = TMath::Sqrt(TMath::Abs(maxdist));
212 fMaxDist = maxdist<0 ? -md : md; // [mm]
213
214 SetReadyToSave();
215
216 return 0;
217}
218
219// --------------------------------------------------------------------------
220//
221// This function is ment for special usage, please never try to set
222// values via this function
223//
224void MHillasExt::Set(const TArrayF &arr)
225{
226 if (arr.GetSize() != 4)
227 return;
228
229 fAsym = arr.At(0);
230 fM3Long = arr.At(1);
231 fM3Trans = arr.At(2);
232 fMaxDist = arr.At(3);
233}
Note: See TracBrowser for help on using the repository browser.