1 | /* ======================================================================== *\
|
---|
2 | ! $Name: not supported by cvs2svn $:$Id: MExtractTimeAndCharge.cc,v 1.55 2006-10-24 08:24:52 tbretz Exp $
|
---|
3 | ! --------------------------------------------------------------------------
|
---|
4 | !
|
---|
5 | ! *
|
---|
6 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
7 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
8 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
9 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
10 | ! *
|
---|
11 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
12 | ! * documentation for any purpose is hereby granted without fee,
|
---|
13 | ! * provided that the above copyright notice appear in all copies and
|
---|
14 | ! * that both that copyright notice and this permission notice appear
|
---|
15 | ! * in supporting documentation. It is provided "as is" without express
|
---|
16 | ! * or implied warranty.
|
---|
17 | ! *
|
---|
18 | !
|
---|
19 | !
|
---|
20 | ! Author(s): Markus Gaug, 05/2004 <mailto:markus@ifae.es>
|
---|
21 | ! Author(s): Thomas Bretz, 05/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
22 | !
|
---|
23 | ! Copyright: MAGIC Software Development, 2000-2006
|
---|
24 | !
|
---|
25 | !
|
---|
26 | \* ======================================================================== */
|
---|
27 |
|
---|
28 | //////////////////////////////////////////////////////////////////////////////
|
---|
29 | //
|
---|
30 | // MExtractTimeAndCharge
|
---|
31 | //
|
---|
32 | // Base class for the signal extractors which extract the arrival time
|
---|
33 | // and the signal at the same time. Uses the functions
|
---|
34 | // FindTimeAndChargeHiGain() and FindTimeAndChargeLoGain() to extract the signal and
|
---|
35 | // substract the pedestal value.
|
---|
36 | //
|
---|
37 | // The following figure gives and example of possible inheritance trees.
|
---|
38 | // An extractor class can inherit from each of the following base classes:
|
---|
39 | // - MExtractor
|
---|
40 | // - MExtractTime
|
---|
41 | // - MExtractTimeAndCharge
|
---|
42 | //
|
---|
43 | //Begin_Html
|
---|
44 | /*
|
---|
45 | <img src="images/ExtractorClasses.gif">
|
---|
46 | */
|
---|
47 | //End_Html
|
---|
48 | //
|
---|
49 | // The following variables have to be set by the derived class and
|
---|
50 | // do not have defaults:
|
---|
51 | // - fNumHiGainSamples
|
---|
52 | // - fNumLoGainSamples
|
---|
53 | // - fSqrtHiGainSamples
|
---|
54 | // - fSqrtLoGainSamples
|
---|
55 | //
|
---|
56 | // Input Containers:
|
---|
57 | // MRawEvtData
|
---|
58 | // MRawRunHeader
|
---|
59 | // MPedestalCam
|
---|
60 | //
|
---|
61 | // Output Containers:
|
---|
62 | // MArrivalTimeCam
|
---|
63 | // MExtractedSignalCam
|
---|
64 | //
|
---|
65 | // For weired events check: Run 94127 Event 672, 1028
|
---|
66 | //
|
---|
67 | //////////////////////////////////////////////////////////////////////////////
|
---|
68 | #include "MExtractTimeAndCharge.h"
|
---|
69 |
|
---|
70 | #include <TRandom.h>
|
---|
71 |
|
---|
72 | #include "MLog.h"
|
---|
73 | #include "MLogManip.h"
|
---|
74 |
|
---|
75 | #include "MParList.h"
|
---|
76 |
|
---|
77 | //#include "MArrayB.h"
|
---|
78 | //#include "MArrayF.h"
|
---|
79 |
|
---|
80 | //#include "MRawEvtData.h"
|
---|
81 | #include "MRawEvtPixelIter.h"
|
---|
82 | //#include "MRawRunHeader.h"
|
---|
83 |
|
---|
84 | //#include "MPedestalCam.h"
|
---|
85 | //#include "MPedestalPix.h"
|
---|
86 | #include "MPedestalSubtractedEvt.h"
|
---|
87 |
|
---|
88 | #include "MArrivalTimeCam.h"
|
---|
89 | #include "MArrivalTimePix.h"
|
---|
90 |
|
---|
91 | #include "MExtractedSignalCam.h"
|
---|
92 | #include "MExtractedSignalPix.h"
|
---|
93 |
|
---|
94 | ClassImp(MExtractTimeAndCharge);
|
---|
95 |
|
---|
96 | using namespace std;
|
---|
97 |
|
---|
98 | const Float_t MExtractTimeAndCharge::fgLoGainStartShift = -6.0;
|
---|
99 | const Byte_t MExtractTimeAndCharge::fgLoGainSwitch = 120;
|
---|
100 |
|
---|
101 | // --------------------------------------------------------------------------
|
---|
102 | //
|
---|
103 | // Default constructor.
|
---|
104 | //
|
---|
105 | // Sets:
|
---|
106 | // - fWindowSizeHiGain and fWindowSizeLoGain to 0
|
---|
107 | // - fLoGainStartShift to fgLoGainStartShift+fgOffsetLoGain
|
---|
108 | // - fLoGainSwitch to fgLoGainSwitch
|
---|
109 | //
|
---|
110 | MExtractTimeAndCharge::MExtractTimeAndCharge(const char *name, const char *title)
|
---|
111 | : /*fLoGainFirstSave(0),*/ fWindowSizeHiGain(0), fWindowSizeLoGain(0)
|
---|
112 | {
|
---|
113 | fName = name ? name : "MExtractTimeAndCharge";
|
---|
114 | fTitle = title ? title : "Base class for signal and time extractors";
|
---|
115 |
|
---|
116 | SetLoGainStartShift();
|
---|
117 | SetLoGainSwitch();
|
---|
118 | }
|
---|
119 |
|
---|
120 | // --------------------------------------------------------------------------
|
---|
121 | //
|
---|
122 | // The PreProcess searches for the following input containers:
|
---|
123 | // - MRawEvtData
|
---|
124 | // - MRawRunHeader
|
---|
125 | // - MPedestalCam
|
---|
126 | //
|
---|
127 | // The following output containers are also searched and created if
|
---|
128 | // they were not found:
|
---|
129 | //
|
---|
130 | // - MExtractedSignalCam
|
---|
131 | // - MArrivalTimeCam
|
---|
132 | //
|
---|
133 | Int_t MExtractTimeAndCharge::PreProcess(MParList *pList)
|
---|
134 | {
|
---|
135 |
|
---|
136 | if (!MExtractTime::PreProcess(pList))
|
---|
137 | return kFALSE;
|
---|
138 |
|
---|
139 | fSignals = (MExtractedSignalCam*)pList->FindCreateObj("MExtractedSignalCam",AddSerialNumber(fNameSignalCam));
|
---|
140 | if (!fSignals)
|
---|
141 | return kFALSE;
|
---|
142 |
|
---|
143 | *fLog << flush << inf;
|
---|
144 | return kTRUE;
|
---|
145 | }
|
---|
146 |
|
---|
147 | // --------------------------------------------------------------------------
|
---|
148 | //
|
---|
149 | // The ReInit calls:
|
---|
150 | // - MExtractor::ReInit()
|
---|
151 | //
|
---|
152 | // Call:
|
---|
153 | // - MArrivalTimeCam::SetUsedFADCSlices(fHiGainFirst, fHiGainLast, fNumHiGainSamples,
|
---|
154 | // fLoGainFirst, fLoGainLast, fNumLoGainSamples);
|
---|
155 | // - InitArrays();
|
---|
156 | //
|
---|
157 | Bool_t MExtractTimeAndCharge::ReInit(MParList *pList)
|
---|
158 | {
|
---|
159 |
|
---|
160 | if (!MExtractTime::ReInit(pList))
|
---|
161 | return kFALSE;
|
---|
162 |
|
---|
163 | if (!InitArrays())
|
---|
164 | return kFALSE;
|
---|
165 |
|
---|
166 | if (fSignals)
|
---|
167 | fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast/*+fHiLoLast*/, fNumHiGainSamples,
|
---|
168 | fLoGainFirst, fLoGainLast, fNumLoGainSamples);
|
---|
169 |
|
---|
170 | return kTRUE;
|
---|
171 | }
|
---|
172 |
|
---|
173 | // --------------------------------------------------------------------------
|
---|
174 | //
|
---|
175 | // Calculate the integral of the FADC time slices and store them as a new
|
---|
176 | // pixel in the MArrivalTimeCam container.
|
---|
177 | // Calculate the integral of the FADC time slices and store them as a new
|
---|
178 | // pixel in the MExtractedSignalCam container.
|
---|
179 | // The functions FindTimeAndChargeHiGain() and FindTimeAndChargeLoGain() are
|
---|
180 | // supposed to extract the signal themselves.
|
---|
181 | //
|
---|
182 | Int_t MExtractTimeAndCharge::Process()
|
---|
183 | {
|
---|
184 | MRawEvtPixelIter pixel(fRawEvt);
|
---|
185 |
|
---|
186 | while (pixel.Next())
|
---|
187 | {
|
---|
188 | const Int_t pixidx = pixel.GetPixelId();
|
---|
189 |
|
---|
190 | //
|
---|
191 | // Preparations for the pedestal subtraction (with AB-noise correction)
|
---|
192 | //
|
---|
193 | Float_t *sig = fSignal->GetSamples(pixidx);
|
---|
194 |
|
---|
195 | // ====================================================================
|
---|
196 | // MOVE THIS TO MExtractTimeAndCharge
|
---|
197 | // ====================================================================
|
---|
198 | // number of hi- and lo-gains
|
---|
199 | const Int_t numh = pixel.GetNumHiGainSamples();
|
---|
200 | const Int_t numl = pixel.GetNumLoGainSamples();
|
---|
201 | /*
|
---|
202 | // COPY HERE PRODUCING ARRAY WITH SAMPLES
|
---|
203 | static MArrayB sample;
|
---|
204 | sample.Set(numh+numl);
|
---|
205 |
|
---|
206 | if (numl>0)
|
---|
207 | {
|
---|
208 | memcpy(sample.GetArray(), pixel.GetHiGainSamples(), numh);
|
---|
209 | memcpy(sample.GetArray()+numh, pixel.GetLoGainSamples(), numl);
|
---|
210 | }
|
---|
211 |
|
---|
212 | // get pedestal information
|
---|
213 | const MPedestalPix &pedpix = (*fPedestals)[pixidx];
|
---|
214 |
|
---|
215 | // pedestal information
|
---|
216 | const Int_t ab = pixel.HasABFlag() ? 1 : 0;
|
---|
217 | const Float_t ped = pedpix.GetPedestal();
|
---|
218 |
|
---|
219 | // destination array
|
---|
220 | static MArrayF sig;
|
---|
221 | sig.Set(numh+numl);
|
---|
222 |
|
---|
223 | // start of destination array, end of hi-gain destination array
|
---|
224 | // and start of hi-gain samples
|
---|
225 | Float_t *beg = sig.GetArray();
|
---|
226 | Float_t *end = beg + sig.GetSize();
|
---|
227 |
|
---|
228 | // determine with which pedestal (+/- AB offset) to start
|
---|
229 | const Bool_t noswap = (ab&1)==((beg-beg)&1);
|
---|
230 | const Float_t offh = noswap ? pedpix.GetPedestalABoffset() : -pedpix.GetPedestalABoffset();
|
---|
231 | const Float_t mean[2] = { ped + offh, ped - offh };
|
---|
232 |
|
---|
233 | //const Int_t rangeh = fHiGainLast - fHiGainFirst + 1 + fHiLoLast;
|
---|
234 | //const Int_t rangel = fLoGainLast - fLoGainFirst + 1;
|
---|
235 |
|
---|
236 | const Byte_t *src = numl>0 ? sample.GetArray() : pixel.GetHiGainSamples();
|
---|
237 | //const Byte_t *src = sample.GetArray();
|
---|
238 |
|
---|
239 | // Copy hi-gains into array and substract pedestal
|
---|
240 | // FIXME: Shell we really subtract the pedestal from saturating slices???
|
---|
241 | for (Float_t *ptr=beg; ptr<end; ptr++)
|
---|
242 | *ptr = (Float_t)*src++ - mean[(ptr-beg)&1];
|
---|
243 |
|
---|
244 | // Determin saturation of hi-gains
|
---|
245 | Byte_t *p0 = fSignal->GetSamplesRaw(pixidx); //numl>0 ? sample.GetArray() : pixel.GetHiGainSamples();
|
---|
246 | // Byte_t *p0 = sample.GetArray();
|
---|
247 |
|
---|
248 | Byte_t maxcont = 0;
|
---|
249 | Int_t maxposhi = -1;
|
---|
250 |
|
---|
251 | Byte_t *sathi0 = 0; // first saturating hi-gain slice
|
---|
252 | Byte_t *sathi1 = 0; // last saturating hi-gain slice
|
---|
253 | for (Byte_t *ptr=p0+fHiGainFirst; ptr<p0+fHiGainLast+fHiLoLast+1; ptr++)
|
---|
254 | {
|
---|
255 | // Get hi-gain maxbincontent
|
---|
256 | // Put this into its own function and loop?
|
---|
257 | if (*ptr>maxcont)
|
---|
258 | {
|
---|
259 | // ORGINAL:
|
---|
260 | //Int_t range = (fHiGainLast - fHiGainFirst + 1 + fHiLoLast) - fWindowSizeHiGain + 1;
|
---|
261 | // maxpos>1 && maxpos<=range
|
---|
262 |
|
---|
263 | // This is a strange workaround to fit the previous
|
---|
264 | // Spline setup: TO BE CHECKED!
|
---|
265 | const Int_t pos = ptr-p0;
|
---|
266 | if (pos<fHiGainLast+1)
|
---|
267 | {
|
---|
268 | maxposhi = pos-fHiGainFirst;
|
---|
269 |
|
---|
270 | if (maxposhi>1 && maxposhi<fHiGainLast-fHiGainFirst*//*+1 -fWindowSizeHiGain+1*//*+fHiLoLast*//*)
|
---|
271 | maxcont = *ptr;
|
---|
272 | }
|
---|
273 | }
|
---|
274 |
|
---|
275 | // FIXME: Do we also have to really COUNT the number
|
---|
276 | // of saturating slices, eg. for crosschecks?
|
---|
277 | if (*ptr>=fSaturationLimit)
|
---|
278 | {
|
---|
279 | sathi1 = ptr;
|
---|
280 | if (!sathi0)
|
---|
281 | sathi0 = ptr;
|
---|
282 | }
|
---|
283 | }
|
---|
284 | */
|
---|
285 | Int_t sathi0 = fHiGainFirst; // First slice to extract and first saturating slice
|
---|
286 | Int_t sathi1 = fHiGainLast/*+fHiLoLast*/; // Last slice to extract and last saturating slice
|
---|
287 |
|
---|
288 | Int_t maxcont;
|
---|
289 | Int_t maxposhi = fSignal->GetMax(pixidx, sathi0, sathi1, maxcont);
|
---|
290 | // Would it be better to take lastsat-firstsat?
|
---|
291 | Int_t numsathi = fSignal->GetSaturation(pixidx, fSaturationLimit, sathi0, sathi1);
|
---|
292 | /*
|
---|
293 | // sathi2 is the number (not the index) of first saturating slice
|
---|
294 | // const Byte_t sathi2 = sathi0<0 ? 0 : sathi0+1;
|
---|
295 |
|
---|
296 | // Number (not index) of first saturating slice
|
---|
297 | // const Byte_t sathi2 = sathi0==0 ? 0 : sathi0-p0+1;
|
---|
298 | // const Byte_t numsathi = sathi0==0 ? 0 : sathi1-sathi0+1;
|
---|
299 |
|
---|
300 | // Int_t maxb = maxcont;
|
---|
301 |
|
---|
302 | // ====================================================================
|
---|
303 | // FIXME: Move range out of the extractors...
|
---|
304 |
|
---|
305 | // Initialize maxcont for the case, it gets not set by the derived class
|
---|
306 | Float_t sumhi2 =0., deltasumhi2 =-1; // Set hi-gain of MExtractedSignalPix valid
|
---|
307 | Float_t timehi2=0., deltatimehi2=-1; // Set hi-gain of MArrivalTimePix valid
|
---|
308 | */
|
---|
309 | Float_t sumhi =0., deltasumhi =-1; // Set hi-gain of MExtractedSignalPix valid
|
---|
310 | Float_t timehi=0., deltatimehi=-1; // Set hi-gain of MArrivalTimePix valid
|
---|
311 | if (numsathi<1)
|
---|
312 | {
|
---|
313 |
|
---|
314 | const Int_t rangehi = fHiGainLast - fHiGainFirst + 1/* + fHiLoLast*/;
|
---|
315 | FindTimeAndChargeHiGain2(sig/*.GetArray()*/+fHiGainFirst, rangehi,
|
---|
316 | sumhi, deltasumhi, timehi, deltatimehi,
|
---|
317 | numsathi, maxposhi);
|
---|
318 |
|
---|
319 | timehi += fHiGainFirst;
|
---|
320 | }
|
---|
321 | /*
|
---|
322 | Float_t sumhi = sumhi2;
|
---|
323 | Float_t deltasumhi = deltasumhi2;
|
---|
324 | Float_t timehi = timehi2;
|
---|
325 | Float_t deltatimehi=deltatimehi2;
|
---|
326 | // Byte_t sathi = sathi2;
|
---|
327 |
|
---|
328 |
|
---|
329 | //
|
---|
330 | // Find signal in hi- and lo-gain
|
---|
331 | //
|
---|
332 | Float_t sumhi =0., deltasumhi =-1; // Set hi-gain of MExtractedSignalPix valid
|
---|
333 | Float_t timehi=0., deltatimehi=-1; // Set hi-gain of MArrivalTimePix valid
|
---|
334 | Byte_t sathi=0;
|
---|
335 |
|
---|
336 | // Initialize maxcont for the case, it gets not set by the derived class
|
---|
337 | maxcont = fLoGainSwitch + 1;
|
---|
338 |
|
---|
339 | //const Int_t pixidx = pixel.GetPixelId();
|
---|
340 | //const MPedestalPix &ped = (*fPedestals)[pixidx];
|
---|
341 | const Bool_t higainabflag = pixel.HasABFlag();
|
---|
342 | FindTimeAndChargeHiGain(pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(),
|
---|
343 | sumhi, deltasumhi, timehi, deltatimehi,
|
---|
344 | sathi, pedpix, higainabflag);
|
---|
345 | timehi += fHiGainFirst;
|
---|
346 |
|
---|
347 | */
|
---|
348 | // Make sure that in cases the time couldn't be correctly determined
|
---|
349 | // more meaningfull default values are assigned
|
---|
350 | if (timehi<=fHiGainFirst || timehi>=fHiGainLast)
|
---|
351 | timehi = gRandom->Uniform(fHiGainLast-fHiGainFirst)+fHiGainFirst;
|
---|
352 |
|
---|
353 | Float_t sumlo =0., deltasumlo =-1.; // invalidate logain of MExtractedSignalPix
|
---|
354 | Float_t timelo=0., deltatimelo=-1; // invalidate logain of MArrivalTimePix
|
---|
355 | Byte_t satlo=0;
|
---|
356 | Int_t numsatlo=0;
|
---|
357 |
|
---|
358 | //
|
---|
359 | // Adapt the low-gain extraction range from the obtained high-gain time
|
---|
360 | //
|
---|
361 |
|
---|
362 | // IN THIS CASE THE PIXEL SHOULD BE MARKED BAD!!!!
|
---|
363 | // MEANS: Hi gain has saturated, but the signal is to dim
|
---|
364 | // to extract the lo-gain properly
|
---|
365 | // THIS produces pulse positions ~= -1
|
---|
366 | // The signal might be handled in MCalibrateData, but hwat's about
|
---|
367 | // the arrival times in MCalibrateRelTime
|
---|
368 | if (numsathi>0 && maxcont<=fLoGainSwitch)
|
---|
369 | deltasumlo=deltasumhi=deltatimelo=deltatimehi=-1;
|
---|
370 |
|
---|
371 | // If more than 8 hi-gain slices have saturated this is
|
---|
372 | // no physical event. We just assume that something with
|
---|
373 | // the extraction is wrong
|
---|
374 | if (numsathi>8) // FIXME: Should be something like 2?
|
---|
375 | deltasumhi=deltatimehi=-1;
|
---|
376 |
|
---|
377 | // FIXME: What to do with the pixel if it saturates too early???
|
---|
378 | if (pixel.HasLoGain() && (maxcont > fLoGainSwitch /*|| sathi>0*/) )
|
---|
379 | {
|
---|
380 | // To determin the window in which the lo-gain is extracted
|
---|
381 | // clearly more information about the relation between the
|
---|
382 | // extraction window and the reslting time is necessary.
|
---|
383 | //fLoGainStartShift = -6.0;
|
---|
384 |
|
---|
385 | const Byte_t fLoGainFirstSave = fLoGainFirst;
|
---|
386 |
|
---|
387 | // sathi is the number (not index!) of the first saturating slice
|
---|
388 | // 0 indicates that no saturation was found
|
---|
389 | // FIXME: Is 0.5 should be expressed by the rise time of
|
---|
390 | // the hi-gain signal!
|
---|
391 | const Float_t pos = numsathi==0 ? timehi : sathi0-0.5;
|
---|
392 |
|
---|
393 | const Int_t lostart = TMath::FloorNint(pos+6);
|
---|
394 |
|
---|
395 | const Int_t newfirst = TMath::FloorNint(pos+fLoGainStartShift);
|
---|
396 | fLoGainFirst = newfirst>fLoGainFirstSave ? newfirst : fLoGainFirstSave;
|
---|
397 |
|
---|
398 | // if (fLoGainLast-fLoGainFirst >= fWindowSizeLoGain)
|
---|
399 | {
|
---|
400 | /*
|
---|
401 | Float_t sumlo2 =0., deltasumlo2 =-1.; // invalidate logain of MExtractedSignalPix
|
---|
402 | Float_t timelo2=0., deltatimelo2=-1.; // invalidate logain of MArrivalTimePix
|
---|
403 |
|
---|
404 | // Determin saturation in lo-gains
|
---|
405 | Byte_t *satlo0 = 0; // first saturating hi-gain slice
|
---|
406 | Byte_t *satlo1 = 0; // last saturating hi-gain slice
|
---|
407 | Int_t maxposlo = -1;
|
---|
408 | Byte_t maxlo = 0;
|
---|
409 |
|
---|
410 | Byte_t *p0 = fSignal->GetSamplesRaw(pixidx);
|
---|
411 | for (Byte_t *ptr=p0+numh+fLoGainFirst; ptr<p0+numh+fLoGainLast+1; ptr++)
|
---|
412 | {
|
---|
413 | if (*ptr>maxlo)
|
---|
414 | {
|
---|
415 | // This is a strange workaround to fit the previous
|
---|
416 | // Spline setup: TO BE CHECKED!
|
---|
417 | const Int_t ipos = ptr-p0-numh;
|
---|
418 | if (ipos>=fLoGainFirst && ipos<=fLoGainLast)
|
---|
419 | {
|
---|
420 | maxposlo = ipos-fLoGainFirst;
|
---|
421 | maxlo = *ptr;
|
---|
422 | }
|
---|
423 | }
|
---|
424 | if (*ptr>=fSaturationLimit)
|
---|
425 | {
|
---|
426 | satlo1 = ptr;
|
---|
427 | if (!satlo0)
|
---|
428 | satlo0 = ptr;
|
---|
429 | }
|
---|
430 | // FIXME: Do we also have to really COUNT the number
|
---|
431 | // of saturating slices, eg. for crosschecks?
|
---|
432 | }
|
---|
433 |
|
---|
434 | // Number of saturating lo-gain slices (this is not necessary
|
---|
435 | // identical to a counter counting the number of saturating
|
---|
436 | // slices!)
|
---|
437 | const Byte_t numsatlo = satlo0==0 ? 0 : satlo1-satlo0+1;
|
---|
438 | */
|
---|
439 |
|
---|
440 | Int_t satlo0 = numh+fLoGainFirst; // First slice to extract and first saturating slice
|
---|
441 | Int_t satlo1 = numh+fLoGainLast; // Last slice to extract and last saturating slice
|
---|
442 |
|
---|
443 | // Would it be better to take lastsat-firstsat?
|
---|
444 | Int_t maxlo;
|
---|
445 | Int_t maxposlo = fSignal->GetMax(pixidx, satlo0, satlo1, maxlo);
|
---|
446 | numsatlo = fSignal->GetSaturation(pixidx, fSaturationLimit, satlo0, satlo1);
|
---|
447 |
|
---|
448 | // const Byte_t satlo2 = numsatlo;
|
---|
449 |
|
---|
450 | const Int_t rangelo = fLoGainLast - fLoGainFirst + 1;
|
---|
451 | FindTimeAndChargeLoGain2(sig/*.GetArray()*/+numh+fLoGainFirst, rangelo,
|
---|
452 | sumlo, deltasumlo, timelo, deltatimelo,
|
---|
453 | numsatlo, maxposlo);
|
---|
454 | timelo += fLoGainFirst;
|
---|
455 |
|
---|
456 | // sumlo =sumlo2, deltasumlo=deltasumlo2; // invalidate logain of MExtractedSignalPix
|
---|
457 | // timelo=timelo2, deltatimelo=deltatimelo2; // invalidate logain of MArrivalTimePix
|
---|
458 | // satlo = satlo2;
|
---|
459 |
|
---|
460 | /*
|
---|
461 | // THIS IS NOW THE JOB OF THE EXTRACTOR!
|
---|
462 | //deltasumlo = 0; // make logain of MExtractedSignalPix valid
|
---|
463 | //deltatimelo = 0; // make logain of MArrivalTimePix valid
|
---|
464 |
|
---|
465 | const Bool_t logainabflag = (higainabflag + pixel.GetNumHiGainSamples()) & 0x1;
|
---|
466 | FindTimeAndChargeLoGain(pixel.GetLoGainSamples()+fLoGainFirst,
|
---|
467 | sumlo, deltasumlo, timelo, deltatimelo,
|
---|
468 | satlo, pedpix, logainabflag);
|
---|
469 | timelo += fLoGainFirst;
|
---|
470 | */
|
---|
471 |
|
---|
472 |
|
---|
473 | // If more than 6 lo-gain slices have saturated this is
|
---|
474 | // no physical event. We just assume that something with
|
---|
475 | // the extraction is wrong
|
---|
476 | if (numsatlo>6)
|
---|
477 | deltasumlo=deltatimelo=-1;
|
---|
478 | }
|
---|
479 | fLoGainFirst = fLoGainFirstSave;
|
---|
480 |
|
---|
481 | // Make sure that in cases the time couldn't be correctly determined
|
---|
482 | // more meaningfull default values are assigned
|
---|
483 | if (timelo<=fLoGainFirst || timelo>=fLoGainLast)
|
---|
484 | timelo = gRandom->Uniform(fLoGainLast-fLoGainFirst)+fLoGainFirst;
|
---|
485 | }
|
---|
486 |
|
---|
487 | MExtractedSignalPix &pix = (*fSignals)[pixidx];
|
---|
488 | MArrivalTimePix &tix = (*fArrTime)[pixidx];
|
---|
489 | pix.SetExtractedSignal(sumhi, deltasumhi, sumlo, deltasumlo);
|
---|
490 | pix.SetGainSaturation(numsathi, numsatlo);
|
---|
491 | // pix.SetGainSaturation(sathi, satlo);
|
---|
492 |
|
---|
493 | tix.SetArrivalTime(timehi, deltatimehi, timelo-fOffsetLoGain, deltatimelo);
|
---|
494 | tix.SetGainSaturation(numsathi, numsatlo);
|
---|
495 | // tix.SetGainSaturation(sathi, satlo);
|
---|
496 | } /* while (pixel.Next()) */
|
---|
497 |
|
---|
498 | fArrTime->SetReadyToSave();
|
---|
499 | fSignals->SetReadyToSave();
|
---|
500 |
|
---|
501 | return kTRUE;
|
---|
502 | }
|
---|
503 |
|
---|
504 | // --------------------------------------------------------------------------
|
---|
505 | //
|
---|
506 | // In addition to the resources of the base-class MExtractor:
|
---|
507 | // MJPedestal.MExtractor.LoGainStartShift: -2.8
|
---|
508 | //
|
---|
509 | Int_t MExtractTimeAndCharge::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
|
---|
510 | {
|
---|
511 |
|
---|
512 | Bool_t rc = MExtractTime::ReadEnv(env, prefix, print);
|
---|
513 |
|
---|
514 | if (rc)
|
---|
515 | SetLoGainStartShift();
|
---|
516 |
|
---|
517 | if (IsEnvDefined(env, prefix, "LoGainStartShift", print))
|
---|
518 | {
|
---|
519 | fLoGainStartShift = GetEnvValue(env, prefix, "LoGainStartShift", fgLoGainStartShift);
|
---|
520 | SetLoGainStartShift(fLoGainStartShift);
|
---|
521 | rc = kTRUE;
|
---|
522 | }
|
---|
523 |
|
---|
524 | if (IsEnvDefined(env, prefix, "LoGainSwitch", print))
|
---|
525 | {
|
---|
526 | fLoGainSwitch = GetEnvValue(env, prefix, "LoGainSwitch", fLoGainSwitch);
|
---|
527 | rc = kTRUE;
|
---|
528 | }
|
---|
529 |
|
---|
530 | return rc;
|
---|
531 | }
|
---|
532 |
|
---|
533 | void MExtractTimeAndCharge::Print(Option_t *o) const
|
---|
534 | {
|
---|
535 | MExtractTime::Print(o);
|
---|
536 | // if (IsA()==Class())
|
---|
537 | // *fLog << GetDescriptor() << ":" << endl;
|
---|
538 |
|
---|
539 | *fLog << dec;
|
---|
540 | //*fLog << " Taking " << fWindowSizeHiGain
|
---|
541 | // << " HiGain samples from slice " << (Int_t)fHiGainFirst
|
---|
542 | // << " to " << (Int_t)(fHiGainLast/*+fHiLoLast*/) << " incl" << endl;
|
---|
543 | //*fLog << " Taking " << fWindowSizeLoGain
|
---|
544 | // << " LoGain samples from slice " << (Int_t)fLoGainFirst
|
---|
545 | // << " to " << (Int_t)fLoGainLast << " incl" << endl;
|
---|
546 | //
|
---|
547 | *fLog << " LoGainStartShift: " << fLoGainStartShift << endl;
|
---|
548 | *fLog << " LoGainSwitch: " << (Int_t)fLoGainSwitch << endl;
|
---|
549 | }
|
---|