Hi, I’m trying to get a 2D plot
This is the ROOT file si-500596.root (1.4 MB) and thi is the macro caloeff.cpp (72.7 KB)
This is the code that I used
TH2F *henecdsubstringcutrelTHFcut = new TH2F("henecdsubstringcutrelTHFcut", "", 500, 0., 20.,500, 0.,5000.);
TString what2 = TString::Format("Calo_EnDep[%d] : xh","subdet==%d && xh>%d>> henecdsubstringcutrelTHFcut",f,subdet,xhn);
t->Draw(what2, cut && cut3sub && cut4sub && cut5sub);
gPad->Modified();
gPad->Update(); // make sure it's really (re)drawn
henecdsubstringcutrelTHFcut->SetTitle(cdhenecdsubstringcutrelTHFname);
henecdsubstringcutrelTHFcut->GetXaxis()->SetTitle(cdeneXnameabenecvsd);
henecdsubstringcutrelTHFcut->GetYaxis()->SetTitle(cdeneYnameabenecvsd);
henecdsubstringcutrelTHFcut->GetYaxis()->SetTitleSize(c2_YTitleSize);
henecdsubstringcutrelTHFcut->GetYaxis()->SetTitleFont(c2_YTitleFont);
henecdsubstringcutrelTHFcut->GetYaxis()->SetTitleOffset(c2_YTitleOffset);
henecdsubstringcutrelTHFcut->GetYaxis()->SetLabelFont(c2_YLabelFont);
henecdsubstringcutrelTHFcut->GetYaxis()->SetLabelSize(c2_YLabelSize);
henecdsubstringcutrelTHFcut->GetXaxis()->SetTitleSize(c2_XTitleSize);
henecdsubstringcutrelTHFcut->GetXaxis()->SetTitleFont(c2_XTitleFont);
henecdsubstringcutrelTHFcut->GetXaxis()->SetTitleOffset(c2_XTitleOffset);
henecdsubstringcutrelTHFcut->GetXaxis()->SetLabelFont(c2_XLabelFont);
henecdsubstringcutrelTHFcut->GetXaxis()->SetLabelSize(c2_XLabelSize);
henecdsubstringcutrelTHFcut->SetMarkerSize(50);
henecdsubstringcutrelTHFcut->Draw("COLZ");
henecdsubstringcutrelTHFcut->SetName(heneabname);
gPad->Modified();
gPad->Update(); // make sure it's really (re)drawn
TH1 *hhb = henecdsubstringcutrelTHFcut->DrawCopy("colz"); // creates all axes
gPad->Modified();
gPad->Update(); // make sure it's really (re)drawn
TPaletteAxis * palette2 = (TPaletteAxis *) hhb->GetListOfFunctions()->FindObject("palette");
palette2->SetX1NDC(0.86);
palette2->SetX2NDC(0.90);
palette2->SetY1NDC(0.2);
palette2->SetY2NDC(0.8);
c97->Modified();
c97->Update();
TLegend* leghenecdsubstringcutrelTHFcut = new TLegend(0.65, 0.7, .75, .75);
leghenecdsubstringcutrelTHFcut->SetHeader("Legend");
leghenecdsubstringcutrelTHFcut->SetNColumns(1);
leghenecdsubstringcutrelTHFcut->AddEntry(leghenecdsubstringcutrelTHFcut, "Data", "l");
leghenecdsubstringcutrelTHFcut->Draw();
gPad->Update();
TPaveStats *statsghenecdsubstringcutrelTHFcut = (TPaveStats*)henecdsubstringcutrelTHFcut->GetListOfFunctions()->FindObject("stats");
statsghenecdsubstringcutrelTHFcut->SetTextColor(kBlue);
statsghenecdsubstringcutrelTHFcut->SetX1NDC(0.80); statsghenecdsubstringcutrelTHFcut->SetX2NDC(0.98);
statsghenecdsubstringcutrelTHFcut->SetY1NDC(0.77); statsghenecdsubstringcutrelTHFcut->SetY2NDC(0.92);
gPad->Update();
c97->Print(myplothenecdsubstringcutrelTHFcut);
delete c97;
By writing
TString what2 = TString::Format("Calo_EnDep[%d] : xh","subdet==%d && xh>%d>> henecdsubstringcutrelTHFcut",f,subdet,xhn);
I get this error
but I setted f=0, so why does ROOT say that the index is too high?
Anyway I tried to write
TString what2 = TString::Format("Calo_EnDep[0] : xh","subdet==36 && xh>-99>> henecdsubstringcutrelTHFcut");
In this way, I didn’t get errors, but ROOT doesn’t create the plot…
Please read tips for efficient and successful posting and posting code
ROOT Version: 6.20.24
Platform: Windows
Compiler: Not Provided