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

Last change on this file since 3534 was 3431, checked in by gaug, 21 years ago
*** empty log message ***
File size: 5.4 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!
20! Copyright: MAGIC Software Development, 2000-2004
21!
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// MPedPhotCam
37// MExtractedSignalCam
38// MBlindPixels
39// MArrivalTime
40// MArrivalTimeCam
41// MArrivalTimePix
42//
43// It uses the geometry (MGeomCam) found in the parameter list.
44// If it is not found the task tries to create the geometry
45// specified in the constructor. The default geometry is
46// MGeomCamMagic.
47//
48// Input Containers:
49// [MGeomCam]
50//
51// Output Containers:
52// [MPedestalCam]
53// [MCalibrationChargeCam]
54// [MPedPhotCam]
55// [MExtractedSignalCam]
56// [MBlindPixels]
57// [MArrivalTime]
58// [MArrivalTimeCam]
59//
60//////////////////////////////////////////////////////////////////////////////
61#include "MGeomApply.h"
62
63#include <fstream>
64
65#include "MLog.h"
66#include "MLogManip.h"
67
68#include "MParList.h"
69
70#include "MGeomCam.h"
71#include "MPedestalCam.h"
72#include "MCalibrationChargeCam.h"
73#include "MPedPhotCam.h"
74#include "MExtractedSignalCam.h"
75#include "MBlindPixels.h"
76#include "MArrivalTimeCam.h"
77#include "MBadPixelsCam.h"
78
79ClassImp(MGeomApply);
80
81using namespace std;
82
83// --------------------------------------------------------------------------
84//
85// Default constructor. MGeomCamMagic is the default geometry.
86//
87MGeomApply::MGeomApply(const char *name, const char *title) : fGeomName("MGeomCamMagic")
88{
89 fName = name ? name : "MGeomApply";
90 fTitle = title ? title : "Task to apply geometry settings";
91}
92
93// --------------------------------------------------------------------------
94//
95// Try to find 'MGeomCam' in the Parameter List. If it is not found,
96// try to create a fGeomName object.
97//
98Int_t MGeomApply::PreProcess(MParList *pList)
99{
100 MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
101 if (cam)
102 return kTRUE;
103
104 cam = (MGeomCam*)pList->FindCreateObj(AddSerialNumber(fGeomName), "MGeomCam");
105
106 return cam ? kTRUE : kFALSE;
107}
108
109// --------------------------------------------------------------------------
110//
111// Try to find 'MGeomCam' in the Parameter List. If it is not found,
112// processing is stopped.
113//
114// The size of MPedestalCam and MBlindPixels is set accordingly.
115//
116Bool_t MGeomApply::ReInit(MParList *pList)
117{
118 MGeomCam *cam = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
119 if (!cam)
120 {
121 *fLog << err << GetDescriptor() << ": No MGeomCam found... aborting." << endl;
122 return kFALSE;
123 }
124
125 // FIXME, workaround: this call to CalcPixRatio is here just to allow
126 // the use of some camera files from the 0.7 beta version in which the
127 // array containing pixel ratios is not initialized.
128 cam->CalcPixRatio();
129
130 MPedestalCam *ped = (MPedestalCam*)pList->FindObject(AddSerialNumber("MPedestalCam"));
131 if (ped)
132 ped->InitSize(cam->GetNumPixels());
133
134 MCalibrationChargeCam *cal = (MCalibrationChargeCam*)pList->FindObject(AddSerialNumber("MCalibrationChargeCam"));
135 if (cal)
136 cal->InitSize(cam->GetNumPixels());
137
138 MPedPhotCam *pedphot = (MPedPhotCam*)pList->FindObject(AddSerialNumber("MPedPhotCam"));
139 if (pedphot)
140 pedphot->InitSize(cam->GetNumPixels());
141
142 MExtractedSignalCam *ext = (MExtractedSignalCam*)pList->FindObject(AddSerialNumber("MExtractedSignalCam"));
143 if (ext)
144 ext->InitSize(cam->GetNumPixels());
145
146 MBlindPixels *bnd = (MBlindPixels*)pList->FindObject(AddSerialNumber("MBlindPixels"));
147 if (bnd)
148 bnd->InitSize(cam->GetNumPixels());
149
150 MArrivalTimeCam *tme = (MArrivalTimeCam*)pList->FindObject(AddSerialNumber("MArrivalTimeCam"));
151 if (tme)
152 tme->InitSize(cam->GetNumPixels());
153
154 MBadPixelsCam *bad = (MBadPixelsCam*)pList->FindObject(AddSerialNumber("MBadPixelsCam"));
155 if (bad)
156 bad->InitSize(cam->GetNumPixels());
157
158 return kTRUE;
159}
160
161// --------------------------------------------------------------------------
162//
163// Implementation of SavePrimitive. Used to write the call to a constructor
164// to a macro. In the original root implementation it is used to write
165// gui elements to a macro-file.
166//
167void MGeomApply::StreamPrimitive(ofstream &out) const
168{
169 out << " " << ClassName() << " " << GetUniqueName() << "(\"";
170 out << "\"" << fName << "\", \"" << fTitle << "\");" << endl;
171
172 if (fGeomName.IsNull())
173 return;
174
175 out << " " << GetUniqueName() << ".SetGeometry(\"";
176 out << fGeomName << "\");" << endl;
177}
Note: See TracBrowser for help on using the repository browser.