source: trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc@ 857

Last change on this file since 857 was 857, checked in by tbretz, 23 years ago
*** empty log message ***
File size: 4.1 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): Josep Flix 04/2001 (jflix@ifae.es)
19! Thomas Bretz 05/2001 (tbretz@uni-sw.gwdg.de)
20!
21! Copyright: MAGIC Software Development, 2000-2001
22!
23!
24\* ======================================================================== */
25
26/////////////////////////////////////////////////////////////////////////////
27// //
28// MPedCalcPedRun //
29// //
30// Input Containers: //
31// MRawEvtData //
32// //
33// Output Containers: //
34// MPedestalCam //
35// //
36/////////////////////////////////////////////////////////////////////////////
37
38#include "MPedCalcPedRun.h"
39
40#include "MParList.h"
41
42#include "MLog.h"
43#include "MLogManip.h"
44
45#include "MRawEvtPixelIter.h"
46#include "MRawEvtData.h"
47
48#include "MPedestalPix.h"
49#include "MPedestalCam.h"
50
51ClassImp(MPedCalcPedRun);
52
53MPedCalcPedRun::MPedCalcPedRun(const char *name, const char *title)
54{
55 *fName = name ? name : "MPedCalcPedRun";
56 *fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data";
57}
58
59Bool_t MPedCalcPedRun::PreProcess( MParList *pList )
60{
61 fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
62 if (!fRawEvt)
63 {
64 *fLog << dbginf << "MRawEvtData not found... aborting." << endl;
65 return kFALSE;
66 }
67
68 fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
69 if (!fPedestals)
70 return kFALSE;
71
72 fNumHiGainSamples = fRawEvt->GetNumHiGainSamples();
73
74 return kTRUE;
75}
76
77
78Bool_t MPedCalcPedRun::Process()
79{
80 MRawEvtPixelIter pixel(fRawEvt);
81
82 while (pixel.Next())
83 {
84 Byte_t *ptr = pixel.GetHiGainFadcSamples();
85 const Byte_t *end = ptr + fRawEvt->GetNumHiGainSamples();
86
87 const Float_t higainped = CalcHiGainMean(ptr, end);
88 const Float_t higainrms = CalcHiGainRms(ptr, end, higainped);
89
90 const Float_t higainpederr = CalcHiGainMeanErr(higainrms);
91 const Float_t higainrmserr = CalcHiGainRmsErr(higainrms);
92
93 const UInt_t pixid = pixel.GetPixelId();
94 MPedestalPix &pix = (*fPedestals)[pixid];
95
96 pix.SetPedestal(higainped, higainrms);
97 pix.SetPedestalRms(higainpederr, higainrmserr);
98 }
99
100 fPedestals->SetReadyToSave();
101
102 return kTRUE;
103}
104
105Float_t MPedCalcPedRun::CalcHiGainMean(Byte_t *ptr, const Byte_t *end) const
106{
107 Int_t sum=0;
108
109 do sum += *ptr;
110 while (++ptr != end);
111
112 return (Float_t)sum/fNumHiGainSamples;
113}
114
115
116Float_t MPedCalcPedRun::CalcHiGainRms(Byte_t *ptr, const Byte_t *end, Float_t higainped) const
117{
118 Float_t rms = 0;
119
120 do
121 {
122 const Float_t diff = (Float_t)(*ptr)-higainped;
123
124 rms += diff*diff;
125 } while (++ptr != end);
126
127 return sqrt(rms/(fNumHiGainSamples-1));
128}
129
130Float_t MPedCalcPedRun::CalcHiGainMeanErr(Float_t higainrms) const
131{
132 return higainrms/sqrt(fNumHiGainSamples);
133}
134
135Float_t MPedCalcPedRun::CalcHiGainRmsErr(Float_t higainrms) const
136{
137 return higainrms/sqrt(2.*fNumHiGainSamples);
138}
139
Note: See TracBrowser for help on using the repository browser.