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