Applies a Poissonian log-likelihood ratio test to the two given histograms.
49 {
52
53 const TH1* h1 = dynamic_cast<const TH1*>(o1);
54 const TH1* h2 = dynamic_cast<const TH1*>(o2);
55
56 if (h1 == NULL || h2 == NULL) {
58 }
59
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);
65 }
66
67 TH1* h3 = (TH1*) h1->Clone(h1->GetName() == h2->GetName() ?
70
71 h3->Reset();
72
73 double LnLratio = 0.0;
74
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){
78
79 double contribution = 0.0;
80
81 const double n0 = h1->GetBinContent(i,j,k);
82 const double n1 = h2->GetBinContent(i,j,k);
83
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;
88 }
89
90 h3->SetBinContent(i,j,k, contribution);
91
92 LnLratio += contribution;
93 }
94 }
95 }
96
97 const bool passed = (LnLratio <
threshold);
98
100
101 h3->SetTitle(title.getTitle().c_str());
103
108
109 this->push_back(r);
110 }
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
#define MAKE_CSTRING(A)
Make C-string.
#define MAKE_STRING(A)
Make string.
Class dedicated to standardize the title of the graphical objects produced by the JTest_t() derived c...
double threshold
threshold chi-square to decide if test is passed.
const std::string resultType
test result type
const std::string testName
test name
Auxiliary class to handle file name, ROOT directory and object name.
Exception for accessing a value in a collection that is outside of its range.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Structure containing the result of the test.