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