File indexing completed on 2024-04-06 12:33:47
0001 #include <iostream> // std::cout
0002 #include <string> // std::string
0003 #include <sstream> // std::stringstream
0004 #include <fstream> // std::filestream
0005 #include "TH1F.h"
0006 #include "TH2.h"
0007 #include "TProfile.h"
0008 #include "TText.h"
0009
0010 class HistoCompare {
0011
0012 public:
0013
0014 HistoCompare() { std::cout << "Initializing HistoCompare... " << std::endl; } ;
0015
0016 void PVCompute(TH1 * oldHisto , TH1 * newHisto , TText * te, const double x=0.6, const double y=0.7);
0017 void PVCompute(TH2 * oldHisto , TH2 * newHisto , TText * te, const double x=0.2, const double y=0.7);
0018 void PVCompute(TProfile * oldHisto , TProfile * newHisto , TText * te, const double x=0.2, const double y=0.7);
0019
0020 private:
0021
0022 TH1 * myoldHisto1;
0023 TH1 * mynewHisto1;
0024
0025 TH2 * myoldHisto2;
0026 TH2 * mynewHisto2;
0027
0028 TProfile * myoldProfile;
0029 TProfile * mynewProfile;
0030
0031 TText * myte;
0032
0033 };
0034
0035 void HistoCompare::PVCompute(TH1 * oldHisto , TH1 * newHisto , TText * te, const double x, const double y)
0036 {
0037
0038 myoldHisto1 = oldHisto;
0039 mynewHisto1 = newHisto;
0040 myte = te;
0041
0042 Double_t mypv = myoldHisto1->Chi2Test(mynewHisto1,"UUNORM");
0043 std::stringstream buf;
0044 std::string value;
0045 buf<<"PV="<<mypv<<std::endl;
0046 buf>>value;
0047
0048 myte->DrawTextNDC(x, y, value.c_str());
0049
0050 std::cout << "[OVAL] " << myoldHisto1->GetName() << " PV = " << mypv << std::endl;
0051 return;
0052
0053 }
0054
0055 void HistoCompare::PVCompute(TH2 * oldHisto , TH2 * newHisto , TText * te, const double x, const double y)
0056 {
0057
0058 myoldHisto2 = oldHisto;
0059 mynewHisto2 = newHisto;
0060 myte = te;
0061
0062 Double_t mypv = myoldHisto2->Chi2Test(mynewHisto2,"UUNORM");
0063 std::stringstream buf;
0064 std::string value;
0065 buf<<"PV="<<mypv<<std::endl;
0066 buf>>value;
0067
0068 myte->DrawTextNDC(x, y, value.c_str());
0069
0070 std::cout << "[OVAL] " << myoldHisto2->GetName() << " PV = " << mypv << std::endl;
0071 return;
0072
0073 }
0074
0075
0076 void HistoCompare::PVCompute(TProfile * oldHisto , TProfile * newHisto , TText * te, const double x, const double y)
0077 {
0078
0079 myoldProfile = oldHisto;
0080 mynewProfile = newHisto;
0081 myte = te;
0082
0083 Double_t mypv = myoldProfile->Chi2Test(mynewProfile,"UUNORM");
0084 std::stringstream buf;
0085 std::string value;
0086 buf<<"PV="<<mypv<<std::endl;
0087 buf>>value;
0088
0089 myte->DrawTextNDC(x, y, value.c_str());
0090
0091 std::cout << "[OVAL] " << myoldProfile->GetName() << " PV = " << mypv << std::endl;
0092 return;
0093
0094 }