CMS 3D CMS Logo

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

std::unique_ptr< TFile > theFileRef
 
mihp1 theHistoProfs1
 
mihp2 theHistoProfs2
 
mih1 theHistos1
 
mih2 theHistos2
 

Detailed Description

Definition at line 21 of file TestHistoMgr.h.

Constructor & Destructor Documentation

◆ TestHistoMgr()

TestHistoMgr::TestHistoMgr ( )

Definition at line 18 of file TestHistoMgr.cc.

18  {
19  // pi_aida::Proxy_Selector::setHistogramType(pi_aida::Histogram_Native);
20 }

◆ ~TestHistoMgr()

TestHistoMgr::~TestHistoMgr ( )

Definition at line 23 of file TestHistoMgr.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, theHistoProfs1, theHistoProfs2, theHistos1, and theHistos2.

23  {
24  for (auto& it : theHistos1) {
25  delete it.second;
26  }
27  for (auto& it : theHistos2) {
28  delete it.second;
29  }
30  for (auto& it : theHistoProfs1) {
31  delete it.second;
32  }
33  for (auto& it : theHistoProfs2) {
34  delete it.second;
35  }
36 }
mihp2 theHistoProfs2
Definition: TestHistoMgr.h:46
mihp1 theHistoProfs1
Definition: TestHistoMgr.h:45

Member Function Documentation

◆ addHisto1()

bool TestHistoMgr::addHisto1 ( TH1F *  ih)

Definition at line 108 of file TestHistoMgr.cc.

References theHistos1.

108  {
109  int ih = atoi(sih->GetName());
110  theHistos1[ih] = sih;
111  edm::LogInfo("MaterialBudget") << "TestHistoMgr: addHisto1: " << ih << " = " << sih->GetTitle();
112  return true;
113 }
Log< level::Info, false > LogInfo

◆ addHisto2()

bool TestHistoMgr::addHisto2 ( TH2F *  ih)

Definition at line 115 of file TestHistoMgr.cc.

References theHistos2.

115  {
116  int ih = atoi(sih->GetName());
117  theHistos2[ih] = sih;
118  return true;
119 }

◆ addHistoProf1()

bool TestHistoMgr::addHistoProf1 ( TProfile *  ih)

Definition at line 121 of file TestHistoMgr.cc.

References theHistoProfs1.

121  {
122  int ih = atoi(sih->GetName());
123  theHistoProfs1[ih] = sih;
124  edm::LogInfo("MaterialBudget") << "TestHistoMgr: addHistoProf1: " << ih << " = " << sih->GetTitle();
125  return true;
126 }
Log< level::Info, false > LogInfo
mihp1 theHistoProfs1
Definition: TestHistoMgr.h:45

◆ addHistoProf2()

bool TestHistoMgr::addHistoProf2 ( TProfile2D *  ih)

Definition at line 128 of file TestHistoMgr.cc.

References theHistoProfs2.

128  {
129  int ih = atoi(sih->GetName());
130  theHistoProfs2[ih] = sih;
131  edm::LogInfo("MaterialBudget") << "TestHistoMgr: addHistoProf2: " << ih << " = " << sih->GetTitle();
132  return true;
133 }
Log< level::Info, false > LogInfo
mihp2 theHistoProfs2
Definition: TestHistoMgr.h:46

◆ getHisto1()

TH1F * TestHistoMgr::getHisto1 ( int  ih)

Definition at line 135 of file TestHistoMgr.cc.

References cppFunctionSkipper::exception, and theHistos1.

135  {
136  TH1F* his = nullptr;
137 
138  mih1::const_iterator ite = theHistos1.find(ih);
139  if (ite != theHistos1.end()) {
140  his = (*ite).second;
141  } else {
142  edm::LogError("MaterialBudget") << "TestHistoMgr: getHisto1 Histogram does not exist " << ih;
143  std::exception();
144  }
145  return his;
146 }
Log< level::Error, false > LogError

◆ getHisto1FromSecondFile()

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

Definition at line 184 of file TestHistoMgr.cc.

References cppFunctionSkipper::exception, and theFileRef.

Referenced by printComparisonResult().

184  {
185  TH1F* his = new TH1F();
186  if (!theFileRef) {
187  edm::LogError("MaterialBudget") << "TestHistoMgr: Second file not yet opened ";
188  std::exception();
189  } else {
190  his = (TH1F*)(*theFileRef).Get(hnam);
191  }
192 
193  if (!his) {
194  edm::LogError("MaterialBudget") << "TestHistoMgr: FATAL ERROR Histogram does not exist in second file " << hnam;
195  theFileRef->ls();
196  std::exception();
197  }
198  return his;
199 }
Log< level::Error, false > LogError
std::unique_ptr< TFile > theFileRef
Definition: TestHistoMgr.h:48

◆ getHisto2()

TH2F * TestHistoMgr::getHisto2 ( int  ih)

Definition at line 148 of file TestHistoMgr.cc.

References cppFunctionSkipper::exception, and theHistos2.

148  {
149  TH2F* his = nullptr;
150  mih2::const_iterator ite = theHistos2.find(ih);
151  if (ite != theHistos2.end()) {
152  his = (*ite).second;
153  } else {
154  edm::LogError("MaterialBudget") << "TestHistoMgr: getHisto2 Histogram does not exist " << ih;
155  std::exception();
156  }
157  return his;
158 }
Log< level::Error, false > LogError

◆ getHistoProf1()

TProfile * TestHistoMgr::getHistoProf1 ( int  ih)

Definition at line 160 of file TestHistoMgr.cc.

References cppFunctionSkipper::exception, and theHistoProfs1.

