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

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