CMS 3D CMS Logo

TestHistoMgr Class Reference

#include <Validation/Geometry/interface/TestHistoMgr.h>

List of all members.

Public Member Functions

bool addHisto1 (TH1F *ih)
bool addHisto2 (TH2F *ih)
bool addHistoProf1 (TProfile *ih)
bool addHistoProf2 (TProfile2D *ih)
TH1F * getHisto1 (int ih)
TH1F * getHisto1FromSecondFile (const char *hnam)
TH2F * getHisto2 (int ih)
TProfile * getHistoProf1 (int ih)
TProfile2D * getHistoProf2 (int ih)
void openSecondFile (const std::string &name)
void printComparisonResult (int ih)
void save (const std::string &name)
 TestHistoMgr ()
 ~TestHistoMgr ()

Private Attributes

TFile * theFileRef
mihp1 theHistoProfs1
mihp2 theHistoProfs2
mih1 theHistos1
mih2 theHistos2


Detailed Description

Definition at line 20 of file TestHistoMgr.h.


Constructor & Destructor Documentation

TestHistoMgr::TestHistoMgr (  ) 

Definition at line 18 of file TestHistoMgr.cc.

00019 {
00020   //  pi_aida::Proxy_Selector::setHistogramType(pi_aida::Histogram_Native);
00021 
00022 }

TestHistoMgr::~TestHistoMgr (  ) 

Definition at line 26 of file TestHistoMgr.cc.

References theHistoProfs1, theHistoProfs2, theHistos1, and theHistos2.

00027 { 
00028   mih1::const_iterator ite1;
00029   mih2::const_iterator ite2;
00030   mihp1::const_iterator itep1;
00031   mihp2::const_iterator itep2;
00032 
00033   for( ite1 = theHistos1.begin(); ite1 != theHistos1.end(); ite1++ ){ 
00034     delete (*ite1).second;
00035   }
00036   for( ite2 = theHistos2.begin(); ite2 != theHistos2.end(); ite2++ ){
00037     delete (*ite2).second;
00038   }
00039   for( itep1 = theHistoProfs1.begin(); itep1 != theHistoProfs1.end(); itep1++ ){
00040     delete (*itep1).second;
00041   }
00042   for( itep2 = theHistoProfs2.begin(); itep2 != theHistoProfs2.end(); itep2++ ){    delete (*itep2).second;
00043   }
00044  
00045 }


Member Function Documentation

bool TestHistoMgr::addHisto1 ( TH1F *  ih  ) 

Definition at line 150 of file TestHistoMgr.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), and theHistos1.

Referenced by MaterialBudgetEcalHistos::book(), MaterialBudgetHistos::book(), and MaterialBudgetTrackerHistos::book().

00151 {
00152   int ih = atoi(sih->GetName());
00153   theHistos1[ih] = sih;
00154   std::cout << " addHisto1 " << sih->GetName() << " = " << ih << std::endl;
00155 
00156   return true;
00157 }

bool TestHistoMgr::addHisto2 ( TH2F *  ih  ) 

Definition at line 159 of file TestHistoMgr.cc.

References theHistos2.

Referenced by MaterialBudgetEcalHistos::book(), MaterialBudgetHistos::book(), and MaterialBudgetTrackerHistos::book().

00160 {
00161   int ih = atoi(sih->GetName());
00162   theHistos2[ih] = sih;
00163 
00164   return true;
00165 }

bool TestHistoMgr::addHistoProf1 ( TProfile *  ih  ) 

Definition at line 168 of file TestHistoMgr.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), and theHistoProfs1.

Referenced by MaterialBudgetEcalHistos::book(), MaterialBudgetHistos::book(), and MaterialBudgetTrackerHistos::book().

00169 {
00170   int ih = atoi(sih->GetName());
00171   theHistoProfs1[ih] = sih;
00172   std::cout << " addProfHisto1 " << sih->GetName() << " = " << ih << std::endl;
00173 
00174   return true;
00175 }

