CMS 3D CMS Logo

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 23 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:53
bool do_nothing_
Definition: HistoCompare.h:54
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  result_ = 0;
23  do_nothing_ = false;
24  // open reference file
25  refFile_ = new TFile(refFilename);
26  if (refFile_->IsZombie()) {
27  std::cout << " Error openning file " << refFilename << std::endl;
28  std::cout << " we will not compare histograms. " << std::endl;
29  do_nothing_ = true;
30  } else {
31  std::cout << " open file " << refFilename << std::endl;
32  }
33 
34  setChi2Test_ = true;
35 }
double result_
Definition: HistoCompare.h:53
bool do_nothing_
Definition: HistoCompare.h:54
bool setChi2Test_
Definition: HistoCompare.h:48
TFile * refFile_
Definition: HistoCompare.h:58
HistoCompare::~HistoCompare ( )

Definition at line 37 of file HistoCompare.cc.

37 {}

Member Function Documentation

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

Definition at line 39 of file HistoCompare.cc.

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

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

Definition at line 48 of file HistoCompare.h.

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

Definition at line 32 of file HistoCompare.h.

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

32  {
34  // if (refFile_) delete refFile_;
35  refFile_ = new TFile(refFilename_);
36  if (refFile_->IsZombie()) {
37  std::cout << " Error openning file " << refFilename_ << std::endl;
38  std::cout << " we will not compare histograms. " << std::endl;
39  do_nothing_ = true;
40  }
41  std::cout << " open file" << std::endl;
42  };
bool do_nothing_
Definition: HistoCompare.h:54
TString refFilename_
Definition: HistoCompare.h:60
TFile * refFile_
Definition: HistoCompare.h:58

Member Data Documentation

bool HistoCompare::do_nothing_
private

Definition at line 54 of file HistoCompare.h.

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

TFile* HistoCompare::refFile_
private

Definition at line 58 of file HistoCompare.h.

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

TString HistoCompare::refFilename_
private

Definition at line 60 of file HistoCompare.h.

Referenced by SetReferenceFilename().

TH1* HistoCompare::refHisto_
private

Definition at line 57 of file HistoCompare.h.

Referenced by Compare().

TH1* HistoCompare::resHisto_
private

Definition at line 56 of file HistoCompare.h.

Referenced by Compare().

double HistoCompare::result_
private

Definition at line 53 of file HistoCompare.h.

Referenced by Compare(), and HistoCompare().

bool HistoCompare::setChi2Test_
private

Definition at line 48 of file HistoCompare.h.

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

bool HistoCompare::setKGTest_
private

Definition at line 52 of file HistoCompare.h.

Referenced by Compare(), and SetKGTest().