source: trunk/MagicSoft/Mars/manalysis/MHillasExt.cc@ 1292

Last change on this file since 1292 was 1222, checked in by tbretz, 23 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!
21! Copyright: MAGIC Software Development, 2000-2002
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MHillasExt
29//
30// Storage Container for extended image parameters
31//
32// extended image parameters
33// fConc ratio of sum of two highest pixels over fSize
34// fConc1 ratio of highest pixel over fSize
35// fAsym distance from highest pixel to center, projected onto major axis
36// fM3Long third moment along major axis
37// fM3Trans third moment along minor axis
38//
39////////////////////////////////////////////////////////////////////////////
40#include "MHillasExt.h"
41
42#include <fstream.h>
43
44#include "MGeomPix.h"
45#include "MGeomCam.h"
46
47#include "MCerPhotPix.h"
48#include "MCerPhotEvt.h"
49
50#include "MLog.h"
51#include "MLogManip.h"
52
53ClassImp(MHillasExt);
54
55// -------------------------------------------------------------------------
56//
57// Default constructor.
58//
59MHillasExt::MHillasExt(const char *name, const char *title)
60{
61 fName = name ? name : "MHillas";
62 fTitle = title ? title : "Storage container for extended parameter set of one event";
63
64 Reset();
65 // FIXME: (intelligent) initialization of values missing
66}
67
68// -------------------------------------------------------------------------
69//
70void MHillasExt::Reset()
71{
72 MHillas::Reset();
73
74 fConc = 0;
75 fConc1 = 0;
76 fAsym = 0;
77 fM3Long = 0;
78 fM3Trans = 0;
79}
80
81// -------------------------------------------------------------------------
82//
83void MHillasExt::Print(Option_t *) const
84{
85 MHillas::Print();
86
87 *fLog << "Extended Image Parameters (" << GetName() << ")" << endl;
88 *fLog << " - Conc = " << fConc << " (ratio)" << endl;
89 *fLog << " - Conc1 = " << fConc1 << " (ratio)" << endl;
90 *fLog << " - Asymmetry = " << fAsym << " mm" << endl;
91 *fLog << " - 3rd Moment Long = " << fM3Long << " mm" << endl;
92 *fLog << " - 3rd Moment Trans = " << fM3Trans << " mm" << endl;
93}
94
95// -------------------------------------------------------------------------
96//
97// calculation of additional parameters based on the camera geometry
98// and the cerenkov photon event
99//
100Bool_t MHillasExt::Calc(const MGeomCam &geom, const MCerPhotEvt &evt)
101{
102 if (!MHillas::Calc(geom, evt))
103 return kFALSE;
104
105 //
106 // calculate the additional image parameters
107 // --------------------------------------------
108 //
109 // loop to get third moments along ellipse axes and two max pixels
110 //
111 float m3x = 0;
112 float m3y = 0;
113
114 float maxpix1 = 0; // [#phot]
115 float maxpix2 = 0; // [#phot]
116
117 float maxpixx = 0; // [mm]
118 float maxpixy = 0; // [mm]
119
120 const UInt_t npixevt = evt.GetNumPixels();
121
122 for (UInt_t i=0; i<npixevt; i++)
123 {
124 const MCerPhotPix &pix = evt[i];
125 if (!pix.IsPixelUsed())
126 continue;
127
128 const MGeomPix &gpix = geom[pix.GetPixId()];
129 const float dx = gpix.GetX() - GetMeanX(); // [mm]
130 const float dy = gpix.GetY() - GetMeanY(); // [mm]
131
132 const float nphot = pix.GetNumPhotons(); // [1]
133
134 const float dzx = GetCosDelta()*dx + GetSinDelta()*dy; // [mm]
135 const float dzy = -GetSinDelta()*dx + GetCosDelta()*dy; // [mm]
136
137 m3x += nphot * dzx*dzx*dzx; // [mm^3]
138 m3y += nphot * dzy*dzy*dzy; // [mm^3]
139
140 if (nphot>maxpix1)
141 {
142 maxpix2 = maxpix1;
143 maxpix1 = nphot; // [1]
144 maxpixx = dx + GetMeanX(); // [mm]
145 maxpixy = dy + GetMeanY(); // [mm]
146 continue; // [1]
147 }
148
149 if (nphot>maxpix2)
150 maxpix2 = nphot; // [1]
151 }
152
153 fAsym = (GetMeanX()-maxpixx)*GetCosDelta() + (GetMeanY()-maxpixy)*GetSinDelta(); // [mm]
154 fConc = (maxpix1+maxpix2)/GetSize(); // [ratio]
155 fConc1 = maxpix1/GetSize(); // [ratio]
156
157 //
158 // Third moments along axes get normalized
159 //
160 m3x /= GetSize();
161 m3y /= GetSize();
162
163 fM3Long = m3x<0 ? -pow(-m3x, 1./3) : pow(m3x, 1./3); // [mm]
164 fM3Trans = m3y<0 ? -pow(-m3y, 1./3) : pow(m3y, 1./3); // [mm]
165
166 SetReadyToSave();
167
168 return kTRUE;
169}
170
171// -------------------------------------------------------------------------
172//
173void MHillasExt::AsciiRead(ifstream &fin)
174{
175 MHillas::AsciiRead(fin);
176
177 fin >> fConc;
178 fin >> fConc1;
179 fin >> fAsym;
180 fin >> fM3Long;
181 fin >> fM3Trans;
182}
183
184// -------------------------------------------------------------------------
185/*
186void MHillasExt::AsciiWrite(ofstream &fout) const
187{
188 MHillas::AsciiWrite(fout);
189
190 fout << " ";
191 fout << fConc << " ";
192 fout << fConc1 << " ";
193 fout << fAsym << " ";
194 fout << fM3Long << " ";
195 fout << fM3Trans;
196}
197*/
Note: See TracBrowser for help on using the repository browser.