Jpp  15.0.1-rc.2-highQE
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | Protected Attributes | Private Attributes | List of all members
JCOMPAREHISTOGRAMS::JTestSignificance_2D Class Reference

Significance test applied to 2D histograms. More...

#include <JTestSignificance_2D.hh>

Inheritance diagram for JCOMPAREHISTOGRAMS::JTestSignificance_2D:
JCOMPAREHISTOGRAMS::JTest_t JCOMPAREHISTOGRAMS::JTestSignificance_t

Public Member Functions

 JTestSignificance_2D ()
 Default constructor. More...
 
std::istream & read (std::istream &in) override
 Read test parameters from input. More...
 
void test (TObject *o1, TObject *o2) override
 Applies Significance test for two ROOT TH1 histograms. More...
 
std::ostream & write (std::ostream &out, const char delimiter= ' ', const bool onlyFailures=false) const
 Write test result to output. More...
 
virtual void save (TFile *f, const std::string &path, const bool onlyFailures=false)
 Writes the test result to root file. More...
 
virtual void clear ()
 Clear results. More...
 
const std::string & getTestName ()
 Get test name. More...
 
const std::string & getResultType ()
 Get result type. More...
 
template<class T >
JTestResult JSignificanceTest (T *h1, T *h2, double threshold, double K, std::string testName, std::string parameterName)
 Significance test for histograms. More...
 

Public Attributes

std::vector< JTestResultresults
 Buffer to store results of multiple tests.*/. More...
 

Protected Attributes

const std::string testName
 test name More...
 
const std::string resultType
 result type More...
 

Private Attributes

double threshold
 threshold p-value to decide if test is passed. More...
 
double K
 normalization factor between histograms. More...
 

Detailed Description

Significance test applied to 2D histograms.

Definition at line 19 of file JTestSignificance_2D.hh.

Constructor & Destructor Documentation

JCOMPAREHISTOGRAMS::JTestSignificance_2D::JTestSignificance_2D ( )
inline

Default constructor.

Definition at line 28 of file JTestSignificance_2D.hh.

28  :
29  JTest_t("Significance_2D", "Significance"),
31  {}
JTest_t(const std::string &name, const std::string &type)
Constructor.
Definition: JTest_t.hh:57

Member Function Documentation

std::istream& JCOMPAREHISTOGRAMS::JTestSignificance_2D::read ( std::istream &  in)
inlineoverridevirtual

Read test parameters from input.

Parameters
ininput stream
Returns
input stream

Implements JCOMPAREHISTOGRAMS::JTest_t.

Definition at line 39 of file JTestSignificance_2D.hh.

39  {
40  return in >> threshold >> K;
41  };
double K
normalization factor between histograms.
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 source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:41
double threshold
threshold p-value to decide if test is passed.
void JCOMPAREHISTOGRAMS::JTestSignificance_2D::test ( TObject o1,
TObject o2 
)
inlineoverridevirtual

Applies Significance test for two ROOT TH1 histograms.

Parameters
o1First histogram
o2Second histogram

Implements JCOMPAREHISTOGRAMS::JTest_t.

Definition at line 49 of file JTestSignificance_2D.hh.

49  {
50 
51  using namespace std;
52 
53  if (!(dynamic_cast<TH2*>(o1) == NULL) && !(dynamic_cast<TH2*>(o2) == NULL)) {
54 
55  TH2D* h1 = dynamic_cast<TH2D*>(o1);
56  TH2D* h2 = dynamic_cast<TH2D*>(o2);
57 
58  if (h1 -> GetNbinsX() != h2 -> GetNbinsX() || h1 -> GetNbinsY() != h2 -> GetNbinsY())
59  ERROR("Histograms with different bining. The objects: " << h1 -> GetName() << " can not be compared." << endl);
60 
61  if (K<0)
62  K = h2->GetEntries()/h1->GetEntries();
63 
64  JTestResult r = JSignificanceTest<TH2D>(h1, h2, threshold, K, testName, resultType);
65 
66  results.push_back(r);
67  }
68  };
double K
normalization factor between histograms.
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
data_type r[M+1]
Definition: JPolint.hh:742
std::vector< JTestResult > results
Buffer to store results of multiple tests.*/.
Definition: JTest_t.hh:162
#define ERROR(A)
Definition: JMessage.hh:66
const std::string resultType
result type
Definition: JTest_t.hh:167
const std::string testName
test name
Definition: JTest_t.hh:166
double threshold
threshold p-value to decide if test is passed.
std::ostream& JCOMPAREHISTOGRAMS::JTest_t::write ( std::ostream &  out,
const char  delimiter = ' ',
const bool  onlyFailures = false 
) const
inlineinherited

