53 const TH1* h1 =
dynamic_cast<const TH1*
>(o1);
54 const TH1* h2 =
dynamic_cast<const TH1*
>(o2);
56 if (h1 == NULL || h2 == NULL) {
60 if(h1->GetNbinsX() != h2->GetNbinsX() ||
61 h1->GetNbinsY() != h2->GetNbinsY() ||
62 h1->GetNbinsZ() != h2->GetNbinsZ()) {
63 THROW(
JValueOutOfRange,
"JTestPoissonLogLikelihood::test(): Histograms with different binning. The objects: " <<
64 h1->GetName() <<
" and " << h2->GetName() <<
" can not be compared." << endl);
67 TH1* h3 = (TH1*) h1->Clone(h1->GetName() == h2->GetName() ?
73 double LnLratio = 0.0;
75 for (
int i=1 ; i <= h1->GetNbinsX() ; ++i){
76 for (
int j=1 ; j <= h1->GetNbinsY() ; ++j){
77 for (
int k=1 ; k <= h1->GetNbinsZ() ; ++k){
79 double contribution = 0.0;
81 const double n0 = h1->GetBinContent(i,j,k);
82 const double n1 = h2->GetBinContent(i,j,k);
84 if (n0 > 0.0 && n1 > 0.0) {
85 contribution = 2 * (n1 - n0 + n0 * log(n0/n1));
86 }
else if (n1 > 0.0) {
87 contribution = 2 * n1;
90 h3->SetBinContent(i,j,k, contribution);
92 LnLratio += contribution;
97 const bool passed = (LnLratio <
threshold);
101 h3->SetTitle(title.
getTitle().c_str());