bool TestHistoMgr::addHistoProf2 ( TProfile2D *  ih  ) 

Definition at line 177 of file TestHistoMgr.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), and theHistoProfs2.

Referenced by MaterialBudgetEcalHistos::book(), MaterialBudgetHistos::book(), and MaterialBudgetTrackerHistos::book().

00178 {
00179   int ih = atoi(sih->GetName());
00180   theHistoProfs2[ih] = sih;
00181   std::cout << " addProfHisto2 " << sih->GetName() << " = " << ih << std::endl;
00182 
00183   return true;
00184 }

TH1F * TestHistoMgr::getHisto1 ( int  ih  ) 

Definition at line 187 of file TestHistoMgr.cc.

References TestMuL1L2Filter_cff::cerr, lat::endl(), exception, and theHistos1.

Referenced by MaterialBudgetEcalHistos::fillEndTrack(), MaterialBudgetHistos::fillEndTrack(), and MaterialBudgetTrackerHistos::fillEndTrack().

00188 {
00189   TH1F* his = 0;
00190 
00191   mih1::const_iterator ite = theHistos1.find( ih );
00192   if( ite != theHistos1.end() ) {
00193     his = (*ite).second;
00194   } else {
00195     std::cerr << "!!!! FATAL ERROR Histogram does not exist " << ih << std::endl;
00196     std::exception();
00197   }
00198   return his;
00199 
00200 }

TH1F * TestHistoMgr::getHisto1FromSecondFile ( const char *  hnam  ) 

Definition at line 246 of file TestHistoMgr.cc.

References TestMuL1L2Filter_cff::cerr, lat::endl(), exception, and theFileRef.

Referenced by printComparisonResult().

00247 {
00248   if( !theFileRef ){
00249     std::cerr << "!!!! FATAL ERROR Second file not yet opened " << std::endl;
00250     std::exception();
00251   }
00252 
00253 
00254   TH1F* his = (TH1F*)(*theFileRef).Get(hnam);
00255   if( !his ) {
00256     std::cerr << "!!!! FATAL ERROR Histogram does not exist in second file " << hnam << std::endl;
00257     theFileRef->ls();
00258     std::exception();
00259     /*  } else {
00260         std::cout << " getHisto1FromSecondFile " << std::endl;
00261     std::cout << his->GetName() << std::endl;
00262     std::cout << his->title() << std::endl;
00263     std::cout << his->entries() << std::endl;
00264     std::cout << his->axis().bins() << std::endl;
00265     std::cout << " end getHisto1FromSecondFile " << std::endl;
00266     */
00267   }
00268 
00269   return his;
00270 
00271 }

TH2F * TestHistoMgr::getHisto2 ( int  ih  ) 

Definition at line 202 of file TestHistoMgr.cc.

References TestMuL1L2Filter_cff::cerr, lat::endl(), exception, and theHistos2.

Referenced by MaterialBudgetEcalHistos::fillEndTrack(), MaterialBudgetHistos::fillEndTrack(), MaterialBudgetTrackerHistos::fillEndTrack(), and MaterialBudgetTrackerHistos::hend().

00203 {
00204   TH2F* his = 0;
00205   mih2::const_iterator ite = theHistos2.find( ih );
00206   if( ite != theHistos2.end() ) {
00207     his = (*ite).second;
00208   } else {
00209     std::cerr << "!!!! FATAL ERROR Histogram does not exist " << ih << std::endl;
00210     std::exception();
00211   }
00212   return his;
00213 }

TProfile * TestHistoMgr::getHistoProf1 ( int  ih  ) 

Definition at line 215 of file TestHistoMgr.cc.

References TestMuL1L2Filter_cff::cerr, lat::endl(), exception, and theHistoProfs1.

Referenced by MaterialBudgetEcalHistos::fillEndTrack(), MaterialBudgetHistos::fillEndTrack(), and MaterialBudgetTrackerHistos::fillEndTrack().

