source: trunk/MagicSoft/Mars/msignal/MExtractBlindPixel.cc@ 4260

Last change on this file since 4260 was 4190, checked in by gaug, 21 years ago
*** empty log message ***
File size: 6.7 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): Markus Gaug, 02/2004 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MExtractBlindPixel
28//
29// Extracts the signal from a fixed window in a given range.
30//
31// Call: SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast)
32// to modify the ranges. The "lo-gain" ranges are used for the NSB rejection
33// whereas the high-gain ranges for blind pixel signal extraction. "High-gain"
34// ranges can extend to the slices stored as "low-gain" in MRawEvtPixelIter
35// Defaults are:
36//
37// fHiGainFirst = fgHiGainFirst = 12
38// fHiGainLast = fgHiGainLast = 16
39// fLoGainFirst = fgLoGainFirst = 0
40// fLoGainLast = fgLoGainLast = 10
41//
42//////////////////////////////////////////////////////////////////////////////
43#include "MExtractBlindPixel.h"
44
45#include <fstream>
46
47#include "MLog.h"
48#include "MLogManip.h"
49
50#include "MParList.h"
51
52#include "MRawEvtData.h"
53#include "MRawEvtPixelIter.h"
54
55#include "MExtractedSignalBlindPixel.h"
56
57#include "MPedestalCam.h"
58#include "MPedestalPix.h"
59
60ClassImp(MExtractBlindPixel);
61
62using namespace std;
63
64const Int_t MExtractBlindPixel::fgBlindPixelIdx = 559;
65const Int_t MExtractBlindPixel::fgNSBFilterLimit = 100;
66const Byte_t MExtractBlindPixel::fgHiGainFirst = 10;
67const Byte_t MExtractBlindPixel::fgHiGainLast = 29;
68const Byte_t MExtractBlindPixel::fgLoGainFirst = 0;
69const Byte_t MExtractBlindPixel::fgLoGainLast = 7;
70// --------------------------------------------------------------------------
71//
72// Default constructor.
73//
74// Initializes:
75// - fBlindPixelIdx to fgBlindPixelIdx
76// - fNSBFilterLimit to fgNSBFilterLimit
77//
78// Calls:
79// - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
80//
81MExtractBlindPixel::MExtractBlindPixel(const char *name, const char *title)
82{
83
84 fName = name ? name : "MExtractBlindPixel";
85 fTitle = title ? title : "Task to extract the signal from the FADC slices";
86
87 AddToBranchList("MRawEvtData.*");
88
89 SetBlindPixelIdx();
90 SetNSBFilterLimit();
91 SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
92
93}
94
95void MExtractBlindPixel::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
96{
97
98 MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
99
100 fNumHiGainSamples = (Float_t)(fHiGainLast-fHiGainFirst+1);
101 fNumLoGainSamples = (Float_t)(fLoGainLast-fLoGainFirst+1);
102
103 fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
104 fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
105
106}
107
108// --------------------------------------------------------------------------
109//
110// The PreProcess searches for the following input containers:
111// - MRawEvtData
112//
113// The following output containers are also searched and created if
114// they were not found:
115//
116// - MExtractedBlindPixel
117//
118Int_t MExtractBlindPixel::PreProcess(MParList *pList)
119{
120
121 if (!MExtractor::PreProcess(pList))
122 return kFALSE;
123
124 fBlindPixel = (MExtractedSignalBlindPixel*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalBlindPixel"));
125 if (!fBlindPixel)
126 return kFALSE;
127
128 fBlindPixel->SetBlindPixelIdx(fBlindPixelIdx);
129 fBlindPixel->SetUsedFADCSlices(fHiGainFirst, fHiGainLast);
130
131 MPedestalPix &pedpix = (*fPedestals)[fBlindPixelIdx];
132
133 if (&pedpix)
134 {
135 fBlindPixel->SetPed ( pedpix.GetPedestal() * fNumLoGainSamples );
136 fBlindPixel->SetPedErr ( pedpix.GetPedestalRms()* fNumLoGainSamples
137 / TMath::Sqrt((Float_t)fPedestals->GetTotalEntries()) );
138 fBlindPixel->SetPedRms ( pedpix.GetPedestalRms()* TMath::Sqrt((Float_t)fNumLoGainSamples) );
139 fBlindPixel->SetPedRmsErr( fBlindPixel->GetPedErr()/2. );
140 }
141
142 return kTRUE;
143}
144
145// --------------------------------------------------------------------------
146//
147// FindSignalHiGain:
148//
149// - Loop from ptr to (ptr+fHiGainLast-fHiGainFirst)
150// - Sum up contents of *ptr
151// - If *ptr is greater than fSaturationLimit, raise sat by 1
152// - If fHiLoLast is set, loop from logain to (logain+fHiLoLast)
153// - Add contents of *logain to sum
154//
155void MExtractBlindPixel::FindSignalHiGain(Byte_t *ptr, Byte_t *logain, Int_t &sum, Byte_t &sat) const
156{
157
158 Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1;
159
160 while (ptr<end)
161 {
162 sum += *ptr;
163
164 if (*ptr++ >= fSaturationLimit)
165 sat++;
166 }
167
168 if (fHiLoLast == 0)
169 return;
170
171
172 end = logain + fHiLoLast;
173 while (logain<end)
174 {
175 sum += *logain;
176
177 if (*logain++ >= fSaturationLimit)
178 sat++;
179 }
180
181}
182
183// --------------------------------------------------------------------------
184//
185// FindSignalFilter:
186//
187// - Loop from ptr to (ptr+fLoGainLast-fLoGainFirst)
188// - Sum up contents of *ptr
189// - If *ptr is greater than fSaturationLimit, raise sat by 1
190//
191void MExtractBlindPixel::FindSignalFilter(Byte_t *ptr, Int_t &sum, Byte_t &sat) const
192{
193
194 Byte_t *end = ptr + fLoGainLast - fLoGainFirst + 1;
195
196 while (ptr<end)
197 {
198 sum += *ptr;
199
200 if (*ptr++ >= fSaturationLimit)
201 sat++;
202 }
203}
204
205// --------------------------------------------------------------------------
206//
207// Calculate the integral of the FADC time slices and store them as a new
208// pixel in the MExtractedBlindPixel container.
209//
210Int_t MExtractBlindPixel::Process()
211{
212
213 MRawEvtPixelIter pixel(fRawEvt);
214
215 fBlindPixel->Clear();
216
217 pixel.Jump(fBlindPixelIdx);
218
219 Int_t sum = 0;
220 Byte_t sat = 0;
221
222 FindSignalFilter(pixel.GetHiGainSamples()+fLoGainFirst, sum, sat);
223
224 if (sum > fNSBFilterLimit)
225 {
226 sum = -1;
227 fBlindPixel->SetExtractedSignal(sum);
228 fBlindPixel->SetNumSaturated(sat);
229 fBlindPixel->SetReadyToSave();
230 return kTRUE;
231 }
232
233 sum = 0;
234 sat = 0;
235
236 FindSignalHiGain(pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(), sum, sat);
237
238 fBlindPixel->SetExtractedSignal(sum);
239 fBlindPixel->SetNumSaturated(sat);
240 fBlindPixel->SetReadyToSave();
241
242 return kTRUE;
243}
244
Note: See TracBrowser for help on using the repository browser.