Dear rooters,
I have five histograms with somewhat related names, so I called them in an array from my root file. But when I draw them only one of them is drawing and I got the following message:
Warning in TCanvas::Constructor: Deleting canvas with same name: jetpt
Below is the related code I use:
void R02jetQA(){
gStyle->SetOptStat (0);
gStyle->SetPadTickX (1);
gStyle->SetPadTickY (1);
gStyle->SetFrameBorderMode(0);
const Int_t mult = 5;
Int_t color[] = {kRed, kRed +3, kBlue -3, kBlue, kBlue +3};
TString multLegend[] = {"0-20%","20-40%","40-60%","60-80%","80-100%"};
TFile *data = new TFile("lhc16q_fast_mult.root", "readonly");
TList *data_container = (TList *)data->Get("AliAnalysisTaskEmcalJetSpectraQA_histos;1");
TH1F *fHistZVertex = (TH1F *)data_container-> FindObject("fHistZVertex");
Int_t Nevt = fHistZVertex->GetEntries();
TH3D *hjet[mult];
TH1 *hptjet[mult];
TH1::AddDirectory(kFALSE);
for(Int_t i=0; i<mult; i++){
hjet[i] = (TH3D*)data_container->FindObject("Jet_AKTChargedR020_tracks_pT0150_pt_scheme")->FindObject(TString::Format("fHistJetPtEtaPhi_%d",i));
if (hjet[i]) printf("Histogram named \"%s\" and has the title \"%s\" and \"%g\" entries \n", hjet[i]->GetName(), hjet[i]->GetTitle(), hjet[i]->GetEntries());
hptjet[i] = hjet[i]->Project3D("Z");
hptjet[i]->Sumw2();
hptjet[i]->Scale(1./Nevt);
hptjet[i]->SetLineColor(color[i]);
hptjet[i]->SetMarkerColor(color[i]);
hptjet[i]->SetMarkerStyle(color[i]);
hptjet[i]->SetMarkerSize(1.2);
hptjet[i]->SetTitle("");
hptjet[i]->GetXaxis()->SetTitle("p_{T} (GeV/#it{c})");
hptjet[i]->GetYaxis()->SetTitle("1/N dN/dp_{T}");
hptjet[i]->GetXaxis()->SetRangeUser(0,120);
TCanvas *pt = new TCanvas("pt","pt",800,600);
pt->SetLogy();
hptjet[i]->Draw("P E SAME");
}
}
Please could you offer a suggestion?
Thanks in advanceā¦