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

Last change on this file since 722 was 717, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.8 KB
Line 
1#include "MImgCleanStd.h"
2
3#include "MLog.h"
4#include "MLogManip.h"
5
6#include "MParList.h"
7#include "MGeomCam.h"
8#include "MCerPhotPix.h"
9#include "MCerPhotEvt.h"
10
11ClassImp(MImgCleanStd)
12
13MImgCleanStd::MImgCleanStd(const Float_t lvl1, const Float_t lvl2,
14 const char *name, const char *title)
15 : fCleanLvl1(lvl1), fCleanLvl2(lvl2)
16{
17 //
18 // the default constructor
19 //
20 *fName = name ? name : "MImgCleanStd";
21 *fTitle = title ? title : "Task which does a standard image cleaning";
22
23 *fLog << "Cleaning initialized. Using noise level " << lvl1 << " and " << lvl2 << endl;
24}
25
26void MImgCleanStd::CleanStep1()
27{
28 //
29 // This method looks for all pixels with an entry (photons)
30 // that is three times bigger than the noise of the pixel
31 // (std: 3 sigma, clean level 1)
32 //
33
34 const Int_t entries = fEvt->GetNumPixels();
35
36 //
37 // check the number of all pixels against the noise level and
38 // set them to 'unused' state if necessary
39 //
40 for (Int_t i=0; i<entries; i++ )
41 {
42 MCerPhotPix &pix = (*fEvt)[i];
43
44 const Float_t entry = pix.GetNumPhotons();
45 const Float_t noise = pix.GetErrorPhot();
46
47 // COBB: '<=' to skip entry=noise=0
48 if (entry <= fCleanLvl1 * noise )
49 pix.SetPixelUnused();
50 }
51}
52
53void MImgCleanStd::CleanStep2()
54{
55 //
56 // check if the survived pixel have a neighbor, that also
57 // survived
58 //
59
60 const Int_t entries = fEvt->GetNumPixels();
61
62 for (Int_t i=0; i<entries; i++)
63 {
64 //
65 // get entry il from list
66 //
67 MCerPhotPix &pix = (*fEvt)[i];
68
69 //
70 // check if pixel is in use, if not goto next pixel in list
71 //
72 if (!pix.IsPixelUsed())
73 continue;
74
75 //
76 // get pixel id of this entry
77 //
78 const Int_t id = pix.GetPixId();
79
80 //
81 // count number of next neighbors of this pixel which
82 // state is 'used'
83 //
84 MGeomPix &gpix = (*fCam)[id];
85 const Int_t nnmax = gpix.GetNumNeighbors();
86
87 Int_t cnt = 0;
88 for (Int_t j=0; j<nnmax; j++)
89 {
90 const Int_t id2 = gpix.GetNeighbor(j); //GetNN(id, in) ;
91
92 if (id2 < 0)
93 continue;
94
95 if (fEvt->IsPixelUsed(id2))
96 cnt++;
97 }
98
99 //
100 // check if no next neighbor has the state 'used'
101 // set this pixel to 'unused', too.
102 //
103 if (cnt==0)
104 pix.SetPixelUnused();
105 }
106
107 //
108 // now we declare all pixels that survive as CorePixels
109 //
110 for (Int_t i=0; i<entries; i++)
111 {
112 MCerPhotPix &pix = (*fEvt)[i];
113
114 if (pix.IsPixelUsed())
115 pix.SetCorePixel();
116 }
117}
118
119void MImgCleanStd::CleanStep3()
120{
121 //
122 // Look for the boundary pixels around the core pixels
123 // if a pixel has more than 2.5 (clean level 2) sigma, and
124 // a core neigbor it is declared as used.
125 //
126 const Int_t entries = fEvt->GetNumPixels();
127 for (Int_t i=0; i<entries; i++)
128 {
129 //
130 // get pixel as entry il from list
131 //
132 MCerPhotPix &pix = (*fEvt)[i];
133
134 //
135 // if pixel is a core pixel go to the next pixel
136 //
137 if (pix.IsCorePixel())
138 continue;
139
140 //
141 // check the num of photons against the noise level
142 //
143 const Float_t entry = pix.GetNumPhotons();
144 const Float_t noise = pix.GetErrorPhot();
145
146 if (entry <= fCleanLvl2 * noise )
147 continue;
148
149 //
150 // get pixel id of this entry
151 //
152 const Int_t id = pix.GetPixId();
153
154 //
155 // check if the pixel's next neighbor is a core pixel.
156 // if it is a core pixel set pixel state to: used.
157 //
158 MGeomPix &gpix = (*fCam)[id];
159 const Int_t nnmax = gpix.GetNumNeighbors();
160
161 for (Int_t j=0; j<nnmax; j++)
162 {
163 const Int_t id2 = gpix.GetNeighbor(j);
164
165 if (id2 <0)
166 continue;
167
168 if (!fEvt->IsPixelCore(id2))
169 continue;
170
171 pix.SetPixelUsed();
172
173 break ;
174 }
175 }
176
177}
178
179Bool_t MImgCleanStd::PreProcess (MParList *pList)
180{
181 //
182 // check if MEvtHeader exists in the Parameter list already.
183 // if not create one and add them to the list
184 //
185 fCam = (MGeomCam*)pList->FindObject("MGeomCam");
186 if (!fCam)
187 {
188 *fLog << dbginf << "MGeomCam not found (no geometry information available)... aborting." << endl;
189 return kFALSE;
190 }
191
192 fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
193 if (!fEvt)
194 {
195 *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
196 return kFALSE;
197 }
198
199 return kTRUE;
200}
201
202Bool_t MImgCleanStd::Process()
203{
204 CleanStep1();
205 CleanStep2();
206 CleanStep3();
207
208 return kTRUE;
209}
210
Note: See TracBrowser for help on using the repository browser.