Filling histogram without zeros

Hi I am very new to root, and I need to make histograms that ignore the zeros from output files from Geant4 simulations of particle detectors. I have code that reads in a 5 column file based on the basic.c example and I can make histograms with it effectively. However, all of my conditional statements to fill the histograms without zeros have failed. Any help is appreciated. I am attaching the code that I am using, it has some of my previous attempts commented out.

What I am currently trying to use is:

  if (d != 0){h1->Fill(d);
  	}

Which results in root just running the script continuously without any output.
basic.C (2.19 KB)

Hi,

Can you post the ROOT file with the ntuple, so we can see why the data doesn’t do what you expect?

How do you determine that your code still fills values of d == 0 into the histogram? Could it just be values != 0 but somewhere between 0 and 10/100=0.1?

Cheers, Axel.

I figured it out, it turned out to be a syntax error. The way I knew it was filling the zeros was the mean energy deposit was far lower that it should have been, and the number of events far higher. The syntax that worked is below, in case anyone else encounters the same problem. Thank you for your reply.

if (d!=0) h1->Fill(d);