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

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