91 Double_t GenerateEvent(Double_t bgr,
103 t=TMath::Tan((t-0.5)*TMath::Pi())*gamma+mass;
110 static Double_t
const E0=2.4;
111 static Double_t
const N0=2.9;
118 t= -(TMath::Power(1.-t,1./(1.-N0))-1.0)*E0;
129 Double_t DetectorEvent(Double_t mTrue) {
131 static Double_t frac=0.1;
132 static Double_t wideBias=0.03;
133 static Double_t wideSigma=0.5;
134 static Double_t smallBias=0.0;
135 static Double_t smallSigma=0.1;
136 if(rnd->Rndm()>frac) {
137 return rnd->Gaus(mTrue+smallBias,smallSigma);
139 return rnd->Gaus(mTrue+wideBias,wideSigma);
146 TH1::SetDefaultSumw2();
152 Double_t
const luminosityData=100000;
153 Double_t
const luminosityMC=1000000;
154 Double_t
const crossSection=1.0;
156 Int_t
const nDet=250;
157 Int_t
const nGen=100;
158 Double_t
const xminDet=0.0;
159 Double_t
const xmaxDet=10.0;
160 Double_t
const xminGen=0.0;
161 Double_t
const xmaxGen=10.0;
166 TH1D *histMgenMC=
new TH1D(
"MgenMC",
";mass(gen)",nGen,xminGen,xmaxGen);
167 TH1D *histMdetMC=
new TH1D(
"MdetMC",
";mass(det)",nDet,xminDet,xmaxDet);
168 TH2D *histMdetGenMC=
new TH2D(
"MdetgenMC",
";mass(det);mass(gen)",nDet,xminDet,xmaxDet,
169 nGen,xminGen,xmaxGen);
170 Int_t neventMC=rnd->Poisson(luminosityMC*crossSection);
171 for(Int_t i=0;i<neventMC;i++) {
172 Double_t mGen=GenerateEvent(0.3,
175 Double_t mDet=DetectorEvent(TMath::Abs(mGen));
184 histMgenMC->Fill(mGen,luminosityData/luminosityMC);
186 histMdetMC->Fill(mDet,luminosityData/luminosityMC);
201 histMdetGenMC->Fill(mDet,mGen,luminosityData/luminosityMC);
207 TH1D *histMgenData=
new TH1D(
"MgenData",
";mass(gen)",nGen,xminGen,xmaxGen);
208 TH1D *histMdetData=
new TH1D(
"MdetData",
";mass(det)",nDet,xminDet,xmaxDet);
209 Int_t neventData=rnd->Poisson(luminosityData*crossSection);
210 for(Int_t i=0;i<neventData;i++) {
211 Double_t mGen=GenerateEvent(0.4,
214 Double_t mDet=DetectorEvent(TMath::Abs(mGen));
217 histMgenData->Fill(mGen);
220 histMdetData->Fill(mDet);
225 TUnfold unfold(histMdetGenMC,TUnfold::kHistMapOutputVert,
226 TUnfold::kRegModeNone);
241 Double_t estimatedPeakPosition=3.8;
243 TUnfold::ERegMode regMode=TUnfold::kRegModeCurvature;
245 Int_t iPeek=(Int_t)(nGen*(estimatedPeakPosition-xminGen)/(xmaxGen-xminGen)
251 unfold.RegularizeBins(1,1,iPeek-nPeek,regMode);
253 unfold.RegularizeBins(iPeek+nPeek,1,nGen-(iPeek+nPeek),regMode);
259 if(unfold.SetInput(histMdetData,0.0)>=10000) {
260 std::cout<<
"Unfolding result may be wrong\n";
268 TSpline *logTauX,*logTauY;
272 iBest=unfold.ScanLcurve(nScan,tauMin,tauMax,&lCurve,&logTauX,&logTauY);
273 std::cout<<
"tau="<<unfold.GetTau()<<
"\n";
274 std::cout<<
"chi**2="<<unfold.GetChi2A()<<
"+"<<unfold.GetChi2L()
275 <<
" / "<<unfold.GetNdf()<<
"\n";
278 Double_t t[1],x[1],y[1];
279 logTauX->GetKnot(iBest,t[0],x[0]);
280 logTauY->GetKnot(iBest,t[0],y[0]);
281 TGraph *bestLcurve=
new TGraph(1,x,y);
282 TGraph *bestLogTauX=
new TGraph(1,t,x);
290 Int_t *binMap=
new Int_t[nGen+2];
291 for(Int_t i=1;i<=nGen;i++) binMap[i]=i;
295 TH1D *histMunfold=
new TH1D(
"Unfolded",
";mass(gen)",nGen,xminGen,xmaxGen);
296 unfold.GetOutput(histMunfold,binMap);
297 TH1D *histMdetFold=
new TH1D(
"FoldedBack",
"mass(det)",nDet,xminDet,xmaxDet);
298 unfold.GetFoldedOutput(histMdetFold);
301 TH1D *histRhoi=
new TH1D(
"rho_I",
"mass",nGen,xminGen,xmaxGen);
302 unfold.GetRhoI(histRhoi,binMap);
321 histMdetGenMC->Draw(
"BOX");
328 histMunfold->SetLineColor(kBlue);
330 histMgenData->SetLineColor(kRed);
331 histMgenData->Draw(
"SAME");
332 histMgenMC->Draw(
"SAME HIST");
339 histMdetFold->SetLineColor(kBlue);
340 histMdetFold->Draw();
341 histMdetData->SetLineColor(kRed);
342 histMdetData->Draw(
"SAME");
343 histMdetMC->Draw(
"SAME HIST");
356 bestLogTauX->SetMarkerColor(kRed);
357 bestLogTauX->Draw(
"*");
361 bestLcurve->SetMarkerColor(kRed);
362 bestLcurve->Draw(
"*");
364 output.SaveAs(
"testUnfold2.ps");