Finding content in points

Hi,

I have a camera with a lot of photons that has landed on it. I want to calculate the locations of these individual points and how much light each of these points contain.

By using:
double x_max = hImage2D->GetXaxis()->GetXmax();
double x_min = hImage2D->GetXaxis()->GetXmin();
double y_max = hImage2D->GetYaxis()->GetXmax();
double y_min = hImage2D->GetYaxis()->GetXmin();

I get the value of xmin/max and ymin/max to be -4.6<x<4.6 and -4.6<y<4.6 but they all contain zero photons.
The problem is also that when showing the values of x and y I only get integers.

Anyway the code I use to display all values of x,y and nr of photons in vectors is:

int bin[81];
int binx[81];
int biny[81];
int * pointer_x;
int * pointer_y;
int * pointer_n;
int n;

for (int n=0; n < 81; n=n+1)
{
for (int x=x_min; x< x_max; x++)
{
for (int y=y_min; y < y_max; y++)
{
pointer_x = binx + n; *pointer_x = x;
pointer_y = biny + n; *pointer_y = y;
pointer_n = bin + n; *pointer_n = hImage2D->GetBinContent(x,y);

     std::cout << binx[n] << ", " << biny[n] << ", " << bin[n] << std::endl;
      }
} 

}

Though I still get zero in every point but if I loop over random points with GetBinContent(n) (0 < n < 81) then I get points that has values in them.

So basically my question is:
What am I doing wrong? Why do I get zero in all the photon points?
Does it have to do with the fact that its all integers (in x and y)? Do I need to calculate the bins instead and get the photons through that?

Thank you

in GetBinContent the input parameters are bin numbers (int) not axis values…

root.cern.ch/root/htmldoc/TH2.h … nContent@1

[code]{
TFile *f = TFile::Open(“hsimple.root”); // a ROOT file from ROOT tutorials
if (!f) return; // just a precaution
TH2F *hImage2D; f->GetObject(“hpxpy”, hImage2D);
if (!hImage2D) return; // just a precaution

Int_t NX = hImage2D->GetNbinsX();
Int_t NY = hImage2D->GetNbinsY();

for (Int_t i = 1; i <= NX; i++) {
for (Int_t j = 1; j <= NY; j++) {
std::cout << "( " << i << " , " << j << " ) : ( "
<< hImage2D->GetXaxis()->GetBinLowEdge(i) << " , "
<< hImage2D->GetYaxis()->GetBinLowEdge(j) << " ) : ( "
<< hImage2D->GetXaxis()->GetBinCenter(i) << " , "
<< hImage2D->GetYaxis()->GetBinCenter(j) << " ) : ( "
<< hImage2D->GetXaxis()->GetBinUpEdge(i) << " , "
<< hImage2D->GetYaxis()->GetBinUpEdge(j) << " ) : "
<< hImage2D->GetBinContent(i, j) << std::endl;
}
}

delete f; // automatically deletes “hImage2D”, too
}[/code]

thanks