1 #ifndef __JCOMPAREHISTOGRAMS__JTESTCHI2_SLICE2D__
2 #define __JCOMPAREHISTOGRAMS__JTESTCHI2_SLICE2D__
19 namespace JCOMPAREHISTOGRAMS {}
20 namespace JPP {
using namespace JCOMPAREHISTOGRAMS; }
22 namespace JCOMPAREHISTOGRAMS {
41 JTest_t(
"Chi2_Slice2D",
"p-Value(chi2)")
56 const TH2* h1 =
dynamic_cast<const TH2*
>(o1);
57 const TH2* h2 =
dynamic_cast<const TH2*
>(o2);
59 if (h1 == NULL || h2 == NULL) {
60 THROW(JValueOutOfRange,
"JTestChi2_Slice2D::test(): Could not cast given TObjects to TH2");
65 const char*
const h3name = (h1->GetName() == h2->GetName() ?
74 const int nSlices1 = h1->GetNbinsX();
75 const int nSlices2 = h2->GetNbinsX();
77 if (nSlices1 != nSlices2) {
78 THROW(JValueOutOfRange,
"JTestChi2_Slice2D::test(): Histograms with different binning. The objects: " << h1->GetName() <<
" and " << h2->GetName() <<
" can not be compared." << endl);
83 h3 = h1->ProjectionX(h3name);
85 for (
int i=1 ;
i<=nSlices1 ; ++
i){
89 const TH1* s1 = h1->ProjectionY(sliceName.c_str(),
i,
i);
90 const TH1* s2 = h2->ProjectionY(sliceName.c_str(),
i,
i);
92 if (!(s1->GetSumOfWeights() > 0 && s2->GetSumOfWeights() > 0)) {
continue; }
94 const double chi2 = s1->Chi2Test(s2 ,
options.c_str());
96 const bool failed = (
options.find(
"CHI2") != std::string::npos ?
100 if (failed) nFailures++;
102 h3->SetBinContent(
i,chi2);
107 const int nSlices1 = h1->GetNbinsY();
108 const int nSlices2 = h2->GetNbinsY();
110 if (nSlices1 != nSlices2) {
111 THROW(JValueOutOfRange,
"JTestChi2_Slice2D::test(): Histograms with different binning. The objects: " << h1->GetName() <<
" and " << h2->GetName() <<
" can not be compared." << endl);
116 h3 = h1->ProjectionY(h3name);
118 for (
int i=1 ;
i<=nSlices1 ; ++
i){
122 const TH1* s1 = h1->ProjectionX(sliceName.c_str(),
i,
i);
123 const TH1* s2 = h2->ProjectionX(sliceName.c_str(),
i,
i);
125 if (!(s1->GetSumOfWeights() > 0 && s2->GetSumOfWeights() > 0)) {
continue; }
127 const double chi2 = s1->Chi2Test (s2 ,
options.c_str());
129 const bool failed = (
options.find(
"CHI2") != std::string::npos ?
133 if (failed) nFailures++;
135 h3->SetBinContent(
i,chi2);
143 h3->SetTitle(title.
getTitle().c_str());
161 std::istream&
read(std::istream&
in)
override
168 THROW(JValueOutOfRange,
"JTestChi2_Slice2D::read(): Invalid threshold value " <<
threshold);
171 if (failuresThreshold < 0.0 || failuresThreshold > 1.0) {
172 THROW(JValueOutOfRange,
"JTestChi2_Slice2D::read(): Invalid failuresThreshold value " <<
failuresThreshold);
176 THROW(JValueOutOfRange,
"JTestChi2_Slice2D::read(): Invalid slice option " <<
slice);
double failuresThreshold
threshold p-value to decide if test is passed.
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.
double threshold
threshold p-value to decide if test is passed.
#define MAKE_CSTRING(A)
Make C-string.
Auxiliary class to handle file name, ROOT directory and object name.
#define MAKE_STRING(A)
Make string.
JTestChi2_Slice2D()
Default constructor.
std::string options
options for the ROOT chi2 test.
const std::string resultType
test result type
const std::string testName
test name
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] 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
std::string to_string(const T &value)
Convert value to string.
then if[[!-f $DETECTOR]] then JDetector sh $DETECTOR fi cat $WORKDIR trigger_parameters txt<< EOFtrigger3DMuon.enabled=1;trigger3DMuon.numberOfHits=5;trigger3DMuon.gridAngle_deg=1;ctMin=0.0;TMaxLocal_ns=15.0;EOF set_variable TRIGGEREFFICIENCY_TRIGGERED_EVENTS_ONLY INPUT_FILES=() for((i=1;$i<=$NUMBER_OF_RUNS;++i));do JSirene.sh $DETECTOR $JPP_DATA/genhen.km3net_wpd_V2_0.evt.gz $WORKDIR/sirene_ ${i}.root JTriggerEfficiency.sh $DETECTOR $DETECTOR $WORKDIR/sirene_ ${i}.root $WORKDIR/trigger_efficiency_ ${i}.root $WORKDIR/trigger_parameters.txt $JPP_DATA/PMT_parameters.txt INPUT_FILES+=($WORKDIR/trigger_efficiency_ ${i}.root) done for ANGLE_DEG in $ANGLES_DEG[*];do set_variable SIGMA_NS 3.0 set_variable OUTLIERS 3 set_variable OUTPUT_FILE $WORKDIR/matrix\[${ANGLE_DEG}\deg\].root $JPP_DIR/examples/JReconstruction-f"$INPUT_FILES[*]"-o $OUTPUT_FILE-S ${SIGMA_NS}-A ${ANGLE_DEG}-O ${OUTLIERS}-d ${DEBUG}--!fiif[[$OPTION=="plot"]];then if((0));then for H1 in h0 h1;do JPlot1D-f"$WORKDIR/matrix["${^ANGLES_DEG}" deg].root:${H1}"-y"1 2e3"-Y-L TR-T""-\^"number of events [a.u.]"-> o chi2
Structure containing the result of the test.
void test(const TObject *o1, const TObject *o2) override
Applies Chi2 test for two ROOT TH2 histograms.
Implementation of the Chi2 test for 2D histograms.