Filling histograms

Hi,

I’ve made my own class in ROOT and I fill a histogram using information from an ntuple. I only want to fill the first 700 bins of this histogram. What is the best way to do this?

Cheers,

Lisa

It depends on how you fill the histogram! For example TTree::Draw has a parameter limiting the number of entries it looked at.

Philippe

Hi,

I fill my histogram in my .C file using
run2->Fill((double)ClusterStrip);

Where run2 is the name of the histogram declared in the header file. I load the class into ROOT and run a script to divide the the histograms.

The run2 histogram has 2000 bins, I only want to fill the first 600 of these bins.
I’ve tried to do it like this

int i =2000;
for (i =0; i <= 2000; ++i){
if(i >=0 && i <=600){
run2->Fill((double)ClusterStrip);
}

but it doesn’t work.

Cheers,

Lisa

Hi,

I am not sure if you really mean " I only want to fill the first 600 of these bins", however this is not what your code does.
Your code currently input the first 600 values no matter where they fall in the histogram.
If you want to only fill the first 600 bins. you would need something more like:

int i =2000; for (i =0; i <= 2000; ++i){ if(ClusterStrip < value_corresponding_to_bin_number_601) { run2->Fill((double)ClusterStrip); }

Cheers,
Philippe