Hi, two questions please;
- I wrote this code in ROOT:
TFile f("H:/cors/cors_plot.root");
f.ls();
TCanvas *c1 = new TCanvas("c1","hists with different scales",600,400);
hngam->SetLineColor(kBlack);
hngam->Draw();
c1->Update();
hnele->SetLineColor(kRed);
hnele->Draw("same");
c1->Update();
hnmuo->SetLineColor(kGreen);
hnmuo->Draw("same");
c1->Update();
hnhad->SetLineColor(kYellow);
hnhad->Draw("same");
c1->Update();
TLegend* leg = new TLegend(0.2, 0.2, .8, .8);
leg-> SetNColumns(1);
leg->AddEntry(hngam, "Fotoni", "l");
leg->AddEntry(hnele, "Elettroni/Positroni", "l");
leg->AddEntry(hnmuo, "Muoni", "l");
leg->AddEntry(hnhad, "Adroni", "l");
leg->Draw("same");
c1->Update;
having this plot
as you can see, the statistical box plot just shows the information about the first hystogram (hngam), how can I change the code to have the informations about all the hystograms?
- I wrote this code
#include "TCanvas.h"
#include "TStyle.h"
#include "TH1.h"
#include "TGaxis.h"
#include "TRandom.h"
void macro_n_part()
{
TFile f("H:/cors/cors_plot.root");
f.ls();
TCanvas *c1 = new TCanvas("c1","hists with different scales",600,400);
hngam->SetLineColor(kBlack);
hngam->Draw();
c1->Update();
hnele->SetLineColor(kRed);
hnele->Draw("same");
c1->Update();
hnmuo->SetLineColor(kGreen);
hnmuo->Draw("same");
c1->Update();
hnhad->SetLineColor(kYellow);
hnhad->Draw("same");
c1->Update();
TLegend* leg = new TLegend(0.2, 0.2, .8, .8);
leg-> SetNColumns(1);
leg->AddEntry(hngam, "Fotoni", "l");
leg->AddEntry(hnele, "Elettroni/Positroni", "l");
leg->AddEntry(hnmuo, "Muoni", "l");
leg->AddEntry(hnhad, "Adroni", "l");
leg->Draw("same");
c1->Update;
}
and I saved it in the macro_n_part.c file and I used it as a macro, but running it I have this plot
but as you can see, it is the same code that I wrote in ROOT (having the other plot), so why doesn’t it works saving it in a macro? Where am I wrong?
Thanks