Here are more details:
In my case I cover a region of space with:
-160 < x < 100 mm with 261 bins
-180 < y < 20 mm with 201 bins
-40 < z < 100 mm with 141 bins.
I need the bin content for a position (x,y,z)
So I should do:
binnumber = TH3F -> GetBin(binx,biny,binz);
bincontent = TH3F -> GetBinContent(binnumber);
or directly
bincontent = TH3F -> GetBincontent(binx,biny,binz);
But in each case bincontent is always 1. Why?
Then I used the fact:
Spatial->SetBinContent(47236,8.651172); (obtained from the saving to c1.C)
So I did:
binnumber = TH3F -> GetBin(binx,biny,binz); for all binx, biny, binz
bincontent = TH3F -> GetBinContent(binnumber);
if(binnumber == 47236) cout << bincontent << endl;
But no bincontent appear in terminal…
Here is the code it self:
TH1 *Spatial = new TH3F(“Spatial”,“Distribution spatiale de puissance”,261,-160,100,201,-180,20,121,-40,80);
Spatial->SetBinContent(47236,8.651172);
Spatial->SetEntries(1.172108e+07);
Double_t binc(0.);
Double_t binc2(0.);
Int_t binno(0.), binno2(0.);
for(int x=1; x < 262; x++)
{
for(int y=1; y < 202; y++)
{
for(int z=1; z < 192; z++)
{
binno = Spatial->GetBin(x,y,z);
//cout << binno << endl;
//binc = (Double_t)Spatial -> GetBinContent(x,y,z);
binc2 = (Double_t)Spatial -> GetBinContent(binno);
if(binno == 47236) cout << "The Binc : " << binc2 << endl;
//cout << binc << endl;
if(binc =! 0. && binno2==0)
{
cout << (x) << "\t" << (y) << "\t" << (z) << "\t" << binc << endl; // give the position in bin number
cout << (x-160) << "\t" << (y-180) << "\t" << (z-40) << "\t" << binc << endl; // give the position in mm
//outputfile << (x-160) << "\t" << (y-180) << "\t" << (z-40) << "\t" << binc << endl;
binno2=1;
}
}
}
}
outputfile.close();
c2.C (1.52 KB)