17 Int_t 
FindTheBin(TH2 *lookup_table, Float_t value_x, Float_t value_y, Int_t &bin_x, Int_t &bin_y)
 
   19  bin_x = lookup_table->GetXaxis()->FindBin(value_x);
 
   20  bin_y = lookup_table->GetYaxis()->FindBin(value_y);
 
   22  if ((bin_x < 1) || (bin_x > lookup_table->GetXaxis()->GetNbins()))
 
   24    bin_x = -1; bin_y = -1; 
 
   28  if ((bin_y < 1) || (bin_y > lookup_table->GetYaxis()->GetNbins()))
 
   30    bin_x = -1; bin_y = -1; 
 
   46  if (use_interpolation)
 
   56    return (lookup_table->Interpolate(value_x,value_y));
 
   61    Int_t binx, biny, retval;
 
   63    retval = 
FindTheBin(lookup_table, value_x, value_y, binx, biny);
 
   66      cout << 
"<E> Error in FindTheBin, check your table and input values!!!!: " << retval << endl;
 
   70    return (lookup_table->GetBinContent(binx,biny));
 
   82  gStyle->SetPalette(1);
 
   84  Double_t xlowarray_1[] = {0,10,20,30,40,50,60,70,80,90,100};
 
   85  Double_t ylowarray_1[] = {0,10,20,30,40,50,60,70,80,90,100};
 
   87  TH2D *
h1 = 
new TH2D(
"h1",
"Input spectrum",
 
   88                      (
sizeof(xlowarray_1)/
sizeof(
Double_t))-1,xlowarray_1,
 
   89                      (
sizeof(ylowarray_1)/
sizeof(
Double_t))-1,ylowarray_1);
 
   91  Double_t xlowarray_2[] = {0,10,20,30,35,40,45,46,47,48,49,50,51,52,53,54,55,60,65,70,80,90,100};
 
   92  Double_t ylowarray_2[] = {0,10,20,30,35,40,45,46,47,48,49,50,51,52,53,54,55,60,65,70,80,90,100};
 
   94  TH2D *
h2 = 
new TH2D(
"h2",
"Check spectrum",
 
   95                      (
sizeof(xlowarray_2)/
sizeof(
Double_t))-1,xlowarray_2,
 
   96                      (
sizeof(ylowarray_2)/
sizeof(
Double_t))-1,ylowarray_2);
 
  102  for (Int_t 
i = 1; 
i < (h1->GetXaxis()->GetNbins() + 1); 
i++)
 
  104     for (Int_t j = 1; j < (h1->GetYaxis()->GetNbins() + 1); j++)
 
  106        h1->SetBinContent(
i,j,
 
  107                          TMath::Gaus(h1->GetXaxis()->GetBinCenter(j),50,20)+
 
  108                          TMath::Gaus(h1->GetXaxis()->GetBinCenter(
i),50,10));
 
  117  for (Int_t 
i = 1; 
i < (h2->GetXaxis()->GetNbins() + 1); 
i++)
 
  119     valx = h2->GetXaxis()->GetBinCenter(
i);
 
  120     for (Int_t j = 1; j < (h2->GetYaxis()->GetNbins() + 1); j++)
 
  122        valy = h2->GetYaxis()->GetBinCenter(j);
 
  123        cout << 
"<I> Checking (" << valx << 
"," << valy << 
")" << endl; 
 
  124        valz = 
GetValueInZ((TH2*) h1, valx, valy, use_interpolation);
 
  125        h2->SetBinContent(
i,j,valz);
 
  133   TCanvas *
c = 
new TCanvas();
 
  140   cout << 
"Compare TestIt(kTRUE) with TestIt(kFALSE), interpolation really improves! Cool, heh!" << endl;
 
Int_t FindTheBin(TH2 *lookup_table, Float_t value_x, Float_t value_y, Int_t &bin_x, Int_t &bin_y)
Double_t GetValueInZ(TH2 *lookup_table, Float_t value_x, Float_t value_y, Bool_t use_interpolation=kFALSE)
void TestIt(Bool_t use_interpolation=kFALSE)