source: trunk/MagicSoft/Mars/manalysis/MCameraData.cc@ 4444

Last change on this file since 4444 was 4444, checked in by hbartko, 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): Thomas Bretz, 10/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
19! Hendrik Bartko, 08/2004 <mailto:hbartko@mppmu.mpg.de>
20!
21! Copyright: MAGIC Software Development, 2000-2003
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MCameraData
29//
30/////////////////////////////////////////////////////////////////////////////
31#include "MCameraData.h"
32
33#include "MCerPhotEvt.h"
34#include "MCerPhotPix.h"
35
36#include "MGeomCam.h"
37#include "MGeomPix.h"
38
39#include "MLog.h"
40#include "MLogManip.h"
41
42#include "MPedPhotCam.h"
43#include "MPedPhotPix.h"
44
45#include "MSigmabar.h"
46
47ClassImp(MCameraData);
48
49using namespace std;
50
51// --------------------------------------------------------------------------
52//
53// Creates a MCerPhotPix object for each pixel in the event
54//
55MCameraData::MCameraData(const char *name, const char *title)
56{
57 fName = name ? name : "MCameraData";
58 fTitle = title ? title : "Photons/PedRMS Information";
59}
60
61/*
62// --------------------------------------------------------------------------
63//
64// This is not yet implemented like it should.
65//
66
67void MCameraData::Draw(Option_t* option)
68{
69 //
70 // FIXME!!! Here the Draw function of the CamDisplay
71 // should be called to add the CamDisplay to the Pad.
72 // The drawing should be done in MCamDisplay::Paint
73 //
74
75 // MGeomCam *geom = fType ? new MGeomCamMagic : new MGeomCamCT1;
76 // MCamDisplay *disp = new MCamDisplay(geom);
77 // delete geom;
78 // disp->DrawPhotNum(this);
79}
80*/
81
82
83// --------------------------------------------------------------------------
84//
85// Function to calculate the cleaning level for all pixels in a given event
86// as the ratio between the measured photons and the pedestal rms.
87// In order to do the image cleaning on average in the same photon flux
88// (reconstructed photons per pixel area) for the inner and outer pixels,
89// a correction factor is applied to the outer pixels (see TDAS 02-14).
90// The correction factor assumes the ideal case that the pedestal rms
91// scales with the inverse square root of the pixel area.
92//
93
94void MCameraData::CalcCleaningLevel(const MCerPhotEvt &evt, const MPedPhotCam &cam,
95 const MGeomCam &geom)
96{
97 const Int_t n = geom.GetNumPixels();
98
99 fData.Set(n);
100 fData.Reset();
101
102 fValidity.Set(n);
103 fValidity.Reset();
104
105 const Int_t entries = evt.GetNumPixels();
106
107 //
108 // check the number of all pixels against the noise level and
109 // set them to 'unused' state if necessary
110 //
111 for (Int_t i=0; i<entries; i++)
112 {
113 const MCerPhotPix &pix = evt[i];
114
115 const Int_t idx = pix.GetPixId();
116 const Float_t noise = cam[idx].GetRms();
117
118 if (noise<=0) // fData[idx]=0, fValidity[idx]=0
119 continue;
120
121 //
122 // We calculate a correction factor which accounts for the
123 // fact that pixels have different size (see TDAS 02-14).
124 //
125 fData[idx] = pix.GetNumPhotons() * geom.GetPixRatioSqrt(idx) / noise;
126 fValidity[idx] = 1;
127 }
128}
129
130// --------------------------------------------------------------------------
131//
132// Function to calculate the cleaning level for all pixels in a given event
133// as the ratio between the measured photons and the pedestal rms.
134// In order to do the image cleaning on average in the same photon flux
135// (reconstructed photons per pixel area) for the inner and outer pixels,
136// a correction factor is applied to the outer pixels (see TDAS 02-14).
137// The correction factor takes the actual average pedestal RMS of the
138// inner and outer pixels into account.
139//
140
141void MCameraData::CalcCleaningLevel2(const MCerPhotEvt &evt, const MPedPhotCam &cam,
142 const MGeomCam &geom)
143{
144 const Int_t n = geom.GetNumPixels();
145
146 fData.Set(n);
147 fData.Reset();
148
149 fValidity.Set(n);
150 fValidity.Reset();
151
152 const Int_t entries = evt.GetNumPixels();
153
154 const Float_t meannoise[2] = {cam.GetArea(0).GetRms(), cam.GetArea(1).GetRms()} ; // mean noise for the inner and the outer pixels
155
156 //
157 // check the number of all pixels against the noise level and
158 // set them to 'unused' state if necessary
159 //
160 for (Int_t i=0; i<entries; i++)
161 {
162 const MCerPhotPix &pix = evt[i];
163
164 const Int_t idx = pix.GetPixId();
165 const Float_t noise = cam[idx].GetRms();
166
167 if (noise<=0) // fData[idx]=0, fValidity[idx]=0
168 continue;
169
170 //
171 // We calculate a correction factor which accounts for the
172 // fact that pixels have different size (see TDAS 02-14).
173 // We also take into account that the RMS does not scale
174 // with the square root of the pixel area.
175 //
176
177 const UInt_t aidx = geom[idx].GetAidx();
178
179
180 if (meannoise[0] > 0 && meannoise[1] > 0)
181 {
182 fData[idx] = pix.GetNumPhotons() * geom.GetPixRatio(idx) * meannoise[aidx] / meannoise[0] / noise;
183
184 }
185 else fData[idx] = pix.GetNumPhotons() * geom.GetPixRatioSqrt(idx) / noise;
186
187 fValidity[idx] = 1;
188 }
189}
190
191
192void MCameraData::CalcCleaningLevel(const MCerPhotEvt &evt, const MSigmabar &sgb,
193 const MGeomCam &geom)
194{
195 CalcCleaningLevel(evt, sgb.GetSigmabarInner(), geom);
196}
197
198void MCameraData::CalcCleaningLevel(const MCerPhotEvt &evt, Double_t noise,
199 const MGeomCam &geom)
200{
201 const Int_t n = geom.GetNumPixels();
202
203 fData.Set(n);
204 fData.Reset();
205
206 fValidity.Set(n);
207 fValidity.Reset();
208
209 if (noise<=0)
210 return;
211
212 const Int_t entries = evt.GetNumPixels();
213
214 //
215 // check the number of all pixels against the noise level and
216 // set them to 'unused' state if necessary
217 //
218 for (Int_t i=0; i<entries; i++)
219 {
220 const MCerPhotPix &pix = evt[i];
221
222 const Int_t idx = pix.GetPixId();
223
224 //
225 // We calculate a correction factor which accounts for the
226 // fact that pixels have different size (see TDAS 02-14).
227 //
228 fData[idx] = pix.GetNumPhotons() * geom.GetPixRatio(idx) / noise;
229 fValidity[idx] = 1;
230 }
231}
232
233
234// --------------------------------------------------------------------------
235//
236// Function to calculate the cleaning level for all pixels in a given event
237// as the ratio between the reconstructed number of photons per area of an
238// inner pixel and the average pedestal RMS of the inner pixels (democratic
239// image cleaning, see TDAS 02-14).
240
241
242void MCameraData::CalcCleaningLevelDemocratic(const MCerPhotEvt &evt, const MPedPhotCam &cam,
243 const MGeomCam &geom)
244{
245 const Int_t n = geom.GetNumPixels();
246
247 fData.Set(n);
248 fData.Reset();
249
250 fValidity.Set(n);
251 fValidity.Reset();
252
253 const Int_t entries = evt.GetNumPixels();
254
255 const Float_t meannoise[2] = {cam.GetArea(0).GetRms(), cam.GetArea(1).GetRms()} ; // mean noise for the inner and the outer pixels
256
257
258 //
259 // check the number of all pixels against the noise level and
260 // set them to 'unused' state if necessary
261 //
262 for (Int_t i=0; i<entries; i++)
263 {
264 const MCerPhotPix &pix = evt[i];
265
266 const Int_t idx = pix.GetPixId();
267 const Float_t noise = cam[idx].GetRms();
268
269 if (noise<=0)
270 continue;
271
272 //
273 // We calculate a correction factor which accounts for the
274 // fact that pixels have different size (see TDAS 02-14).
275 //
276
277
278 if (meannoise[0]>0) // fData[idx]=0, fValidity[idx]=0
279 {
280 fData[idx] = pix.GetNumPhotons() * geom.GetPixRatio(idx) / meannoise[0];
281 fValidity[idx] = 1;
282 }
283 else
284 fValidity[idx] = 0;
285 }
286
287}
288
289
290
291// --------------------------------------------------------------------------
292//
293// Returns, depending on the type flag:
294//
295// 0: Number of Photons*PixRatio
296// 1: Error*sqrt(PixRatio)
297// 2: Cleaning level = Num Photons*sqrt(PixRatio)/Error
298// 3: Number of Photons
299// 4: Error
300//
301Bool_t MCameraData::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
302{
303 if (idx<0 || idx>=fData.GetSize())
304 return kFALSE;
305
306 val = fData[idx];
307 return fValidity[idx];
308}
309
310void MCameraData::DrawPixelContent(Int_t num) const
311{
312 *fLog << warn << "MCameraData::DrawPixelContent - not available." << endl;
313}
Note: See TracBrowser for help on using the repository browser.