3 #include "boost/format.hpp"
11 value_fmt = (boost::format(
"%.4g/%.4g")
14 value_fmt = (boost::format(
"%.4g") % val.
value_u()).str();
16 return boost::format(
"%-6s %-9s %-6s %-8s %-28s %-3i"
17 " %-16s %-4i %-45s %-8s %-13s %-4i %-4i")
56 if (data_u_) data_u_->SetName(std::regex_replace(data_u_->GetName(),std::regex(name_),
name).c_str());
57 if (data_d_) data_d_->SetName(std::regex_replace(data_d_->GetName(),std::regex(name_),
name).c_str());
58 if (pdf_u_) pdf_u_->SetName(std::regex_replace(pdf_u_->GetName(),std::regex(name_),
name).c_str());
59 if (pdf_d_) pdf_d_->SetName(std::regex_replace(pdf_d_->GetName(),std::regex(name_),
name).c_str());
66 swap(first.name_, second.name_);
67 swap(first.type_, second.type_);
68 swap(first.value_u_, second.value_u_);
69 swap(first.value_d_, second.value_d_);
70 swap(first.scale_, second.scale_);
71 swap(first.asymm_, second.asymm_);
72 swap(first.shape_u_, second.shape_u_);
73 swap(first.shape_d_, second.shape_d_);
74 swap(first.pdf_u_, second.pdf_u_);
75 swap(first.pdf_d_, second.pdf_d_);
76 swap(first.data_u_, second.data_u_);
77 swap(first.data_d_, second.data_d_);
84 value_u_(other.value_u_),
85 value_d_(other.value_d_),
90 data_u_(other.data_u_),
91 data_d_(other.data_d_) {
94 h_u =
dynamic_cast<TH1*
>(other.shape_u_->Clone());
97 shape_u_ = std::unique_ptr<TH1>(h_u);
100 h_d =
dynamic_cast<TH1*
>(other.shape_d_->Clone());
101 h_d->SetDirectory(0);
103 shape_d_ = std::unique_ptr<TH1>(h_d);
129 std::unique_ptr<TH1> shape_d, TH1
const* nominal) {
132 throw std::runtime_error(
133 "shape_u and shape_d must be either both valid or both null");
165 shape_u_->SetDirectory(0);
166 shape_d_->SetDirectory(0);
168 if (nominal && nominal->Integral() > 0.) {
169 this->
set_value_u(shape_u_->Integral() / nominal->Integral());
170 this->
set_value_d(shape_d_->Integral() / nominal->Integral());
173 if (shape_u_->Integral() > 0.) shape_u_->Scale(1. / shape_u_->Integral());
174 if (shape_d_->Integral() > 0.) shape_d_->Scale(1. / shape_d_->Integral());
178 TH1
const& nominal) {
180 std::unique_ptr<TH1>(
static_cast<TH1*
>(
shape_d.Clone())),
185 RooDataHist
const* nominal) {
186 if (nominal && nominal->sumEntries() > 0.) {
187 this->
set_value_u(data_u->sumEntries() / nominal->sumEntries());
188 this->
set_value_d(data_d->sumEntries() / nominal->sumEntries());
195 RooAbsReal
const* nominal) {
201 if (!shape_u_)
return std::unique_ptr<TH1>();
202 std::unique_ptr<TH1> res(
static_cast<TH1 *
>(shape_u_->Clone()));
203 res->SetDirectory(0);
208 if (!shape_d_)
return std::unique_ptr<TH1>();
209 std::unique_ptr<TH1> res(
static_cast<TH1 *
>(shape_d_->Clone()));
210 res->SetDirectory(0);
219 TH1F
const* test_f =
dynamic_cast<TH1F const*
>(this->
shape_u());
220 TH1D
const* test_d =
dynamic_cast<TH1D const*
>(this->
shape_u());
226 throw std::runtime_error(
FNERROR(
"TH1 shape is not a TH1F or a TH1D"));
237 TH1F
const* test_f =
dynamic_cast<TH1F const*
>(this->
shape_d());
238 TH1D
const* test_d =
dynamic_cast<TH1D const*
>(this->
shape_d());
244 throw std::runtime_error(
FNERROR(
"TH1 shape is not a TH1F or a TH1D"));
253 (boost::format(
"%-6s %-9s %-6s %-8s %-28s %-3i"
254 " %-16s %-4i %-45s %-8s %-13s %-4i %-4i")
255 %
"mass" %
"analysis" %
"era" %
"channel" %
"bin" %
"id" %
"process" %
"sig"
256 %
"nuisance" %
"type" %
"value" %
"sh_d" %
"sh_u").str();
257 std::string div(line.length(),
'-');
265 return ::format_syst(*this).str();
269 out << ::format_syst(val);
275 value_u_=1./value_u_;
277 double tmp = value_u_;
281 shape_u_.swap(shape_d_);
virtual std::string const & process() const
virtual std::string const & bin() const
virtual int bin_id() const
virtual std::string const & analysis() const
virtual std::string const & era() const
virtual std::string const & mass() const
virtual std::string const & channel() const
Systematic & operator=(Systematic other)
void set_pdf(RooAbsReal *pdf_u, RooAbsReal *pdf_d, RooAbsReal const *nominal)
RooDataHist const * data_d() const
std::unique_ptr< TH1 > ClonedShapeU() const
std::string const & type() const
std::unique_ptr< TH1 > ClonedShapeD() const
void set_shapes(std::unique_ptr< TH1 > shape_u, std::unique_ptr< TH1 > shape_d, TH1 const *nominal)
void set_value_d(double const &value_d)
TH1 const * shape_d() const
void set_name(std::string const &name)
void set_data(RooDataHist *data_u, RooDataHist *data_d, RooDataHist const *nominal)
void set_value_u(double const &value_u)
TH1 const * shape_u() const
std::string const & name() const
std::string to_string() const
RooAbsReal const * pdf_d() const
RooAbsReal const * pdf_u() const
RooDataHist const * data_u() const
TH1F ShapeUAsTH1F() const
TH1F ShapeDAsTH1F() const
friend void swap(Systematic &first, Systematic &second)
static std::ostream & PrintHeader(std::ostream &out)
std::ostream & operator<<(std::ostream &out, HistMapping const &val)
void swap(Systematic &first, Systematic &second)
void swap(CombineHarvester &first, CombineHarvester &second)