00216 {
00217   TProfile* his = 0;
00218   mihp1::const_iterator ite = theHistoProfs1.find( ih );
00219   if( ite != theHistoProfs1.end() ) {
00220    his = (*ite).second;
00221   } else {
00222     std::cerr << "!!!! FATAL ERROR Profile Histogram 1D does not exist " << ih << std::endl;
00223     std::exception();
00224   }
00225 
00226   return his;
00227 
00228 }

TProfile2D * TestHistoMgr::getHistoProf2 ( int  ih  ) 

Definition at line 231 of file TestHistoMgr.cc.

References TestMuL1L2Filter_cff::cerr, lat::endl(), exception, and theHistoProfs2.

Referenced by MaterialBudgetEcalHistos::fillEndTrack(), MaterialBudgetHistos::fillEndTrack(), and MaterialBudgetTrackerHistos::fillEndTrack().

00232 {
00233   TProfile2D* his = 0;
00234   mihp2::const_iterator ite = theHistoProfs2.find( ih );
00235   if( ite != theHistoProfs2.end() ) {
00236    his = (*ite).second;
00237   } else {
00238     std::cerr << "!!!! FATAL ERROR Profile Histogram 2D does not exist " << ih << std::endl;
00239     std::exception();
00240   }
00241 
00242   return his;
00243 
00244 }

void TestHistoMgr::openSecondFile ( const std::string &  name  ) 

Definition at line 75 of file TestHistoMgr.cc.

References theFileRef.

00076 {
00077 
00078   theFileRef = new TFile(name.c_str());
00079 
00080   /*  std::vector<std::string> objectNames = theStoreIn->listObjectNames();
00081   std::vector<std::string> objectTypes = theStoreIn->listObjectTypes(); 
00082   uint siz = objectNames.size();
00083   for( uint ii = 0; ii < siz; ii++ ) {
00084     //    std::cout << " HISTOS IN FILE " << std::endl;
00085 
00086     //   std::cout << " HISTO: " << objectNames[ii] << " " << objectTypes[ii] << std::endl;
00087     }*/
00088 }

void TestHistoMgr::printComparisonResult ( int  ih  ) 

Definition at line 91 of file TestHistoMgr.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), getHisto1FromSecondFile(), and HLT_VtxMuL3::result.

00092 {
00093 
00094   /*
00095     TH1F* histo1 = getHisto1(ih);
00096   */
00097   /*  std::cout << ih << " Histo1 " << histo1;
00098       std::cout << histo1->GetName();
00099       std::cout << histo1->title();
00100       std::cout << histo1->entries();
00101       std::cout << histo1->axis().bins() << std::endl;
00102   */
00103   
00104 #ifdef StatTesting
00105   TH1F* histo2 = getHisto1FromSecondFile(histo1->GetName());
00106   
00107   StatisticsTesting::StatisticsComparator< StatisticsTesting::Chi2ComparisonAlgorithm > comparator;
00108 
00109 //  std::cout << " PrintComparisonResult " << histo1 << " " << histo2 << std::endl;
00110 #ifdef PI121
00111 qStatisticsTesting::ComparisonResult result = comparator.compare(*histo1, *histo2); 
00112 #else
00113   double result = comparator.compare(*histo1, *histo2); 
00114 #endif
00115 
00116   //  std::cout << " PrintComparisonResult " << histo1 << " " << histo2 << std::endl;
00117 
00118   //  double distance  = comparator.calculateDistance(histo1, histo2);
00119   // ---------------------------------------------------------
00120   // Do something with (e.g. print out) the result of the test 
00121   // ---------------------------------------------------------
00122   std::cout << " Result of the Chi2 Statistical Test: " << histo1->GetName() << std::endl
00123 #ifdef PI121
00124             << " distance = " << result.distance() << std::endl
00125             << " ndf = " << result.ndf() << std::endl
00126             << " p-value = " << result.quality() << std::endl
00127  #else
00128             << " p-value = " << result << std::endl
00129  #endif
00130             << "---------------- exampleReadXML  ENDS   ------------------ " 
00131             << std::endl;
00132 #ifdef PI121
00133   std::cout << "[OVAL]: HISTO_QUALITY " << histo1->GetName() <<" " << result.quality() << std::endl;
00134  #else 
00135   std::cout << "[OVAL]: HISTO_QUALITY " << histo1->GetName() <<" " << result << std::endl;
00136  #endif
00137   std::cout << std::endl << " mean= " << histo1->GetMean() << " " << histo1->GetName() << " " << histo1->GetTitle() << std::endl;
00138   std::cout << " rms= " << histo1->GetRMS() << " " << histo1->GetName() << " " << histo1->GetTitle() << std::endl;
00139 
00140 #else
00141   /*  std::cout << " LOG histo " << histo1->GetName() << " mean = " << histo1->mean() << " rms = " << histo1->rms() << std::endl;
00142   std::cout << " REF histo " << histo2->GetName() << " mean = " << histo2->mean() << " rms = " << histo2->rms() << std::endl;
00143   std::cout << " [OVAL]: " << histo1->GetName() << " DIFF_MEAN " << fabs(histo1->mean()-histo2->mean()) << " DIFF_RMS " << fabs(histo1->rms()-histo2->rms()) << std::endl;
00144   */
00145 
00146 #endif
00147 }

