Setting TH2D range

Hi experts.
I have a problem when i set the range of TH2D’s Yaxis.

TChain *ch = new TChain(“ntp”);
char filename[300];
for (int i=1; i<=459; i++){
TString datadir = “/data/COSINE/WORK/islee/NaI037/data/MRGD/”;
sprintf(filename,“mrgd6_M000950.root.%.3d”,i);
ch->Add(datadir+filename);
}

TCanvas *Asy = new TCanvas(“Asymmetry”,“Asymmetry”,800,600);

TString asymmetry = “((pmt41.qc5-pmt42.qc5)/(pmt41.qc5+pmt42.qc5))”;
TString multiple = “(BCsIAll.Energy>50)”;
TH2D *asy = new TH2D(“Asymmetry”,“Asymmetry”,50,-1,1,50,0,10);
asy->GetXaxis()->CenterTitle();
asy->GetXaxis()->SetTitle(“Asymmetry”);
asy->GetYaxis()->CenterTitle();
asy->GetYaxis()->SetTitle(“Energy(keV)”);

ch->Draw(“crystal4.energy*9.3143e-5:”+asymmetry+">>asy", multiple);

TFile o(“Asymmetry.root”,“RECREATE”);
ch->Write();

I set the range of y axis (0,10)
but the result show like below picture.

How can i solve this problem?

I don’t know what is the solution.

Before creating the histogram, add:
gROOT->cd(); // newly created histograms should go here

Then:
ch->Project("Asymmetry", "crystal4.energy * 9.3143e-5 : " + asymmetry, multiple);

Thanks! It works!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.