CMS 3D CMS Logo

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

#include <HistoCompare.h>

Public Member Functions

TH1 * Compare (TH1 *h, TString hname)
 
double GetResult ()
 
 HistoCompare ()
 
 HistoCompare (TString refFilename)
 
void SetChi2Test (bool test=true)
 
void SetKGTest (bool test=true)
 
void SetReferenceFilename (TString filename)
 
 ~HistoCompare ()
 

Private Attributes

bool do_nothing_
 
TFile * refFile_
 
TString refFilename_
 
TH1 * refHisto_
 
TH1 * resHisto_
 
double result_
 
bool setChi2Test_
 
bool setKGTest_
 

Detailed Description


class: HistoCompare.h package: Validation/RecoB

author: Victor Bazterra, UIC Francisco Yumiceva, Fermilab (yumic.nosp@m.eva@.nosp@m.fnal..nosp@m.gov)

version

Id:
HistoCompare.h,v 1.2 2007/02/14 20:09:41 yumiceva Exp

Definition at line 25 of file HistoCompare.h.

Constructor & Destructor Documentation

HistoCompare::HistoCompare ( )

class: HistoCompare.cc package: Validation/RecoB

author: Victor Bazterra, UIC Francisco Yumiceva, Fermilab (yumic.nosp@m.eva@.nosp@m.fnal..nosp@m.gov)

version

Id:
HistoCompare.cc,v 1.3 2007/02/14 20:20:08 yumiceva Exp

Definition at line 17 of file HistoCompare.cc.

References do_nothing_, and result_.

17  {
18  result_ = 0;
19  do_nothing_ = false;
20 }
double result_
Definition: HistoCompare.h:61
bool do_nothing_
Definition: HistoCompare.h:62
HistoCompare::HistoCompare ( TString  refFilename)

Definition at line 22 of file HistoCompare.cc.

References gather_cfg::cout, do_nothing_, refFile_, result_, and setChi2Test_.

22  {
23 
24  result_ = 0;
25  do_nothing_ = false;
26  // open reference file
27  refFile_ = new TFile(refFilename);
28  if (refFile_->IsZombie()) {
29  std::cout << " Error openning file " << refFilename << std::endl;
30  std::cout << " we will not compare histograms. " << std::endl;
31  do_nothing_ = true;
32  } else {
33  std::cout << " open file " << refFilename << std::endl;
34  }
35 
36  setChi2Test_ = true;
37 
38 }
double result_
Definition: HistoCompare.h:61
bool do_nothing_
Definition: HistoCompare.h:62
tuple cout
Definition: gather_cfg.py:121
bool setChi2Test_
Definition: HistoCompare.h:55
TFile * refFile_
Definition: HistoCompare.h:66
HistoCompare::~HistoCompare ( )

Definition at line 40 of file HistoCompare.cc.

40  {
41 }

Member Function Documentation

TH1 * HistoCompare::Compare ( TH1 *  h,
TString  hname 
)

Definition at line 44 of file HistoCompare.cc.

References do_nothing_, refFile_, refHisto_, resHisto_, result_, setChi2Test_, and setKGTest_.

Referenced by BTagValidator::endJob().

44  {
45 
46  if (do_nothing_) return 0;
47 
48  //std::cout << "histo: " << h->GetName() << " entries: "<< h->GetEntries() << std::endl;
49  //std::cout << "hname: " << hname << std::endl;
50 
51 
52  //create a residual histogram
53  //if (resHisto_) delete resHisto_;
54  resHisto_ = (TH1*) h->Clone(TString(h->GetName())+"_residuals");
55  resHisto_->Reset();
56 
57  // clone input histogram
58  TH1 *htemp = (TH1*) h->Clone(TString(h->GetName()));
59 
60  refFile_->cd();
61  //std::cout << "get reference" << std::endl;
62  refHisto_ = (TH1*) gDirectory->Get( hname );
63  //std::cout << "historef: " << refHisto_->GetName() << " entries: "<< refHisto_->GetEntries() << std::endl;
64  //std::cout << "name: " << refHisto_->GetName() << std::endl;
65 
66 
67  // normalize histograms
68  htemp->Scale(1./htemp->Integral());
69  refHisto_->Scale(1./refHisto_->Integral());
70 
71  if (setChi2Test_) {
72  result_ = refHisto_->Chi2Test(htemp,"UFOF");
73  }
74  if (setKGTest_) {
75  result_ = refHisto_->KolmogorovTest(htemp,"UO");
76  }
77 
78 
79  resHisto_->Add( htemp, refHisto_, 1., -1.);
80 
81  //std::cout << " residual done." << std::endl;
82 
83  return resHisto_;
84 
85 }
double result_
Definition: HistoCompare.h:61
TH1 * resHisto_
Definition: HistoCompare.h:64
bool do_nothing_
Definition: HistoCompare.h:62
TH1 * refHisto_
Definition: HistoCompare.h:65
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
bool setChi2Test_
Definition: HistoCompare.h:55
TFile * refFile_
Definition: HistoCompare.h:66
double HistoCompare::GetResult ( )
inline

Definition at line 55 of file HistoCompare.h.

55 { return result_; };
double result_
Definition: HistoCompare.h:61
void HistoCompare::SetChi2Test ( bool  test = true)
inline

Definition at line 47 of file HistoCompare.h.

References setChi2Test_, and run_regression::test.

47  {
49  };
bool setChi2Test_
Definition: HistoCompare.h:55
void HistoCompare::SetKGTest ( bool  test = true)
inline

Definition at line 51 of file HistoCompare.h.

References setKGTest_, and run_regression::test.

51  {
52  setKGTest_ = test;
53  };
void HistoCompare::SetReferenceFilename ( TString  filename)
inline

Definition at line 35 of file HistoCompare.h.

References gather_cfg::cout, do_nothing_, lut2db_cfg::filename, refFile_, and refFilename_.

Referenced by BTagValidator::endJob().

35  {
37  //if (refFile_) delete refFile_;
38  refFile_ = new TFile(refFilename_);
39  if (refFile_->IsZombie()) {
40  std::cout << " Error openning file " << refFilename_ << std::endl;
41  std::cout << " we will not compare histograms. " << std::endl;
42  do_nothing_ = true;
43  }
44  std::cout << " open file" << std::endl;
45  };
bool do_nothing_
Definition: HistoCompare.h:62
TString refFilename_
Definition: HistoCompare.h:68
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:121
TFile * refFile_
Definition: HistoCompare.h:66

Member Data Documentation

bool HistoCompare::do_nothing_
private

Definition at line 62 of file HistoCompare.h.

Referenced by Compare(), HistoCompare(), and SetReferenceFilename().

TFile* HistoCompare::refFile_
private

Definition at line 66 of file HistoCompare.h.

Referenced by Compare(), HistoCompare(), and SetReferenceFilename().

TString HistoCompare::refFilename_
private

Definition at line 68 of file HistoCompare.h.

Referenced by SetReferenceFilename().

TH1* HistoCompare::refHisto_
private

Definition at line 65 of file HistoCompare.h.

Referenced by Compare().

TH1* HistoCompare::resHisto_
private

Definition at line 64 of file HistoCompare.h.

Referenced by Compare().

double HistoCompare::result_
private

Definition at line 61 of file HistoCompare.h.

Referenced by Compare(), and HistoCompare().

bool HistoCompare::setChi2Test_
private

Definition at line 55 of file HistoCompare.h.

Referenced by Compare(), HistoCompare(), and SetChi2Test().

bool HistoCompare::setKGTest_
private

Definition at line 60 of file HistoCompare.h.

Referenced by Compare(), and SetKGTest().