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

Last change on this file since 4544 was 4511, checked in by tbretz, 20 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! Hendrik Bartko, 07/2003 <mailto:hbartko@mppmu.mpg.de>
21!
22! Copyright: MAGIC Software Development, 2000-2004
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// MCalibrationRelTimeCam
38// MCalibrationQECam
39// MCalibrationPedCam
40// MPedPhotCam
41// MExtractedSignalCam
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// [MArrivalTime]
62// [MArrivalTimeCam]
63//
64//////////////////////////////////////////////////////////////////////////////
65#include "MGeomApply.h"
66
67#include <fstream>
68
69#include "MLog.h"
70#include "MLogManip.h"
71
72#include "MParList.h"
73
74#include "MGeomCam.h"
75#include "MPedestalCam.h"
76#include "MCalibrationCam.h"
77#include "MPedPhotCam.h"
78#include "MExtractedSignalCam.h"
79#include "MArrivalTimeCam.h"
80#include "MArrivalTime.h"
81#include "MBadPixelsCam.h"
82
83ClassImp(MGeomApply);
84
85using namespace std;
86
87// --------------------------------------------------------------------------
88//
89// Default constructor. MGeomCamMagic is the default geometry.
90//
91MGeomApply::MGeomApply(const char *name, const char *title) : fGeomName("MGeomCamMagic")
92{
93 fName = name ? name : "MGeomApply";
94 fTitle = title ? title : "Task to apply geometry settings";
95}
96
97// --------------------------------------------------------------------------
98//
99// Try to find 'MGeomCam' in the Parameter List. If it is not found,
100// try to create a fGeomName object.
101//
102Int_t MGeomApply::PreProcess(MParList *pList)
103{
104 MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
105 if (cam)
106 return kTRUE;
107
108 cam = (MGeomCam*)pList->FindCreateObj(AddSerialNumber(fGeomName), "MGeomCam");
109
110 return cam ? kTRUE : kFALSE;
111}
112
113// --------------------------------------------------------------------------
114//
115// Try to find 'MGeomCam' in the Parameter List. If it is not found,
116// processing is stopped.
117//
118Bool_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->Init(*cam);
135
136 MCalibrationCam *cal = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
137 if (cal)
138 cal->Init(*cam);
139
140 MCalibrationCam *cat = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam"));
141 if (cat)
142 cat->Init(*cam);
143
144 MCalibrationCam *qe = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationQECam"));
145 if (qe)
146 qe->Init(*cam);
147
148 MCalibrationCam *pcam = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationPedCam"));
149 if (pcam)
150 pcam->Init(*cam);
151
152 MPedPhotCam *pedphot = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
153 if (pedphot)
154 pedphot->Init(*cam);
155
156 MExtractedSignalCam *ext = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
157 if (ext)
158 ext->InitSize(cam->GetNumPixels());
159
160 MArrivalTimeCam *tme = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
161 if (tme)
162 tme->InitSize(cam->GetNumPixels());
163
164 MArrivalTime *atm = (MArrivalTime*)pList->FindObject(AddSerialNumber("MArrivalTime"));
165 if (atm)
166 atm->InitSize(cam->GetNumPixels());
167
168 MBadPixelsCam *bad = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
169 if (bad)
170 bad->InitSize(cam->GetNumPixels());
171
172 return kTRUE;
173}
174
175// --------------------------------------------------------------------------
176//
177// Implementation of SavePrimitive. Used to write the call to a constructor
178// to a macro. In the original root implementation it is used to write
179// gui elements to a macro-file.
180//
181void MGeomApply::StreamPrimitive(ofstream &out) const
182{
183 out << " " << ClassName() << " " << GetUniqueName() << "(\"";
184 out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
185
186 if (fGeomName.IsNull())
187 return;
188
189 out << " " << GetUniqueName() << ".SetGeometry(\"";
190 out << fGeomName << "\");" << endl;
191}
Note: See TracBrowser for help on using the repository browser.