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

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