-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompareHists.C
74 lines (65 loc) · 2.03 KB
/
CompareHists.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//File: CompareHists.C
//Info: Quick macro to load to compare any two MnvH1D's passed by pointer.
//Author: David Last [email protected]/[email protected]
//C++ includes
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <unordered_map>
#include <bitset>
#include <time.h>
#include <sys/stat.h>
//ROOT includes
#include "TInterpreter.h"
#include "TROOT.h"
#include "TH1F.h"
#include "TH2F.h"
#include "THStack.h"
#include "TFile.h"
#include "TTree.h"
#include "TKey.h"
#include "TDirectory.h"
#include "TSystemDirectory.h"
#include "TCanvas.h"
#include "TStyle.h"
#include "TString.h"
#include "TLorentzVector.h"
#include "TVector3.h"
#include "TLegend.h"
#include "TMath.h"
#include "TColor.h"
//PlotUtils includes??? Trying anything at this point...
#include "PlotUtils/MnvH1D.h"
using namespace std;
using namespace PlotUtils;
void CompareHists(const MnvH1D* m1, const MnvH1D* m2, double tolerance) {
cout << "First check: See if they have the same number of bins" << endl;
if (m1->GetNbinsX() != m2->GetNbinsX()){
cout << "Not same bins. Not comparing." << endl;
return;
}
cout << "Second check: See if all of the contents and total errors are within the tolerance." << endl;
/*
TH1D* h1 = (TH1D*)(m1->GetCVHistoWithError().Clone());
TH1D* h2 = (TH1D*)(m2->GetCVHistoWithError().Clone());
*/
int nBins = m1->GetNbinsX();
for (int iBin=0; iBin <= nBins+1; ++iBin){
if (abs(m1->GetBinContent(iBin) - m2->GetBinContent(iBin)) > tolerance){
cout << "Bin: " << iBin << " has content: " << m1->GetBinContent(iBin) << " in h1, and content: " << m2->GetBinContent(iBin) << " in h2." << endl;
return;
}
if (abs(m1->GetBinError(iBin) - m2->GetBinError(iBin)) > tolerance){
cout << "Bin: " << iBin << " has error: " << m1->GetBinError(iBin) << " in h1, and error: " << m2->GetBinError(iBin) << " in h2." << endl;
return;
}
}
cout << "Seemingly the same." << endl;
return;
}