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): Wolfgang Wittek 03/2003 <mailto:wittek@mppmu.mpg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | //////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // MNewImageParCalc
|
---|
28 | //
|
---|
29 | // Task to calculate the source dependant part of the hillas parameters
|
---|
30 | //
|
---|
31 | //////////////////////////////////////////////////////////////////////////////
|
---|
32 | #include "MNewImageParCalc.h"
|
---|
33 |
|
---|
34 | #include <fstream.h>
|
---|
35 |
|
---|
36 | #include "MParList.h"
|
---|
37 |
|
---|
38 | #include "MGeomCam.h"
|
---|
39 | #include "MSrcPosCam.h"
|
---|
40 | #include "MCerPhotEvt.h"
|
---|
41 | #include "MNewImagePar.h"
|
---|
42 | #include "MNewImagePar.h"
|
---|
43 | #include "MLog.h"
|
---|
44 | #include "MLogManip.h"
|
---|
45 |
|
---|
46 | ClassImp(MNewImageParCalc);
|
---|
47 |
|
---|
48 | static const TString gsDefName = "MNewImageParCalc";
|
---|
49 | static const TString gsDefTitle = "Calculate new image parameters";
|
---|
50 |
|
---|
51 | // -------------------------------------------------------------------------
|
---|
52 | //
|
---|
53 | // Default constructor. The first argument is the name of a container
|
---|
54 | // containing the source position in the camera plain (MScrPosCam).
|
---|
55 | // The default is "MSrcPosCam". newpar is the name of a container
|
---|
56 | // of type MNewImagePar, in which the parameters are stored.
|
---|
57 | // The default is "MNewImagePar"
|
---|
58 | //
|
---|
59 | //
|
---|
60 | MNewImageParCalc::MNewImageParCalc(const char *src, const char *newpar,
|
---|
61 | const char *name, const char *title)
|
---|
62 | : fHillas(NULL), fSrcPos(NULL), fNewImagePar(NULL)
|
---|
63 | {
|
---|
64 | fName = name ? name : gsDefName.Data();
|
---|
65 | fTitle = title ? title : gsDefTitle.Data();
|
---|
66 |
|
---|
67 | fSrcName = src;
|
---|
68 | fNewParName = newpar;
|
---|
69 | fHillasInput = "MHillas";
|
---|
70 | }
|
---|
71 |
|
---|
72 | // -------------------------------------------------------------------------
|
---|
73 | //
|
---|
74 | Bool_t MNewImageParCalc::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 << err << dbginf << fSrcName << " [MSrcPosCam] not found... aborting." << endl;
|
---|
87 | return kFALSE;
|
---|
88 | }
|
---|
89 |
|
---|
90 | fCerPhotEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
|
---|
91 | if (!fCerPhotEvt)
|
---|
92 | {
|
---|
93 | *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
|
---|
94 | return kFALSE;
|
---|
95 | }
|
---|
96 |
|
---|
97 | fGeomCam = (MGeomCam*)pList->FindObject("MGeomCam");
|
---|
98 | if (!fGeomCam)
|
---|
99 | {
|
---|
100 | *fLog << dbginf << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
|
---|
101 | return kFALSE;
|
---|
102 | }
|
---|
103 |
|
---|
104 |
|
---|
105 | fNewImagePar = (MNewImagePar*)pList->FindCreateObj("MNewImagePar", fNewParName);
|
---|
106 | if (!fNewImagePar)
|
---|
107 | return kFALSE;
|
---|
108 |
|
---|
109 | fErrors = 0;
|
---|
110 |
|
---|
111 | return kTRUE;
|
---|
112 | }
|
---|
113 |
|
---|
114 | // -------------------------------------------------------------------------
|
---|
115 | //
|
---|
116 | Bool_t MNewImageParCalc::Process()
|
---|
117 | {
|
---|
118 |
|
---|
119 | if (!fNewImagePar->Calc(*fGeomCam, *fCerPhotEvt, fHillas))
|
---|
120 | {
|
---|
121 | fErrors++;
|
---|
122 | return kCONTINUE;
|
---|
123 |
|
---|
124 | }
|
---|
125 | return kTRUE;
|
---|
126 | }
|
---|
127 |
|
---|
128 | // --------------------------------------------------------------------------
|
---|
129 | //
|
---|
130 | // Prints some statistics about the hillas calculation. The percentage
|
---|
131 | // is calculated with respect to the number of executions of this task.
|
---|
132 | //
|
---|
133 | Bool_t MNewImageParCalc::PostProcess()
|
---|
134 | {
|
---|
135 | if (GetNumExecutions()==0)
|
---|
136 | return kTRUE;
|
---|
137 |
|
---|
138 | *fLog << inf << endl;
|
---|
139 | *fLog << GetDescriptor() << " execution statistics:" << endl;
|
---|
140 | *fLog << dec << setfill(' ');
|
---|
141 | *fLog << " " << fErrors << " (" << (int)(fErrors*100/GetNumExecutions()) << "%) Evts skipped due to: calculation failed" << endl;
|
---|
142 | *fLog << endl;
|
---|
143 |
|
---|
144 | return kTRUE;
|
---|
145 | }
|
---|
146 |
|
---|
147 | // --------------------------------------------------------------------------
|
---|
148 |
|
---|
149 |
|
---|
150 |
|
---|
151 |
|
---|
152 |
|
---|
153 |
|
---|
154 |
|
---|
155 |
|
---|
156 |
|
---|
157 |
|
---|
158 |
|
---|
159 |
|
---|