void CanvasPartition(TCanvas *C,const Int_t Nx = 2,const Int_t Ny = 2, Float_t lMargin = 0.15, Float_t rMargin = 0.05, Float_t bMargin = 0.15, Float_t tMargin = 0.05); void ANTSAll() { TFile *inputfile1 = new TFile("ants_ref.root","READ"); TMultiGraph* mg1 = (TMultiGraph*) inputfile1->Get("mg"); TFile *inputfile2 = new TFile("ants_stoch.root","READ"); TMultiGraph* mg2 = (TMultiGraph*) inputfile2->Get("mg"); TLegend* legend = (TLegend*) inputfile2->Get("legend"); TFile *inputfile3 = new TFile("ants_ideal.root","READ"); TMultiGraph* mg3 = (TMultiGraph*) inputfile3->Get("mg"); gStyle->SetOptStat(0); TCanvas *C = (TCanvas*) gROOT->FindObject("C"); if (C) delete C; C = new TCanvas("C","canvas",800,500); C->SetFillStyle(4000); // Number of PADS const Int_t Nx = 3; const Int_t Ny = 1; // Margins Float_t lMargin = 0.12; Float_t rMargin = 0.05; Float_t bMargin = 0.15; Float_t tMargin = 0.05; // Canvas setup CanvasPartition(C,Nx,Ny,lMargin,rMargin,bMargin,tMargin); // Dummy histogram. //TH1F *h = (TH1F*) gROOT->FindObject("histo"); //if (h) delete h; //h = new TH1F("histo","",100,-5.0,5.0); //h->FillRandom("gaus",10000); //h->GetXaxis()->SetTitle("x axis"); //h->GetYaxis()->SetTitle("y axis"); TPad *pad[Nx][Ny]; C->cd(0); // Get the pads previously created. char pname[16]; sprintf(pname,"pad_%i_%i",0,0); pad[0][0] = (TPad*) gROOT->FindObject(pname); pad[0][0]->Draw(); pad[0][0]->SetFillStyle(4000); pad[0][0]->SetFrameFillStyle(4000); pad[0][0]->SetTitle("Reference Case"); pad[0][0]->SetLogx(); pad[0][0]->SetGrid(); pad[0][0]->cd(); // Size factors Float_t xFactor = pad[0][0]->GetAbsWNDC()/pad[0][0]->GetAbsWNDC(); Float_t yFactor = pad[0][0]->GetAbsHNDC()/pad[0][0]->GetAbsHNDC(); char hname[16]; sprintf(hname,"h_%i_%i",0,0); mg1->DrawClone("AL"); mg1->SetTitle("Reference Case"); // y axis range //hFrame->GetYaxis()->SetRangeUser(0.0001,1.2*h->GetMaximum()); // Format for y axis mg1->GetYaxis()->SetTitle("Loss fraction"); mg1->GetYaxis()->SetLabelFont(43); mg1->GetYaxis()->SetLabelSize(16); mg1->GetYaxis()->SetLabelOffset(0.02); mg1->GetYaxis()->SetTitleFont(43); mg1->GetYaxis()->SetTitleSize(20); mg1->GetYaxis()->SetTitleOffset(2.5); //mg1->GetYaxis()->CenterTitle(); mg1->GetYaxis()->SetNdivisions(210); // TICKS Y Axis //mg1->GetYaxis()->SetTickLength(xFactor*0.04/yFactor); // Format for x axis mg1->GetXaxis()->SetLabelFont(43); mg1->GetXaxis()->SetLabelSize(16); mg1->GetXaxis()->SetLabelOffset(0.02); //mg1->GetXaxis()->SetTitle("t/s"); //mg1->GetXaxis()->SetTitleFont(43); //mg1->GetXaxis()->SetTitleSize(20); //mg1->GetXaxis()->SetTitleOffset(1.2); //mg1->GetXaxis()->CenterTitle(); //mg1->GetXaxis()->SetNdivisions(505); // TICKS X Axis //mg1->GetXaxis()->SetTickLength(yFactor*0.06/xFactor); mg1->DrawClone("AL"); C->cd(0); // Get the pads previously created. sprintf(pname,"pad_%i_%i",1,0); pad[1][0] = (TPad*) gROOT->FindObject(pname); pad[1][0]->Draw(); pad[1][0]->SetFillStyle(4000); pad[1][0]->SetFrameFillStyle(4000); pad[1][0]->SetLogx(); pad[1][0]->SetGrid(); pad[1][0]->cd(); // Size factors xFactor = pad[0][0]->GetAbsWNDC()/pad[1][0]->GetAbsWNDC(); yFactor = pad[0][0]->GetAbsHNDC()/pad[1][0]->GetAbsHNDC(); sprintf(hname,"h_%i_%i",1,0); mg2->DrawClone("AL"); // y axis range //hFrame->GetYaxis()->SetRangeUser(0.0001,1.2*h->GetMaximum()); // Format for y axis mg2->GetYaxis()->SetLabelFont(43); mg2->GetYaxis()->SetLabelSize(0); //mg2->GetYaxis()->SetLabelOffset(0.02); //mg2->GetYaxis()->SetTitleFont(43); //mg2->GetYaxis()->SetTitleSize(16); //mg2->GetYaxis()->SetTitleOffset(5); //mg2->GetYaxis()->CenterTitle(); mg2->GetYaxis()->SetNdivisions(210); // TICKS Y Axis //mg2->GetYaxis()->SetTickLength(xFactor*0.04/yFactor); // Format for x axis mg2->GetXaxis()->SetLabelFont(43); mg2->GetXaxis()->SetLabelSize(16); mg2->GetXaxis()->SetLabelOffset(0.02); //mg2->GetXaxis()->SetTitle("t/s"); //mg2->GetXaxis()->SetTitleFont(43); //mg2->GetXaxis()->SetTitleSize(20); //mg2->GetXaxis()->SetTitleOffset(1.2); //mg2->GetXaxis()->CenterTitle(); //mg2->GetXaxis()->SetNdivisions(505); // TICKS X Axis //mg2->GetXaxis()->SetTickLength(yFactor*0.06/xFactor); mg2->DrawClone("AL"); legend->DrawClone(); C->cd(0); // Get the pads previously created. sprintf(pname,"pad_%i_%i",2,0); pad[2][0] = (TPad*) gROOT->FindObject(pname); pad[2][0]->Draw(); pad[2][0]->SetFillStyle(4000); pad[2][0]->SetFrameFillStyle(4000); pad[2][0]->SetLogx(); pad[2][0]->SetGrid(); pad[2][0]->cd(); // Size factors xFactor = pad[0][0]->GetAbsWNDC()/pad[2][0]->GetAbsWNDC(); yFactor = pad[0][0]->GetAbsHNDC()/pad[2][0]->GetAbsHNDC(); sprintf(hname,"h_%i_%i",2,0); mg3->DrawClone("AL"); // y axis range //hFrame->GetYaxis()->SetRangeUser(0.0001,1.2*h->GetMaximum()); // Format for y axis mg3->GetYaxis()->SetLabelFont(43); mg3->GetYaxis()->SetLabelSize(0); //mg3->GetYaxis()->SetLabelOffset(0.02); //mg3->GetYaxis()->SetTitleFont(43); //mg3->GetYaxis()->SetTitleSize(16); //mg3->GetYaxis()->SetTitleOffset(5); //mg3->GetYaxis()->CenterTitle(); mg3->GetYaxis()->SetNdivisions(210); // TICKS Y Axis //mg3->GetYaxis()->SetTickLength(xFactor*0.04/yFactor); // Format for x axis mg3->GetXaxis()->SetLabelFont(43); mg3->GetXaxis()->SetLabelSize(16); mg3->GetXaxis()->SetLabelOffset(0.02); mg3->GetXaxis()->SetTitle("t/s"); mg3->GetXaxis()->SetTitleFont(43); mg3->GetXaxis()->SetTitleSize(20); mg3->GetXaxis()->SetTitleOffset(1.2); //mg3->GetXaxis()->CenterTitle(); //mg3->GetXaxis()->SetNdivisions(505); // TICKS X Axis //mg3->GetXaxis()->SetTickLength(yFactor*0.06/xFactor); mg3->DrawClone("AL"); C->cd(); gPad->Print("ants.tex"); gPad->Print("ants.pdf"); gPad->Print("ants.eps"); } void CanvasPartition(TCanvas *C,const Int_t Nx,const Int_t Ny, Float_t lMargin, Float_t rMargin, Float_t bMargin, Float_t tMargin) { if (!C) return; // Setup Pad layout: Float_t vSpacing = 0.0; Float_t vStep = (1.- bMargin - tMargin - (Ny-1) * vSpacing) / Ny; Float_t hSpacing = 0.0; Float_t hStep = (1.- lMargin - rMargin - (Nx-1) * hSpacing) / Nx; Float_t vposd,vposu,vmard,vmaru,vfactor; Float_t hposl,hposr,hmarl,hmarr,hfactor; for (Int_t i=0;icd(0); char name[16]; sprintf(name,"pad_%i_%i",i,j); TPad *pad = (TPad*) gROOT->FindObject(name); if (pad) delete pad; pad = new TPad(name,"",hposl,vposd,hposr,vposu); pad->SetLeftMargin(hmarl); pad->SetRightMargin(hmarr); pad->SetBottomMargin(vmard); pad->SetTopMargin(vmaru); pad->SetFrameBorderMode(0); pad->SetBorderMode(0); pad->SetBorderSize(0); pad->Draw(); } } }