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 10/2003 <mailto:wittek@mppmu.mpg.de>
|
---|
19 | !
|
---|
20 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
21 | !
|
---|
22 | !
|
---|
23 | \* ======================================================================== */
|
---|
24 |
|
---|
25 | //////////////////////////////////////////////////////////////////////////////
|
---|
26 | //
|
---|
27 | // M2dimFunctionFit
|
---|
28 | //
|
---|
29 | // Task to fit a 2-dim function to the shower image
|
---|
30 | //
|
---|
31 | //////////////////////////////////////////////////////////////////////////////
|
---|
32 | #include "M2dimFunctionFit.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(M2dimFunctionFit);
|
---|
47 |
|
---|
48 | static const TString gsDefName = "M2dimFunctionFit";
|
---|
49 | static const TString gsDefTitle = "Fit 2-dim function";
|
---|
50 |
|
---|
51 | // -------------------------------------------------------------------------
|
---|
52 | //
|
---|
53 | // Default constructor.
|
---|
54 | //
|
---|
55 | // twodimfunname is the name of a container of type M2dimFunction,
|
---|
56 | // in which the parameters are stored; the default is "M2dimFunction"
|
---|
57 | //
|
---|
58 | //
|
---|
59 | M2dimFunctionFit::M2dimFunctionFit(const char *twodimfunname,
|
---|
60 | const char *name, const char *title)
|
---|
61 | {
|
---|
62 | fName = name ? name : gsDefName.Data();
|
---|
63 | fTitle = title ? title : gsDefTitle.Data();
|
---|
64 |
|
---|
65 | f2dimFunName = twodimfunname;
|
---|
66 | fHillasInput = "MHillas";
|
---|
67 | }
|
---|
68 |
|
---|
69 | // -------------------------------------------------------------------------
|
---|
70 | //
|
---|
71 | Int_t M2dimFunctionFit::PreProcess(MParList *pList)
|
---|
72 | {
|
---|
73 | fHillas = (MHillas*)pList->FindObject(fHillasInput, "MHillas");
|
---|
74 | if (!fHillas)
|
---|
75 | {
|
---|
76 | *fLog << err << dbginf << "MHillas not found... aborting." << endl;
|
---|
77 | return kFALSE;
|
---|
78 | }
|
---|
79 |
|
---|
80 |
|
---|
81 | fCerPhotEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
|
---|
82 | if (!fCerPhotEvt)
|
---|
83 | {
|
---|
84 | *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
|
---|
85 | return kFALSE;
|
---|
86 | }
|
---|
87 |
|
---|
88 | fGeomCam = (MGeomCam*)pList->FindObject("MGeomCam");
|
---|
89 | if (!fGeomCam)
|
---|
90 | {
|
---|
91 | *fLog << dbginf << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
|
---|
92 | return kFALSE;
|
---|
93 | }
|
---|
94 |
|
---|
95 | f2dimfun = (M2dimFunction*)pList->FindCreateObj("M2dimFunction", f2dimFunName);
|
---|
96 | if (!f2dimfun)
|
---|
97 | {
|
---|
98 | *fLog << dbginf << "M2dimFunction object '" << f2dimFunName
|
---|
99 | << "' not found... aborting." << endl;
|
---|
100 | return kFALSE;
|
---|
101 | }
|
---|
102 |
|
---|
103 | fErrors = 0;
|
---|
104 |
|
---|
105 | return kTRUE;
|
---|
106 | }
|
---|
107 |
|
---|
108 | // -------------------------------------------------------------------------
|
---|
109 | //
|
---|
110 | // fit 2-dim function to the shower image
|
---|
111 | //
|
---|
112 |
|
---|
113 | Int_t M2dimFunctionFit::Process()
|
---|
114 | {
|
---|
115 | Bool_t rc = f2dimfun->Fit();
|
---|
116 | if (!rc)
|
---|
117 | {
|
---|
118 | fErrors++;
|
---|
119 | return kCONTINUE;
|
---|
120 | }
|
---|
121 |
|
---|
122 | return kTRUE;
|
---|
123 | }
|
---|
124 |
|
---|
125 | // --------------------------------------------------------------------------
|
---|
126 | //
|
---|
127 | // Prints some statistics about the hillas calculation. The percentage
|
---|
128 | // is calculated with respect to the number of executions of this task.
|
---|
129 | //
|
---|
130 | /*
|
---|
131 | Bool_t M2dimFunctionFit::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: fit of 2-dim function failed" << endl;
|
---|
140 | *fLog << endl;
|
---|
141 |
|
---|
142 | return kTRUE;
|
---|
143 | }
|
---|
144 | */
|
---|
145 |
|
---|