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

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