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

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