CMS 3D CMS Logo

HistoCompare Class Reference

_________________________________________________________________ class: HistoCompare.h package: Validation/RecoB More...

#include <Validation/RecoB/interface/HistoCompare.h>

List of all members.

Public Member Functions

TH1 * Compare (TH1 *h, TString hname)
double GetResult ()
 HistoCompare (TString refFilename)
 HistoCompare ()
 _________________________________________________________________ class: HistoCompare.cc package: Validation/RecoB
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 (yumiceva@fnal.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 (yumiceva@fnal.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_.

00017                            {
00018   result_ = 0;
00019   do_nothing_ = false;
00020 }

HistoCompare::HistoCompare ( TString  refFilename  ) 

Definition at line 22 of file HistoCompare.cc.

References GenMuonPlsPt100GeV_cfg::cout, do_nothing_, lat::endl(), refFile_, result_, and setChi2Test_.

00022                                               {
00023 
00024         result_ = 0;
00025         do_nothing_ = false;
00026         // open reference file
00027         refFile_ = new TFile(refFilename);
00028         if (refFile_->IsZombie()) {
00029                 std::cout << " Error openning file " << refFilename << std::endl;
00030                 std::cout << " we will not compare histograms. " << std::endl;
00031                 do_nothing_ = true;
00032         } else {
00033                 std::cout << " open file " << refFilename << std::endl;
00034         }
00035         
00036         setChi2Test_ = true;
00037         
00038 }

HistoCompare::~HistoCompare (  ) 

Definition at line 40 of file HistoCompare.cc.

00040                             {
00041 }


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().

00044                                                 {
00045 
00046         if (do_nothing_) return 0;
00047         
00048         //std::cout << "histo: " << h->GetName() << " entries: "<< h->GetEntries() << std::endl;
00049         //std::cout << "hname: " << hname << std::endl;
00050 
00051         
00052         //create a residual histogram
00053         //if (resHisto_) delete resHisto_;
00054         resHisto_ = (TH1*) h->Clone(TString(h->GetName())+"_residuals");
00055         resHisto_->Reset();
00056 
00057         // clone input histogram
00058         TH1 *htemp = (TH1*) h->Clone(TString(h->GetName()));
00059 
00060         refFile_->cd();
00061         //std::cout << "get reference" << std::endl;
00062         refHisto_ = (TH1*) gDirectory->Get( hname );
00063         //std::cout << "historef: " << refHisto_->GetName() << " entries: "<< refHisto_->GetEntries() << std::endl;
00064         //std::cout << "name: " << refHisto_->GetName() << std::endl;
00065 
00066 
00067         // normalize histograms
00068         htemp->Scale(1./htemp->Integral());
00069         refHisto_->Scale(1./refHisto_->Integral());
00070         
00071         if (setChi2Test_) {
00072                 result_ = refHisto_->Chi2Test(htemp,"UFOF");
00073         }
00074         if (setKGTest_) {
00075                 result_ = refHisto_->KolmogorovTest(htemp,"UO");
00076         }
00077 
00078         
00079         resHisto_->Add( htemp, refHisto_, 1., -1.);
00080         
00081         //std::cout << " residual done." << std::endl;
00082         
00083         return resHisto_;
00084         
00085 }

double HistoCompare::GetResult (  )  [inline]

Definition at line 55 of file HistoCompare.h.

00055 { return result_; };

void HistoCompare::SetChi2Test ( bool  test = true  )  [inline]

Definition at line 47 of file HistoCompare.h.

References setChi2Test_, and parsecf::pyparsing::test().

00047                                          {
00048                 setChi2Test_ = test;
00049         };

void HistoCompare::SetKGTest ( bool  test = true  )  [inline]

Definition at line 51 of file HistoCompare.h.

References setKGTest_, and parsecf::pyparsing::test().

00051                                        {
00052                 setKGTest_ = test;
00053         };

void HistoCompare::SetReferenceFilename ( TString  filename  )  [inline]

Definition at line 35 of file HistoCompare.h.

References GenMuonPlsPt100GeV_cfg::cout, do_nothing_, lat::endl(), refFile_, and refFilename_.

Referenced by BTagValidator::endJob().

00035                                                     {
00036           refFilename_ = filename;
00037           //if (refFile_) delete refFile_;
00038           refFile_ = new TFile(refFilename_);
00039           if (refFile_->IsZombie()) {
00040                   std::cout << " Error openning file " << refFilename_ << std::endl;
00041                   std::cout << " we will not compare histograms. " << std::endl;
00042                   do_nothing_ = true;
00043           }
00044           std::cout << " open file" << std::endl;
00045         };


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().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:24:16 2009 for CMSSW by  doxygen 1.5.4