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 | // --------------------------------------------------------------------------
|
---|
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 | //
|
---|
88 | Int_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 | //
|
---|
115 | Bool_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 | *fLog << endl;
|
---|
124 | *fLog << inf << GetDescriptor() << ": Taking " << fNumHiGainSamples
|
---|
125 | << " HiGain samples from slice " << (Int_t)fHiGainFirst
|
---|
126 | << " to " << (Int_t)(fHiGainLast+fHiLoLast) << " incl" << endl;
|
---|
127 | *fLog << inf << GetDescriptor() << ": Taking " << fNumLoGainSamples
|
---|
128 | << " LoGain samples from slice " << (Int_t)fLoGainFirst
|
---|
129 | << " to " << (Int_t)fLoGainLast << " incl" << endl;
|
---|
130 |
|
---|
131 | return kTRUE;
|
---|
132 | }
|
---|
133 |
|
---|
134 | void MExtractTimeAndCharge::FindTimeAndChargeHiGain(Byte_t *firstused, Byte_t *logain, Float_t &sum, Float_t &dsum,
|
---|
135 | Float_t &time, Float_t &dtime,
|
---|
136 | Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag)
|
---|
137 | {
|
---|
138 | return;
|
---|
139 | }
|
---|
140 |
|
---|
141 | void MExtractTimeAndCharge::FindTimeAndChargeLoGain(Byte_t *firstused, Float_t &sum, Float_t &dsum,
|
---|
142 | Float_t &time, Float_t &dtime,
|
---|
143 | Byte_t &sat, const MPedestalPix &ped, const Bool_t abflag)
|
---|
144 | {
|
---|
145 | return;
|
---|
146 | }
|
---|
147 |
|
---|
148 |
|
---|
149 | // --------------------------------------------------------------------------
|
---|
150 | //
|
---|
151 | // Calculate the integral of the FADC time slices and store them as a new
|
---|
152 | // pixel in the MArrivalTimeCam container.
|
---|
153 | // Calculate the integral of the FADC time slices and store them as a new
|
---|
154 | // pixel in the MExtractedSignalCam container.
|
---|
155 | // The functions FindTimeAndChargeHiGain() and FindTimeAndChargeLoGain are
|
---|
156 | // supposed to extract the signal themselves.
|
---|
157 | //
|
---|
158 | Int_t MExtractTimeAndCharge::Process()
|
---|
159 | {
|
---|
160 |
|
---|
161 | MRawEvtPixelIter pixel(fRawEvt);
|
---|
162 | fArrTime->Clear();
|
---|
163 | fSignals->Clear();
|
---|
164 |
|
---|
165 | while (pixel.Next())
|
---|
166 | {
|
---|
167 | //
|
---|
168 | // Find signal in hi- and lo-gain
|
---|
169 | //
|
---|
170 | Float_t sumhi =0., deltasumhi =0.;
|
---|
171 | Float_t timehi=0., deltatimehi=0.;
|
---|
172 | Byte_t sathi=0;
|
---|
173 |
|
---|
174 | const Int_t pixid = pixel.GetPixelId();
|
---|
175 | const MPedestalPix &ped = (*fPedestals)[pixid];
|
---|
176 | const Bool_t higainabflag = pixel.HasABFlag();
|
---|
177 |
|
---|
178 | FindTimeAndChargeHiGain(pixel.GetHiGainSamples()+fHiGainFirst, pixel.GetLoGainSamples(),
|
---|
179 | sumhi, deltasumhi,
|
---|
180 | timehi, deltatimehi,
|
---|
181 | sathi, ped, higainabflag);
|
---|
182 |
|
---|
183 | Float_t sumlo =0., deltasumlo =0.;
|
---|
184 | Float_t timelo=0., deltatimelo=0.;
|
---|
185 | Byte_t satlo=0;
|
---|
186 |
|
---|
187 | const Bool_t logainabflag = (higainabflag + pixel.GetNumHiGainSamples() + 1) & 0x1;
|
---|
188 |
|
---|
189 | FindTimeAndChargeLoGain(pixel.GetLoGainSamples()+fLoGainFirst,
|
---|
190 | sumlo, deltasumlo,
|
---|
191 | timelo, deltatimelo,
|
---|
192 | satlo, ped, logainabflag);
|
---|
193 |
|
---|
194 | MExtractedSignalPix &pix = (*fSignals)[pixid];
|
---|
195 | MArrivalTimePix &tix = (*fArrTime)[pixid];
|
---|
196 |
|
---|
197 | pix.SetExtractedSignal(sumhi, deltasumhi,sumlo, deltasumlo);
|
---|
198 | pix.SetGainSaturation(sathi, sathi, satlo);
|
---|
199 |
|
---|
200 | tix.SetArrivalTime(timehi, deltatimehi, timelo-fOffsetLoGain, deltatimelo);
|
---|
201 | tix.SetGainSaturation(sathi, sathi, satlo);
|
---|
202 |
|
---|
203 | } /* while (pixel.Next()) */
|
---|
204 |
|
---|
205 | fArrTime->SetReadyToSave();
|
---|
206 | fSignals->SetReadyToSave();
|
---|
207 |
|
---|
208 | return kTRUE;
|
---|
209 | }
|
---|
210 |
|
---|