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

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