Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:33:30

0001 #include <iostream.h>
0002 #include "TFile.h"
0003 
0004 class HistoCompare_Tracks {
0005 
0006  public:
0007 
0008   HistoCompare_Tracks() 
0009   { 
0010     std::cout << "Initializing HistoCompare_Tracks... " << std::endl; 
0011     name = "none";
0012   } ;
0013 
0014   HistoCompare_Tracks(char* thisname = "none") : mypv(-9999.9)
0015   { 
0016     name = thisname;
0017     std::cout << "Initializing HistoCompare_Tracks... " << 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_Tracks()
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,char * option = "");
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_Tracks::PVCompute(TH1 * oldHisto , TH1 * newHisto , TText * te,char * option)
0070 {
0071 
0072   myoldHisto1 = oldHisto;
0073   mynewHisto1 = newHisto;
0074   myte = te;
0075 
0076   //mypv = myoldHisto1->Chi2Test(mynewHisto1,option);
0077   mypv = myoldHisto1->KolmogorovTest(mynewHisto1);
0078   std::strstream buf;
0079   std::string value;
0080   buf<<"PV="<<mypv<<std::endl;
0081   buf>>value;
0082   
0083   myte->DrawTextNDC(0.6,0.7, value.c_str());
0084 
0085   std::cout << "[OVAL] " << myoldHisto1->GetName() << " PV = " << mypv << std::endl;
0086   
0087   if ( name != "none" )
0088     {
0089       if ( mypv < 0.01 )
0090     out_file << myoldHisto1->GetName() << "     pv = " << mypv << "      comparison fails !!!" << endl; 
0091       else
0092     out_file << myoldHisto1->GetName() << "     pv = " << mypv << endl;
0093     }
0094   
0095   return;
0096 }
0097