Last active
May 6, 2019 08:12
-
-
Save cvson/e6b2caa3fcc131f1cf0e to your computer and use it in GitHub Desktop.
[Duong Bay Vang] to check #root #traffic #lifeapp #tutorials
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://us.24h.com.vn/tin-tuc-trong-ngay/su-that-ve-duong-bay-vang-qua-khong-phan-campuchia-c46a653855.html | |
void titleStyle(TH1* h1){ | |
h1->GetYaxis()->CenterTitle(); | |
h1->GetXaxis()->CenterTitle(); | |
h1->GetXaxis()->SetLabelSize(h1->GetXaxis()->GetTitleSize()*1.2); | |
h1->GetYaxis()->SetLabelSize(h1->GetYaxis()->GetTitleSize()*1.2); | |
h1->GetXaxis()->SetTitleSize(h1->GetXaxis()->GetLabelSize()*1.2); | |
h1->GetYaxis()->SetTitleSize(h1->GetYaxis()->GetLabelSize()*1.2); | |
h1->GetYaxis()->SetTitleOffset(0.9); | |
h1->GetXaxis()->SetTitleOffset(0.9); | |
} | |
void duongbayvang(){ | |
//normal flight | |
float normalLength = 1.2e3;//km | |
float normalFuel = 2.5e4;//lit | |
float normalTime = 105; | |
//Mai Trong Tuan estimation | |
float goldenLength = normalLength-200;//km | |
float goldenFuel = normalFuel-5e3;//lit | |
float goldenTime = normalTime-10;//minute | |
//Tran Dinh Ba estimation | |
float baLength = normalLength-412;//km | |
float baTime = normalTime-26;//minute | |
//test normal flight | |
float testLength = 1276; | |
float testTime = 108; | |
float testFuel = 4140;//kg | |
//test golden flight | |
float testGoldLength = 1191; | |
float testGoldTime = 103; | |
float testGoldFuel = 4330;//kg | |
float testGoldTimeTakeooff = 18.5;//minute | |
float testGoldTimeMiddle =72;//minute | |
float testGoldTimeLanding =testGoldTime - testGoldTimeTakeooff- testGoldTimeMiddle;//12.5 minute | |
float testGoldHeight = 10.668;//km | |
//http://www.airliners.net/aircraft-data/stats.main?id=24 | |
float a312maxspeed = 903;// | |
float a312ecospeed = 828; | |
//http://kinhdoanh.vnexpress.net/tin-tuc/doanh-nghiep/vietnam-airlines-hoan-tat-thu-nghiem-duong-bay-vang-3051605.html | |
float simdistance = 1140; | |
//test distance | |
float averageSpeedGolden = testGoldLength*60/testGoldTime; | |
float averageSpeedNorm = testLength*60/testTime; | |
//cout<<"speed normal "<<averageSpeedNorm<<" Golden "<<averageSpeedGolden<<endl; | |
float speedDeviation = TMath::Abs(averageSpeedGolden-averageSpeedNorm); | |
float randomSpeed; | |
float randomDistance; | |
const Int_t kIteration = 10000; | |
int counttest=0; | |
int countsim=0; | |
TH1 *hdistance = new TH1F("hdistance","hdistance",200,1e3,1.4e3); | |
gRandom->SetSeed(); | |
for (int i=0; i<kIteration; i++){ | |
if (i%100 == 0) printf("Processing %d/%d\n",i,kIteration); | |
randomSpeed = gRandom->Gaus(averageSpeedNorm,speedDeviation); | |
randomDistance = randomSpeed*testGoldTime/60; | |
if (randomDistance>testGoldLength) { | |
++counttest; | |
} | |
if (randomDistance>simdistance) { | |
++countsim; | |
} | |
//if (i%100 == 0) cout<<"distance "<<randomDistance<<endl; | |
hdistance->Fill(randomDistance); | |
} | |
TCanvas *c1 = new TCanvas("c1","c1",1000,800); | |
gStyle->SetOptStat(1); | |
gStyle->SetLineWidth(2); | |
TGaxis::SetMaxDigits(3); | |
hdistance->SetTitle(""); | |
hdistance->SetLineWidth(3); | |
hdistance->SetFillColor(16); | |
hdistance->GetXaxis()->SetTitle("Flight distance (km)"); | |
hdistance->GetYaxis()->SetTitle("Number of trials"); | |
titleStyle(hdistance); | |
Int_t ci; | |
//navy blue | |
ci = TColor::GetColor("#0B3861"); | |
hdistance->SetLineColor(ci); | |
hdistance->GetYaxis()->SetRangeUser(0,hdistance->GetMaximum()*1.2); | |
hdistance->Draw(); | |
TLine *pline = new TLine(testGoldLength, 0, testGoldLength,hdistance->GetMaximum()); | |
pline->SetLineWidth(3); | |
//UT orange | |
ci = TColor::GetColor("#B45F04"); | |
pline->SetLineColor(ci); | |
pline->Draw(); | |
//cout<<"higher than test "<<counttest*100.0/kIteration<<endl; | |
float ratioTest = counttest*100.0/kIteration; | |
TString strCountTest = Form("%.4g%% trials",ratioTest); | |
TLatex *tlx1 = new TLatex(0.55,0.3,strCountTest); | |
tlx1->SetNDC(kTRUE); // <- use NDC coordinate | |
tlx1->SetTextSize(0.04); | |
tlx1->SetTextColor(ci); | |
tlx1->Draw(); | |
TLine *psim = new TLine(simdistance, 0, simdistance,hdistance->GetMaximum()); | |
psim->SetLineWidth(3); | |
//UT orange | |
ci = TColor::GetColor("#1F9839"); | |
psim->SetLineColor(ci); | |
psim->Draw(); | |
//cout<<"higher than SIM "<<countsim*100/kIteration<<endl; | |
float ratioSIM = countsim*100.0/kIteration; | |
TString strCountSim = Form("%.4g%% trials",ratioSIM); | |
TLatex *tlx2 = new TLatex(0.2,0.3,strCountSim); | |
tlx2->SetNDC(kTRUE); // <- use NDC coordinate | |
tlx2->SetTextSize(0.04); | |
tlx2->SetTextColor(ci); | |
tlx2->Draw(); | |
TLegend* leg = new TLegend(0.15,0.6,0.4,0.8); | |
leg->SetFillStyle(0); | |
leg->SetBorderSize(0); | |
leg->AddEntry(hdistance,"Simulated distance","lf"); | |
leg->AddEntry(pline,"Tested Golden distance","l"); | |
leg->AddEntry(psim,"SIM Golden distance","l"); | |
leg->SetTextSize(0.035); | |
leg->Draw("same"); | |
c1->Print("duongbayvang.png"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment