source: tags/Mars-V0.8.1/mimage/MHillasSrcCalc.cc

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