Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:07

0001 #include <iostream.h>
0002 
0003 class HistoCompare {
0004 
0005  public:
0006 
0007   HistoCompare() { std::cout << "Initializing HistoCompare... " << std::endl; } ;
0008 
0009   void PVCompute(TH1 * oldHisto , TH1 * newHisto , TText * te , int method=1);
0010   void PVCompute(TH2 * oldHisto , TH2 * newHisto , TText * te, int method=1 );
0011   void PVCompute(TProfile * oldHisto , TProfile * newHisto , TText * te , int method=1);
0012 
0013  private:
0014   
0015   Double_t mypv;
0016 
0017   TH1 * myoldHisto1;
0018   TH1 * mynewHisto1;
0019 
0020   TH2 * myoldHisto2;
0021   TH2 * mynewHisto2;
0022 
0023   TProfile * myoldProfile;
0024   TProfile * mynewProfile;
0025 
0026   TText * myte;
0027 
0028 };
0029 
0030 HistoCompare::PVCompute(TH1 * oldHisto , TH1 * newHisto , TText * te , int method)
0031 {
0032 
0033   myoldHisto1 = oldHisto;
0034   mynewHisto1 = newHisto;
0035   myte = te;
0036 
0037   Double_t *res;
0038 
0039   Double_t mypv;
0040   if (method == 1) {
0041      mypv = myoldHisto1->Chi2Test(mynewHisto1,"UU",res);
0042   }else {
0043      mypv = myoldHisto1->KolmogorovTest(mynewHisto1, "UO");
0044   }
0045 
0046   std::strstream buf;
0047   std::string value;
0048   buf<<"PV="<<mypv<<std::endl;
0049   buf>>value;
0050   
0051   myte->DrawTextNDC(0.2,0.7, value.c_str());
0052 
0053   std::cout << "[OVAL] " << myoldHisto1->GetName() << " PV = " << mypv << std::endl;
0054   return;
0055 
0056 }
0057 
0058 HistoCompare::PVCompute(TH2 * oldHisto , TH2 * newHisto , TText * te , int method )
0059 {
0060 
0061   myoldHisto2 = oldHisto;
0062   mynewHisto2 = newHisto;
0063   myte = te;
0064 
0065   Double_t *res ;
0066   Double_t mypv ;
0067   if (method == 1) {
0068    mypv = myoldHisto2->Chi2Test(mynewHisto2,"UU",res);
0069   }else {
0070      mypv = myoldHisto2->KolmogorovTest(mynewHisto2, "UO");
0071   }
0072 
0073 
0074   std::strstream buf;
0075   std::string value;
0076   buf<<"PV="<<mypv<<std::endl;
0077   buf>>value;
0078   
0079   myte->DrawTextNDC(0.2,0.7, value.c_str());
0080 
0081   std::cout << "[OVAL] " << myoldHisto2->GetName() << " PV = " << mypv << std::endl;
0082   return;
0083 
0084 }
0085 
0086 
0087 HistoCompare::PVCompute(TProfile * oldHisto , TProfile * newHisto , TText * te , int method)
0088 {
0089 
0090   myoldProfile = oldHisto;
0091   mynewProfile = newHisto;
0092   myte = te;
0093 
0094   Double_t *res ;
0095 
0096   Double_t mypv;
0097   if (method == 1) {
0098    mypv = myoldProfile->Chi2Test(mynewProfile,"UU",res);
0099   }else {
0100      mypv = myoldProfile->KolmogorovTest(mynewProfile, "UO");
0101   }
0102 
0103 
0104   std::strstream buf;
0105   std::string value;
0106   buf<<"PV="<<mypv<<std::endl;
0107   buf>>value;
0108   
0109   myte->DrawTextNDC(0.2,0.7, value.c_str());
0110 
0111   std::cout << "[OVAL] " << myoldProfile->GetName() << " PV = " << mypv << std::endl;
0112   return;
0113 
0114 }