void TestHistoMgr::save ( const std::string &  name  ) 

Definition at line 49 of file TestHistoMgr.cc.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), theHistoProfs1, theHistoProfs2, theHistos1, and theHistos2.

Referenced by MaterialBudgetEcalHistos::hend(), MaterialBudgetHistos::hend(), and MaterialBudgetTrackerHistos::hend().

00050 {
00051 
00052   std::cout << "=== save user histos ===" << std::endl;
00053   TFile fout(name.c_str(),"recreate");
00054   // write out the histos
00055   mih1::const_iterator ite1;
00056   mih2::const_iterator ite2;
00057   mihp1::const_iterator itep1;
00058   mihp2::const_iterator itep2;
00059 
00060   for( ite1 = theHistos1.begin(); ite1 != theHistos1.end(); ite1++ ){
00061     ((*ite1).second)->Write();
00062   }
00063   for( ite2 = theHistos2.begin(); ite2 != theHistos2.end(); ite2++ ){
00064     ((*ite2).second)->Write();
00065   }
00066   for( itep1 = theHistoProfs1.begin(); itep1 != theHistoProfs1.end(); itep1++ ){
00067     ((*itep1).second)->Write();
00068   }
00069   for( itep2 = theHistoProfs2.begin(); itep2 != theHistoProfs2.end(); itep2++ ){
00070     ((*itep2).second)->Write();
00071   }
00072 
00073 }


Member Data Documentation

TFile* TestHistoMgr::theFileRef [private]

Definition at line 49 of file TestHistoMgr.h.

Referenced by getHisto1FromSecondFile(), and openSecondFile().

mihp1 TestHistoMgr::theHistoProfs1 [private]

Definition at line 46 of file TestHistoMgr.h.

Referenced by addHistoProf1(), getHistoProf1(), save(), and ~TestHistoMgr().

mihp2 TestHistoMgr::theHistoProfs2 [private]

Definition at line 47 of file TestHistoMgr.h.

Referenced by addHistoProf2(), getHistoProf2(), save(), and ~TestHistoMgr().

mih1 TestHistoMgr::theHistos1 [private]

Definition at line 44 of file TestHistoMgr.h.

Referenced by addHisto1(), getHisto1(), save(), and ~TestHistoMgr().

mih2 TestHistoMgr::theHistos2 [private]

Definition at line 45 of file TestHistoMgr.h.

Referenced by addHisto2(), getHisto2(), save(), and ~TestHistoMgr().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:33:18 2009 for CMSSW by  doxygen 1.5.4