source: trunk/MagicSoft/Mars/manalysis/MHillasSrcCalc.cc@ 1762

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