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-2006
|
---|
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 MSignalCam.
|
---|
32 | //
|
---|
33 | // Input Containers:
|
---|
34 | // MArrivalTimeCam
|
---|
35 | // MCalibrationRelTimeCam
|
---|
36 | //
|
---|
37 | // Output Containers:
|
---|
38 | // MSignalCam
|
---|
39 | //
|
---|
40 | //////////////////////////////////////////////////////////////////////////////
|
---|
41 | #include "MCalibrateRelTimes.h"
|
---|
42 |
|
---|
43 | #include "MLog.h"
|
---|
44 | #include "MLogManip.h"
|
---|
45 |
|
---|
46 | #include "MParList.h"
|
---|
47 |
|
---|
48 | #include "MGeomCam.h"
|
---|
49 |
|
---|
50 | #include "MCalibrationRelTimeCam.h"
|
---|
51 | #include "MCalibrationRelTimePix.h"
|
---|
52 |
|
---|
53 | #include "MArrivalTimeCam.h"
|
---|
54 | #include "MArrivalTimePix.h"
|
---|
55 |
|
---|
56 | #include "MBadPixelsCam.h"
|
---|
57 | #include "MBadPixelsPix.h"
|
---|
58 |
|
---|
59 | #include "MSignalCam.h"
|
---|
60 | #include "MSignalPix.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 | Int_t MCalibrateRelTimes::PreProcess(MParList *pList)
|
---|
86 | {
|
---|
87 | fSignals = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
|
---|
88 |
|
---|
89 | if (!fSignals)
|
---|
90 | {
|
---|
91 | *fLog << err << AddSerialNumber("MArrivalTimeCam") << " not found ... aborting" << endl;
|
---|
92 | return kFALSE;
|
---|
93 | }
|
---|
94 |
|
---|
95 | fBadPixels = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
|
---|
96 | if (!fBadPixels)
|
---|
97 | *fLog << warn << AddSerialNumber("MBadPixelsCam") << " not found ... ignoring." << endl;
|
---|
98 |
|
---|
99 | fCalibrations = (MCalibrationRelTimeCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam"));
|
---|
100 | if (!fCalibrations)
|
---|
101 | {
|
---|
102 | *fLog << err << AddSerialNumber("MCalibrationRelTimeCam") << " not found ... aborting." << endl;
|
---|
103 | return kFALSE;
|
---|
104 | }
|
---|
105 |
|
---|
106 | fArrivalTime = (MSignalCam*)pList->FindCreateObj(AddSerialNumber("MSignalCam"));
|
---|
107 | if (!fArrivalTime)
|
---|
108 | return kFALSE;
|
---|
109 |
|
---|
110 | return kTRUE;
|
---|
111 | }
|
---|
112 |
|
---|
113 | // --------------------------------------------------------------------------
|
---|
114 | //
|
---|
115 | // Apply the calibration factors to the extracted signal according to the
|
---|
116 | // selected calibration method
|
---|
117 | //
|
---|
118 | Int_t MCalibrateRelTimes::Process()
|
---|
119 | {
|
---|
120 | const UInt_t npix = fSignals->GetSize();
|
---|
121 |
|
---|
122 | for (UInt_t idx=0; idx<npix; idx++)
|
---|
123 | {
|
---|
124 | if (fBadPixels && (*fBadPixels)[idx].IsUnsuitable(MBadPixelsPix::kUnsuitableRun))
|
---|
125 | continue;
|
---|
126 |
|
---|
127 | const MCalibrationRelTimePix &pix = (MCalibrationRelTimePix&)(*fCalibrations)[idx];
|
---|
128 | const MArrivalTimePix &sig = (*fSignals)[idx];
|
---|
129 |
|
---|
130 | const Float_t signal = sig.GetArrivalTime();
|
---|
131 | const Float_t offset = pix.GetTimeOffset();
|
---|
132 |
|
---|
133 | (*fArrivalTime)[idx].SetArrivalTime(signal-offset);
|
---|
134 |
|
---|
135 | // FIXME: Is this necessary or explicitly done by the signal-
|
---|
136 | // extractor (may depend on the fact whether independent
|
---|
137 | // extractor are or can be used for signal and arrival time)
|
---|
138 | if (fBadPixels && !sig.IsArrivalTimeValid())
|
---|
139 | (*fBadPixels)[idx].SetUnsuitable(MBadPixelsPix::kUnsuitableEvt);
|
---|
140 | }
|
---|
141 |
|
---|
142 | fArrivalTime->SetReadyToSave();
|
---|
143 |
|
---|
144 | return kTRUE;
|
---|
145 | }
|
---|