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

#include <JTestRuns_1D.hh>

Inheritance diagram for JTestRuns_1D:
JTest_t JTestRuns_t

Public Member Functions

 JTestRuns_1D ()
 
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 JRunsTest (TH1 *h1, TH1 *h2, double threshold, bool logX, bool logY)
 

Public Attributes

vector< JTestResultresults
 

Private Attributes

double threshold
 
bool logX
 
bool logY
 

Detailed Description

Definition at line 13 of file JTestRuns_1D.hh.

Constructor & Destructor Documentation

JTestRuns_1D::JTestRuns_1D ( )
inline

Definition at line 19 of file JTestRuns_1D.hh.

19 {}

Member Function Documentation

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

Implements JTest_t.

Definition at line 27 of file JTestRuns_1D.hh.

27  {
28  return in >> threshold >> logX >> logY;
29  };
double threshold
Definition: JTestRuns_1D.hh:92
esac print_variable DETECTOR INPUT_FILE OUTPUT_FILE CDF for TYPE in
Definition: JSirene.sh:45
std::ostream& JTestRuns_1D::write ( std::ostream &  out)
inlinevirtual

Implements JTest_t.

Definition at line 37 of file JTestRuns_1D.hh.

37  {
38  for (vector<JTestResult>::const_iterator r = results.begin() ; r != results.end() ; ++r) {
39  out << scientific << setprecision(2) << (r->passed ? GREEN : RED) << r->message << endl;
40  }
41  return out;
42  };
data_type r[M+1]
Definition: JPolint.hh:709
vector< JTestResult > results
Definition: JTest_t.hh:77
void JTestRuns_1D::test ( TObject o1,
TObject o2 
)
inlinevirtual

Implements JTest_t.

Definition at line 50 of file JTestRuns_1D.hh.

50  {
51 
52  if (!(dynamic_cast<TH2*>(o1) == NULL) || !(dynamic_cast<TH2*>(o2) == NULL)) {
53  ERROR("For 2D histograms call JTestRuns_2D: " << o1->GetName() << endl);
54 
55  } else if (!(dynamic_cast<TH1*>(o1) == NULL) && !(dynamic_cast<TH1*>(o2) == NULL)) {
56 
57  TH1D* h1 = dynamic_cast<TH1D*>(o1);
58  TH1D* h2 = dynamic_cast<TH1D*>(o2);
59 
60  if(h1 -> GetNbinsX() != h2 -> GetNbinsX())
61  ERROR("Histograms with different bining. The objects: " << h1 -> GetName() << " can not be compared." << endl);
62 
64 
65  results.push_back(r);
66  }
67  };
double threshold
Definition: JTestRuns_1D.hh:92
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:69
data_type r[M+1]
Definition: JPolint.hh:709
#define ERROR(A)
Definition: JMessage.hh:66
vector< JTestResult > results
Definition: JTest_t.hh:77
JTestResult JRunsTest(TH1 *h1, TH1 *h2, double threshold, bool logX, bool logY)
Definition: JTestRuns_t.hh:24
virtual void JTestRuns_1D::save ( TFile *  f,
string  path 
)
inlinevirtual

Implements JTest_t.

Definition at line 74 of file JTestRuns_1D.hh.

74  {
75 
76  for (vector<JTestResult>::const_iterator r = results.begin() ; r != results.end() ; ++r){
77 
78  if (f -> GetDirectory(path.c_str())==0) f->mkdir(path.c_str());
79  f->cd(path.c_str());
80  r->obj->Write();
81  }
82  }
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 JTestRuns_1D::clear ( )
inlinevirtual

Implements JTest_t.

Definition at line 87 of file JTestRuns_1D.hh.

87  {
88  results.clear();
89  }
vector< JTestResult > results
Definition: JTest_t.hh:77
JTestResult JTestRuns_t::JRunsTest ( TH1 *  h1,
TH1 *  h2,
double  threshold,
bool  logX,
bool  logY 
)
inlineinherited

Definition at line 24 of file JTestRuns_t.hh.

24  {
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  };
#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
fi JEventTimesliceWriter a
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:699
do set_variable OUTPUT_DIRECTORY $WORKDIR T
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
#define ERROR(A)
Definition: JMessage.hh:66
then usage $script[distance] fi case set_variable R
Definition: JDrawLED.sh:40
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.
bool passed
Definition: JTest_t.hh:64
TObject * obj
Definition: JTest_t.hh:66
then usage $script[input file[working directory[option]]] nWhere option can be N
Definition: JMuonPostfit.sh:37

Member Data Documentation

double JTestRuns_1D::threshold
private

Definition at line 92 of file JTestRuns_1D.hh.

bool JTestRuns_1D::logX
private

Definition at line 93 of file JTestRuns_1D.hh.

bool JTestRuns_1D::logY
private

Definition at line 94 of file JTestRuns_1D.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: