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_2D Class Reference

#include <JTestRuns_2D.hh>

Inheritance diagram for JTestRuns_2D:
JTestRuns_t JTest_t

Public Member Functions

 JTestRuns_2D ()
 
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
 
char slice
 

Detailed Description

Definition at line 13 of file JTestRuns_2D.hh.

Constructor & Destructor Documentation

JTestRuns_2D::JTestRuns_2D ( )
inline

Definition at line 19 of file JTestRuns_2D.hh.

19 {}

Member Function Documentation

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

Implements JTest_t.

Definition at line 27 of file JTestRuns_2D.hh.

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

Implements JTest_t.

Definition at line 37 of file JTestRuns_2D.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_2D::test ( TObject o1,
TObject o2 
)
inlinevirtual

Implements JTest_t.

Definition at line 50 of file JTestRuns_2D.hh.

50  {
51 
52  if (!(dynamic_cast<TH2*>(o1) == NULL) && !(dynamic_cast<TH2*>(o2) == NULL)) {
53 
54  TH2D* h1 = dynamic_cast<TH2D*>(o1);
55  TH2D* h2 = dynamic_cast<TH2D*>(o2);
56 
57  if(slice == 'x' || slice == 'X'){
58 
59  int nSlices1 = h1->GetNbinsX();
60  int nSlices2 = h2->GetNbinsX();
61 
62  if(nSlices1 != nSlices2)
63  ERROR("Histograms with different binning. The objects: " << o1->GetName() << " can not be compared." << endl);
64 
65  for (int i=1 ; i<=nSlices1 ; ++i){
66 
67  string name = MAKE_STRING(o1->GetName() + to_string("_") + to_string(i));
68 
69  TH1D* s1 = h1->ProjectionY (name.c_str(),i,i);
70  TH1D* s2 = h2->ProjectionY (name.c_str(),i,i);
71 
73 
74  results.push_back(r);
75  }
76  }else if (slice == 'y' || slice == 'Y'){
77 
78  int nSlices1 = h1->GetNbinsY();
79  int nSlices2 = h2->GetNbinsY();
80 
81  if(nSlices1 != nSlices2)
82  ERROR("Histograms with different binning. The objects: " << o1->GetName() << " can not be compared." << endl);
83 
84  for (int i=1 ; i<=nSlices1 ; ++i){
85 
86  string name = MAKE_STRING(o1->GetName() + to_string("_") + to_string(i));
87 
88  TH1D* s1 = h1->ProjectionX (name.c_str(),i,i);
89  TH1D* s2 = h2->ProjectionX (name.c_str(),i,i);
90 
92  results.push_back(r);
93  }
94  }
95 
96  } else if (!(dynamic_cast<TH1*>(o1) == NULL) && !(dynamic_cast<TH1*>(o2) == NULL)) {
97  ERROR("For 1D histograms call JChi2_1D: " << o1->GetName() << endl);
98  }
99  };
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
vector< JTestResult > results
Definition: JTest_t.hh:77
then echo n User name
Definition: JCookie.sh:45
std::string to_string(const T &value)
Convert value to string.
double threshold
JTestResult JRunsTest(TH1 *h1, TH1 *h2, double threshold, bool logX, bool logY)
Definition: JTestRuns_t.hh:24
virtual void JTestRuns_2D::save ( TFile *  f,
string  path 
)
inlinevirtual

Implements JTest_t.

Definition at line 106 of file JTestRuns_2D.hh.

106  {
107 
108  for (vector<JTestResult>::const_iterator r = results.begin() ; r != results.end() ; ++r){
109 
110  if (f -> GetDirectory(path.c_str())==0) f->mkdir(path.c_str());
111  f->cd(path.c_str());
112  r->obj->Write();
113  }
114  }
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_2D::clear ( )
inlinevirtual

Implements JTest_t.

Definition at line 119 of file JTestRuns_2D.hh.

119  {
120  results.clear();
121  }
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_2D::threshold
private

Definition at line 124 of file JTestRuns_2D.hh.

bool JTestRuns_2D::logX
private

Definition at line 125 of file JTestRuns_2D.hh.

bool JTestRuns_2D::logY
private

Definition at line 126 of file JTestRuns_2D.hh.

char JTestRuns_2D::slice
private

Definition at line 127 of file JTestRuns_2D.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: