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 "low-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 | //
|
---|
36 | // Defaults are:
|
---|
37 | //
|
---|
38 | // fHiGainFirst = fgHiGainFirst = 10
|
---|
39 | // fHiGainLast = fgHiGainLast = 29
|
---|
40 | // fLoGainFirst = fgLoGainFirst = 0
|
---|
41 | // fLoGainLast = fgLoGainLast = 7
|
---|
42 | //
|
---|
43 | // The switches:
|
---|
44 | // - SetExtractionType ( kAmplitude ) and SetExtractionType ( kIntegral )
|
---|
45 | // can be used to choose between amplitude extraction (using a spline) and
|
---|
46 | // summed integral.
|
---|
47 | // - SetExtractionType ( kFilter )
|
---|
48 | // can be used to apply a filter discarding events passing over a threshold
|
---|
49 | // defined in fNSBFilterLimit
|
---|
50 | //
|
---|
51 | //////////////////////////////////////////////////////////////////////////////
|
---|
52 | #include "MExtractBlindPixel.h"
|
---|
53 |
|
---|
54 | #include "MLog.h"
|
---|
55 | #include "MLogManip.h"
|
---|
56 |
|
---|
57 | #include "MParList.h"
|
---|
58 |
|
---|
59 | #include "MRawEvtData.h"
|
---|
60 | #include "MRawRunHeader.h"
|
---|
61 | #include "MRawEvtPixelIter.h"
|
---|
62 |
|
---|
63 | #include "MPedestalSubtractedEvt.h"
|
---|
64 | #include "MExtractedSignalBlindPixel.h"
|
---|
65 |
|
---|
66 | #include "MPedestalCam.h"
|
---|
67 | #include "MPedestalPix.h"
|
---|
68 |
|
---|
69 | #include "MCalibrationBlindCam.h"
|
---|
70 | #include "MCalibrationBlindPix.h"
|
---|
71 |
|
---|
72 | #include "MExtralgoSpline.h"
|
---|
73 |
|
---|
74 | ClassImp(MExtractBlindPixel);
|
---|
75 |
|
---|
76 | using namespace std;
|
---|
77 |
|
---|
78 | const UInt_t MExtractBlindPixel::fgBlindPixelIdx = 559;
|
---|
79 | const Byte_t MExtractBlindPixel::fgHiGainFirst = 10;
|
---|
80 | const Byte_t MExtractBlindPixel::fgHiGainLast = 19;
|
---|
81 | const Byte_t MExtractBlindPixel::fgLoGainFirst = 0;
|
---|
82 | const Byte_t MExtractBlindPixel::fgLoGainLast = 7;
|
---|
83 | const Int_t MExtractBlindPixel::fgNSBFilterLimit = 70;
|
---|
84 | const Float_t MExtractBlindPixel::fgResolution = 0.003;
|
---|
85 | const Float_t MExtractBlindPixel::gkOverflow = 300.;
|
---|
86 |
|
---|
87 | // --------------------------------------------------------------------------
|
---|
88 | //
|
---|
89 | // Default constructor.
|
---|
90 | //
|
---|
91 | // Initializes:
|
---|
92 | // - fBlindPixelIdx to fgBlindPixelIdx
|
---|
93 | // - fNSBFilterLimit to fgNSBFilterLimit
|
---|
94 | // - fResolution to fgResolution
|
---|
95 | // - fExtractionType to 0.
|
---|
96 | //
|
---|
97 | // Calls:
|
---|
98 | // - SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
|
---|
99 | //
|
---|
100 | MExtractBlindPixel::MExtractBlindPixel(const char *name, const char *title)
|
---|
101 | : fBlindPixel(0), /*fHiLoLast(0),*/ fDataType(0)
|
---|
102 | {
|
---|
103 |
|
---|
104 | fName = name ? name : "MExtractBlindPixel";
|
---|
105 | fTitle = title ? title : "Task to extract the signal from the FADC slices";
|
---|
106 |
|
---|
107 | SetResolution();
|
---|
108 | SetNSBFilterLimit();
|
---|
109 | SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast);
|
---|
110 |
|
---|
111 | // SetNumBlindPixels();
|
---|
112 | fBlindPixelIdx.Set(1);
|
---|
113 | fBlindPixelIdx[0] = fgBlindPixelIdx;
|
---|
114 |
|
---|
115 | Clear();
|
---|
116 |
|
---|
117 | }
|
---|
118 |
|
---|
119 | // --------------------------------------------------------------------------
|
---|
120 | //
|
---|
121 | // Clear
|
---|
122 | //
|
---|
123 | // Initializes:
|
---|
124 | // - fBlindPixelIdx to 0
|
---|
125 | // - fExtractionType to 0
|
---|
126 | //
|
---|
127 | // Calls:
|
---|
128 | // - SetBlindPixelIdx()
|
---|
129 | //
|
---|
130 | // Deletes and sets to NULL (if exists):
|
---|
131 | // - fHiGainSignal
|
---|
132 | // - fHiGainFirstDeriv
|
---|
133 | // - fHiGainSecondDeriv
|
---|
134 | //
|
---|
135 | void MExtractBlindPixel::Clear( const Option_t *o)
|
---|
136 | {
|
---|
137 | fExtractionType = 0;
|
---|
138 |
|
---|
139 | fBlindPixelIdx.Set(1);
|
---|
140 | fBlindPixelIdx[0] = fgBlindPixelIdx;
|
---|
141 | }
|
---|
142 |
|
---|
143 | void MExtractBlindPixel::SetBlindPixels(const MCalibrationBlindCam &cam)
|
---|
144 | {
|
---|
145 | const Int_t n = cam.GetSize();
|
---|
146 |
|
---|
147 | fBlindPixelIdx.Set(n);
|
---|
148 | for (Int_t i=0; i<n; i++)
|
---|
149 | fBlindPixelIdx[i] = cam[i].GetPixId();
|
---|
150 | }
|
---|
151 |
|
---|
152 | void MExtractBlindPixel::SetRange(Byte_t hifirst, Byte_t hilast, Int_t lofirst, Byte_t lolast)
|
---|
153 | {
|
---|
154 |
|
---|
155 | MExtractor::SetRange(hifirst,hilast,lofirst,lolast);
|
---|
156 |
|
---|
157 | fNumHiGainSamples = (Float_t)(fHiGainLast-fHiGainFirst+1);
|
---|
158 | // if (lolast)
|
---|
159 | // fNumLoGainSamples = (Float_t)(fLoGainLast-fLoGainFirst+1);
|
---|
160 | // else
|
---|
161 | fNumLoGainSamples = 0.;
|
---|
162 |
|
---|
163 | fSqrtHiGainSamples = TMath::Sqrt(fNumHiGainSamples);
|
---|
164 | fSqrtLoGainSamples = TMath::Sqrt(fNumLoGainSamples);
|
---|
165 |
|
---|
166 | //fHiLoFirst = 0;
|
---|
167 | //fHiLoLast = 0;
|
---|
168 | }
|
---|
169 |
|
---|
170 | // --------------------------------------------------------------------------
|
---|
171 | //
|
---|
172 | // Calls:
|
---|
173 | // - MExtractor::PreProcess(pList)
|
---|
174 | //
|
---|
175 | // The following output containers are also searched and created if
|
---|
176 | // they were not found:
|
---|
177 | //
|
---|
178 | // - MExtractedBlindPixel
|
---|
179 | //
|
---|
180 | Int_t MExtractBlindPixel::PreProcess(MParList *pList)
|
---|
181 | {
|
---|
182 |
|
---|
183 | if (!MExtractor::PreProcess(pList))
|
---|
184 | return kFALSE;
|
---|
185 |
|
---|
186 | fBlindPixel = (MExtractedSignalBlindPixel*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalBlindPixel"));
|
---|
187 | if (!fBlindPixel)
|
---|
188 | return kFALSE;
|
---|
189 |
|
---|
190 | const TString raw = IsDataType(kRawEvt2) ? "MRawEvtData2" : "MRawEvtData";
|
---|
191 | const TString sig = IsDataType(kRawEvt2) ? "MPedestalSubtractedEvt2" : "MPedestalSubtractedEvt";
|
---|
192 |
|
---|
193 | fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber(raw), "MRawEvtData");
|
---|
194 | if (!fRawEvt)
|
---|
195 | {
|
---|
196 | *fLog << err << raw << " [MRawEvtData] not found... aborting." << endl;
|
---|
197 | return kFALSE;
|
---|
198 | }
|
---|
199 |
|
---|
200 | fSignal = (MPedestalSubtractedEvt*)pList->FindObject(AddSerialNumber(sig), "MPedestalSubtractedEvt");
|
---|
201 | if (!fSignal)
|
---|
202 | {
|
---|
203 | *fLog << err << sig << " [MPedestalSubtractedEvt] not found... aborting." << endl;
|
---|
204 | return kFALSE;
|
---|
205 | }
|
---|
206 |
|
---|
207 | return kTRUE;
|
---|
208 | }
|
---|
209 |
|
---|
210 | // -------------------------------------------------------------------------- //
|
---|
211 | //
|
---|
212 | // The ReInit searches for:
|
---|
213 | // - MRawRunHeader::GetNumSamplesHiGain()
|
---|
214 | // - MRawRunHeader::GetNumSamplesLoGain()
|
---|
215 | //
|
---|
216 | // In case that the variables fHiGainLast and fLoGainLast are smaller than
|
---|
217 | // the even part of the number of samples obtained from the run header, a
|
---|
218 | // warning is given an the range is set back accordingly. A call to:
|
---|
219 | // - SetRange(fHiGainFirst, fHiGainLast-diff, fLoGainFirst, fLoGainLast) or
|
---|
220 | // - SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast-diff)
|
---|
221 | // is performed in that case. The variable diff means here the difference
|
---|
222 | // between the requested range (fHiGainLast) and the available one. Note that
|
---|
223 | // the functions SetRange() are mostly overloaded and perform more checks,
|
---|
224 | // modifying the ranges again, if necessary.
|
---|
225 | //
|
---|
226 | Bool_t MExtractBlindPixel::ReInit(MParList *pList)
|
---|
227 | {
|
---|
228 |
|
---|
229 | for (UInt_t i=0;i<fBlindPixelIdx.GetSize();i++)
|
---|
230 | fBlindPixel->SetBlindPixelIdx(fBlindPixelIdx[i], i);
|
---|
231 |
|
---|
232 | fBlindPixel->SetExtractionType(fExtractionType);
|
---|
233 | /*
|
---|
234 | for (UInt_t i=0;i<fBlindPixelIdx.GetSize();i++)
|
---|
235 | {
|
---|
236 |
|
---|
237 | MPedestalPix &pedpix = (*fPedestals)[fBlindPixelIdx.At(i)];
|
---|
238 |
|
---|
239 | if (&pedpix)
|
---|
240 | {
|
---|
241 | fBlindPixel->SetPed ( pedpix.GetPedestal() * fNumLoGainSamples, i );
|
---|
242 | fBlindPixel->SetPedErr ( pedpix.GetPedestalRms()* fNumLoGainSamples
|
---|
243 | / TMath::Sqrt((Float_t)fPedestals->GetNumSlices()*pedpix.GetNumEvents()), i );
|
---|
244 | fBlindPixel->SetPedRms ( pedpix.GetPedestalRms()* TMath::Sqrt((Float_t)fNumLoGainSamples), i );
|
---|
245 | fBlindPixel->SetPedRmsErr( fBlindPixel->GetPedErr()/2., i );
|
---|
246 | }
|
---|
247 | }
|
---|
248 |
|
---|
249 | const Int_t higainsamples = fRunHeader->GetNumSamplesHiGain();
|
---|
250 | const Int_t logainsamples = fRunHeader->GetNumSamplesLoGain();
|
---|
251 | Int_t lastavailable = higainsamples-1;
|
---|
252 |
|
---|
253 | if (logainsamples)
|
---|
254 | {
|
---|
255 | //
|
---|
256 | // If the signal is searched entirely in the low-gain range, have
|
---|
257 | // to skip the higain completely. This is steered by the variable fHiLoFirst
|
---|
258 | //
|
---|
259 | const Int_t firstdesired = (Int_t)fHiGainFirst;
|
---|
260 |
|
---|
261 | if (firstdesired > lastavailable)
|
---|
262 | {
|
---|
263 | const Int_t diff = firstdesired - lastavailable;
|
---|
264 | *fLog << endl;
|
---|
265 | *fLog << warn << "First Hi Gain slice " << (int)fHiGainFirst << " out of range [0,";
|
---|
266 | *fLog << lastavailable << "]... start at slice " << diff << " of the Lo Gain " << endl;
|
---|
267 |
|
---|
268 | fHiLoFirst = diff;
|
---|
269 | }
|
---|
270 | }
|
---|
271 |
|
---|
272 | const Int_t lastdesired = (Int_t)fHiGainLast;
|
---|
273 |
|
---|
274 | if (lastdesired > lastavailable)
|
---|
275 | {
|
---|
276 | Int_t diff = lastdesired - lastavailable;
|
---|
277 | lastavailable += logainsamples ? logainsamples-1 : 0;
|
---|
278 |
|
---|
279 | if (lastdesired > lastavailable)
|
---|
280 | {
|
---|
281 | *fLog << endl;
|
---|
282 | *fLog << "Last Hi Gain slice " << (int)fHiGainLast << " out of range [0,";
|
---|
283 | *fLog << lastavailable << "]... reduce upper limit by " << diff << endl;
|
---|
284 | diff = logainsamples;
|
---|
285 | }
|
---|
286 |
|
---|
287 | fHiGainLast = higainsamples - 1;
|
---|
288 | fHiLoLast = logainsamples ? diff : 0;
|
---|
289 | }
|
---|
290 | */
|
---|
291 | const Int_t range = fHiGainLast-fHiGainFirst+1; //fHiLoFirst ? fHiLoLast - fHiLoFirst + 1 : fHiGainLast - fHiGainFirst + fHiLoLast + 1;
|
---|
292 |
|
---|
293 | // fHiGainSignal.Set(range);
|
---|
294 | // fHiGainSignal.Reset();
|
---|
295 |
|
---|
296 | fHiGainFirstDeriv.Set(range);
|
---|
297 | fHiGainFirstDeriv.Reset();
|
---|
298 |
|
---|
299 | fHiGainSecondDeriv.Set(range);
|
---|
300 | fHiGainSecondDeriv.Reset();
|
---|
301 |
|
---|
302 | *fLog << endl;
|
---|
303 | *fLog << inf << "Extracting "
|
---|
304 | << (IsExtractionType(kAmplitude) ? "Amplitude" : " Integral")
|
---|
305 | << " using " << range << " FADC samples from slice "
|
---|
306 | << (Int_t)fHiGainFirst << " to " << (Int_t)fHiGainLast << " (incl)" << endl;
|
---|
307 |
|
---|
308 | if (IsExtractionType(kFilter))
|
---|
309 | *fLog << inf << "Will use Filter using "
|
---|
310 | << (Int_t)(fLoGainLast-fLoGainFirst+1) << " FADC slices"
|
---|
311 | << " from slice " << (Int_t)fLoGainFirst
|
---|
312 | << " to " << (Int_t)fLoGainLast << endl;
|
---|
313 |
|
---|
314 | fBlindPixel->SetUsedFADCSlices(fHiGainFirst, range);
|
---|
315 |
|
---|
316 | return kTRUE;
|
---|
317 |
|
---|
318 | }
|
---|
319 |
|
---|
320 | // --------------------------------------------------------------------------
|
---|
321 | //
|
---|
322 | // FindSignalHiGain:
|
---|
323 | //
|
---|
324 | // - Loop from ptr to (ptr+fHiGainLast-fHiGainFirst)
|
---|
325 | // - Sum up contents of *ptr
|
---|
326 | // - If *ptr is greater than fSaturationLimit, raise sat by 1
|
---|
327 | // - If fHiLoLast is set, loop from logain to (logain+fHiLoLast)
|
---|
328 | // - Add contents of *logain to sum
|
---|
329 | //
|
---|
330 | /*
|
---|
331 | void MExtractBlindPixel::FindIntegral(Byte_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat)
|
---|
332 | {
|
---|
333 | const Byte_t *end = ptr + fHiGainLast - fHiGainFirst + 1;
|
---|
334 |
|
---|
335 | Int_t summ = 0;
|
---|
336 | while (p<end)
|
---|
337 | {
|
---|
338 | summ += *ptr;
|
---|
339 |
|
---|
340 | if (*ptr++ >= fSaturationLimit)
|
---|
341 | sat++;
|
---|
342 | }
|
---|
343 |
|
---|
344 | sum = (Float_t)summ;
|
---|
345 | }
|
---|
346 | */
|
---|
347 |
|
---|
348 | // --------------------------------------------------------------------------
|
---|
349 | //
|
---|
350 | // FindSignalPhe:
|
---|
351 | //
|
---|
352 | // - Loop from ptr to (ptr+fHiGainLast-fHiGainFirst)
|
---|
353 | // - Sum up contents of *ptr
|
---|
354 | // - If *ptr is greater than fSaturationLimit, raise sat by 1
|
---|
355 | // - If fHiLoLast is set, loop from logain to (logain+fHiLoLast)
|
---|
356 | // - Add contents of *logain to sum
|
---|
357 | //
|
---|
358 | //void MExtractBlindPixel::FindAmplitude(Float_t *ptr, Byte_t *logain, Float_t &sum, Byte_t &sat)
|
---|
359 | Float_t MExtractBlindPixel::FindAmplitude(Int_t idx, Int_t numsat) const
|
---|
360 | {
|
---|
361 | Int_t sat0 = fHiGainFirst; // First slice to extract and first saturating slice
|
---|
362 | Int_t sat1 = fHiGainLast; // Last slice to extract and last saturating slice
|
---|
363 |
|
---|
364 | UInt_t maxcont;
|
---|
365 | Int_t maxpos = fSignal->GetMax(idx, sat0, sat1, maxcont);
|
---|
366 |
|
---|
367 | // numsat = fSignal->GetSaturation(idx, fSaturationLimit, sat0, sat1);
|
---|
368 |
|
---|
369 | const Float_t *ptr = fSignal->GetSamples(idx);
|
---|
370 | const Int_t num = fHiGainLast-fHiGainFirst+1;
|
---|
371 |
|
---|
372 | MExtralgoSpline s(ptr, num, fHiGainFirstDeriv.GetArray(), fHiGainSecondDeriv.GetArray());
|
---|
373 |
|
---|
374 | s.SetExtractionType(MExtralgoSpline::kAmplitude);
|
---|
375 |
|
---|
376 | s.Extract(numsat, maxpos);
|
---|
377 |
|
---|
378 | return s.GetSignal();
|
---|
379 | /*
|
---|
380 | Int_t range = 0;
|
---|
381 | Int_t count = 0;
|
---|
382 | Float_t abmaxpos = 0.;
|
---|
383 | Byte_t *p = ptr;
|
---|
384 | Byte_t *end;
|
---|
385 | Byte_t max = 0;
|
---|
386 | Byte_t maxpos = 0;
|
---|
387 | Int_t summ = 0;
|
---|
388 |
|
---|
389 | if (fHiLoFirst == 0)
|
---|
390 | {
|
---|
391 |
|
---|
392 | range = fHiGainLast - fHiGainFirst + 1;
|
---|
393 |
|
---|
394 | end = ptr + range;
|
---|
395 | //
|
---|
396 | // Check for saturation in all other slices
|
---|
397 | //
|
---|
398 | while (p++<end)
|
---|
399 | {
|
---|
400 |
|
---|
401 | fHiGainSignal[count] = (Float_t)*p;
|
---|
402 | summ += *p;
|
---|
403 |
|
---|
404 | if (*p > max)
|
---|
405 | {
|
---|
406 | max = *p;
|
---|
407 | maxpos = count;
|
---|
408 | }
|
---|
409 |
|
---|
410 | count++;
|
---|
411 |
|
---|
412 | if (*p >= fSaturationLimit)
|
---|
413 | sat++;
|
---|
414 | }
|
---|
415 | }
|
---|
416 |
|
---|
417 | if (fHiLoLast != 0)
|
---|
418 | {
|
---|
419 |
|
---|
420 | p = logain + fHiLoFirst;
|
---|
421 | end = logain + fHiLoLast;
|
---|
422 |
|
---|
423 | while (p<end)
|
---|
424 | {
|
---|
425 |
|
---|
426 | fHiGainSignal[count] = (Float_t)*p;
|
---|
427 | summ += *p;
|
---|
428 |
|
---|
429 | if (*p > max)
|
---|
430 | {
|
---|
431 | max = *p;
|
---|
432 | maxpos = count;
|
---|
433 | }
|
---|
434 |
|
---|
435 | range++;
|
---|
436 | count++;
|
---|
437 |
|
---|
438 | if (*p++ >= fSaturationLimit)
|
---|
439 | sat++;
|
---|
440 | }
|
---|
441 | }
|
---|
442 |
|
---|
443 | //
|
---|
444 | // allow one saturated slice
|
---|
445 | //
|
---|
446 | if (sat > 1)
|
---|
447 | {
|
---|
448 | sum = gkOverflow;
|
---|
449 | return;
|
---|
450 | }
|
---|
451 |
|
---|
452 | //
|
---|
453 | // Don't start if the maxpos is too close to the left limit.
|
---|
454 | //
|
---|
455 | if (maxpos < 2)
|
---|
456 | {
|
---|
457 | sum = (Float_t)max;
|
---|
458 | return;
|
---|
459 | }
|
---|
460 |
|
---|
461 | Float_t pp;
|
---|
462 |
|
---|
463 | for (Int_t i=1;i<range-1;i++)
|
---|
464 | {
|
---|
465 | pp = fHiGainSecondDeriv[i-1] + 4.;
|
---|
466 | fHiGainSecondDeriv[i] = -1.0/pp;
|
---|
467 | fHiGainFirstDeriv [i] = fHiGainSignal[i+1] - fHiGainSignal[i] - fHiGainSignal[i] + fHiGainSignal[i-1];
|
---|
468 | fHiGainFirstDeriv [i] = (6.0*fHiGainFirstDeriv[i]-fHiGainFirstDeriv[i-1])/pp;
|
---|
469 | p++;
|
---|
470 | }
|
---|
471 |
|
---|
472 | fHiGainSecondDeriv[range-1] = 0.;
|
---|
473 | for (Int_t k=range-2;k>=0;k--)
|
---|
474 | fHiGainSecondDeriv[k] = (fHiGainSecondDeriv[k]*fHiGainSecondDeriv[k+1] + fHiGainFirstDeriv[k])/6.;
|
---|
475 |
|
---|
476 | //
|
---|
477 | // Now find the maximum
|
---|
478 | //
|
---|
479 | Float_t step = 0.2; // start with step size of 1ns and loop again with the smaller one
|
---|
480 | Float_t lower = (Float_t)maxpos-1.;
|
---|
481 | Float_t upper = (Float_t)maxpos;
|
---|
482 | Float_t x = lower;
|
---|
483 | Float_t y = 0.;
|
---|
484 | Float_t a = 1.;
|
---|
485 | Float_t b = 0.;
|
---|
486 | Int_t klo = maxpos-1;
|
---|
487 | Int_t khi = maxpos;
|
---|
488 | Float_t klocont = fHiGainSignal[klo];
|
---|
489 | Float_t khicont = fHiGainSignal[khi];
|
---|
490 | sum = (Float_t)khicont;
|
---|
491 | abmaxpos = lower;
|
---|
492 |
|
---|
493 | //
|
---|
494 | // Search for the maximum, starting in interval maxpos-1. If no maximum is found, go to
|
---|
495 | // interval maxpos+1.
|
---|
496 | //
|
---|
497 | while (x<upper-0.3)
|
---|
498 | {
|
---|
499 |
|
---|
500 | x += step;
|
---|
501 | a -= step;
|
---|
502 | b += step;
|
---|
503 |
|
---|
504 | y = a*klocont
|
---|
505 | + b*khicont
|
---|
506 | + (a*a*a-a)*fHiGainSecondDeriv[klo]
|
---|
507 | + (b*b*b-b)*fHiGainSecondDeriv[khi];
|
---|
508 |
|
---|
509 | if (y > sum)
|
---|
510 | {
|
---|
511 | sum = y;
|
---|
512 | abmaxpos = x;
|
---|
513 | }
|
---|
514 | }
|
---|
515 |
|
---|
516 | if (abmaxpos > upper-0.1)
|
---|
517 | {
|
---|
518 |
|
---|
519 | upper = (Float_t)maxpos+1;
|
---|
520 | lower = (Float_t)maxpos;
|
---|
521 | x = lower;
|
---|
522 | a = 1.;
|
---|
523 | b = 0.;
|
---|
524 | khi = maxpos+1;
|
---|
525 | klo = maxpos;
|
---|
526 | klocont = fHiGainSignal[klo];
|
---|
527 | khicont = fHiGainSignal[khi];
|
---|
528 |
|
---|
529 | while (x<upper-0.3)
|
---|
530 | {
|
---|
531 |
|
---|
532 | x += step;
|
---|
533 | a -= step;
|
---|
534 | b += step;
|
---|
535 |
|
---|
536 | y = a* klocont
|
---|
537 | + b* khicont
|
---|
538 | + (a*a*a-a)*fHiGainSecondDeriv[klo]
|
---|
539 | + (b*b*b-b)*fHiGainSecondDeriv[khi];
|
---|
540 |
|
---|
541 | if (y > sum)
|
---|
542 | {
|
---|
543 | sum = y;
|
---|
544 | abmaxpos = x;
|
---|
545 | }
|
---|
546 | }
|
---|
547 | }
|
---|
548 |
|
---|
549 | const Float_t up = abmaxpos+step-0.055;
|
---|
550 | const Float_t lo = abmaxpos-step+0.055;
|
---|
551 | const Float_t maxpossave = abmaxpos;
|
---|
552 |
|
---|
553 | x = abmaxpos;
|
---|
554 | a = upper - x;
|
---|
555 | b = x - lower;
|
---|
556 |
|
---|
557 | step = 0.04; // step size of 83 ps
|
---|
558 |
|
---|
559 | while (x<up)
|
---|
560 | {
|
---|
561 |
|
---|
562 | x += step;
|
---|
563 | a -= step;
|
---|
564 | b += step;
|
---|
565 |
|
---|
566 | y = a* klocont
|
---|
567 | + b* khicont
|
---|
568 | + (a*a*a-a)*fHiGainSecondDeriv[klo]
|
---|
569 | + (b*b*b-b)*fHiGainSecondDeriv[khi];
|
---|
570 |
|
---|
571 | if (y > sum)
|
---|
572 | {
|
---|
573 | sum = y;
|
---|
574 | abmaxpos = x;
|
---|
575 | }
|
---|
576 | }
|
---|
577 |
|
---|
578 | if (abmaxpos < klo + 0.02)
|
---|
579 | {
|
---|
580 | klo--;
|
---|
581 | khi--;
|
---|
582 | klocont = fHiGainSignal[klo];
|
---|
583 | khicont = fHiGainSignal[khi];
|
---|
584 | upper--;
|
---|
585 | lower--;
|
---|
586 | }
|
---|
587 |
|
---|
588 | x = maxpossave;
|
---|
589 | a = upper - x;
|
---|
590 | b = x - lower;
|
---|
591 |
|
---|
592 | while (x>lo)
|
---|
593 | {
|
---|
594 |
|
---|
595 | x -= step;
|
---|
596 | a += step;
|
---|
597 | b -= step;
|
---|
598 |
|
---|
599 | y = a* klocont
|
---|
600 | + b* khicont
|
---|
601 | + (a*a*a-a)*fHiGainSecondDeriv[klo]
|
---|
602 | + (b*b*b-b)*fHiGainSecondDeriv[khi];
|
---|
603 |
|
---|
604 | if (y > sum)
|
---|
605 | {
|
---|
606 | sum = y;
|
---|
607 | abmaxpos = x;
|
---|
608 | }
|
---|
609 | }
|
---|
610 | */
|
---|
611 | }
|
---|
612 |
|
---|
613 | // --------------------------------------------------------------------------
|
---|
614 | //
|
---|
615 | // FindSignalFilter:
|
---|
616 | //
|
---|
617 | // - Loop from ptr to (ptr+fLoGainLast-fLoGainFirst)
|
---|
618 | // - Sum up contents of *ptr
|
---|
619 | // - If *ptr is greater than fSaturationLimit, raise sat by 1
|
---|
620 | //
|
---|
621 | /*
|
---|
622 | void MExtractBlindPixel::FindSignalFilter(Byte_t *ptr, Int_t range, Int_t &sum, Byte_t &sat) const
|
---|
623 | {
|
---|
624 |
|
---|
625 | Byte_t *end = ptr + range;
|
---|
626 |
|
---|
627 | while (ptr<end)
|
---|
628 | {
|
---|
629 | sum += *ptr;
|
---|
630 |
|
---|
631 | if (*ptr++ >= fSaturationLimit)
|
---|
632 | sat++;
|
---|
633 | }
|
---|
634 | }
|
---|
635 | */
|
---|
636 |
|
---|
637 | // --------------------------------------------------------------------------
|
---|
638 | //
|
---|
639 | // Calculate the integral of the FADC time slices and store them as a new
|
---|
640 | // pixel in the MExtractedBlindPixel container.
|
---|
641 | //
|
---|
642 | Int_t MExtractBlindPixel::Process()
|
---|
643 | {
|
---|
644 |
|
---|
645 | MRawEvtPixelIter pixel(fRawEvt);
|
---|
646 |
|
---|
647 | fBlindPixel->Clear();
|
---|
648 |
|
---|
649 | for (UInt_t id=0;id<fBlindPixelIdx.GetSize();id++)
|
---|
650 | {
|
---|
651 | // Be carefull: GetSaturation changed sat0 and sat1
|
---|
652 | Int_t sat0 = fHiGainFirst; // First slice to extract and first saturating slice
|
---|
653 | Int_t sat1 = fHiGainLast; // Last slice to extract and last saturating slice
|
---|
654 |
|
---|
655 | const Int_t sat = fSignal->GetSaturation(fBlindPixelIdx[id], fSaturationLimit, sat0, sat1);
|
---|
656 |
|
---|
657 | if (IsExtractionType(kFilter))
|
---|
658 | {
|
---|
659 | // FIXME: fLoGain* is used to determine the FILTER/CHECK range
|
---|
660 | const Int_t numh = fRunHeader->GetNumSamplesHiGain();
|
---|
661 |
|
---|
662 | const Int_t sum = fSignal->GetIntegralRaw(fBlindPixelIdx[id], fLoGainFirst+numh, fLoGainLast+numh);
|
---|
663 | if (sum > fNSBFilterLimit)
|
---|
664 | {
|
---|
665 | fBlindPixel->SetExtractedSignal(-1.,id);
|
---|
666 | fBlindPixel->SetNumSaturated(sat,id);
|
---|
667 | fBlindPixel->SetReadyToSave();
|
---|
668 | continue;
|
---|
669 | }
|
---|
670 |
|
---|
671 | /*
|
---|
672 | sum = 0;
|
---|
673 | if (pixel.HasLoGain())
|
---|
674 | FindSignalFilter(sl+pixel.GetNumLoGainSamples()+fLoGainFirst, fLoGainLast - fLoGainFirst + 1, sum, sat);
|
---|
675 |
|
---|
676 | if (fModified)
|
---|
677 | {
|
---|
678 | if (sum > fNSBFilterLimit)
|
---|
679 | {
|
---|
680 | fBlindPixel->SetExtractedSignal(-1.,id);
|
---|
681 | fBlindPixel->SetNumSaturated(sat,id);
|
---|
682 | fBlindPixel->SetReadyToSave();
|
---|
683 | continue;
|
---|
684 | }
|
---|
685 | }
|
---|
686 | */
|
---|
687 | }
|
---|
688 |
|
---|
689 |
|
---|
690 | Float_t newsum = 0.;
|
---|
691 | if (IsExtractionType(kAmplitude))
|
---|
692 | newsum = FindAmplitude(fBlindPixelIdx[id], sat);
|
---|
693 | else
|
---|
694 | newsum = fSignal->GetIntegralRaw(fBlindPixelIdx[id], fHiGainFirst, fHiGainLast);
|
---|
695 |
|
---|
696 | fBlindPixel->SetExtractedSignal(newsum, id);
|
---|
697 | fBlindPixel->SetNumSaturated(sat, id);
|
---|
698 | }
|
---|
699 |
|
---|
700 | fBlindPixel->SetReadyToSave();
|
---|
701 | return kTRUE;
|
---|
702 | }
|
---|
703 |
|
---|
704 | // ------------------------------------------------------------------------------------
|
---|
705 | //
|
---|
706 | // Returns true if the Data type. Available are: kAmplitude, kIntegral and kFilter
|
---|
707 | // The flags kIntegral and kFilter may be set both.
|
---|
708 | //
|
---|
709 | Bool_t MExtractBlindPixel::IsDataType( const DataType_t typ )
|
---|
710 | {
|
---|
711 | return TESTBIT( fDataType, typ );
|
---|
712 | }
|
---|
713 |
|
---|
714 | // ------------------------------------------------------------------------------------
|
---|
715 | //
|
---|
716 | // Returns true if the extraction type. Available are: kAmplitude, kIntegral and kFilter
|
---|
717 | // The flags kIntegral and kFilter may be set both.
|
---|
718 | //
|
---|
719 | Bool_t MExtractBlindPixel::IsExtractionType( const ExtractionType_t typ )
|
---|
720 | {
|
---|
721 | return TESTBIT( fExtractionType, typ );
|
---|
722 | }
|
---|
723 |
|
---|
724 | // --------------------------------------------------------------------------
|
---|
725 | //
|
---|
726 | // Sets the Data type. Available are: kAmplitude and kIntegral
|
---|
727 | //
|
---|
728 | void MExtractBlindPixel::SetDataType( const DataType_t typ )
|
---|
729 | {
|
---|
730 | SETBIT( fDataType, typ );
|
---|
731 | }
|
---|
732 |
|
---|
733 | // --------------------------------------------------------------------------
|
---|
734 | //
|
---|
735 | // Sets the extraction type. Available are: kAmplitude and kIntegral
|
---|
736 | //
|
---|
737 | void MExtractBlindPixel::SetExtractionType( const ExtractionType_t typ )
|
---|
738 | {
|
---|
739 | SETBIT( fExtractionType, typ );
|
---|
740 | }
|
---|