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

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