source: trunk/MagicSoft/Mars/msignal/MExtractTimeAndCharge.cc@ 5193

Last change on this file since 5193 was 5193, checked in by gaug, 20 years ago
*** empty log message ***
File size: 6.1 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, 05/2004 <mailto:markus@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MExtractTimeAndCharge
28//
29// Base class for the signal extractors which extract the arrival time
30// and the signal at the same time. Uses the functions
31// FindTimeAndChargeHiGain() and FindTimeAndChargeLoGain() to extract the signal and
32// substract the pedestal value
33//
34// The following variables have to be set by the derived class and
35// do not have defaults:
36// - fNumHiGainSamples
37// - fNumLoGainSamples
38// - fSqrtHiGainSamples
39// - fSqrtLoGainSamples
40//
41// Input Containers:
42// MRawEvtData
43// MRawRunHeader
44// MPedestalCam
45//
46// Output Containers:
47// MArrivalTimeCam
48// MExtractedSignalCam
49//
50//////////////////////////////////////////////////////////////////////////////
51#include "MExtractTimeAndCharge.h"
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
68#include "MExtractedSignalCam.h"
69#include "MExtractedSignalPix.h"
70
71ClassImp(MExtractTimeAndCharge);
72
73using namespace std;
74
75// --------------------------------------------------------------------------
76//
77// The PreProcess searches for the following input containers:
78// - MRawEvtData
79// - MRawRunHeader
80// - MPedestalCam
81//
82// The following output containers are also searched and created if
83// they were not found:
84//
85// - MExtractedSignalCam
86// - MArrivalTimeCam
87//
88Int_t MExtractTimeAndCharge::PreProcess(MParList *pList)
89{
90
91 if (!MExtractTime::PreProcess(pList))
92 return kFALSE;
93
94 fSignals = (MExtractedSignalCam*)pList->FindCreateObj(AddSerialNumber("MExtractedSignalCam"));
95 if (!fSignals)
96 {
97 *fLog << err << GetDescriptor()
98 << ": Could not find nor create MExtractedSignalCam,... aborting." << endl;
99 return kFALSE;
100 }
101
102
103 return kTRUE;
104}
105
106// --------------------------------------------------------------------------
107//
108// The ReInit calls:
109// - MExtractor::ReInit()
110//
111// Call:
112// - MArrivalTimeCam::SetUsedFADCSlices(fHiGainFirst, fHiGainLast, fNumHiGainSamples,
113// fLoGainFirst, fLoGainLast, fNumLoGainSamples);
114//
115Bool_t MExtractTimeAndCharge::ReInit(MParList *pList)
116{
117
118 MExtractTime::ReInit(pList);
119
120 fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast+fHiLoLast, fNumHiGainSamples,
121 fLoGainFirst, fLoGainLast, fNumLoGainSamples);
122
123 return kTRUE;
124}
125
126void MExtractTimeAndCharge::FindTimeAndChargeHiGain(Byte_t *firstused, Byte_t *logain, Float_t &sum, Float_t &dsum,
127 Float_t &time, Float_t &dtime,
128 Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag)
129{
130 return;
131}
132
133void MExtractTimeAndCharge::FindTimeAndChargeLoGain(Byte_t *firstused, Float_t &sum, Float_t &dsum,
134 Float_t &time, Float_t &dtime,
135 Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag)
136{
137 return;
138}
139
140
141// --------------------------------------------------------------------------
142//
143// Calculate the integral of the FADC time slices and store them as a new
144// pixel in the MArrivalTimeCam container.
145// Calculate the integral of the FADC time slices and store them as a new
146// pixel in the MExtractedSignalCam container.
147// The functions FindTimeAndChargeHiGain() and FindTimeAndChargeLoGain are
148// supposed to extract the signal themselves.
149//
150Int_t MExtractTimeAndCharge::Process()
151{
152
153 MRawEvtPixelIter pixel(fRawEvt);
154 fArrTime->Clear();
155 fSignals->Clear();
156
157 while (pixel.Next())
158 {
159 //
160 // Find signal in hi- and lo-gain
161 //
162 Float_t sumhi =0., deltasumhi =0.;
163 Float_t timehi=0., deltatimehi=0.;
164 Byte_t sathi=0;
165
166 const Int_t pixid = pixel.GetPixelId();
167 const MPedestalPix &ped = (*fPedestals)[pixid];
168 const Bool_t higainabflag = pixel.HasABFlag();
169
170 FindTimeAndChargeHiGain(pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(),
171 sumhi, deltasumhi,
172 timehi, deltatimehi,
173 sathi, ped, higainabflag);
174
175 Float_t sumlo =0., deltasumlo =0.;
176 Float_t timelo=0., deltatimelo=0.;
177 Byte_t satlo=0;
178
179 const Int_t logainflag = higainabflag + pixel.GetNumHiGainSamples();
180
181 FindTimeAndChargeLoGain(pixel.GetLoGainSamples()+fLoGainFirst,
182 sumlo, deltasumlo,
183 timelo, deltatimelo,
184 satlo, ped, logainflag & 0x1);
185
186 MExtractedSignalPix &pix = (*fSignals)[pixid];
187 MArrivalTimePix &tix = (*fArrTime)[pixid];
188
189 pix.SetExtractedSignal(sumhi, deltasumhi,sumlo, deltasumlo);
190 pix.SetGainSaturation(sathi, sathi, satlo);
191
192 tix.SetArrivalTime(timehi, deltatimehi, timelo-fOffsetLoGain, deltatimelo);
193 tix.SetGainSaturation(sathi, sathi, satlo);
194
195 } /* while (pixel.Next()) */
196
197 fArrTime->SetReadyToSave();
198 fSignals->SetReadyToSave();
199
200 return kTRUE;
201}
202
Note: See TracBrowser for help on using the repository browser.