{
//
// To see the output of this macro, click begin_html here. end_html
//
gROOT->Reset();
c1 = new TCanvas("c1","Difference of cross sections",200,10,700,500);
c1->SetFillColor(0);
c1->SetGrid();
c1->SetBorderMode(0);
// draw a frame to define the range
TMultiGraph *mg = new TMultiGraph();
// draw the legend
TLegend *legend=new TLegend(0.5,0.65,0.88,0.85);
legend->SetTextFont(72);
legend->SetTextSize(0.05);
legend->SetFillColor(0);
const Int_t n = 1000; const Int_t N = 5;
Double_t x[n], y[N][n];
// we assume a file lossbg1.csv in the current directory
// this file has 6 columns of float data
ifstream in;
in.open("lossbg1.csv");
Float_t E,Y,T,S,P,TP;
Int_t nlines = 0;
while (1) {
in >> E >> Y >> T >> S >> P >> TP;
if (!in.good() || (nlines>=1000)) break;
x[nlines] = E;
y[0][nlines] = Y;
y[1][nlines] = T;
y[2][nlines] = S;
y[3][nlines] = P;
y[4][nlines] = TP;
// if (nlines < 5) printf("E=%8f, Y=%8f, T=%8f\n",E,Y,T);
nlines++;
}
in.close();
/* for (Int_t i = 0; iSetLineColor(3);
gr->SetLineWidth(2);
// gr->SetMarkerStyle(1);
gr->SetMarkerSize(5);
gr->SetMarkerColor(2);
mg->Add(gr);
char a[50];
sprintf(a,"Measured");
legend->AddEntry(gr,a,"l");
/* gr = new TGraph(nlines-1,x,y[1]);
gr->SetLineColor(1);
gr->SetLineWidth(1);
mg->Add(gr);
sprintf(a,"Tougaard");
legend->AddEntry(gr,a,"l");
gr = new TGraph(nlines-1,x,y[2]);
gr->SetLineColor(1);
gr->SetLineWidth(2);
mg->Add(gr);
sprintf(a,"ShirleyCS");
legend->AddEntry(gr,a,"l");
gr = new TGraph(nlines-1,x,y[3]);
gr->SetLineColor(3);
gr->SetLineWidth(2);
mg->Add(gr);
sprintf(a,"Peak");
legend->AddEntry(gr,a,"l");
gr = new TGraph(nlines-1,x,y[4]);
gr->SetLineColor(4);
gr->SetLineWidth(2);
mg->Add(gr);
sprintf(a,"Tailed peak");
legend->AddEntry(gr,a,"l");
*/ mg->Draw("ACP");
legend->Draw();
// TCanvas::Update() draws the frame, after which one can change it
c1->Update();
c1->GetFrame()->SetFillColor(0);
// c1->GetFrame()->SetBorderSize(12);
c1->Modified();
}