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

Last change on this file since 711 was 698, checked in by tbretz, 24 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.1 KB
Line 
1#include "MImgCleanStd.h"
2
3#include "MLog.h"
4#include "MLogManip.h"
5
6#include "MParList.h"
7#include "MCerPhotPix.h"
8#include "MCerPhotEvt.h"
9#include "MCamNeighbor.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 il=0; il<entries; il++ )
37 {
38 MCerPhotPix &pix = (*fEvt)[il];
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 il=0; il<entries; il++)
58 {
59 //
60 // get entry il from list
61 //
62 MCerPhotPix &pix = (*fEvt)[il];
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 Int_t itest = 0 ;
80 for (Int_t in=0 ; in < 6; in++ )
81 {
82 const Int_t id2 = fNN.GetNN(id, in) ;
83
84 if (id2 < 0)
85 continue;
86
87 if (fEvt->IsPixelUsed(id2))
88 itest++ ;
89 }
90
91 //
92 // check if no next neighbor has the state 'used'
93 // set this pixel to 'unused', too.
94 //
95 if (itest==0)
96 pix.SetPixelUnused();
97 }
98
99 //
100 // now we declare all pixels that survive as CorePixels
101 //
102 for (Int_t il=0; il<entries; il++)
103 {
104 MCerPhotPix &pix = (*fEvt)[il];
105
106 if (pix.IsPixelUsed())
107 pix.SetCorePixel();
108 }
109
110}
111
112void MImgCleanStd::CleanLevel3()
113{
114 //
115 // Look for the boundary pixels around the core pixels
116 // if a pixel has more than 2.5 sigma, and a core neigbor
117 // it is declared as used.
118 //
119 const Int_t entries = fEvt->GetNumPixels();
120
121 for (Int_t il=0; il<entries; il++)
122 {
123 //
124 // get pixel as entry il from list
125 //
126 MCerPhotPix &pix = (*fEvt)[il];
127
128 //
129 // if pixel is a core pixel go to the next pixel
130 //
131 if (pix.IsCorePixel())
132 continue;
133
134 //
135 // check the num of photons against the noise level
136 //
137 const Float_t entry = pix.GetNumPhotons();
138 const Float_t noise = pix.GetErrorPhot();
139
140 if (entry <= 2.5 * noise )
141 continue;
142
143 //
144 // get pixel id of this entry
145 //
146 const Int_t id = pix.GetPixId();
147
148 //
149 // check if the pixel's next neighbor is a core pixel.
150 // if it is a core pixel set pixel state to: used.
151 //
152 for (Int_t in=0; in<6 ; in++)
153 {
154 const Int_t id2 = fNN.GetNN(id, in);
155
156 if (id2 <0)
157 continue;
158
159 if (!fEvt->IsPixelCore(id2))
160 continue;
161
162 pix.SetPixelUsed();
163
164 break ;
165 }
166 }
167}
168
169Bool_t MImgCleanStd::PreProcess (MParList *pList)
170{
171 //
172 // check if MEvtHeader exists in the Parameter list already.
173 // if not create one and add them to the list
174 //
175 fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
176 if (fEvt)
177 return kTRUE;
178
179 *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
180 return kFALSE;
181}
182
183Bool_t MImgCleanStd::Process()
184{
185 CleanLevel1();
186 CleanLevel2();
187 CleanLevel3();
188
189 return kTRUE;
190}
191
Note: See TracBrowser for help on using the repository browser.