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): Thomas Bretz, 09/2003 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | ! Markus Gaug, 03/2004 <mailto:markus@ifae.es>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 | //////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MGeomApply
|
---|
28 | //
|
---|
29 | // Applies the geometry to geometry dependant containers.
|
---|
30 | //
|
---|
31 | // It changes the size of the arrays in the containers to a size
|
---|
32 | // matching the number of pixels, eg:
|
---|
33 | //
|
---|
34 | // MPedestalCam
|
---|
35 | // MCalibrationChargeCam
|
---|
36 | // MCalibrationRelTimeCam
|
---|
37 | // MCalibrationQECam
|
---|
38 | // MCalibrationPedCam
|
---|
39 | // MPedPhotCam
|
---|
40 | // MExtractedSignalCam
|
---|
41 | // MBlindPixels
|
---|
42 | // MArrivalTimeCam
|
---|
43 | // MArrivalTimePix
|
---|
44 | //
|
---|
45 | // It uses the geometry (MGeomCam) found in the parameter list.
|
---|
46 | // If it is not found the task tries to create the geometry
|
---|
47 | // specified in the constructor. The default geometry is
|
---|
48 | // MGeomCamMagic.
|
---|
49 | //
|
---|
50 | // Input Containers:
|
---|
51 | // [MGeomCam]
|
---|
52 | //
|
---|
53 | // Output Containers:
|
---|
54 | // [MPedestalCam]
|
---|
55 | // [MCalibrationChargeCam]
|
---|
56 | // [MCalibrationRelTimeCam]
|
---|
57 | // [MCalibrationQECam]
|
---|
58 | // [MCalibrationPedCam]
|
---|
59 | // [MPedPhotCam]
|
---|
60 | // [MExtractedSignalCam]
|
---|
61 | // [MBlindPixels]
|
---|
62 | // [MArrivalTime]
|
---|
63 | // [MArrivalTimeCam]
|
---|
64 | //
|
---|
65 | //////////////////////////////////////////////////////////////////////////////
|
---|
66 | #include "MGeomApply.h"
|
---|
67 |
|
---|
68 | #include <fstream>
|
---|
69 |
|
---|
70 | #include "MLog.h"
|
---|
71 | #include "MLogManip.h"
|
---|
72 |
|
---|
73 | #include "MParList.h"
|
---|
74 |
|
---|
75 | #include "MGeomCam.h"
|
---|
76 | #include "MPedestalCam.h"
|
---|
77 | #include "MCalibrationChargeCam.h"
|
---|
78 | #include "MCalibrationRelTimeCam.h"
|
---|
79 | #include "MCalibrationQECam.h"
|
---|
80 | #include "MCalibrationPedCam.h"
|
---|
81 | #include "MPedPhotCam.h"
|
---|
82 | #include "MExtractedSignalCam.h"
|
---|
83 | #include "MBlindPixels.h"
|
---|
84 | #include "MArrivalTimeCam.h"
|
---|
85 | #include "MBadPixelsCam.h"
|
---|
86 |
|
---|
87 | ClassImp(MGeomApply);
|
---|
88 |
|
---|
89 | using namespace std;
|
---|
90 |
|
---|
91 | // --------------------------------------------------------------------------
|
---|
92 | //
|
---|
93 | // Default constructor. MGeomCamMagic is the default geometry.
|
---|
94 | //
|
---|
95 | MGeomApply::MGeomApply(const char *name, const char *title) : fGeomName("MGeomCamMagic")
|
---|
96 | {
|
---|
97 | fName = name ? name : "MGeomApply";
|
---|
98 | fTitle = title ? title : "Task to apply geometry settings";
|
---|
99 | }
|
---|
100 |
|
---|
101 | // --------------------------------------------------------------------------
|
---|
102 | //
|
---|
103 | // Try to find 'MGeomCam' in the Parameter List. If it is not found,
|
---|
104 | // try to create a fGeomName object.
|
---|
105 | //
|
---|
106 | Int_t MGeomApply::PreProcess(MParList *pList)
|
---|
107 | {
|
---|
108 | MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
|
---|
109 | if (cam)
|
---|
110 | return kTRUE;
|
---|
111 |
|
---|
112 | cam = (MGeomCam*)pList->FindCreateObj(AddSerialNumber(fGeomName), "MGeomCam");
|
---|
113 |
|
---|
114 | return cam ? kTRUE : kFALSE;
|
---|
115 | }
|
---|
116 |
|
---|
117 | // --------------------------------------------------------------------------
|
---|
118 | //
|
---|
119 | // Try to find 'MGeomCam' in the Parameter List. If it is not found,
|
---|
120 | // processing is stopped.
|
---|
121 | //
|
---|
122 | // The size of MPedestalCam and MBlindPixels is set accordingly.
|
---|
123 | //
|
---|
124 | Bool_t MGeomApply::ReInit(MParList *pList)
|
---|
125 | {
|
---|
126 | MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
|
---|
127 | if (!cam)
|
---|
128 | {
|
---|
129 | *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
|
---|
130 | return kFALSE;
|
---|
131 | }
|
---|
132 |
|
---|
133 | // FIXME, workaround: this call to CalcPixRatio is here just to allow
|
---|
134 | // the use of some camera files from the 0.7 beta version in which the
|
---|
135 | // array containing pixel ratios is not initialized.
|
---|
136 | cam->CalcPixRatio();
|
---|
137 |
|
---|
138 | MPedestalCam *ped = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
|
---|
139 | if (ped)
|
---|
140 | ped->InitSize(cam->GetNumPixels());
|
---|
141 |
|
---|
142 | MCalibrationChargeCam *cal =
|
---|
143 | (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
|
---|
144 | if (cal)
|
---|
145 | {
|
---|
146 | cal->InitSize ( cam->GetNumPixels() );
|
---|
147 | cal->InitAverageAreas ( cam->GetNumAreas() );
|
---|
148 | cal->InitAverageSectors( cam->GetNumSectors() );
|
---|
149 | }
|
---|
150 |
|
---|
151 | MCalibrationRelTimeCam *cat =
|
---|
152 | (MCalibrationRelTimeCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam"));
|
---|
153 | if (cat)
|
---|
154 | {
|
---|
155 | cat->InitSize ( cam->GetNumPixels() );
|
---|
156 | cat->InitAverageAreas ( cam->GetNumAreas() );
|
---|
157 | cat->InitAverageSectors( cam->GetNumSectors() );
|
---|
158 | }
|
---|
159 |
|
---|
160 | MCalibrationQECam *qe =
|
---|
161 | (MCalibrationQECam*)pList->FindObject(AddSerialNumber("MCalibrationQECam"));
|
---|
162 | if (qe)
|
---|
163 | {
|
---|
164 | qe->InitSize ( cam->GetNumPixels() );
|
---|
165 | qe->InitAverageAreas ( cam->GetNumAreas() );
|
---|
166 | qe->InitAverageSectors ( cam->GetNumSectors() );
|
---|
167 | }
|
---|
168 |
|
---|
169 | MCalibrationPedCam *pcam =
|
---|
170 | (MCalibrationPedCam*)pList->FindObject(AddSerialNumber("MCalibrationPedCam"));
|
---|
171 | if (pcam)
|
---|
172 | {
|
---|
173 | pcam->InitSize ( cam->GetNumPixels() );
|
---|
174 | pcam->InitAverageAreas ( cam->GetNumAreas() );
|
---|
175 | pcam->InitAverageSectors ( cam->GetNumSectors() );
|
---|
176 | }
|
---|
177 |
|
---|
178 | MPedPhotCam *pedphot = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
|
---|
179 | if (pedphot)
|
---|
180 | pedphot->InitSize(cam->GetNumPixels());
|
---|
181 |
|
---|
182 |
|
---|
183 | MExtractedSignalCam *ext = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
|
---|
184 | if (ext)
|
---|
185 | ext->InitSize(cam->GetNumPixels());
|
---|
186 |
|
---|
187 |
|
---|
188 | MBlindPixels *bnd = (MBlindPixels*)pList->FindObject(AddSerialNumber("MBlindPixels"));
|
---|
189 | if (bnd)
|
---|
190 | bnd->InitSize(cam->GetNumPixels());
|
---|
191 |
|
---|
192 | MArrivalTimeCam *tme = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
|
---|
193 | if (tme)
|
---|
194 | tme->InitSize(cam->GetNumPixels());
|
---|
195 |
|
---|
196 | MBadPixelsCam *bad = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
|
---|
197 | if (bad)
|
---|
198 | bad->InitSize(cam->GetNumPixels());
|
---|
199 |
|
---|
200 | return kTRUE;
|
---|
201 | }
|
---|
202 |
|
---|
203 | // --------------------------------------------------------------------------
|
---|
204 | //
|
---|
205 | // Implementation of SavePrimitive. Used to write the call to a constructor
|
---|
206 | // to a macro. In the original root implementation it is used to write
|
---|
207 | // gui elements to a macro-file.
|
---|
208 | //
|
---|
209 | void MGeomApply::StreamPrimitive(ofstream &out) const
|
---|
210 | {
|
---|
211 | out << " " << ClassName() << " " << GetUniqueName() << "(\"";
|
---|
212 | out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
|
---|
213 |
|
---|
214 | if (fGeomName.IsNull())
|
---|
215 | return;
|
---|
216 |
|
---|
217 | out << " " << GetUniqueName() << ".SetGeometry(\"";
|
---|
218 | out << fGeomName << "\");" << endl;
|
---|
219 | }
|
---|