Changeset 18625 for trunk/FACT++
- Timestamp:
- 09/18/16 14:50:59 (8 years ago)
- Location:
- trunk/FACT++/drive
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/drive/TPointGui.cc
r18618 r18625 1 1 #include "TPointGui.h" 2 2 3 #include <iomanip> 3 4 #include <fstream> 4 5 #include <stdlib.h> 6 7 #include <TROOT.h> 8 #include <TClass.h> 9 #include <TSystem.h> 5 10 6 11 #include <TGLabel.h> … … 24 29 #include <TGraphErrors.h> 25 30 26 #include "MLog.h"27 #include "MLogManip.h"28 29 #include "MGList.h"30 31 31 #include "TPointStar.h" 32 32 33 ClassImp(TPointGui);34 35 33 using namespace std; 36 34 37 TPointGui::TPointGui(const char *fname, const char *mod) : TGMainFrame(gClient->GetRoot(), 750, 435, kHorizontalFrame), fExitLoopOnClose(kFALSE),38 fAzMin( -180), fAzMax(180), fZdMin(0), fZdMax(90), fMagMin(0), fLimit(0.05)35 TPointGui::TPointGui(const string fname, const string mod) : TGMainFrame(gClient->GetRoot(), 650, 435, kHorizontalFrame), fExitLoopOnClose(kFALSE), 36 fAzMin(0), fAzMax(360), fZdMin(0), fZdMax(90), fMagMax(10), fLimit(0.05) 39 37 { 40 38 fCoordinates.SetOwner(); 41 39 fOriginal.SetOwner(); 42 40 43 fList = new MGList;41 fList = new TList; 44 42 fList->SetOwner(); 43 44 gROOT->GetListOfCleanups()->Add(fList); 45 fList->SetBit(kMustCleanup); 45 46 46 47 fFont = gVirtualX->LoadQueryFont("7x13bold"); … … 90 91 AddCheckButton(vframe, fBending.GetVarName(i), i); 91 92 92 TGButton *but = (TGButton*) fList->FindWidget(0);93 TGButton *but = (TGButton*)FindWidget(0); 93 94 94 95 comp->AddFrame(vframe, hints3); … … 213 214 TGTextEntry *entry1 = new TGTextEntry(v1, Form("%.1f", fAzMin), kIdAzMin); 214 215 TGTextEntry *entry2 = new TGTextEntry(v2, Form("%.1f", fAzMax), kIdAzMax); 215 TGTextEntry *entry3 = new TGTextEntry(v3, Form("%.1f", fMagM in), kIdMagMin);216 TGTextEntry *entry3 = new TGTextEntry(v3, Form("%.1f", fMagMax), kIdMagMax); 216 217 TGTextEntry *entry4 = new TGTextEntry(v1, Form("%.1f", fZdMin), kIdZdMin); 217 218 TGTextEntry *entry5 = new TGTextEntry(v2, Form("%.1f", fZdMax), kIdZdMax); … … 251 252 252 253 // FIXME: Move this to the rc-file. 253 ((TGCheckButton*)fList->FindWidget(0))->SetState(kButtonDown); 254 ((TGCheckButton*)fList->FindWidget(1))->SetState(kButtonDown); 255 ((TGCheckButton*)fList->FindWidget(5))->SetState(kButtonDown); 256 ((TGCheckButton*)fList->FindWidget(6))->SetState(kButtonDown); 257 ((TGCheckButton*)fList->FindWidget(9))->SetState(kButtonDown); 258 ((TGCheckButton*)fList->FindWidget(11))->SetState(kButtonDown); 259 ((TGCheckButton*)fList->FindWidget(15))->SetState(kButtonDown); 260 ((TGCheckButton*)fList->FindWidget(16))->SetState(kButtonDown); 261 ((TGCheckButton*)fList->FindWidget(17))->SetState(kButtonDown); 262 263 ((TGCheckButton*)fList->FindWidget(19))->SetState(kButtonDisabled); 264 ((TGCheckButton*)fList->FindWidget(20))->SetState(kButtonDisabled); 265 ((TGCheckButton*)fList->FindWidget(21))->SetState(kButtonDisabled); 266 ((TGCheckButton*)fList->FindWidget(22))->SetState(kButtonDisabled); 267 268 ((TGCheckButton*)fList->FindWidget(19+2*MPointing::GetNumPar()))->SetState(kButtonDisabled); 269 ((TGCheckButton*)fList->FindWidget(20+2*MPointing::GetNumPar()))->SetState(kButtonDisabled); 270 ((TGCheckButton*)fList->FindWidget(21+2*MPointing::GetNumPar()))->SetState(kButtonDisabled); 271 ((TGCheckButton*)fList->FindWidget(22+2*MPointing::GetNumPar()))->SetState(kButtonDisabled); 272 254 ((TGCheckButton*)FindWidget(0))->SetState(kButtonDown); 255 ((TGCheckButton*)FindWidget(1))->SetState(kButtonDown); 256 ((TGCheckButton*)FindWidget(3))->SetState(kButtonDown); 257 ((TGCheckButton*)FindWidget(4))->SetState(kButtonDown); 258 ((TGCheckButton*)FindWidget(5))->SetState(kButtonDown); 259 ((TGCheckButton*)FindWidget(6))->SetState(kButtonDown); 260 ((TGCheckButton*)FindWidget(7))->SetState(kButtonDown); 261 ((TGCheckButton*)FindWidget(8))->SetState(kButtonDown); 262 ((TGCheckButton*)FindWidget(11))->SetState(kButtonDown); 263 ((TGCheckButton*)FindWidget(12))->SetState(kButtonDown); 264 ((TGCheckButton*)FindWidget(13))->SetState(kButtonDown); 265 ((TGCheckButton*)FindWidget(14))->SetState(kButtonDown); 266 /* 267 ((TGCheckButton*)FindWidget(19))->SetState(kButtonDisabled); 268 ((TGCheckButton*)FindWidget(20))->SetState(kButtonDisabled); 269 ((TGCheckButton*)FindWidget(21))->SetState(kButtonDisabled); 270 ((TGCheckButton*)FindWidget(22))->SetState(kButtonDisabled); 271 272 ((TGCheckButton*)FindWidget(19+2*MPointing::GetNumPar()))->SetState(kButtonDisabled); 273 ((TGCheckButton*)FindWidget(20+2*MPointing::GetNumPar()))->SetState(kButtonDisabled); 274 ((TGCheckButton*)FindWidget(21+2*MPointing::GetNumPar()))->SetState(kButtonDisabled); 275 ((TGCheckButton*)FindWidget(22+2*MPointing::GetNumPar()))->SetState(kButtonDisabled); 276 */ 273 277 SetWindowName("Telesto"); 274 278 SetIconName("Telesto"); … … 279 283 MapWindow(); 280 284 281 if (! TString(fname).IsNull())282 LoadStars(fname );283 if (! TString(mod).IsNull())284 fBending.Load(mod );285 if (!fname.empty()) 286 LoadStars(fname.c_str()); 287 if (!mod.empty()) 288 fBending.Load(mod.c_str()); 285 289 286 290 DisplayBending(); … … 306 310 bend.SetParameters(par); // Set Parameters [deg] to MPointing 307 311 312 int cnt = 0; 308 313 for (int i=0; i<fCoordinates.GetSize(); i++) 309 314 { … … 312 317 if (set.GetStarZd()<fZdMin || set.GetStarZd()>fZdMax || 313 318 set.GetStarAz()<fAzMin || set.GetStarAz()>fAzMax || 314 set.GetMag() <fMagMin)319 set.GetMag() >fMagMax) 315 320 continue; 316 321 317 322 set.Adjust(bend); 318 323 319 Double_t err = 0.0 1; // [deg] = 0.25SE324 Double_t err = 0.0043; // [deg] 320 325 Double_t res = set.GetResidual();//(&err); 321 326 res /= err; 322 327 323 328 f += res*res; 324 } 325 326 f /= fCoordinates.GetSize(); 329 cnt++; 330 } 331 332 f /= cnt; 327 333 } 328 334 … … 351 357 void TPointGui::AddResetButton(TGCompositeFrame *f, Int_t id, TGLayoutHints *h, Int_t height) 352 358 { 353 TGPictureButton *but = new TGPictureButton(f, " tpoint/skull.xpm", id);359 TGPictureButton *but = new TGPictureButton(f, "drive/skull.xpm", id); 354 360 but->SetHeight(height); // Offsets from TGLayout 355 361 but->SetWidth(height); … … 395 401 { 396 402 TGLabel *l1 = (TGLabel*)fLabel.At(3*MPointing::GetNumPar()+1); 397 l1->SetText(Form("Before: %.1f +- %.1f SE", before, 0.));403 l1->SetText(Form("Before: %.1f arcsec", before*360*3600/16384)); 398 404 399 405 TGLabel *l2 = (TGLabel*)fLabel.At(3*MPointing::GetNumPar()+2); 400 l2->SetText(Form("After: %.1f +- %.1f SE", after, 0.));406 l2->SetText(Form("After: %.1f arcsec", after*360*3600/16384)); 401 407 402 408 TGLabel *l3 = (TGLabel*)fLabel.At(3*MPointing::GetNumPar()+3); 403 l3->SetText(Form("Backw: %.1f +- %.1f SE", backw, 0.));409 l3->SetText(Form("Backw: %.1f arcsec", backw*360*3600/16384)); 404 410 } 405 411 … … 410 416 if (!view) 411 417 { 412 gLog << err<< "No View!" << endl;418 cout << "No View!" << endl; 413 419 return; 414 420 } … … 434 440 if (!view) 435 441 { 436 gLog << err<< "No View!" << endl;442 cout << "No View!" << endl; 437 443 return; 438 444 } … … 548 554 if (!view) 549 555 { 550 gLog << err<< "No View!" << endl;556 cout << "No View!" << endl; 551 557 return; 552 558 } … … 555 561 if (!fin) 556 562 { 557 gLog << err<< "ERROR - " << fname << " not found." << endl;563 cout << "ERROR - " << fname << " not found." << endl; 558 564 return; 559 565 } … … 621 627 if (!fin) 622 628 { 623 gLog << err<< "Collection '" << fname << "' not found!" << endl;629 cout << "Collection '" << fname << "' not found!" << endl; 624 630 return; 625 631 } … … 637 643 if (line.Length()==0) 638 644 continue; 639 645 /* 640 646 if (!line.EndsWith(".txt")) 641 647 { 642 gLog << warn<< "WARNING: " << line << endl;648 cout << "WARNING: " << line << endl; 643 649 continue; 644 650 } 645 651 */ 646 652 LoadStars(line); 647 653 } … … 667 673 if (!fin) 668 674 { 669 gLog << err<< "File '" << fname << "' not found!" << endl;675 cout << "File '" << fname << "' not found!" << endl; 670 676 return; 671 677 } … … 685 691 } 686 692 687 gLog << all<< "Found " << fOriginal.GetSize()-size;688 gLog<< " sets of coordinates in " << fname;689 gLog<< " (Total=" << fOriginal.GetSize() << ")" << endl;693 cout << "Found " << fOriginal.GetSize()-size; 694 cout << " sets of coordinates in " << fname; 695 cout << " (Total=" << fOriginal.GetSize() << ")" << endl; 690 696 691 697 fFileNameStars = fname; … … 695 701 Float_t TPointGui::GetFloat(Int_t id) const 696 702 { 697 return atof(static_cast<TGTextEntry*>( fList->FindWidget(id))->GetText());703 return atof(static_cast<TGTextEntry*>(FindWidget(id))->GetText()); 698 704 } 699 705 … … 775 781 fZdMax = GetFloat(kIdZdMax); 776 782 return kTRUE; 777 case kIdMagM in:778 fMagM in = GetFloat(kIdMagMin);783 case kIdMagMax: 784 fMagMax = GetFloat(kIdMagMax); 779 785 return kTRUE; 780 786 case kIdLimit: … … 795 801 if (fOriginal.GetSize()==0) 796 802 { 797 gLog << warn<< "Sorry, no input data loaded..." << endl;803 cout << "Sorry, no input data loaded..." << endl; 798 804 return; 799 805 } … … 803 809 fCoordinates.Add(new TPointStar(*(TPointStar*)fOriginal.At(i))); 804 810 805 gLog << all<< "-----------------------------------------------------------------------" << endl;811 cout << "-----------------------------------------------------------------------" << endl; 806 812 807 813 gStyle->SetOptStat("emro"); … … 811 817 TH1F hres3("Res3", " Residuals after backward correction ", fOriginal.GetSize()/3, 0, 0.3); 812 818 813 TProfile proaz ("ProAz", " \\Delta profile vs. Az", 48, -180, 180);814 TProfile prozd ("ProZd", " \\Delta profile vs. Zd", 60, 0,90);815 TProfile promag("ProMag", " \\Delta profile vs. Mag", 40, 1, 4);819 TProfile proaz ("ProAz", " \\Delta profile vs. Az", 24, 0, 360); 820 TProfile prozd ("ProZd", " \\Delta profile vs. Zd", 30, 0, 90); 821 TProfile promag("ProMag", " \\Delta profile vs. Mag", 10, 1, 10); 816 822 817 823 hres1.SetXTitle("\\Delta [\\circ]"); … … 856 862 for (int i=0; i<MPointing::GetNumPar(); i++) 857 863 { 858 TGButton *l = (TGButton*) fList->FindWidget(i);864 TGButton *l = (TGButton*)FindWidget(i); 859 865 minuit.FixParameter(i); 860 866 if (l->GetState()==kButtonDown) … … 865 871 //minuit.Command("SHOW LIMITS"); 866 872 867 gLog << inf<< endl;868 gLog<< "Starting fit..." << endl;869 gLog<< "For the fit an measurement error in the residual of ";870 gLog<< "0.02deg (=1SE) is assumed." << endl;871 gLog<< endl;873 cout << endl; 874 cout << "Starting fit..." << endl; 875 cout << "For the fit an measurement error in the residual of "; 876 cout << "0.02deg (=1SE) is assumed." << endl; 877 cout << endl; 872 878 873 879 Int_t ierflg = 0; 874 880 ierflg = minuit.Migrad(); 875 gLog << inf<< "Migrad returns " << ierflg << endl;881 cout << "Migrad returns " << ierflg << endl; 876 882 // minuit.Release(2); 877 883 ierflg = minuit.Migrad(); 878 gLog << inf<< "Migrad returns " << ierflg << endl << endl;884 cout << "Migrad returns " << ierflg << endl << endl; 879 885 880 886 // … … 883 889 fBending.GetMinuitParameters(minuit); 884 890 fBending.PrintMinuitParameters(minuit); 885 gLog<< endl;891 cout << endl; 886 892 //fBending.Save("bending_magic.txt"); 887 893 … … 906 912 b2.SetParameters(par); 907 913 908 gLog << all<< endl << "Sets with Residual exceeding " << fLimit << "deg:" << endl;909 gLog<< " StarAz StarEl RawAz RawEl Mag Residual Filename" << endl;914 cout << endl << "Sets with Residual exceeding " << fLimit << "deg:" << endl; 915 cout << " StarAz StarEl RawAz RawEl Mag Residual Filename" << endl; 910 916 911 917 // … … 919 925 920 926 ZdAz za(set0.GetStarZdAz()); 921 za *= kRad2Deg;927 za *= 180/M_PI; 922 928 923 929 // … … 947 953 948 954 if (resi>fLimit) // 0.13 949 gLog << all<< " " << orig << " <" << Form("%5.3f", resi) << "> " << orig.GetName() << endl;955 cout << " " << orig << " <" << Form("%5.3f", resi) << "> " << orig.GetName() << endl; 950 956 951 957 proaz.Fill(za.Az(), set0.GetResidual(&err)); … … 964 970 } 965 971 966 gLog<< "done." << endl << endl;972 cout << "done." << endl << endl; 967 973 968 974 // … … 971 977 const Stat_t ov = hres2.GetBinContent(hres2.GetNbinsX()+1); 972 978 if (ov>0) 973 gLog << warn<< "WARNING: " << ov << " overflows in residuals." << endl;974 975 976 977 gLog << inf<< dec << endl;978 gLog << "Number of calls to FCN: " << minuit.fNfcn << endl;979 gLog << "Minimum value found for FCN (Chi^2?): " << minuit.fAmin << endl;980 gLog << " Fit-Probability(?): " << TMath::Prob(minuit.fAmin/*fOriginal.GetSize()*/, fOriginal.GetSize()-minuit.GetNumFreePars())*100 << "%" << endl;981 gLog << "Chi^2/NDF: " << minuit.fAmin/(fOriginal.GetSize()-minuit.GetNumFreePars()) << endl;979 cout << "WARNING: " << ov << " overflows in residuals." << endl; 980 981 982 983 cout << dec << endl; 984 cout << " Number of calls to FCN: " << minuit.fNfcn << endl; 985 cout << "Minimum value found for FCN (Chi^2): " << minuit.fAmin << endl; 986 cout << " Fit-Probability: " << TMath::Prob(minuit.fAmin/*fOriginal.GetSize()*/, fOriginal.GetSize()-minuit.GetNumFreePars())*100 << "%" << endl; 987 cout << " Chi^2/NDF: " << minuit.fAmin/(fOriginal.GetSize()-minuit.GetNumFreePars()) << endl; 982 988 //cout << "Prob(?): " << TMath::Prob(fChisquare,ndf); 983 989 … … 989 995 // bending correction itself 990 996 // 991 gLog<< endl;992 gLog<< "Checking backward correction (raw-->star):" << endl;997 cout << endl; 998 cout << "Checking backward correction (raw-->star):" << endl; 993 999 for (int i=0; i<fCoordinates.GetSize(); i++) 994 1000 { … … 1008 1014 continue; 1009 1015 1010 gLog<< "DBack: " << setw(6) << set0.GetStarZd() << " " << setw(7) << set0.GetStarAz() << ": ";1011 gLog<< "ResB="<< setw(7) << res0*60 << " ResF=" << setw(7) << res1*60 << " |ResB-ResF|=" << setw(7) << diff*60 << " arcmin" << endl;1012 } 1013 gLog<< "OK." << endl;1014 gLog<< endl;1016 cout << "DBack: " << setw(6) << set0.GetStarZd() << " " << setw(7) << set0.GetStarAz() << ": "; 1017 cout << "ResB="<< setw(7) << res0*60 << " ResF=" << setw(7) << res1*60 << " |ResB-ResF|=" << setw(7) << diff*60 << " arcmin" << endl; 1018 } 1019 cout << "OK." << endl; 1020 cout << endl; 1015 1021 1016 1022 const Double_t max1 = TMath::Max(gaz.GetHistogram()->GetMaximum(), gdaz.GetHistogram()->GetMaximum()); … … 1022 1028 const Double_t min3 = TMath::Min(grzd.GetHistogram()->GetMinimum(), graz.GetHistogram()->GetMinimum()); 1023 1029 1024 const Double_t absmax1 = TMath::Max(max1, TMath::Abs(min1));1025 const Double_t absmax2 = TMath::Max(max2, TMath::Abs(min2));1026 const Double_t absmax3 = TMath::Max(max3, TMath::Abs(min3));1030 const Double_t absmax1 = 0.05;//TMath::Max(max1, TMath::Abs(min1)); 1031 const Double_t absmax2 = 0.05;//TMath::Max(max2, TMath::Abs(min2)); 1032 const Double_t absmax3 = 0.05;//TMath::Max(max3, TMath::Abs(min3)); 1027 1033 1028 1034 gaz.SetMaximum(absmax1); … … 1232 1238 cout << "-------------------------" << endl; 1233 1239 cout << "before: " << Form("%6.4f", hres1.GetMean()) << " \xb1 " << Form("%6.4f", hres1.GetRMS()) << " deg \t"; 1234 cout << "before: " << Form("%4.1f", hres1.GetMean()* 60) << " \xb1 " << Form("%.1f", hres1.GetRMS()*60) << " arcmin" << endl;1240 cout << "before: " << Form("%4.1f", hres1.GetMean()*3600) << " \xb1 " << Form("%.1f", hres1.GetRMS()*3600) << " arcsec" << endl; 1235 1241 cout << "after: " << Form("%6.4f", hres2.GetMean()) << " \xb1 " << Form("%6.4f", hres2.GetRMS()) << " deg \t"; 1236 cout << "after: " << Form("%4.1f", hres2.GetMean()* 60) << " \xb1 " << Form("%.1f", hres2.GetRMS()*60) << " arcmin" << endl;1242 cout << "after: " << Form("%4.1f", hres2.GetMean()*3600) << " \xb1 " << Form("%.1f", hres2.GetRMS()*3600) << " arcsec" << endl; 1237 1243 cout << "backw: " << Form("%6.4f", hres3.GetMean()) << " \xb1 " << Form("%6.4f", hres3.GetRMS()) << " deg \t"; 1238 cout << "backw: " << Form("%4.1f", hres3.GetMean()* 60) << " \xb1 " << Form("%.1f", hres3.GetRMS()*60) << " arcmin" << endl;1244 cout << "backw: " << Form("%4.1f", hres3.GetMean()*3600) << " \xb1 " << Form("%.1f", hres3.GetRMS()*3600) << " arcsec" << endl; 1239 1245 cout << endl; 1240 1246 cout << "before: " << Form("%4.1f", hres1.GetMean()*16348/360) << " \xb1 " << Form("%.1f", hres1.GetRMS()*16384/360) << " SE \t\t"; … … 1335 1341 } 1336 1342 1343 TObject *TPointGui::FindWidget(Int_t id) const 1344 { 1345 if (id<0) 1346 return NULL; 1347 1348 TObject *obj; 1349 TIter Next(fList); 1350 while ((obj=Next())) 1351 { 1352 const TGWidget *wid = (TGWidget*)obj->IsA()->DynamicCast(TGWidget::Class(), obj); 1353 if (!wid) 1354 continue; 1355 1356 if (id == wid->WidgetId()) 1357 return obj; 1358 } 1359 return NULL; 1360 } -
trunk/FACT++/drive/TPointGui.h
r18618 r18625 12 12 #include "MPointing.h" 13 13 14 class MGList; // To be removed!!!15 14 class TPointStar; 16 15 class TVirtualPad; 17 16 class TGLabel; 17 class TList; 18 18 19 19 class TPointGui : public TGMainFrame … … 33 33 kIdZdMin, 34 34 kIdZdMax, 35 kIdMagM in,35 kIdMagMax, 36 36 kIdLimit, 37 37 }; 38 38 39 MGList *fList;39 TList *fList; 40 40 41 41 TList fOriginal; … … 55 55 Float_t fZdMin; 56 56 Float_t fZdMax; 57 Float_t fMagM in;57 Float_t fMagMax; 58 58 59 59 Float_t fLimit; … … 61 61 void Fcn(Int_t &/*npar*/, Double_t */*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/); 62 62 static void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag); 63 64 TObject *FindWidget(Int_t id) const; 63 65 64 66 void AddTextButton(TGCompositeFrame *f, TString txt, Int_t id=-1, TGLayoutHints *h=0); … … 74 76 void DrawPolLine(TVirtualPad *pad, Double_t r0, Double_t phi0, Double_t r1, Double_t phi1); 75 77 void DrawSet(TVirtualPad *pad, TPointStar &set, Float_t scale=-1, Float_t angle=0); 76 void DrawHorizon(TVirtualPad *pad, const char *fname=" horizon.dat") const;78 void DrawHorizon(TVirtualPad *pad, const char *fname="drive/horizon.dat") const; 77 79 78 80 TString OpenDialog(TString &dir, EFileDialogMode mode=kFDOpen); … … 88 90 89 91 public: 90 TPointGui(const char *fname=NULL, const char *mod=NULL);92 TPointGui(const std::string fname, const std::string mod); 91 93 ~TPointGui(); 92 94 93 95 void SetExitLoopOnClose(Bool_t b=kTRUE) { fExitLoopOnClose=b; } 94 95 ClassDef(TPointGui, 0)96 96 }; 97 97
Note:
See TracChangeset
for help on using the changeset viewer.