00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <algorithm>
00021 #include "RooStats/HistFactory/EstimateSummary.h"
00022
00023 ClassImp(RooStats::HistFactory::EstimateSummary)
00024
00025 using namespace std;
00026
00027 namespace RooStats {
00028 namespace HistFactory {
00029
00030 EstimateSummary::EstimateSummary(){
00031 nominal=0;
00032 normName="Lumi";
00033 }
00034 EstimateSummary::~EstimateSummary(){}
00035
00036 void EstimateSummary::Print(const char * ) const {
00037 cout << "EstimateSummary (name = " << name << " empty = " << name.empty() << ")"<< endl;
00038 cout << " TObj name = " << this->GetName() << endl;
00039 cout << " Channel = " << channel << endl;
00040 cout << " NormName = " << normName << endl;
00041 cout << " Nominal ptr = " << nominal << endl;
00042 if (nominal) cout << " Nominal hist name = " << nominal->GetName() << endl;
00043 cout << " Number of hist variations = " << systSourceForHist.size()
00044 << " " << lowHists.size() << " "
00045 << " " << highHists.size() << endl;
00046 cout << " Number of overall systematics = " << overallSyst.size() << endl;
00047 }
00048
00049 void EstimateSummary::AddSyst(const string &sname, TH1F* low, TH1F* high){
00050 systSourceForHist.push_back(sname);
00051 lowHists.push_back(low);
00052 highHists.push_back(high);
00053 }
00054
00055 bool EstimateSummary::operator==(const EstimateSummary &other) const {
00056
00057
00058
00059
00060 if(! (name==other.name)){
00061 cout << "names don't match : " << name << " vs " << other.name << endl;
00062 return false;
00063 }
00064 if(! (channel==other.channel)){
00065 cout << "channel names don't match : " << channel << " vs " << other.channel << endl;
00066 return false;
00067 }
00068 if(! (normName==other.normName)){
00069 cout << "norm names don't match : " << normName << " vs " << other.normName << endl;
00070 return false;
00071 }
00072 if (nominal && other.nominal)
00073 if(! CompareHisto( this->nominal, other.nominal ) ) {
00074 cout << "nominal histo don't match" << endl;
00075 return false;
00076 }
00077
00078 int counter=0;
00079 for( vector<string>::const_iterator itr=systSourceForHist.begin(); itr!=systSourceForHist.end(); ++itr){
00080 unsigned int ind = find(other.systSourceForHist.begin(), other.systSourceForHist.end(), *itr) - other.systSourceForHist.begin();
00081 if(ind<other.systSourceForHist.size() && systSourceForHist.size() == other.systSourceForHist.size()){
00082 if(! (CompareHisto( lowHists[ counter ], other.lowHists[ ind ]))){
00083 cout << "contents of sys histo low " << *itr << " did not match" << endl;
00084 }
00085 else if (!( CompareHisto( highHists[counter], other.highHists[ ind ]) ) ){
00086 cout << "contents of sys histo high " << *itr << " did not match" << endl;
00087 }
00088 } else {
00089 cout << "mismatch in systSourceForHist : " << systSourceForHist.size() << " vs " << other.systSourceForHist.size() << endl;
00090 for( vector<string>::const_iterator itr_this=systSourceForHist.begin(); itr_this!=systSourceForHist.end(); ++itr_this){
00091 cout << " this contains: " << *itr_this << endl;
00092 }
00093 for( vector<string>::const_iterator itr_other=other.systSourceForHist.begin(); itr_other!=other.systSourceForHist.end(); ++itr_other){
00094 cout << " other contains: " << *itr_other << endl;
00095 }
00096 return false;
00097 }
00098 counter++;
00099 }
00100
00101 if( overallSyst.size() != other.overallSyst.size()){
00102 cout << "mismatch in overallSyst : " << overallSyst.size() << " vs " << other.overallSyst.size() << endl;
00103 return false;
00104 }
00105 for( map<string, pair<double, double> >::const_iterator itr=overallSyst.begin(); itr!=overallSyst.end(); ++itr){
00106 map<string, pair<double, double> >::const_iterator found=other.overallSyst.find(itr->first);
00107 if(found==other.overallSyst.end()){
00108 cout << "mismatch in overallSyst, didn't find " << itr->first << endl;
00109 return false;
00110 }
00111 if(! (itr->second.first==found->second.first && itr->second.second==found->second.second)){
00112 cout << "mismatch in overall Syst value of " << itr->first << endl;
00113 return false;
00114 }
00115 }
00116 return true;
00117 }
00118
00119 bool EstimateSummary::CompareHisto( const TH1 * one, const TH1 * two) const {
00120
00121 if (!one && !two) return true;
00122 if (!one) return false;
00123 if (!two) return false;
00124
00125 for(int i=1; i<=one->GetNbinsX(); ++i){
00126 if(!(one->GetBinContent(i)-two->GetBinContent(i)==0)) return false;
00127 }
00128 return true;
00129
00130
00131 }
00132
00133 }
00134 }
00135