source: trunk/MagicSoft/Mars/manalysis/MImgCleanStd.cc@ 770

Last change on this file since 770 was 765, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 6.6 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): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
19! Author(s): Thomas Bretz 12/2000 (tbretz@uni-sw.gwdg.de)
20!
21! Copyright: MAGIC Software Development, 2000-2001
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27//
28// MImgCleanStd
29//
30// This is the standard image cleaning. If you want to know how it works
31// Please look at the three CleanSteps and Process
32//
33/////////////////////////////////////////////////////////////////////////////
34#include "MImgCleanStd.h"
35
36#include "MLog.h"
37#include "MLogManip.h"
38
39#include "MParList.h"
40#include "MGeomCam.h"
41#include "MCerPhotPix.h"
42#include "MCerPhotEvt.h"
43
44ClassImp(MImgCleanStd)
45
46// --------------------------------------------------------------------------
47//
48// Default constructor. Here you can specify the cleaning levels. If you
49// don't specify them the 'common standard' values 2.5 and 3.0 (sigma
50// above mean) are used
51//
52MImgCleanStd::MImgCleanStd(const Float_t lvl1, const Float_t lvl2,
53 const char *name, const char *title)
54 : fCleanLvl1(lvl1), fCleanLvl2(lvl2)
55{
56 *fName = name ? name : "MImgCleanStd";
57 *fTitle = title ? title : "Task which does a standard image cleaning";
58
59 *fLog << "Cleaning initialized. Using noise level " << lvl1 << " and " << lvl2 << endl;
60}
61
62// --------------------------------------------------------------------------
63//
64// This method looks for all pixels with an entry (photons)
65// that is three times bigger than the noise of the pixel
66// (std: 3 sigma, clean level 1)
67//
68void MImgCleanStd::CleanStep1()
69{
70 const Int_t entries = fEvt->GetNumPixels();
71
72 //
73 // check the number of all pixels against the noise level and
74 // set them to 'unused' state if necessary
75 //
76 for (Int_t i=0; i<entries; i++ )
77 {
78 MCerPhotPix &pix = (*fEvt)[i];
79
80 const Float_t entry = pix.GetNumPhotons();
81 const Float_t noise = pix.GetErrorPhot();
82
83 // COBB: '<=' to skip entry=noise=0
84 if (entry <= fCleanLvl1 * noise )
85 pix.SetPixelUnused();
86 }
87}
88
89// --------------------------------------------------------------------------
90//
91// check if the survived pixel have a neighbor, that also
92// survived
93//
94void MImgCleanStd::CleanStep2()
95{
96 const Int_t entries = fEvt->GetNumPixels();
97
98 for (Int_t i=0; i<entries; i++)
99 {
100 //
101 // get entry i from list
102 //
103 MCerPhotPix &pix = (*fEvt)[i];
104
105 //
106 // check if pixel is in use, if not goto next pixel in list
107 //
108 if (!pix.IsPixelUsed())
109 continue;
110
111 //
112 // get pixel id of this entry
113 //
114 const Int_t id = pix.GetPixId();
115
116 //
117 // count number of next neighbors of this pixel which
118 // state is 'used'
119 //
120 MGeomPix &gpix = (*fCam)[id];
121 const Int_t nnmax = gpix.GetNumNeighbors();
122
123 Int_t cnt = 0;
124 for (Int_t j=0; j<nnmax; j++)
125 {
126 const Int_t id2 = gpix.GetNeighbor(j); //GetNN(id, in) ;
127
128 if (id2 < 0)
129 continue;
130
131 if (fEvt->IsPixelUsed(id2))
132 cnt++;
133 }
134
135 //
136 // check if no next neighbor has the state 'used'
137 // set this pixel to 'unused', too.
138 //
139 if (cnt==0)
140 pix.SetPixelUnused();
141 }
142
143 //
144 // now we declare all pixels that survive as CorePixels
145 //
146 for (Int_t i=0; i<entries; i++)
147 {
148 MCerPhotPix &pix = (*fEvt)[i];
149
150 if (pix.IsPixelUsed())
151 pix.SetCorePixel();
152 }
153}
154
155// --------------------------------------------------------------------------
156//
157// Look for the boundary pixels around the core pixels
158// if a pixel has more than 2.5 (clean level 2) sigma, and
159// a core neigbor it is declared as used.
160//
161void MImgCleanStd::CleanStep3()
162{
163 const Int_t entries = fEvt->GetNumPixels();
164
165 for (Int_t i=0; i<entries; i++)
166 {
167 //
168 // get pixel as entry il from list
169 //
170 MCerPhotPix &pix = (*fEvt)[i];
171
172 //
173 // if pixel is a core pixel go to the next pixel
174 //
175 if (pix.IsCorePixel())
176 continue;
177
178 //
179 // check the num of photons against the noise level
180 //
181 const Float_t entry = pix.GetNumPhotons();
182 const Float_t noise = pix.GetErrorPhot();
183
184 if (entry <= fCleanLvl2 * noise )
185 continue;
186
187 //
188 // get pixel id of this entry
189 //
190 const Int_t id = pix.GetPixId();
191
192 //
193 // check if the pixel's next neighbor is a core pixel.
194 // if it is a core pixel set pixel state to: used.
195 //
196 MGeomPix &gpix = (*fCam)[id];
197 const Int_t nnmax = gpix.GetNumNeighbors();
198
199 for (Int_t j=0; j<nnmax; j++)
200 {
201 const Int_t id2 = gpix.GetNeighbor(j);
202
203 if (id2 <0)
204 continue;
205
206 if (!fEvt->IsPixelCore(id2))
207 continue;
208
209 pix.SetPixelUsed();
210
211 break ;
212 }
213 }
214}
215
216// --------------------------------------------------------------------------
217//
218// check if MEvtHeader exists in the Parameter list already.
219// if not create one and add them to the list
220//
221Bool_t MImgCleanStd::PreProcess (MParList *pList)
222{
223 fCam = (MGeomCam*)pList->FindObject("MGeomCam");
224 if (!fCam)
225 {
226 *fLog << dbginf << "MGeomCam not found (no geometry information available)... aborting." << endl;
227 return kFALSE;
228 }
229
230 fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
231 if (!fEvt)
232 {
233 *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
234 return kFALSE;
235 }
236
237 return kTRUE;
238}
239
240// --------------------------------------------------------------------------
241//
242// Cleans the image.
243//
244Bool_t MImgCleanStd::Process()
245{
246 CleanStep1();
247 CleanStep2();
248 CleanStep3();
249
250 return kTRUE;
251}
252
Note: See TracBrowser for help on using the repository browser.