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