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

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