source: trunk/MagicSoft/Mars/mtemp/MStarLocalPos.cc@ 4555

Last change on this file since 4555 was 4545, checked in by wittek, 21 years ago
*** empty log message ***
File size: 8.9 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 expressed
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Javier López , 4/2004 <mailto:jlopez@ifae.es>
19! Robert Wagner, 7/2004 <mailto:rwagner@mppmu.mpg.de>
20! Wolfgang Wittek, 8/2004 <mailto:wittek@mppmu.mpg.de>
21!
22! Copyright: MAGIC Software Development, 2000-2004
23!
24!
25\* ======================================================================== */
26#include "MStarLocalPos.h"
27
28#include <TEllipse.h>
29#include <TMarker.h>
30
31#include "MLog.h"
32#include "MLogManip.h"
33
34ClassImp(MStarLocalPos);
35
36using namespace std;
37
38MStarLocalPos::MStarLocalPos(const char *name, const char *title)
39{
40
41 fName = name ? name : "MStarLocalPos";
42 fTitle = title ? title : "";
43
44 Reset();
45}
46
47void MStarLocalPos::Reset()
48{
49
50 //Expected position on camera
51 fMagExp = 0.;
52 fXExp = 0.;
53 fYExp = 0.;
54
55 //Info from calculation
56 fMagCalc = 0.;
57 fMaxCalc = 0.;
58 fMeanXCalc = 0.;
59 fMeanYCalc = 0.;
60 fSigmaMinorAxisCalc = 0.;
61 fSigmaMajorAxisCalc = 0.;
62
63 //Info from uncorrelated Gauss fit
64 fMagFit = 0.;
65 fMaxFit = 0.;
66 fMeanXFit = 0.;
67 fMeanYFit = 0.;
68 fSigmaMinorAxisFit = 0.;
69 fSigmaMajorAxisFit = 0.;
70
71 fChiSquare = 0.;
72 fNdof = 1;
73
74 //Info from correlated Gauss fit
75 fMagCGFit = 0.;
76 fMaxCGFit = 0.;
77 fMeanXCGFit = 0.;
78 fMeanYCGFit = 0.;
79 fSigmaXCGFit = 0.;
80 fSigmaYCGFit = 0.;
81 fCorrXYCGFit = 0.;
82 fXXErrCGFit = 0.;
83 fXYErrCGFit = 0.;
84 fYYErrCGFit = 0.;
85
86 fChiSquareCGFit = 0.;
87 fNdofCGFit = 1;
88
89}
90
91void MStarLocalPos::SetExpValues(Float_t mag, Float_t x, Float_t y)
92{
93 fMagExp = mag;
94 fXExp = x;
95 fYExp = y;
96}
97
98void MStarLocalPos::SetCalcValues(Float_t mag, Float_t max,
99 Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis)
100{
101 fMagCalc = mag;
102 fMaxCalc = max;
103 fMeanXCalc = x;
104 fMeanYCalc = y;
105 fSigmaMinorAxisCalc = sigmaMinorAxis;
106 fSigmaMajorAxisCalc = sigmaMajorAxis;
107}
108
109void MStarLocalPos::SetFitValues(Float_t mag, Float_t max,
110 Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis,
111 Float_t chiSquare, Int_t ndof)
112{
113 fMagFit = mag;
114 fMaxFit = max;
115 fMeanXFit = x;
116 fMeanYFit = y;
117 fSigmaMinorAxisFit = sigmaMinorAxis;
118 fSigmaMajorAxisFit = sigmaMajorAxis;
119 fChiSquare = chiSquare;
120 fNdof = ndof;
121}
122
123void MStarLocalPos::SetFitValues(Float_t mag, Float_t max,
124 Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis,
125 Float_t chiSquare, Int_t ndof,
126 Float_t xx, Float_t xy, Float_t yy)
127{
128 SetFitValues(mag, max, x, y, sigmaMinorAxis, sigmaMajorAxis, chiSquare, ndof);
129 fXXErr = xx;
130 fYYErr = yy;
131 fXYErr = xy;
132}
133
134void MStarLocalPos::SetCGFitValues(
135 Float_t mag, Float_t max, Float_t x, Float_t y,
136 Float_t sigmaX, Float_t sigmaY, Float_t correlation,
137 Float_t xx, Float_t xy, Float_t yy,
138 Float_t chiSquare, Int_t ndof)
139{
140 fMagCGFit = mag;
141 fMaxCGFit = max;
142 fMeanXCGFit = x;
143 fMeanYCGFit = y;
144 fSigmaXCGFit = sigmaX;
145 fSigmaYCGFit = sigmaY;
146 fCorrXYCGFit = correlation;
147 fXXErrCGFit = xx;
148 fXYErrCGFit = xy;
149 fYYErrCGFit = yy;
150
151 fChiSquareCGFit = chiSquare;
152 fNdofCGFit = ndof;
153}
154
155
156// --------------------------------------------------------------------------
157//
158// Paint the ellipse corresponding to the parameters
159//
160void MStarLocalPos::Paint(Option_t *opt)
161{
162 //Print a cross in the expected position
163 TMarker mexp(fXExp, fYExp, 29);
164 mexp.SetMarkerSize(3);
165 mexp.SetMarkerColor(94);
166 mexp.Paint();
167
168 if (fSigmaMinorAxisCalc>0. && fSigmaMajorAxisCalc>0.)
169 {
170 TEllipse ecalc(fMeanXCalc, fMeanYCalc, fSigmaMinorAxisCalc, fSigmaMajorAxisCalc, 0, 360, 0);
171 ecalc.SetLineWidth(3);
172 ecalc.SetLineColor(kBlue);
173 ecalc.Paint();
174 }
175
176 if (fSigmaMinorAxisFit>0. && fSigmaMajorAxisFit>0.)
177 {
178 TEllipse efit(fMeanXFit, fMeanYFit, fSigmaMinorAxisFit, fSigmaMajorAxisFit, 0, 360, 0);
179 efit.SetLineWidth(3);
180 efit.SetLineColor(kBlack);
181 efit.Paint();
182 }
183
184 if (fSigmaXCGFit>0. && fSigmaYCGFit>0.)
185 {
186 //Print a cross in the fitted position
187 //TMarker mCGFit(fMeanXCGFit, fMeanYCGFit, 3);
188 //mCGFit.SetMarkerSize(3);
189 //mCGFit.SetMarkerColor(1);
190 //mCGFit.Paint();
191
192 Double_t cxx = fSigmaXCGFit*fSigmaXCGFit;
193 Double_t cyy = fSigmaYCGFit*fSigmaYCGFit;
194 Double_t d = cyy - cxx;
195 Double_t cxy = fCorrXYCGFit * fSigmaXCGFit * fSigmaYCGFit;
196 Double_t tandel;
197 if (cxy != 0.0)
198 tandel = ( d + sqrt(d*d + 4.0*cxy*cxy) ) / (2.0*cxy);
199 else
200 tandel = 0.0;
201
202 Double_t sindel = tandel / sqrt(1.0 + tandel*tandel);
203 Double_t delta = TMath::ASin(sindel);
204
205 Double_t major = (cxx + 2.0*tandel*cxy + tandel*tandel*cyy)
206 / (1.0 + tandel*tandel);
207
208 Double_t minor = (tandel*tandel*cxx - 2.0*tandel*cxy + cyy)
209 / (1.0 + tandel*tandel);
210
211 TEllipse efit(fMeanXCGFit, fMeanYCGFit, sqrt(major), sqrt(minor),
212 0, 360, delta*kRad2Deg);
213 efit.SetLineWidth(3);
214 efit.SetLineColor(kMagenta);
215 efit.Paint();
216 }
217}
218
219void MStarLocalPos::Print(Option_t *opt) const
220{
221 TString o = opt;
222
223 if (o.Contains("name", TString::kIgnoreCase) || opt == NULL)
224 {
225 *fLog << inf << "Star Name: \"" << this->GetName() << "\"" << endl;
226 }
227
228
229 if (o.Contains("mag", TString::kIgnoreCase) || opt == NULL)
230 {
231
232 *fLog << inf << "Star maginitude:" << endl;
233 *fLog << inf << " Expected \t" << setw(4) << fMagExp << endl;
234 *fLog << inf << " Calcultated \t " << setw(4) << fMagCalc << endl;
235 *fLog << inf << " Fitted \t " << setw(4) << fMagFit << endl;
236 *fLog << inf << " CGFitted \t " << setw(4) << fMagCGFit << endl;
237 }
238
239 if (o.Contains("max", TString::kIgnoreCase) || opt == NULL)
240 {
241 *fLog << inf << "Star Maximum:" << endl;
242 *fLog << inf << " Calcultated \t " << setw(4) << fMaxCalc << " uA"
243 << endl;
244 *fLog << inf << " Fitted \t " << setw(4) << fMaxFit << " uA" << endl;
245 *fLog << inf << " CGFitted \t " << setw(4) << fMaxCGFit << " uA" << endl;
246 }
247
248 if (o.Contains("pos", TString::kIgnoreCase) || opt == NULL)
249 {
250 *fLog << inf << "Star position:" << endl;
251 *fLog << inf << " Expected \t X " << setw(4) << fXExp
252 << " mm \tY " << setw(4) << fYExp << " mm" << endl;
253 *fLog << inf << " Calcultated \t X " << setw(4) << fMeanXCalc
254 << " mm \tY " << setw(4) << fMeanYCalc << " mm" << endl;
255 *fLog << inf << " Fitted \t X " << setw(4) << fMeanXFit
256 << " mm \tY " << setw(4) << fMeanYFit << " mm" << endl;
257 *fLog << inf << " CGFitted \t X " << setw(4) << fMeanXCGFit
258 << " mm \tY " << setw(4) << fMeanYCGFit << " mm" << endl;
259 }
260
261 if (o.Contains("siz", TString::kIgnoreCase) || opt == NULL)
262 {
263 *fLog << inf << "Star size:" << endl;
264 *fLog << inf << " Calcultated \t X " << setw(4) << fSigmaMinorAxisCalc
265 << " mm \tY " << setw(4) << fSigmaMajorAxisCalc << " mm" << endl;
266 *fLog << inf << " Fitted \t X " << setw(4) << fSigmaMinorAxisFit
267 << " mm \tY " << setw(4) << fSigmaMajorAxisFit << " mm" << endl;
268 *fLog << inf << " CGFitted \t X " << setw(4) << fSigmaXCGFit
269 << " mm \tY " << setw(4) << fSigmaYCGFit << " mm \t correlation"
270 << setw(4) << fCorrXYCGFit << endl;
271 }
272
273 if (o.Contains("chi", TString::kIgnoreCase) || opt == NULL)
274 {
275 *fLog << inf << "Star Fit Quality:" << endl;
276 *fLog << inf << " ChiSquare/Ndof \t " << setw(3) << fChiSquare
277 << "/" << fNdof << endl;
278
279 *fLog << inf << "Star CGFit Quality:" << endl;
280 *fLog << inf << " ChiSquareCGFit/NdofCGFit \t " << setw(3)
281 << fChiSquareCGFit << "/" << fNdofCGFit << endl;
282 }
283
284 if (o.Contains("err", TString::kIgnoreCase) || opt == NULL)
285 {
286 *fLog << inf << "CGFit Error Matrix of (fMeanXCGFit,fMeanYCGFit) :"
287 << endl;
288 *fLog << inf << " xx,xy,yy \t " << setw(3) << fXXErrCGFit << ", "
289 << fXYErrCGFit << ", " << fYYErrCGFit << endl;
290 }
291
292
293}
294//--------------------------------------------------------------------------
295
296
297
298
299
300
301
302
303
Note: See TracBrowser for help on using the repository browser.