| 1 | #include <fstream>
|
|---|
| 2 | #include <iostream>
|
|---|
| 3 | #include <iomanip>
|
|---|
| 4 |
|
|---|
| 5 | #include <TError.h>
|
|---|
| 6 |
|
|---|
| 7 | #include <TGFrame.h>
|
|---|
| 8 | #include <TGLabel.h>
|
|---|
| 9 | #include <TGButton.h>
|
|---|
| 10 | #include <TGFileDialog.h>
|
|---|
| 11 |
|
|---|
| 12 | #include <TF1.h>
|
|---|
| 13 | #include <TH1.h>
|
|---|
| 14 | #include <TH2.h>
|
|---|
| 15 | #include <TText.h>
|
|---|
| 16 | #include <TProfile.h>
|
|---|
| 17 | #include <TPolyLine.h>
|
|---|
| 18 | #include <TGraphErrors.h>
|
|---|
| 19 |
|
|---|
| 20 | #include <TList.h>
|
|---|
| 21 | #include <TStyle.h>
|
|---|
| 22 | #include <TMinuit.h>
|
|---|
| 23 |
|
|---|
| 24 | #include <TView.h>
|
|---|
| 25 | #include <TLine.h>
|
|---|
| 26 | #include <TMarker.h>
|
|---|
| 27 | #include <TCanvas.h>
|
|---|
| 28 |
|
|---|
| 29 | //#include "coord.h"
|
|---|
| 30 |
|
|---|
| 31 | #include "MGList.h"
|
|---|
| 32 | #include "MPointing.h"
|
|---|
| 33 |
|
|---|
| 34 | using namespace std;
|
|---|
| 35 |
|
|---|
| 36 | //#define PRESENTATION
|
|---|
| 37 |
|
|---|
| 38 | class Set : public TObject
|
|---|
| 39 | {
|
|---|
| 40 | friend istream &operator>>(istream &fin, Set &set);
|
|---|
| 41 | friend ostream &operator<<(ostream &fout, Set &set);
|
|---|
| 42 | private:
|
|---|
| 43 | Double_t fStarAz;
|
|---|
| 44 | Double_t fStarEl;
|
|---|
| 45 |
|
|---|
| 46 | Double_t fRawAz;
|
|---|
| 47 | Double_t fRawEl;
|
|---|
| 48 |
|
|---|
| 49 | Double_t fMag;
|
|---|
| 50 | public:
|
|---|
| 51 | Set(Double_t sel=0, Double_t saz=0, Double_t rel=0, Double_t raz=0) :
|
|---|
| 52 | fStarAz(saz*TMath::DegToRad()),
|
|---|
| 53 | fStarEl(sel*TMath::DegToRad()),
|
|---|
| 54 | fRawAz(raz*TMath::DegToRad()),
|
|---|
| 55 | fRawEl(rel*TMath::DegToRad()), fMag(-25)
|
|---|
| 56 | {
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | Double_t GetMag() const { return fMag; }
|
|---|
| 60 | Double_t GetResidual(Double_t *err=0) const
|
|---|
| 61 | {
|
|---|
| 62 | /*
|
|---|
| 63 | TVector3 v1, v2;
|
|---|
| 64 | v1.SetMagThetaPhi(1, TMath::Pi()/2-fRawEl, fRawAz);
|
|---|
| 65 | v2.SetMagThetaPhi(1, TMath::Pi()/2-fStarEl, fStarAz);
|
|---|
| 66 |
|
|---|
| 67 | return v1.Angle(v2)*TMath::RadToDeg();
|
|---|
| 68 | */
|
|---|
| 69 |
|
|---|
| 70 | const Double_t del = fRawEl-fStarEl;
|
|---|
| 71 | const Double_t daz = fRawAz-fStarAz;
|
|---|
| 72 |
|
|---|
| 73 | /*
|
|---|
| 74 | const Double_t dphi2 = daz/2.;
|
|---|
| 75 | const Double_t cos2 = cos(dphi2)*cos(dphi2);
|
|---|
| 76 | const Double_t sin2 = sin(dphi2)*sin(dphi2);
|
|---|
| 77 | const Double_t d = cos(del)*cos2 - cos(fRawEl+fStarEl)*sin2;
|
|---|
| 78 | */
|
|---|
| 79 | const Double_t d = cos(del) - cos(fRawEl)*cos(fStarEl)*(1.-cos(daz));
|
|---|
| 80 |
|
|---|
| 81 | if (err)
|
|---|
| 82 | {
|
|---|
| 83 | // Error of one pixel in the CCD
|
|---|
| 84 | const Double_t e1 = 32./3600*TMath::DegToRad() * 0.5;
|
|---|
| 85 |
|
|---|
| 86 | // Error of one SE unit
|
|---|
| 87 | const Double_t e2 = 360./16384*TMath::DegToRad() * 0.5;
|
|---|
| 88 |
|
|---|
| 89 | const Double_t e11 = sin(del)+cos(fRawEl)*sin(fStarEl)*(1-cos(daz));
|
|---|
| 90 | const Double_t e12 = cos(fRawEl)*cos(fStarEl)*sin(daz);
|
|---|
| 91 |
|
|---|
| 92 | const Double_t e21 = -sin(del)+sin(fRawEl)*cos(fStarEl)*(1-cos(daz));
|
|---|
| 93 | const Double_t e22 = -cos(fRawEl)*cos(fStarEl)*sin(daz);
|
|---|
| 94 |
|
|---|
| 95 | const Double_t err1 = sqrt(1-d*d);
|
|---|
| 96 | const Double_t err2 = (e11*e11 + e12*e12)*e1*e1;
|
|---|
| 97 | const Double_t err3 = (e21*e21 + e22*e22)*e2*e2;
|
|---|
| 98 |
|
|---|
| 99 | *err = sqrt(err2+err3)/err1 * TMath::RadToDeg();
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | const Double_t dist = acos(d);
|
|---|
| 103 | return dist * TMath::RadToDeg();
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | void operator=(Set &set)
|
|---|
| 107 | {
|
|---|
| 108 | fStarAz = set.fStarAz;
|
|---|
| 109 | fStarEl = set.fStarEl;
|
|---|
| 110 | fRawAz = set.fRawAz;
|
|---|
| 111 | fRawEl = set.fRawEl;
|
|---|
| 112 | fMag = set.fMag;
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | Double_t GetDEl() const { return (fRawEl-fStarEl)*TMath::RadToDeg(); }
|
|---|
| 116 | Double_t GetDZd() const { return -GetDEl(); }
|
|---|
| 117 | Double_t GetDAz() const { return (fRawAz-fStarAz)*TMath::RadToDeg(); }
|
|---|
| 118 | Double_t GetStarEl() const { return fStarEl*TMath::RadToDeg(); }
|
|---|
| 119 | Double_t GetStarZd() const { return 90.-fStarEl*TMath::RadToDeg(); }
|
|---|
| 120 | Double_t GetStarAz() const { return fStarAz*TMath::RadToDeg(); }
|
|---|
| 121 | Double_t GetRawEl() const { return fRawEl*TMath::RadToDeg(); }
|
|---|
| 122 | Double_t GetRawAz() const { return fRawAz*TMath::RadToDeg(); }
|
|---|
| 123 | Double_t GetRawZd() const { return 90.-fRawEl*TMath::RadToDeg(); }
|
|---|
| 124 |
|
|---|
| 125 | ZdAz GetStarZdAz() const { return ZdAz(TMath::Pi()/2-fStarEl, fStarAz); }
|
|---|
| 126 | AltAz GetStarAltAz() const { return AltAz(fStarEl, fStarAz); }
|
|---|
| 127 |
|
|---|
| 128 | ZdAz GetRawZdAz() const { return ZdAz(TMath::Pi()/2-fRawEl, fRawAz); }
|
|---|
| 129 | AltAz GetRawAltAz() const { return AltAz(fRawEl, fRawAz); }
|
|---|
| 130 |
|
|---|
| 131 | void AdjustEl(Double_t del) { fStarEl += del*TMath::DegToRad(); }
|
|---|
| 132 | void AdjustAz(Double_t daz) { fStarAz += daz*TMath::DegToRad(); }
|
|---|
| 133 |
|
|---|
| 134 | void Adjust(const MPointing &bend)
|
|---|
| 135 | {
|
|---|
| 136 | AltAz p = bend(GetStarAltAz());
|
|---|
| 137 | fStarEl = p.Alt();
|
|---|
| 138 | fStarAz = p.Az();
|
|---|
| 139 | }
|
|---|
| 140 | void AdjustBack(const MPointing &bend)
|
|---|
| 141 | {
|
|---|
| 142 | AltAz p = bend.CorrectBack(GetRawAltAz());
|
|---|
| 143 | fRawEl = p.Alt();
|
|---|
| 144 | fRawAz = p.Az();
|
|---|
| 145 | }
|
|---|
| 146 | ClassDef(Set, 0)
|
|---|
| 147 | };
|
|---|
| 148 |
|
|---|
| 149 | ClassImp(Set);
|
|---|
| 150 |
|
|---|
| 151 | istream &operator>>(istream &fin, Set &set)
|
|---|
| 152 | {
|
|---|
| 153 | TString str;
|
|---|
| 154 | do
|
|---|
| 155 | {
|
|---|
| 156 | str.ReadLine(fin);
|
|---|
| 157 | if (!fin)
|
|---|
| 158 | return fin;
|
|---|
| 159 | } while (str[0]=='#');
|
|---|
| 160 |
|
|---|
| 161 | Float_t v[4], mag;
|
|---|
| 162 | Int_t n = sscanf(str.Data(), "%f %f %f %f %*f %*f %*f %*f %*f %*f %f", v, v+1, v+2, v+3, &mag);
|
|---|
| 163 | if (n<4)
|
|---|
| 164 | {
|
|---|
| 165 | cout << "Read: ERROR - Not enough numbers" << endl;
|
|---|
| 166 | return fin;
|
|---|
| 167 | }
|
|---|
| 168 | set.fMag = n<5 ? -25 : mag;
|
|---|
| 169 |
|
|---|
| 170 | set.fStarAz = v[0]*TMath::DegToRad();
|
|---|
| 171 | set.fStarEl = v[1]*TMath::DegToRad();
|
|---|
| 172 |
|
|---|
| 173 | set.fRawAz = v[2]*TMath::DegToRad();
|
|---|
| 174 | set.fRawEl = v[3]*TMath::DegToRad();
|
|---|
| 175 |
|
|---|
| 176 | if (fin)
|
|---|
| 177 | {
|
|---|
| 178 | Double_t res, err;
|
|---|
| 179 | res = set.GetResidual(&err);
|
|---|
| 180 | cout << "Read: " << v[0] << " " << v[1] << " : " << v[2] << " " << v[3] << " : " << v[2]-v[0] << " " << v[3]-v[1] << " : " << res << " " << err << " " << err/res << endl;
|
|---|
| 181 | }
|
|---|
| 182 |
|
|---|
| 183 | return fin;
|
|---|
| 184 | }
|
|---|
| 185 |
|
|---|
| 186 | ostream &operator<<(ostream &out, Set &set)
|
|---|
| 187 | {
|
|---|
| 188 | out << Form("%8.3f", set.fStarAz*TMath::RadToDeg()) << " ";
|
|---|
| 189 | out << Form("%8.3f", set.fStarEl*TMath::RadToDeg()) << " ";
|
|---|
| 190 | out << Form("%8.3f", set.fRawAz*TMath::RadToDeg()) << " ";
|
|---|
| 191 | out << Form("%8.1f", set.fRawEl*TMath::RadToDeg()) << " ";
|
|---|
| 192 | out << set.fMag;
|
|---|
| 193 |
|
|---|
| 194 | return out;
|
|---|
| 195 | }
|
|---|
| 196 |
|
|---|
| 197 | class MFit : public TGMainFrame
|
|---|
| 198 | {
|
|---|
| 199 | private:
|
|---|
| 200 | enum {
|
|---|
| 201 | kTbFit = 19, //MPointing::GetNumPar(), // FIXME!!!
|
|---|
| 202 | kTbLoad,
|
|---|
| 203 | kTbSave,
|
|---|
| 204 | kTbLoadStars,
|
|---|
| 205 | kTbReset,
|
|---|
| 206 | kTbResetStars,
|
|---|
| 207 | kTbReloadStars
|
|---|
| 208 | };
|
|---|
| 209 |
|
|---|
| 210 | MGList *fList;
|
|---|
| 211 |
|
|---|
| 212 | TList fOriginal;
|
|---|
| 213 | TList fCoordinates;
|
|---|
| 214 | TList fLabel;
|
|---|
| 215 |
|
|---|
| 216 | MPointing fBending;
|
|---|
| 217 |
|
|---|
| 218 | TString fFileNameStars;
|
|---|
| 219 |
|
|---|
| 220 | FontStruct_t fFont;
|
|---|
| 221 |
|
|---|
| 222 | void Fcn(Int_t &/*npar*/, Double_t */*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/)
|
|---|
| 223 | {
|
|---|
| 224 | f = 0;
|
|---|
| 225 |
|
|---|
| 226 | MPointing bend;
|
|---|
| 227 | bend.SetParameters(par); // Set Parameters [deg] to MPointing
|
|---|
| 228 |
|
|---|
| 229 | for (int i=0; i<fCoordinates.GetSize(); i++)
|
|---|
| 230 | {
|
|---|
| 231 | Set set = *(Set*)fCoordinates.At(i);
|
|---|
| 232 |
|
|---|
| 233 | set.Adjust(bend);
|
|---|
| 234 |
|
|---|
| 235 | Double_t err = 0.01; // [deg] = 0.25SE
|
|---|
| 236 | Double_t res = set.GetResidual(); //(&err);
|
|---|
| 237 | res /= err;
|
|---|
| 238 |
|
|---|
| 239 | f += res*res;
|
|---|
| 240 | }
|
|---|
| 241 |
|
|---|
| 242 | f /= fCoordinates.GetSize();
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 | static void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag)
|
|---|
| 246 | {
|
|---|
| 247 | ((MFit*)gMinuit->GetObjectFit())->Fcn(npar, gin, f, par, iflag);
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | void DrawMarker(TVirtualPad *pad, Double_t r0, Double_t phi0)
|
|---|
| 251 | {
|
|---|
| 252 | TView *view = pad->GetView();
|
|---|
| 253 |
|
|---|
| 254 | if (!view)
|
|---|
| 255 | {
|
|---|
| 256 | cout << "No View!" << endl;
|
|---|
| 257 | return;
|
|---|
| 258 | }
|
|---|
| 259 |
|
|---|
| 260 | TMarker mark0;
|
|---|
| 261 | mark0.SetMarkerStyle(kFullDotLarge);
|
|---|
| 262 | mark0.SetMarkerColor(kBlue);
|
|---|
| 263 |
|
|---|
| 264 | r0 /= 90;
|
|---|
| 265 | phi0 *= TMath::DegToRad();
|
|---|
| 266 |
|
|---|
| 267 | Double_t x[6] = { r0*cos(phi0), r0*sin(phi0), 0, 0, 0, 0};
|
|---|
| 268 |
|
|---|
| 269 | view->WCtoNDC(x, x+3);
|
|---|
| 270 |
|
|---|
| 271 | mark0.DrawMarker(-x[3], x[4]);
|
|---|
| 272 | }
|
|---|
| 273 |
|
|---|
| 274 | void DrawPolLine(TVirtualPad *pad, Double_t r0, Double_t phi0, Double_t r1, Double_t phi1)
|
|---|
| 275 | {
|
|---|
| 276 | TView *view = pad->GetView();
|
|---|
| 277 |
|
|---|
| 278 | if (!view)
|
|---|
| 279 | {
|
|---|
| 280 | cout << "No View!" << endl;
|
|---|
| 281 | return;
|
|---|
| 282 | }
|
|---|
| 283 | /*
|
|---|
| 284 | if (r0<0)
|
|---|
| 285 | {
|
|---|
| 286 | r0 = -r0;
|
|---|
| 287 | phi0 += 180;
|
|---|
| 288 | }
|
|---|
| 289 | if (r1<0)
|
|---|
| 290 | {
|
|---|
| 291 | r1 = -r1;
|
|---|
| 292 | phi1 += 180;
|
|---|
| 293 | }
|
|---|
| 294 |
|
|---|
| 295 | phi0 = fmod(phi0+360, 360);
|
|---|
| 296 | phi1 = fmod(phi1+360, 360);
|
|---|
| 297 |
|
|---|
| 298 | if (phi1-phi0<-180)
|
|---|
| 299 | phi1+=360;
|
|---|
| 300 | */
|
|---|
| 301 | TLine line;
|
|---|
| 302 | line.SetLineWidth(2);
|
|---|
| 303 | line.SetLineColor(kBlue);
|
|---|
| 304 |
|
|---|
| 305 | Double_t p0 = phi0<phi1?phi0:phi1;
|
|---|
| 306 | Double_t p1 = phi0<phi1?phi1:phi0;
|
|---|
| 307 |
|
|---|
| 308 | if (phi0>phi1)
|
|---|
| 309 | {
|
|---|
| 310 | Double_t d = r1;
|
|---|
| 311 | r1 = r0;
|
|---|
| 312 | r0 = d;
|
|---|
| 313 | }
|
|---|
| 314 |
|
|---|
| 315 | r0 /= 90;
|
|---|
| 316 | r1 /= 90;
|
|---|
| 317 |
|
|---|
| 318 | Double_t dr = r1-r0;
|
|---|
| 319 | Double_t dp = p1-p0;
|
|---|
| 320 |
|
|---|
| 321 | Double_t x0[3] = { r0*cos(p0*TMath::DegToRad()), r0*sin(p0*TMath::DegToRad()), 0};
|
|---|
| 322 |
|
|---|
| 323 | for (double i=p0+10; i<p1+10; i+=10)
|
|---|
| 324 | {
|
|---|
| 325 | if (i>p1)
|
|---|
| 326 | i=p1;
|
|---|
| 327 |
|
|---|
| 328 | Double_t r = dr/dp*(i-p0)+r0;
|
|---|
| 329 | Double_t p = TMath::DegToRad()*i;
|
|---|
| 330 |
|
|---|
| 331 | Double_t x1[3] = { r*cos(p), r*sin(p), 0};
|
|---|
| 332 |
|
|---|
| 333 | Double_t y0[3], y1[3];
|
|---|
| 334 |
|
|---|
| 335 | view->WCtoNDC(x0, y0);
|
|---|
| 336 | view->WCtoNDC(x1, y1);
|
|---|
| 337 |
|
|---|
| 338 | line.DrawLine(y0[0], y0[1], y1[0], y1[1]);
|
|---|
| 339 |
|
|---|
| 340 | x0[0] = x1[0];
|
|---|
| 341 | x0[1] = x1[1];
|
|---|
| 342 | }
|
|---|
| 343 | }
|
|---|
| 344 |
|
|---|
| 345 | void DrawSet(TVirtualPad *pad, Set &set, Float_t scale=-1, Float_t angle=0)
|
|---|
| 346 | {
|
|---|
| 347 | Double_t r0 = set.GetRawZd();
|
|---|
| 348 | Double_t phi0 = set.GetRawAz()-angle;
|
|---|
| 349 | Double_t r1 = set.GetStarZd();
|
|---|
| 350 | Double_t phi1 = set.GetStarAz()-angle;
|
|---|
| 351 |
|
|---|
| 352 | if (r0<0)
|
|---|
| 353 | {
|
|---|
| 354 | r0 = -r0;
|
|---|
| 355 | phi0 += 180;
|
|---|
| 356 | }
|
|---|
| 357 | if (r1<0)
|
|---|
| 358 | {
|
|---|
| 359 | r1 = -r1;
|
|---|
| 360 | phi1 += 180;
|
|---|
| 361 | }
|
|---|
| 362 |
|
|---|
| 363 | phi0 = fmod(phi0+360, 360);
|
|---|
| 364 | phi1 = fmod(phi1+360, 360);
|
|---|
| 365 |
|
|---|
| 366 | if (phi1-phi0<-180)
|
|---|
| 367 | phi1+=360;
|
|---|
| 368 |
|
|---|
| 369 | if (scale<0 || scale>1000)
|
|---|
| 370 | scale = -1;
|
|---|
| 371 |
|
|---|
| 372 | if (scale>0)
|
|---|
| 373 | {
|
|---|
| 374 | Double_t d = r1-r0;
|
|---|
| 375 | r0 += scale*d;
|
|---|
| 376 | r1 -= scale*d;
|
|---|
| 377 | d = phi1-phi0;
|
|---|
| 378 | phi0 += scale*d;
|
|---|
| 379 | phi1 -= scale*d;
|
|---|
| 380 |
|
|---|
| 381 | DrawPolLine(pad, r0, phi0, r1, phi1);
|
|---|
| 382 | DrawMarker(pad, r0, phi0);
|
|---|
| 383 | }
|
|---|
| 384 | else
|
|---|
| 385 | DrawMarker(pad, r1, phi1);
|
|---|
| 386 | }
|
|---|
| 387 |
|
|---|
| 388 | void DrawHorizon(TVirtualPad *pad, const char *fname="horizon.dat") const
|
|---|
| 389 | {
|
|---|
| 390 | TView *view = pad->GetView();
|
|---|
| 391 |
|
|---|
| 392 | if (!view)
|
|---|
| 393 | {
|
|---|
| 394 | cout << "No View!" << endl;
|
|---|
| 395 | return;
|
|---|
| 396 | }
|
|---|
| 397 |
|
|---|
| 398 | ifstream fin(fname);
|
|---|
| 399 | if (!fin)
|
|---|
| 400 | {
|
|---|
| 401 | cout << "ERROR - " << fname << " not found." << endl;
|
|---|
| 402 | return;
|
|---|
| 403 | }
|
|---|
| 404 |
|
|---|
| 405 | TPolyLine poly;
|
|---|
| 406 | poly.SetLineWidth(2);
|
|---|
| 407 | poly.SetLineColor(12);
|
|---|
| 408 | poly.SetLineStyle(8);
|
|---|
| 409 |
|
|---|
| 410 | while (1)
|
|---|
| 411 | {
|
|---|
| 412 | TString line;
|
|---|
| 413 | line.ReadLine(fin);
|
|---|
| 414 | if (!fin)
|
|---|
| 415 | break;
|
|---|
| 416 |
|
|---|
| 417 | Float_t az, alt;
|
|---|
| 418 | sscanf(line.Data(), "%f %f", &az, &alt);
|
|---|
| 419 |
|
|---|
| 420 | Float_t zd = 90-alt;
|
|---|
| 421 |
|
|---|
| 422 | az *= TMath::DegToRad();
|
|---|
| 423 | zd /= 90;
|
|---|
| 424 |
|
|---|
| 425 | Double_t x[6] = { zd*cos(az), zd*sin(az), 0, 0, 0, 0};
|
|---|
| 426 | view->WCtoNDC(x, x+3);
|
|---|
| 427 | poly.SetNextPoint(-x[3], x[4]);
|
|---|
| 428 | }
|
|---|
| 429 |
|
|---|
| 430 | poly.DrawClone()->SetBit(kCanDelete);
|
|---|
| 431 |
|
|---|
| 432 | }
|
|---|
| 433 |
|
|---|
| 434 | void Fit(Double_t &before, Double_t &after, Double_t &backw)
|
|---|
| 435 | {
|
|---|
| 436 | if (fOriginal.GetSize()==0)
|
|---|
| 437 | {
|
|---|
| 438 | cout << "Sorry, no input data loaded..." << endl;
|
|---|
| 439 | return;
|
|---|
| 440 | }
|
|---|
| 441 |
|
|---|
| 442 | fCoordinates.Delete();
|
|---|
| 443 | for (int i=0; i<fOriginal.GetSize(); i++)
|
|---|
| 444 | fCoordinates.Add(new Set(*(Set*)fOriginal.At(i)));
|
|---|
| 445 |
|
|---|
| 446 | cout << "-----------------------------------------------------------------------" << endl;
|
|---|
| 447 |
|
|---|
| 448 | gStyle->SetOptStat("emro");
|
|---|
| 449 |
|
|---|
| 450 | TH1F hres1("Res1", " Residuals before correction ", fOriginal.GetSize()/3, 0, 0.3);
|
|---|
| 451 | TH1F hres2("Res2", " Residuals after correction ", fOriginal.GetSize()/3, 0, 0.3);
|
|---|
| 452 | TH1F hres3("Res3", " Residuals after backward correction ", fOriginal.GetSize()/3, 0, 0.3);
|
|---|
| 453 |
|
|---|
| 454 | TProfile proaz ("ProAz", " \\Delta profile vs. Az", 48, -180, 180);
|
|---|
| 455 | TProfile prozd ("ProZd", " \\Delta profile vs. Zd", 60, 0, 90);
|
|---|
| 456 | TProfile promag("ProMag", " \\Delta profile vs. Mag", 40, 1, 4);
|
|---|
| 457 |
|
|---|
| 458 | hres1.SetXTitle("\\Delta [\\circ]");
|
|---|
| 459 | hres1.SetYTitle("Counts");
|
|---|
| 460 |
|
|---|
| 461 | hres2.SetXTitle("\\Delta [\\circ]");
|
|---|
| 462 | hres2.SetYTitle("Counts");
|
|---|
| 463 |
|
|---|
| 464 | hres3.SetXTitle("\\Delta [\\circ]");
|
|---|
| 465 | hres3.SetYTitle("Counts");
|
|---|
| 466 |
|
|---|
| 467 | TGraph gdaz;
|
|---|
| 468 | TGraph gdzd;
|
|---|
| 469 | TGraph gaz;
|
|---|
| 470 | TGraph gzd;
|
|---|
| 471 | TGraphErrors graz;
|
|---|
| 472 | TGraphErrors grzd;
|
|---|
| 473 | TGraphErrors grmag;
|
|---|
| 474 | TGraph gmaz;
|
|---|
| 475 | TGraph gmzd;
|
|---|
| 476 |
|
|---|
| 477 | gdaz.SetTitle(" \\Delta Az vs. Zd ");
|
|---|
| 478 | gdzd.SetTitle(" \\Delta Zd vs. Az ");
|
|---|
| 479 |
|
|---|
| 480 | gaz.SetTitle(" \\Delta Az vs. Az ");
|
|---|
| 481 | gzd.SetTitle(" \\Delta Zd vs. Zd ");
|
|---|
| 482 |
|
|---|
| 483 | gmaz.SetTitle(" \\Delta Az vs. Mag ");
|
|---|
| 484 | gmzd.SetTitle(" \\Delta Zd vs. Mag ");
|
|---|
| 485 |
|
|---|
| 486 | graz.SetTitle(" \\Delta vs. Az ");
|
|---|
| 487 | grzd.SetTitle(" \\Delta vs. Zd ");
|
|---|
| 488 | grmag.SetTitle(" \\Delta vs. Mag ");
|
|---|
| 489 |
|
|---|
| 490 | TMinuit minuit(MPointing::GetNumPar()); //initialize TMinuit with a maximum of 5 params
|
|---|
| 491 | minuit.SetObjectFit(this);
|
|---|
| 492 | minuit.SetPrintLevel(-1);
|
|---|
| 493 | minuit.SetFCN(fcn);
|
|---|
| 494 |
|
|---|
| 495 | fBending.SetMinuitParameters(minuit, MPointing::GetNumPar()); // Init Parameters [deg]
|
|---|
| 496 |
|
|---|
| 497 | for (int i=0; i<MPointing::GetNumPar(); i++)
|
|---|
| 498 | {
|
|---|
| 499 | TGButton *l = (TGButton*)fList->FindWidget(i);
|
|---|
| 500 | minuit.FixParameter(i);
|
|---|
| 501 | if (l->GetState()==kButtonDown)
|
|---|
| 502 | minuit.Release(i);
|
|---|
| 503 | }
|
|---|
| 504 |
|
|---|
| 505 | //minuit.Command("SHOW PARAMETERS");
|
|---|
| 506 | //minuit.Command("SHOW LIMITS");
|
|---|
| 507 |
|
|---|
| 508 | cout << endl;
|
|---|
| 509 | cout << "Starting fit..." << endl;
|
|---|
| 510 | cout << "For the fit an measurement error in the residual of ";
|
|---|
| 511 | cout << "0.02deg (=1SE) is assumed." << endl;
|
|---|
| 512 | cout << endl;
|
|---|
| 513 |
|
|---|
| 514 | Int_t ierflg = 0;
|
|---|
| 515 | ierflg = minuit.Migrad();
|
|---|
| 516 | cout << "Migrad returns " << ierflg << endl;
|
|---|
| 517 | // minuit.Release(2);
|
|---|
| 518 | ierflg = minuit.Migrad();
|
|---|
| 519 | cout << "Migrad returns " << ierflg << endl << endl;
|
|---|
| 520 |
|
|---|
| 521 | //
|
|---|
| 522 | // Get Fit Results
|
|---|
| 523 | //
|
|---|
| 524 | fBending.GetMinuitParameters(minuit);
|
|---|
| 525 | fBending.PrintMinuitParameters(minuit);
|
|---|
| 526 | cout << endl;
|
|---|
| 527 | //fBending.Save("bending_magic.txt");
|
|---|
| 528 |
|
|---|
| 529 |
|
|---|
| 530 | //
|
|---|
| 531 | // Make a copy of all list entries
|
|---|
| 532 | //
|
|---|
| 533 | TList list;
|
|---|
| 534 | list.SetOwner();
|
|---|
| 535 | for (int i=0; i<fCoordinates.GetSize(); i++)
|
|---|
| 536 | list.Add(new Set(*(Set*)fCoordinates.At(i)));
|
|---|
| 537 |
|
|---|
| 538 | //
|
|---|
| 539 | // Correct for Offsets only
|
|---|
| 540 | //
|
|---|
| 541 | TArrayD par;
|
|---|
| 542 | fBending.GetParameters(par);
|
|---|
| 543 | for (int i=2; i<MPointing::GetNumPar(); i++)
|
|---|
| 544 | par[i]=0;
|
|---|
| 545 |
|
|---|
| 546 | MPointing b2;
|
|---|
| 547 | b2.SetParameters(par);
|
|---|
| 548 |
|
|---|
| 549 | cout << "Sets with Residual exceeding 0.13deg:" << endl;
|
|---|
| 550 |
|
|---|
| 551 | //
|
|---|
| 552 | // Calculate correction and residuals
|
|---|
| 553 | //
|
|---|
| 554 | for (int i=0; i<fCoordinates.GetSize(); i++)
|
|---|
| 555 | {
|
|---|
| 556 | Set orig = *(Set*)fCoordinates.At(i);
|
|---|
| 557 |
|
|---|
| 558 | Set &set0 = *(Set*)fCoordinates.At(i);
|
|---|
| 559 |
|
|---|
| 560 | ZdAz za(set0.GetStarZdAz());
|
|---|
| 561 | za *=kRad2Deg;
|
|---|
| 562 |
|
|---|
| 563 | //
|
|---|
| 564 | // Correct for offsets only
|
|---|
| 565 | //
|
|---|
| 566 | Set set1(set0);
|
|---|
| 567 | set1.Adjust(b2);
|
|---|
| 568 |
|
|---|
| 569 | hres1.Fill(set1.GetResidual());
|
|---|
| 570 |
|
|---|
| 571 | set0.Adjust(fBending);
|
|---|
| 572 | hres2.Fill(set0.GetResidual());
|
|---|
| 573 |
|
|---|
| 574 | Double_t dz = fmod(set0.GetDAz()+720, 360);
|
|---|
| 575 | if (dz>180)
|
|---|
| 576 | dz -= 360;
|
|---|
| 577 |
|
|---|
| 578 | Double_t err;
|
|---|
| 579 | Double_t resi = set0.GetResidual(&err);
|
|---|
| 580 |
|
|---|
| 581 | gdzd.SetPoint(i, za.Az(), set0.GetDZd());
|
|---|
| 582 | gdaz.SetPoint(i, za.Zd(), dz);
|
|---|
| 583 | graz.SetPoint(i, za.Az(), resi);
|
|---|
| 584 | graz.SetPointError(i, 0, err);
|
|---|
| 585 | grzd.SetPoint(i, za.Zd(), resi);
|
|---|
| 586 | grzd.SetPointError(i, 0, err);
|
|---|
| 587 |
|
|---|
| 588 | if (resi>0.13)//orig.GetStarAz()>0 && orig.GetStarAz()<50 && set0.GetDZd()<-0.032 && orig.GetStarEl()<80) // 0.13
|
|---|
| 589 | cout << " " << orig << " <" << resi << ">" << endl;
|
|---|
| 590 |
|
|---|
| 591 | proaz.Fill(za.Az(), set0.GetResidual(&err));
|
|---|
| 592 | prozd.Fill(za.Zd(), set0.GetResidual(&err));
|
|---|
| 593 | promag.Fill(set0.GetMag(), set0.GetResidual(&err));
|
|---|
| 594 |
|
|---|
| 595 | gaz.SetPoint( i, za.Az(), dz);
|
|---|
| 596 | gzd.SetPoint( i, za.Zd(), set0.GetDZd());
|
|---|
| 597 | if (set0.GetMag()>=-20)
|
|---|
| 598 | {
|
|---|
| 599 | grmag.SetPoint(i, set0.GetMag(), set0.GetResidual(&err));
|
|---|
| 600 | grmag.SetPointError(i, 0, err);
|
|---|
| 601 | gmaz.SetPoint( i, set0.GetMag(), dz);
|
|---|
| 602 | gmzd.SetPoint( i, set0.GetMag(), set0.GetDZd());
|
|---|
| 603 | }
|
|---|
| 604 | }
|
|---|
| 605 |
|
|---|
| 606 | //
|
|---|
| 607 | // Check for overflows
|
|---|
| 608 | //
|
|---|
| 609 | const Stat_t ov = hres2.GetBinContent(hres2.GetNbinsX()+1);
|
|---|
| 610 | if (ov>0)
|
|---|
| 611 | cout << "WARNING: " << ov << " overflows in residuals." << endl;
|
|---|
| 612 |
|
|---|
| 613 |
|
|---|
| 614 |
|
|---|
| 615 | cout << dec << endl;
|
|---|
| 616 | cout << " Number of calls to FCN: " << minuit.fNfcn << endl;
|
|---|
| 617 | cout << "Minimum value found for FCN (Chi^2?): " << minuit.fAmin << endl;
|
|---|
| 618 | cout << " Fit-Probability(?): " << TMath::Prob(minuit.fAmin/*fOriginal.GetSize()*/, fOriginal.GetSize()-minuit.GetNumFreePars())*100 << "%" << endl;
|
|---|
| 619 | cout << " Chi^2/NDF: " << minuit.fAmin/(fOriginal.GetSize()-minuit.GetNumFreePars()) << endl;
|
|---|
| 620 | //cout << "Prob(?): " << TMath::Prob(fChisquare,ndf);
|
|---|
| 621 |
|
|---|
| 622 |
|
|---|
| 623 |
|
|---|
| 624 | //
|
|---|
| 625 | // Print all data sets for which the backward correction is
|
|---|
| 626 | // twice times worse than the residual gotten from the
|
|---|
| 627 | // bending correction itself
|
|---|
| 628 | //
|
|---|
| 629 | cout << endl;
|
|---|
| 630 | cout << "Checking backward correction (raw-->star):" << endl;
|
|---|
| 631 | for (int i=0; i<fCoordinates.GetSize(); i++)
|
|---|
| 632 | {
|
|---|
| 633 | Set set0(*(Set*)list.At(i));
|
|---|
| 634 | Set &set1 = *(Set*)list.At(i);
|
|---|
| 635 |
|
|---|
| 636 | set0.AdjustBack(fBending);
|
|---|
| 637 | set1.Adjust(fBending);
|
|---|
| 638 |
|
|---|
| 639 | const Double_t res0 = set0.GetResidual();
|
|---|
| 640 | const Double_t res1 = set1.GetResidual();
|
|---|
| 641 | const Double_t diff = TMath::Abs(res0-res1);
|
|---|
| 642 |
|
|---|
| 643 | hres3.Fill(res0);
|
|---|
| 644 |
|
|---|
| 645 | if (diff<hres2.GetMean()*0.66)
|
|---|
| 646 | continue;
|
|---|
| 647 |
|
|---|
| 648 | cout << "DBack: " << setw(6) << set0.GetStarZd() << " " << setw(7) << set0.GetStarAz() << ": ";
|
|---|
| 649 | cout << "ResB="<< setw(7) << res0*60 << " ResF=" << setw(7) << res1*60 << " |ResB-ResF|=" << setw(7) << diff*60 << " arcmin" << endl;
|
|---|
| 650 | }
|
|---|
| 651 | cout << "OK." << endl;
|
|---|
| 652 | cout << endl;
|
|---|
| 653 |
|
|---|
| 654 | const Double_t max1 = TMath::Max(gaz.GetHistogram()->GetMaximum(), gdaz.GetHistogram()->GetMaximum());
|
|---|
| 655 | const Double_t max2 = TMath::Max(gzd.GetHistogram()->GetMaximum(), gdzd.GetHistogram()->GetMaximum());
|
|---|
| 656 | const Double_t max3 = TMath::Max(grzd.GetHistogram()->GetMaximum(), graz.GetHistogram()->GetMaximum());
|
|---|
| 657 |
|
|---|
| 658 | const Double_t min1 = TMath::Min(gaz.GetHistogram()->GetMinimum(), gdaz.GetHistogram()->GetMinimum());
|
|---|
| 659 | const Double_t min2 = TMath::Min(gzd.GetHistogram()->GetMinimum(), gdzd.GetHistogram()->GetMinimum());
|
|---|
| 660 | const Double_t min3 = TMath::Min(grzd.GetHistogram()->GetMinimum(), graz.GetHistogram()->GetMinimum());
|
|---|
| 661 |
|
|---|
| 662 | const Double_t absmax1 = TMath::Max(max1, TMath::Abs(min1));
|
|---|
| 663 | const Double_t absmax2 = TMath::Max(max2, TMath::Abs(min2));
|
|---|
| 664 | const Double_t absmax3 = TMath::Max(max3, TMath::Abs(min3));
|
|---|
| 665 |
|
|---|
| 666 | gaz.SetMaximum(absmax1);
|
|---|
| 667 | gzd.SetMaximum(absmax2);
|
|---|
| 668 | gdaz.SetMaximum(absmax1);
|
|---|
| 669 | gdzd.SetMaximum(absmax2);
|
|---|
| 670 | gmaz.SetMaximum(absmax1);
|
|---|
| 671 | gmzd.SetMaximum(absmax2);
|
|---|
| 672 | graz.SetMaximum(absmax3);
|
|---|
| 673 | grzd.SetMaximum(absmax3);
|
|---|
| 674 | grmag.SetMaximum(absmax3);
|
|---|
| 675 | gaz.SetMinimum(-absmax1);
|
|---|
| 676 | gzd.SetMinimum(-absmax2);
|
|---|
| 677 | gdaz.SetMinimum(-absmax1);
|
|---|
| 678 | gdzd.SetMinimum(-absmax2);
|
|---|
| 679 | gmaz.SetMinimum(-absmax1);
|
|---|
| 680 | gmzd.SetMinimum(-absmax2);
|
|---|
| 681 | graz.SetMinimum(0);
|
|---|
| 682 | grzd.SetMinimum(0);
|
|---|
| 683 | grmag.SetMinimum(0);
|
|---|
| 684 |
|
|---|
| 685 | TCanvas *c1;
|
|---|
| 686 |
|
|---|
| 687 | if (gROOT->FindObject("CanvGraphs"))
|
|---|
| 688 | c1 = dynamic_cast<TCanvas*>(gROOT->FindObject("CanvGraphs"));
|
|---|
| 689 | else
|
|---|
| 690 | c1=new TCanvas("CanvGraphs", "Graphs");
|
|---|
| 691 |
|
|---|
| 692 | gROOT->SetSelectedPad(0);
|
|---|
| 693 | c1->SetSelectedPad(0);
|
|---|
| 694 | c1->SetBorderMode(0);
|
|---|
| 695 | c1->SetFrameBorderMode(0);
|
|---|
| 696 | c1->Clear();
|
|---|
| 697 |
|
|---|
| 698 | c1->SetFillColor(kWhite);
|
|---|
| 699 | #ifndef PRESENTATION
|
|---|
| 700 | c1->Divide(3,3,1e-10,1e-10);
|
|---|
| 701 | #else
|
|---|
| 702 | c1->Divide(2,2,1e-10,1e-10);
|
|---|
| 703 | #endif
|
|---|
| 704 | c1->SetFillColor(kWhite);
|
|---|
| 705 |
|
|---|
| 706 | TGraph *g=0;
|
|---|
| 707 |
|
|---|
| 708 | TLine line;
|
|---|
| 709 | line.SetLineColor(kGreen);
|
|---|
| 710 | line.SetLineWidth(2);
|
|---|
| 711 | #ifndef PRESENTATION
|
|---|
| 712 | c1->cd(1);
|
|---|
| 713 | gPad->SetBorderMode(0);
|
|---|
| 714 | gPad->SetFrameBorderMode(0);
|
|---|
| 715 | gPad->SetGridx();
|
|---|
| 716 | gPad->SetGridy();
|
|---|
| 717 | g=(TGraph*)gaz.DrawClone("A*");
|
|---|
| 718 | g->SetBit(kCanDelete);
|
|---|
| 719 | g->GetHistogram()->SetXTitle("Az [\\circ]");
|
|---|
| 720 | g->GetHistogram()->SetYTitle("\\Delta Az [\\circ]");
|
|---|
| 721 |
|
|---|
| 722 | line.DrawLine(g->GetXaxis()->GetXmin(), 360./16384, g->GetXaxis()->GetXmax(), 360./16384);
|
|---|
| 723 | line.DrawLine(g->GetXaxis()->GetXmin(), -360./16384, g->GetXaxis()->GetXmax(), -360./16384);
|
|---|
| 724 |
|
|---|
| 725 | c1->cd(2);
|
|---|
| 726 | gPad->SetBorderMode(0);
|
|---|
| 727 | gPad->SetFrameBorderMode(0);
|
|---|
| 728 | gPad->SetGridx();
|
|---|
| 729 | gPad->SetGridy();
|
|---|
| 730 | g=(TGraph*)gdaz.DrawClone("A*");
|
|---|
| 731 | g->SetBit(kCanDelete);
|
|---|
| 732 | g->GetHistogram()->SetXTitle("Zd [\\circ]");
|
|---|
| 733 | g->GetHistogram()->SetYTitle("\\Delta Az [\\circ]");
|
|---|
| 734 | line.DrawLine(g->GetXaxis()->GetXmin(), 360./16384, g->GetXaxis()->GetXmax(), 360./16384);
|
|---|
| 735 | line.DrawLine(g->GetXaxis()->GetXmin(), -360./16384, g->GetXaxis()->GetXmax(), -360./16384);
|
|---|
| 736 | cout << "Mean dAz: " << g->GetMean(2) << " \xb1 " << g->GetRMS(2) << endl;
|
|---|
| 737 |
|
|---|
| 738 | c1->cd(3);
|
|---|
| 739 | gPad->SetBorderMode(0);
|
|---|
| 740 | gPad->SetFrameBorderMode(0);
|
|---|
| 741 | gPad->SetGridx();
|
|---|
| 742 | gPad->SetGridy();
|
|---|
| 743 | if (gmaz.GetN()>0)
|
|---|
| 744 | {
|
|---|
| 745 | g=(TGraph*)gmaz.DrawClone("A*");
|
|---|
| 746 | g->SetBit(kCanDelete);
|
|---|
| 747 | g->GetHistogram()->SetXTitle("Mag");
|
|---|
| 748 | g->GetHistogram()->SetYTitle("\\Delta Az [\\circ]");
|
|---|
| 749 | line.DrawLine(g->GetXaxis()->GetXmin(), 360./16384, g->GetXaxis()->GetXmax(), 360./16384);
|
|---|
| 750 | line.DrawLine(g->GetXaxis()->GetXmin(), -360./16384, g->GetXaxis()->GetXmax(), -360./16384);
|
|---|
| 751 | }
|
|---|
| 752 | #endif
|
|---|
| 753 |
|
|---|
| 754 | #ifndef PRESENTATION
|
|---|
| 755 | c1->cd(4);
|
|---|
| 756 | #else
|
|---|
| 757 | c1->cd(1);
|
|---|
| 758 | #endif
|
|---|
| 759 | gPad->SetBorderMode(0);
|
|---|
| 760 | gPad->SetFrameBorderMode(0);
|
|---|
| 761 | gPad->SetGridx();
|
|---|
| 762 | gPad->SetGridy();
|
|---|
| 763 | g=(TGraph*)gdzd.DrawClone("A*");
|
|---|
| 764 | g->SetBit(kCanDelete);
|
|---|
| 765 | g->GetHistogram()->SetXTitle("Az [\\circ]");
|
|---|
| 766 | g->GetHistogram()->SetYTitle("\\Delta Zd [\\circ]");
|
|---|
| 767 | line.DrawLine(g->GetXaxis()->GetXmin(), 360./16384, g->GetXaxis()->GetXmax(), 360./16384);
|
|---|
| 768 | line.DrawLine(g->GetXaxis()->GetXmin(), -360./16384, g->GetXaxis()->GetXmax(), -360./16384);
|
|---|
| 769 | cout << "Mean dZd: " << g->GetMean(2) << " \xb1 " << g->GetRMS(2) << endl;
|
|---|
| 770 | cout << endl;
|
|---|
| 771 |
|
|---|
| 772 | #ifndef PRESENTATION
|
|---|
| 773 | c1->cd(5);
|
|---|
| 774 | #else
|
|---|
| 775 | c1->cd(2);
|
|---|
| 776 | #endif
|
|---|
| 777 | gPad->SetBorderMode(0);
|
|---|
| 778 | gPad->SetFrameBorderMode(0);
|
|---|
| 779 | gPad->SetGridx();
|
|---|
| 780 | gPad->SetGridy();
|
|---|
| 781 | g=(TGraph*)gzd.DrawClone("A*");
|
|---|
| 782 | g->SetBit(kCanDelete);
|
|---|
| 783 | g->GetHistogram()->SetXTitle("Zd [\\circ]");
|
|---|
| 784 | g->GetHistogram()->SetYTitle("\\Delta Zd [\\circ]");
|
|---|
| 785 | line.DrawLine(g->GetXaxis()->GetXmin(), 360./16384, g->GetXaxis()->GetXmax(), 360./16384);
|
|---|
| 786 | line.DrawLine(g->GetXaxis()->GetXmin(), -360./16384, g->GetXaxis()->GetXmax(), -360./16384);
|
|---|
| 787 | #ifndef PRESENTATION
|
|---|
| 788 | c1->cd(6);
|
|---|
| 789 | gPad->SetBorderMode(0);
|
|---|
| 790 | gPad->SetFrameBorderMode(0);
|
|---|
| 791 | gPad->SetGridx();
|
|---|
| 792 | gPad->SetGridy();
|
|---|
| 793 | if (gmzd.GetN()>0)
|
|---|
| 794 | {
|
|---|
| 795 | g=(TGraph*)gmzd.DrawClone("A*");
|
|---|
| 796 | g->SetBit(kCanDelete);
|
|---|
| 797 | g->GetHistogram()->SetXTitle("Mag");
|
|---|
| 798 | g->GetHistogram()->SetYTitle("\\Delta Zd [\\circ]");
|
|---|
| 799 | line.DrawLine(g->GetXaxis()->GetXmin(), 360./16384, g->GetXaxis()->GetXmax(), 360./16384);
|
|---|
| 800 | line.DrawLine(g->GetXaxis()->GetXmin(), -360./16384, g->GetXaxis()->GetXmax(), -360./16384);
|
|---|
| 801 | }
|
|---|
| 802 | #endif
|
|---|
| 803 |
|
|---|
| 804 | #ifndef PRESENTATION
|
|---|
| 805 | c1->cd(7);
|
|---|
| 806 | #else
|
|---|
| 807 | c1->cd(3);
|
|---|
| 808 | #endif
|
|---|
| 809 | gPad->SetBorderMode(0);
|
|---|
| 810 | gPad->SetFrameBorderMode(0);
|
|---|
| 811 | gPad->SetGridx();
|
|---|
| 812 | gPad->SetGridy();
|
|---|
| 813 | g=(TGraph*)graz.DrawClone("AP");
|
|---|
| 814 | g->SetBit(kCanDelete);
|
|---|
| 815 | g->GetHistogram()->SetXTitle("Az [\\circ]");
|
|---|
| 816 | g->GetHistogram()->SetYTitle("\\Delta [\\circ]");
|
|---|
| 817 | line.DrawLine(g->GetXaxis()->GetXmin(), 360./16384, g->GetXaxis()->GetXmax(), 360./16384);
|
|---|
| 818 |
|
|---|
| 819 | proaz.SetLineWidth(2);
|
|---|
| 820 | proaz.SetLineColor(kBlue);
|
|---|
| 821 | proaz.SetMarkerColor(kBlue);
|
|---|
| 822 | proaz.DrawCopy("pc hist same");
|
|---|
| 823 |
|
|---|
| 824 | #ifndef PRESENTATION
|
|---|
| 825 | c1->cd(8);
|
|---|
| 826 | #else
|
|---|
| 827 | c1->cd(4);
|
|---|
| 828 | #endif
|
|---|
| 829 | gPad->SetBorderMode(0);
|
|---|
| 830 | gPad->SetFrameBorderMode(0);
|
|---|
| 831 | gPad->SetGridx();
|
|---|
| 832 | gPad->SetGridy();
|
|---|
| 833 | g=(TGraph*)grzd.DrawClone("AP");
|
|---|
| 834 | g->SetBit(kCanDelete);
|
|---|
| 835 | g->GetHistogram()->SetXTitle("Zd [\\circ]");
|
|---|
| 836 | g->GetHistogram()->SetYTitle("\\Delta [\\circ]");
|
|---|
| 837 | line.DrawLine(g->GetXaxis()->GetXmin(), 360./16384, g->GetXaxis()->GetXmax(), 360./16384);
|
|---|
| 838 |
|
|---|
| 839 | prozd.SetLineWidth(2);
|
|---|
| 840 | prozd.SetLineColor(kBlue);
|
|---|
| 841 | prozd.SetMarkerColor(kBlue);
|
|---|
| 842 | prozd.DrawCopy("pc hist same");
|
|---|
| 843 |
|
|---|
| 844 | #ifndef PRESENTATION
|
|---|
| 845 | c1->cd(9);
|
|---|
| 846 | gPad->SetBorderMode(0);
|
|---|
| 847 | gPad->SetFrameBorderMode(0);
|
|---|
| 848 | gPad->SetGridx();
|
|---|
| 849 | gPad->SetGridy();
|
|---|
| 850 | if (grmag.GetN()>0)
|
|---|
| 851 | {
|
|---|
| 852 | g=(TGraph*)grmag.DrawClone("AP");
|
|---|
| 853 | g->SetBit(kCanDelete);
|
|---|
| 854 | g->GetHistogram()->SetXTitle("Mag");
|
|---|
| 855 | g->GetHistogram()->SetYTitle("\\Delta [\\circ]");
|
|---|
| 856 | line.DrawLine(g->GetXaxis()->GetXmin(), 360./16384, g->GetXaxis()->GetXmax(), 360./16384);
|
|---|
| 857 | }
|
|---|
| 858 | promag.SetLineWidth(2);
|
|---|
| 859 | promag.SetLineColor(kBlue);
|
|---|
| 860 | promag.SetMarkerColor(kBlue);
|
|---|
| 861 | promag.DrawCopy("pc hist same");
|
|---|
| 862 | #endif
|
|---|
| 863 |
|
|---|
| 864 | //
|
|---|
| 865 | // Print out the residual before and after correction in several
|
|---|
| 866 | // units
|
|---|
| 867 | //
|
|---|
| 868 | cout << fCoordinates.GetSize() << " data sets." << endl << endl;
|
|---|
| 869 | cout << "Total Spread of Residual:" << endl;
|
|---|
| 870 | cout << "-------------------------" << endl;
|
|---|
| 871 | cout << "before: " << Form("%6.4f", hres1.GetMean()) << " \xb1 " << Form("%6.4f", hres1.GetRMS()) << " deg \t";
|
|---|
| 872 | cout << "before: " << Form("%4.1f", hres1.GetMean()*60) << " \xb1 " << Form("%.1f", hres1.GetRMS()*60) << " arcmin" << endl;
|
|---|
| 873 | cout << "after: " << Form("%6.4f", hres2.GetMean()) << " \xb1 " << Form("%6.4f", hres2.GetRMS()) << " deg \t";
|
|---|
| 874 | cout << "after: " << Form("%4.1f", hres2.GetMean()*60) << " \xb1 " << Form("%.1f", hres2.GetRMS()*60) << " arcmin" << endl;
|
|---|
| 875 | cout << "backw: " << Form("%6.4f", hres3.GetMean()) << " \xb1 " << Form("%6.4f", hres3.GetRMS()) << " deg \t";
|
|---|
| 876 | cout << "backw: " << Form("%4.1f", hres3.GetMean()*60) << " \xb1 " << Form("%.1f", hres3.GetRMS()*60) << " arcmin" << endl;
|
|---|
| 877 | cout << endl;
|
|---|
| 878 | cout << "before: " << Form("%4.1f", hres1.GetMean()*16348/360) << " \xb1 " << Form("%.1f", hres1.GetRMS()*16384/360) << " SE \t\t";
|
|---|
| 879 | cout << "before: " << Form("%4.1f", hres1.GetMean()*60*60/23.4) << " \xb1 " << Form("%.1f", hres1.GetRMS()*60*60/23.4) << " pix" << endl;
|
|---|
| 880 | cout << "after: " << Form("%4.1f", hres2.GetMean()*16384/360) << " \xb1 " << Form("%.1f", hres2.GetRMS()*16384/360) << " SE \t\t";
|
|---|
| 881 | cout << "after: " << Form("%4.1f", hres2.GetMean()*60*60/23.4) << " \xb1 " << Form("%.1f", hres2.GetRMS()*60*60/23.4) << " pix" << endl;
|
|---|
| 882 | cout << "backw: " << Form("%4.1f", hres3.GetMean()*16384/360) << " \xb1 " << Form("%.1f", hres3.GetRMS()*16384/360) << " SE \t\t";
|
|---|
| 883 | cout << "backw: " << Form("%4.1f", hres3.GetMean()*60*60/23.4) << " \xb1 " << Form("%.1f", hres3.GetRMS()*60*60/23.4) << " pix" << endl;
|
|---|
| 884 | cout << endl;
|
|---|
| 885 | cout << endl; // ±
|
|---|
| 886 |
|
|---|
| 887 |
|
|---|
| 888 | before = hres1.GetMean()*16384/360;
|
|---|
| 889 | after = hres2.GetMean()*16384/360;
|
|---|
| 890 | backw = hres3.GetMean()*16384/360;
|
|---|
| 891 |
|
|---|
| 892 |
|
|---|
| 893 | gStyle->SetOptStat(1110);
|
|---|
| 894 | gStyle->SetStatFormat("6.2g");
|
|---|
| 895 |
|
|---|
| 896 | if (gROOT->FindObject("CanvResiduals"))
|
|---|
| 897 | c1 = dynamic_cast<TCanvas*>(gROOT->FindObject("CanvResiduals"));
|
|---|
| 898 | else
|
|---|
| 899 | c1=new TCanvas("CanvResiduals", "Residuals", 800, 800);
|
|---|
| 900 |
|
|---|
| 901 | gROOT->SetSelectedPad(0);
|
|---|
| 902 | c1->SetSelectedPad(0);
|
|---|
| 903 | c1->Clear();
|
|---|
| 904 | c1->SetFillColor(kWhite);
|
|---|
| 905 |
|
|---|
| 906 | c1->Divide(2, 2, 1e-10, 1e-10);
|
|---|
| 907 |
|
|---|
| 908 | c1->cd(2);
|
|---|
| 909 | gPad->SetBorderMode(0);
|
|---|
| 910 | gPad->SetFrameBorderMode(0);
|
|---|
| 911 | hres1.SetLineColor(kRed);
|
|---|
| 912 | hres1.DrawCopy();
|
|---|
| 913 |
|
|---|
| 914 | gPad->Update();
|
|---|
| 915 |
|
|---|
| 916 | line.DrawLine(360./16384, gPad->GetUymin(), 360./16384, gPad->GetUymax());
|
|---|
| 917 |
|
|---|
| 918 | c1->cd(4);
|
|---|
| 919 | gPad->SetBorderMode(0);
|
|---|
| 920 | gPad->SetFrameBorderMode(0);
|
|---|
| 921 | hres2.SetLineColor(kBlue);
|
|---|
| 922 | TH1 *h=hres2.DrawCopy();
|
|---|
| 923 | TF1 f("mygaus", "(gaus)", 0, 1);
|
|---|
| 924 | f.SetLineColor(kMagenta/*6*/);
|
|---|
| 925 | f.SetLineWidth(1);
|
|---|
| 926 | f.SetParameter(0, h->GetBinContent(1));
|
|---|
| 927 | f.FixParameter(1, 0);
|
|---|
| 928 | f.SetParameter(2, h->GetRMS());
|
|---|
| 929 | h->Fit("mygaus", "QR");
|
|---|
| 930 | hres3.SetLineColor(kCyan);
|
|---|
| 931 | hres3.SetLineStyle(kDashed);
|
|---|
| 932 | hres3.DrawCopy("same");
|
|---|
| 933 | cout << "Gaus-Fit Sigma: " << f.GetParameter(2) << "\xb0" << endl;
|
|---|
| 934 | cout << "Fit-Probability: " << f.GetProb()*100 << "%" << endl;
|
|---|
| 935 | cout << " Chi^2/NDF: " << f.GetChisquare() << "/" << f.GetNDF() << " = " << f.GetChisquare()/f.GetNDF() << endl;
|
|---|
| 936 | gPad->Update();
|
|---|
| 937 | line.DrawLine(360./16384, gPad->GetUymin(), 360./16384, gPad->GetUymax());
|
|---|
| 938 |
|
|---|
| 939 | c1->cd(1);
|
|---|
| 940 | gPad->SetBorderMode(0);
|
|---|
| 941 | gPad->SetFrameBorderMode(0);
|
|---|
| 942 | gPad->SetTheta(90);
|
|---|
| 943 | gPad->SetPhi(90);
|
|---|
| 944 | TH2F h2res1("Res2D1", " Dataset positions on the sky ", 36, 0, 360, 8, 0, 90);
|
|---|
| 945 | h2res1.SetBit(TH1::kNoStats);
|
|---|
| 946 | h2res1.DrawCopy("surf1pol");
|
|---|
| 947 | gPad->Modified();
|
|---|
| 948 | gPad->Update();
|
|---|
| 949 | DrawHorizon(gPad);
|
|---|
| 950 | for (int i=0; i<fOriginal.GetSize(); i++)
|
|---|
| 951 | DrawSet(gPad, *(Set*)fOriginal.At(i));//, 10./hres1.GetMean());
|
|---|
| 952 |
|
|---|
| 953 | TText text;
|
|---|
| 954 | text.SetTextAlign(22);
|
|---|
| 955 | text.DrawText( 0.00, 0.66, "N");
|
|---|
| 956 | text.DrawText( 0.66, 0.00, "E");
|
|---|
| 957 | text.DrawText( 0.00, -0.66, "S");
|
|---|
| 958 | text.DrawText(-0.66, 0.00, "W");
|
|---|
| 959 |
|
|---|
| 960 | c1->cd(3);
|
|---|
| 961 | gPad->SetBorderMode(0);
|
|---|
| 962 | gPad->SetFrameBorderMode(0);
|
|---|
| 963 | gPad->SetTheta(90);
|
|---|
| 964 | gPad->SetPhi(90);
|
|---|
| 965 | h2res1.SetTitle(" Arb. Residuals after correction (scaled) ");
|
|---|
| 966 | h2res1.DrawCopy("surf1pol");
|
|---|
| 967 | gPad->Modified();
|
|---|
| 968 | gPad->Update();
|
|---|
| 969 | // for (int i=0; i<fCoordinates.GetSize(); i++)
|
|---|
| 970 | // DrawSet(gPad, *(Set*)fCoordinates.At(i), 10./hres2.GetMean(), par[0]);
|
|---|
| 971 |
|
|---|
| 972 | RaiseWindow();
|
|---|
| 973 | }
|
|---|
| 974 |
|
|---|
| 975 | void LoadCollection(TString fname)
|
|---|
| 976 | {
|
|---|
| 977 | ifstream fin(fname);
|
|---|
| 978 | if (!fin)
|
|---|
| 979 | {
|
|---|
| 980 | cout << "Collection '" << fname << "' not found!" << endl;
|
|---|
| 981 | return;
|
|---|
| 982 | }
|
|---|
| 983 |
|
|---|
| 984 | while (1)
|
|---|
| 985 | {
|
|---|
| 986 | TString line;
|
|---|
| 987 | line.ReadLine(fin);
|
|---|
| 988 | if (!fin)
|
|---|
| 989 | break;
|
|---|
| 990 |
|
|---|
| 991 | line = line.Strip(TString::kBoth);
|
|---|
| 992 | if (line[0]=='#')
|
|---|
| 993 | continue;
|
|---|
| 994 | if (line.Length()==0)
|
|---|
| 995 | continue;
|
|---|
| 996 |
|
|---|
| 997 | if (!line.EndsWith(".txt"))
|
|---|
| 998 | {
|
|---|
| 999 | cout << "WARNING: " << line << endl;
|
|---|
| 1000 | continue;
|
|---|
| 1001 | }
|
|---|
| 1002 |
|
|---|
| 1003 | LoadStars(line);
|
|---|
| 1004 | }
|
|---|
| 1005 | }
|
|---|
| 1006 |
|
|---|
| 1007 |
|
|---|
| 1008 | void LoadStars(TString fname="tpoint.txt")
|
|---|
| 1009 | {
|
|---|
| 1010 | if (fname.EndsWith(".col"))
|
|---|
| 1011 | {
|
|---|
| 1012 | LoadCollection(fname);
|
|---|
| 1013 | fFileNameStars = fname;
|
|---|
| 1014 | return;
|
|---|
| 1015 | }
|
|---|
| 1016 |
|
|---|
| 1017 | const Int_t size = fOriginal.GetSize();
|
|---|
| 1018 |
|
|---|
| 1019 | ifstream fin(fname);
|
|---|
| 1020 |
|
|---|
| 1021 | while (fin && fin.get()!='\n');
|
|---|
| 1022 | while (fin && fin.get()!='\n');
|
|---|
| 1023 | while (fin && fin.get()!='\n');
|
|---|
| 1024 | if (!fin)
|
|---|
| 1025 | {
|
|---|
| 1026 | cout << "File '" << fname << "' not found!" << endl;
|
|---|
| 1027 | return;
|
|---|
| 1028 | }
|
|---|
| 1029 |
|
|---|
| 1030 | while (1)
|
|---|
| 1031 | {
|
|---|
| 1032 | Set set;
|
|---|
| 1033 |
|
|---|
| 1034 | fin >> set; // Read data from file [deg], it is stored in [rad]
|
|---|
| 1035 | if (!fin)
|
|---|
| 1036 | break;
|
|---|
| 1037 |
|
|---|
| 1038 | fOriginal.Add(new Set(set));
|
|---|
| 1039 | }
|
|---|
| 1040 |
|
|---|
| 1041 | cout << "Found " << fOriginal.GetSize()-size;
|
|---|
| 1042 | cout << " sets of coordinates in " << fname;
|
|---|
| 1043 | cout << " (Total=" << fOriginal.GetSize() << ")" << endl;
|
|---|
| 1044 |
|
|---|
| 1045 | fFileNameStars = fname;
|
|---|
| 1046 | }
|
|---|
| 1047 |
|
|---|
| 1048 | // --------------------------------------------------------------------------
|
|---|
| 1049 | //
|
|---|
| 1050 | // Opens an open dialog
|
|---|
| 1051 | //
|
|---|
| 1052 | TString OpenDialog(EFileDialogMode mode=kFDOpen)
|
|---|
| 1053 | {
|
|---|
| 1054 | static const char *gOpenTypes[] =
|
|---|
| 1055 | {
|
|---|
| 1056 | "TPoint files", "*.txt",
|
|---|
| 1057 | "Collection files", "*.col",
|
|---|
| 1058 | "All files", "*",
|
|---|
| 1059 | NULL, NULL
|
|---|
| 1060 | };
|
|---|
| 1061 |
|
|---|
| 1062 | static TString dir("tpoint/");
|
|---|
| 1063 |
|
|---|
| 1064 | TGFileInfo fi; // fFileName and fIniDir deleted in ~TGFileInfo
|
|---|
| 1065 |
|
|---|
| 1066 | fi.fFileTypes = (const char**)gOpenTypes;
|
|---|
| 1067 | fi.fIniDir = StrDup(dir);
|
|---|
| 1068 |
|
|---|
| 1069 | new TGFileDialog(fClient->GetRoot(), this, mode, &fi);
|
|---|
| 1070 |
|
|---|
| 1071 | if (!fi.fFilename)
|
|---|
| 1072 | return 0;
|
|---|
| 1073 |
|
|---|
| 1074 | dir = fi.fIniDir;
|
|---|
| 1075 |
|
|---|
| 1076 | return fi.fFilename;
|
|---|
| 1077 | }
|
|---|
| 1078 |
|
|---|
| 1079 | Bool_t ProcessMessage(Long_t msg, Long_t mp1, Long_t)
|
|---|
| 1080 | {
|
|---|
| 1081 | // cout << "Msg: " << hex << GET_MSG(msg) << endl;
|
|---|
| 1082 | // cout << "SubMsg: " << hex << GET_SUBMSG(msg) << dec << endl;
|
|---|
| 1083 | switch (GET_MSG(msg))
|
|---|
| 1084 | {
|
|---|
| 1085 | case kC_COMMAND:
|
|---|
| 1086 | switch (GET_SUBMSG(msg))
|
|---|
| 1087 | {
|
|---|
| 1088 | case kCM_BUTTON:
|
|---|
| 1089 | switch (mp1)
|
|---|
| 1090 | {
|
|---|
| 1091 | case kTbFit:
|
|---|
| 1092 | {
|
|---|
| 1093 | Double_t before=0;
|
|---|
| 1094 | Double_t after=0;
|
|---|
| 1095 | Double_t backw=0;
|
|---|
| 1096 | Fit(before, after, backw);
|
|---|
| 1097 | DisplayBending();
|
|---|
| 1098 | DisplayResult(before, after, backw);
|
|---|
| 1099 | }
|
|---|
| 1100 | return kTRUE;
|
|---|
| 1101 | case kTbLoad:
|
|---|
| 1102 | fBending.Load(OpenDialog());
|
|---|
| 1103 | DisplayBending();
|
|---|
| 1104 | return kTRUE;
|
|---|
| 1105 | case kTbSave:
|
|---|
| 1106 | fBending.Save(OpenDialog(kFDSave));
|
|---|
| 1107 | return kTRUE;
|
|---|
| 1108 | case kTbLoadStars:
|
|---|
| 1109 | LoadStars(OpenDialog());
|
|---|
| 1110 | DisplayData();
|
|---|
| 1111 | return kTRUE;
|
|---|
| 1112 | case kTbReset:
|
|---|
| 1113 | fBending.Clear();
|
|---|
| 1114 | DisplayBending();
|
|---|
| 1115 | return kTRUE;
|
|---|
| 1116 | case kTbReloadStars:
|
|---|
| 1117 | fOriginal.Delete();
|
|---|
| 1118 | LoadStars(fFileNameStars); // FIXME: Use TGLabel!
|
|---|
| 1119 | DisplayData();
|
|---|
| 1120 | return kTRUE;
|
|---|
| 1121 | case kTbResetStars:
|
|---|
| 1122 | fOriginal.Delete();
|
|---|
| 1123 | DisplayData();
|
|---|
| 1124 | return kTRUE;
|
|---|
| 1125 | }
|
|---|
| 1126 | return kTRUE;
|
|---|
| 1127 | }
|
|---|
| 1128 | return kTRUE;
|
|---|
| 1129 | }
|
|---|
| 1130 | return kTRUE;
|
|---|
| 1131 | }
|
|---|
| 1132 |
|
|---|
| 1133 | void AddTextButton(TGCompositeFrame *f, TString txt, Int_t id=-1, TGLayoutHints *h=0)
|
|---|
| 1134 | {
|
|---|
| 1135 | TGButton *but = new TGTextButton(f, txt, id);
|
|---|
| 1136 | but->Associate(this);
|
|---|
| 1137 | f->AddFrame(but, h);
|
|---|
| 1138 | fList->Add(but);
|
|---|
| 1139 |
|
|---|
| 1140 | }
|
|---|
| 1141 |
|
|---|
| 1142 | void AddCheckButton(TGCompositeFrame *f, TString txt, Int_t id=-1, TGLayoutHints *h=0)
|
|---|
| 1143 | {
|
|---|
| 1144 | TGButton *but = new TGCheckButton(f, txt, id);
|
|---|
| 1145 | but->Associate(this);
|
|---|
| 1146 | f->AddFrame(but, h);
|
|---|
| 1147 | fList->Add(but);
|
|---|
| 1148 | }
|
|---|
| 1149 |
|
|---|
| 1150 | TGLabel *AddLabel(TGCompositeFrame *f, TString txt, TGLayoutHints *h=0)
|
|---|
| 1151 | {
|
|---|
| 1152 | TGLabel *l = new TGLabel(f, txt/*, TGLabel::GetDefaultGC()(), fFont*/);
|
|---|
| 1153 | f->AddFrame(l, h);
|
|---|
| 1154 | fList->Add(l);
|
|---|
| 1155 | fLabel.Add(l);
|
|---|
| 1156 | return l;
|
|---|
| 1157 | }
|
|---|
| 1158 |
|
|---|
| 1159 | void DisplayBending()
|
|---|
| 1160 | {
|
|---|
| 1161 | TArrayD par, err;
|
|---|
| 1162 | fBending.GetParameters(par);
|
|---|
| 1163 | fBending.GetError(err);
|
|---|
| 1164 |
|
|---|
| 1165 | TGLabel *l;
|
|---|
| 1166 |
|
|---|
| 1167 | for (int i=0; i<MPointing::GetNumPar(); i++)
|
|---|
| 1168 | {
|
|---|
| 1169 | l = (TGLabel*)fLabel.At(i);
|
|---|
| 1170 | l->SetText(Form("%.4f\xb0", par[i]));
|
|---|
| 1171 |
|
|---|
| 1172 | l = (TGLabel*)fLabel.At(MPointing::GetNumPar()+i);
|
|---|
| 1173 | l->SetText(Form("\xb1 %8.4f\xb0", err[i]));
|
|---|
| 1174 | }
|
|---|
| 1175 | }
|
|---|
| 1176 |
|
|---|
| 1177 | void DisplayData()
|
|---|
| 1178 | {
|
|---|
| 1179 | TGLabel *l = (TGLabel*)fLabel.At(3*MPointing::GetNumPar());
|
|---|
| 1180 | l->SetText(Form("%d data sets loaded.", fOriginal.GetSize()));
|
|---|
| 1181 | }
|
|---|
| 1182 |
|
|---|
| 1183 | void DisplayResult(Double_t before, Double_t after, Double_t backw)
|
|---|
| 1184 | {
|
|---|
| 1185 | TGLabel *l1 = (TGLabel*)fLabel.At(3*MPointing::GetNumPar()+1);
|
|---|
| 1186 | l1->SetText(Form("Before: %.1f +- %.1f SE", before, 0.));
|
|---|
| 1187 |
|
|---|
| 1188 | TGLabel *l2 = (TGLabel*)fLabel.At(3*MPointing::GetNumPar()+2);
|
|---|
| 1189 | l2->SetText(Form("After: %.1f +- %.1f SE", after, 0.));
|
|---|
| 1190 |
|
|---|
| 1191 | TGLabel *l3 = (TGLabel*)fLabel.At(3*MPointing::GetNumPar()+3);
|
|---|
| 1192 | l3->SetText(Form("Backw: %.1f +- %.1f SE", backw, 0.));
|
|---|
| 1193 | }
|
|---|
| 1194 |
|
|---|
| 1195 | public:
|
|---|
| 1196 | ~MFit()
|
|---|
| 1197 | {
|
|---|
| 1198 | if (fFont)
|
|---|
| 1199 | gVirtualX->DeleteFont(fFont);
|
|---|
| 1200 | }
|
|---|
| 1201 | MFit(const char *fname) : TGMainFrame(gClient->GetRoot(), 750, 370, kHorizontalFrame)
|
|---|
| 1202 | {
|
|---|
| 1203 | fCoordinates.SetOwner();
|
|---|
| 1204 | fOriginal.SetOwner();
|
|---|
| 1205 |
|
|---|
| 1206 | fList = new MGList;
|
|---|
| 1207 | fList->SetOwner();
|
|---|
| 1208 |
|
|---|
| 1209 | fFont = gVirtualX->LoadQueryFont("7x13bold");
|
|---|
| 1210 |
|
|---|
| 1211 | TGLayoutHints *hints0 = new TGLayoutHints(kLHintsExpandY, 7, 5, 5, 6);
|
|---|
| 1212 | TGLayoutHints *hints1 = new TGLayoutHints(kLHintsExpandX|kLHintsExpandY, 5, 7, 5, 6);
|
|---|
| 1213 | TGLayoutHints *hints2 = new TGLayoutHints(kLHintsCenterX|kLHintsCenterY, 5, 5, 5, 5);
|
|---|
| 1214 | fList->Add(hints0);
|
|---|
| 1215 | fList->Add(hints1);
|
|---|
| 1216 | fList->Add(hints2);
|
|---|
| 1217 |
|
|---|
| 1218 | TGGroupFrame *grp1 = new TGGroupFrame(this, "Control", kVerticalFrame);
|
|---|
| 1219 | AddFrame(grp1, hints0);
|
|---|
| 1220 | fList->Add(grp1);
|
|---|
| 1221 |
|
|---|
| 1222 | TGGroupFrame *grp2 = new TGGroupFrame(this, "Parameters", kHorizontalFrame);
|
|---|
| 1223 | AddFrame(grp2, hints1);
|
|---|
| 1224 | fList->Add(grp2);
|
|---|
| 1225 |
|
|---|
| 1226 |
|
|---|
| 1227 |
|
|---|
| 1228 | TGLayoutHints *hints4 = new TGLayoutHints(kLHintsExpandX, 5, 5, 3);
|
|---|
| 1229 | TGLayoutHints *hints5 = new TGLayoutHints(kLHintsExpandX, 5, 5, 10);
|
|---|
| 1230 | AddTextButton(grp1, "Load Pointing Model", kTbLoad, hints5);
|
|---|
| 1231 | AddTextButton(grp1, "Save Pointing Model", kTbSave, hints4);
|
|---|
| 1232 | AddTextButton(grp1, "Fit Parameters", kTbFit, hints5);
|
|---|
| 1233 | AddTextButton(grp1, "Reset Parameters", kTbReset, hints4);
|
|---|
| 1234 | AddTextButton(grp1, "Load Stars", kTbLoadStars, hints5);
|
|---|
| 1235 | AddTextButton(grp1, "Reset Stars", kTbResetStars, hints4);
|
|---|
| 1236 | AddTextButton(grp1, "Reload Stars", kTbReloadStars, hints4);
|
|---|
| 1237 | fList->Add(hints4);
|
|---|
| 1238 | fList->Add(hints5);
|
|---|
| 1239 |
|
|---|
| 1240 |
|
|---|
| 1241 | TGHorizontalFrame *comp = new TGHorizontalFrame(grp2, 1, 1);
|
|---|
| 1242 | grp2->AddFrame(comp);
|
|---|
| 1243 | fList->Add(comp);
|
|---|
| 1244 |
|
|---|
| 1245 | TGLayoutHints *hints3 = new TGLayoutHints(kLHintsLeft|kLHintsTop, 0, 20, 5, 0);
|
|---|
| 1246 | fList->Add(hints3);
|
|---|
| 1247 |
|
|---|
| 1248 | TGLabel *l;
|
|---|
| 1249 |
|
|---|
| 1250 | TGVerticalFrame *vframe = new TGVerticalFrame(comp, 1, 1);
|
|---|
| 1251 | comp->AddFrame(vframe, hints3);
|
|---|
| 1252 | fList->Add(vframe);
|
|---|
| 1253 |
|
|---|
| 1254 | for (int i=0; i<MPointing::GetNumPar(); i++)
|
|---|
| 1255 | AddCheckButton(vframe, fBending.GetVarName(i), i);
|
|---|
| 1256 |
|
|---|
| 1257 | vframe = new TGVerticalFrame(comp, 1, 1);
|
|---|
| 1258 | comp->AddFrame(vframe, hints3);
|
|---|
| 1259 | fList->Add(vframe);
|
|---|
| 1260 |
|
|---|
| 1261 | l = new TGLabel(vframe, "+000.0000");
|
|---|
| 1262 | l->SetTextJustify(kTextRight);
|
|---|
| 1263 | fList->Add(l);
|
|---|
| 1264 | fLabel.Add(l);
|
|---|
| 1265 |
|
|---|
| 1266 | TGButton *but = (TGButton*)fList->FindWidget(0);
|
|---|
| 1267 |
|
|---|
| 1268 | TGLayoutHints *h = new TGLayoutHints(kLHintsCenterY, 0, 0, but->GetHeight()-l->GetHeight());
|
|---|
| 1269 | fList->Add(h);
|
|---|
| 1270 |
|
|---|
| 1271 | vframe->AddFrame(l,h);
|
|---|
| 1272 |
|
|---|
| 1273 | for (int i=1; i<MPointing::GetNumPar(); i++)
|
|---|
| 1274 | AddLabel(vframe, "+000.0000", h)->SetTextJustify(kTextRight);
|
|---|
| 1275 |
|
|---|
| 1276 | vframe = new TGVerticalFrame(comp, 1, 1);
|
|---|
| 1277 | comp->AddFrame(vframe, hints3);
|
|---|
| 1278 | fList->Add(vframe);
|
|---|
| 1279 |
|
|---|
| 1280 | for (int i=0; i<MPointing::GetNumPar(); i++)
|
|---|
| 1281 | AddLabel(vframe, "\xb1 00.0000\xb0", h)->SetTextJustify(kTextRight);
|
|---|
| 1282 |
|
|---|
| 1283 | vframe = new TGVerticalFrame(comp, 1, 1);
|
|---|
| 1284 | comp->AddFrame(vframe, hints3);
|
|---|
| 1285 | fList->Add(vframe);
|
|---|
| 1286 |
|
|---|
| 1287 | for (int i=0; i<MPointing::GetNumPar(); i++)
|
|---|
| 1288 | AddLabel(vframe, fBending.GetDescription(i), h);
|
|---|
| 1289 |
|
|---|
| 1290 | l = new TGLabel(grp1, "0000000 Data Sets loaded.");
|
|---|
| 1291 | grp1->AddFrame(l, hints5);
|
|---|
| 1292 | fList->Add(l);
|
|---|
| 1293 | fLabel.Add(l);
|
|---|
| 1294 |
|
|---|
| 1295 | l = new TGLabel(grp1, "");
|
|---|
| 1296 | l->SetTextJustify(kTextLeft);
|
|---|
| 1297 | grp1->AddFrame(l, hints5);
|
|---|
| 1298 | fList->Add(l);
|
|---|
| 1299 | fLabel.Add(l);
|
|---|
| 1300 |
|
|---|
| 1301 | l = new TGLabel(grp1, "");
|
|---|
| 1302 | l->SetTextJustify(kTextLeft);
|
|---|
| 1303 | grp1->AddFrame(l, hints5);
|
|---|
| 1304 | fList->Add(l);
|
|---|
| 1305 | fLabel.Add(l);
|
|---|
| 1306 |
|
|---|
| 1307 | l = new TGLabel(grp1, "");
|
|---|
| 1308 | l->SetTextJustify(kTextLeft);
|
|---|
| 1309 | grp1->AddFrame(l, hints5);
|
|---|
| 1310 | fList->Add(l);
|
|---|
| 1311 | fLabel.Add(l);
|
|---|
| 1312 |
|
|---|
| 1313 |
|
|---|
| 1314 | ((TGCheckButton*)fList->FindWidget(0))->SetState(kButtonDown);
|
|---|
| 1315 | ((TGCheckButton*)fList->FindWidget(1))->SetState(kButtonDown);
|
|---|
| 1316 | ((TGCheckButton*)fList->FindWidget(6))->SetState(kButtonDown);
|
|---|
| 1317 | ((TGCheckButton*)fList->FindWidget(10))->SetState(kButtonDown);
|
|---|
| 1318 | ((TGCheckButton*)fList->FindWidget(12))->SetState(kButtonDown);
|
|---|
| 1319 | ((TGCheckButton*)fList->FindWidget(17))->SetState(kButtonDown);
|
|---|
| 1320 |
|
|---|
| 1321 | SetWindowName("TPoint Fitting Window");
|
|---|
| 1322 | SetIconName("TPoint++");
|
|---|
| 1323 |
|
|---|
| 1324 | Layout();
|
|---|
| 1325 |
|
|---|
| 1326 | MapSubwindows();
|
|---|
| 1327 | MapWindow();
|
|---|
| 1328 |
|
|---|
| 1329 | if (fname)
|
|---|
| 1330 | LoadStars(fname);
|
|---|
| 1331 |
|
|---|
| 1332 | DisplayBending();
|
|---|
| 1333 | DisplayData();
|
|---|
| 1334 | }
|
|---|
| 1335 | ClassDef(MFit, 0)
|
|---|
| 1336 | };
|
|---|
| 1337 |
|
|---|
| 1338 | ClassImp(MFit);
|
|---|
| 1339 |
|
|---|
| 1340 | void gui(const char *fname=NULL)
|
|---|
| 1341 | {
|
|---|
| 1342 | gErrorIgnoreLevel = kError;
|
|---|
| 1343 | new MFit(fname);
|
|---|
| 1344 | // TF1 f1("f1", "[0]/cos((90-x)*3.1415/180)", 0, 90)
|
|---|
| 1345 | }
|
|---|