Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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 );
0010   void PVCompute(TH2 * oldHisto , TH2 * newHisto , TText * te );
0011   void PVCompute(TProfile * oldHisto , TProfile * newHisto , TText * te );
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 )
0031 {
0032 
0033   myoldHisto1 = oldHisto;
0034   mynewHisto1 = newHisto;
0035   myte = te;
0036   Double_t * res;
0037 
0038   Double_t mypv = 0.;
0039   Double_t chi2;
0040   Int_t ndf, igood;
0041   if (myoldHisto1->GetEntries() == mynewHisto1->GetEntries()
0042        && myoldHisto1->GetSumOfWeights() ==0 && mynewHisto1->GetSumOfWeights() ==0) { 
0043     mypv = 1.;
0044   } else {
0045      mypv = myoldHisto1->Chi2TestX(mynewHisto1,chi2,ndf,igood,"UU NORM");
0046      if (ndf==0) mypv=1;
0047   }
0048 
0049   std::strstream buf;
0050   std::string value;
0051   buf<<"PV="<<mypv<<std::endl;
0052   buf>>value;
0053   
0054   myte->DrawTextNDC(0.2,0.7, value.c_str());
0055 
0056   std::cout << "[OVAL] " << myoldHisto1->GetName() << " PV= "<< mypv <<std::endl;
0057   return;
0058 
0059 }
0060 
0061 HistoCompare::PVCompute(TH2 * oldHisto , TH2 * newHisto , TText * te )
0062 {
0063 
0064   myoldHisto2 = oldHisto;
0065   mynewHisto2 = newHisto;
0066   myte = te;
0067 
0068   Double_t mypv = myoldHisto2->Chi2Test(mynewHisto2,"UU");
0069   std::strstream buf;
0070   std::string value;
0071   buf<<"PV="<<mypv<<std::endl;
0072   buf>>value;
0073   
0074   myte->DrawTextNDC(0.2,0.7, value.c_str());
0075 
0076   std::cout << "[OVAL] " << myoldHisto2->GetName() << " PV= " << mypv << std::endl;
0077   return;
0078 
0079 }
0080 
0081 
0082 HistoCompare::PVCompute(TProfile * oldHisto , TProfile * newHisto , TText * te )
0083 {
0084 
0085   myoldProfile = oldHisto;
0086   mynewProfile = newHisto;
0087   myte = te;
0088 
0089   Double_t mypv = myoldProfile->Chi2Test(mynewProfile,"UU");
0090   std::strstream buf;
0091   std::string value;
0092   buf<<"PV="<<mypv<<std::endl;
0093   buf>>value;
0094   
0095   myte->DrawTextNDC(0.2,0.7, value.c_str());
0096 
0097   std::cout << "[OVAL] " << myoldProfile->GetName() << " PV = " << mypv << std::endl;
0098   return;
0099 
0100 }