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

Last change on this file since 4781 was 4577, checked in by tbretz, 20 years ago
*** empty log message ***
File size: 6.1 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 *geom = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
121 if (!geom)
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 geom->CalcPixRatio();
131
132 TIter Next(*pList);
133 TObject *o = 0;
134
135 while ((o=Next()))
136 {
137 MCamEvent *cam = dynamic_cast<MCamEvent*>(o);
138 if (cam)
139 cam->Init(*geom);
140 }
141/*
142 MPedestalCam *ped = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
143 if (ped)
144 ped->Init(*geom);
145
146 MCalibrationCam *cal = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
147 if (cal)
148 cal->Init(*geom);
149
150 MCalibrationCam *cat = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationRelTimeCam"));
151 if (cat)
152 cat->Init(*geom);
153
154 MCalibrationCam *qe = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationQECam"));
155 if (qe)
156 qe->Init(*geom);
157
158 MCalibrationCam *pcam = (MCalibrationCam*)pList->FindObject(AddSerialNumber("MCalibrationPedCam"));
159 if (pcam)
160 pcam->Init(*geom);
161
162 MPedPhotCam *pedphot = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
163 if (pedphot)
164 pedphot->Init(*geom);
165
166 MExtractedSignalCam *ext = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
167 if (ext)
168 ext->Init(*cam);
169
170 MArrivalTimeCam *tme = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
171 if (tme)
172 tme->InitSize(cam->GetNumPixels());
173
174 MArrivalTime *atm = (MArrivalTime*)pList->FindObject(AddSerialNumber("MArrivalTime"));
175 if (atm)
176 atm->InitSize(cam->GetNumPixels());
177
178 MBadPixelsCam *bad = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
179 if (bad)
180 bad->InitSize(cam->GetNumPixels());
181 */
182
183 return kTRUE;
184}
185
186// --------------------------------------------------------------------------
187//
188// Implementation of SavePrimitive. Used to write the call to a constructor
189// to a macro. In the original root implementation it is used to write
190// gui elements to a macro-file.
191//
192void MGeomApply::StreamPrimitive(ofstream &out) const
193{
194 out << " " << ClassName() << " " << GetUniqueName() << "(\"";
195 out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
196
197 if (fGeomName.IsNull())
198 return;
199
200 out << " " << GetUniqueName() << ".SetGeometry(\"";
201 out << fGeomName << "\");" << endl;
202}
Note: See TracBrowser for help on using the repository browser.