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

Last change on this file since 2591 was 2173, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 6.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@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//
102void MHillasExt::Print(Option_t *) const
103{
104 *fLog << "Extended Image Parameters (" << GetName() << ")" << endl;
105 *fLog << " - Asymmetry = " << fAsym << " mm" << endl;
106 *fLog << " - 3rd Moment Long = " << fM3Long << " mm" << endl;
107 *fLog << " - 3rd Moment Trans = " << fM3Trans << " mm" << endl;
108}
109
110// -------------------------------------------------------------------------
111//
112// calculation of additional parameters based on the camera geometry
113// and the cerenkov photon event
114//
115Int_t MHillasExt::Calc(const MGeomCam &geom, const MCerPhotEvt &evt, const MHillas &hil)
116{
117 //
118 // calculate the additional image parameters
119 // --------------------------------------------
120 //
121 // loop to get third moments along ellipse axes and two max pixels
122 //
123 // For the moments double precision is used to make sure, that
124 // the complex matrix multiplication and sum is evaluated correctly.
125 //
126 Double_t m3x = 0;
127 Double_t m3y = 0;
128
129 const UInt_t npixevt = evt.GetNumPixels();
130
131 Int_t maxpixid = 0;
132 Float_t maxpix = 0;
133
134 for (UInt_t i=0; i<npixevt; i++)
135 {
136 const MCerPhotPix &pix = evt[i];
137 if (!pix.IsPixelUsed())
138 continue;
139
140 const Int_t pixid = pix.GetPixId();
141
142 const MGeomPix &gpix = geom[pixid];
143 const Double_t dx = gpix.GetX() - hil.GetMeanX(); // [mm]
144 const Double_t dy = gpix.GetY() - hil.GetMeanY(); // [mm]
145
146 Double_t nphot = pix.GetNumPhotons(); // [1]
147
148 const Double_t dzx = hil.GetCosDelta()*dx + hil.GetSinDelta()*dy; // [mm]
149 const Double_t dzy = -hil.GetSinDelta()*dx + hil.GetCosDelta()*dy; // [mm]
150
151 m3x += nphot * dzx*dzx*dzx; // [mm^3]
152 m3y += nphot * dzy*dzy*dzy; // [mm^3]
153
154 //
155 // Now we are working on absolute values of nphot, which
156 // must take pixel size into account
157 //
158 nphot *= geom.GetPixRatio(pixid);
159
160 if (nphot>maxpix)
161 {
162 maxpix = nphot; // [1]
163 maxpixid = pixid;
164 continue; // [1]
165 }
166 }
167
168 const MGeomPix &maxp = geom[maxpixid];
169
170 fAsym = (hil.GetMeanX()-maxp.GetX())*hil.GetCosDelta() +
171 (hil.GetMeanY()-maxp.GetY())*hil.GetSinDelta(); // [mm]
172
173 //
174 // Third moments along axes get normalized
175 //
176 m3x /= hil.GetSize();
177 m3y /= hil.GetSize();
178
179 fM3Long = m3x<0 ? -pow(-m3x, 1./3) : pow(m3x, 1./3); // [mm]
180 fM3Trans = m3y<0 ? -pow(-m3y, 1./3) : pow(m3y, 1./3); // [mm]
181
182 SetReadyToSave();
183
184 return 0;
185}
186
187// --------------------------------------------------------------------------
188//
189// This function is ment for special usage, please never try to set
190// values via this function
191//
192void MHillasExt::Set(const TArrayF &arr)
193{
194 if (arr.GetSize() != 3)
195 return;
196
197 fAsym = arr.At(0); // [mm] fDist minus dist: center of ellipse, highest pixel
198 fM3Long = arr.At(1); // [mm] 3rd moment (e-weighted) along major axis
199 fM3Trans = arr.At(2); // [mm] 3rd moment (e-weighted) along minor axis
200}
Note: See TracBrowser for help on using the repository browser.