00001
00002
00003 {
00004 TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
00005 dir.ReplaceAll("hbars.C","../tree/cernbuild.C");
00006 dir.ReplaceAll("/./","/");
00007 if (!gInterpreter->IsLoaded(dir.Data())) gInterpreter->LoadMacro(dir.Data());
00008 TFile *f = (TFile*)gROOT->ProcessLineFast("cernbuild(1)");
00009 if (!f) return;
00010 TTree *T = (TTree*)f->Get("T");
00011 T->SetFillColor(45);
00012 TCanvas *c1 = new TCanvas("c1","histograms with bars",700,800);
00013 c1->SetFillColor(42);
00014 c1->Divide(1,2);
00015
00016
00017 c1->cd(1); gPad->SetGrid(); gPad->SetLogx(); gPad->SetFrameFillColor(33);
00018 T->Draw("Nation","","hbar2");
00019
00020
00021 c1->cd(2); gPad->SetGrid(); gPad->SetFrameFillColor(33);
00022 T->Draw("Division>>hDiv","","goff");
00023 TH1F *hDiv = (TH1F*)gDirectory->Get("hDiv");
00024 hDiv->SetStats(0);
00025 TH1F *hDivFR = (TH1F*)hDiv->Clone("hDivFR");
00026 T->Draw("Division>>hDivFR","Nation==\"FR\"","goff");
00027 hDiv->SetBarWidth(0.45);
00028 hDiv->SetBarOffset(0.1);
00029 hDiv->SetFillColor(49);
00030 TH1 *h1 = hDiv->DrawCopy("bar2");
00031 hDivFR->SetBarWidth(0.4);
00032 hDivFR->SetBarOffset(0.55);
00033 hDivFR->SetFillColor(50);
00034 TH1 *h2 = hDivFR->DrawCopy("bar2,same");
00035
00036 TLegend *legend = new TLegend(0.55,0.65,0.76,0.82);
00037 legend->AddEntry(h1,"All nations","f");
00038 legend->AddEntry(h2,"French only","f");
00039 legend->Draw();
00040
00041 c1->cd();
00042 delete f;
00043 return c1;
00044 }