Hi Experts,
I am trying to fill a 2D histogram with hits on x vs z values. I am unable to fill the histogram, however doing a cout I get the result.
I am attaching the block of the code as well the screenshot of the terminal result. I will be extremly grateful if you point out
my mistake ?
TH2F* h2D = new TH2F(h2D, x vs z , 100, 10000, 20000, 100, -4000, 4000);
for (Long64_t jentry=0; jentry<nentries;jentry++)
{
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = b_RecoHitPos->GetEntry(ientry);
nbytes += nb;
for (Long64_t nHit=0; nHit<nHits;nHit++)
{
if (RecoHitPos[nHit][0] != -999)
{
h2D->Fill(RecoHitPos[nHit][0], RecoHitPos[nHit][2]);
cout<<"nHit"<<nHit<<" RecoHitPos[nHit][0]"<<RecoHitPos[nHit][0]<<" nHit"<<nHit<<" RecoHitPos[nHit][2]"<<RecoHitPos[nHit][2]<< endl;
}
}
}
TCanvas* canvas = new TCanvas("canvas", "canvas", 800, 600);
h2D->Draw("colz"); // "colz" option for a 2D color plot
canvas->SaveAs("output.png");
}