Test program for the classes TUnfoldDensity and TUnfoldBinning.
A toy test of the TUnfold package
This is an example of unfolding a two-dimensional distribution also using an auxiliary measurement to constrain some background
The example comprises several macros
- testUnfold5a.C create root files with TTree objects for signal, background and data
- write files testUnfold5_signal.root testUnfold5_background.root testUnfold5_data.root
- testUnfold5b.C create a root file with the TUnfoldBinning objects
- write file testUnfold5_binning.root
- testUnfold5c.C loop over trees and fill histograms based on the TUnfoldBinning objects
- read testUnfold5_binning.root testUnfold5_signal.root testUnfold5_background.root testUnfold5_data.root
- write testUnfold5_histograms.root
- testUnfold5d.C run the unfolding
- read testUnfold5_histograms.root
- write testUnfold5_result.root testUnfold5_result.ps
0.00999402999878
3.72628998756
Processing /mnt/build/workspace/root-makedoc-v614/rootspi/rdoc/src/v6-14-00-patches/tutorials/unfold/testUnfold5b.C...
TUnfoldBinning "generator" has 115 bins [1,116] nTH1x=115
TUnfoldBinning "signal" has 25 bins [1,26] nTH1x=25
distribution: 25 bins
"ptgen" nbin=3 plus underflow plus overflow
"etagen" nbin=3 plus underflow plus overflow
TUnfoldBinning "background" has 90 bins [26,116] nTH1x=90
distribution: 90 bins
"ptrec" nbin=8 plus overflow
"etarec" nbin=10
#include <iostream>
#include <fstream>
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;
}
Version 17.6, in parallel to changes in TUnfold
History:
- Version 17.5, updated for writing out XML code
- Version 17.4, updated for writing out XML code
- Version 17.3, updated for writing out XML code
- Version 17.2, updated for writing out XML code
- Version 17.1, in parallel to changes in TUnfold
- Version 17.0 example for multi-dimensional unfolding
This file is part of TUnfold.
TUnfold is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
TUnfold is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with TUnfold. If not, see http://www.gnu.org/licenses/.
- Author
- Stefan Schmitt DESY, 14.10.2008
Definition in file testUnfold5b.C.