160  {
161  TProfile* his = nullptr;
162  mihp1::const_iterator ite = theHistoProfs1.find(ih);
163  if (ite != theHistoProfs1.end()) {
164  his = (*ite).second;
165  } else {
166  edm::LogError("MaterialBudget") << "TestHistoMgr: Profile Histogram 1D does not exist " << ih;
167  std::exception();
168  }
169  return his;
170 }
Log< level::Error, false > LogError
mihp1 theHistoProfs1
Definition: TestHistoMgr.h:45

◆ getHistoProf2()

TProfile2D * TestHistoMgr::getHistoProf2 ( int  ih)

Definition at line 172 of file TestHistoMgr.cc.

References cppFunctionSkipper::exception, and theHistoProfs2.

172  {
173  TProfile2D* his = nullptr;
174  mihp2::const_iterator ite = theHistoProfs2.find(ih);
175  if (ite != theHistoProfs2.end()) {
176  his = (*ite).second;
177  } else {
178  edm::LogError("MaterialBudget") << "TestHistoMgr: Profile Histogram 2D does not exist " << ih;
179  std::exception();
180  }
181  return his;
182 }
Log< level::Error, false > LogError
mihp2 theHistoProfs2
Definition: TestHistoMgr.h:46

◆ openSecondFile()

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

Definition at line 64 of file TestHistoMgr.cc.

References mergeVDriftHistosByStation::name, and theFileRef.

64 { theFileRef = std::make_unique<TFile>(name.c_str()); }
std::unique_ptr< TFile > theFileRef
Definition: TestHistoMgr.h:48

◆ printComparisonResult()

void TestHistoMgr::printComparisonResult ( int  ih)

Definition at line 66 of file TestHistoMgr.cc.

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

66  {
67 #ifdef StatTesting
68 
69  TH1F* histo2 = getHisto1FromSecondFile(histo1->GetName());
70 
71  StatisticsTesting::StatisticsComparator<StatisticsTesting::Chi2ComparisonAlgorithm> comparator;
72 
73 #ifdef PI121
74 
75  qStatisticsTesting::ComparisonResult result = comparator.compare(*histo1, *histo2);
76 
77 #else
78 
79  double result = comparator.compare(*histo1, *histo2);
80 
81 #endif
82 
83  // ---------------------------------------------------------
84  // Do something with (e.g. print out) the result of the test
85  // ---------------------------------------------------------
86  edm::LogInfo << "TestHistoMgr: Result of the Chi2 Statistical Test: " << histo1->GetName();
87 #ifdef PI121
88  << " distance = " << result.distance() << std::endl
89  << " ndf = " << result.ndf() << std::endl
90  << " p-value = " << result.quality() << std::endl
91 #else
92  << " p-value = " << result << std::endl
93 #endif
94  << "---------------- exampleReadXML ENDS ------------------ " << std::endl;
95 #ifdef PI121
96  std::cout << "[OVAL]: HISTO_QUALITY " << histo1->GetName() << " " << result.quality() << std::endl;
97 #else
98  std::cout << "[OVAL]: HISTO_QUALITY " << histo1->GetName() << " " << result << std::endl;
99 #endif
100  std::cout << std::endl
101  << " mean= " << histo1->GetMean() << " " << histo1->GetName() << " " << histo1->GetTitle() << std::endl;
102  std::cout << " rms= " << histo1->GetRMS() << " " << histo1->GetName() << " " << histo1->GetTitle() << std::endl;
103 
104 #else
105 #endif
106 }
TH1F * getHisto1FromSecondFile(const char *hnam)

◆ save()

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

Definition at line 39 of file TestHistoMgr.cc.

References groupFilesInBlocks::fout, mergeVDriftHistosByStation::name, theHistoProfs1, theHistoProfs2, theHistos1, and theHistos2.

39  {
40  edm::LogInfo("MaterialBudget") << "TestHistoMgr: Save user histos";
41 
42  TFile fout(name.c_str(), "recreate");
43 
44  // write out the histos
45  mih1::const_iterator ite1;
46  mih2::const_iterator ite2;
47  mihp1::const_iterator itep1;
48  mihp2::const_iterator itep2;
49 
50  for (ite1 = theHistos1.begin(); ite1 != theHistos1.end(); ite1++) {
51  ((*ite1).second)->Write();
52  }
53  for (ite2 = theHistos2.begin(); ite2 != theHistos2.end(); ite2++) {
54  ((*ite2).second)->Write();
55  }
56  for (itep1 = theHistoProfs1.begin(); itep1 != theHistoProfs1.end(); itep1++) {
57  ((*itep1).second)->Write();
58  }
59  for (itep2 = theHistoProfs2.begin(); itep2 != theHistoProfs2.end(); itep2++) {
60  ((*itep2).second)->Write();
61  }
62 }
Log< level::Info, false > LogInfo
mihp2 theHistoProfs2
Definition: TestHistoMgr.h:46
mihp1 theHistoProfs1
Definition: TestHistoMgr.h:45

Member Data Documentation

◆ theFileRef

std::unique_ptr<TFile> TestHistoMgr::theFileRef
private

Definition at line 48 of file TestHistoMgr.h.

Referenced by getHisto1FromSecondFile(), and openSecondFile().

◆ theHistoProfs1

mihp1 TestHistoMgr::theHistoProfs1
private

Definition at line 45 of file TestHistoMgr.h.

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

◆ theHistoProfs2

mihp2 TestHistoMgr::theHistoProfs2
private

Definition at line 46 of file TestHistoMgr.h.

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

◆ theHistos1

mih1 TestHistoMgr::theHistos1
private

Definition at line 43 of file TestHistoMgr.h.

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

◆ theHistos2

mih2 TestHistoMgr::theHistos2
private

Definition at line 44 of file TestHistoMgr.h.

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