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

Last change on this file since 7977 was 7784, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 8.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#include <TMarker.h>
67#include <TVector2.h>
68#include <TVirtualPad.h>
69
70#include "MGeomPix.h"
71#include "MGeomCam.h"
72
73#include "MSignalPix.h"
74#include "MSignalCam.h"
75
76#include "MLog.h"
77#include "MLogManip.h"
78
79#include "MHillas.h"
80
81ClassImp(MHillasExt);
82
83using namespace std;
84
85// -------------------------------------------------------------------------
86//
87// Default constructor.
88//
89MHillasExt::MHillasExt(const char *name, const char *title)
90{
91 fName = name ? name : "MHillasExt";
92 fTitle = title ? title : "Storage container for extended parameter set of one event";
93
94 Reset();
95}
96
97// -------------------------------------------------------------------------
98//
99// Reset values to:
100// fAsym = 0;
101// fM3Long = 0;
102// fM3Trans = 0;
103// fMaxDist = 0;
104//
105void MHillasExt::Reset()
106{
107 fAsym = 0;
108 fM3Long = 0;
109 fM3Trans = 0;
110
111 fMaxDist = 0;
112}
113
114// -------------------------------------------------------------------------
115//
116// calculation of additional parameters based on the camera geometry
117// and the cerenkov photon event
118//
119Int_t MHillasExt::Calc(const MGeomCam &geom, const MSignalCam &evt, const MHillas &hil, Int_t island)
120{
121 //
122 // calculate the additional image parameters
123 // --------------------------------------------
124 //
125 // loop to get third moments along ellipse axes and two max pixels
126 //
127 // For the moments double precision is used to make sure, that
128 // the complex matrix multiplication and sum is evaluated correctly.
129 //
130 Double_t m3x = 0;
131 Double_t m3y = 0;
132
133 Int_t maxpixid = 0;
134 Float_t maxpix = 0;
135 Float_t maxdist = 0;
136
137 // MSignalPix *pix = 0;
138 // TIter Next(evt);
139 // while ((pix=(MSignalPix*)Next()))
140
141 const UInt_t npix = evt.GetNumPixels();
142 for (UInt_t i=0; i<npix; i++)
143 {
144 const MSignalPix &pix = evt[i];
145 if (!pix.IsPixelUsed())
146 continue;
147
148 if (island>=0 && pix.GetIdxIsland()!=island)
149 continue;
150
151 //const Int_t pixid = pix->GetPixId();
152
153 const MGeomPix &gpix = geom[i/*pixid*/];
154 const Double_t dx = gpix.GetX() - hil.GetMeanX(); // [mm]
155 const Double_t dy = gpix.GetY() - hil.GetMeanY(); // [mm]
156
157 Double_t nphot = pix.GetNumPhotons(); // [1]
158
159 const Double_t dzx = hil.GetCosDelta()*dx + hil.GetSinDelta()*dy; // [mm]
160 const Double_t dzy = -hil.GetSinDelta()*dx + hil.GetCosDelta()*dy; // [mm]
161
162 const Double_t dist = dx*dx+dy*dy;
163 if (dist>TMath::Abs(maxdist))
164 maxdist = dzx<0 ? -dist : dist; // [mm^2]
165
166 m3x += nphot * dzx*dzx*dzx; // [mm^3]
167 m3y += nphot * dzy*dzy*dzy; // [mm^3]
168
169 //
170 // Now we are working on absolute values of nphot, which
171 // must take pixel size into account
172 //
173 nphot *= geom.GetPixRatio(i/*pixid*/);
174
175 if (nphot>maxpix)
176 {
177 maxpix = nphot; // [1]
178 maxpixid = i;//pixid;
179 }
180 }
181
182 const MGeomPix &maxp = geom[maxpixid];
183
184 //
185 // Asymmetry
186 //
187 fAsym = (hil.GetMeanX()-maxp.GetX())*hil.GetCosDelta() +
188 (hil.GetMeanY()-maxp.GetY())*hil.GetSinDelta(); // [mm]
189
190 //
191 // Third moments along axes get normalized
192 //
193 m3x /= hil.GetSize();
194 m3y /= hil.GetSize();
195
196 fM3Long = m3x<0 ? -pow(-m3x, 1./3) : pow(m3x, 1./3); // [mm]
197 fM3Trans = m3y<0 ? -pow(-m3y, 1./3) : pow(m3y, 1./3); // [mm]
198
199 //
200 // Distance between max signal and COG
201 //
202 const Double_t md = TMath::Sqrt(TMath::Abs(maxdist));
203 fMaxDist = maxdist<0 ? -md : md; // [mm]
204
205 SetReadyToSave();
206
207 return 0;
208}
209
210// --------------------------------------------------------------------------
211//
212// This function is ment for special usage, please never try to set
213// values via this function
214//
215void MHillasExt::Set(const TArrayF &arr)
216{
217 if (arr.GetSize() != 4)
218 return;
219
220 fAsym = arr.At(0);
221 fM3Long = arr.At(1);
222 fM3Trans = arr.At(2);
223 fMaxDist = arr.At(3);
224}
225
226// -------------------------------------------------------------------------
227//
228// Print contents of MHillasExt to *fLog.
229//
230void MHillasExt::Print(Option_t *) const
231{
232 *fLog << all;
233 *fLog << GetDescriptor() << endl;
234 *fLog << " - Asymmetry [mm] = " << fAsym << endl;
235 *fLog << " - 3.Moment Long [mm] = " << fM3Long << endl;
236 *fLog << " - 3.Moment Trans [mm] = " << fM3Trans << endl;
237 *fLog << " - Max.Dist [mm] = " << fMaxDist << endl;
238}
239
240// -------------------------------------------------------------------------
241//
242// Print contents of MHillasExt to *fLog, depending on the geometry in
243// units of deg.
244//
245void MHillasExt::Print(const MGeomCam &geom) const
246{
247 *fLog << all;
248 *fLog << GetDescriptor() << endl;
249 *fLog << " - Asymmetry [deg] = " << fAsym *geom.GetConvMm2Deg() << endl;
250 *fLog << " - 3.Moment Long [deg] = " << fM3Long *geom.GetConvMm2Deg() << endl;
251 *fLog << " - 3.Moment Trans [deg] = " << fM3Trans*geom.GetConvMm2Deg() << endl;
252 *fLog << " - Max.Dist [deg] = " << fMaxDist*geom.GetConvMm2Deg() << endl;
253}
254
255// -------------------------------------------------------------------------
256//
257// Paint the 3rd moment on top of the shower. Therefor "MHillas" is needed.
258// it is searched via gPad->FindObject. If opt is not IsNull an object with
259// the name opt is searched.
260//
261void MHillasExt::Paint(Option_t *opt)
262{
263 const TString name(opt);
264
265 const MHillas *hil = dynamic_cast<const MHillas*>(gPad->FindObject(name.IsNull() ? "MHillas" : name.Data()));
266 if (!hil)
267 return;
268
269 TVector2 v(fM3Long, fM3Trans);
270 v = v.Rotate(hil->GetDelta()+TMath::Pi());
271 v += hil->GetMean();
272
273 TMarker m;
274 m.SetMarkerColor(15);
275 m.SetMarkerStyle(kFullDotLarge);
276 m.PaintMarker(v.X(), v.Y());
277}
Note: See TracBrowser for help on using the repository browser.