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 |
|
---|
45 | ClassImp(MHillasSrcCalc);
|
---|
46 |
|
---|
47 | // -------------------------------------------------------------------------
|
---|
48 | //
|
---|
49 | // Default constructor. The first argument is the name of a container
|
---|
50 | // containing the source position in the camera plain (MScrPosCam).
|
---|
51 | // The default is "MSrcPosCam". hil is the name of a container
|
---|
52 | // of type MHillasSrc (or derived) in which the parameters are stored
|
---|
53 | // The default is "MHillasSrc"
|
---|
54 | //
|
---|
55 | MHillasSrcCalc::MHillasSrcCalc(const char *src, const char *hil,
|
---|
56 | const char *name, const char *title)
|
---|
57 | {
|
---|
58 | fName = name ? name : "MHillasSrcCalc";
|
---|
59 | fTitle = title ? title : "add parameters dependent on source position (MHillasSrc)";
|
---|
60 |
|
---|
61 | fSrcName = src;
|
---|
62 | fHillasName = hil;
|
---|
63 | }
|
---|
64 |
|
---|
65 | // -------------------------------------------------------------------------
|
---|
66 | //
|
---|
67 | Bool_t MHillasSrcCalc::PreProcess(MParList *pList)
|
---|
68 | {
|
---|
69 | fHillas = (MHillas*)pList->FindObject("MHillas");
|
---|
70 | if (!fHillas)
|
---|
71 | {
|
---|
72 | *fLog << err << dbginf << "MHillas not found... aborting." << endl;
|
---|
73 | return kFALSE;
|
---|
74 | }
|
---|
75 |
|
---|
76 | fSrcPos = (MSrcPosCam*)pList->FindObject(fSrcName, "MSrcPosCam");
|
---|
77 | if (!fSrcPos)
|
---|
78 | {
|
---|
79 | *fLog << err << dbginf << fSrcName << " [MSrcPosCam] not found... aborting." << endl;
|
---|
80 | return kFALSE;
|
---|
81 | }
|
---|
82 |
|
---|
83 | fHillasSrc = (MHillasSrc*)pList->FindCreateObj("MHillasSrc", fHillasName);
|
---|
84 | if (!fHillasSrc)
|
---|
85 | return kFALSE;
|
---|
86 |
|
---|
87 | fHillasSrc->SetSrcPos(fSrcPos);
|
---|
88 |
|
---|
89 | return kTRUE;
|
---|
90 | }
|
---|
91 |
|
---|
92 | // -------------------------------------------------------------------------
|
---|
93 | //
|
---|
94 | Bool_t MHillasSrcCalc::Process()
|
---|
95 | {
|
---|
96 | return fHillasSrc->Calc(fHillas) ? kTRUE : kCONTINUE;
|
---|
97 | }
|
---|
98 |
|
---|
99 |
|
---|
100 | // --------------------------------------------------------------------------
|
---|
101 | //
|
---|
102 | // Implementation of SavePrimitive. Used to write the call to a constructor
|
---|
103 | // to a macro. In the original root implementation it is used to write
|
---|
104 | // gui elements to a macro-file.
|
---|
105 | //
|
---|
106 | void MHillasSrcCalc::StreamPrimitive(ofstream &out) const
|
---|
107 | {
|
---|
108 | if (fHillas)
|
---|
109 | fHillas->SavePrimitive(out);
|
---|
110 |
|
---|
111 | if (fSrcPos)
|
---|
112 | fSrcPos->SavePrimitive(out);
|
---|
113 |
|
---|
114 | if (fHillasSrc)
|
---|
115 | fHillasSrc->SavePrimitive(out);
|
---|
116 |
|
---|
117 | out << " MHillasSrcCalc " << ToLower(fName) << "(";
|
---|
118 |
|
---|
119 | if (fSrcPos)
|
---|
120 | out << "&" << ToLower(fSrcPos->GetName());
|
---|
121 | else
|
---|
122 | out << "\"" << fSrcName << "\"";
|
---|
123 |
|
---|
124 | if (fHillasSrc)
|
---|
125 | out << "&" << ToLower(fHillasSrc->GetName());
|
---|
126 | else
|
---|
127 | out << "\"" << fHillasName << "\"";
|
---|
128 |
|
---|
129 | out << ", \"" << fName << "\", \"" << fTitle << "\");" << endl;
|
---|
130 | }
|
---|