File indexing completed on 2024-04-06 12:33:30
0001 #include <iostream.h>
0002 #include "TFile.h"
0003
0004 class HistoCompare_Strips {
0005
0006 public:
0007
0008 HistoCompare_Strips()
0009 {
0010 std::cout << "Initializing HistoCompare_Strips... " << std::endl;
0011 name = "none";
0012 } ;
0013
0014 HistoCompare_Strips(char* thisname = "none") : mypv(-9999.9)
0015 {
0016 name = thisname;
0017 std::cout << "Initializing HistoCompare_Strips... " << std::endl;
0018 if ( name != "none" )
0019 {
0020 cout << "... creating output file" << endl;
0021
0022 out_file.open( thisname, ios::out);
0023 if ( out_file.fail() )
0024 {
0025 cout << "Could not open data file" << endl;
0026 exit(1);
0027 }
0028 }
0029 } ;
0030
0031 ~HistoCompare_Strips()
0032 {
0033 if ( name != "none" )
0034 {
0035 cout << "... closing output file" << endl;
0036 out_file.close();
0037 }
0038
0039 };
0040
0041 void PVCompute(TH1 * oldHisto , TH1 * newHisto , TText * te );
0042 void PVCompute(TH2 * oldHisto , TH2 * newHisto , TText * te );
0043 void PVCompute(TProfile * oldHisto , TProfile * newHisto , TText * te );
0044
0045 Double_t getPV() { return mypv; };
0046 void setName(char* s) { name = s; };
0047
0048 private:
0049
0050 Double_t mypv;
0051
0052 TH1 * myoldHisto1;
0053 TH1 * mynewHisto1;
0054
0055 TH2 * myoldHisto2;
0056 TH2 * mynewHisto2;
0057
0058 TProfile * myoldProfile;
0059 TProfile * mynewProfile;
0060
0061 TText * myte;
0062
0063 char* name;
0064
0065 fstream out_file;
0066
0067 };
0068
0069 HistoCompare_Strips::PVCompute(TH1 * oldHisto , TH1 * newHisto , TText * te )
0070 {
0071
0072 myoldHisto1 = oldHisto;
0073 mynewHisto1 = newHisto;
0074 myte = te;
0075
0076
0077
0078 mypv = myoldHisto1->Chi2Test(mynewHisto1,"UUNORM");
0079
0080 std::strstream buf;
0081 std::string value;
0082 buf<<"PV="<<mypv<<std::endl;
0083 buf>>value;
0084
0085 myte->DrawTextNDC(0.6,0.7, value.c_str());
0086
0087 std::cout << "[OVAL] " << myoldHisto1->GetName() << " PV = " << mypv << std::endl;
0088
0089 if ( name != "none" )
0090 {
0091 if ( mypv < 0.01 )
0092 out_file << myoldHisto1->GetName() << " pv = " << mypv << " comparison fails !!!" << endl;
0093 else
0094 out_file << myoldHisto1->GetName() << " pv = " << mypv << endl;
0095 }
0096
0097 return;
0098
0099 }
0100
0101 HistoCompare_Strips::PVCompute(TH2 * oldHisto , TH2 * newHisto , TText * te )
0102 {
0103
0104 myoldHisto2 = oldHisto;
0105 mynewHisto2 = newHisto;
0106 myte = te;
0107
0108
0109 mypv = myoldHisto2->Chi2Test(mynewHisto2,"OU");
0110 std::strstream buf;
0111 std::string value;
0112 buf<<"PV="<<mypv<<std::endl;
0113 buf>>value;
0114
0115 myte->DrawTextNDC(0.2,0.7, value.c_str());
0116
0117 std::cout << "[OVAL] " << myoldHisto2->GetName() << " PV = " << mypv << std::endl;
0118
0119 if ( name != "none" )
0120 {
0121 if ( mypv < 0.01 )
0122 out_file << myoldHisto1->GetName() << " pv = " << mypv << " comparison fails !!!" << endl;
0123 else
0124 out_file << myoldHisto1->GetName() << " pv = " << mypv << endl;
0125 }
0126
0127 return;
0128 }
0129
0130
0131 HistoCompare_Strips::PVCompute(TProfile * oldHisto , TProfile * newHisto , TText * te )
0132 {
0133
0134 myoldProfile = oldHisto;
0135 mynewProfile = newHisto;
0136 myte = te;
0137
0138
0139 mypv = myoldProfile->Chi2Test(mynewProfile,"OU");
0140 std::strstream buf;
0141 std::string value;
0142 buf<<"PV="<<mypv<<std::endl;
0143 buf>>value;
0144
0145 myte->DrawTextNDC(0.2,0.7, value.c_str());
0146
0147 std::cout << "[OVAL] " << myoldProfile->GetName() << " PV = " << mypv << std::endl;
0148
0149 if ( name != "none" )
0150 {
0151 if ( mypv < 0.01 )
0152 out_file << myoldHisto1->GetName() << " pv = " << mypv << " comparison fails !!!" << endl;
0153 else
0154 out_file << myoldHisto1->GetName() << " pv = " << mypv << endl;
0155 }
0156
0157 return;
0158
0159 }