source: trunk/MagicSoft/Mars/msignal/MExtractor.cc@ 3861

Last change on this file since 3861 was 3861, checked in by gaug, 21 years ago
*** empty log message ***
File size: 5.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): Markus Gaug, 04/2004 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MExtractor
28//
29// Base class for the signal extractors, used the function
30// FindSignal() to extract the signal and substract the pedestal value
31//
32// The following variables have to be set by the derived class and
33// do not have defaults:
34// - fNumHiGainSamples
35// - fNumLoGainSamples
36// - fSqrtHiGainSamples
37// - fSqrtLoGainSamples
38//
39//////////////////////////////////////////////////////////////////////////////
40#include "MExtractor.h"
41
42#include <fstream>
43
44#include "MLog.h"
45#include "MLogManip.h"
46
47#include "MParList.h"
48
49#include "MRawEvtData.h"
50#include "MRawEvtPixelIter.h"
51
52#include "MPedestalCam.h"
53#include "MPedestalPix.h"
54
55#include "MExtractedSignalCam.h"
56#include "MExtractedSignalPix.h"
57
58ClassImp(MExtractor);
59
60using namespace std;
61
62const Byte_t MExtractor::fgSaturationLimit = 254;
63// --------------------------------------------------------------------------
64//
65// Default constructor.
66//
67MExtractor::MExtractor(const char *name, const char *title)
68 : fNumHiGainSamples(0.), fNumLoGainSamples(0.), fSaturationLimit(fgSaturationLimit)
69{
70
71 fName = name ? name : "MExtractor";
72 fTitle = title ? title : "Base class for signal extractors";
73
74 AddToBranchList("MRawEvtData.*");
75
76 SetRange();
77}
78
79void MExtractor::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast)
80{
81
82 fHiGainFirst = hifirst;
83 fLoGainFirst = lofirst;
84
85 fHiGainLast = hilast;
86 fLoGainLast = lolast;
87
88}
89
90// --------------------------------------------------------------------------
91//
92// The PreProcess searches for the following input containers:
93// - MRawEvtData
94// - MPedestalCam
95//
96// The following output containers are also searched and created if
97// they were not found:
98//
99// - MExtractedSignalCam
100//
101Int_t MExtractor::PreProcess(MParList *pList)
102{
103 fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
104 if (!fRawEvt)
105 {
106 *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
107 return kFALSE;
108 }
109
110
111 fSignals = (MExtractedSignalCam*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalCam"));
112 if (!fSignals)
113 return kFALSE;
114
115 fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast, fNumHiGainSamples,
116 fLoGainFirst, fLoGainLast, fNumLoGainSamples);
117
118 fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
119
120 if (!fPedestals)
121 {
122 *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
123 return kFALSE;
124 }
125
126 return kTRUE;
127}
128
129void MExtractor::FindSignalHiGain(Byte_t *ptr, Int_t last, Int_t &sum, Byte_t &sat) const
130{
131 return;
132}
133
134void MExtractor::FindSignalLoGain(Byte_t *ptr, Int_t last, Int_t &sum, Byte_t &sat) const
135{
136 return;
137}
138
139// --------------------------------------------------------------------------
140//
141// Calculate the integral of the FADC time slices and store them as a new
142// pixel in the MExtractedSignalCam container.
143//
144Int_t MExtractor::Process()
145{
146
147 MRawEvtPixelIter pixel(fRawEvt);
148 fSignals->Clear();
149
150 UInt_t sat=0;
151
152 while (pixel.Next())
153 {
154 Int_t sumhi;
155 Byte_t sathi;
156
157 FindSignalHiGain(pixel.GetHiGainSamples()+fHiGainFirst, fHiGainLast, sumhi, sathi);
158
159 Int_t sumlo = 0;
160 Byte_t satlo = 0;
161
162 if (pixel.HasLoGain())
163 {
164 FindSignalLoGain(pixel.GetLoGainSamples()+fLoGainFirst, fLoGainLast, sumlo, satlo);
165
166 if (satlo)
167 sat++;
168 }
169
170 const Int_t pixid = pixel.GetPixelId();
171
172 const MPedestalPix &ped = (*fPedestals)[pixid];
173 MExtractedSignalPix &pix = (*fSignals)[pixid];
174
175 const Float_t pedes = ped.GetPedestal();
176 const Float_t pedrms = ped.GetPedestalRms();
177
178 pix.SetExtractedSignal(sumhi - pedes*fNumHiGainSamples, pedrms*fSqrtHiGainSamples,
179 sumlo - pedes*fNumLoGainSamples, pedrms*fSqrtLoGainSamples);
180
181 pix.SetGainSaturation(sathi, sathi, satlo);
182
183 } /* while (pixel.Next()) */
184
185 fSignals->SetReadyToSave();
186
187 return kTRUE;
188}
189
190// --------------------------------------------------------------------------
191//
192// Implementation of SavePrimitive. Used to write the call to a constructor
193// to a macro. In the original root implementation it is used to write
194// gui elements to a macro-file.
195//
196void MExtractor::StreamPrimitive(ofstream &out) const
197{
198}
199
Note: See TracBrowser for help on using the repository browser.