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 | // MCalibrateRelTimes
|
---|
28 | //
|
---|
29 | // This task takes the extracted arrival times from MArrivalTimeCam for each
|
---|
30 | // pixel and applies the offset calibrated in MCalibrationRelTimeCam
|
---|
31 | // The calibrated arrival time and its error gets stored in MCerPhotEvt.
|
---|
32 | //
|
---|
33 | // Input Containers:
|
---|
34 | // MArrivalTimeCam
|
---|
35 | // MCalibrationRelTimeCam
|
---|
36 | //
|
---|
37 | // Output Containers:
|
---|
38 | // MCerPhotEvt
|
---|
39 | //
|
---|
40 | //////////////////////////////////////////////////////////////////////////////
|
---|
41 | #include "MCalibrateRelTimes.h"
|
---|
42 |
|
---|
43 | #include "MLog.h"
|
---|
44 | #include "MLogManip.h"
|
---|
45 |
|
---|
46 | #include "MParList.h"
|
---|
47 | #include "MH.h"
|
---|
48 |
|
---|
49 | #include "MGeomCam.h"
|
---|
50 |
|
---|
51 | #include "MCalibrationRelTimeCam.h"
|
---|
52 | #include "MCalibrationRelTimePix.h"
|
---|
53 |
|
---|
54 | #include "MArrivalTimeCam.h"
|
---|
55 | #include "MArrivalTimePix.h"
|
---|
56 |
|
---|
57 | #include "MBadPixelsCam.h"
|
---|
58 | #include "MBadPixelsPix.h"
|
---|
59 |
|
---|
60 | #include "MCerPhotEvt.h"
|
---|
61 |
|
---|
62 | ClassImp(MCalibrateRelTimes);
|
---|
63 |
|
---|
64 | using namespace std;
|
---|
65 | // --------------------------------------------------------------------------
|
---|
66 | //
|
---|
67 | // Default constructor.
|
---|
68 | //
|
---|
69 | MCalibrateRelTimes::MCalibrateRelTimes(const char *name, const char *title)
|
---|
70 | : fGeomCam(NULL), fCalibrations(NULL), fBadPixels(NULL), fSignals(NULL),
|
---|
71 | fCerPhotEvt(NULL)
|
---|
72 | {
|
---|
73 | fName = name ? name : "MCalibrateRelTimes";
|
---|
74 | fTitle = title ? title : "Task to calculate the calibrated arrival times of photons in one event";
|
---|
75 | }
|
---|
76 |
|
---|
77 | // --------------------------------------------------------------------------
|
---|
78 | //
|
---|
79 | // The PreProcess searches for the following input containers:
|
---|
80 | // - MGeomCam
|
---|
81 | // - MCalibrationRelTimesCam
|
---|
82 | // - MArrivalTimeCam
|
---|
83 | // - MBadPixelsCam
|
---|
84 | //
|
---|
85 | // The following output containers are also searched and created if
|
---|
86 | // they were not found:
|
---|
87 | //
|
---|
88 | // - MCerPhotEvt
|
---|
89 | //
|
---|
90 | Int_t MCalibrateRelTimes::PreProcess(MParList *pList)
|
---|
91 | {
|
---|
92 |
|
---|
93 | fSignals = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
|
---|
94 |
|
---|
95 | if (!fSignals)
|
---|
96 | {
|
---|
97 | *fLog << err << AddSerialNumber("MArrivalTimeCam") << " not found ... aborting" << endl;
|
---|
98 | return kFALSE;
|
---|
99 | }
|
---|
100 |
|
---|
101 | fBadPixels = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
|
---|
102 | if (!fBadPixels)
|
---|
103 | *fLog << warn << AddSerialNumber("MBadPixelsCam") << " not found ... no action" << endl;
|
---|
104 |
|
---|
105 | fCalibrations = (MCalibrationRelTimeCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam"));
|
---|
106 | if (!fCalibrations)
|
---|
107 | {
|
---|
108 | *fLog << err << AddSerialNumber("MCalibrationRelTimeCam") << " not found ... aborting." << endl;
|
---|
109 | return kFALSE;
|
---|
110 | }
|
---|
111 |
|
---|
112 |
|
---|
113 | fCerPhotEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
|
---|
114 | if (!fCerPhotEvt)
|
---|
115 | {
|
---|
116 | *fLog << err << AddSerialNumber("MCerPhotEvt") << " not found ... aborting." << endl;
|
---|
117 | return kFALSE;
|
---|
118 | }
|
---|
119 |
|
---|
120 | return kTRUE;
|
---|
121 | }
|
---|
122 |
|
---|
123 | // --------------------------------------------------------------------------
|
---|
124 | //
|
---|
125 | // Check for validity of the selected calibration method, switch to a
|
---|
126 | // different one in case of need
|
---|
127 | //
|
---|
128 | Bool_t MCalibrateRelTimes::ReInit(MParList *pList)
|
---|
129 | {
|
---|
130 | return kTRUE;
|
---|
131 | }
|
---|
132 | // --------------------------------------------------------------------------
|
---|
133 | //
|
---|
134 | // Apply the calibration factors to the extracted signal according to the
|
---|
135 | // selected calibration method
|
---|
136 | //
|
---|
137 | Int_t MCalibrateRelTimes::Process()
|
---|
138 | {
|
---|
139 |
|
---|
140 | /*
|
---|
141 | if (fCalibrations->GetNumPixels() != (UInt_t)fSignals->GetSize())
|
---|
142 | {
|
---|
143 | // FIXME: MArrivalTime must be of variable size -
|
---|
144 | // like MCerPhotEvt - because we must be able
|
---|
145 | // to reduce size by zero supression
|
---|
146 | // For the moment this check could be done in ReInit...
|
---|
147 | *fLog << err << "MArrivalTime and MCalibrationCam have different sizes... abort." << endl;
|
---|
148 | return kFALSE;
|
---|
149 | }
|
---|
150 | */
|
---|
151 |
|
---|
152 | UInt_t npix = fSignals->GetSize();
|
---|
153 |
|
---|
154 | Float_t offset = 0.;
|
---|
155 | Float_t precision = 0.;
|
---|
156 |
|
---|
157 | for (UInt_t pixidx=0; pixidx<npix; pixidx++)
|
---|
158 | {
|
---|
159 |
|
---|
160 | MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCalibrations)[pixidx];
|
---|
161 | MBadPixelsPix &bad = (*fBadPixels)[pixidx];
|
---|
162 |
|
---|
163 | if (fBadPixels)
|
---|
164 | if (!bad.IsCalibrationResultOK())
|
---|
165 | continue;
|
---|
166 |
|
---|
167 | offset = pix.GetTimeOffset();
|
---|
168 | precision = pix.GetTimePrecision();
|
---|
169 |
|
---|
170 | MArrivalTimePix &sig = (*fSignals)[pixidx];
|
---|
171 |
|
---|
172 | Float_t signal;
|
---|
173 |
|
---|
174 | if (sig.IsLoGainUsed())
|
---|
175 | signal = sig.GetArrivalTimeLoGain();
|
---|
176 | else
|
---|
177 | signal = sig.GetArrivalTimeHiGain();
|
---|
178 |
|
---|
179 | const Float_t time = signal - offset;
|
---|
180 |
|
---|
181 | //
|
---|
182 | // The following part is the outcommented first version of the error calculation
|
---|
183 | // Contact Markus Gaug for questions (or wait for the next documentation update...)
|
---|
184 | //
|
---|
185 | /*
|
---|
186 | nphotErr = signal > 0 ? signalErr*signalErr / (signal * signal) : 0.
|
---|
187 | + calibConv > 0 ? calibConvVar / (calibConv * calibConv ) : 0.
|
---|
188 | + calibQE > 0 ? calibQEVar / (calibQE * calibQE ) : 0.;
|
---|
189 | nphotErr = TMath::Sqrt(nphotErr) * nphot;
|
---|
190 | */
|
---|
191 |
|
---|
192 | MCerPhotPix &cpix = (*fCerPhotEvt)[pixidx];
|
---|
193 | cpix.SetTime(time);
|
---|
194 |
|
---|
195 | } /* for (UInt_t pixidx=0; pixidx<npix; pixidx++) */
|
---|
196 |
|
---|
197 | fCerPhotEvt->SetReadyToSave();
|
---|
198 |
|
---|
199 | return kTRUE;
|
---|
200 | }
|
---|