#include <unfold.h>
Utility class, to unfold distributions directly from Root histograms Cint/Python/Ruby interpreters. Example of use with Cint:
{
gROOT->Reset();
gSystem->Exec("cd ../lib; gmake unfold_shared");
gSystem->Load("../lib/libunfold.so");
gStyle->SetOptStat(0);
TFile* hfile = new TFile ("unfold_input_10000.root");
TH1F* hdata = (TH1F*)hfile->Get("hdata");
TH2F* hmigr = (TH2F*)hfile->Get("hmigr");
TH1F* hbkg = (TH1F*)hfile->Get("hbkg");
TH1F* hgen[5] = {NULL};
TH1F* htrue_binning = NULL;
AMSUnfold* unfold = new AMSUnfold();
unfold->SetData(hdata);
unfold->SetMigrationMatrix(hmigr);
unfold->SetBackground(hbkg);
TH1F* htest = unfold->GetTest();
TH1F* hdata_nobkg = (TH1F*)hdata->Clone();
hdata_nobkg->Add(hdata,hbkg,+1.,-1.);
char* chmethod[5] = {
"Exact Inversion",
"Bayesian Unfolding",
"Tikhonov regularization",
"CDelgado regularization",
"JAlcaraz unfolding"};
TCanvas* c1 = new TCanvas("c1","Unfolding tests",1024.,768.);
c1->Divide(2,2);
for (int method=1; method<=4; method++) {
c1->cd(method);
TH1F* hgen_tmp = unfold->Unfold(method);
hgen[method] = (TH1F*)hgen_tmp->Clone();
if (method==3) htrue_binning = unfold->true_binning();
if (method==3) {
htrue_binning->SetMarkerStyle(20);
htrue_binning->Draw("e0");
} else {
hgen[method]->SetMarkerStyle(20);
hgen[method]->Draw("e0");
}
htest->Draw("histsame");
htest->SetXTitle("Unfolded variable");
hdata_nobkg->SetLineStyle(2);
hdata_nobkg->Draw("histsame");
TText *t = new TText();
t->SetTextSize(0.04);
t->SetTextAlign(12);
t->DrawText(0.15,1600,chmethod[method]);
t->DrawText(0.15,1400,"Theory (predicted)");
t->DrawText(0.15,1200,"Original data distribution");
TGraph *graph = new TGraph(1);
graph->SetMarkerStyle(20);
graph->SetMarkerSize(1);
graph->SetPoint(0,0.1,1600.);
graph->Draw("P");
TLine *line = new TLine(0.08,1400.,0.12,1400.);
line->SetLineStyle(1);
line->SetLineWidth(2);
line->Draw();
TLine *line2 = new TLine(0.08,1200.,0.12,1200.);
line2->SetLineStyle(2);
line2->SetLineWidth(2);
line2->Draw();
}
}
Definition at line 19 of file unfold.h.
Public Member Functions | |
| AMSUnfold () | |
| Constructor. | |
| bool | SetData (TH1F *hdata) |
| Set data histogram [ndata] (mandatory). | |
| bool | SetMigrationMatrix (TH2F *hmigr) |
| Set 2D-histogram for the migration matrix [ndata][ngen] (mandatory, it fixes ngen). | |
| bool | SetBackground (TH1F *hbkg) |
| Histogram for the backgrounds (binning as data, optional). | |
| bool | BuildTestHistogram () |
| Build the test histogram. | |
| TH1F * | GetData () |
| Get data histogram. | |
| TH2F * | GetMigrationMatrix () |
| Get migration matrix histogram. | |
| TH1F * | GetBackground () |
| Get background histogram. | |
| TH1F * | GetResult () |
| Get unfolded histogram (result, ngen bins). | |
| TH1F * | GetTest () |
| Get test histogram at generator level (internally built, for tuning/test, ngen bins). | |
| double | MigrationMatrixElement (int i, int j) |
| Get migration matrix bin (i,j). | |
| double | MigrationProbability (int i, int j) |
| Get migration probability from generator bin j to reconstructed bin i. | |
| TH1F * | Unfold (int method=2, int args=0) |
| Unfold using a given method 0: exact inversion 1: Bayesian (also called D'agostini) method 2: Tikhonov regularization from SVD decomposition and relevant #d.o.f. 3: C. Delgado regularization 4: J. Alcaraz unfolding. | |
| TH1F * | Exact_Inversion () |
| Exact inversion/solution (not what you want in general). | |
| TH1F * | Unfold_Bayesian (int iterations=-1) |
| Simple Bayesian unfolding method. | |
| TH1F * | Unfold_Tikhonov (double smooth_param=-1.) |
| Tikhonov regularisation using SVD decomposition and relevant Ndof. | |
| TH1F * | Unfold_CDelgado (int order=0) |
| C. Delgado regularisation method. | |
| TH1F * | Unfold_JAlcaraz (double sigma_cut=1.0) |
| J. Alcaraz unfolding method to test MC predictions. | |
Static Public Member Functions | |
| AMSUnfold * | GetStaticPointer () |
| Get the pointer to AMSUnfold static object. | |
Protected Member Functions | |
| bool | SetErrors_SVD (bool use_mask=false) |
| bool | SetErrors_SVD_with_matrix (TMatrixD &Anew) |
| TH1F * | Unfold_CDelgado_step (int order=0) |
|
|
Exact inversion/solution (not what you want in general). Exact inversion Do SVD Definition at line 810 of file unfold.C. References SetErrors_SVD(). Referenced by Unfold(). |
|
|
* If we prefer to get uncertainties from DATA... * If we prefer to impose uncertainties from MC... Definition at line 1047 of file unfold.C. References MigrationProbability(). Referenced by Exact_Inversion(), and Unfold_JAlcaraz(). |
|
|
* If we prefer to get uncertainties from DATA... Definition at line 1108 of file unfold.C. Referenced by Unfold_Tikhonov(). |
|
|
Simple Bayesian unfolding method. D'Agostini method Initial probabilities Iterations Update _hgen Recalculate probabilities Definition at line 177 of file unfold.C. References MigrationProbability(). Referenced by Unfold(). |
|
|
D'Agostini method Initial probabilities Update _hgen Recompute probabilities Definition at line 315 of file unfold.C. References MigrationProbability(). Referenced by Unfold_CDelgado(). |
|
|
J. Alcaraz unfolding method to test MC predictions. J. Alcaraz SVD + regularization Do SVD Definition at line 849 of file unfold.C. References MigrationProbability(), and SetErrors_SVD(). Referenced by Unfold(). |
|
|
Tikhonov regularisation using SVD decomposition and relevant Ndof. Tikhonov regularization SVD decomposition used to find out the significant degrees of freedom and to set a convenient smoothing parameter The approach is similar (but not equal) to the one used in the Hoecker-Kartvelishvili method J. Alcaraz, April 2005 Do SVD Set smoothing parameter Find the regularised solution Definition at line 716 of file unfold.C. References SetErrors_SVD_with_matrix(). Referenced by Unfold(). |
1.3.5