1 #ifndef __JCOMPAREHISTOGRAMS__JTESTRUNS_1D__
2 #define __JCOMPAREHISTOGRAMS__JTESTRUNS_1D__
17 namespace JCOMPAREHISTOGRAMS {}
18 namespace JPP {
using namespace JCOMPAREHISTOGRAMS; }
20 namespace JCOMPAREHISTOGRAMS {
52 const TH1* h1 =
dynamic_cast<const TH1*
>(o1);
53 const TH1* h2 =
dynamic_cast<const TH1*
>(o2);
55 if (h1 == NULL || h2 == NULL) {
56 THROW(JValueOutOfRange,
"JTestRuns_1D::test(): Could not cast given TObjects to TH1.");
59 if (h1->GetDimension() != 1 || h2->GetDimension() != 1) {
60 THROW(JValueOutOfRange,
"JTestRuns_1D::test(): Given histograms must be 1-D.");
63 if(h1->GetNbinsX() != h2->GetNbinsX()) {
64 THROW(JValueOutOfRange,
"JTestIdentical::test(): Histograms with different bining. The objects: " <<
65 h1->GetName() <<
" and " << h2->GetName() <<
" can not be compared." << endl);
68 const double R = h1->Integral();
69 const double T = h2->Integral();
71 TH1* h3 = (TH1*) h1->Clone(h1->GetName() == h2->GetName() ?
75 for (
int i=1 ;
i<h1->GetNbinsX() ; ++
i) {
76 h3->SetBinContent(
i, (
T/
R)*h1->GetBinContent(
i) - h2->GetBinContent(
i));
79 bool a = ((
T/
R)*h1->GetBinContent(1) - h2->GetBinContent(1)) < 0;
82 double p = (
a ? 1 : 0);
83 double q = (
a ? 0 : 1);
85 for (
int i = 2 ;
i<h1->GetNbinsX() ; ++
i){
87 const bool b = ((
T/
R)*h1->GetBinContent(
i) - h2->GetBinContent(
i)) < 0;
97 const double N = 1 + 2*p*q/(p+q) ;
98 const double s = sqrt( 2*p*q*(2*p*q-p-q)/(p+q)/(p+q)/(p+q-1) );
99 const double d = (
n-
N)/s;
105 h3->SetTitle(title.
getTitle().c_str());
123 std::istream&
read(std::istream&
in)
override
130 THROW(JValueOutOfRange,
"JTestRuns_1D::read(): Invalid threshold value " <<
threshold);
Interface to read input and write output for TObject tests.
std::string getTitle() const
Returns a standard string to be used as title of a graphical root object.
std::istream & read(std::istream &in) override
Read test parameters from input.
Class dedicated to standardize the title of the graphical objects produced by the JTest_t() derived c...
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
#define MAKE_CSTRING(A)
Make C-string.
void test(const TObject *o1, const TObject *o2) override
Tests the statistical compatibility of two ROOT TObjects.
Auxiliary class to handle file name, ROOT directory and object name.
#define MAKE_STRING(A)
Make string.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
Implementation of the Runs test for 1D histograms.
const std::string resultType
test result type
const std::string testName
test name
then JCookie sh JDataQuality D $DETECTOR_ID R
then JMuonMCEvt f $INPUT_FILE o $INTERMEDIATE_FILE d
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
double threshold
threshold value to decide if test is passed.
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Structure containing the result of the test.
JTestRuns_1D()
Default constructor.