#include "TCanvas.h" #include "TPad.h" #include "TMultiGraph.h" #include "TGraph.h" #include "TGraphErrors.h" #include "TGraphAsymmErrors.h" #include "TAxis.h" #include "TLegend.h" #include "TLatex.h" #include "TROOT.h" #include "TPaveStats.h" #include "TStyle.h" #include void partscint() { gStyle->SetOptFit(0); //no print stat //gStyle->SetOptFit(); const char *dataele = "Partscintdataele.txt"; const char *datapos = "Partscintdatapos.txt"; const char *datagam = "Partscintdatagam.txt"; const char *datatot = "Partscintdatatot.txt"; const char *dataout = "simulazione/ParticlesScintillatorThickness.png"; TCanvas *c01 = new TCanvas("c01","multigraph",1280,1024); 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(dataele,"%lg %lg 0 %lg"); TGraphAsymmErrors *graph2 = new TGraphAsymmErrors(datapos,"%lg %lg 0 0 %lg %lg"); TGraphErrors *graph3 = new TGraphErrors(datagam,"%lg %lg 0 %lg"); TGraphErrors *graph4 = new TGraphErrors(datatot,"%lg %lg 0 %lg"); printf("%d %d %d %d \n",graph1->GetN(),graph2->GetN(),graph3->GetN(),graph1->GetN()); graph1->SetMarkerColor(kBlue); graph1->SetLineColor(kBlue); graph1->SetMarkerStyle(3); graph1->SetMarkerSize(2); graph1->SetLineWidth(line); mg->Add(graph1); graph2->SetMarkerColor(kGreen); graph2->SetLineColor(kGreen); graph2->SetMarkerStyle(22); graph2->SetMarkerSize(2); graph2->SetLineWidth(line); mg->Add(graph2); graph3->SetMarkerColor(kYellow+2); graph3->SetLineColor(kYellow+2); graph3->SetMarkerStyle(29); graph3->SetMarkerSize(2); graph3->SetLineWidth(line); mg->Add(graph3); graph4->SetMarkerColor(kRed+2); graph4->SetLineColor(kRed+2); graph4->SetMarkerStyle(23); graph4->SetMarkerSize(2); graph4->SetLineWidth(line); mg->Add(graph4); mg->SetTitle(""); mg->GetXaxis()->SetTitle("Thickness (mm)"); mg->GetYaxis()->SetTitle("Particle number"); 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->SetMinimum(1.e-8); mg->SetMaximum(2.e-4); mg->Draw("ALP"); TLegend* leg = new TLegend(0.2, 0.78, .3, .88); leg->SetHeader("Legend"); leg->SetNColumns(1); leg->AddEntry(graph1, "Electrons", "ap"); leg->AddEntry(graph2, "Positrons", "ap"); leg->AddEntry(graph3, "Photons", "ap"); leg->AddEntry(graph4, "All", "ap"); leg->Draw(); c01->Update(); c01->Print(dataout); }