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 | // MArrivalTime
|
---|
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 "MCalibrationCam.h"
|
---|
78 | #include "MPedPhotCam.h"
|
---|
79 | #include "MExtractedSignalCam.h"
|
---|
80 | #include "MBlindPixels.h"
|
---|
81 | #include "MArrivalTimeCam.h"
|
---|
82 | #include "MArrivalTime.h"
|
---|
83 | #include "MBadPixelsCam.h"
|
---|
84 |
|
---|
85 | ClassImp(MGeomApply);
|
---|
86 |
|
---|
87 | using namespace std;
|
---|
88 |
|
---|
89 | // --------------------------------------------------------------------------
|
---|
90 | //
|
---|
91 | // Default constructor. MGeomCamMagic is the default geometry.
|
---|
92 | //
|
---|
93 | MGeomApply::MGeomApply(const char *name, const char *title) : fGeomName("MGeomCamMagic")
|
---|
94 | {
|
---|
95 | fName = name ? name : "MGeomApply";
|
---|
96 | fTitle = title ? title : "Task to apply geometry settings";
|
---|
97 | }
|
---|
98 |
|
---|
99 | // --------------------------------------------------------------------------
|
---|
100 | //
|
---|
101 | // Try to find 'MGeomCam' in the Parameter List. If it is not found,
|
---|
102 | // try to create a fGeomName object.
|
---|
103 | //
|
---|
104 | Int_t MGeomApply::PreProcess(MParList *pList)
|
---|
105 | {
|
---|
106 | MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
|
---|
107 | if (cam)
|
---|
108 | return kTRUE;
|
---|
109 |
|
---|
110 | cam = (MGeomCam*)pList->FindCreateObj(AddSerialNumber(fGeomName), "MGeomCam");
|
---|
111 |
|
---|
112 | return cam ? kTRUE : kFALSE;
|
---|
113 | }
|
---|
114 |
|
---|
115 | // --------------------------------------------------------------------------
|
---|
116 | //
|
---|
117 | // Try to find 'MGeomCam' in the Parameter List. If it is not found,
|
---|
118 | // processing is stopped.
|
---|
119 | //
|
---|
120 | // The size of MPedestalCam and MBlindPixels is set accordingly.
|
---|
121 | //
|
---|
122 | Bool_t MGeomApply::ReInit(MParList *pList)
|
---|
123 | {
|
---|
124 | MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
|
---|
125 | if (!cam)
|
---|
126 | {
|
---|
127 | *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
|
---|
128 | return kFALSE;
|
---|
129 | }
|
---|
130 |
|
---|
131 | // FIXME, workaround: this call to CalcPixRatio is here just to allow
|
---|
132 | // the use of some camera files from the 0.7 beta version in which the
|
---|
133 | // array containing pixel ratios is not initialized.
|
---|
134 | cam->CalcPixRatio();
|
---|
135 |
|
---|
136 | MPedestalCam *ped = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
|
---|
137 | if (ped)
|
---|
138 | ped->Init(*cam);
|
---|
139 |
|
---|
140 | MCalibrationCam *cal = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
|
---|
141 | if (cal)
|
---|
142 | cal->Init(*cam);
|
---|
143 |
|
---|
144 | MCalibrationCam *cat = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam"));
|
---|
145 | if (cat)
|
---|
146 | cat->Init(*cam);
|
---|
147 |
|
---|
148 | MCalibrationCam *qe = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationQECam"));
|
---|
149 | if (qe)
|
---|
150 | qe->Init(*cam);
|
---|
151 |
|
---|
152 | MCalibrationCam *pcam = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationPedCam"));
|
---|
153 | if (pcam)
|
---|
154 | pcam->Init(*cam);
|
---|
155 |
|
---|
156 | MPedPhotCam *pedphot = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
|
---|
157 | if (pedphot)
|
---|
158 | pedphot->InitSize(cam->GetNumPixels());
|
---|
159 |
|
---|
160 | MExtractedSignalCam *ext = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
|
---|
161 | if (ext)
|
---|
162 | ext->InitSize(cam->GetNumPixels());
|
---|
163 |
|
---|
164 | MBlindPixels *bnd = (MBlindPixels*)pList->FindObject(AddSerialNumber("MBlindPixels"));
|
---|
165 | if (bnd)
|
---|
166 | bnd->InitSize(cam->GetNumPixels());
|
---|
167 |
|
---|
168 | MArrivalTimeCam *tme = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
|
---|
169 | if (tme)
|
---|
170 | tme->InitSize(cam->GetNumPixels());
|
---|
171 |
|
---|
172 | MArrivalTime *atm = (MArrivalTime*)pList->FindObject(AddSerialNumber("MArrivalTime"));
|
---|
173 | if (atm)
|
---|
174 | atm->InitSize(cam->GetNumPixels());
|
---|
175 |
|
---|
176 | MBadPixelsCam *bad = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
|
---|
177 | if (bad)
|
---|
178 | bad->InitSize(cam->GetNumPixels());
|
---|
179 |
|
---|
180 | return kTRUE;
|
---|
181 | }
|
---|
182 |
|
---|
183 | // --------------------------------------------------------------------------
|
---|
184 | //
|
---|
185 | // Implementation of SavePrimitive. Used to write the call to a constructor
|
---|
186 | // to a macro. In the original root implementation it is used to write
|
---|
187 | // gui elements to a macro-file.
|
---|
188 | //
|
---|
189 | void MGeomApply::StreamPrimitive(ofstream &out) const
|
---|
190 | {
|
---|
191 | out << " " << ClassName() << " " << GetUniqueName() << "(\"";
|
---|
192 | out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
|
---|
193 |
|
---|
194 | if (fGeomName.IsNull())
|
---|
195 | return;
|
---|
196 |
|
---|
197 | out << " " << GetUniqueName() << ".SetGeometry(\"";
|
---|
198 | out << fGeomName << "\");" << endl;
|
---|
199 | }
|
---|