source: tags/Mars-V0.9.1/mpedestal/MExtractPedestal.cc

Last change on this file was 6913, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 22.5 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 01/2004 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MExtractPedestal
28//
29// Pedestal Extractor base class
30//
31// Input Containers:
32// MRawEvtData
33// MRawRunHeader
34// MRawEvtHeader
35// MGeomCam
36// MPedestalCam
37//
38// Output Containers:
39// MPedestalCam
40//
41// This class should be used for pedestal extractors with the following facilities:
42// a) Standardized calculation of AB-noise, mean pedestals and RMS
43// b) Standardized treatment of area- and sector averaged pedestals values
44// c) Possibility to use a signal extractor to be applied on the pedestals
45// d) Possibility to handle two MPedestalCams: one for the signal extractor and
46// a second to be filled during the pedestal calculating process.
47//
48// ad a): Every calculated value is referred to one FADC slice (e.g. Mean pedestal per slice),
49// RMS per slice.
50// MExtractPedestal applies the following formula (1):
51//
52// Pedestal per slice = sum(x_i) / n / slices
53// PedRMS per slice = Sqrt( ( sum(x_i^2) - sum(x_i)^2/n ) / n-1 / slices )
54// AB-Offset per slice = (sumAB0 - sumAB1) / n / slices
55//
56// where x_i is the sum of "slices" FADC slices and sum means the sum over all
57// events. "n" is the number of events, "slices" is the number of summed FADC samples.
58//
59// Note that the slice-to-slice fluctuations are not Gaussian, but Poissonian, thus
60// asymmetric and they are correlated.
61//
62// It is important to know that the Pedestal per slice and PedRMS per slice depend
63// on the number of used FADC slices, as seen in the following plots:
64//
65//Begin_Html
66/*
67<img src="images/PedestalStudyInner.gif">
68*/
69//End_Html
70//
71//Begin_Html
72/*
73<img src="images/PedestalStudyOuter.gif">
74*/
75//End_Html
76//
77// The plots show the inner and outer pixels, respectivly and have the following meaning:
78//
79// 1) The calculated mean pedestal per slice (from MPedCalcPedRun)
80// 2) The fitted mean pedestal per slice (from MHPedestalCam)
81// 3) The calculated pedestal RMS per slice (from MPedCalcPedRun)
82// 4) The fitted sigma of the pedestal distribution per slice
83// (from MHPedestalCam)
84// 5) The relative difference between calculation and histogram fit
85// for the mean
86// 6) The relative difference between calculation and histogram fit
87// for the sigma or RMS, respectively.
88//
89// The calculated means do not change significantly except for the case of 2 slices,
90// however the RMS changes from 5.7 per slice in the case of 2 extracted slices
91// to 8.3 per slice in the case of 26 extracted slices. This change is very significant.
92//
93// ad b) Every calculated value is referred to one FADC slice and one (averaged) pixel,
94// (e.g. Mean Pedestal per area index per slice per pixel, etc. )
95//
96// MExtractPedestal applies the following formula (2):
97//
98// Averaged Pedestal per slice = sum(x_i) / n / slices / n_pix
99// PedRMS per slice = Sqrt( ( sum(x_i^2) - sum(x_i)^2/n ) / n-1 / slices / n_pix )
100// AB-Offset per slice = (sumAB0 - sumAB1) / n / slices / n_pix
101//
102// where x_i is the sum of "slices" FADC slices and sum means the sum over all
103// events and all concerned pixels.
104// "n" is the number of events, "slices" is the number of summed FADC samples and
105// "n_pix" is the number of pixels belonging to the specific area index or camera sector.
106//
107// Calculating these averaged event-by-event values is very important to trace coherent
108// fluctuations. An example is given in the following plots:
109//
110//Begin_Html
111/*
112<img src="images/PedestalOscillations.gif">
113*/
114//End_Html
115//
116// The plots show the extracted pedestals of the inner pixels (obtained
117// with MHPedestalCam), averaged on an event-by-event basis from
118// run 13428 with switched off camera LV.
119// The meaning of the four plots is:
120//
121// 1) The distribution of the averaged pedestals
122// 2) The averaged pedestals vs. time.
123// One can see clearly the oscillation pattern
124// 3) The fourier transform of the averaged pedestals vs. time.
125// One can see clearly a peak at a certain frequency
126// 4) The projection of the fourier components with the non-exponential
127// (and therefore significant) outlier.
128//
129// ad c) Many signal extractors, especially those using a sliding window
130// have biases and their resolutions for zero-signals do not agree
131// with the pedestal RMS. For the F-Factor method in the calibration
132// and the image cleaning, however, both have to be known and measured.
133//
134// For this reason, a signal extractor can be handed over to the
135// pedestal extractor and applied on the pedestal events with the
136// function SetExtractor().
137// The results will get stored in an MPedestalCam.
138//
139// Note that only extractors deriving from MExtractTimeAndCharge
140// can be used.
141//
142// ad d) The signal extractors themselves need a pedestal to be subtracted
143// from the FADC slices.
144// If the user wishes that the pededestals do not get overwritten by
145// the results from the signal extractor, a different named MPedestalCam
146// can be created with the function: SetNamePedestalOut().
147//
148// See also: MPedestalCam, MPedestalPix, MPedCalcPedRun, MPedCalcFromLoGain
149//
150/////////////////////////////////////////////////////////////////////////////
151#include "MExtractPedestal.h"
152
153#include "MParList.h"
154
155#include "MLog.h"
156#include "MLogManip.h"
157
158#include "MRawRunHeader.h"
159#include "MRawEvtHeader.h"
160#include "MRawEvtPixelIter.h"
161#include "MRawEvtData.h"
162
163#include "MPedestalPix.h"
164#include "MPedestalCam.h"
165
166#include "MGeomPix.h"
167#include "MGeomCam.h"
168
169#include "MTaskEnv.h"
170#include "MExtractTimeAndCharge.h"
171
172ClassImp(MExtractPedestal);
173
174using namespace std;
175
176const TString MExtractPedestal::fgNamePedestalCam = "MPedestalCam";
177const UInt_t MExtractPedestal::fgNumDump = 500;
178
179// --------------------------------------------------------------------------
180//
181// Default constructor:
182//
183// Sets:
184// - all pointers to NULL
185//
186// Calls:
187// - AddToBranchList("fHiGainPixId");
188// - AddToBranchList("fHiGainFadcSamples");
189// - Clear()
190//
191MExtractPedestal::MExtractPedestal(const char *name, const char *title)
192 : fGeom(NULL), fPedestalsIn(NULL), fPedestalsInter(NULL), fPedestalsOut(NULL),
193 fExtractor(NULL), fExtractWinFirst(0), fExtractWinSize(0)
194{
195 fName = name ? name : "MExtractPedestal";
196 fTitle = title ? title : "Base class to calculate pedestals";
197
198 AddToBranchList("fHiGainPixId");
199 AddToBranchList("fLoGainPixId");
200 AddToBranchList("fHiGainFadcSamples");
201 AddToBranchList("fLoGainFadcSamples");
202
203 SetIntermediateStorage( kFALSE );
204 SetPedestalUpdate ( kTRUE );
205 SetRandomCalculation ( kTRUE );
206
207 SetNamePedestalCamIn();
208 SetNamePedestalCamOut();
209 SetNumDump();
210
211 Clear();
212}
213
214void MExtractPedestal::ResetArrays()
215{
216 // Reset contents of arrays.
217 fSumx.Reset();
218 fSumx2.Reset();
219 fSumAB0.Reset();
220 fSumAB1.Reset();
221 fAreaSumx.Reset();
222 fAreaSumx2.Reset();
223 fAreaSumAB0.Reset();
224 fAreaSumAB1.Reset();
225 fAreaFilled.Reset();
226 fAreaValid.Reset();
227 fSectorSumx.Reset();
228 fSectorSumx2.Reset();
229 fSectorSumAB0.Reset();
230 fSectorSumAB1.Reset();
231 fSectorFilled.Reset();
232 fSectorValid.Reset();
233
234}
235
236// --------------------------------------------------------------------------
237//
238// Resets Arrays:
239//
240// Sets:
241// - fRawEvt to NULL
242// - fRunHeader to NULL
243// - fEvtHeader to NULL
244//
245void MExtractPedestal::Clear(const Option_t *o)
246{
247
248 fRawEvt = NULL;
249 fRunHeader = NULL;
250 fEvtHeader = NULL;
251
252 // If the size is yet set, set the size
253 if (fSumx.GetSize()>0)
254 ResetArrays();
255
256}
257
258// --------------------------------------------------------------------------
259//
260// Checks:
261// - if a window is odd
262//
263Bool_t MExtractPedestal::SetExtractWindow(UShort_t windowf, UShort_t windows)
264{
265
266 Bool_t rc = kTRUE;
267
268 const Int_t odd = windows & 0x1;
269
270 if (odd && !fExtractor)
271 {
272 *fLog << warn << GetDescriptor();
273 *fLog << " - WARNING: Window size in SetExtractWindow has to be even... ";
274 *fLog << " raising from " << windows << " to ";
275 windows += 1;
276 *fLog << windows << "!" << endl;
277 rc = kFALSE;
278 }
279
280 if (windows==0)
281 {
282 *fLog << warn << GetDescriptor();
283 *fLog << " - WARNING: Window size in SetExtractWindow has to be > 0... adjusting to 2!" << endl;
284 windows = 2;
285 rc = kFALSE;
286 }
287
288 fExtractWinSize = windows;
289 fExtractWinFirst = windowf;
290 fExtractWinLast = fExtractWinFirst+fExtractWinSize-1;
291
292 return rc;
293}
294
295// --------------------------------------------------------------------------
296//
297// Look for the following input containers:
298//
299// - MRawEvtData
300// - MRawRunHeader
301// - MRawEvtHeader
302// - MGeomCam
303//
304// The following output containers are also searched and created if
305// they were not found:
306//
307// - MPedestalCam with the name fPedContainerName
308//
309Int_t MExtractPedestal::PreProcess(MParList *pList)
310{
311
312 Clear();
313
314 fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
315 if (!fRawEvt)
316 {
317 *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
318 return kFALSE;
319 }
320
321 fRunHeader = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
322 if (!fRunHeader)
323 {
324 *fLog << err << AddSerialNumber("MRawRunHeader") << " not found... aborting." << endl;
325 return kFALSE;
326 }
327
328 fEvtHeader = (MRawEvtHeader*)pList->FindObject(AddSerialNumber("MRawEvtHeader"));
329 if (!fEvtHeader)
330 {
331 *fLog << err << AddSerialNumber("MRawEvtHeader") << " not found... aborting." << endl;
332 return kFALSE;
333 }
334
335 fGeom = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
336 if (!fGeom)
337 {
338 *fLog << err << AddSerialNumber("MGeomCam") << " not found... aborting." << endl;
339 return kFALSE;
340 }
341
342 if (fExtractor && !fPedestalsIn)
343 {
344 fPedestalsIn = (MPedestalCam*)pList->FindObject(AddSerialNumber(fNamePedestalCamIn), "MPedestalCam");
345 if (!fPedestalsIn)
346 {
347 *fLog << err << AddSerialNumber(fNamePedestalCamIn) << " not found... aborting." << endl;
348 return kFALSE;
349 }
350 }
351
352 if (!fPedestalsInter && fIntermediateStorage)
353 {
354 fPedestalsInter = (MPedestalCam*)pList->FindCreateObj("MPedestalCam", AddSerialNumber(fNamePedestalCamInter));
355 if (!fPedestalsInter)
356 return kFALSE;
357 }
358
359 if (!fPedestalsOut)
360 {
361 fPedestalsOut = (MPedestalCam*)pList->FindCreateObj("MPedestalCam", AddSerialNumber(fNamePedestalCamOut));
362 if (!fPedestalsOut)
363 return kFALSE;
364 }
365
366 *fLog << inf;
367 Print();
368
369 return fExtractor ? fExtractor->CallPreProcess(pList) : kTRUE;
370}
371
372Int_t MExtractPedestal::Process()
373{
374 if (fExtractor)
375 fExtractor->SetNoiseCalculation(fRandomCalculation);
376
377 const Int_t rc = Calc();
378
379 if (fExtractor)
380 fExtractor->SetNoiseCalculation(kFALSE);
381
382 return rc;
383}
384
385// ---------------------------------------------------------------------------------
386//
387// Sets the size (from MPedestalCam::GetSize() ) and resets the following arrays:
388// - fSumx
389// - fSumx2
390// - fSumAB0
391// - fSumAB1
392// - fAreaSumx
393// - fAreaSumx2
394// - fAreaSumAB0
395// - fAreaSumAB1
396// - fAreaFilled
397// - fAreaValid
398// - fSectorSumx
399// - fSectorSumx2
400// - fSectorSumAB0
401// - fSectorSumAB1
402// - fSectorFilled
403// - fSectorValid
404//
405Bool_t MExtractPedestal::ReInit(MParList *pList)
406{
407 // If the size is not yet set, set the size
408 if (fSumx.GetSize()==0)
409 {
410 const Int_t npixels = fPedestalsOut->GetSize();
411 const Int_t areas = fPedestalsOut->GetNumAverageArea();
412 const Int_t sectors = fPedestalsOut->GetNumAverageSector();
413
414 fSumx. Set(npixels);
415 fSumx2. Set(npixels);
416 fSumAB0.Set(npixels);
417 fSumAB1.Set(npixels);
418
419 fAreaSumx. Set(areas);
420 fAreaSumx2. Set(areas);
421 fAreaSumAB0.Set(areas);
422 fAreaSumAB1.Set(areas);
423 fAreaFilled.Set(areas);
424 fAreaValid .Set(areas);
425
426 fSectorSumx. Set(sectors);
427 fSectorSumx2. Set(sectors);
428 fSectorSumAB0.Set(sectors);
429 fSectorSumAB1.Set(sectors);
430 fSectorFilled.Set(sectors);
431 fSectorValid .Set(sectors);
432
433 for (Int_t i=0; i<npixels; i++)
434 {
435 const UInt_t aidx = (*fGeom)[i].GetAidx();
436 const UInt_t sector = (*fGeom)[i].GetSector();
437
438 fAreaValid [aidx] ++;
439 fSectorValid[sector]++;
440 }
441 }
442
443 if (fExtractor)
444 {
445 if (!((MTask*)fExtractor)->ReInit(pList))
446 return kFALSE;
447
448 if (!fExtractor->InitArrays())
449 return kFALSE;
450
451 SetExtractWindow(fExtractor->GetHiGainFirst(), (Int_t)TMath::Nint(fExtractor->GetNumHiGainSamples()));
452 }
453
454 return kTRUE;
455}
456
457Int_t MExtractPedestal::PostProcess()
458{
459 fPedestalsIn = NULL;
460 return fExtractor ? fExtractor->CallPostProcess() : kTRUE;
461}
462
463
464// --------------------------------------------------------------------------
465//
466// The following resources are available:
467// ExtractWindowFirst: 15
468// ExtractWindowSize: 6
469// NumEventsDump: 500
470// PedestalUpdate: yes
471// RandomCalculation: yes
472//
473Int_t MExtractPedestal::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
474{
475 Bool_t rc=kFALSE;
476
477 // find resource for numdump
478 if (IsEnvDefined(env, prefix, "NumDump", print))
479 {
480 const Int_t num = GetEnvValue(env, prefix, "NumDump", -1);
481 if (num<=0)
482 {
483 *fLog << err << GetDescriptor() << ": ERROR - NumDump invalid!" << endl;
484 return kERROR;
485 }
486
487 SetNumDump(num);
488 rc = kTRUE;
489 }
490
491 // find resource for numeventsdump
492 if (IsEnvDefined(env, prefix, "NumEventsDump", print))
493 {
494 SetNumEventsDump(GetEnvValue(env, prefix, "NumEventsDump", (Int_t)fNumEventsDump));
495 rc = kTRUE;
496 }
497
498 // find resource for numeventsdump
499 if (IsEnvDefined(env, prefix, "NumAreasDump", print))
500 {
501 SetNumAreasDump(GetEnvValue(env, prefix, "NumAreasDump", (Int_t)fNumAreasDump));
502 rc = kTRUE;
503 }
504
505 // find resource for numeventsdump
506 if (IsEnvDefined(env, prefix, "NumSectorsDump", print))
507 {
508 SetNumSectorsDump(GetEnvValue(env, prefix, "NumSectorsDump", (Int_t)fNumSectorsDump));
509 rc = kTRUE;
510 }
511
512 // find resource for pedestal update
513 if (IsEnvDefined(env, prefix, "PedestalUpdate", print))
514 {
515 SetPedestalUpdate(GetEnvValue(env, prefix, "PedestalUpdate", fPedestalUpdate));
516 rc = kTRUE;
517 }
518
519 if (IsEnvDefined(env, prefix, "IntermediateStorage", print))
520 {
521 SetIntermediateStorage(GetEnvValue(env, prefix, "IntermediateStorage", fIntermediateStorage));
522 rc = kTRUE;
523 }
524
525 // find resource for random calculation
526 if (IsEnvDefined(env, prefix, "RandomCalculation", print))
527 {
528 SetRandomCalculation(GetEnvValue(env, prefix, "RandomCalculation", fRandomCalculation));
529 rc = kTRUE;
530 }
531
532 // Find resources for ExtractWindow
533 Int_t ef = fExtractWinFirst;
534 Int_t es = fExtractWinSize;
535 if (IsEnvDefined(env, prefix, "ExtractWinFirst", print))
536 {
537 ef = GetEnvValue(env, prefix, "ExtractWinFirst", ef);
538 rc = kTRUE;
539 }
540 if (IsEnvDefined(env, prefix, "ExtractWinSize", print))
541 {
542 es = GetEnvValue(env, prefix, "ExtractWinSize", es);
543 rc = kTRUE;
544 }
545
546 SetExtractWindow(ef,es);
547
548 // find resource for MPedestalCam
549 if (IsEnvDefined(env, prefix, "NamePedestalCamIn", print))
550 {
551 SetNamePedestalCamIn(GetEnvValue(env, prefix, "NamePedestalCamIn", fNamePedestalCamIn));
552 rc = kTRUE;
553 }
554
555 if (IsEnvDefined(env, prefix, "NamePedestalCamInter", print))
556 {
557 SetNamePedestalCamInter(GetEnvValue(env, prefix, "NamePedestalCamInter", fNamePedestalCamInter));
558 rc = kTRUE;
559 }
560
561 if (IsEnvDefined(env, prefix, "NamePedestalCamOut", print))
562 {
563 SetNamePedestalCamOut(GetEnvValue(env, prefix, "NamePedestalCamOut", fNamePedestalCamOut));
564 rc = kTRUE;
565 }
566
567 return rc;
568}
569
570// ---------------------------------------------------------------------------------
571//
572// Calculates for pixel "idx":
573//
574// Ped per slice = sum / n / fExtractWinSize;
575// RMS per slice = sqrt { (sum2 - sum*sum/n) / (n-1) / fExtractWinSize }
576// ABOffset per slice = (fSumAB0[idx] - fSumAB1[idx]) / n / fExtractWinSize;
577//
578// Stores the results in MPedestalCam[pixid]
579//
580void MExtractPedestal::CalcPixResults(const UInt_t nevts, const UInt_t pixid)
581{
582 const Float_t sum = fSumx[pixid];
583 const Float_t sum2 = fSumx2[pixid];
584
585 // 1. Calculate the mean of the sums:
586 Float_t ped = sum/nevts;
587
588 // 2. Calculate the Variance of the sums:
589 Float_t var = (sum2-sum*sum/nevts)/(nevts-1.);
590
591 // 3. Calculate the amplitude of the 150MHz "AB" noise
592 Float_t abOffs = (fSumAB0[pixid] - fSumAB1[pixid]) / nevts;
593
594 // 4. Scale the mean, variance and AB-noise to the number of slices:
595 ped /= fExtractor ? fExtractor->GetNumHiGainSamples() : fExtractWinSize;
596 var /= fExtractor ? fExtractor->GetNumHiGainSamples() : fExtractWinSize;
597 abOffs /= fExtractor ? fExtractor->GetNumHiGainSamples() : fExtractWinSize;
598
599 // 5. Calculate the RMS from the Variance:
600 const Float_t rms = var<0 ? 0 : TMath::Sqrt(var);
601
602 (*fPedestalsOut)[pixid].Set(ped, rms, abOffs, nevts);
603}
604
605// ---------------------------------------------------------------------------------
606//
607// Calculates for area idx "aidx" with "napix" valid pixels:
608//
609// Ped per slice = sum / nevts / fExtractWinSize / napix;
610// RMS per slice = sqrt { (sum2 - sum*sum/nevts) / (nevts-1) / fExtractWinSize / napix }
611// ABOffset per slice = (fSumAB0[idx] - fSumAB1[idx]) / nevts / fExtractWinSize / napix;
612//
613// Stores the results in MPedestalCam::GetAverageArea(aidx)
614//
615void MExtractPedestal::CalcAreaResults(const UInt_t nevts, const UInt_t napix, const UInt_t aidx)
616{
617 const Float_t sum = fAreaSumx[aidx];
618 const Float_t sum2 = fAreaSumx2[aidx];
619
620 // 1. Calculate the mean of the sums:
621 Float_t ped = sum/nevts;
622
623 // 2. Calculate the Variance of the sums:
624 Float_t var = (sum2-sum*sum/nevts)/(nevts-1.);
625
626 // 3. Calculate the amplitude of the 150MHz "AB" noise
627 Float_t abOffs = (fAreaSumAB0[aidx] - fAreaSumAB1[aidx]) / nevts;
628
629 // 4. Scale the mean, variance and AB-noise to the number of slices:
630 ped /= fExtractor ? fExtractor->GetNumHiGainSamples() : fExtractWinSize;
631 var /= fExtractor ? fExtractor->GetNumHiGainSamples() : fExtractWinSize;
632 abOffs /= fExtractor ? fExtractor->GetNumHiGainSamples() : fExtractWinSize;
633
634 // 5. Scale the mean, variance and AB-noise to the number of pixels:
635 ped /= napix;
636 var /= napix;
637 abOffs /= napix;
638
639 // 6. Calculate the RMS from the Variance:
640 const Float_t rms = var<0 ? 0 : TMath::Sqrt(var);
641
642 fPedestalsOut->GetAverageArea(aidx).Set(ped, rms, abOffs, nevts);
643}
644
645// ---------------------------------------------------------------------------------
646//
647// Calculates for sector idx "sector" with "nspix" valid pixels:
648//
649// Ped per slice = sum / nevts / fExtractWinSize / nspix;
650// RMS per slice = sqrt { (sum2 - sum*sum/nevts) / (nevts-1) / fExtractWinSize / nspix }
651// ABOffset per slice = (fSumAB0[idx] - fSumAB1[idx]) / nevts / fExtractWinSize / nspix;
652//
653// Stores the results in MPedestalCam::GetAverageSector(sector)
654//
655void MExtractPedestal::CalcSectorResults(const UInt_t nevts, const UInt_t nspix, const UInt_t sector)
656{
657 const Float_t sum = fSectorSumx[sector];
658 const Float_t sum2 = fSectorSumx2[sector];
659
660 // 1. Calculate the mean of the sums:
661 Float_t ped = sum/nevts;
662
663 // 2. Calculate the Variance of the sums:
664 Float_t var = (sum2-sum*sum/nevts)/(nevts-1.);
665
666 // 3. Calculate the amplitude of the 150MHz "AB" noise
667 Float_t abOffs = (fSectorSumAB0[sector] - fSectorSumAB1[sector]) / nevts;
668
669 // 4. Scale the mean, variance and AB-noise to the number of slices:
670 ped /= fExtractor ? fExtractor->GetNumHiGainSamples() : fExtractWinSize;
671 var /= fExtractor ? fExtractor->GetNumHiGainSamples() : fExtractWinSize;
672 abOffs /= fExtractor ? fExtractor->GetNumHiGainSamples() : fExtractWinSize;
673
674 // 5. Scale the mean, variance and AB-noise to the number of pixels:
675 ped /= nspix;
676 var /= nspix;
677 abOffs /= nspix;
678
679 // 6. Calculate the RMS from the Variance:
680 const Float_t rms = var<0 ? 0 : TMath::Sqrt(var);
681
682 fPedestalsOut->GetAverageSector(sector).Set(ped, rms, abOffs, nevts);
683}
684
685void MExtractPedestal::Print(Option_t *o) const
686{
687 *fLog << GetDescriptor() << ":" << endl;
688 *fLog << "Name of input MPedestalCam: " << (fPedestalsIn?fPedestalsIn->GetName():fNamePedestalCamIn.Data()) << " (" << fPedestalsIn << ")" << endl;
689 *fLog << "Name of interm. MPedestalCam: " << (fPedestalsInter?fPedestalsInter->GetName():fNamePedestalCamInter.Data()) << " (" << fPedestalsInter << ")" << endl;
690 *fLog << "Name of output MPedestalCam: " << (fPedestalsOut?fPedestalsOut->GetName():fNamePedestalCamOut.Data()) << " (" << fPedestalsOut << ")" << endl;
691 *fLog << "Intermediate Storage is " << (fIntermediateStorage?"on":"off") << endl;
692 *fLog << "Pedestal Update is " << (fPedestalUpdate?"on":"off") << endl;
693 if (fPedestalUpdate)
694 {
695 *fLog << "Num evts for pedestal calc: " << fNumEventsDump << endl;
696 *fLog << "Num evts for avg.areas calc: " << fNumAreasDump << endl;
697 *fLog << "Num evts for avg.sector calc: " << fNumSectorsDump << endl;
698 }
699 if (fExtractor)
700 {
701 *fLog << "Extractor used: " << fExtractor->ClassName() << " (";
702 *fLog << (fRandomCalculation?"":"non-") << "random)" << endl;
703 }
704}
Note: See TracBrowser for help on using the repository browser.