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

Last change on this file since 7033 was 6869, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 7.1 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// calculation of additional parameters based on the camera geometry
108// and the cerenkov photon event
109//
110Int_t MHillasExt::Calc(const MGeomCam &geom, const MSignalCam &evt, const MHillas &hil, Int_t island)
111{
112 //
113 // calculate the additional image parameters
114 // --------------------------------------------
115 //
116 // loop to get third moments along ellipse axes and two max pixels
117 //
118 // For the moments double precision is used to make sure, that
119 // the complex matrix multiplication and sum is evaluated correctly.
120 //
121 Double_t m3x = 0;
122 Double_t m3y = 0;
123
124 Int_t maxpixid = 0;
125 Float_t maxpix = 0;
126 Float_t maxdist = 0;
127
128 // MSignalPix *pix = 0;
129 // TIter Next(evt);
130 // while ((pix=(MSignalPix*)Next()))
131
132 const UInt_t npix = evt.GetNumPixels();
133 for (UInt_t i=0; i<npix; i++)
134 {
135 const MSignalPix &pix = evt[i];
136 if (!pix.IsPixelUsed())
137 continue;
138
139 if (island>=0 && pix.GetIdxIsland()!=island)
140 continue;
141
142 //const Int_t pixid = pix->GetPixId();
143
144 const MGeomPix &gpix = geom[i/*pixid*/];
145 const Double_t dx = gpix.GetX() - hil.GetMeanX(); // [mm]
146 const Double_t dy = gpix.GetY() - hil.GetMeanY(); // [mm]
147
148 Double_t nphot = pix.GetNumPhotons(); // [1]
149
150 const Double_t dzx = hil.GetCosDelta()*dx + hil.GetSinDelta()*dy; // [mm]
151 const Double_t dzy = -hil.GetSinDelta()*dx + hil.GetCosDelta()*dy; // [mm]
152
153 const Double_t dist = dx*dx+dy*dy;
154 if (TMath::Abs(dist)>TMath::Abs(maxdist))
155 maxdist = dzx<0 ? -dist : dist; // [mm^2]
156
157 m3x += nphot * dzx*dzx*dzx; // [mm^3]
158 m3y += nphot * dzy*dzy*dzy; // [mm^3]
159
160 //
161 // Now we are working on absolute values of nphot, which
162 // must take pixel size into account
163 //
164 nphot *= geom.GetPixRatio(i/*pixid*/);
165
166 if (nphot>maxpix)
167 {
168 maxpix = nphot; // [1]
169 maxpixid = i;//pixid;
170 continue; // [1]
171 }
172 }
173
174 const MGeomPix &maxp = geom[maxpixid];
175
176 fAsym = (hil.GetMeanX()-maxp.GetX())*hil.GetCosDelta() +
177 (hil.GetMeanY()-maxp.GetY())*hil.GetSinDelta(); // [mm]
178
179 //
180 // Third moments along axes get normalized
181 //
182 m3x /= hil.GetSize();
183 m3y /= hil.GetSize();
184
185 fM3Long = m3x<0 ? -pow(-m3x, 1./3) : pow(m3x, 1./3); // [mm]
186 fM3Trans = m3y<0 ? -pow(-m3y, 1./3) : pow(m3y, 1./3); // [mm]
187
188 const Double_t md = TMath::Sqrt(TMath::Abs(maxdist));
189 fMaxDist = maxdist<0 ? -md : md; // [mm]
190
191 SetReadyToSave();
192
193 return 0;
194}
195
196// --------------------------------------------------------------------------
197//
198// This function is ment for special usage, please never try to set
199// values via this function
200//
201void MHillasExt::Set(const TArrayF &arr)
202{
203 if (arr.GetSize() != 4)
204 return;
205
206 fAsym = arr.At(0);
207 fM3Long = arr.At(1);
208 fM3Trans = arr.At(2);
209 fMaxDist = arr.At(3);
210}
211
212// -------------------------------------------------------------------------
213//
214// Print contents of MHillasExt to *fLog.
215//
216void MHillasExt::Print(Option_t *) const
217{
218 *fLog << all;
219 *fLog << GetDescriptor() << endl;
220 *fLog << " - Asymmetry = " << fAsym << endl;
221 *fLog << " - 3.Moment Long [mm] = " << fM3Long << endl;
222 *fLog << " - 3.Moment Trans [mm] = " << fM3Trans << endl;
223 *fLog << " - Max.Dist [mm] = " << fMaxDist << endl;
224}
225
226// -------------------------------------------------------------------------
227//
228// Print contents of MHillasExt to *fLog, depending on the geometry in
229// units of deg.
230//
231void MHillasExt::Print(const MGeomCam &geom) const
232{
233 *fLog << all;
234 *fLog << GetDescriptor() << endl;
235 *fLog << " - Asymmetry = " << fAsym *geom.GetConvMm2Deg() << endl;
236 *fLog << " - 3.Moment Long [deg] = " << fM3Long *geom.GetConvMm2Deg() << endl;
237 *fLog << " - 3.Moment Trans [deg] = " << fM3Trans*geom.GetConvMm2Deg() << endl;
238 *fLog << " - Max.Dist [deg] = " << fMaxDist*geom.GetConvMm2Deg() << endl;
239}
Note: See TracBrowser for help on using the repository browser.