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, 04/2004 <mailto:markus@ifae.es>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | //////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MExtractTime
|
---|
28 | //
|
---|
29 | // Base class for the signal extractors, used the functions
|
---|
30 | // FindTimeHiGain() and FindTimeLoGain() to extract the signal and
|
---|
31 | // substract the pedestal value
|
---|
32 | //
|
---|
33 | // The following figure gives and example of possible inheritance trees.
|
---|
34 | // An extractor class can inherit from each of the following base classes:
|
---|
35 | // - MExtractor
|
---|
36 | // - MExtractTime
|
---|
37 | // - MExtractTimeAndCharge
|
---|
38 | //
|
---|
39 | //Begin_Html
|
---|
40 | /*
|
---|
41 | <img src="images/ExtractorClasses.gif">
|
---|
42 | */
|
---|
43 | //End_Html
|
---|
44 | //
|
---|
45 | // The following variables have to be set by the derived class and
|
---|
46 | // do not have defaults:
|
---|
47 | // - fNumHiGainSamples
|
---|
48 | // - fNumLoGainSamples
|
---|
49 | // - fSqrtHiGainSamples
|
---|
50 | // - fSqrtLoGainSamples
|
---|
51 | //
|
---|
52 | // Input Containers:
|
---|
53 | // MRawEvtData
|
---|
54 | // MRawRunHeader
|
---|
55 | // MPedestalCam
|
---|
56 | //
|
---|
57 | // Output Containers:
|
---|
58 | // MArrivalTimeCam
|
---|
59 | //
|
---|
60 | //////////////////////////////////////////////////////////////////////////////
|
---|
61 | #include "MExtractTime.h"
|
---|
62 |
|
---|
63 | #include <fstream>
|
---|
64 |
|
---|
65 | #include "MLog.h"
|
---|
66 | #include "MLogManip.h"
|
---|
67 |
|
---|
68 | #include "MParList.h"
|
---|
69 |
|
---|
70 | #include "MRawEvtData.h"
|
---|
71 | #include "MRawEvtPixelIter.h"
|
---|
72 | #include "MRawRunHeader.h"
|
---|
73 |
|
---|
74 | #include "MPedestalCam.h"
|
---|
75 | #include "MPedestalPix.h"
|
---|
76 |
|
---|
77 | #include "MArrivalTimeCam.h"
|
---|
78 | #include "MArrivalTimePix.h"
|
---|
79 |
|
---|
80 | ClassImp(MExtractTime);
|
---|
81 |
|
---|
82 | using namespace std;
|
---|
83 |
|
---|
84 | const TString MExtractTime::fgNameTimeCam = "MArrivalTimeCam";
|
---|
85 | // --------------------------------------------------------------------------
|
---|
86 | //
|
---|
87 | // Default constructor.
|
---|
88 | //
|
---|
89 | // Set:
|
---|
90 | // - all pointers to NULL
|
---|
91 | // - all variables to 0
|
---|
92 | // - fSaturationLimit to fgSaturationLimit
|
---|
93 | // - fNameTimeCam to fgNameTimeCam
|
---|
94 | //
|
---|
95 | // Call:
|
---|
96 | // - AddToBranchList("MRawEvtData.*")
|
---|
97 | //
|
---|
98 | MExtractTime::MExtractTime(const char *name, const char *title)
|
---|
99 | : fArrTime(NULL)
|
---|
100 | {
|
---|
101 |
|
---|
102 | fName = name ? name : "MExtractTime";
|
---|
103 | fTitle = title ? title : "Base class for signal extractors";
|
---|
104 |
|
---|
105 | SetNameTimeCam();
|
---|
106 | }
|
---|
107 |
|
---|
108 |
|
---|
109 |
|
---|
110 | // --------------------------------------------------------------------------
|
---|
111 | //
|
---|
112 | // The PreProcess searches for the following input containers:
|
---|
113 | // - MRawEvtData
|
---|
114 | // - MRawRunHeader
|
---|
115 | // - MPedestalCam
|
---|
116 | //
|
---|
117 | // The following output containers are also searched and created if
|
---|
118 | // they were not found:
|
---|
119 | //
|
---|
120 | // - MArrivalTimeCam
|
---|
121 | //
|
---|
122 | Int_t MExtractTime::PreProcess(MParList *pList)
|
---|
123 | {
|
---|
124 | fArrTime = (MArrivalTimeCam*)pList->FindCreateObj("MArrivalTimeCam",AddSerialNumber(fNameTimeCam));
|
---|
125 | if (!fArrTime)
|
---|
126 | return kFALSE;
|
---|
127 |
|
---|
128 | return PreProcessStd(pList);
|
---|
129 | }
|
---|
130 |
|
---|
131 | // --------------------------------------------------------------------------
|
---|
132 | //
|
---|
133 | // The ReInit calls:
|
---|
134 | // - MExtractor::ReInit()
|
---|
135 | //
|
---|
136 | // Call:
|
---|
137 | // - MArrivalTimeCam::SetUsedFADCSlices(fHiGainFirst, fHiGainLast, fNumHiGainSamples,
|
---|
138 | // fLoGainFirst, fLoGainLast, fNumLoGainSamples);
|
---|
139 | //
|
---|
140 | Bool_t MExtractTime::ReInit(MParList *pList)
|
---|
141 | {
|
---|
142 | if (!MExtractor::ReInit(pList))
|
---|
143 | return kFALSE;
|
---|
144 |
|
---|
145 | if (fArrTime)
|
---|
146 | fArrTime->SetUsedFADCSlices(fHiGainFirst, fHiGainLast+fHiLoLast, fLoGainFirst, fLoGainLast);
|
---|
147 |
|
---|
148 | return kTRUE;
|
---|
149 | }
|
---|
150 |
|
---|
151 | // --------------------------------------------------------------------------
|
---|
152 | //
|
---|
153 | // Calculate the integral of the FADC time slices and store them as a new
|
---|
154 | // pixel in the MArrivalTimeCam container.
|
---|
155 | //
|
---|
156 | Int_t MExtractTime::Process()
|
---|
157 | {
|
---|
158 |
|
---|
159 |
|
---|
160 | MRawEvtPixelIter pixel(fRawEvt);
|
---|
161 | fArrTime->Clear();
|
---|
162 |
|
---|
163 | while (pixel.Next())
|
---|
164 | {
|
---|
165 | //
|
---|
166 | // Find signal in hi- and lo-gain
|
---|
167 | //
|
---|
168 | Float_t timehi=0., deltatimehi=0.;
|
---|
169 | Byte_t sathi=0;
|
---|
170 |
|
---|
171 | const Int_t pixid = pixel.GetPixelId();
|
---|
172 | const MPedestalPix &ped = (*fPedestals)[pixid];
|
---|
173 | MArrivalTimePix &pix = (*fArrTime)[pixid];
|
---|
174 |
|
---|
175 | FindTimeHiGain(pixel.GetHiGainSamples()+fHiGainFirst, timehi, deltatimehi, sathi, ped);
|
---|
176 |
|
---|
177 | Float_t timelo=0., deltatimelo=0.;
|
---|
178 | Byte_t satlo=0;
|
---|
179 |
|
---|
180 | if ((sathi)&&pixel.HasLoGain())
|
---|
181 | FindTimeLoGain(pixel.GetLoGainSamples()+fLoGainFirst, timelo, deltatimelo, satlo, ped);
|
---|
182 |
|
---|
183 | pix.SetArrivalTime(timehi, deltatimehi, timelo-fOffsetLoGain, deltatimelo);
|
---|
184 | pix.SetGainSaturation(sathi, sathi, satlo);
|
---|
185 |
|
---|
186 | } /* while (pixel.Next()) */
|
---|
187 |
|
---|
188 | fArrTime->SetReadyToSave();
|
---|
189 |
|
---|
190 | return kTRUE;
|
---|
191 | }
|
---|
192 |
|
---|
193 | void MExtractTime::Print(Option_t *o) const
|
---|
194 | {
|
---|
195 | if (IsA()==MExtractTime::Class())
|
---|
196 | *fLog << GetDescriptor() << ":" << endl;
|
---|
197 | *fLog << " Offset Lo-Gain: " << fOffsetLoGain << endl;
|
---|
198 | MExtractor::Print(o);
|
---|
199 | }
|
---|