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

Last change on this file since 2409 was 2237, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.3 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 <mailto:jflix@ifae.es>
19! Author(s): Thomas Bretz 05/2001 <mailto: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
53using namespace std;
54
55MPedCalcPedRun::MPedCalcPedRun(const char *name, const char *title)
56{
57 fName = name ? name : "MPedCalcPedRun";
58 fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data";
59
60 AddToBranchList("fHiGainPixId");
61 //AddToBranchList("fLoGainPixId");
62 AddToBranchList("fHiGainFadcSamples");
63 //AddToBranchList("fLoGainFadcSamples");
64}
65
66Int_t MPedCalcPedRun::PreProcess( MParList *pList )
67{
68 fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");
69 if (!fRawEvt)
70 {
71 *fLog << dbginf << "MRawEvtData not found... aborting." << endl;
72 return kFALSE;
73 }
74
75 fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam");
76 if (!fPedestals)
77 return kFALSE;
78
79 fNumHiGainSamples = fRawEvt->GetNumHiGainSamples();
80
81 return kTRUE;
82}
83
84
85Int_t MPedCalcPedRun::Process()
86{
87 MRawEvtPixelIter pixel(fRawEvt);
88
89 while (pixel.Next())
90 {
91 Byte_t *ptr = pixel.GetHiGainSamples();
92 const Byte_t *end = ptr + fRawEvt->GetNumHiGainSamples();
93
94 const Float_t higainped = CalcHiGainMean(ptr, end);
95 const Float_t higainrms = CalcHiGainRms(ptr, end, higainped);
96
97 //const Float_t higainpederr = CalcHiGainMeanErr(higainrms);
98 //const Float_t higainrmserr = CalcHiGainRmsErr(higainrms);
99
100 const UInt_t pixid = pixel.GetPixelId();
101 MPedestalPix &pix = (*fPedestals)[pixid];
102
103 pix.Set(higainped, higainrms);
104 //pix.SetPedestalRms(higainpederr, higainrmserr);
105 }
106
107 fPedestals->SetReadyToSave();
108
109 return kTRUE;
110}
111
112Float_t MPedCalcPedRun::CalcHiGainMean(Byte_t *ptr, const Byte_t *end) const
113{
114 Int_t sum=0;
115
116 do sum += *ptr;
117 while (++ptr != end);
118
119 return (Float_t)sum/fNumHiGainSamples;
120}
121
122
123Float_t MPedCalcPedRun::CalcHiGainRms(Byte_t *ptr, const Byte_t *end, Float_t higainped) const
124{
125 Float_t rms = 0;
126
127 do
128 {
129 const Float_t diff = (Float_t)(*ptr)-higainped;
130
131 rms += diff*diff;
132 } while (++ptr != end);
133
134 return sqrt(rms/fNumHiGainSamples);
135}
136/*
137Float_t MPedCalcPedRun::CalcHiGainMeanErr(Float_t higainrms) const
138{
139 return higainrms/sqrt((float)fNumHiGainSamples);
140}
141
142Float_t MPedCalcPedRun::CalcHiGainRmsErr(Float_t higainrms) const
143{
144 return higainrms/sqrt(2.*fNumHiGainSamples);
145}
146*/
Note: See TracBrowser for help on using the repository browser.