69 while((
r<nmax)&&(
f>=probability[
r])) {
88 r=rnd->
Gaus(shapeParm[1],shapeParm[2]);
90 r=rnd->
Rndm()*(shapeParm[4]-shapeParm[3])+shapeParm[3];
95void testUnfold4(
bool printInfo =
false)
124 static const Double_t genFrac[]={0.3,0.6,0.1};
127 static const Double_t genShape[][5]=
128 {{1.0,2.0,1.5,0.,15.},
129 {1.0,7.0,2.5,0.,15.},
130 {0.0,0.0,0.0,0.,15.}};
134 TH1D *histDetDATA=
new TH1D(
"Yrec",
";DATA(Yrec)",nDet,xminDet,xmaxDet);
138 TH2D *histGenDetMC=
new TH2D(
"Yrec%Xgen",
"MC(Xgen,Yrec)",
139 nGen,xminGen,xmaxGen,nDet,xminDet,xmaxDet);
141 TH1D *histUnfold=
new TH1D(
"Xgen",
";DATA(Xgen)",nGen,xminGen,xmaxGen);
144 TH1D **histPullArea=
new TH1D* [nGen];
145 for(
int i=0;i<nGen;i++) {
153 for(
int itoy=0;itoy<1000;itoy++) {
154 if(!(itoy %10)) cout<<
"toy iteration: "<<itoy<<
"\n";
155 histDetDATA->
Reset();
156 histGenDetMC->
Reset();
159 for(
Int_t i=0;i<nData;i++) {
160 Int_t iGen=GenerateGenEvent(nGen,genFrac);
161 Double_t yObs=GenerateRecEvent(genShape[iGen]);
162 histDetDATA->
Fill(yObs);
166 for(
Int_t i=0;i<nMC;i++) {
167 Int_t iGen=GenerateGenEvent(nGen,genFrac);
168 Double_t yObs=GenerateRecEvent(genShape[iGen]);
169 histGenDetMC->
Fill(iGen,yObs);
182 unfold.SetInput(histDetDATA,0.0,1.0);
185 unfold.ScanLcurve(50,0.,0.,
nullptr,
nullptr,
nullptr);
188 unfold.GetOutput(histUnfold);
190 for(
int i=0;i<nGen;i++) {
199 unfold.ScanLcurve(50,0.,0.,
nullptr,
nullptr,
nullptr);
202 unfold.GetOutput(histUnfold);
204 for(
int i=0;i<nGen;i++) {
215 for(
int i=0;i<nGen;i++) {
217 histPullNC[i]->
Fit(
"gaus");
218 histPullNC[i]->
Draw();
220 for(
int i=0;i<nGen;i++) {
222 histPullArea[i]->
Fit(
"gaus");
223 histPullArea[i]->
Draw();
225 output.
SaveAs(
"testUnfold4.ps");
int Int_t
Signed integer 4 bytes (int).
double Double_t
Double 8 bytes.
externInt_t gErrorIgnoreLevel
errors with level below this value will be ignored. Default is kUnset.
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
1-D histogram with a double per channel (see TH1 documentation)
void Reset(Option_t *option="") override
Reset.
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
Fit histogram with function fname.
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
void Draw(Option_t *option="") override
Draw this histogram with options.
static void SetDefaultSumw2(Bool_t sumw2=kTRUE)
When this static function is called with sumw2=kTRUE, all new histograms will automatically activate ...
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
2-D histogram with a double per channel (see TH1 documentation)
void Reset(Option_t *option="") override
Reset this histogram: contents, errors, etc.
Int_t Fill(Double_t) override
Invalid Fill method.
void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override
Automatic pad generation by division.
void SaveAs(const char *filename="", Option_t *option="") const override
Save the pad content in a file.
Random number generator class based on M.
This is the base class for the ROOT Random number generators.
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
Double_t Rndm() override
Machine independent random number generator.
virtual ULong64_t Poisson(Double_t mean)
Generates a random integer N according to a Poisson law.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
An algorithm to unfold distributions from detector to truth level, with background subtraction and pr...
static const char * GetTUnfoldVersion(void)
return a string describing the TUnfold version
@ kEConstraintArea
enforce preservation of the area
@ kEConstraintNone
use no extra constraint
@ kRegModeSize
regularise the amplitude of the output distribution
@ kHistMapOutputHoriz
truth level on x-axis of the response matrix