Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | Private Attributes | List of all members
JTestZero Class Reference

#include <JTestZero.hh>

Inheritance diagram for JTestZero:
JTest_t JTestZero_t

Public Member Functions

 JTestZero ()
 
std::istream & read (std::istream &in)
 
std::ostream & write (std::ostream &out)
 
void test (TObject *o1, TObject *o2)
 
virtual void save (TFile *f, string path)
 
void clear ()
 
JTestResult JTestZero_2D (TH2 *h1, TH2 *h2, double outliersThreshold, double threshold)
 

Public Attributes

vector< JTestResultresults
 

Private Attributes

double outliersThreshold
 Fraction of bins allowed to fail. More...
 
double threshold
 threshold p-value to decide if test is passed. More...
 

Detailed Description

Definition at line 22 of file JTestZero.hh.

Constructor & Destructor Documentation

JTestZero::JTestZero ( )
inline

Definition at line 31 of file JTestZero.hh.

31 {}

Member Function Documentation

std::istream& JTestZero::read ( std::istream &  in)
inlinevirtual

Implements JTest_t.

Definition at line 39 of file JTestZero.hh.

39  {
40  return in >> outliersThreshold >> threshold;
41  };
double outliersThreshold
Fraction of bins allowed to fail.
Definition: JTestZero.hh:98
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
double threshold
threshold p-value to decide if test is passed.
Definition: JTestZero.hh:99
std::ostream& JTestZero::write ( std::ostream &  out)
inlinevirtual

Implements JTest_t.

Definition at line 49 of file JTestZero.hh.

49  {
50  for (vector<JTestResult>::const_iterator r = results.begin() ; r != results.end() ; ++r) {
51  out << scientific << setprecision(2) << (r->passed ? GREEN : RED) << r->message << endl;
52  }
53  return out;
54  };
data_type r[M+1]
Definition: JPolint.hh:709
vector< JTestResult > results
Definition: JTest_t.hh:77
void JTestZero::test ( TObject o1,
TObject o2 
)
inlinevirtual

Implements JTest_t.

Definition at line 62 of file JTestZero.hh.

62  {
63 
64  if (!(dynamic_cast<TH2*>(o1) == NULL) && !(dynamic_cast<TH2*>(o2) == NULL)) {
65 
66  TH2D* h1 = dynamic_cast<TH2D*>(o1);
67  TH2D* h2 = dynamic_cast<TH2D*>(o2);
68 
70  results.push_back(r);
71  }
72  };
JTestResult JTestZero_2D(TH2 *h1, TH2 *h2, double outliersThreshold, double threshold)
Definition: JTestZero_t.hh:37
double outliersThreshold
Fraction of bins allowed to fail.
Definition: JTestZero.hh:98
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
data_type r[M+1]
Definition: JPolint.hh:709
double threshold
threshold p-value to decide if test is passed.
Definition: JTestZero.hh:99
vector< JTestResult > results
Definition: JTest_t.hh:77
virtual void JTestZero::save ( TFile *  f,
string  path 
)
inlinevirtual

Implements JTest_t.

Definition at line 80 of file JTestZero.hh.

80  {
81 
82  for (vector<JTestResult>::const_iterator r = results.begin() ; r != results.end() ; ++r){
83 
84  if (f -> GetDirectory(path.c_str())==0) f->mkdir(path.c_str());
85  f->cd(path.c_str());
86  r->obj->Write();
87  }
88  }
data_type r[M+1]
Definition: JPolint.hh:709
then JPizza f
Definition: JPizza.sh:46
do cat driver txt<< EOFevent ev_configure{RC_EVT%< ev_configure.txt > RC_DWRT path
vector< JTestResult > results
Definition: JTest_t.hh:77
void JTestZero::clear ( )
inlinevirtual

Implements JTest_t.

Definition at line 93 of file JTestZero.hh.

93  {
94  results.clear();
95  }
vector< JTestResult > results
Definition: JTest_t.hh:77
JTestResult JTestZero_t::JTestZero_2D ( TH2 *  h1,
TH2 *  h2,
double  outliersThreshold,
double  threshold 
)
inlineinherited

Definition at line 37 of file JTestZero_t.hh.

37  {
38 
39  int nx1 = h1->GetNbinsX();
40  int nx2 = h2->GetNbinsX();
41  int ny1 = h1->GetNbinsY();
42  int ny2 = h2->GetNbinsY();
43 
44  if(nx1 != nx2 || ny1 != ny2)
45  ERROR("Histograms with different binning. The objects: " << h1->GetName() << " can not be compared." << endl);
46 
47  TH2D* h3 = (TH2D*)h1->Clone(h1->GetName()==h2->GetName() ?
48  MAKE_CSTRING(to_string(h1->GetName())) :
49  MAKE_CSTRING(to_string(h1->GetName()) + "_VS_" + to_string(h2->GetName())));
50  h3->Reset();
51 
52  JTestResult r;
53 
54  double failures = 0;
55 
56  for (int i=1 ; i<nx1+1 ; ++i){
57  for (int j=1 ; j<ny1+1 ; ++j){
58 
59  double m = h1 -> GetBinContent(i,j);
60  double n = h2 -> GetBinContent(i,j);
61 
62  double p1 = 1 - ROOT::Math::poisson_cdf(m,1);
63  double p2 = 1 - ROOT::Math::poisson_cdf(n,1);
64 
65  cout << "m " << m << " pm " << p1 << " n " << n << " pn " << p2 << endl;
66 
67  if ((p1 > threshold && p2 < threshold) ||
68  (p1 < threshold && p2 > threshold)){
69  h3->Fill(i,j);
70  failures+=1./(nx1*ny1);
71  }
72  }
73  }
74 
75  (failures > outliersThreshold ? r.passed = false : r.passed = true);
76 
77  r.message = MAKE_STRING(scientific << setprecision(2)<< "Test: " << "Chi2" <<
78  " HA: " << h1->GetUniqueID() << " " << h1->GetName() <<
79  " HB: " << h2->GetUniqueID() << " " << h2->GetName() <<
80  " Threshold: " << outliersThreshold << " Result: " << failures << " " << (r.passed ? "PASSED" : "FAILED"));
81 
82  JResultTitle title("Zero", "Failures[%] ", r.passed , failures * 100);
83 
84  h3->SetTitle(title.getTitle().c_str());
85 
86  r.obj = h3;
87 
88  return r;
89  };
TPaveText * p1
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:708
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
data_type r[M+1]
Definition: JPolint.hh:709
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:699
#define ERROR(A)
Definition: JMessage.hh:66
string message
Definition: JTest_t.hh:65
alias put_queue eval echo n
Definition: qlib.csh:19
std::string to_string(const T &value)
Convert value to string.
int j
Definition: JPolint.hh:634
bool passed
Definition: JTest_t.hh:64
TObject * obj
Definition: JTest_t.hh:66

Member Data Documentation

double JTestZero::outliersThreshold
private

Fraction of bins allowed to fail.

Definition at line 98 of file JTestZero.hh.

double JTestZero::threshold
private

threshold p-value to decide if test is passed.

Definition at line 99 of file JTestZero.hh.

vector<JTestResult> JTest_t::results
inherited

Definition at line 77 of file JTest_t.hh.


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