I am a stupid beginner on ROOT. I was trying to find out the bin numbers (counts) in some particular channel (the horizontal axis is my channel number) and a range of channels. Then I may do some populate work of these bin counts. However, I could not make it. My script gives me zero count pedestalhistest.C (841 Bytes)
The problem is not with ROOT but with your logic. Check how/where you are setting the value/s of n; as it is, you are only printing the last (bin) value.
Another (unrelated) thing: do you really need 15000 bins in a histo from 0 to 300?
I’m not sure what you’re exactly trying to find weather bin number at a particular channel or bin content. But if you want bin number at a particular channel then you should do
hist->FindFixBin(x-axis label);
This will give you bin number at the X axis value.
And also notice that you haven’t provided Pedestal_0_2_5_2023_002.ascii file.
Thanks for your response. I also would like to find the content of in a bin, so could you please give a sample example on how to call GetBinContent()? My scrip only shows me 0 which means it did not get any bin counts. So my logic was wrong but I could not figure out how to make GetBinContent() run. Thanks so much for your time!
Sorry for I am just a beginner of ROOT. I also do not know much about coding. I readly do not know where I should put my n. Should I put n into the while loop? Could you please explain a little bit more?
The reason I claim 15000 bins is because it is safe to keep the bins greater than the my channel numbers, actually in this case, I think I only need 300 bins. Thanks so much for your time!