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

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