CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
TestHistoMgr Class Reference

#include <TestHistoMgr.h>

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 19 of file TestHistoMgr.cc.

20 {
21  // pi_aida::Proxy_Selector::setHistogramType(pi_aida::Histogram_Native);
22 
23 }
TestHistoMgr::~TestHistoMgr ( )

Definition at line 27 of file TestHistoMgr.cc.

References theHistoProfs1, theHistoProfs2, theHistos1, and theHistos2.

28 {
29  mih1::const_iterator ite1;
30  mih2::const_iterator ite2;
31  mihp1::const_iterator itep1;
32  mihp2::const_iterator itep2;
33 
34  for( ite1 = theHistos1.begin(); ite1 != theHistos1.end(); ite1++ ){
35  delete (*ite1).second;
36  }
37  for( ite2 = theHistos2.begin(); ite2 != theHistos2.end(); ite2++ ){
38  delete (*ite2).second;
39  }
40  for( itep1 = theHistoProfs1.begin(); itep1 != theHistoProfs1.end(); itep1++ ){
41  delete (*itep1).second;
42  }
43  for( itep2 = theHistoProfs2.begin(); itep2 != theHistoProfs2.end(); itep2++ ){ delete (*itep2).second;
44  }
45 
46 }
mihp2 theHistoProfs2
Definition: TestHistoMgr.h:47
mihp1 theHistoProfs1
Definition: TestHistoMgr.h:46

Member Function Documentation

bool TestHistoMgr::addHisto1 ( TH1F *  ih)

Definition at line 151 of file TestHistoMgr.cc.

References gather_cfg::cout, and theHistos1.

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

152 {
153  int ih = atoi(sih->GetName());
154  theHistos1[ih] = sih;
155  std::cout << " addHisto1 " << sih->GetName() << " = " << ih << std::endl;
156 
157  return true;
158 }
tuple cout
Definition: gather_cfg.py:41
bool TestHistoMgr::addHisto2 ( TH2F *  ih)

Definition at line 160 of file TestHistoMgr.cc.

References theHistos2.

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

161 {
162  int ih = atoi(sih->GetName());
163  theHistos2[ih] = sih;
164 
165  return true;
166 }
bool TestHistoMgr::addHistoProf1 ( TProfile *  ih)

Definition at line 169 of file TestHistoMgr.cc.

References gather_cfg::cout, and theHistoProfs1.

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

170 {
171  int ih = atoi(sih->GetName());
172  theHistoProfs1[ih] = sih;
173  std::cout << " addProfHisto1 " << sih->GetName() << " = " << ih << std::endl;
174 
175  return true;
176 }
tuple cout
Definition: gather_cfg.py:41
mihp1 theHistoProfs1
Definition: TestHistoMgr.h:46
bool TestHistoMgr::addHistoProf2 ( TProfile2D *  ih)

Definition at line 178 of file TestHistoMgr.cc.

References gather_cfg::cout, and theHistoProfs2.

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

179 {
180  int ih = atoi(sih->GetName());
181  theHistoProfs2[ih] = sih;
182  std::cout << " addProfHisto2 " << sih->GetName() << " = " << ih << std::endl;
183 
184  return true;
185 }
mihp2 theHistoProfs2
Definition: TestHistoMgr.h:47
tuple cout
Definition: gather_cfg.py:41
TH1F * TestHistoMgr::getHisto1 ( int  ih)

Definition at line 188 of file TestHistoMgr.cc.

References ExpressReco_HICollisions_FallBack::cerr, cmsCodeRules.cppFunctionSkipper::exception, and theHistos1.

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

189 {
190  TH1F* his = 0;
191 
192  mih1::const_iterator ite = theHistos1.find( ih );
193  if( ite != theHistos1.end() ) {
194  his = (*ite).second;
195  } else {
196  std::cerr << "!!!! FATAL ERROR Histogram does not exist " << ih << std::endl;
197  std::exception();
198  }
199  return his;
200 
201 }
TH1F * TestHistoMgr::getHisto1FromSecondFile ( const char *  hnam)

Definition at line 247 of file TestHistoMgr.cc.

References ExpressReco_HICollisions_FallBack::cerr, cmsCodeRules.cppFunctionSkipper::exception, and theFileRef.

Referenced by printComparisonResult().

