source: trunk/MagicSoft/Mars/mimage/MHillasSrcCalc.cc@ 4693

Last change on this file since 4693 was 3666, 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 12/2000 <mailto:tbretz@uni-sw.gwdg.de>
19! Author(s): Rudolf Bock 10/2001 <mailto:Rudolf.Bock@cern.ch>
20!
21! Copyright: MAGIC Software Development, 2000-2002
22!
23!
24\* ======================================================================== */
25
26//////////////////////////////////////////////////////////////////////////////
27//
28// MHillasSrcCalc
29//
30// Task to calculate the source dependant part of the hillas parameters
31//
32// FIXME: Merge with MHillasCalc
33//
34// Input Containers:
35// MHillas
36// [MSrcPosCam]
37//
38// Output Containers:
39// MHillasSrc
40//
41//////////////////////////////////////////////////////////////////////////////
42#include "MHillasSrcCalc.h"
43
44#include <fstream>
45
46#include "MParList.h"
47
48#include "MSrcPosCam.h"
49#include "MHillasSrc.h"
50
51#include "MLog.h"
52#include "MLogManip.h"
53
54ClassImp(MHillasSrcCalc);
55
56using namespace std;
57
58static const TString gsDefName = "MHillasSrcCalc";
59static const TString gsDefTitle = "Calculate position dependant image parameters";
60
61// -------------------------------------------------------------------------
62//
63// Default constructor. The first argument is the name of a container
64// containing the source position in the camera plain (MScrPosCam).
65// The default is "MSrcPosCam". hil is the name of a container
66// of type MHillasSrc (or derived) in which the parameters are stored
67// The default is "MHillasSrc"
68//
69MHillasSrcCalc::MHillasSrcCalc(const char *src, const char *hil,
70 const char *name, const char *title)
71 : fHillas(NULL), fSrcPos(NULL), fHillasSrc(NULL)
72{
73 fName = name ? name : gsDefName.Data();
74 fTitle = title ? title : gsDefTitle.Data();
75
76 fSrcName = src;
77 fHillasName = hil;
78 fHillasInput = "MHillas";
79}
80
81// -------------------------------------------------------------------------
82//
83Int_t MHillasSrcCalc::PreProcess(MParList *pList)
84{
85 fHillas = (MHillas*)pList->FindObject(AddSerialNumber(fHillasInput), "MHillas");
86 if (!fHillas)
87 {
88 *fLog << err << dbginf << "MHillas not found... aborting." << endl;
89 return kFALSE;
90 }
91
92 fSrcPos = (MSrcPosCam*)pList->FindObject(AddSerialNumber(fSrcName), "MSrcPosCam");
93 if (!fSrcPos)
94 {
95 *fLog << warn << AddSerialNumber(fSrcName) << " [MSrcPosCam] not found... creating default container." << endl;
96 fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", AddSerialNumber(fSrcName));
97 if (!fSrcPos)
98 return kFALSE;
99 }
100
101 fHillasSrc = (MHillasSrc*)pList->FindCreateObj("MHillasSrc", AddSerialNumber(fHillasName));
102 if (!fHillasSrc)
103 return kFALSE;
104
105 fHillasSrc->SetSrcPos(fSrcPos);
106
107 fErrors = 0;
108
109 return kTRUE;
110}
111
112// -------------------------------------------------------------------------
113//
114Int_t MHillasSrcCalc::Process()
115{
116 if (!fHillasSrc->Calc(fHillas))
117 {
118 fErrors++;
119 return kCONTINUE;
120
121 }
122 return kTRUE;
123}
124
125// --------------------------------------------------------------------------
126//
127// Prints some statistics about the hillas calculation. The percentage
128// is calculated with respect to the number of executions of this task.
129//
130Int_t MHillasSrcCalc::PostProcess()
131{
132 if (GetNumExecutions()==0)
133 return kTRUE;
134
135 *fLog << inf << endl;
136 *fLog << GetDescriptor() << " execution statistics:" << endl;
137 *fLog << dec << setfill(' ');
138 *fLog << " " << fErrors << " (" << (int)(fErrors*100/GetNumExecutions()) << "%) Evts skipped due to: Dist==0" << endl;
139 *fLog << endl;
140
141 return kTRUE;
142}
143
144// --------------------------------------------------------------------------
145//
146// Implementation of SavePrimitive. Used to write the call to a constructor
147// to a macro. In the original root implementation it is used to write
148// gui elements to a macro-file.
149//
150void MHillasSrcCalc::StreamPrimitive(ofstream &out) const
151{
152 if (fHillas)
153 fHillas->SavePrimitive(out);
154
155 if (fSrcPos)
156 fSrcPos->SavePrimitive(out);
157
158 if (fHillasSrc)
159 fHillasSrc->SavePrimitive(out);
160
161 out << " MHillasSrcCalc " << GetUniqueName() << "(";
162
163 if (fSrcPos)
164 out << "&" << fSrcPos->GetUniqueName();
165 else
166 out << "\"" << fSrcName << "\"";
167
168 out << ", ";
169
170 if (fHillasSrc)
171 out << "&" << fHillasSrc->GetUniqueName();
172 else
173 out << "\"" << fHillasName << "\"";
174
175 if (fName!=gsDefName || fTitle!=gsDefTitle)
176 {
177 out << ", \"" << fName << "\"";
178 if (fTitle!=gsDefTitle)
179 out << ", \"" << fTitle << "\"";
180 }
181 out << ");" << endl;
182}
Note: See TracBrowser for help on using the repository browser.