source: trunk/MagicSoft/Mars/manalysis/MGeomApply.cc@ 3751

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