source: trunk/MagicSoft/Mars/msignal/MExtractTime.cc@ 5359

Last change on this file since 5359 was 5307, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 5.8 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// MExtractTime
28//
29// Base class for the signal extractors, used the functions
30// FindTimeHiGain() and FindTimeLoGain() 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// MRawRunHeader
43// MPedestalCam
44//
45// Output Containers:
46// MArrivalTimeCam
47//
48//////////////////////////////////////////////////////////////////////////////
49#include "MExtractTime.h"
50
51#include <fstream>
52
53#include "MLog.h"
54#include "MLogManip.h"
55
56#include "MParList.h"
57
58#include "MRawEvtData.h"
59#include "MRawEvtPixelIter.h"
60#include "MRawRunHeader.h"
61
62#include "MPedestalCam.h"
63#include "MPedestalPix.h"
64
65#include "MArrivalTimeCam.h"
66#include "MArrivalTimePix.h"
67
68ClassImp(MExtractTime);
69
70using namespace std;
71
72// --------------------------------------------------------------------------
73//
74// Default constructor.
75//
76// Set:
77// - all pointers to NULL
78// - all variables to 0
79// - fSaturationLimit to fgSaturationLimit
80//
81// Call:
82// - AddToBranchList("MRawEvtData.*")
83//
84MExtractTime::MExtractTime(const char *name, const char *title)
85 : fArrTime(NULL)
86{
87
88 fName = name ? name : "MExtractTime";
89 fTitle = title ? title : "Base class for signal extractors";
90
91}
92
93
94
95// --------------------------------------------------------------------------
96//
97// The PreProcess searches for the following input containers:
98// - MRawEvtData
99// - MRawRunHeader
100// - MPedestalCam
101//
102// The following output containers are also searched and created if
103// they were not found:
104//
105// - MArrivalTimeCam
106//
107Int_t MExtractTime::PreProcess(MParList *pList)
108{
109 fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
110 if (!fRawEvt)
111 {
112 *fLog << err << AddSerialNumber("MRawEvtData") << " not found... aborting." << endl;
113 return kFALSE;
114 }
115
116 fRunHeader = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
117 if (!fRunHeader)
118 {
119 *fLog << err << AddSerialNumber("MRawRunHeader") << " not found... aborting." << endl;
120 return kFALSE;
121 }
122
123
124 fArrTime = (MArrivalTimeCam*)pList->FindCreateObj(AddSerialNumber("MArrivalTimeCam"));
125 if (!fArrTime)
126 return kFALSE;
127
128
129 fPedestals = (MPedestalCam*)pList->FindObject( AddSerialNumber(fNamePedestalCam), "MPedestalCam");
130 if (!fPedestals)
131 {
132 *fLog << err << AddSerialNumber("MPedestalCam") << " not found... aborting" << endl;
133 return kFALSE;
134 }
135
136 return kTRUE;
137}
138
139// --------------------------------------------------------------------------
140//
141// The ReInit calls:
142// - MExtractor::ReInit()
143//
144// Call:
145// - MArrivalTimeCam::SetUsedFADCSlices(fHiGainFirst, fHiGainLast, fNumHiGainSamples,
146// fLoGainFirst, fLoGainLast, fNumLoGainSamples);
147//
148Bool_t MExtractTime::ReInit(MParList *pList)
149{
150 if (!MExtractor::ReInit(pList))
151 return kFALSE;
152
153 fArrTime->SetUsedFADCSlices(fHiGainFirst, fHiGainLast+fHiLoLast, fLoGainFirst, fLoGainLast);
154
155 return kTRUE;
156}
157
158void MExtractTime::FindTimeHiGain(Byte_t *firstused, Float_t &time, Float_t &dtime,
159 Byte_t &sat, const MPedestalPix &ped) const
160{
161 return;
162}
163
164void MExtractTime::FindTimeLoGain(Byte_t *firstused, Float_t &time, Float_t &dtime,
165 Byte_t &sat, const MPedestalPix &ped) const
166{
167 return;
168}
169
170// --------------------------------------------------------------------------
171//
172// Calculate the integral of the FADC time slices and store them as a new
173// pixel in the MArrivalTimeCam container.
174//
175Int_t MExtractTime::Process()
176{
177
178
179 MRawEvtPixelIter pixel(fRawEvt);
180 fArrTime->Clear();
181
182 while (pixel.Next())
183 {
184 //
185 // Find signal in hi- and lo-gain
186 //
187 Float_t timehi=0., deltatimehi=0.;
188 Byte_t sathi=0;
189
190 const Int_t pixid = pixel.GetPixelId();
191 const MPedestalPix &ped = (*fPedestals)[pixid];
192 MArrivalTimePix &pix = (*fArrTime)[pixid];
193
194 FindTimeHiGain(pixel.GetHiGainSamples()+fHiGainFirst, timehi, deltatimehi, sathi, ped);
195
196 Float_t timelo=0., deltatimelo=0.;
197 Byte_t satlo=0;
198
199 if ((sathi)&&pixel.HasLoGain())
200 FindTimeLoGain(pixel.GetLoGainSamples()+fLoGainFirst, timelo, deltatimelo, satlo, ped);
201
202 pix.SetArrivalTime(timehi, deltatimehi, timelo-fOffsetLoGain, deltatimelo);
203 pix.SetGainSaturation(sathi, sathi, satlo);
204
205 } /* while (pixel.Next()) */
206
207 fArrTime->SetReadyToSave();
208
209 return kTRUE;
210}
211
212void MExtractTime::Print(Option_t *o) const
213{
214 *fLog << all;
215 if (IsA()==MExtractTime::Class())
216 *fLog << GetDescriptor() << ":" << endl;
217 *fLog << " Offset Lo-Gain: " << fOffsetLoGain << endl;
218 MExtractor::Print(o);
219}
Note: See TracBrowser for help on using the repository browser.