Hi,
I am trying to create a histogram using data from a simulation. I have written some code to create, fill and draw the histogram. However, on loading my code in root, it produces an empty canvas and then will not draw the histogram when running the code. I also know that the histograms are being filled with non-zero values because I can output them to the terminal. How do I rectify the problem of the empty canvas appearing when the code is loaded? I’ve attached the code below.
Thanks!
TH2F* Kstar_mass_against_B0_ThetaK = new TH2F (“Kstar_mass_against_B0_ThetaK”,“Kstar mass against B0 cos(ThetaK)”,100, 500, 2000, 100, -1., 1.);
if (fChain == 0) return;
Long64_t nentries = fChain->GetEntriesFast();
Long64_t nbytes = 0, nb = 0;
for (Long64_t jentry=0; jentry<nentries;jentry++) {
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
// if (Cut(ientry) < 0) continue;
// Filling histograms
double costheta = cos(B0_ThetaK);
Kstar_mass_against_B0_ThetaK -> Fill(Kstar_M, cos(B0_ThetaK));
}
// Drawing histograms
TCanvas* c_Kstar_mass_against_B0_ThetaK = new TCanvas();
Kstar_mass_against_B0_ThetaK -> Draw(“COLZ”);