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 |
|
---|
34 | ClassImp(MStarLocalPos);
|
---|
35 |
|
---|
36 | using namespace std;
|
---|
37 |
|
---|
38 | MStarLocalPos::MStarLocalPos(const char *name, const char *title)
|
---|
39 | {
|
---|
40 |
|
---|
41 | fName = name ? name : "MStarLocalPos";
|
---|
42 | fTitle = title ? title : "";
|
---|
43 |
|
---|
44 | Reset();
|
---|
45 | }
|
---|
46 |
|
---|
47 | void 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 |
|
---|
91 | void MStarLocalPos::SetExpValues(Float_t mag, Float_t x, Float_t y)
|
---|
92 | {
|
---|
93 | fMagExp = mag;
|
---|
94 | fXExp = x;
|
---|
95 | fYExp = y;
|
---|
96 | }
|
---|
97 |
|
---|
98 | void MStarLocalPos::SetIdealValues(Float_t mag, Float_t x, Float_t y)
|
---|
99 | {
|
---|
100 | fMagIdeal = mag;
|
---|
101 | fXIdeal = x;
|
---|
102 | fYIdeal = y;
|
---|
103 | }
|
---|
104 |
|
---|
105 | void MStarLocalPos::SetCalcValues(Float_t mag, Float_t max,
|
---|
106 | Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis)
|
---|
107 | {
|
---|
108 | fMagCalc = mag;
|
---|
109 | fMaxCalc = max;
|
---|
110 | fMeanXCalc = x;
|
---|
111 | fMeanYCalc = y;
|
---|
112 | fSigmaMinorAxisCalc = sigmaMinorAxis;
|
---|
113 | fSigmaMajorAxisCalc = sigmaMajorAxis;
|
---|
114 | }
|
---|
115 |
|
---|
116 | void MStarLocalPos::SetFitValues(Float_t mag, Float_t max,
|
---|
117 | Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis,
|
---|
118 | Float_t chiSquare, Int_t ndof)
|
---|
119 | {
|
---|
120 | fMagFit = mag;
|
---|
121 | fMaxFit = max;
|
---|
122 | fMeanXFit = x;
|
---|
123 | fMeanYFit = y;
|
---|
124 | fSigmaMinorAxisFit = sigmaMinorAxis;
|
---|
125 | fSigmaMajorAxisFit = sigmaMajorAxis;
|
---|
126 | fChiSquare = chiSquare;
|
---|
127 | fNdof = ndof;
|
---|
128 | }
|
---|
129 |
|
---|
130 | void MStarLocalPos::SetFitValues(Float_t mag, Float_t max,
|
---|
131 | Float_t x, Float_t y, Float_t sigmaMinorAxis, Float_t sigmaMajorAxis,
|
---|
132 | Float_t chiSquare, Int_t ndof,
|
---|
133 | Float_t xx, Float_t xy, Float_t yy)
|
---|
134 | {
|
---|
135 | SetFitValues(mag, max, x, y, sigmaMinorAxis, sigmaMajorAxis, chiSquare, ndof);
|
---|
136 | fXXErr = xx;
|
---|
137 | fYYErr = yy;
|
---|
138 | fXYErr = xy;
|
---|
139 | }
|
---|
140 |
|
---|
141 | void MStarLocalPos::SetCGFitValues(
|
---|
142 | Float_t mag, Float_t max, Float_t x, Float_t y,
|
---|
143 | Float_t sigmaX, Float_t sigmaY, Float_t correlation,
|
---|
144 | Float_t xx, Float_t xy, Float_t yy,
|
---|
145 | Float_t chiSquare, Int_t ndof)
|
---|
146 | {
|
---|
147 | fMagCGFit = mag;
|
---|
148 | fMaxCGFit = max;
|
---|
149 | fMeanXCGFit = x;
|
---|
150 | fMeanYCGFit = y;
|
---|
151 | fSigmaXCGFit = sigmaX;
|
---|
152 | fSigmaYCGFit = sigmaY;
|
---|
153 | fCorrXYCGFit = correlation;
|
---|
154 | fXXErrCGFit = xx;
|
---|
155 | fXYErrCGFit = xy;
|
---|
156 | fYYErrCGFit = yy;
|
---|
157 |
|
---|
158 | fChiSquareCGFit = chiSquare;
|
---|
159 | fNdofCGFit = ndof;
|
---|
160 | }
|
---|
161 |
|
---|
162 |
|
---|
163 | // --------------------------------------------------------------------------
|
---|
164 | //
|
---|
165 | // Paint the ellipse corresponding to the parameters
|
---|
166 | //
|
---|
167 | void MStarLocalPos::Paint(Option_t *opt)
|
---|
168 | {
|
---|
169 | //Print a cross in the expected position
|
---|
170 | TMarker mexp(fXExp, fYExp, 29);
|
---|
171 | mexp.SetMarkerSize(3);
|
---|
172 | mexp.SetMarkerColor(94);
|
---|
173 | mexp.Paint();
|
---|
174 |
|
---|
175 | if (fSigmaMinorAxisCalc>0. && fSigmaMajorAxisCalc>0.)
|
---|
176 | {
|
---|
177 | TEllipse ecalc(fMeanXCalc, fMeanYCalc, fSigmaMinorAxisCalc, fSigmaMajorAxisCalc, 0, 360, 0);
|
---|
178 | ecalc.SetLineWidth(3);
|
---|
179 | ecalc.SetLineColor(kBlue);
|
---|
180 | ecalc.Paint();
|
---|
181 | }
|
---|
182 |
|
---|
183 | if (fSigmaMinorAxisFit>0. && fSigmaMajorAxisFit>0.)
|
---|
184 | {
|
---|
185 | TEllipse efit(fMeanXFit, fMeanYFit, fSigmaMinorAxisFit, fSigmaMajorAxisFit, 0, 360, 0);
|
---|
186 | efit.SetLineWidth(3);
|
---|
187 | efit.SetLineColor(kBlack);
|
---|
188 | efit.Paint();
|
---|
189 | }
|
---|
190 |
|
---|
191 | if (fSigmaXCGFit>0. && fSigmaYCGFit>0.)
|
---|
192 | {
|
---|
193 | //Print a cross in the fitted position
|
---|
194 | //TMarker mCGFit(fMeanXCGFit, fMeanYCGFit, 3);
|
---|
195 | //mCGFit.SetMarkerSize(3);
|
---|
196 | //mCGFit.SetMarkerColor(1);
|
---|
197 | //mCGFit.Paint();
|
---|
198 |
|
---|
199 | Double_t cxx = fSigmaXCGFit*fSigmaXCGFit;
|
---|
200 | Double_t cyy = fSigmaYCGFit*fSigmaYCGFit;
|
---|
201 | Double_t d = cyy - cxx;
|
---|
202 | Double_t cxy = fCorrXYCGFit * fSigmaXCGFit * fSigmaYCGFit;
|
---|
203 | Double_t tandel;
|
---|
204 | if (cxy != 0.0)
|
---|
205 | tandel = ( d + sqrt(d*d + 4.0*cxy*cxy) ) / (2.0*cxy);
|
---|
206 | else
|
---|
207 | tandel = 0.0;
|
---|
208 |
|
---|
209 | Double_t sindel = tandel / sqrt(1.0 + tandel*tandel);
|
---|
210 | Double_t delta = TMath::ASin(sindel);
|
---|
211 |
|
---|
212 | Double_t major = (cxx + 2.0*tandel*cxy + tandel*tandel*cyy)
|
---|
213 | / (1.0 + tandel*tandel);
|
---|
214 |
|
---|
215 | Double_t minor = (tandel*tandel*cxx - 2.0*tandel*cxy + cyy)
|
---|
216 | / (1.0 + tandel*tandel);
|
---|
217 |
|
---|
218 | TEllipse efit(fMeanXCGFit, fMeanYCGFit, sqrt(major), sqrt(minor),
|
---|
219 | 0, 360, delta*kRad2Deg);
|
---|
220 | efit.SetLineWidth(3);
|
---|
221 | efit.SetLineColor(kMagenta);
|
---|
222 | efit.Paint();
|
---|
223 | }
|
---|
224 | }
|
---|
225 |
|
---|
226 | void MStarLocalPos::Print(Option_t *opt) const
|
---|
227 | {
|
---|
228 | TString o = opt;
|
---|
229 |
|
---|
230 | if (o.Contains("name", TString::kIgnoreCase) || opt == NULL)
|
---|
231 | {
|
---|
232 | *fLog << inf << "Star Name: \"" << this->GetName() << "\"" << endl;
|
---|
233 | }
|
---|
234 |
|
---|
235 | if (o.Contains("mag", TString::kIgnoreCase) || opt == NULL)
|
---|
236 | {
|
---|
237 |
|
---|
238 | *fLog << inf << "Star magnitude:" << endl;
|
---|
239 | *fLog << inf << " Expected \t" << setw(4) << fMagExp << endl;
|
---|
240 | *fLog << inf << " Calcultated \t " << setw(4) << fMagCalc << endl;
|
---|
241 | *fLog << inf << " Fitted \t " << setw(4) << fMagFit << endl;
|
---|
242 | *fLog << inf << " CGFitted \t " << setw(4) << fMagCGFit << endl;
|
---|
243 | }
|
---|
244 |
|
---|
245 | if (o.Contains("max", TString::kIgnoreCase) || opt == NULL)
|
---|
246 | {
|
---|
247 | *fLog << inf << "Star Maximum:" << endl;
|
---|
248 | *fLog << inf << " Calcultated \t " << setw(4) << fMaxCalc << " uA"
|
---|
249 | << endl;
|
---|
250 | *fLog << inf << " Fitted \t " << setw(4) << fMaxFit << " uA" << endl;
|
---|
251 | *fLog << inf << " CGFitted \t " << setw(4) << fMaxCGFit << " uA" << endl;
|
---|
252 | }
|
---|
253 |
|
---|
254 | if (o.Contains("pos", TString::kIgnoreCase) || opt == NULL)
|
---|
255 | {
|
---|
256 | *fLog << inf << "Star position:" << endl;
|
---|
257 | *fLog << inf << " Expected \t X " << setw(4) << fXExp
|
---|
258 | << " mm \tY " << setw(4) << fYExp << " mm" << endl;
|
---|
259 | *fLog << inf << " Calcultated \t X " << setw(4) << fMeanXCalc
|
---|
260 | << " mm \tY " << setw(4) << fMeanYCalc << " mm" << endl;
|
---|
261 | *fLog << inf << " Fitted \t X " << setw(4) << fMeanXFit
|
---|
262 | << " mm \tY " << setw(4) << fMeanYFit << " mm" << endl;
|
---|
263 | *fLog << inf << " CGFitted \t X " << setw(4) << fMeanXCGFit
|
---|
264 | << " mm \tY " << setw(4) << fMeanYCGFit << " mm" << endl;
|
---|
265 | }
|
---|
266 |
|
---|
267 | if (o.Contains("siz", TString::kIgnoreCase) || opt == NULL)
|
---|
268 | {
|
---|
269 | *fLog << inf << "Star size:" << endl;
|
---|
270 | *fLog << inf << " Calcultated \t X " << setw(4) << fSigmaMinorAxisCalc
|
---|
271 | << " mm \tY " << setw(4) << fSigmaMajorAxisCalc << " mm" << endl;
|
---|
272 | *fLog << inf << " Fitted \t X " << setw(4) << fSigmaMinorAxisFit
|
---|
273 | << " mm \tY " << setw(4) << fSigmaMajorAxisFit << " mm" << endl;
|
---|
274 | *fLog << inf << " CGFitted \t X " << setw(4) << fSigmaXCGFit
|
---|
275 | << " mm \tY " << setw(4) << fSigmaYCGFit << " mm \t correlation"
|
---|
276 | << setw(4) << fCorrXYCGFit << endl;
|
---|
277 | }
|
---|
278 |
|
---|
279 | if (o.Contains("chi", TString::kIgnoreCase) || opt == NULL)
|
---|
280 | {
|
---|
281 | *fLog << inf << "Star Fit Quality:" << endl;
|
---|
282 | *fLog << inf << " ChiSquare/Ndof \t " << setw(3) << fChiSquare
|
---|
283 | << "/" << fNdof << endl;
|
---|
284 |
|
---|
285 | *fLog << inf << "Star CGFit Quality:" << endl;
|
---|
286 | *fLog << inf << " ChiSquareCGFit/NdofCGFit \t " << setw(3)
|
---|
287 | << fChiSquareCGFit << "/" << fNdofCGFit << endl;
|
---|
288 | }
|
---|
289 |
|
---|
290 | if (o.Contains("err", TString::kIgnoreCase) || opt == NULL)
|
---|
291 | {
|
---|
292 | *fLog << inf << "CGFit Error Matrix of (fMeanXCGFit,fMeanYCGFit) :"
|
---|
293 | << endl;
|
---|
294 | *fLog << inf << " xx,xy,yy \t " << setw(3) << fXXErrCGFit << ", "
|
---|
295 | << fXYErrCGFit << ", " << fYYErrCGFit << endl;
|
---|
296 | }
|
---|
297 |
|
---|
298 |
|
---|
299 | }
|
---|
300 | //--------------------------------------------------------------------------
|
---|
301 |
|
---|
302 |
|
---|
303 |
|
---|
304 |
|
---|
305 |
|
---|
306 |
|
---|
307 |
|
---|
308 |
|
---|
309 |
|
---|