Created
August 25, 2014 01:57
-
-
Save cvson/42d990b5fd96e0760954 to your computer and use it in GitHub Desktop.
Solve Random walk problem with Monte Carlo Method
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
{ | |
TH2F *h = new TH2F("h","h",10,0,9,10,0,9); | |
TCanvas *c = new TCanvas("c","c"); | |
c->Range(-0.3373713,-2.125,3.036341,9.125); | |
//new TCanvas; | |
//gPad->Range(-0.3373713,-2.125,3.036341,9.125); | |
gStyle->SetOptStat(0); | |
c->cd(); | |
h->SetTitle(""); | |
h->Draw(); | |
TLine *hline; | |
Int_t ci; | |
for (int i=0; i<10; i++){ | |
hline = new TLine(i,0,i,9); | |
ci = TColor::GetColor("#0B3861"); | |
hline->SetLineColor(ci); | |
hline->SetLineWidth(3); | |
hline->Draw("same"); | |
hline = new TLine(0,i,9,i); | |
ci = TColor::GetColor("#B45F04"); | |
hline->SetLineColor(ci); | |
hline->Draw("same"); | |
} | |
TPad *l = new TPad("l","l",0.24,0.75,0.3,.84); | |
l->SetFillStyle(4000); | |
l->Draw(); | |
l->cd(); | |
TImage *img = TImage::Open("users.gif"); | |
img->Draw(); | |
l->Update(); | |
//delete l; | |
//delete img; | |
c->cd(); | |
TPad *l2 = new TPad("l2","l2",0.74,0.27,0.82,0.35); | |
l2->SetFillStyle(4000); | |
l2->Draw(); | |
l2->cd(); | |
TImage *img2 = TImage::Open("users.gif"); | |
img2->Draw(); | |
l2->Update(); | |
c->Print("plots/walkMap.png"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment