This is an example of unfolding a two-dimensional distribution also using an auxiliary measurement to constrain some background
#include <iostream>
#include <fstream>
using std::ofstream;
void testUnfold5b()
{
TFile *binningSchemes=
new TFile(
"testUnfold5_binning.root",
"recreate");
#define NBIN_PT_FINE 8
#define NBIN_ETA_FINE 10
#define NBIN_DISCR 4
#define NBIN_PT_COARSE 3
#define NBIN_ETA_COARSE 3
{3.5,4.0,4.5,5.0,6.0,7.0,8.0,10.0,13.0};
Double_t ptBinsCoarse[NBIN_PT_COARSE+1]=
{ 4.0, 5.0, 7.0, 10.0};
{-3.,-2.5,-2.0,-1.,-0.5,0.0,0.5,1.,2.,2.5,3.};
Double_t etaBinsCoarse[NBIN_ETA_COARSE+1]=
{ -2.0, -0.5, 0.5, 2. };
Double_t discrBins[NBIN_DISCR+1]={0.,0.15,0.5,0.85,1.0};
detectorBinning->
AddBinning(
"detectordistribution");
detectorDistribution->
AddAxis(
"pt",NBIN_PT_FINE,ptBinsFine,
false,
true
);
detectorDistribution->
AddAxis(
"eta",NBIN_ETA_FINE,etaBinsFine,
false,
false
);
detectorDistribution->
AddAxis(
"discriminator",NBIN_DISCR,discrBins,
false,
false
);
signalBinning->
AddAxis(
"ptgen",NBIN_PT_COARSE,ptBinsCoarse,
true,
true
);
signalBinning->
AddAxis(
"etagen",NBIN_ETA_COARSE,etaBinsCoarse,
true,
true
);
TF2 *userFunc=
new TF2(
"userfunc",
"1./x+0.2*y^2",ptBinsCoarse[0],
ptBinsCoarse[NBIN_PT_COARSE],
etaBinsCoarse[0],etaBinsCoarse[NBIN_ETA_COARSE]);
bgrBinning->
AddAxis(
"ptrec",NBIN_PT_FINE,ptBinsFine,
false,
true
);
bgrBinning->
AddAxis(
"etarec",NBIN_ETA_FINE,etaBinsFine,
false,
false
);
detectorBinning->
Write();
generatorBinning->
Write();
ofstream xmlOut("testUnfold5binning.xml");
xmlOut.close();
delete binningSchemes;
}
A 2-Dim function with parameters.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
static Int_t ExportXML(const TUnfoldBinning &binning, std::ostream &out, Bool_t writeHeader, Bool_t writeFooter, Int_t indent=0)
export a binning scheme to a stream in XML format
static void WriteDTD(const char *fileName="tunfoldbinning.dtd")
write dtd file
Binning schemes for use with the unfolding algorithm TUnfoldDensity.
void PrintStream(std::ostream &out, Int_t indent=0, int debug=0) const
print some information about this binning tree
void SetBinFactorFunction(Double_t normalisation, TF1 *userFunc=nullptr)
set normalisation factor and function which are used in calls to GetBinFactor()
TUnfoldBinning * AddBinning(TUnfoldBinning *binning)
add a TUnfoldBinning as the last child of this node
Bool_t AddAxis(const char *name, Int_t nBins, const Double_t *binBorders, Bool_t hasUnderflow, Bool_t hasOverflow)
add an axis with the specified bin borders