source: trunk/MagicSoft/Mars/mtemp/meth/MStarLocalPos.cc@ 5468

Last change on this file since 5468 was 4415, checked in by stark, 20 years ago
*** empty log message ***
File size: 5.8 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): Javier López , 4/2004 <mailto:jlopez@ifae.es>
19!
20! Copyright: MAGIC Software Development, 2000-2004
21!
22!
23\* ======================================================================== */
24#include "MStarLocalPos.h"
25
26#include <TEllipse.h>
27
28#include "MLog.h"
29#include "MLogManip.h"
30
31ClassImp(MStarLocalPos);
32
33using namespace std;
34
35MStarLocalPos::MStarLocalPos(const char *name, const char *title)
36{
37
38 fName = name ? name : "MStarLocalPos";
39 fTitle = title ? title : "";
40
41 Reset();
42}
43
44void MStarLocalPos::Reset()
45{
46
47 //Expected position on camera
48 fMagExp = 0.;
49 fXExp = 0.;
50 fYExp = 0.;
51
52 //Info from calculation
53
54 fMagCalc = 0.;
55 fMaxCalc = 0.;
56 fMeanXCalc = 0.;
57 fMeanYCalc = 0.;
58 fSigmaMinorAxisCalc = 0.;
59 fSigmaMajorAxisCalc = 0.;
60
61 //Info from fit
62
63 fMagFit = 0.;
64 fBkFit = 0.;
65 fMaxFit = 0.;
66 fMeanXFit = 0.;
67 fMeanYFit = 0.;
68 fSigmaMinorAxisFit = 0.;
69 fSigmaMajorAxisFit = 0.;
70 fPhiFit = 0.;
71 fChiSquare = 0.;
72 fNdof = 1;
73
74}
75
76void MStarLocalPos::SetExpValues(Float_t mag, Float_t x, Float_t y)
77{
78 fMagExp = mag;
79 fXExp = x;
80 fYExp = y;
81}
82
83void MStarLocalPos::SetCalcValues(Float_t mag, Float_t max, Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis)
84{
85 fMagCalc = mag;
86 fMaxCalc = max;
87 fMeanXCalc = x;
88 fMeanYCalc = y;
89 fSigmaMinorAxisCalc = sigmaMinorAxis;
90 fSigmaMajorAxisCalc = sigmaMajorAxis;
91}
92
93void MStarLocalPos::SetFitValues(Float_t mag, Float_t max, Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis, Float_t chiSquare, Int_t ndof)
94{
95 fMagFit = mag;
96 fMaxFit = max;
97 fMeanXFit = x;
98 fMeanYFit = y;
99 fSigmaMinorAxisFit = sigmaMinorAxis;
100 fSigmaMajorAxisFit = sigmaMajorAxis;
101 fChiSquare = chiSquare;
102 fNdof = ndof;
103}
104
105void MStarLocalPos::SetFitValues(Float_t mag, Float_t bk, Float_t max, Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis, Float_t phi, Float_t chiSquare, Int_t ndof)
106{
107 fMagFit = mag;
108 fBkFit = bk;
109 fMaxFit = max;
110 fMeanXFit = x;
111 fMeanYFit = y;
112 fSigmaMinorAxisFit = sigmaMinorAxis;
113 fSigmaMajorAxisFit = sigmaMajorAxis;
114 fPhiFit = phi;
115 fChiSquare = chiSquare;
116 fNdof = ndof;
117}
118
119// --------------------------------------------------------------------------
120//
121// Paint the ellipse corresponding to the parameters
122//
123void MStarLocalPos::Paint(Option_t *opt)
124{
125 //Print a cross in the expected position
126
127 if (fSigmaMinorAxisCalc>0. && fSigmaMajorAxisCalc>0.)
128 {
129 TEllipse ecalc(fMeanXCalc, fMeanYCalc, fSigmaMinorAxisCalc, fSigmaMajorAxisCalc, 0, 360, 0);
130 ecalc.SetLineWidth(2);
131 ecalc.SetLineColor(kRed);
132 ecalc.Paint();
133 }
134
135 if (fSigmaMinorAxisFit>0. || fSigmaMajorAxisFit>0.)
136 {
137 TEllipse efit(fMeanXFit, fMeanYFit, fSigmaMinorAxisFit, fSigmaMajorAxisFit, 0, 360, fPhiFit);
138 efit.SetLineWidth(2);
139 efit.SetLineColor(kBlack);
140 efit.Paint();
141 }
142}
143
144void MStarLocalPos::Print(Option_t *opt) const
145{
146 TString o = opt;
147
148 if (o.Contains("mag", TString::kIgnoreCase) || opt == NULL)
149 {
150 *fLog << inf << "Star maginitude:" << endl;
151 *fLog << inf << " Expected \t" << setw(4) << fMagExp << endl;
152 *fLog << inf << " Calcultated \t " << setw(4) << fMagCalc << endl;
153 *fLog << inf << " Fitted \t " << setw(4) << fMagFit << endl;
154 }
155
156 if (o.Contains("bk", TString::kIgnoreCase) || opt == NULL)
157 {
158 *fLog << inf << "Background:" << endl;
159 *fLog << inf << " Fitted \t " << setw(4) << fBkFit << " uA" << endl;
160 }
161
162 if (o.Contains("max", TString::kIgnoreCase) || opt == NULL)
163 {
164 *fLog << inf << "Star Maximum:" << endl;
165 *fLog << inf << " Calcultated \t " << setw(4) << fMaxCalc << " uA" << endl;
166 *fLog << inf << " Fitted \t " << setw(4) << fMaxFit << " uA" << endl;
167 }
168
169 if (o.Contains("pos", TString::kIgnoreCase) || opt == NULL)
170 {
171 *fLog << inf << "Star position:" << endl;
172 *fLog << inf << " Expected \t X " << setw(4) << fXExp << " mm \tY " << setw(4) << fYExp << " mm" << endl;
173 *fLog << inf << " Calcultated \t X " << setw(4) << fMeanXCalc << " mm \tY " << setw(4) << fMeanYCalc << " mm" << endl;
174 *fLog << inf << " Fitted \t X " << setw(4) << fMeanXFit << " mm \tY " << setw(4) << fMeanYFit << " mm" << endl;
175 }
176
177 if (o.Contains("rot", TString::kIgnoreCase) || opt == NULL)
178 {
179 *fLog << inf << "Rotation of ellipse:" << endl;
180 *fLog << inf << " Fitted \t " << setw(4) << fPhiFit << " rad " << endl;
181 }
182
183 if (o.Contains("siz", TString::kIgnoreCase) || opt == NULL)
184 {
185 *fLog << inf << "Star size:" << endl;
186 *fLog << inf << " Calcultated \t X " << setw(4) << fSigmaMinorAxisCalc << " mm \tY " << setw(4) << fSigmaMajorAxisCalc << " mm" << endl;
187 *fLog << inf << " Fitted \t X " << setw(4) << fSigmaMinorAxisFit << " mm \tY " << setw(4) << fSigmaMajorAxisFit << " mm" << endl;
188 }
189
190 if (o.Contains("chi", TString::kIgnoreCase) || opt == NULL)
191 {
192 *fLog << inf << "Star Fit Quality:" << endl;
193 *fLog << inf << " ChiSquare/Ndof \t " << setw(3) << fChiSquare << "/" << fNdof << endl;
194 }
195}
196
Note: See TracBrowser for help on using the repository browser.