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 |
|
---|
71 | ClassImp(MExtractTimeAndCharge);
|
---|
72 |
|
---|
73 | using namespace std;
|
---|
74 |
|
---|
75 | const Float_t MExtractTimeAndCharge::fgLoGainStartShift = -2.8;
|
---|
76 |
|
---|
77 | // --------------------------------------------------------------------------
|
---|
78 | //
|
---|
79 | // Default constructor.
|
---|
80 | //
|
---|
81 | // Sets:
|
---|
82 | // - fLoGainFirstSave to 0
|
---|
83 | // - fWindowSizeHiGain and fWindowSizeLoGain to 0
|
---|
84 | // - fLoGainStartShift to fgLoGainStartShift+fgOffsetLoGain
|
---|
85 | //
|
---|
86 | MExtractTimeAndCharge::MExtractTimeAndCharge(const char *name, const char *title)
|
---|
87 | : fLoGainFirstSave(0), fWindowSizeHiGain(0), fWindowSizeLoGain(0)
|
---|
88 | {
|
---|
89 | fName = name ? name : "MExtractTimeAndCharge";
|
---|
90 | fTitle = title ? title : "Base class for signal and time extractors";
|
---|
91 |
|
---|
92 | SetLoGainStartShift();
|
---|
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 | // - MExtractedSignalCam
|
---|
106 | // - MArrivalTimeCam
|
---|
107 | //
|
---|
108 | Int_t MExtractTimeAndCharge::PreProcess(MParList *pList)
|
---|
109 | {
|
---|
110 |
|
---|
111 | if (!MExtractTime::PreProcess(pList))
|
---|
112 | return kFALSE;
|
---|
113 |
|
---|
114 | fSignals = (MExtractedSignalCam*)pList->FindCreateObj("MExtractedSignalCam",AddSerialNumber(fNameSignalCam));
|
---|
115 | if (!fSignals)
|
---|
116 | {
|
---|
117 | *fLog << err << fNameSignalCam.Data() << " could not be found nor created... aborting" << endl;
|
---|
118 | return kFALSE;
|
---|
119 | }
|
---|
120 |
|
---|
121 | return kTRUE;
|
---|
122 | }
|
---|
123 |
|
---|
124 | // --------------------------------------------------------------------------
|
---|
125 | //
|
---|
126 | // The ReInit calls:
|
---|
127 | // - MExtractor::ReInit()
|
---|
128 | //
|
---|
129 | // Call:
|
---|
130 | // - MArrivalTimeCam::SetUsedFADCSlices(fHiGainFirst, fHiGainLast, fNumHiGainSamples,
|
---|
131 | // fLoGainFirst, fLoGainLast, fNumLoGainSamples);
|
---|
132 | // - InitArrays();
|
---|
133 | //
|
---|
134 | Bool_t MExtractTimeAndCharge::ReInit(MParList *pList)
|
---|
135 | {
|
---|
136 |
|
---|
137 | if (!MExtractTime::ReInit(pList))
|
---|
138 | return kFALSE;
|
---|
139 |
|
---|
140 | if (fSignals)
|
---|
141 | fSignals->SetUsedFADCSlices(fHiGainFirst, fHiGainLast+fHiLoLast, fNumHiGainSamples,
|
---|
142 | fLoGainFirst, fLoGainLast, fNumLoGainSamples);
|
---|
143 |
|
---|
144 |
|
---|
145 | if (!InitArrays())
|
---|
146 | return kFALSE;
|
---|
147 |
|
---|
148 | Print();
|
---|
149 |
|
---|
150 | return kTRUE;
|
---|
151 | }
|
---|
152 |
|
---|
153 | // --------------------------------------------------------------------------
|
---|
154 | //
|
---|
155 | // Calculate the integral of the FADC time slices and store them as a new
|
---|
156 | // pixel in the MArrivalTimeCam container.
|
---|
157 | // Calculate the integral of the FADC time slices and store them as a new
|
---|
158 | // pixel in the MExtractedSignalCam container.
|
---|
159 | // The functions FindTimeAndChargeHiGain() and FindTimeAndChargeLoGain are
|
---|
160 | // supposed to extract the signal themselves.
|
---|
161 | //
|
---|
162 | Int_t MExtractTimeAndCharge::Process()
|
---|
163 | {
|
---|
164 |
|
---|
165 | MRawEvtPixelIter pixel(fRawEvt);
|
---|
166 | fArrTime->Clear();
|
---|
167 | fSignals->Clear();
|
---|
168 |
|
---|
169 | while (pixel.Next())
|
---|
170 | {
|
---|
171 | //
|
---|
172 | // Find signal in hi- and lo-gain
|
---|
173 | //
|
---|
174 | Float_t sumhi =0., deltasumhi =0.;
|
---|
175 | Float_t timehi=0., deltatimehi=0.;
|
---|
176 | Byte_t sathi=0;
|
---|
177 |
|
---|
178 | const Int_t pixid = pixel.GetPixelId();
|
---|
179 | const MPedestalPix &ped = (*fPedestals)[pixid];
|
---|
180 | const Bool_t higainabflag = pixel.HasABFlag();
|
---|
181 |
|
---|
182 | FindTimeAndChargeHiGain(pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(),
|
---|
183 | sumhi, deltasumhi,
|
---|
184 | timehi, deltatimehi,
|
---|
185 | sathi, ped, higainabflag);
|
---|
186 |
|
---|
187 | Float_t sumlo =0., deltasumlo =0.;
|
---|
188 | Float_t timelo=0., deltatimelo=0.;
|
---|
189 | Byte_t satlo=0;
|
---|
190 |
|
---|
191 | //
|
---|
192 | // Adapt the low-gain extraction range from the obtained high-gain time
|
---|
193 | //
|
---|
194 | if (pixel.HasLoGain())
|
---|
195 | {
|
---|
196 | fLoGainFirstSave = (Int_t)fLoGainFirst;
|
---|
197 | const Int_t logainstart = (Int_t)(timehi+fLoGainStartShift);
|
---|
198 | fLoGainFirst = logainstart > fLoGainFirstSave ? logainstart : fLoGainFirstSave;
|
---|
199 |
|
---|
200 | if ( fLoGainFirst < fLoGainLast )
|
---|
201 | {
|
---|
202 | const Bool_t logainabflag = (higainabflag + pixel.GetNumHiGainSamples()) & 0x1;
|
---|
203 | FindTimeAndChargeLoGain(pixel.GetLoGainSamples()+fLoGainFirst,
|
---|
204 | sumlo, deltasumlo,
|
---|
205 | timelo, deltatimelo,
|
---|
206 | satlo, ped, logainabflag);
|
---|
207 | }
|
---|
208 |
|
---|
209 | fLoGainFirst = fLoGainFirstSave;
|
---|
210 | }
|
---|
211 |
|
---|
212 | MExtractedSignalPix &pix = (*fSignals)[pixid];
|
---|
213 | MArrivalTimePix &tix = (*fArrTime)[pixid];
|
---|
214 |
|
---|
215 | pix.SetExtractedSignal(sumhi, deltasumhi,sumlo, deltasumlo);
|
---|
216 | pix.SetGainSaturation(sathi, sathi, satlo);
|
---|
217 |
|
---|
218 | tix.SetArrivalTime(timehi, deltatimehi, timelo-fOffsetLoGain, deltatimelo);
|
---|
219 | tix.SetGainSaturation(sathi, sathi, satlo);
|
---|
220 |
|
---|
221 | } /* while (pixel.Next()) */
|
---|
222 |
|
---|
223 | fArrTime->SetReadyToSave();
|
---|
224 | fSignals->SetReadyToSave();
|
---|
225 |
|
---|
226 | return kTRUE;
|
---|
227 | }
|
---|
228 |
|
---|
229 | // --------------------------------------------------------------------------
|
---|
230 | //
|
---|
231 | // In addition to the resources of the base-class MExtractor:
|
---|
232 | // MJPedestal.MExtractor.LoGainStartShift: -2.8
|
---|
233 | //
|
---|
234 | Int_t MExtractTimeAndCharge::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
|
---|
235 | {
|
---|
236 | Bool_t rc = kFALSE;
|
---|
237 |
|
---|
238 | if (IsEnvDefined(env, prefix, "LoGainStartShift", print))
|
---|
239 | {
|
---|
240 | fLoGainStartShift = GetEnvValue(env, prefix, "LoGainStartShift", fLoGainStartShift);
|
---|
241 | rc = kTRUE;
|
---|
242 | }
|
---|
243 |
|
---|
244 |
|
---|
245 | return MExtractTime::ReadEnv(env, prefix, print) ? kTRUE : rc;
|
---|
246 | }
|
---|
247 |
|
---|
248 | void MExtractTimeAndCharge::Print(Option_t *o) const
|
---|
249 | {
|
---|
250 |
|
---|
251 | *fLog << all;
|
---|
252 | if (IsA()==MExtractTimeAndCharge::Class())
|
---|
253 | *fLog << GetDescriptor() << ":" << endl;
|
---|
254 |
|
---|
255 | *fLog << dec << endl;
|
---|
256 | *fLog << inf << "Taking " << fNumHiGainSamples
|
---|
257 | << " HiGain samples from slice " << (Int_t)fHiGainFirst
|
---|
258 | << " to " << (Int_t)(fHiGainLast+fHiLoLast) << " incl" << endl;
|
---|
259 | *fLog << inf << "Taking " << fNumLoGainSamples
|
---|
260 | << " LoGain samples from slice " << (Int_t)fLoGainFirst
|
---|
261 | << " to " << (Int_t)fLoGainLast << " incl" << endl;
|
---|
262 |
|
---|
263 | *fLog << " LoGainStartShift: " << fLoGainStartShift << endl;
|
---|
264 | MExtractTime::Print(o);
|
---|
265 | }
|
---|