#include "TCanvas.h" #include "TPad.h" #include "TMultiGraph.h" #include "TGraph.h" #include "TGraphAsymmErrors.h" #include "TGraphErrors.h" #include "TAxis.h" #include "TLegend.h" #include "TLatex.h" #include "TROOT.h" #include "TPaveStats.h" #include "TStyle.h" #include "TGaxis.h" #include void emitarnum() { gStyle->SetOptFit(0); //no print stat //gStyle->SetOptFit(); const char *dataBe = "Emittance_numb_target_Be.txt"; const char *dataC = "Emittance_numb_target_C.txt"; const char *dataout = "simulazione/Emittance_numb_target.png"; TCanvas *c01 = new TCanvas("c01","multigraph",1280,1024); c01->SetBottomMargin(0.4134134); //c01->SetLogy(); gStyle->SetOptStat(111110); auto mg = new TMultiGraph(); float offx=1.3; float offy=1.3; float margr=0.08; float w=3; float margl=0.12; float line=2; gPad->SetLeftMargin(margl); gPad->SetRightMargin(margr); TGraphErrors *graph1 = new TGraphErrors(dataBe,"%lg %lg %lg %lg"); TGraphErrors *graph2 = new TGraphErrors(dataC,"%lg %lg %lg %lg"); printf("%d %d \n",graph1->GetN(),graph2->GetN()); graph1->SetMarkerColor(kBlue); graph1->SetLineColor(kBlue); graph1->SetMarkerStyle(5); graph1->SetMarkerSize(6); graph1->SetLineWidth(line); //graph1->SetLineStyle(8); mg->Add(graph1); graph2->SetMarkerColor(kGreen); graph2->SetLineColor(kGreen); graph2->SetMarkerStyle(5); graph2->SetMarkerSize(6); graph2->SetLineWidth(line); //graph2->SetLineStyle(8); mg->Add(graph2); mg->SetTitle(""); mg->GetXaxis()->SetTitle("Number of targets"); mg->GetYaxis()->SetTitle("#epsilon_{RMS} (nm*rad)"); mg->GetYaxis()->SetTitleOffset(offy); mg->GetXaxis()->SetTitleOffset(offx); mg->GetYaxis()->SetTitleSize(40); mg->GetYaxis()->SetTitleFont(43); mg->GetYaxis()->SetLabelFont(43); mg->GetYaxis()->SetLabelSize(40); mg->GetXaxis()->SetTitleSize(40); mg->GetXaxis()->SetTitleFont(43); mg->GetXaxis()->SetLabelFont(43); mg->GetXaxis()->SetLabelSize(40); mg->GetXaxis()->SetNdivisions(6); // //mg->SetMinimum(1.e-10); //mg->SetMaximum(1.5e-5); mg->Draw("AP"); TLegend* leg = new TLegend(0.2, 0.78, .3, .88); leg->SetHeader("Legend"); leg->SetNColumns(1); leg->AddEntry(graph1, "Beryllium", "ap"); leg->AddEntry(graph2, "Carbon", "ap"); //leg->Draw(); c01->Update(); TGaxis *axis = new TGaxis(2, 1, 5, 1,26,95,69); axis->SetLineColor(kRed); axis->SetLabelColor(kRed); axis->SetLabelOffset(0.015); axis->SetNdivisions(6); // axis->SetTitle("Be slices+vacuum (mm)"); axis->SetTitleSize(40); axis->SetTitleFont(43); axis->SetLabelFont(43); axis->SetLabelSize(40); axis->SetNdivisions(6); // axis->Draw(); TGaxis *axis2 = new TGaxis(2, -1, 5, -1 ,22,85,63); axis2->SetLineColor(kBlue); axis2->SetLabelColor(kBlue); axis2->SetLabelOffset(0.015); axis2->SetNdivisions(6); // axis2->SetTitle("C slices+vacuum (mm)"); axis2->SetTitleSize(40); axis2->SetTitleFont(43); axis2->SetLabelFont(43); axis2->SetLabelSize(40); axis2->SetNdivisions(6); // axis2->Draw(); c01->Print(dataout); }