source: tags/Mars-V0.9.4.3/mimage/MHillasExt.cc

Last change on this file was 7181, checked in by tbretz, 19 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 (TMath::Abs(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 continue; // [1]
180 }
181 }
182
183 const MGeomPix &maxp = geom[maxpixid];
184
185 fAsym = (hil.GetMeanX()-maxp.GetX())*hil.GetCosDelta() +
186 (hil.GetMeanY()-maxp.GetY())*hil.GetSinDelta(); // [mm]
187
188 //
189 // Third moments along axes get normalized
190 //
191 m3x /= hil.GetSize();
192 m3y /= hil.GetSize();
193
194 fM3Long = m3x<0 ? -pow(-m3x, 1./3) : pow(m3x, 1./3); // [mm]
195 fM3Trans = m3y<0 ? -pow(-m3y, 1./3) : pow(m3y, 1./3); // [mm]
196
197 const Double_t md = TMath::Sqrt(TMath::Abs(maxdist));
198 fMaxDist = maxdist<0 ? -md : md; // [mm]
199
200 SetReadyToSave();
201
202 return 0;
203}
204
205// --------------------------------------------------------------------------
206//
207// This function is ment for special usage, please never try to set
208// values via this function
209//
210void MHillasExt::Set(const TArrayF &arr)
211{
212 if (arr.GetSize() != 4)
213 return;
214
215 fAsym = arr.At(0);
216 fM3Long = arr.At(1);
217 fM3Trans = arr.At(2);
218 fMaxDist = arr.At(3);
219}
220
221// -------------------------------------------------------------------------
222//
223// Print contents of MHillasExt to *fLog.
224//
225void MHillasExt::Print(Option_t *) const
226{
227 *fLog << all;
228 *fLog << GetDescriptor() << endl;
229 *fLog << " - Asymmetry [mm] = " << fAsym << endl;
230 *fLog << " - 3.Moment Long [mm] = " << fM3Long << endl;
231 *fLog << " - 3.Moment Trans [mm] = " << fM3Trans << endl;
232 *fLog << " - Max.Dist [mm] = " << fMaxDist << endl;
233}
234
235// -------------------------------------------------------------------------
236//
237// Print contents of MHillasExt to *fLog, depending on the geometry in
238// units of deg.
239//
240void MHillasExt::Print(const MGeomCam &geom) const
241{
242 *fLog << all;
243 *fLog << GetDescriptor() << endl;
244 *fLog << " - Asymmetry [deg] = " << fAsym *geom.GetConvMm2Deg() << endl;
245 *fLog << " - 3.Moment Long [deg] = " << fM3Long *geom.GetConvMm2Deg() << endl;
246 *fLog << " - 3.Moment Trans [deg] = " << fM3Trans*geom.GetConvMm2Deg() << endl;
247 *fLog << " - Max.Dist [deg] = " << fMaxDist*geom.GetConvMm2Deg() << endl;
248}
249
250// -------------------------------------------------------------------------
251//
252// Paint the 3rd moment on top of the shower. Therefor "MHillas" is needed.
253// it is searched via gPad->FindObject. If opt is not IsNull an object with
254// the name opt is searched.
255//
256void MHillasExt::Paint(Option_t *opt)
257{
258 const TString name(opt);
259
260 const MHillas *hil = dynamic_cast<const MHillas*>(gPad->FindObject(name.IsNull() ? "MHillas" : name));
261 if (!hil)
262 return;
263
264 TVector2 v(fM3Long, fM3Trans);
265 v = v.Rotate(hil->GetDelta()+TMath::Pi());
266 v += hil->GetMean();
267
268 TMarker m;
269 m.SetMarkerColor(15);
270 m.SetMarkerStyle(kFullDotLarge);
271 m.PaintMarker(v.X(), v.Y());
272}
Note: See TracBrowser for help on using the repository browser.