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

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