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

Last change on this file since 3450 was 2624, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 6.6 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//
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//
50// WARNING: Before you can use fAsym, fM3Long and fM3Trans you must
51// multiply by the sign of MHillasSrc::fCosDeltaAlpha
52//
53////////////////////////////////////////////////////////////////////////////
54/*
55 // fAsymna d/(d na) of ( sum(x*q^na)/sum(q^na), sum(y*q^na)/sum(q^na) )
56 // projected onto the major axis
57 // fAsym0 (F-B)/(F+B) along the major axis
58 */
59#include "MHillasExt.h"
60
61#include <fstream>
62#include <TArrayF.h>
63
64#include "MGeomPix.h"
65#include "MGeomCam.h"
66
67#include "MCerPhotPix.h"
68#include "MCerPhotEvt.h"
69
70#include "MLog.h"
71#include "MLogManip.h"
72
73#include "MHillas.h"
74
75ClassImp(MHillasExt);
76
77using namespace std;
78
79// -------------------------------------------------------------------------
80//
81// Default constructor.
82//
83MHillasExt::MHillasExt(const char *name, const char *title)
84{
85 fName = name ? name : "MHillasExt";
86 fTitle = title ? title : "Storage container for extended parameter set of one event";
87
88 Reset();
89}
90
91// -------------------------------------------------------------------------
92//
93void MHillasExt::Reset()
94{
95 fAsym = 0;
96 fM3Long = 0;
97 fM3Trans = 0;
98}
99
100// -------------------------------------------------------------------------
101//
102// Print contents of MHillasExt to *fLog.
103//
104void MHillasExt::Print(Option_t *) const
105{
106 *fLog << all;
107 *fLog << "Extended Image Parameters (" << GetName() << ")" << endl;
108 *fLog << " - Asymmetry = " << fAsym << endl;
109 *fLog << " - 3.Moment Long [mm] = " << fM3Long << endl;
110 *fLog << " - 3.Moment Trans [mm] = " << fM3Trans << endl;
111}
112
113// -------------------------------------------------------------------------
114//
115// Print contents of MHillasExt to *fLog, depending on the geometry in
116// units of deg.
117//
118void MHillasExt::Print(const MGeomCam &geom) const
119{
120 *fLog << all;
121 *fLog << "Extended Image Parameters (" << GetName() << ")" << endl;
122 *fLog << " - Asymmetry = " << fAsym *geom.GetConvMm2Deg() << endl;
123 *fLog << " - 3.Moment Long [deg] = " << fM3Long *geom.GetConvMm2Deg() << endl;
124 *fLog << " - 3.Moment Trans [deg] = " << fM3Trans*geom.GetConvMm2Deg() << endl;
125}
126
127// -------------------------------------------------------------------------
128//
129// calculation of additional parameters based on the camera geometry
130// and the cerenkov photon event
131//
132Int_t MHillasExt::Calc(const MGeomCam &geom, const MCerPhotEvt &evt, const MHillas &hil)
133{
134 //
135 // calculate the additional image parameters
136 // --------------------------------------------
137 //
138 // loop to get third moments along ellipse axes and two max pixels
139 //
140 // For the moments double precision is used to make sure, that
141 // the complex matrix multiplication and sum is evaluated correctly.
142 //
143 Double_t m3x = 0;
144 Double_t m3y = 0;
145
146 const UInt_t npixevt = evt.GetNumPixels();
147
148 Int_t maxpixid = 0;
149 Float_t maxpix = 0;
150
151 for (UInt_t i=0; i<npixevt; i++)
152 {
153 const MCerPhotPix &pix = evt[i];
154 if (!pix.IsPixelUsed())
155 continue;
156
157 const Int_t pixid = pix.GetPixId();
158
159 const MGeomPix &gpix = geom[pixid];
160 const Double_t dx = gpix.GetX() - hil.GetMeanX(); // [mm]
161 const Double_t dy = gpix.GetY() - hil.GetMeanY(); // [mm]
162
163 Double_t nphot = pix.GetNumPhotons(); // [1]
164
165 const Double_t dzx = hil.GetCosDelta()*dx + hil.GetSinDelta()*dy; // [mm]
166 const Double_t dzy = -hil.GetSinDelta()*dx + hil.GetCosDelta()*dy; // [mm]
167
168 m3x += nphot * dzx*dzx*dzx; // [mm^3]
169 m3y += nphot * dzy*dzy*dzy; // [mm^3]
170
171 //
172 // Now we are working on absolute values of nphot, which
173 // must take pixel size into account
174 //
175 nphot *= geom.GetPixRatio(pixid);
176
177 if (nphot>maxpix)
178 {
179 maxpix = nphot; // [1]
180 maxpixid = pixid;
181 continue; // [1]
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 // 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 SetReadyToSave();
200
201 return 0;
202}
203
204// --------------------------------------------------------------------------
205//
206// This function is ment for special usage, please never try to set
207// values via this function
208//
209void MHillasExt::Set(const TArrayF &arr)
210{
211 if (arr.GetSize() != 3)
212 return;
213
214 fAsym = arr.At(0); // [mm] fDist minus dist: center of ellipse, highest pixel
215 fM3Long = arr.At(1); // [mm] 3rd moment (e-weighted) along major axis
216 fM3Trans = arr.At(2); // [mm] 3rd moment (e-weighted) along minor axis
217}
Note: See TracBrowser for help on using the repository browser.