source: trunk/MagicSoft/Mars/mimage/MNewImagePar.cc@ 4384

Last change on this file since 4384 was 4188, checked in by rico, 21 years ago
*** empty log message ***
File size: 8.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): 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//
62/////////////////////////////////////////////////////////////////////////////
63#include "MNewImagePar.h"
64
65#include <fstream>
66
67#include "MLog.h"
68#include "MLogManip.h"
69
70#include "MHillas.h"
71
72#include "MGeomCam.h"
73#include "MGeomPix.h"
74
75#include "MCerPhotEvt.h"
76#include "MCerPhotPix.h"
77
78ClassImp(MNewImagePar);
79
80using namespace std;
81
82// --------------------------------------------------------------------------
83//
84// Default constructor.
85//
86MNewImagePar::MNewImagePar(const char *name, const char *title)
87{
88 fName = name ? name : "MNewImagePar";
89 fTitle = title ? title : "New image parameters";
90}
91
92// --------------------------------------------------------------------------
93//
94void MNewImagePar::Reset()
95{
96 fLeakage1 = -1;
97 fLeakage2 = -1;
98
99 fInnerLeakage1 = -1;
100 fInnerLeakage2 = -1;
101 fInnerSize = -1;
102
103 fConc = -1;
104 fConc1 = -1;
105
106 fNumUsedPixels = -1;
107 fNumCorePixels = -1;
108
109 fUsedArea = -1;
110 fCoreArea = -1;
111
112 fNumSaturatedPixels = -1;
113 fNumHGSaturatedPixels = -1;
114}
115
116// --------------------------------------------------------------------------
117//
118// Calculation of new image parameters
119//
120void MNewImagePar::Calc(const MGeomCam &geom, const MCerPhotEvt &evt,
121 const MHillas &hillas)
122{
123 fNumUsedPixels = 0;
124 fNumCorePixels = 0;
125
126 fUsedArea = 0;
127 fCoreArea = 0;
128
129 fNumSaturatedPixels = 0;
130 fNumHGSaturatedPixels = 0;
131
132 fInnerSize = 0;
133
134 const UInt_t npixevt = evt.GetNumPixels();
135
136 Double_t edgepix1 = 0;
137 Double_t edgepix2 = 0;
138
139 Double_t edgepixin1 = 0;
140 Double_t edgepixin2 = 0;
141
142 Float_t maxpix1 = 0; // [#phot]
143 Float_t maxpix2 = 0; // [#phot]
144
145 for (UInt_t i=0; i<npixevt; i++)
146 {
147 const MCerPhotPix &pix = evt[i];
148
149 // count saturated pixels
150 if (pix.IsPixelHGSaturated())
151 fNumHGSaturatedPixels++;
152 if (pix.IsPixelSaturated())
153 fNumSaturatedPixels++;
154
155 // skip unused pixels
156 if (!pix.IsPixelUsed())
157 continue;
158
159 // Get geometry of pixel
160 const Int_t pixid = pix.GetPixId();
161 const MGeomPix &gpix = geom[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 //
185 // Now we are working on absolute values of nphot, which
186 // must take pixel size into account
187 //
188 nphot *= geom.GetPixRatio(pixid);
189
190 // count inner pixels: To dependent on MAGIC Camera --> FIXME
191
192 if (pixid<397){
193 fInnerSize += nphot;
194 if(pixid>270){
195 edgepixin2 += nphot;
196 if(pixid>330)
197 edgepixin1 += nphot;
198 }
199 }
200
201 // Compute Concentration 1-2
202 if (nphot>maxpix1)
203 {
204 maxpix2 = maxpix1;
205 maxpix1 = nphot; // [1]
206 continue; // [1]
207 }
208
209 if (nphot>maxpix2)
210 maxpix2 = nphot; // [1]
211 }
212
213 fInnerLeakage1 = edgepixin1 / fInnerSize;
214 fInnerLeakage2 = edgepixin2 / fInnerSize;
215 fLeakage1 = edgepix1 / hillas.GetSize();
216 fLeakage2 = edgepix2 / hillas.GetSize();
217
218 fConc = (maxpix1+maxpix2)/hillas.GetSize(); // [ratio]
219 fConc1 = maxpix1/hillas.GetSize(); // [ratio]
220
221 SetReadyToSave();
222}
223
224// --------------------------------------------------------------------------
225//
226void MNewImagePar::Print(Option_t *) const
227{
228 *fLog << all;
229 *fLog << "New Image Parameters (" << GetName() << ")" << endl;
230 *fLog << " - Leakage1 [1] = " << fLeakage1 << endl;
231 *fLog << " - Leakage2 [1] = " << fLeakage2 << endl;
232 *fLog << " - InnerLeakage1 [1] = " << fInnerLeakage1 << endl;
233 *fLog << " - InnerLeakage2 [1] = " << fInnerLeakage2 << endl;
234 *fLog << " - InnerSize [#] = " << fInnerSize << " CerPhot" << endl;
235 *fLog << " - Conc [1] = " << fConc << " (ratio)" << endl;
236 *fLog << " - Conc1 [1] = " << fConc1 << " (ratio)" << endl;
237 *fLog << " - Used Pixels [#] = " << fNumUsedPixels << " Pixels" << endl;
238 *fLog << " - Core Pixels [#] = " << fNumCorePixels << " Pixels" << endl;
239 *fLog << " - Used Area [mm^2] = " << fUsedArea << endl;
240 *fLog << " - Core Area [mm^2] = " << fCoreArea << endl;
241 *fLog << " - Sat.Pixels/HG [#] = " << fNumHGSaturatedPixels << " Pixels" << endl;
242 *fLog << " - Sat.Pixels/LG [#] = " << fNumSaturatedPixels << " Pixels" << endl;
243}
244
245// -------------------------------------------------------------------------
246//
247// Print contents of MNewImagePar to *fLog, depending on the geometry in
248// units of deg.
249//
250void MNewImagePar::Print(const MGeomCam &geom) const
251{
252 *fLog << all;
253 *fLog << "New Image Parameters (" << GetName() << ")" << endl;
254 *fLog << " - Leakage1 [1] = " << fLeakage1 << endl;
255 *fLog << " - Leakage2 [1] = " << fLeakage2 << endl;
256 *fLog << " - InnerLeakage1 [1] = " << fInnerLeakage1 << endl;
257 *fLog << " - InnerLeakage2 [1] = " << fInnerLeakage2 << endl;
258 *fLog << " - InnerSize [#] = " << fInnerSize << " CerPhot" << endl;
259 *fLog << " - Conc [1] = " << fConc << " (ratio)" << endl;
260 *fLog << " - Conc1 [1] = " << fConc1 << " (ratio)" << endl;
261 *fLog << " - Used Pixels [#] = " << fNumUsedPixels << " Pixels" << endl;
262 *fLog << " - Core Pixels [#] = " << fNumCorePixels << " Pixels" << endl;
263 *fLog << " - Used Area [deg^2] = " << fUsedArea*geom.GetConvMm2Deg()*geom.GetConvMm2Deg() << endl;
264 *fLog << " - Core Area [deg^2] = " << fCoreArea*geom.GetConvMm2Deg()*geom.GetConvMm2Deg() << endl;
265 *fLog << " - Sat.Pixels/HG [#] = " << fNumHGSaturatedPixels << " Pixels" << endl;
266 *fLog << " - Sat.Pixels/LG [#] = " << fNumSaturatedPixels << " Pixels" << endl;
267}
Note: See TracBrowser for help on using the repository browser.