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

Last change on this file since 3624 was 3624, checked in by gaug, 21 years ago
*** empty log message ***
File size: 5.8 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 "MCalibrationQECam.h"
75#include "MPedPhotCam.h"
76#include "MExtractedSignalCam.h"
77#include "MBlindPixels.h"
78#include "MArrivalTimeCam.h"
79#include "MBadPixelsCam.h"
80
81ClassImp(MGeomApply);
82
83using namespace std;
84
85// --------------------------------------------------------------------------
86//
87// Default constructor. MGeomCamMagic is the default geometry.
88//
89MGeomApply::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//
100Int_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//
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->InitSize(cam->GetNumPixels());
135
136 MCalibrationChargeCam *cal = (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
137 if (cal)
138 {
139 cal->InitSize(cam->GetNumPixels());
140 cal->InitAverageAreas(cam->GetNumAreas());
141 cal->InitAverageSectors(cam->GetNumSectors());
142 }
143
144
145 MCalibrationQECam *qe = (MCalibrationQECam*)pList->FindObject(AddSerialNumber("MCalibrationQECam"));
146 if (qe)
147 qe->InitSize(cam->GetNumPixels());
148
149 MPedPhotCam *pedphot = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
150 if (pedphot)
151 pedphot->InitSize(cam->GetNumPixels());
152
153 MExtractedSignalCam *ext = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
154 if (ext)
155 ext->InitSize(cam->GetNumPixels());
156
157 MBlindPixels *bnd = (MBlindPixels*)pList->FindObject(AddSerialNumber("MBlindPixels"));
158 if (bnd)
159 bnd->InitSize(cam->GetNumPixels());
160
161 MArrivalTimeCam *tme = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
162 if (tme)
163 tme->InitSize(cam->GetNumPixels());
164
165 MBadPixelsCam *bad = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
166 if (bad)
167 bad->InitSize(cam->GetNumPixels());
168
169 return kTRUE;
170}
171
172// --------------------------------------------------------------------------
173//
174// Implementation of SavePrimitive. Used to write the call to a constructor
175// to a macro. In the original root implementation it is used to write
176// gui elements to a macro-file.
177//
178void MGeomApply::StreamPrimitive(ofstream &out) const
179{
180 out << " " << ClassName() << " " << GetUniqueName() << "(\"";
181 out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
182
183 if (fGeomName.IsNull())
184 return;
185
186 out << " " << GetUniqueName() << ".SetGeometry(\"";
187 out << fGeomName << "\");" << endl;
188}
Note: See TracBrowser for help on using the repository browser.