248 {
249  if( !theFileRef ){
250  std::cerr << "!!!! FATAL ERROR Second file not yet opened " << std::endl;
251  std::exception();
252  }
253 
254 
255  TH1F* his = (TH1F*)(*theFileRef).Get(hnam);
256  if( !his ) {
257  std::cerr << "!!!! FATAL ERROR Histogram does not exist in second file " << hnam << std::endl;
258  theFileRef->ls();
259  std::exception();
260  /* } else {
261  std::cout << " getHisto1FromSecondFile " << std::endl;
262  std::cout << his->GetName() << std::endl;
263  std::cout << his->title() << std::endl;
264  std::cout << his->entries() << std::endl;
265  std::cout << his->axis().bins() << std::endl;
266  std::cout << " end getHisto1FromSecondFile " << std::endl;
267  */
268  }
269 
270  return his;
271 
272 }
TFile * theFileRef
Definition: TestHistoMgr.h:49
TH2F * TestHistoMgr::getHisto2 ( int  ih)

Definition at line 203 of file TestHistoMgr.cc.

References ExpressReco_HICollisions_FallBack::cerr, cmsCodeRules.cppFunctionSkipper::exception, and theHistos2.

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

204 {
205  TH2F* his = 0;
206  mih2::const_iterator ite = theHistos2.find( ih );
207  if( ite != theHistos2.end() ) {
208  his = (*ite).second;
209  } else {
210  std::cerr << "!!!! FATAL ERROR Histogram does not exist " << ih << std::endl;
211  std::exception();
212  }
213  return his;
214 }
TProfile * TestHistoMgr::getHistoProf1 ( int  ih)

Definition at line 216 of file TestHistoMgr.cc.

References ExpressReco_HICollisions_FallBack::cerr, cmsCodeRules.cppFunctionSkipper::exception, and theHistoProfs1.

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

217 {
218  TProfile* his = 0;
219  mihp1::const_iterator ite = theHistoProfs1.find( ih );
220  if( ite != theHistoProfs1.end() ) {
221  his = (*ite).second;
222  } else {
223  std::cerr << "!!!! FATAL ERROR Profile Histogram 1D does not exist " << ih << std::endl;
224  std::exception();
225  }
226 
227  return his;
228 
229 }
mihp1 theHistoProfs1
Definition: TestHistoMgr.h:46
TProfile2D * TestHistoMgr::getHistoProf2 ( int  ih)

Definition at line 232 of file TestHistoMgr.cc.

References ExpressReco_HICollisions_FallBack::cerr, cmsCodeRules.cppFunctionSkipper::exception, and theHistoProfs2.

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

233 {
234  TProfile2D* his = 0;
235  mihp2::const_iterator ite = theHistoProfs2.find( ih );
236  if( ite != theHistoProfs2.end() ) {
237  his = (*ite).second;
238  } else {
239  std::cerr << "!!!! FATAL ERROR Profile Histogram 2D does not exist " << ih << std::endl;
240  std::exception();
241  }
242 
243  return his;
244 
245 }
mihp2 theHistoProfs2
Definition: TestHistoMgr.h:47
void TestHistoMgr::openSecondFile ( const std::string &  name)

Definition at line 76 of file TestHistoMgr.cc.

References theFileRef.

77 {
78 
79  theFileRef = new TFile(name.c_str());
80 
81  /* std::vector<std::string> objectNames = theStoreIn->listObjectNames();
82  std::vector<std::string> objectTypes = theStoreIn->listObjectTypes();
83  unsigned int siz = objectNames.size();
84  for( unsigned int ii = 0; ii < siz; ii++ ) {
85  // std::cout << " HISTOS IN FILE " << std::endl;
86 
87  // std::cout << " HISTO: " << objectNames[ii] << " " << objectTypes[ii] << std::endl;
88  }*/
89 }
TFile * theFileRef
Definition: TestHistoMgr.h:49
void TestHistoMgr::printComparisonResult ( int  ih)

Definition at line 92 of file TestHistoMgr.cc.

References gather_cfg::cout, getHisto1FromSecondFile(), and query::result.

