Description
I am trying to write a single datacard for multiple mass points:
cb.WriteDatacard(f"output/datacard.txt",f"output/datacard.inputs.root")
instead of
for mass in masses:
cb.cp().mass([mass,'*']).WriteDatacard(f"output/datacard_M{mass}.txt",f"output/datacard_M{mass}.inputs.txt")
However, currently the writing routine throws an error:
CombineHarvester/CombineTools/src/CombineHarvester_Datacards.cc
Lines 669 to 675 in ba8d9b8
I am wondering if there is a canonical way of doing this, or otherwise, we can add support for this? The inputs ROOT file would contain the histograms for all signal mass points, while writing the $MASS
keyword in the datacard (which it already does, actually), and setting the signal rate to -1
to make Combine take the rate from the histogram's integral, see https://cms-analysis.github.io/HiggsAnalysis-CombinedLimit/latest/part2/settinguptheanalysis/?h=rate#rates-for-shape-analyses
Currently, an ugly workaround to get the histograms of all signal mass points written to the same ROOT file is the following:
outfname_txt = "output/datacard.txt"
outfname_root = "output/datacard.inputs.root"
outfile_root = TFile(outfname_root,'RECREATE')
for mass in masses: # write each signal mass point to ROOT file
cb.cp().signals().mass([mass]).WriteDatacard(outfname_txt,outfile_root) # cannot handle multiple masses $MASS
cb.cp().signals().ForEachProc( lambda x: x.set_rate(-1) ) # tell Combine to take the rate from the histogram
cb.cp().mass([masses[0],'*']).WriteDatacard(outfname_txt,outfile_root)
outfile_root.Close()
But it's a bit ugly, and it overwrites the text file for each signal point, but all signal histograms in the ROOT file seem to retain the integral of their initial value.
Tagging @anigamova