30bool checkRegularBins(
const TAxis &ax)
 
   34   for (
int i = 0; i <= ax.
GetNbins(); ++i) {
 
   50      auto &bounds = axis[
"bounds"];
 
   52      for (
int i = 0; i <= ax.
GetNbins(); ++i) {
 
   60   std::vector<std::string> obsnames{
"obs_x_" + 
c.GetName(), 
"obs_y_" + 
c.GetName(), 
"obs_z_" + 
c.GetName()};
 
   61   obsnames.resize(
c.GetData().GetHisto()->GetDimension());
 
   65void writeObservables(
const TH1 &
h, 
JSONNode &
n, 
const std::vector<std::string> &varnames)
 
   68   auto &observables = 
n[
"axes"].set_seq();
 
   69   auto &
x = observables.append_child().set_map();
 
   70   x[
"name"] << varnames[0];
 
   71   writeAxis(
x, *
h.GetXaxis());
 
   72   if (
h.GetDimension() > 1) {
 
   73      auto &
y = observables.append_child().set_map();
 
   74      y[
"name"] << varnames[1];
 
   75      writeAxis(
y, *(
h.GetYaxis()));
 
   76      if (
h.GetDimension() > 2) {
 
   77         auto &z = observables.append_child().set_map();
 
   78         z[
"name"] << varnames[2];
 
   79         writeAxis(z, *(
h.GetZaxis()));
 
   84void exportHistogram(
const TH1 &histo, 
JSONNode &node, 
const std::vector<std::string> &varnames,
 
   85                     const TH1 *errH = 
nullptr, 
bool doWriteObservables = 
true, 
bool writeErrors = 
true)
 
   88   auto &weights = node[
"contents"].
set_seq();
 
   91      errors = &node[
"errors"].
set_seq();
 
   93   if (doWriteObservables) {
 
   94      writeObservables(histo, node, varnames);
 
   97   for (
int i = 1; i <= nBins; ++i) {
 
   99      weights.append_child() << val;
 
  101         const double err = errH ? val * errH->GetBinContent(i) : histo.
GetBinError(i);
 
  108                  std::vector<std::string> 
const &obsnames)
 
  113      auto &modifiers = s[
"modifiers"];
 
  114      for (
const auto &sys : sample.GetOverallSysList()) {
 
  116         node[
"type"] << 
"normsys";
 
  117         auto &
data = node[
"data"];
 
  119         data[
"lo"] << sys.GetLow();
 
  120         data[
"hi"] << sys.GetHigh();
 
  125      auto &modifiers = s[
"modifiers"];
 
  126      for (
const auto &nf : sample.GetNormFactorList()) {
 
  130      mod[
"type"] << 
"normfactor";
 
  131      mod[
"constraint_name"] << 
"lumiConstraint";
 
  135      auto &modifiers = s[
"modifiers"];
 
  139         node[
"type"] << 
"histosys";
 
  141         exportHistogram(*(sys.GetHistoLow()), 
data[
"lo"], obsnames, 
nullptr, 
false);
 
  142         exportHistogram(*(sys.GetHistoHigh()), 
data[
"hi"], obsnames, 
nullptr, 
false);
 
  146   auto &tags = s[
"dict"].set_map();
 
  153   auto &
data = s[
"data"];
 
  158      writeObservables(*sample.
GetHisto(), channelNode, obsnames);
 
  160   exportHistogram(*sample.
GetHisto(), 
data, obsnames, errH, 
false);
 
  165   ch[
"type"] << 
"histfactory_dist";
 
  167   auto &staterr = ch[
"statError"].
set_map();
 
  168   staterr[
"relThreshold"] << 
c.GetStatErrorConfig().GetRelErrorThreshold();
 
  171   const std::vector<std::string> obsnames = getObsnames(
c);
 
  173   for (
const auto &s : 
c.GetSamples()) {
 
  174      exportSample(s, ch, obsnames);
 
  183   for (
const auto &ch : measurement.GetChannels()) {
 
  184      if (!ch.CheckHistograms())
 
  185         throw std::runtime_error(
"unable to export histograms, please call CollectHistograms first");
 
  189   std::map<std::string, RooStats::HistFactory::Constraint::Type> constraints;
 
  190   std::map<std::string, NormFactor> normfactors;
 
  191   for (
const auto &ch : measurement.GetChannels()) {
 
  192      for (
const auto &s : ch.GetSamples()) {
 
  193         for (
const auto &sys : s.GetOverallSysList()) {
 
  196         for (
const auto &sys : s.GetHistoSysList()) {
 
  199         for (
const auto &sys : s.GetShapeSysList()) {
 
  200            constraints[sys.GetName()] = sys.GetConstraintType();
 
  202         for (
const auto &norm : s.GetNormFactorList()) {
 
  203            normfactors[norm.GetName()] = norm;
 
  210      auto &funclist = 
n[
"functions"];
 
  211      for (
const auto &func : measurement.GetFunctionObjects()) {
 
  213         f[
"name"] << func.GetName();
 
  214         f[
"expression"] << func.GetExpression();
 
  215         f[
"dependents"] << func.GetDependents();
 
  216         f[
"command"] << func.GetCommand();
 
  220   auto &pdflist = 
n[
"distributions"];
 
  223   analysisNode[
"domains"].set_seq().append_child() << 
"default_domain";
 
  225   auto &analysisPois = analysisNode[
"parameters_of_interest"].set_seq();
 
  227   for (
const auto &poi : measurement.GetPOIList()) {
 
  228      analysisPois.append_child() << poi;
 
  231   analysisNode[
"likelihood"] << measurement.
GetName();
 
  234   likelihoodNode[
"distributions"].set_seq();
 
  235   likelihoodNode[
"data"].set_seq();
 
  238   for (
const auto &
c : measurement.GetChannels()) {
 
  240      auto pdfName = std::string(
"model_") + 
c.GetName();
 
  242      likelihoodNode[
"distributions"].append_child() << pdfName;
 
  243      likelihoodNode[
"data"].append_child() << std::string(
"obsData_") + 
c.GetName();
 
  247   struct VariableInfo {
 
  249      double minVal = -5.0;
 
  251      bool isConstant = 
false;
 
  252      bool writeDomain = 
true;
 
  254   std::unordered_map<std::string, VariableInfo> 
variables;
 
  256   for (
const auto &channel : measurement.GetChannels()) {
 
  257      for (
const auto &sample : channel.GetSamples()) {
 
  258         for (
const auto &norm : sample.GetNormFactorList()) {
 
  260            info.val = norm.GetVal();
 
  261            info.minVal = norm.GetLow();
 
  262            info.maxVal = norm.GetHigh();
 
  264         for (
const auto &sys : sample.GetOverallSysList()) {
 
  265            variables[std::string(
"alpha_") + sys.GetName()] = VariableInfo{};
 
  269   for (
const auto &sys : measurement.GetConstantParams()) {
 
  271      info.isConstant = 
true;
 
  272      bool isGamma = sys.find(
"gamma_") != std::string::npos;
 
  274      info.val = isGamma ? 1.0 : 0.0;
 
  277      info.writeDomain = !isGamma;
 
  282      double nominal = measurement.
GetLumi();
 
  288      info1.maxVal = 10 * nominal;
 
  289      info1.isConstant = 
true;
 
  294      info2.maxVal = nominal + 10 * error;
 
  295      info2.isConstant = 
true;
 
  300      std::string 
const &parname = item.first;
 
  301      VariableInfo 
const &info = item.second;
 
  304      v[
"value"] << info.val;
 
  307      if (info.writeDomain) {
 
  308         domains.
readVariable(parname.c_str(), info.minVal, info.maxVal);
 
  313   auto &child1 = 
n.get(
"misc", 
"ROOT_internal", 
"combined_datas").set_map()[
"obsData"].set_map();
 
  314   auto &child2 = 
n.get(
"misc", 
"ROOT_internal", 
"combined_distributions").set_map()[
"simPdf"].set_map();
 
  316   child1[
"index_cat"] << 
"channelCat";
 
  317   auto &labels1 = child1[
"labels"].set_seq();
 
  318   auto &indices1 = child1[
"indices"].set_seq();
 
  320   child2[
"index_cat"] << 
"channelCat";
 
  321   auto &labels2 = child2[
"labels"].set_seq();
 
  322   auto &indices2 = child2[
"indices"].set_seq();
 
  323   auto &pdfs2 = child2[
"distributions"].set_seq();
 
  325   std::vector<std::string> channelNames;
 
  326   for (
const auto &
c : measurement.GetChannels()) {
 
  327      labels1.append_child() << 
c.GetName();
 
  328      indices1.append_child() << 
int(channelNames.size());
 
  329      labels2.append_child() << 
c.GetName();
 
  330      indices2.append_child() << 
int(channelNames.size());
 
  331      pdfs2.append_child() << (std::string(
"model_") + 
c.GetName());
 
  334      dataOutput[
"type"] << 
"binned";
 
  336      exportHistogram(*
c.GetData().GetHisto(), dataOutput, getObsnames(
c));
 
  337      channelNames.push_back(
c.GetName());
 
  341   modelConfigAux[
"combined_data_name"] << 
"obsData";
 
  342   modelConfigAux[
"pdfName"] << 
"simPdf";
 
  343   modelConfigAux[
"mcName"] << 
"ModelConfig";
 
  347   lumiConstraint[
"mean"] << 
"nominalLumi";
 
  349   lumiConstraint[
"type"] << 
"gaussian_dist";
 
  350   lumiConstraint[
"x"] << 
"Lumi";
 
  358   auto &
n = 
tree->rootnode();
 
  367   this->PrintJSON(out);
 
  373   auto &
n = 
tree->rootnode().set_map();
 
  375   exportMeasurement(_measurement, 
n, domains);
 
  383   this->PrintYAML(out);
 
  389   node[
"type"] << 
"staterror";
 
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
 
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
 
virtual JSONNode & set_map()=0
 
virtual JSONNode & append_child()=0
 
virtual JSONNode & set_seq()=0
 
virtual bool has_child(std::string const &) const =0
 
void readVariable(const char *name, double min, double max)
 
void writeJSON(RooFit::Detail::JSONNode &) const
 
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...
 
double GetLumiRelErr()
retrieve relative uncertainty on luminosity
 
std::vector< RooStats::HistFactory::PreprocessFunction > & GetFunctionObjects()
get vector of defined function objects
 
double GetLumi()
retrieve integrated luminosity
 
std::vector< RooStats::HistFactory::OverallSys > & GetOverallSysList()
 
std::string GetName() const
get name of sample
 
const TH1 * GetHisto() const
 
RooStats::HistFactory::StatError & GetStatError()
 
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
 
Class to manage histogram axis.
 
Bool_t IsVariableBinSize() const
 
virtual Double_t GetBinUpEdge(Int_t bin) const
Return up edge of bin.
 
TH1 is the base class of all histogram classes in ROOT.
 
virtual Int_t GetNbinsY() const
 
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
 
virtual Int_t GetNbinsZ() const
 
virtual Int_t GetNbinsX() const
 
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
 
const char * GetName() const override
Returns name of object.
 
std::string Name(Type type)
 
void variables(TString dataset, TString fin="TMVA.root", TString dirName="InputVariables_Id", TString title="TMVA Input Variables", Bool_t isRegression=kFALSE, Bool_t useTMVAStyle=kTRUE)