#include "readfile.h"
#include "comphists.h"
#include "CxxUtils/checker_macros.h"
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <sys/stat.h>
Go to the source code of this file.
|
void | classifyByKey (const KeyToHistMap &hists1, KeyToHistMap &hists2, std::vector< std::pair< std::string, TH1 * > > &histsOnlyIn1, std::vector< std::pair< std::string, TH1 * > > &histsOnlyIn2, std::vector< std::pair< std::string, std::pair< TH1 *, TH1 * > > > &histsInBoth) |
|
void usage | ATLAS_NOT_THREAD_SAFE (char **argv, int exitcode) |
|
bool | fileExists (const std::string &filename) |
|
int main | ATLAS_NOT_THREAD_SAFE (int argc, char **argv) |
|
◆ ATLAS_NOT_THREAD_SAFE() [1/2]
void usage ATLAS_NOT_THREAD_SAFE |
( |
char ** |
argv, |
|
|
int |
exitcode |
|
) |
| |
Definition at line 34 of file main_comphistfiles.cxx.
35 std::cout <<
"Usage:"<<std::endl;
36 std::cout <<
""<<std::endl;
37 std::cout <<
argv[0]<<
" [flags] histfile1.root histfile2.root [outputfile.root]"<<std::endl;
38 std::cout <<
""<<std::endl;
39 std::cout <<
"Program which checks for consistency (up to floating point accuracy)"<<std::endl;
40 std::cout <<
"between ROOT histograms found in two ROOT files and outputs a small report."<<std::endl;
41 std::cout <<
""<<std::endl;
42 std::cout <<
"Supplying an outputfile.root argument will result in copies of inconsistent"<<std::endl;
43 std::cout <<
"histograms written to this file."<<std::endl;
44 std::cout <<
""<<std::endl;
45 std::cout <<
"Unless -h/--help is requested, exit-code 0 implies complete consistency."<<std::endl;
46 std::cout <<
""<<std::endl;
47 std::cout <<
"Optional flags:"<<std::endl;
48 std::cout <<
" -h, --help : This help"<<std::endl;
49 std::cout <<
" -v, --verbose : Verbose output"<<std::endl;
50 std::cout <<
" --silentnan : Suppress warnings regarding NaN values (when in both hists compared)."<<std::endl;
51 std::cout <<
" --ignore-stylevars : Ignore certain unsupported style-vars (ndivisions, ticklength, ..)."<<std::endl;
52 std::cout <<
" --ignore-sumw2-nonalloc : Ignore case where one histogram has not allocated a sumw2 (error) array."<<std::endl;
53 std::cout <<
""<<std::endl;
◆ ATLAS_NOT_THREAD_SAFE() [2/2]
int main ATLAS_NOT_THREAD_SAFE |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 63 of file main_comphistfiles.cxx.
66 std::vector<std::string> rootfiles;
72 if (
arg==
"-h"||
arg==
"--help")
74 if (
arg==
"-v"||
arg==
"--verbose") {
80 if (
arg==
"--silentnan") {
86 if (
arg==
"--ignore-stylevars") {
92 if (
arg==
"--ignore-sumw2-nonalloc") {
98 if (
arg.empty()||
arg[0]==
'-')
100 rootfiles.push_back(
arg);
102 if (rootfiles.size()<2||rootfiles.size()>3)
104 const std::string file1 = rootfiles.at(0);
105 const std::string file2 = rootfiles.at(1);
106 const std::string
outputfile = (rootfiles.size()>2 ? rootfiles.at(2):
"");
108 std::cout<<
"Error: File "<<file1<<
" not found."<<std::endl;
112 std::cout<<
"Error: File "<<file2<<
" not found."<<std::endl;
116 std::cout<<
"Error: File "<<
outputfile<<
" already exists."<<std::endl;
130 std::cout<<
"Problems getting histograms from file "<<file1<<std::endl;
134 std::cout<<
"Problems getting histograms from file "<<file2<<std::endl;
137 std::vector<std::pair<std::string,TH1*> > histsOnlyIn1;
138 std::vector<std::pair<std::string,TH1*> > histsOnlyIn2;
139 std::vector<std::pair<std::string,std::pair<TH1*,TH1*> > > histsInBoth;
142 histsOnlyIn1, histsOnlyIn2, histsInBoth );
144 if (!histsOnlyIn1.empty()) {
146 for (
unsigned i=0;
i<histsOnlyIn1.size();++
i)
147 std::cout<<
"Only found in "<<file1<<
": "<<histsOnlyIn1.at(
i).first<<std::endl;
150 if (!histsOnlyIn2.empty()) {
152 for (
unsigned i=0;
i<histsOnlyIn2.size();++
i)
153 std::cout<<
"Only found in "<<file2<<
": "<<histsOnlyIn2.at(
i).first<<std::endl;
157 unsigned nincompat(0);
158 std::vector<TH1*> incompathists;
159 if (!histsInBoth.empty()) {
160 for (
unsigned i=0;
i<histsInBoth.size();++
i) {
162 std::cout<<
"Found in both files: "<<histsInBoth.at(
i).first<<std::endl;
163 if (!
histsCompatible(histsInBoth.at(
i).second.first,histsInBoth.at(
i).second.second)) {
164 std::cout<<
" => Incompatibilities detected in "<<histsInBoth.at(
i).first<<std::endl;
165 incompathists.push_back(histsInBoth.at(
i).second.first);
166 incompathists.push_back(histsInBoth.at(
i).second.second);
173 std::cout<<
"============== Summary =============="<<std::endl;
174 if (!histsOnlyIn1.empty())
175 std::cout<<histsOnlyIn1.size()<<
" histograms only found in "<<file1<<std::endl;
176 if (!histsOnlyIn2.empty())
177 std::cout<<histsOnlyIn2.size()<<
" histograms only found in "<<file2<<std::endl;
178 if (histsInBoth.size()-nincompat>0)
179 std::cout<<histsInBoth.size()-nincompat<<
" common and compatible histograms found in both files"<<std::endl;
181 std::cout<<nincompat<<
" common but incompatible histograms found in both files"<<std::endl;
183 std::cout<<
"====================================="<<std::endl;
186 std::cout<<
"Writing copies of the "<<nincompat<<
" (both versions) incompatible histograms to file "<<
outputfile<<std::endl;
188 if (!
file->IsOpen()) {
189 std::cout<<
"ERROR: Problems opening file"<<std::endl;
192 for (
unsigned i=0;
i<incompathists.size();++
i)
193 incompathists.at(
i)->Write();
196 std::cout<<
"Done writing file "<<
outputfile<<std::endl;
199 return allok ? 0 : 1;
◆ classifyByKey()
void classifyByKey |
( |
const KeyToHistMap & |
hists1, |
|
|
KeyToHistMap & |
hists2, |
|
|
std::vector< std::pair< std::string, TH1 * > > & |
histsOnlyIn1, |
|
|
std::vector< std::pair< std::string, TH1 * > > & |
histsOnlyIn2, |
|
|
std::vector< std::pair< std::string, std::pair< TH1 *, TH1 * > > > & |
histsInBoth |
|
) |
| |
Definition at line 13 of file main_comphistfiles.cxx.
18 KeyToHistMap::const_iterator
it1(hists1.begin()), it1E(hists1.end());
21 if (it2!=hists2.end()) {
22 histsInBoth.push_back(std::make_pair(
it1->first,std::pair<TH1*,TH1*>(
it1->second,it2->second)));
25 histsOnlyIn1.push_back(*
it1);
28 KeyToHistMap::const_iterator it2(hists2.begin()), it2E(hists2.end());
29 histsOnlyIn2.reserve(hists2.size());
30 for (;it2!=it2E;++it2)
31 histsOnlyIn2.push_back(*it2);
◆ fileExists()
bool fileExists |
( |
const std::string & |
filename | ) |
|
void classifyByKey(const KeyToHistMap &hists1, KeyToHistMap &hists2, std::vector< std::pair< std::string, TH1 * > > &histsOnlyIn1, std::vector< std::pair< std::string, TH1 * > > &histsOnlyIn2, std::vector< std::pair< std::string, std::pair< TH1 *, TH1 * > > > &histsInBoth)
bool fileExists(const std::string &filename)