Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
EstimateSummary.cxx
Go to the documentation of this file.
1// @(#)root/roostats:$Id: cranmer $
2// Author: Kyle Cranmer, Akira Shibata
3/*************************************************************************
4 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11////////////////////////////////////////////////////////////////////////////////
12
13/** \class RooStats::HistFactory::EstimateSummary
14 * \ingroup HistFactory
15 */
16
17#include <algorithm>
19
21
22using namespace std;
23
24namespace RooStats {
25 namespace HistFactory {
26
28 nominal=0;
29
30 normName="Lumi";
31 IncludeStatError = false;
34 relStatError=NULL;
36 }
38
39 void EstimateSummary::Print(const char * /*opt*/) const {
40 cout << "EstimateSummary (name = " << name << " empty = " << name.empty() << ")"<< endl;
41 cout << " TObj name = " << this->GetName() << endl;
42 cout << " Channel = " << channel << endl;
43 cout << " NormName = " << normName << endl;
44 cout << " Nominal ptr = " << nominal << endl;
45 if (nominal) cout << " Nominal hist name = " << nominal->GetName() << endl;
46 cout << " Number of hist variations = " << systSourceForHist.size()
47 << " " << lowHists.size() << " "
48 << " " << highHists.size() << endl;
49 cout << " Number of overall systematics = " << overallSyst.size() << endl;
50 }
51
52 void EstimateSummary::AddSyst(const string &sname, TH1* low, TH1* high){
53 systSourceForHist.push_back(sname);
54 lowHists.push_back(low);
55 highHists.push_back(high);
56 }
57
59 // Comparator for two Estimate summary objects. Useful to make sure two analyses are the same
60
61 //this->print();
62 //other.print();
63 if(! (name==other.name)){
64 cout << "names don't match : " << name << " vs " << other.name << endl;
65 return false;
66 }
67 if(! (channel==other.channel)){
68 cout << "channel names don't match : " << channel << " vs " << other.channel << endl;
69 return false;
70 }
71 if(! (normName==other.normName)){
72 cout << "norm names don't match : " << normName << " vs " << other.normName << endl;
73 return false;
74 }
75 if(! (shapeFactorName==other.shapeFactorName)){
76 cout << "norm names don't match : " << shapeFactorName << " vs " << other.shapeFactorName << endl;
77 return false;
78 }
79 if (nominal && other.nominal)
80 if(! CompareHisto( this->nominal, other.nominal ) ) {
81 cout << "nominal histo don't match" << endl;
82 return false;
83 }
85 cout << "Include Stat Error bools don't match : " << IncludeStatError << " vs " << other.IncludeStatError << endl;
86 return false;
87 }
89 cout << "Stat Constraint Types don't match : " << StatConstraintType << " vs " << other.StatConstraintType << endl;
90 return false;
91 }
93 cout << "Relative Stat Error Thresholds don't match : " << RelErrorThreshold << " vs " << other.RelErrorThreshold << endl;
94 return false;
95 }
96 if (relStatError && other.relStatError)
97 if(! CompareHisto( this->relStatError, other.relStatError ) ) {
98 cout << "relStatError histo don't match" << endl;
99 return false;
100 }
101 if(! (shapeFactorName==other.shapeFactorName)){
102 cout << "Shape Factor Names don't match : " << shapeFactorName << " vs " << other.shapeFactorName << endl;
103 return false;
104 }
105
106
107 /// compare histo sys
108 int counter=0;
109 for( vector<string>::const_iterator itr=systSourceForHist.begin(); itr!=systSourceForHist.end(); ++itr){
110 unsigned int ind = find(other.systSourceForHist.begin(), other.systSourceForHist.end(), *itr) - other.systSourceForHist.begin();
111 if(ind<other.systSourceForHist.size() && systSourceForHist.size() == other.systSourceForHist.size()){
112 if(! (CompareHisto( lowHists[ counter ], other.lowHists[ ind ]))){
113 cout << "contents of sys histo low " << *itr << " did not match" << endl;
114 }
115 else if (!( CompareHisto( highHists[counter], other.highHists[ ind ]) ) ){
116 cout << "contents of sys histo high " << *itr << " did not match" << endl;
117 }
118 } else {
119 cout << "mismatch in systSourceForHist : " << systSourceForHist.size() << " vs " << other.systSourceForHist.size() << endl;
120 for( vector<string>::const_iterator itr_this=systSourceForHist.begin(); itr_this!=systSourceForHist.end(); ++itr_this){
121 cout << " this contains: " << *itr_this << endl;
122 }
123 for( vector<string>::const_iterator itr_other=other.systSourceForHist.begin(); itr_other!=other.systSourceForHist.end(); ++itr_other){
124 cout << " other contains: " << *itr_other << endl;
125 }
126 return false;
127 }
128 counter++;
129 }
130 /// compare overall sys
131 if( overallSyst.size() != other.overallSyst.size()){
132 cout << "mismatch in overallSyst : " << overallSyst.size() << " vs " << other.overallSyst.size() << endl;
133 return false;
134 }
135 for( map<string, pair<double, double> >::const_iterator itr=overallSyst.begin(); itr!=overallSyst.end(); ++itr){
136 map<string, pair<double, double> >::const_iterator found=other.overallSyst.find(itr->first);
137 if(found==other.overallSyst.end()){
138 cout << "mismatch in overallSyst, didn't find " << itr->first << endl;
139 return false;
140 }
141 if(! (itr->second.first==found->second.first && itr->second.second==found->second.second)){
142 cout << "mismatch in overall Syst value of " << itr->first << endl;
143 return false;
144 }
145 }
146 return true;
147 }
148
149 bool EstimateSummary::CompareHisto( const TH1 * one, const TH1 * two) const {
150
151 if (!one && !two) return true;
152 if (!one) return false;
153 if (!two) return false;
154
155 for(int i=1; i<=one->GetNbinsX(); ++i){
156 if(!(one->GetBinContent(i)-two->GetBinContent(i)==0)) return false;
157 }
158 return true;
159 //if(one->Integral()-two->Integral()==0) return true;
160 //cout << "Integral of " << one->GetName() << " : " << one->Integral() << " vs Integral ov " << two->GetName() << " : " << two->Integral() << endl;
161 }
162
163 }
164}
165
#define ClassImp(name)
Definition Rtypes.h:364
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:58
virtual Int_t GetNbinsX() const
Definition TH1.h:296
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition TH1.cxx:4993
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:359
Namespace for the RooStats classes.
Definition Asimov.h:19
void Print(const char *opt=0) const
This method must be overridden when a class wants to print itself.
bool operator==(const EstimateSummary &other) const
void AddSyst(const std::string &sname, TH1 *low, TH1 *high)
std::vector< std::string > systSourceForHist
std::map< std::string, std::pair< double, double > > overallSyst
bool CompareHisto(const TH1 *one, const TH1 *two) const