5 #include "TDirectory.h"
6 #include "TGraphAsymmErrors.h"
8 #include "TObjString.h"
18 const std::vector<SystShifts>& univ_shifts,
20 : fNom(loader, axis, spillcut, cut,
kNoShift, cv_wei)
22 fUnivs.reserve(univ_shifts.size());
24 fUnivs.emplace_back(loader, axis, spillcut, cut, ss, cv_wei);
33 const std::vector<Var>& univ_weis,
35 : fNom(loader, axis, spillcut, cut,
kNoShift, cv_wei)
37 fUnivs.reserve(univ_weis.size());
38 for(
const Var&
w: univ_weis){
48 std::unique_ptr<TH1D> hnom(
fNom.
ToTH1(exposure, expotype, bintype));
50 std::vector<std::unique_ptr<TH1D>> hunivs;
51 hunivs.reserve(
fUnivs.size());
52 for(
const Spectrum& u:
fUnivs) hunivs.emplace_back(u.ToTH1(exposure, expotype, bintype));
54 TGraphAsymmErrors*
g =
new TGraphAsymmErrors;
56 for(
int binIdx = 0; binIdx < hnom->GetNbinsX()+2; ++binIdx){
57 const double xnom = hnom->GetXaxis()->GetBinCenter(binIdx);
58 const double ynom = hnom->GetBinContent(binIdx);
59 g->SetPoint(binIdx, xnom, ynom);
61 const double dx = hnom->GetXaxis()->GetBinWidth(binIdx);
63 std::vector<double> ys;
64 ys.reserve(hunivs.size());
65 for(
const std::unique_ptr<TH1D>& hu: hunivs){
66 ys.push_back(hu->GetBinContent(binIdx));
75 g->SetPointError(binIdx, dx/2, dx/2,
76 std::max(ynom-y0, 0.),
77 std::max(y1-ynom, 0.));
161 TDirectory* tmp = gDirectory;
164 TObjString(
"EnsembleSpectrum").Write(
"type");
167 for(
unsigned int i = 0; i <
fUnivs.size(); ++i){
179 TObjString* tag = (TObjString*)dir->Get(
"type");
181 assert(tag->GetString() ==
"EnsembleSpectrum");
186 for(
unsigned int i = 0; ; ++i){
187 TDirectory* d = dir->GetDirectory((
"univ"+
std::to_string(i)).c_str());
196 void DrawErrorBand(TH1* nom, TGraphAsymmErrors* band,
int bandCol,
double alpha)
198 if(bandCol == -1) bandCol = nom->GetLineColor()-10;
201 const bool same = gPad && !gPad->GetListOfPrimitives()->IsEmpty();
203 nom->Draw(same ?
"hist same" :
"hist");
205 band->SetFillColorAlpha(bandCol, alpha);
206 band->Draw(
"e2 same");
208 nom->Draw(
"hist same");
215 for(
int i = 1; i < band->GetN()-1; ++i){
216 maxY = std::max(maxY, band->GetY()[i] + band->GetErrorYhigh(i));
220 nom->GetYaxis()->SetRangeUser(1
e-10, 1.1 * maxY);
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir)
EnsembleSpectrum operator-(const EnsembleSpectrum &rhs) const
EnsembleSpectrum operator+(const EnsembleSpectrum &rhs) const
EnsembleSpectrum(SpectrumLoaderBase &loader, const HistAxis &axis, const SpillCut &spillcut, const Cut &cut, const std::vector< SystShifts > &univ_shifts, const Var &cv_wei=kUnweighted)
Simple record of shifts applied to systematic parameters.
static std::unique_ptr< EnsembleSpectrum > LoadFrom(TDirectory *dir)
double FindQuantile(double frac, std::vector< double > &xs)
EnsembleSpectrum & operator+=(const EnsembleSpectrum &rhs)
process_name opflashCryoW ana
void Scale(double c)
Multiply this spectrum by a constant c.
Representation of a spectrum in any variable, with associated POT.
EnsembleSpectrum & operator*=(const EnsembleRatio &rhs)
void SaveTo(TDirectory *dir) const
EnsembleSpectrum & operator/=(const EnsembleRatio &rhs)
EExposureType
For use as an argument to Spectrum::ToTH1.
Ratio Universe(unsigned int i) const
EnsembleSpectrum operator/(const EnsembleRatio &rhs) const
const SystShifts kNoShift
unsigned int NUniverses() const
Base class for the various types of spectrum loader.
std::vector< Spectrum > fUnivs
TGraphAsymmErrors * ErrorBand(double exposure, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Result can be painted prettily with DrawErrorBand.
EnsembleSpectrum & operator-=(const EnsembleSpectrum &rhs)
std::string to_string(WindowPattern const &pattern)
then echo File list $list not found else cat $list while read file do echo $file sed s
Prevent histograms being added to the current directory.
EnsembleSpectrum operator*(const EnsembleRatio &rhs) const
void DrawErrorBand(TH1 *nom, TGraphAsymmErrors *band, int bandCol, double alpha)
void SaveTo(TDirectory *dir) const