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, const TString &hname)
 
double GetResult ()
 
 HistoCompare ()
 
 HistoCompare (const TString &refFilename)
 
void SetChi2Test (bool test=true)
 
void SetKGTest (bool test=true)
 
void SetReferenceFilename (const 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)


Definition at line 24 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)


Definition at line 16 of file HistoCompare.cc.

References do_nothing_, and result_.

16  {
17  result_ = 0;
18  do_nothing_ = false;
19 }
double result_
Definition: HistoCompare.h:60
bool do_nothing_
Definition: HistoCompare.h:61
HistoCompare::HistoCompare ( const TString &  refFilename)

Definition at line 21 of file HistoCompare.cc.

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

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

Definition at line 39 of file HistoCompare.cc.

39  {
40 }

Member Function Documentation

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

Definition at line 43 of file HistoCompare.cc.

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

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

Definition at line 54 of file HistoCompare.h.

54 { return result_; };
double result_
Definition: HistoCompare.h:60
void HistoCompare::SetChi2Test ( bool  test = true)
inline
void HistoCompare::SetKGTest ( bool  test = true)
inline
void HistoCompare::SetReferenceFilename ( const TString &  filename)
inline

Definition at line 34 of file HistoCompare.h.

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

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

Member Data Documentation

bool HistoCompare::do_nothing_
private

Definition at line 61 of file HistoCompare.h.

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

TFile* HistoCompare::refFile_
private

Definition at line 65 of file HistoCompare.h.

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

TString HistoCompare::refFilename_
private

Definition at line 67 of file HistoCompare.h.

Referenced by SetReferenceFilename().

TH1* HistoCompare::refHisto_
private

Definition at line 64 of file HistoCompare.h.

Referenced by Compare().

TH1* HistoCompare::resHisto_
private

Definition at line 63 of file HistoCompare.h.

Referenced by Compare().

double HistoCompare::result_
private

Definition at line 60 of file HistoCompare.h.

Referenced by Compare(), and HistoCompare().

bool HistoCompare::setChi2Test_
private

Definition at line 54 of file HistoCompare.h.

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

bool HistoCompare::setKGTest_
private

Definition at line 59 of file HistoCompare.h.

Referenced by Compare(), and SetKGTest().