Created
August 25, 2014 01:56
-
-
Save cvson/984c5404da6e4150982c to your computer and use it in GitHub Desktop.
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
void titleStyle(TH1* h1){ | |
h1->SetTitle(""); | |
h1->GetYaxis()->CenterTitle(); | |
h1->GetXaxis()->CenterTitle(); | |
h1->GetXaxis()->SetLabelSize(h1->GetXaxis()->GetTitleSize()*1.4); | |
h1->GetYaxis()->SetLabelSize(h1->GetYaxis()->GetTitleSize()*1.4); | |
h1->GetXaxis()->SetTitleSize(h1->GetXaxis()->GetLabelSize()*1.2); | |
h1->GetYaxis()->SetTitleSize(h1->GetYaxis()->GetLabelSize()*1.2); | |
h1->GetYaxis()->SetTitleOffset(0.9); | |
} | |
void titleStyle2D(TH2* h1){ | |
h1->SetTitle(""); | |
h1->GetYaxis()->CenterTitle(); | |
h1->GetXaxis()->CenterTitle(); | |
h1->GetXaxis()->SetLabelSize(h1->GetXaxis()->GetTitleSize()*1.4); | |
h1->GetYaxis()->SetLabelSize(h1->GetYaxis()->GetTitleSize()*1.4); | |
h1->GetXaxis()->SetTitleSize(h1->GetXaxis()->GetLabelSize()*1.2); | |
h1->GetYaxis()->SetTitleSize(h1->GetYaxis()->GetLabelSize()*1.2); | |
h1->GetYaxis()->SetTitleOffset(0.9); | |
} | |
void plot2dhist(TH2* h1, TString savename){ | |
new TCanvas; | |
titleStyle2D(h1); | |
Int_t ci; | |
ci = TColor::GetColor("#0B3861"); | |
h1->SetMarkerColor(ci); | |
h1->SetMarkerStyle(1); | |
h1->Draw(""); | |
TProfile *hprofile = (TProfile*)h1->ProfileX(); | |
hprofile->SetLineWidth(3); | |
hprofile->SetMarkerStyle(8); | |
ci = TColor::GetColor("#B45F04"); | |
hprofile->SetMarkerColor(ci); | |
hprofile->SetMarkerSize(1.2); | |
hprofile->SetLineColor(ci); | |
hprofile->Draw("same"); | |
gPad->Print("plots/randomwalk_"+savename+"2D.eps"); | |
gPad->Print("plots/randomwalk_"+savename+"2D.png"); | |
} | |
void plot4hist1d(TH1* h1, TH1* h2,TH1* h3,TH1* h4, TString savename){ | |
h1->SetLineWidth(3); | |
h2->SetLineWidth(3); | |
h3->SetLineWidth(3); | |
h4->SetLineWidth(3); | |
Int_t ci; | |
ci = TColor::GetColor("#0B3861"); | |
h1->SetLineColor(ci); | |
h2->SetLineColor(ci); | |
ci = TColor::GetColor("#B45F04"); | |
h3->SetLineColor(ci); | |
h4->SetLineColor(ci); | |
TCanvas *c1 = new TCanvas("c1",""); | |
gStyle->SetOptStat(1); | |
c1->Divide(2,2); | |
c1->cd(1); | |
titleStyle(h1); | |
h1->Draw(); | |
c1->cd(2); | |
titleStyle(h2); | |
h2->Draw(); | |
c1->cd(3); | |
titleStyle(h3); | |
h3->Draw(); | |
c1->cd(4); | |
titleStyle(h4); | |
h4->Draw(); | |
c1->Print("plots/randomwalk_"+savename+".png"); | |
} | |
void plotrandomWalk(){ | |
gROOT->ProcessLine(".x rootlogon.C"); | |
TFile *pfile = new TFile("randomWalk.root"); | |
TH2F* hstepvsdist = (TH2F*)pfile->Get("hstepvsdist"); | |
hstepvsdist->GetXaxis()->SetTitle("Initial distance btw two people"); | |
hstepvsdist->GetYaxis()->SetTitle("Step number to meet"); | |
plot2dhist(hstepvsdist,"hstepvsdist"); | |
TH1F *hx10 = (TH1F*)pfile->Get("hx10"); | |
TH1F *hx20 = (TH1F*)pfile->Get("hx20"); | |
TH1F *hy10 = (TH1F*)pfile->Get("hy10"); | |
TH1F *hy20 = (TH1F*)pfile->Get("hy20"); | |
plot4hist1d(hx10,hx20,hy10,hy20,"iniPos"); | |
TH1F *hstepLeft1 = (TH1F*)pfile->Get("hstepLeft1"); | |
TH1F *hstepRight1 = (TH1F*)pfile->Get("hstepRight1"); | |
TH1F *hstepUp1 = (TH1F*)pfile->Get("hstepUp1"); | |
TH1F *hstepDown1 = (TH1F*)pfile->Get("hstepDown1"); | |
plot4hist1d(hstepLeft1,hstepRight1,hstepUp1,hstepDown1,"turn_percentage1"); | |
TH1F *hstepLeft2 = (TH1F*)pfile->Get("hstepLeft2"); | |
TH1F *hstepRight2 = (TH1F*)pfile->Get("hstepRight2"); | |
TH1F *hstepUp2 = (TH1F*)pfile->Get("hstepUp2"); | |
TH1F *hstepDown2 = (TH1F*)pfile->Get("hstepDown2"); | |
plot4hist1d(hstepLeft2,hstepRight2,hstepUp2,hstepDown2,"turn_percentage2"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment