96 |
|
string get_directory(); |
97 |
|
bool Contains(string wholestring, string findme); |
98 |
|
TH1F* CollapseStack(THStack stack,TString hname); |
99 |
+ |
TH1F* CollapseStack(THStack* stack,TString hname); |
100 |
|
//------------------------------------------------------------------------------------- |
101 |
|
|
102 |
|
template<typename U> |
1728 |
|
return basehisto; |
1729 |
|
} |
1730 |
|
|
1731 |
+ |
TH1F* CollapseStack(THStack *stack,TString hname="CollapsedStack") { |
1732 |
+ |
TH1F *bhist = ((TH1F*)((stack->GetHists())->At(0))); |
1733 |
+ |
TH1F *basehisto = (TH1F*)bhist->Clone(hname); |
1734 |
+ |
TIter next(stack->GetHists()); |
1735 |
+ |
TH1F *h; |
1736 |
+ |
int counter=0; |
1737 |
+ |
while ((h=(TH1F*)next())) { |
1738 |
+ |
counter++; |
1739 |
+ |
if(counter==1) continue; |
1740 |
+ |
basehisto->Add(h); |
1741 |
+ |
} |
1742 |
+ |
return basehisto; |
1743 |
+ |
} |
1744 |
+ |
|
1745 |
|
void Save_With_Ratio(TH1F *nominator, THStack denominator, TVirtualPad *canvas, string savemeas, bool do_bpred_ratio=false) { |
1746 |
|
TH1F *denominator_histo = (TH1F*) CollapseStack(denominator); |
1747 |
|
Save_With_Ratio(nominator, denominator_histo, canvas, savemeas, do_bpred_ratio); |
2098 |
|
temp=int(temp)/pow(10.0,digits); |
2099 |
|
return any2string(temp); |
2100 |
|
} |
2101 |
+ |
|
2102 |
+ |
|
2103 |
+ |
float GetYield(TH1F *histo, float min, float max) { |
2104 |
+ |
float res=0.0; |
2105 |
+ |
for(int i=1;i<=histo->GetNbinsX();i++) { |
2106 |
+ |
if(histo->GetBinLowEdge(i)+histo->GetBinWidth(i)<=min) continue;// considered in the next bin |
2107 |
+ |
if(histo->GetBinLowEdge(i)>=max) continue;//above the threshold, out! |
2108 |
+ |
// cout << " added yield for bin [" << histo->GetBinLowEdge(i) << "," << histo->GetBinLowEdge(i)+histo->GetBinWidth(i) << "] which is " << histo->GetBinContent(i) << " in GetYield" << endl; |
2109 |
+ |
res+=histo->GetBinContent(i); |
2110 |
+ |
} |
2111 |
+ |
return res; |
2112 |
+ |
} |
2113 |
+ |
|
2114 |
+ |
void ProduceYields(float min, float max, TH1F *data, THStack *stack) { |
2115 |
+ |
dout << " *************** <MC YIELDS> ********* " << endl; |
2116 |
+ |
dout << " Considering " << min << " < mll < " << max << " " << endl; |
2117 |
+ |
dout << " Data : " << GetYield(data,min,max) << endl; |
2118 |
+ |
TIter nextSF(stack->GetHists()); |
2119 |
+ |
TH1F* h; |
2120 |
+ |
while ( h = (TH1F*)nextSF() ) { |
2121 |
+ |
dout << " " << h->GetName() << " : " << GetYield(h,min,max) << endl; |
2122 |
+ |
} |
2123 |
+ |
dout << " *************** </MC YIELDS> ********* " << endl; |
2124 |
+ |
} |
2125 |
+ |
|
2126 |
+ |
|
2127 |
+ |
void WriteYield(THStack *mc, float low, float high) { |
2128 |
+ |
TH1F *h; |
2129 |
+ |
TIter NextHisto(mc->GetHists()); |
2130 |
+ |
while ( h = (TH1F*)NextHisto() ) { |
2131 |
+ |
float CurrBKG=0; |
2132 |
+ |
float CurrBKGErr=0; |
2133 |
+ |
for(int i=1;i<=h->GetNbinsX()+1;i++) { |
2134 |
+ |
if(h->GetBinLowEdge(i)+h->GetBinWidth(i)<=low) continue;// considered in the next bin |
2135 |
+ |
if(h->GetBinLowEdge(i)>=high) continue;//above the threshold, out! |
2136 |
+ |
CurrBKG+=h->GetBinContent(i); |
2137 |
+ |
CurrBKGErr=sqrt(CurrBKGErr*CurrBKGErr+h->GetBinError(i)*h->GetBinError(i)); |
2138 |
+ |
} |
2139 |
+ |
dout << " " << h->GetName() << " : " << CurrBKG << " +/- " << CurrBKGErr << endl; |
2140 |
+ |
} |
2141 |
+ |
} |