Write test result to output.

Parameters
outoutput stream
delimiterfield delimiter
onlyFailuresif true, write only failures.
Returns
output stream

Definition at line 81 of file JTest_t.hh.

83  {
84 
85  for (std::vector<JTestResult>::const_iterator r = results.begin() ; r != results.end() ; ++r) {
86 
87  if (onlyFailures && r->passed) {
88  continue;
89  }
90 
91  print(out, *r, delimiter, true);
92  }
93 
94  return out;
95  }
std::ostream & print(std::ostream &out, const JTestSummary &summary, const char delimiter= ' ', const bool useColors=true)
Print test summary.
data_type r[M+1]
Definition: JPolint.hh:742
std::vector< JTestResult > results
Buffer to store results of multiple tests.*/.
Definition: JTest_t.hh:162
virtual void JCOMPAREHISTOGRAMS::JTest_t::save ( TFile *  f,
const std::string &  path,
const bool  onlyFailures = false 
)
inlinevirtualinherited

Writes the test result to root file.

Parameters
fA ROOT file
pathPath in root file.
onlyFailuresIf true, write only failures.

Definition at line 113 of file JTest_t.hh.

115  {
116 
117  using namespace std;
118 
119  if (f -> GetDirectory(path.c_str())==0) {
120  f->mkdir(path.c_str());
121  }
122 
123  f->cd(path.c_str());
124 
125  for (vector<JTestResult>::const_iterator r = results.begin() ; r != results.end() ; ++r){
126 
127  if (!onlyFailures || !r->passed){
128  r->obj->Write();
129  }
130  }
131  }
then JMuonPostfit f
data_type r[M+1]
Definition: JPolint.hh:742
std::vector< JTestResult > results
Buffer to store results of multiple tests.*/.
Definition: JTest_t.hh:162
$WORKDIR driver txt done cat $WORKDIR driver txt<< EOFprocess ${DATAFILTER}$FILTER_HOST csh-c '(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&JDataFilter-H\$SERVER\$-M\$LOGGER\$-d $DEBUG-u ${DATAFILTER}-P $PORT</dev/null > &/dev/null)&';process ${DATAWRITER}$WRITER_HOST csh-c '(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&JDataWriter-H\$SERVER\$-M\$LOGGER\$-d $DEBUG-u ${DATAWRITER}</dev/null > &/dev/null)&';print enterevent ev_init{RC_CMD}event ev_reset{RC_CMD}event ev_init{RC_CMD}event ev_configure{RC_DFLTR%<$WORKDIR/ev_configure_datafilter.txt > RC_DOM<$WORKDIR/ev_configure_domsimulator.txt > RC_DWRT path
virtual void JCOMPAREHISTOGRAMS::JTest_t::clear ( )
inlinevirtualinherited

Clear results.

Definition at line 137 of file JTest_t.hh.

137  {
138  results.clear();
139  }
std::vector< JTestResult > results
Buffer to store results of multiple tests.*/.
Definition: JTest_t.hh:162
const std::string& JCOMPAREHISTOGRAMS::JTest_t::getTestName ( )
inlineinherited

Get test name.

Returns
test name

Definition at line 147 of file JTest_t.hh.

147  {
148  return testName;
149  }
const std::string testName
test name
Definition: JTest_t.hh:166
const std::string& JCOMPAREHISTOGRAMS::JTest_t::getResultType ( )
inlineinherited

Get result type.

Returns
result type

Definition at line 157 of file JTest_t.hh.

157  {
158  return resultType;
159  }
const std::string resultType
result type
Definition: JTest_t.hh:167
template<class T >
JTestResult JCOMPAREHISTOGRAMS::JTestSignificance_t::JSignificanceTest ( T h1,
T h2,
double  threshold,
double  K,
std::string  testName,
std::string  parameterName 
)
inlineinherited

Significance test for histograms.


Parameters
h1First object
h2Second object
thresholdSignificance threshold
KNormalisation parameter
parameterNameName of the parameter used to test the histograms
testNameName of the test used to compare the histograms
Returns
Test result.

Definition at line 59 of file JTestSignificance_t.hh.

59  {
60 
61  using namespace std;
62  using namespace JPP;
63 
64  if(h1 -> GetNbinsX() != h2 -> GetNbinsX())
65  ERROR("Histograms with different bining. The objects: " << h1 -> GetName() << " can not be compared." << endl);
66 
67 
68  T* h3 = (T*)h1->Clone(h1->GetName()==h2->GetName() ?
69  MAKE_CSTRING(to_string(h1->GetName())) :
70  MAKE_CSTRING(to_string(h1->GetName()) + "_VS_" + to_string(h2->GetName())));
71 
72  h3->Add(h2,-1*K);
73 
74  double S = 0;
75 
76  for (int i=0 ; i < h1->GetNbinsX() ; ++i){
77  for (int j=0 ; j< h1->GetNbinsY() ; ++j){
78  for (int k=0 ; k< h1->GetNbinsZ() ; ++k){
79 
80  double a = h1->GetBinContent(i+1,j+1,k+1);
81  double b = h2->GetBinContent(i+1,j+1,k+1);
82 
83  if(a!=0 || b!=0){
84  S += fabs((a - K*b)/sqrt(a + K*K*b));
85  }
86  }
87  }
88  }
89 
90  S /= (h1->GetNbinsX()*h1->GetNbinsY()*h1->GetNbinsZ());
91 
92  bool passed;
93 
94  (S < threshold ? passed = false : passed = true);
95 
96  JResultTitle title(testName, parameterName, passed, S);
97 
98  h3->SetTitle(title.getTitle().c_str());
99 
100  JTestResult r (testName,
101  JRootObjectID(MAKE_STRING(h1->GetDirectory()->GetPath() << h1->GetName())),
102  JRootObjectID(MAKE_STRING(h2->GetDirectory()->GetPath() << h1->GetName())),
103  parameterName, S , threshold, h3, passed);
104 
105  return r;
106  };
then fatal No hydrophone data file $HYDROPHONE_TXT fi sort gr k
static const uint32_t K[64]
Definition: crypt.cc:77
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:151
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
data_type r[M+1]
Definition: JPolint.hh:742
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:142
do set_variable OUTPUT_DIRECTORY $WORKDIR T
#define ERROR(A)
Definition: JMessage.hh:66
do set_variable SIGMA_NS set_variable OUTLIERS set_variable OUTPUT_FILE matrix[${ALPHA_DEG}\deg\] root $JPP JMatrixNZ a $DETECTOR f $INPUT_FILE o $OUTPUT_FILE S
Definition: JMatrixNZ.sh:58
then JCalibrateToT a
Definition: JTuneHV.sh:116
std::string to_string(const T &value)
Convert value to string.
int j
Definition: JPolint.hh:666

Member Data Documentation

double JCOMPAREHISTOGRAMS::JTestSignificance_2D::threshold
private

threshold p-value to decide if test is passed.

Definition at line 68 of file JTestSignificance_2D.hh.

double JCOMPAREHISTOGRAMS::JTestSignificance_2D::K
private

normalization factor between histograms.

Definition at line 72 of file JTestSignificance_2D.hh.

std::vector<JTestResult> JCOMPAREHISTOGRAMS::JTest_t::results
inherited

Buffer to store results of multiple tests.*/.

Definition at line 162 of file JTest_t.hh.

const std::string JCOMPAREHISTOGRAMS::JTest_t::testName
protectedinherited

test name

Definition at line 166 of file JTest_t.hh.

const std::string JCOMPAREHISTOGRAMS::JTest_t::resultType
protectedinherited

result type

Definition at line 167 of file JTest_t.hh.


The documentation for this class was generated from the following file: