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 | ! Author(s): Markus Gaug 04/2004 <mailto:markus@ifae.es>
|
---|
18 | !
|
---|
19 | ! Copyright: MAGIC Software Development, 2002-2004
|
---|
20 | !
|
---|
21 | !
|
---|
22 | \* ======================================================================== */
|
---|
23 |
|
---|
24 | //////////////////////////////////////////////////////////////////////////////
|
---|
25 | //
|
---|
26 | // MTimeExtractor
|
---|
27 | //
|
---|
28 | // Base class for the time extractor, see also MExtractor
|
---|
29 | //
|
---|
30 | // Input Containers:
|
---|
31 | // MPedestalCam
|
---|
32 | //
|
---|
33 | // Output Containers:
|
---|
34 | // MArrivalTime
|
---|
35 | //
|
---|
36 | //////////////////////////////////////////////////////////////////////////////
|
---|
37 | #include "MTimeExtractor.h"
|
---|
38 |
|
---|
39 | #include "MParList.h"
|
---|
40 |
|
---|
41 | #include "MLog.h"
|
---|
42 | #include "MLogManip.h"
|
---|
43 |
|
---|
44 | #include "MRawRunHeader.h"
|
---|
45 | #include "MRawEvtPixelIter.h"
|
---|
46 |
|
---|
47 | #include "MArrivalTimeCam.h"
|
---|
48 | #include "MArrivalTimePix.h"
|
---|
49 |
|
---|
50 | #include "MPedestalCam.h"
|
---|
51 |
|
---|
52 | ClassImp(MTimeExtractor);
|
---|
53 |
|
---|
54 | using namespace std;
|
---|
55 | // --------------------------------------------------------------------------
|
---|
56 | //
|
---|
57 | // Default constructor.
|
---|
58 | //
|
---|
59 | // Set:
|
---|
60 | // - all pointers to NULL
|
---|
61 | //
|
---|
62 | MTimeExtractor::MTimeExtractor(const char *name, const char *title)
|
---|
63 | : fArrTime(NULL)
|
---|
64 | {
|
---|
65 |
|
---|
66 | fName = name ? name : "MTimeExtractor";
|
---|
67 | fTitle = title ? title : "Base class for arrival time extractors";
|
---|
68 |
|
---|
69 | }
|
---|
70 |
|
---|
71 |
|
---|
72 | // --------------------------------------------------------------------------
|
---|
73 | //
|
---|
74 | // The PreProcess searches for the following input containers:
|
---|
75 | // - MRawEvtData
|
---|
76 | // - MRawRunHeader
|
---|
77 | // - MPedestalCam
|
---|
78 | //
|
---|
79 | // The following output containers are also searched and created if
|
---|
80 | // they were not found:
|
---|
81 | //
|
---|
82 | // - MArrivalTimeCam
|
---|
83 | //
|
---|
84 | Int_t MTimeExtractor::PreProcess(MParList *pList)
|
---|
85 | {
|
---|
86 |
|
---|
87 | fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData"));
|
---|
88 | if (!fRawEvt)
|
---|
89 | {
|
---|
90 | *fLog << err << "MRawEvtData not found... aborting." << endl;
|
---|
91 | return kFALSE;
|
---|
92 | }
|
---|
93 |
|
---|
94 | fRunHeader = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
|
---|
95 | if (!fRunHeader)
|
---|
96 | {
|
---|
97 | *fLog << err << AddSerialNumber("MRawRunHeader") << " not found... aborting." << endl;
|
---|
98 | return kFALSE;
|
---|
99 | }
|
---|
100 |
|
---|
101 | fPedestals = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
|
---|
102 | if (!fPedestals)
|
---|
103 | {
|
---|
104 | *fLog << warn << GetDescriptor()
|
---|
105 | << ": MPedestalCam not found, calculate times without pedestal information..." << endl;
|
---|
106 | }
|
---|
107 |
|
---|
108 |
|
---|
109 | fArrTime = (MArrivalTimeCam*)pList->FindCreateObj(AddSerialNumber("MArrivalTimeCam"));
|
---|
110 | if (!fArrTime)
|
---|
111 | {
|
---|
112 | *fLog << err << GetDescriptor()
|
---|
113 | << ": Cannot create MArrivalTimeCam... abort" << endl;
|
---|
114 | return kFALSE;
|
---|
115 | }
|
---|
116 |
|
---|
117 | return kTRUE;
|
---|
118 | }
|
---|
119 |
|
---|
120 | // --------------------------------------------------------------------------
|
---|
121 | //
|
---|
122 | // The ReInit searches for:
|
---|
123 | // - MRawRunHeader::GetNumSamplesHiGain()
|
---|
124 | // - MRawRunHeader::GetNumSamplesLoGain()
|
---|
125 | //
|
---|
126 | // In case that the variables fHiGainLast and fLoGainLast are smaller than
|
---|
127 | // the even part of the number of samples obtained from the run header, a
|
---|
128 | // warning is given an the range is set back accordingly. A call to:
|
---|
129 | // - SetRange(fHiGainFirst, fHiGainLast-diff, fLoGainFirst, fLoGainLast) or
|
---|
130 | // - SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast-diff)
|
---|
131 | // is performed in that case. The variable diff means here the difference
|
---|
132 | // between the requested range (fHiGainLast) and the available one. Note that
|
---|
133 | // the functions SetRange() are mostly overloaded and perform more checks,
|
---|
134 | // modifying the ranges again, if necessary.
|
---|
135 | //
|
---|
136 | // Call:
|
---|
137 | // - MArrivalTimeCam::SetUsedFADCSlices(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast);
|
---|
138 | //
|
---|
139 | Bool_t MTimeExtractor::ReInit(MParList *pList)
|
---|
140 | {
|
---|
141 |
|
---|
142 | Int_t lastdesired = (Int_t)fHiGainLast;
|
---|
143 | Int_t lastavailable = (Int_t)fRunHeader->GetNumSamplesHiGain()-1;
|
---|
144 |
|
---|
145 | if (lastdesired > lastavailable)
|
---|
146 | {
|
---|
147 | const Int_t diff = lastdesired - lastavailable;
|
---|
148 | *fLog << endl;
|
---|
149 | *fLog << warn << GetDescriptor()
|
---|
150 | << Form("%s%2i%s%2i%s%2i%s",": Selected Hi Gain FADC Window [",
|
---|
151 | (int)fHiGainFirst,",",lastdesired,
|
---|
152 | "] ranges out of the available limits: [0,",lastavailable,"].") << endl;
|
---|
153 | *fLog << GetDescriptor() << ": Will reduce the upper edge to " << (int)(fHiGainLast - diff) << endl;
|
---|
154 | SetRange(fHiGainFirst, fHiGainLast-diff, fLoGainFirst, fLoGainLast);
|
---|
155 | }
|
---|
156 |
|
---|
157 | lastdesired = (Int_t)(fLoGainLast);
|
---|
158 | lastavailable = (Int_t)fRunHeader->GetNumSamplesLoGain()-1;
|
---|
159 |
|
---|
160 | if (lastdesired > lastavailable)
|
---|
161 | {
|
---|
162 | const Int_t diff = lastdesired - lastavailable;
|
---|
163 | *fLog << endl;
|
---|
164 | *fLog << warn << GetDescriptor()
|
---|
165 | << Form("%s%2i%s%2i%s%2i%s",": Selected Lo Gain FADC Window [",
|
---|
166 | (int)fLoGainFirst,",",lastdesired,
|
---|
167 | "] ranges out of the available limits: [0,",lastavailable,"].") << endl;
|
---|
168 | *fLog << GetDescriptor() << ": Will reduce the upper edge to " << (int)(fLoGainLast - diff) << endl;
|
---|
169 | SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast-diff);
|
---|
170 | }
|
---|
171 |
|
---|
172 | fArrTime->SetUsedFADCSlices(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast);
|
---|
173 |
|
---|
174 | return kTRUE;
|
---|
175 | }
|
---|
176 |
|
---|
177 |
|
---|
178 | void MTimeExtractor::FindTimeHiGain(Byte_t *firstused, Float_t &time, Float_t &dtime,
|
---|
179 | Byte_t &sat, const MPedestalPix &ped) const
|
---|
180 | {
|
---|
181 | return;
|
---|
182 | }
|
---|
183 |
|
---|
184 | void MTimeExtractor::FindTimeLoGain(Byte_t *firstused, Float_t &time, Float_t &dtime,
|
---|
185 | Byte_t &sat, const MPedestalPix &ped) const
|
---|
186 | {
|
---|
187 | return;
|
---|
188 | }
|
---|
189 |
|
---|
190 |
|
---|
191 | // --------------------------------------------------------------------------
|
---|
192 | //
|
---|
193 | // Evaluation of the mean arrival times
|
---|
194 | // per pixel and store them in the MArrivalTime container.
|
---|
195 | //
|
---|
196 | Int_t MTimeExtractor::Process()
|
---|
197 | {
|
---|
198 |
|
---|
199 | MRawEvtPixelIter pixel(fRawEvt);
|
---|
200 | fArrTime->Clear();
|
---|
201 |
|
---|
202 | while (pixel.Next())
|
---|
203 | {
|
---|
204 |
|
---|
205 | //
|
---|
206 | // Find signal in hi- and lo-gain
|
---|
207 | //
|
---|
208 | Float_t timehi, deltatimehi;
|
---|
209 | Byte_t sathi = 0;
|
---|
210 |
|
---|
211 | //
|
---|
212 | // Take correspodning pedestal
|
---|
213 | //
|
---|
214 | const UInt_t pixid = pixel.GetPixelId();
|
---|
215 | const MPedestalPix &ped = (*fPedestals)[pixid];
|
---|
216 |
|
---|
217 | FindTimeHiGain(pixel.GetHiGainSamples()+fHiGainFirst, timehi, deltatimehi, sathi, ped);
|
---|
218 |
|
---|
219 | Float_t timelo =0.;
|
---|
220 | Float_t deltatimelo =0.;
|
---|
221 | Byte_t satlo =0;
|
---|
222 |
|
---|
223 | if (pixel.HasLoGain() && sathi>0)
|
---|
224 | FindTimeLoGain(pixel.GetLoGainSamples()+fLoGainFirst, timelo, deltatimelo, satlo, ped);
|
---|
225 |
|
---|
226 | MArrivalTimePix &pix = (*fArrTime)[pixid];
|
---|
227 |
|
---|
228 | pix.SetArrivalTime(timehi,deltatimehi, timelo, deltatimelo);
|
---|
229 | pix.SetGainSaturation(sathi, sathi, satlo);
|
---|
230 |
|
---|
231 | }
|
---|
232 |
|
---|
233 | fArrTime->SetReadyToSave();
|
---|
234 |
|
---|
235 | return kTRUE;
|
---|
236 | }
|
---|
237 |
|
---|
238 |
|
---|