source: tags/Mars-V0.9.4.2/mimage/MNewImagePar.cc

Last change on this file was 7188, checked in by tbretz, 19 years ago
*** empty log message ***
File size: 9.1 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): Wolfgang Wittek 03/2003 <mailto:wittek@mppmu.mpg.de>
19! Author(s): Thomas Bretz <mailto:tbretz@astro.uni-wuerzburg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2004
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MNewImagePar
29//
30// Storage Container for new image parameters
31//
32// Float_t fLeakage1; // (photons in most outer ring of pixels) over fSize
33// Float_t fLeakage2; // (photons in the 2 outer rings of pixels) over fSize
34// Float_t fInnerLeakage1; // (photons in most outer rings of inner pixels) over fInnerSize
35// Float_t fInnerLeakage2; // (photons in the 2 outer rings of inner pixels) over fInnerSize
36// Float_t fInnerSize; //
37//
38// Float_t fConc; // [ratio] concentration ratio: sum of the two highest pixels / fSize
39// Float_t fConc1; // [ratio] concentration ratio: sum of the highest pixel / fSize
40//
41// Float_t fUsedArea; // Area of pixels which survived the image cleaning
42// Float_t fCoreArea; // Area of core pixels
43// Short_t fNumUsedPixels; // Number of pixels which survived the image cleaning
44// Short_t fNumCorePixels; // number of core pixels
45// Short_t fNumHGSaturatedPixels; // number of pixels with saturating hi-gains
46// Short_t fNumSaturatedPixels; // number of pixels with saturating lo-gains
47//
48// Version 2:
49// ----------
50// - added fNumSaturatedPixels
51//
52// Version 3:
53// ----------
54// - added fNumHGSaturatedPixels
55// - added fInnerLeakage1
56// - added fInnerLeakage2
57// - added fInnerSize
58// - added fUsedArea
59// - added fCoreArea
60//
61// Version 4:
62// ----------
63// - moved cleaning/island independant parameters to MImagePar:
64// + removed fNumHGSaturatedPixels
65// + removed fNumSaturatedPixels
66//
67//
68/////////////////////////////////////////////////////////////////////////////
69#include "MNewImagePar.h"
70
71#include "MLog.h"
72#include "MLogManip.h"
73
74#include "MHillas.h"
75
76#include "MGeomCam.h"
77#include "MGeomPix.h"
78
79#include "MSignalCam.h"
80#include "MSignalPix.h"
81
82ClassImp(MNewImagePar);
83
84using namespace std;
85
86// --------------------------------------------------------------------------
87//
88// Default constructor.
89//
90MNewImagePar::MNewImagePar(const char *name, const char *title)
91{
92 fName = name ? name : "MNewImagePar";
93 fTitle = title ? title : "New image parameters";
94
95 Reset();
96}
97
98// --------------------------------------------------------------------------
99//
100void MNewImagePar::Reset()
101{
102 fLeakage1 = -1;
103 fLeakage2 = -1;
104
105 fInnerLeakage1 = -1;
106 fInnerLeakage2 = -1;
107 fInnerSize = -1;
108
109 fConc = -1;
110 fConc1 = -1;
111
112 fNumUsedPixels = -1;
113 fNumCorePixels = -1;
114
115 fUsedArea = -1;
116 fCoreArea = -1;
117}
118
119// --------------------------------------------------------------------------
120//
121// Calculation of new image parameters
122//
123void MNewImagePar::Calc(const MGeomCam &geom, const MSignalCam &evt,
124 const MHillas &hillas, Int_t island)
125{
126 fNumUsedPixels = 0;
127 fNumCorePixels = 0;
128
129 fUsedArea = 0;
130 fCoreArea = 0;
131
132 fInnerSize = 0;
133
134 Double_t edgepix1 = 0;
135 Double_t edgepix2 = 0;
136
137 Double_t edgepixin1 = 0;
138 Double_t edgepixin2 = 0;
139
140 Float_t maxpix1 = 0; // [#phot]
141 Float_t maxpix2 = 0; // [#phot]
142
143 const Bool_t ismagiclike =
144 geom.GetNumPixels() == 577 &&
145 geom.GetNumAreas() == 2 &&
146 geom.GetPixRatio(396) > geom.GetPixRatio(397);
147
148 UInt_t npix = evt.GetNumPixels();
149 for (UInt_t i=0; i<npix; i++)
150 {
151 const MSignalPix &pix = evt[i];
152 if (!pix.IsPixelUsed())
153 continue;
154
155 // Check for requested islands
156 if (island>=0 && pix.GetIdxIsland()!=island)
157 continue;
158
159 // Get geometry of pixel
160 //const Int_t pixid = pix->GetPixId();
161 const MGeomPix &gpix = geom[i/*pixid*/];
162
163 // count used and core pixels
164 if (pix.IsPixelCore())
165 {
166 fNumCorePixels++;
167 fCoreArea += gpix.GetA();
168 }
169
170 // count used pixels
171 fNumUsedPixels++;
172 fUsedArea += gpix.GetA();
173
174 Double_t nphot = pix.GetNumPhotons();
175
176 //
177 // count photons in outer rings of camera
178 //
179 if (gpix.IsInOutermostRing())
180 edgepix1 += nphot;
181 if (gpix.IsInOuterRing())
182 edgepix2 += nphot;
183
184 const Double_t ratio = geom.GetPixRatio(i);
185 if (TMath::Nint(ratio)==1) // Means this is a small (= inner pixel)
186 {
187 fInnerSize += nphot;
188
189 // Do calculation of "inner leakage" only for MAGIC-like geometry,
190 // i.e., 577 pixels, pixels of 2 different areas, inner part
191 // from pixel 0 to 396:
192 if (ismagiclike)
193 {
194 if(i > 270) // last two "rings" of inner pixels
195 {
196 edgepixin2 += nphot;
197 if(i > 330) // last "ring" of inner pixels
198 edgepixin1 += nphot;
199 }
200 }
201 }
202
203 //
204 // Now convert nphot from absolute number of photons or phe to signal
205 // density (divide by pixel area), to find the pixel with highest signal
206 // density:
207 //
208 nphot *= ratio;
209
210 // Look for signal density in two highest pixels:
211 if (nphot>maxpix1)
212 {
213 maxpix2 = maxpix1;
214 maxpix1 = nphot; // [1]
215 continue; // [1]
216 }
217
218 if (nphot>maxpix2)
219 maxpix2 = nphot; // [1]
220 }
221
222 fInnerLeakage1 = edgepixin1 / fInnerSize;
223 fInnerLeakage2 = edgepixin2 / fInnerSize;
224
225 fLeakage1 = edgepix1 / hillas.GetSize();
226 fLeakage2 = edgepix2 / hillas.GetSize();
227
228 // FIXME?: in case the pixel with highest signal density is an outer pixel,
229 // the value of fConc (ratio of signal in two highest pixels to SIZE) should
230 // rather be 2*fConc1, under the simplest assumption that the light density
231 // inside the outer (large) pixel is uniform.
232 fConc = (maxpix1+maxpix2)/hillas.GetSize(); // [ratio]
233 fConc1 = maxpix1/hillas.GetSize(); // [ratio]
234
235 SetReadyToSave();
236}
237
238// --------------------------------------------------------------------------
239//
240void MNewImagePar::Print(Option_t *) const
241{
242 *fLog << all;
243 *fLog << GetDescriptor() << endl;
244 *fLog << " - Leakage1 [1] = " << fLeakage1 << endl;
245 *fLog << " - Leakage2 [1] = " << fLeakage2 << endl;
246 *fLog << " - InnerLeakage1 [1] = " << fInnerLeakage1 << endl;
247 *fLog << " - InnerLeakage2 [1] = " << fInnerLeakage2 << endl;
248 *fLog << " - InnerSize [phe] = " << fInnerSize << endl;
249 *fLog << " - Conc [1] = " << fConc << endl;
250 *fLog << " - Conc1 [1] = " << fConc1 << endl;
251 *fLog << " - Num Used Pixels [#] = " << fNumUsedPixels << endl;
252 *fLog << " - Num Core Pixels [#] = " << fNumCorePixels << endl;
253 *fLog << " - Used Area [mm^2] = " << fUsedArea << endl;
254 *fLog << " - Core Area [mm^2] = " << fCoreArea << endl;
255}
256
257// -------------------------------------------------------------------------
258//
259// Print contents of MNewImagePar to *fLog, depending on the geometry in
260// units of deg.
261//
262void MNewImagePar::Print(const MGeomCam &geom) const
263{
264 *fLog << all;
265 *fLog << GetDescriptor() << endl;
266 *fLog << " - Leakage1 [1] = " << fLeakage1 << endl;
267 *fLog << " - Leakage2 [1] = " << fLeakage2 << endl;
268 *fLog << " - InnerLeakage1 [1] = " << fInnerLeakage1 << endl;
269 *fLog << " - InnerLeakage2 [1] = " << fInnerLeakage2 << endl;
270 *fLog << " - InnerSize [phe] = " << fInnerSize << endl;
271 *fLog << " - Conc [1] = " << fConc << endl;
272 *fLog << " - Conc1 [1] = " << fConc1 << endl;
273 *fLog << " - Num Used Pixels [#] = " << fNumUsedPixels << endl;
274 *fLog << " - Num Core Pixels [#] = " << fNumCorePixels << endl;
275 *fLog << " - Used Area [deg^2] = " << fUsedArea*geom.GetConvMm2Deg()*geom.GetConvMm2Deg() << endl;
276 *fLog << " - Core Area [deg^2] = " << fCoreArea*geom.GetConvMm2Deg()*geom.GetConvMm2Deg() << endl;
277}
Note: See TracBrowser for help on using the repository browser.