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_Pixels {
0005 
0006  public:
0007 
0008   HistoCompare_Pixels() 
0009   { 
0010     std::cout << "Initializing HistoCompare_Pixels... " << std::endl; 
0011     name = "none";
0012   } ;
0013 
0014   HistoCompare_Pixels(char* thisname = "none") : mypv(-9999.9)
0015   { 
0016     name = thisname;
0017     std::cout << "Initializing HistoCompare_Pixels... " << 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_Pixels()
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, const double x, const double y);
0042   void PVCompute(TH2 * oldHisto , TH2 * newHisto , TText * te, const double x, const double y);
0043   void PVCompute(TProfile * oldHisto , TProfile * newHisto , TText * te, const double x, const double y);
0044   void PVCompute(TH1 * oldHisto , TH1 * newHisto , TText * te);
0045   void PVCompute(TH2 * oldHisto , TH2 * newHisto , TText * te);
0046   void PVCompute(TProfile * oldHisto , TProfile * newHisto , TText * te);
0047 
0048   Double_t getPV() { return mypv; };
0049   void setName(char* s) { name = s; };
0050 
0051  private:
0052   
0053   Double_t mypv;
0054 
0055   TH1 * myoldHisto1;
0056   TH1 * mynewHisto1;
0057 
0058   TH2 * myoldHisto2;
0059   TH2 * mynewHisto2;
0060 
0061   TProfile * myoldProfile;
0062   TProfile * mynewProfile;
0063 
0064   TText * myte;
0065   
0066 
0067   
0068   char* name;
0069   
0070   fstream out_file;
0071 
0072 };
0073 
0074 HistoCompare_Pixels::PVCompute(TH1 * oldHisto , TH1 * newHisto , TText * te, const double x, const double y )
0075 {
0076 
0077   myoldHisto1 = oldHisto;
0078   mynewHisto1 = newHisto;
0079   myte = te;
0080 
0081 
0082   mypv = myoldHisto1->Chi2Test(mynewHisto1, "UUNORM");
0083   std::strstream buf;
0084   std::string value;
0085   buf<<"PV="<<mypv<<std::endl;
0086   buf>>value;
0087   
0088   myte->DrawTextNDC(x, y, value.c_str());
0089 
0090   std::cout << "[OVAL] " << myoldHisto1->GetName() << " PV = " << mypv << std::endl;
0091   
0092   if ( name != "none" )
0093     {
0094       if ( mypv < 0.01 )
0095     out_file << myoldHisto1->GetName() << "     pv = " << mypv << "      comparison fails !!!" << endl; 
0096       else
0097     out_file << myoldHisto1->GetName() << "     pv = " << mypv << endl;
0098     }
0099   
0100   return;
0101 
0102 }
0103 
0104 HistoCompare_Pixels::PVCompute(TH2 * oldHisto , TH2 * newHisto , TText * te, const double x, const double y)
0105 {
0106 
0107   myoldHisto2 = oldHisto;
0108   mynewHisto2 = newHisto;
0109   myte = te;
0110 
0111 
0112 
0113   mypv = myoldHisto2->Chi2Test(mynewHisto2,"UU");
0114   std::strstream buf;
0115   std::string value;
0116   buf<<"PV="<<mypv<<std::endl;
0117   buf>>value;
0118   
0119   myte->DrawTextNDC(x, y, value.c_str());
0120 
0121   std::cout << "[OVAL] " << myoldHisto2->GetName() << " PV = " << mypv << std::endl;
0122   
0123   if ( name != "none" )
0124     {
0125       if ( mypv < 0.01 )
0126     out_file << myoldHisto1->GetName() << "     pv = " << mypv << "      comparison fails !!!" << endl; 
0127       else
0128     out_file << myoldHisto1->GetName() << "     pv = " << mypv << endl;
0129     }
0130 
0131   return;
0132 }
0133 
0134 
0135 HistoCompare_Pixels::PVCompute(TProfile * oldHisto , TProfile * newHisto , TText * te, const double x, const double y )
0136 {
0137 
0138   myoldProfile = oldHisto;
0139   mynewProfile = newHisto;
0140   myte = te;
0141 
0142   
0143   mypv = myoldProfile->Chi2Test(mynewProfile,"WW");
0144   std::strstream buf;
0145   std::string value;
0146   buf<<"PV="<<mypv<<std::endl;
0147   buf>>value;
0148   
0149   myte->DrawTextNDC(x, y, value.c_str());
0150 
0151   std::cout << "[OVAL] " << myoldProfile->GetName() << " PV = " << mypv << std::endl;
0152   
0153   if ( name != "none" )
0154     {
0155       if ( mypv < 0.01 )
0156     out_file << myoldHisto1->GetName() << "     pv = " << mypv << "      comparison fails !!!" << endl; 
0157       else
0158     out_file << myoldHisto1->GetName() << "     pv = " << mypv << endl;
0159     }
0160   
0161   return;
0162 }
0163 
0164 HistoCompare_Pixels::PVCompute(TH1 * oldHisto , TH1 * newHisto , TText * te)
0165 {
0166 
0167   myoldHisto1 = oldHisto;
0168   mynewHisto1 = newHisto;
0169   myte = te;
0170 
0171 
0172   mypv = myoldHisto1->Chi2Test(mynewHisto1, "UUNORM");
0173   std::strstream buf;
0174   std::string value;
0175   buf<<"PV="<<mypv<<std::endl;
0176   buf>>value;
0177   
0178   myte->DrawTextNDC(0.6, 0.7, value.c_str());
0179 
0180   std::cout << "[OVAL] " << myoldHisto1->GetName() << " PV = " << mypv << std::endl;
0181   
0182   if ( name != "none" )
0183     {
0184       if ( mypv < 0.01 )
0185     out_file << myoldHisto1->GetName() << "     pv = " << mypv << "      comparison fails !!!" << endl; 
0186       else
0187     out_file << myoldHisto1->GetName() << "     pv = " << mypv << endl;
0188     }
0189   
0190   return;
0191 
0192 }
0193 
0194 HistoCompare_Pixels::PVCompute(TH2 * oldHisto , TH2 * newHisto , TText * te)
0195 {
0196 
0197   myoldHisto2 = oldHisto;
0198   mynewHisto2 = newHisto;
0199   myte = te;
0200 
0201 
0202 
0203   mypv = myoldHisto2->Chi2Test(mynewHisto2,"UU");
0204   std::strstream buf;
0205   std::string value;
0206   buf<<"PV="<<mypv<<std::endl;
0207   buf>>value;
0208   
0209   myte->DrawTextNDC(0.6, 0.7, value.c_str());
0210 
0211   std::cout << "[OVAL] " << myoldHisto2->GetName() << " PV = " << mypv << std::endl;
0212   
0213   if ( name != "none" )
0214     {
0215       if ( mypv < 0.01 )
0216     out_file << myoldHisto1->GetName() << "     pv = " << mypv << "      comparison fails !!!" << endl; 
0217       else
0218     out_file << myoldHisto1->GetName() << "     pv = " << mypv << endl;
0219     }
0220 
0221   return;
0222 }
0223 
0224 
0225 HistoCompare_Pixels::PVCompute(TProfile * oldHisto , TProfile * newHisto , TText * te)
0226 {
0227 
0228   myoldProfile = oldHisto;
0229   mynewProfile = newHisto;
0230   myte = te;
0231 
0232   
0233   mypv = myoldProfile->Chi2Test(mynewProfile,"WW");
0234   std::strstream buf;
0235   std::string value;
0236   buf<<"PV="<<mypv<<std::endl;
0237   buf>>value;
0238   
0239   myte->DrawTextNDC(0.6, 0.7, value.c_str());
0240 
0241   std::cout << "[OVAL] " << myoldProfile->GetName() << " PV = " << mypv << std::endl;
0242   
0243   if ( name != "none" )
0244     {
0245       if ( mypv < 0.01 )
0246     out_file << myoldHisto1->GetName() << "     pv = " << mypv << "      comparison fails !!!" << endl; 
0247       else
0248     out_file << myoldHisto1->GetName() << "     pv = " << mypv << endl;
0249     }
0250   
0251   return;
0252 }