Hi, Rooters,
I have a Geant4 produced ntuple file. This file has 200+ branches.
When I make a 2D plot in Treeviewer, this plot has a correct results, as the first attachment.
However, when I convert this kind of plot into a TH2F histogram with the attached script[1], I got a weird plot : (1) there exists box like distributed points, (2) some of the points “projected” to the Y axis. As another attached plot show.
As mentioned earlier, there exists many branches in my ntuple file, which means I do need a script to get 2D histograms instead of openning and saving them in Treeviewer manually.
Could you please give me a hint on how to solve this problem?
Thanks !
Best,
Junhui
[1] Script
void htr1() {
TFile *f = new TFile("/home/junhui/Geantfour/producedRootFiles/SDDArrayRectangleBeamShape15MEvents.root “);
TTree T = (TTree)f->Get(“ScintillatorRun”);
T->Draw(“Sdd_Energy:Bar2_Time_1stHit >> h_SDDE_vs_Bar2Time”,”(Sdd_N_of_Hits > 0) && (Bar2_N_of_Hits > 0)");
TH2F h_SDDE_vs_Bar2Time = (TH2F)gDirectory->Get(“h_SDDE_vs_Bar2Time”);
h_SDDE_vs_Bar2Time->SetLineColor(2);
TCanvas *c1 = new TCanvas(“c1”,“test”,10,10,1200,1500);
c1->Divide(1,1);
c1->cd(1);
h_SDDE_vs_Bar2Time->Draw();
TPaveText *pt = new TPaveText(10.57013,30608.47,14.91404,36353.8,“br”);
pt = new TPaveText(0.4,0.65,0.9,0.75,“brNDC”);
pt->SetFillColor(0);
text = pt->AddText("# of hits in Bar1");
pt->Draw();
c1_1->Modified();
c1->cd();
}
void ntupleToHistogramSDDArray() {
htr1();
}
TGrpahInTreeviewer.pdf (71.5 KB)
ntupleConvertToHist.pdf (72 KB)