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 | // MArrivalTime
|
---|
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 "MArrivalTime.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 | fArrivalTime(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 | // - MArrivalTime
|
---|
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 |
|
---|
106 | fCalibrations = (MCalibrationRelTimeCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam"));
|
---|
107 | if (!fCalibrations)
|
---|
108 | {
|
---|
109 | *fLog << err << AddSerialNumber("MCalibrationRelTimeCam") << " not found ... aborting." << endl;
|
---|
110 | return kFALSE;
|
---|
111 | }
|
---|
112 |
|
---|
113 |
|
---|
114 | fArrivalTime = (MArrivalTime*)pList->FindCreateObj(AddSerialNumber("MArrivalTime"));
|
---|
115 | if (!fArrivalTime)
|
---|
116 | {
|
---|
117 | *fLog << err << AddSerialNumber("MArrivalTime") << ": Cannot create ... aborting." << endl;
|
---|
118 | return kFALSE;
|
---|
119 | }
|
---|
120 |
|
---|
121 | return kTRUE;
|
---|
122 | }
|
---|
123 |
|
---|
124 | // --------------------------------------------------------------------------
|
---|
125 | //
|
---|
126 | // Check for validity of the selected calibration method, switch to a
|
---|
127 | // different one in case of need
|
---|
128 | //
|
---|
129 | Bool_t MCalibrateRelTimes::ReInit(MParList *pList)
|
---|
130 | {
|
---|
131 | return kTRUE;
|
---|
132 | }
|
---|
133 | // --------------------------------------------------------------------------
|
---|
134 | //
|
---|
135 | // Apply the calibration factors to the extracted signal according to the
|
---|
136 | // selected calibration method
|
---|
137 | //
|
---|
138 | Int_t MCalibrateRelTimes::Process()
|
---|
139 | {
|
---|
140 |
|
---|
141 | /*
|
---|
142 | if (fCalibrations->GetNumPixels() != (UInt_t)fSignals->GetSize())
|
---|
143 | {
|
---|
144 | // FIXME: MArrivalTime must be of variable size -
|
---|
145 | // like MCerPhotEvt - because we must be able
|
---|
146 | // to reduce size by zero supression
|
---|
147 | // For the moment this check could be done in ReInit...
|
---|
148 | *fLog << err << "MArrivalTime and MCalibrationCam have different sizes... abort." << endl;
|
---|
149 | return kFALSE;
|
---|
150 | }
|
---|
151 | */
|
---|
152 |
|
---|
153 | UInt_t npix = fSignals->GetSize();
|
---|
154 |
|
---|
155 | Float_t offset = 0.;
|
---|
156 | Float_t precision = 0.;
|
---|
157 |
|
---|
158 | for (UInt_t pixidx=0; pixidx<npix; pixidx++)
|
---|
159 | {
|
---|
160 |
|
---|
161 | MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCalibrations)[pixidx];
|
---|
162 |
|
---|
163 | if (fBadPixels)
|
---|
164 | {
|
---|
165 | MBadPixelsPix &bad = (*fBadPixels)[pixidx];
|
---|
166 | if (bad.IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
---|
167 | continue;
|
---|
168 | }
|
---|
169 |
|
---|
170 | offset = pix.GetTimeOffset();
|
---|
171 | precision = pix.GetTimePrecision();
|
---|
172 |
|
---|
173 | MArrivalTimePix &sig = (*fSignals)[pixidx];
|
---|
174 |
|
---|
175 | Float_t signal;
|
---|
176 | Float_t sigerr;
|
---|
177 |
|
---|
178 | if (sig.IsLoGainUsed())
|
---|
179 | {
|
---|
180 | signal = sig.GetArrivalTimeLoGain();
|
---|
181 | sigerr = sig.GetArrivalTimeLoGainError();
|
---|
182 | }
|
---|
183 | else
|
---|
184 | {
|
---|
185 | signal = sig.GetArrivalTimeHiGain();
|
---|
186 | sigerr = sig.GetArrivalTimeHiGainError();
|
---|
187 | }
|
---|
188 |
|
---|
189 | const Float_t time = signal - offset;
|
---|
190 | Float_t err = sigerr*sigerr + precision*precision;
|
---|
191 | if (err > 0)
|
---|
192 | err = TMath::Sqrt(err);
|
---|
193 |
|
---|
194 | fArrivalTime->SetTime(pixidx,time);
|
---|
195 | fArrivalTime->SetTimeErr(pixidx,err);
|
---|
196 |
|
---|
197 | } /* for (UInt_t pixidx=0; pixidx<npix; pixidx++) */
|
---|
198 |
|
---|
199 | fArrivalTime->SetReadyToSave();
|
---|
200 |
|
---|
201 | return kTRUE;
|
---|
202 | }
|
---|