Jpp
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
software
JCompareHistograms
JTestRuns_t.hh
Go to the documentation of this file.
1
#ifndef __JTESTRUNS_T__
2
#define __JTESTRUNS_T__
3
4
#include <iostream>
5
#include "
JTest_t.hh
"
6
7
using namespace
std;
8
9
/*
10
* Runs test.
11
*/
12
class
JTestRuns_t
13
{
14
public
:
15
16
JTestRuns_t
(){}
17
18
/*
19
* Tests the statistical compatibility of two ROOT TObjects
20
*
21
* \param h1 First object
22
* \param h2 Second object
23
*/
24
JTestResult
JRunsTest
(TH1*
h1
, TH1* h2,
double
threshold,
bool
logX,
bool
logY) {
25
26
JTestResult
r
;
27
28
if
(h1 -> GetNbinsX() != h2 -> GetNbinsX())
29
ERROR
(
"Histograms with different bining. The objects: "
<< h1 -> GetName() <<
" can not be compared."
<< endl);
30
31
double
R
= h1->Integral();
32
double
T
= h2->Integral();
33
34
int
n
= 1;
35
double
p = 0;
36
double
q = 0;
37
38
bool
a
= ((T/
R
)*h1->GetBinContent(1) - h2->GetBinContent(1)) < 0;
39
40
(a ? p++ : q++);
41
42
for
(
int
i = 2 ; i<h1->GetNbinsX() ; ++i){
43
44
bool
b = ((T/
R
)*h1->GetBinContent(i) - h2->GetBinContent(i)) < 0;
45
46
(b ? p++ : q++);
47
48
if
(b != a){
49
n++;
50
a=b;
51
}
52
}
53
54
double
N
= 1 + 2*p*q/(p+q) ;
55
double
s = sqrt( 2*p*q*(2*p*q-p-q)/(p+q)/(p+q)/(p+q-1) );
56
double
d
= (n-
N
)/s;
57
58
(fabs(d) > threshold ? r.
passed
=
false
: r.
passed
=
true
);
59
60
r.
message
=
MAKE_STRING
(scientific << setprecision(2)<<
"Test: "
<<
"Runs"
<<
61
" HA: "
<< h1->GetUniqueID() <<
" "
<< h1->GetName() <<
62
" HB: "
<< h2->GetUniqueID() <<
" "
<< h2->GetName() <<
63
" Threshold: "
<< threshold <<
" Result: "
<< fabs(d) <<
" "
<< (r.
passed
?
"PASSED"
:
"FAILED"
));
64
65
TH2D* h3 = (TH2D*)h1->Clone(h1->GetName()==h2->GetName() ?
66
MAKE_CSTRING
(
to_string
(h1->GetName())) :
67
MAKE_CSTRING
(
to_string
(h1->GetName()) +
"_VS_"
+
to_string
(h2->GetName())));
68
69
for
(
int
i=1 ; i<h1->GetNbinsX() ; ++i) {
70
h3->SetBinContent(i , (T/R)*h1->GetBinContent(i) - h2->GetBinContent(i));
71
}
72
73
JResultTitle
title(
"Runs"
,
"Deviation[#sigma] "
, r.
passed
, fabs(d));
74
75
h3->SetTitle(title.
getTitle
().c_str());
76
77
r.
obj
= h3;
78
79
return
r
;
80
};
81
};
82
83
#endif
JResultTitle
Definition:
JTest_t.hh:17
MAKE_CSTRING
#define MAKE_CSTRING(A)
Make C-string.
Definition:
JPrint.hh:708
h1
then for HISTOGRAM in h0 h1
Definition:
JMatrixNZ.sh:69
JTOOLS::r
data_type r[M+1]
Definition:
JPolint.hh:709
a
fi JEventTimesliceWriter a
Definition:
JEventProcessor.sh:71
JTestResult
Definition:
JTest_t.hh:63
MAKE_STRING
#define MAKE_STRING(A)
Make string.
Definition:
JPrint.hh:699
T
do set_variable OUTPUT_DIRECTORY $WORKDIR T
Definition:
JCalibrateHeight.sh:61
d
then print_variable DETECTOR INPUT_FILE INTERMEDIATE_FILE check_input_file $DETECTOR $INPUT_FILE check_output_file $INTERMEDIATE_FILE $OUTPUT_FILE JMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
Definition:
JPath.sh:52
ERROR
#define ERROR(A)
Definition:
JMessage.hh:66
JResultTitle::getTitle
string getTitle()
Definition:
JTest_t.hh:48
JTest_t.hh
R
then usage $script[distance] fi case set_variable R
Definition:
JDrawLED.sh:40
JTestResult::message
string message
Definition:
JTest_t.hh:65
JTestRuns_t::JTestRuns_t
JTestRuns_t()
Definition:
JTestRuns_t.hh:16
n
alias put_queue eval echo n
Definition:
qlib.csh:19
JTestRuns_t
Definition:
JTestRuns_t.hh:12
JLANG::to_string
std::string to_string(const T &value)
Convert value to string.
Definition:
JLangToolkit.hh:192
JTestRuns_t::JRunsTest
JTestResult JRunsTest(TH1 *h1, TH1 *h2, double threshold, bool logX, bool logY)
Definition:
JTestRuns_t.hh:24
JTestResult::passed
bool passed
Definition:
JTest_t.hh:64
JTestResult::obj
TObject * obj
Definition:
JTest_t.hh:66
N
then usage $script[input file[working directory[option]]] nWhere option can be N
Definition:
JMuonPostfit.sh:37
Generated by
1.8.5