20#ifdef ROOFIT_HS3_WITH_RYML
38 s[
"type"] <<
"hist-sample";
41 auto &overallSys = s[
"overallSystematics"];
44 auto &node = overallSys[sys.GetName()];
46 node[
"low"] << sys.GetLow();
47 node[
"high"] << sys.GetHigh();
52 auto &normFactors = s[
"normFactors"];
55 normFactors.append_child() << sys.GetName();
60 auto &histoSys = s[
"histogramSystematics"];
64 auto &node = histoSys[sys.GetName()];
71 auto &tags = s[
"dict"];
77 auto &data = s[
"data"];
87 ch[
"type"] <<
"histfactory";
89 auto &staterr = ch[
"statError"];
91 staterr[
"relThreshold"] <<
c.GetStatErrorConfig().GetRelErrorThreshold();
94 auto &samples = ch[
"samples"];
96 for (
const auto &s :
c.GetSamples()) {
97 auto &sample = samples[s.GetName()];
98 exportSample(s, sample);
99 auto &ns = sample[
"namespaces"];
110 if (!ch.CheckHistograms())
111 throw std::runtime_error(
"unable to export histograms, please call CollectHistograms first");
114 auto &pdflist =
n[
"pdfs"];
118 std::map<std::string, RooStats::HistFactory::Constraint::Type> constraints;
119 std::map<std::string, NormFactor> normfactors;
121 for (
const auto &s : ch.GetSamples()) {
122 for (
const auto &sys : s.GetOverallSysList()) {
125 for (
const auto &sys : s.GetHistoSysList()) {
128 for (
const auto &sys : s.GetShapeSysList()) {
129 constraints[sys.GetName()] = sys.GetConstraintType();
131 for (
const auto &norm : s.GetNormFactorList()) {
132 normfactors[norm.GetName()] = norm;
139 auto &funclist =
n[
"functions"];
142 auto &
f = funclist[func.GetName()];
144 f[
"name"] << func.GetName();
145 f[
"expression"] << func.GetExpression();
146 f[
"dependents"] << func.GetDependents();
147 f[
"command"] << func.GetCommand();
152 auto &sim = pdflist[measurement.
GetName()];
154 sim[
"type"] <<
"simultaneous";
155 sim[
"index"] <<
"channelCat";
156 auto &simdict = sim[
"dict"];
159 auto &simtags = sim[
"tags"];
161 simtags.append_child() <<
"toplevel";
162 auto &ch = sim[
"channels"];
165 auto &thisch = ch[
c.GetName()];
166 exportChannel(
c, thisch);
170 auto &varlist =
n[
"variables"];
173 for (
const auto &s :
c.GetSamples()) {
174 for (
const auto &norm : s.GetNormFactorList()) {
175 if (!varlist.has_child(norm.GetName())) {
176 auto &
v = varlist[norm.GetName()];
178 v[
"value"] << norm.GetVal();
179 v[
"min"] << norm.GetLow();
180 v[
"max"] << norm.GetHigh();
181 if (norm.GetConst()) {
186 for (
const auto &sys : s.GetOverallSysList()) {
187 std::string parname(
"alpha_");
188 parname += sys.GetName();
189 if (!varlist.has_child(parname)) {
190 auto &
v = varlist[parname];
200 std::string parname =
"alpha_" + sys;
201 if (!varlist.has_child(parname)) {
202 auto &
v = varlist[parname];
205 varlist[parname][
"const"] <<
true;
208 for (
const auto &poi : measurement.
GetPOIList()) {
209 if (!varlist[poi].has_child(
"tags")) {
210 auto &tags = varlist[poi][
"tags"];
213 varlist[poi][
"tags"].append_child() <<
"poi";
217 auto &datalist =
n[
"data"];
219 auto &obsdata = datalist[
"obsData"];
221 obsdata[
"index"] <<
"channelCat";
223 const std::vector<std::string> obsnames{
"obs_x_" +
c.GetName(),
"obs_y_" +
c.GetName(),
"obs_z_" +
c.GetName()};
225 auto &chdata = obsdata[
c.GetName()];
242 std::ofstream out(filename);
243 this->PrintJSON(out);
246#ifdef ROOFIT_HS3_WITH_RYML
252 exportMeasurement(_measurement,
n);
258 std::cerr <<
"YAML export only support with rapidyaml!" << std::endl;
264 std::ofstream out(filename);
265 this->PrintYAML(out);
This class encapsulates all information for the statistical interpretation of one experiment.
The RooStats::HistFactory::Measurement class can be used to construct a model by combining multiple R...
std::vector< std::string > & GetPOIList()
get vector of PoI names
std::vector< std::string > & GetConstantParams()
get vector of all constant parameters
std::vector< RooStats::HistFactory::Channel > & GetChannels()
std::vector< RooStats::HistFactory::PreprocessFunction > & GetFunctionObjects()
get vector of defined function objects
std::string GetInterpolationScheme()
std::vector< RooStats::HistFactory::OverallSys > & GetOverallSysList()
std::string GetName() const
get name of sample
const TH1 * GetHisto() const
RooStats::HistFactory::StatError & GetStatError()
std::string GetChannelName() const
get name of associated channel
std::vector< RooStats::HistFactory::NormFactor > & GetNormFactorList()
std::vector< RooStats::HistFactory::HistoSys > & GetHistoSysList()
bool GetNormalizeByTheory() const
does the normalization scale with luminosity
const TH1 * GetErrorHist() const
virtual Node & rootnode() override
virtual const char * GetName() const
Returns name of object.
std::string Name(Type type)