11 #include "TPostScript.h" 12 #include "TPaveText.h" 17 std::cout <<
"getAllKeys-> " << fDir->GetName() <<
", " << fClassName << std::endl;
19 std::vector<std::string>
result;
20 TIter
next (fDir->GetListOfKeys ());
21 for (TKey*
key = 0; (
key = (TKey *)
next());) {
22 std::cout <<
"key from list: " <<
key->GetName() <<
'/' <<
key->GetClassName () << std::endl;
23 if (fClassName ==
key->GetClassName ()) {
31 std::cout <<
"getAllObjects-> " << fDir->GetName() <<
", " << fClassName << std::endl;
33 std::vector<std::string>
result;
34 TIter
next (fDir->GetList ());
35 for (TObject*
obj = 0; (
obj = (TObject *)
next());) {
36 std::cout <<
"name from list: " <<
obj->GetName() <<
'/' <<
obj->ClassName () << std::endl;
37 if (fClassName ==
obj->ClassName ()) {
44 TObject*
getObject (TDirectory* fDir,
const std::vector <std::string>& fObjectName) {
46 TDirectory*
dir = fDir;
47 for (
unsigned i = 0;
i < fObjectName.size (); ++
i) {
48 dir->GetObject (fObjectName[
i].c_str(),
result);
50 if (
i < fObjectName.size () - 1) {
56 std::cerr <<
"getObject-> Can not find (sub)dir/object " << fObjectName[
i] <<
" in directory " <<
dir->GetName () << std::endl;
64 double pv = fHist->KolmogorovTest (fRefHist,
"OU");
66 TPad pad (
"pad",
"pad", 0, 0, 1, 0.9, 0);
71 sprintf (
buf,
"%s: Kolmogorov Test PV = %5.3f", fPrefix.c_str(),
pv);
72 TPaveText
title (0.3,0.85,0.95, 0.99,
buf);
73 title.SetFillColor(
pv > 0.01 ? 3 : 2);
75 sprintf (
buf,
"Kolmogorov Test PV = %6.4f",
pv);
83 fHist->Scale (fRefHist->GetSumOfWeights () / fHist->GetSumOfWeights ());
85 fHist->SetMarkerStyle (21);
86 fHist->SetMarkerSize (0.7);
87 fRefHist->SetLineColor (2);
88 fRefHist->SetFillColor (42);
90 int blank =
name.rfind (
' ');
91 if (blank >= 0)
name.erase (0, blank+1);
92 fHist->SetXTitle (
name.c_str());
96 fHist->Draw (
"e1p,same");
112 TFile* refFile = TFile::Open (
refFileName.c_str());
114 std::cout <<
"ls for the file:" << std::endl;
118 for (
unsigned idir = 0; idir < dirName1.size(); idir++) {
119 TDirectory*
dir1 = 0;
122 std::vector<std::string> dirName2 =
getAllKeys (
dir1,
"TDirectory");
123 for (
unsigned idir2 = 0; idir2 < dirName1.size(); ++idir2) {
124 TDirectory*
dir2 = 0;
125 dir1->GetObject (dirName2[idir2].c_str(),
dir2);
129 gStyle->SetOptStat (kFALSE);
130 TCanvas
canvas (
"Jets",
"Jets",800,600);
131 TPostScript ps ((dirName2[idir2]+
std::string(
".ps")).c_str(), -112);
132 ps.Range(29.7 , 21.0);
133 for (
unsigned ihist = 0; ihist < histKeys.size (); ++ihist) {
135 dir2->GetObject (histKeys[ihist].c_str(),
hist);
137 std::vector<std::string> histPathName;
138 histPathName.push_back (dirName1[idir]);
139 histPathName.push_back (dirName2[idir2]);
140 histPathName.push_back (histKeys[ihist]);
141 TH1* refhist = (TH1*)
getObject (refFile, histPathName);
145 std::cout <<
"pv for hist " << dirName1[idir] <<
'/' << dirName2[idir2] <<
'/' << histKeys[ihist] <<
" is " <<
pv << std::endl;
150 std::cerr <<
"Can not get histogram " << histKeys[ihist] << std::endl;
157 std::cerr <<
"Can not find dir1: " << dirName1[idir] << std::endl;
TObject * getObject(TDirectory *fDir, const std::vector< std::string > &fObjectName)
std::vector< std::string > getAllObjects(const TDirectory *fDir, const std::string &fClassName)
int main(int argn, char *argv [])
std::vector< std::string > getAllKeys(const TDirectory *fDir, const std::string &fClassName)
double makeGifHists(TH1 *fHist, TH1 *fRefHist, TCanvas *fCanvas, const std::string &fPrefix="")