cms-analysis / HiggsAnalysis-CombinedLimit

CMS Higgs Combination toolkit.
https://cms-analysis.github.io/HiggsAnalysis-CombinedLimit/latest
Apache License 2.0
75 stars 384 forks source link

Dump postfit shapes with best fit MultiSignalModel? #766

Closed patrickbryant closed 2 years ago

patrickbryant commented 2 years ago

I cannot find any way to output best fit TH1 shapes for plotting with multiple signal POIs at their best fit value. Surely there is a way to do this...

Here's my first failed attempt to solve this: https://github.com/cms-analysis/HiggsAnalysis-CombinedLimit/issues/765

adewit commented 2 years ago

I think you’ll want to try PostFitShapesFromWorkspace: http://cms-analysis.github.io/CombineHarvester/post-fit-shapes-ws.html (you can use the fit result from MultiDimFit with this instead of a fit result from FitDiagnostics as in the example)

patrickbryant commented 2 years ago

I get a weird error if I try to output postfit histograms:

[bryantp@cmslpc139]/uscms_data/d3/bryantp/CMSSW_11_1_0_pre5/src% combine -M MultiDimFit --setParameters  rZZ=1,rZH=1,rHH=1 --robustFit 1 -n .fit_all -d ZZ4b/nTupleAnalysis/combine/combine_closure_SvB.root --saveWorkspace
 <<< Combine >>> 
   Options for Robust Minimizer :: 
        Tolerance  0.1
        Strategy   0
        Type,Algo  Minuit2,Migrad
>>> method used is MultiDimFit
>>> random number generator seed is 123456
ModelConfig 'ModelConfig' defines more than one parameter of interest. This is not supported in some statistical methods.
Set Default Value of Parameter rZZ To : 1
Set Default Value of Parameter rZH To : 1
Set Default Value of Parameter rHH To : 1
SimNLL created with 9 channels, 0 generic constraints, 178 fast gaussian constraints, 0 fast poisson constraints, 0 fast group constraints, 

 --- MultiDimFit ---
best fit parameter values: 
   rHH :    +2.523
   rZZ :    +1.696
   rZH :    +1.909
Done in 0.00 min (cpu), 0.00 min (real)
[bryantp@cmslpc139]/uscms_data/d3/bryantp/CMSSW_11_1_0_pre5/src% PostFitShapesFromWorkspace -w higgsCombine.fit_all.MultiDimFit.mH120.root --output postfit_s.root --total-shapes --skip-prefit --postfit
[SetFlag] Changing value of flag "workspaces-use-clone" from 0 to 1
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing dataset hh6
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing dataset hh7
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing dataset hh8
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing dataset zh6
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing dataset zh7
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing dataset zh8
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing dataset zz6
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing dataset zz7
[#1] INFO:ObjectHandling -- RooWorkspace::import(w) importing dataset zz8
[SetFlag] Changing value of flag "workspaces-use-clone" from 0 to 1
terminate called after throwing an instance of 'std::runtime_error'
  what():  
*******************************************************************************
Context: Function ch::OpenFromTFile at 
  /uscms_data/d3/bryantp/CMSSW_11_1_0_pre5/src/CombineHarvester/CombineTools/interface/TFileIO.h:60
Problem: Input path must of the format file.root:object
*******************************************************************************
Please report issues at
  https://github.com/cms-analysis/CombineHarvester/issues
*******************************************************************************
zsh: abort      PostFitShapesFromWorkspace -w higgsCombine.fit_all.MultiDimFit.mH120.root   
patrickbryant commented 2 years ago

Needed to save the fit result and pass it in to PostFitShapes:

combine -M MultiDimFit --setParameters  rZZ=1,rZH=1,rHH=1 --robustFit 1 -n .fit_all -d ZZ4b/nTupleAnalysis/combine/combine_closure_SvB.root --saveWorkspace --saveFitResult
PostFitShapesFromWorkspace -w higgsCombine.fit_all.MultiDimFit.mH120.root --output postfit_s.root --total-shapes --skip-prefit --postfit -f multidimfit.fit_all.root:fit_mdf

works

patrickbryant commented 2 years ago

Ok great thanks, I have cleaned up my workflow dramatically with this.