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

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