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

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