93 {
94 
95  /*
96  TH1F* histo1 = getHisto1(ih);
97  */
98  /* std::cout << ih << " Histo1 " << histo1;
99  std::cout << histo1->GetName();
100  std::cout << histo1->title();
101  std::cout << histo1->entries();
102  std::cout << histo1->axis().bins() << std::endl;
103  */
104 
105 #ifdef StatTesting
106  TH1F* histo2 = getHisto1FromSecondFile(histo1->GetName());
107 
108  StatisticsTesting::StatisticsComparator< StatisticsTesting::Chi2ComparisonAlgorithm > comparator;
109 
110 // std::cout << " PrintComparisonResult " << histo1 << " " << histo2 << std::endl;
111 #ifdef PI121
112 qStatisticsTesting::ComparisonResult result = comparator.compare(*histo1, *histo2);
113 #else
114  double result = comparator.compare(*histo1, *histo2);
115 #endif
116 
117  // std::cout << " PrintComparisonResult " << histo1 << " " << histo2 << std::endl;
118 
119  // double distance = comparator.calculateDistance(histo1, histo2);
120  // ---------------------------------------------------------
121  // Do something with (e.g. print out) the result of the test
122  // ---------------------------------------------------------
123  std::cout << " Result of the Chi2 Statistical Test: " << histo1->GetName() << std::endl
124 #ifdef PI121
125  << " distance = " << result.distance() << std::endl
126  << " ndf = " << result.ndf() << std::endl
127  << " p-value = " << result.quality() << std::endl
128  #else
129  << " p-value = " << result << std::endl
130  #endif
131  << "---------------- exampleReadXML ENDS ------------------ "
132  << std::endl;
133 #ifdef PI121
134  std::cout << "[OVAL]: HISTO_QUALITY " << histo1->GetName() <<" " << result.quality() << std::endl;
135  #else
136  std::cout << "[OVAL]: HISTO_QUALITY " << histo1->GetName() <<" " << result << std::endl;
137  #endif
138  std::cout << std::endl << " mean= " << histo1->GetMean() << " " << histo1->GetName() << " " << histo1->GetTitle() << std::endl;
139  std::cout << " rms= " << histo1->GetRMS() << " " << histo1->GetName() << " " << histo1->GetTitle() << std::endl;
140 
141 #else
142  /* std::cout << " LOG histo " << histo1->GetName() << " mean = " << histo1->mean() << " rms = " << histo1->rms() << std::endl;
143  std::cout << " REF histo " << histo2->GetName() << " mean = " << histo2->mean() << " rms = " << histo2->rms() << std::endl;
144  std::cout << " [OVAL]: " << histo1->GetName() << " DIFF_MEAN " << fabs(histo1->mean()-histo2->mean()) << " DIFF_RMS " << fabs(histo1->rms()-histo2->rms()) << std::endl;
145  */
146 
147 #endif
148 }
tuple result
Definition: query.py:137
TH1F * getHisto1FromSecondFile(const char *hnam)
tuple cout
Definition: gather_cfg.py:41
void TestHistoMgr::save ( const std::string &  name)

Definition at line 50 of file TestHistoMgr.cc.

References gather_cfg::cout, makeHLTPrescaleTable::fout, theHistoProfs1, theHistoProfs2, theHistos1, and theHistos2.

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

51 {
52 
53  std::cout << "=== save user histos ===" << std::endl;
54  TFile fout(name.c_str(),"recreate");
55  // write out the histos
56  mih1::const_iterator ite1;
57  mih2::const_iterator ite2;
58  mihp1::const_iterator itep1;
59  mihp2::const_iterator itep2;
60 
61  for( ite1 = theHistos1.begin(); ite1 != theHistos1.end(); ite1++ ){
62  ((*ite1).second)->Write();
63  }
64  for( ite2 = theHistos2.begin(); ite2 != theHistos2.end(); ite2++ ){
65  ((*ite2).second)->Write();
66  }
67  for( itep1 = theHistoProfs1.begin(); itep1 != theHistoProfs1.end(); itep1++ ){
68  ((*itep1).second)->Write();
69  }
70  for( itep2 = theHistoProfs2.begin(); itep2 != theHistoProfs2.end(); itep2++ ){
71  ((*itep2).second)->Write();
72  }
73 
74 }
mihp2 theHistoProfs2
Definition: TestHistoMgr.h:47
tuple cout
Definition: gather_cfg.py:41
mihp1 theHistoProfs1
Definition: TestHistoMgr.h:46

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().