Toy generation from workspace

Hello,

I am trying to generate some toys from the script I attached. The script use as input a 2D workspace (attached under the name: 2D_sigScaleDown_combined_ShapeFit_model.root) I built from 2D histograms. The code is running without errors, but the results (attached under the name run2D-output_0_15.root) are very odd, the histograms are more or less flat without any structure, contrary to what we expected.

The script is the following:

#include "RooHist.h"
#include "TMath.h"
#include "TLorentzVector.h"
#include "TStyle.h"
#include "TCanvas.h"
#include "TLatex.h"
#include "TROOT.h"
#include "TLegend.h"
#include "HGGfitter/HggZeeMassPdfBuilder.h"
#include "RooGaussian.h"
#include "HGGfitter/HggTwoSidedCBPdf.h"
#include "RooAddPdf.h"
#include "HfitterModels/HftTemplatePdfBuilder.h"
 
void run_2Dscan_SZdZd()
{
  HftModel* SZdZd = HftModelBuilder::CreateFromWSFile("2D_sigScaleDown_combined_ShapeFit_model.root","combined", "ModelConfig", "SZdZd");
  SZdZd->Var("obs_x_SR_shape")->setConstant(1);
  SZdZd->Var("obs_x_SR_shape")->setRange(0,120);
  SZdZd->Var("obs_y_SR_shape")->setConstant(1);
  SZdZd->Var("obs_y_SR_shape")->setRange(0,60);
  SZdZd->Var("mu")->setVal(0);
  SZdZd->Var("mu")->setConstant(1);
  SZdZd->Var("mu")->setRange(0,100);
  SZdZd->Workspace()->allVars().Print("V");
  HftParameterStorage  state = SZdZd->CurrentState();
  double offset = 0;
  TFile* f = TFile::Open("run2D-output_0_15.root", "RECREATE");
  TFile* fWS = TFile::Open("run2D-ws.root", "RECREATE");
  for (unsigned int k = 0; k < 15; k++) {
    SZdZd->LoadState(state);
    RooDataSet* data = SZdZd->GenerateEvents();
    TH2F* hcond = new TH2F(Form("scan_toy_cond%d", k), "", 40, 0, 120, 30, 0, 60);
    TH2F* hUncond = new TH2F(Form("scan_toy_Uncond%d", k), "", 40, 0, 120, 30, 0, 60);
    hcond->GetXaxis()->SetTitle("m_{S} [GeV]");
    hcond->GetYaxis()->SetTitle("m_{Zd} [GeV]");
    hUncond->GetXaxis()->SetTitle("m_{S} [GeV]");
    hUncond->GetYaxis()->SetTitle("m_{Zd} [GeV]");
    for (int i = 1; i <= 40; i++) {
      for (int j = 1; j <= 30; j++) {
	cout << "==== bin " << i << " " << j << endl;
	SZdZd->LoadState(state);
	double mS = hcond->GetXaxis()->GetBinCenter(i);
	double mZd = hcond->GetYaxis()->GetBinCenter(j);
	SZdZd->LoadState(state);
	SZdZd->Var("obs_x_SR_shape")->setVal(mS);
	SZdZd->Var("obs_y_SR_shape")->setVal(mZd);
	RooFitResult* rcond = SZdZd->Fit(*data, "Robust:Offcheck:Offset", &offset);
	hcond->SetBinContent(i,j, 2*(rcond->minNll() + offset));
	SZdZd->LoadState(state);
	SZdZd->Var("obs_x_SR_shape")->setVal(mS);
	SZdZd->Var("obs_y_SR_shape")->setVal(mZd);
	SZdZd->Var("mu")->setConstant(false);
	RooFitResult* rUncond = SZdZd->Fit(*data, "Robust:Offcheck:Offset", &offset);
	hUncond->SetBinContent(i,j, 2*(rUncond->minNll() + offset));
	RooWorkspace* w = SZdZd->ExportWorkspace("", Form("bin%d_%d_toy%d", i,j,k), "", data);
	fWS->cd();
	w->Write();
      }
    }
    f->cd();
    hcond->Write();
    hUncond->Write();
  }
  
  delete f;
  delete fWS;
}

The workspace input and the outputs are the following:
2D_sigScaleDown_combined_ShapeFit_model.root (71.6 KB)
run2D-output_0_15.root (17.0 KB)

Could someone advice what is the issue please?

Thanks.

Best,

Diallo.

We cannot run your script:

Processing run_2Dscan_SZdZd.C...

←[1mRooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby←[0m
                Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
                All rights reserved, please read http://roofit.sourceforge.net/license.txt

In file included from input_line_8:1:
C:\Users\bellenot\rootdev\Forum\diboye\run_2Dscan_SZdZd.C:9:10: fatal error: 'HGGfitter/HggZeeMassPdfBuilder.h' file not found
#include "HGGfitter/HggZeeMassPdfBuilder.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\bellenot\rootdev\Forum\diboye\run_2Dscan_SZdZd.C:11:10: fatal error: 'HGGfitter/HggTwoSidedCBPdf.h' file not found
#include "HGGfitter/HggTwoSidedCBPdf.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\bellenot\rootdev\Forum\diboye\run_2Dscan_SZdZd.C:13:10: fatal error: 'HfitterModels/HftTemplatePdfBuilder.h' file not found
#include "HfitterModels/HftTemplatePdfBuilder.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
root [1]

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.