Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TUnfold.h
Go to the documentation of this file.
1// Author: Stefan Schmitt
2// DESY, 13/10/08
3
4// Version 17.9, add new methods GetDF(), GetSURE(), ScanSURE(), GetSqrtEvEmatrix()
5//
6// History:
7// Version 17.8, add new method GetDXDY() for histograms
8// Version 17.7, updates in the TUnfold implementation
9// Version 17.6, updated doxygen-style comments, add one argument for scanLCurve
10// Version 17.5, fix memory leak and other bugs
11// Version 17.4, in parallel to changes in TUnfoldBinning
12// Version 17.3, in parallel to changes in TUnfoldBinning
13// Version 17.2, in parallel to changes in TUnfoldBinning
14// Version 17.1, bug fixes in GetFoldedOutput, GetOutput
15// Version 17.0, error matrix with SetInput, store fL not fLSquared
16// Version 16.2, in parallel to bug-fix in TUnfoldSys
17// Version 16.1, in parallel to bug-fix in TUnfold.C
18// Version 16.0, some cleanup, more getter functions, query version number
19// Version 15, simplified L-curve scan, new tau definition, new eror calc.
20// Version 14, with changes in TUnfoldSys.cxx
21// Version 13, new methods for derived classes
22// Version 12, with support for preconditioned matrix inversion
23// Version 11, regularisation methods have return values
24// Version 10, with bug-fix in TUnfold.cxx
25// Version 9, implements method for optimized inversion of sparse matrix
26// Version 8, replace all TMatrixSparse matrix operations by private code
27// Version 7, fix problem with TMatrixDSparse,TMatrixD multiplication
28// Version 6, completely remove definition of class XY
29// Version 5, move definition of class XY from TUnfold.C to this file
30// Version 4, with bug-fix in TUnfold.C
31// Version 3, with bug-fix in TUnfold.C
32// Version 2, with changed ScanLcurve() arguments
33// Version 1, added ScanLcurve() method
34// Version 0, stable version of basic unfolding algorithm
35
36
37#ifndef ROOT_TUnfold
38#define ROOT_TUnfold
39
40//////////////////////////////////////////////////////////////////////////
41// //
42// //
43// TUnfold provides functionality to correct data //
44// for migration effects. //
45// //
46// Citation: S.Schmitt, JINST 7 (2012) T10003 [arXiv:1205.6201] //
47// //
48// //
49// TUnfold solves the inverse problem //
50// //
51// T -1 2 T //
52// chi**2 = (y-Ax) Vyy (y-Ax) + tau (L(x-x0)) L(x-x0) //
53// //
54// Monte Carlo input //
55// y: vector of measured quantities (dimension ny) //
56// Vyy: covariance matrix for y (dimension ny x ny) //
57// A: migration matrix (dimension ny x nx) //
58// x: unknown underlying distribution (dimension nx) //
59// Regularisation //
60// tau: parameter, defining the regularisation strength //
61// L: matrix of regularisation conditions (dimension nl x nx) //
62// x0: underlying distribution bias //
63// //
64// where chi**2 is minimized as a function of x //
65// //
66// The algorithm is based on "standard" matrix inversion, with the //
67// known limitations in numerical accuracy and computing cost for //
68// matrices with large dimensions. //
69// //
70// Thus the algorithm should not used for large dimensions of x and y //
71// dim(x) should not exceed O(100) //
72// dim(y) should not exceed O(500) //
73// //
74//////////////////////////////////////////////////////////////////////////
75
76/*
77 This file is part of TUnfold.
78
79 TUnfold is free software: you can redistribute it and/or modify
80 it under the terms of the GNU General Public License as published by
81 the Free Software Foundation, either version 3 of the License, or
82 (at your option) any later version.
83
84 TUnfold is distributed in the hope that it will be useful,
85 but WITHOUT ANY WARRANTY; without even the implied warranty of
86 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
87 GNU General Public License for more details.
88
89 You should have received a copy of the GNU General Public License
90 along with TUnfold. If not, see <http://www.gnu.org/licenses/>.
91*/
92
93#include <TH1D.h>
94#include <TH2D.h>
95#include <TGraph.h>
96#include <TObject.h>
97#include <TArrayI.h>
98#include <TSpline.h>
99#include <TMatrixDSparse.h>
100#include <TMatrixD.h>
101#include <TObjArray.h>
102#include <TString.h>
103
104#define TUnfold_VERSION "V17.9"
105#define TUnfold_CLASS_VERSION 17
106
107class TUnfold : public TObject {
108 private:
109 void InitTUnfold(void); // initialize all data members
110 public:
111
112 /// type of extra constraint
114
115 /// use no extra constraint
117
118 /// enforce preservation of the area
120 };
121
122 /// choice of regularisation scheme
123 enum ERegMode {
124
125 /// no regularisation, or defined later by RegularizeXXX() methods
127
128 /// regularise the amplitude of the output distribution
130
131 /// regularize the 1st derivative of the output distribution
133
134 /// regularize the 2nd derivative of the output distribution
136
137
138 /// mixed regularisation pattern
139 kRegModeMixed = 4
140 };
141
142 /// arrangement of axes for the response matrix (TH2 histogram)
143 enum EHistMap {
144
145 /// truth level on x-axis of the response matrix
147
148 /// truth level on y-axis of the response matrix
150 };
151
152 protected:
153 /// response matrix A
155 /// regularisation conditions L
157 /// input (measured) data y
159 /// covariance matrix Vyy corresponding to y
161 /// scale factor for the bias
163 /// bias vector x0
165 /// regularisation parameter tau squared
167 /// mapping of matrix indices to histogram bins
169 /// mapping of histogram bins to matrix indices
171 /// truth vector calculated from the non-normalized response matrix
173 /// type of constraint to use for the unfolding
175 /// type of regularisation
177 private:
178 /// number of input bins which are dropped because they have error=nullptr
180 /// machine accuracy used to determine matrix rank after eigenvalue analysis
182 /// unfolding result x
184 /// covariance matrix Vxx
186 /// inverse of covariance matrix Vxx<sup>-1</sup>
188 /// inverse of the input covariance matrix Vyy<sup>-1</sup>
190 /// result x folded back A*x
192 /// chi**2 contribution from (y-Ax)Vyy<sup>-1</sup>(y-Ax)
194 /// chi**2 contribution from (x-s*x0)<sup>T</sup>L<sup>T</sup>L(x-s*x0)
196 /// maximum global correlation coefficient
198 /// average global correlation coefficient
200 /// number of degrees of freedom
202 /// matrix contribution to the of derivative dx_k/dA_ij
204 /// vector contribution to the of derivative dx_k/dA_ij
206 /// derivative of the result wrt tau squared
208 /// derivative of the result wrt dx/dy
210 /// matrix E^(-1)
212 /// matrix E
214 protected:
215 // Int_t IsNotSymmetric(TMatrixDSparse const &m) const;
216 virtual Double_t DoUnfold(void); // the unfolding algorithm
217 virtual void ClearResults(void); // clear all results
218 void ClearHistogram(TH1 *h,Double_t x=0.) const;
219 virtual TString GetOutputBinName(Int_t iBinX) const; // name a bin
220 TMatrixDSparse *MultiplyMSparseM(const TMatrixDSparse *a,const TMatrixD *b) const; // multiply sparse and non-sparse matrix
221 TMatrixDSparse *MultiplyMSparseMSparse(const TMatrixDSparse *a,const TMatrixDSparse *b) const; // multiply sparse and sparse matrix
222 TMatrixDSparse *MultiplyMSparseTranspMSparse(const TMatrixDSparse *a,const TMatrixDSparse *b) const; // multiply transposed sparse and sparse matrix
224 (const TMatrixDSparse *m1,const TMatrixDSparse *m2,
225 const TMatrixTBase<Double_t> *v) const; // calculate M_ij = sum_k [m1_ik*m2_jk*v[k] ]. the pointer v may be zero (means no scaling).
226 TMatrixDSparse *InvertMSparseSymmPos(const TMatrixDSparse *A,Int_t *rank) const; // invert symmetric (semi-)positive sparse matrix
227 void AddMSparse(TMatrixDSparse *dest,Double_t f,const TMatrixDSparse *src) const; // replacement for dest += f*src
228 TMatrixDSparse *CreateSparseMatrix(Int_t nrow,Int_t ncol,Int_t nele,Int_t *row,Int_t *col,Double_t *data) const; // create a TMatrixDSparse from an array
229 /// returns internal number of output (truth) matrix rows
230 inline Int_t GetNx(void) const {
231 return fA->GetNcols();
232 }
233 /// converts truth histogram bin number to matrix row
234 inline Int_t GetRowFromBin(int ix) const { return fHistToX[ix]; }
235 /// converts matrix row to truth histogram bin number
236 inline Int_t GetBinFromRow(int ix) const { return fXToHist[ix]; }
237 /// returns the number of measurement bins
238 inline Int_t GetNy(void) const {
239 return fA->GetNrows();
240 }
241 /// vector of the unfolding result
242 inline const TMatrixD *GetX(void) const { return fX; }
243 /// covariance matrix of the result
244 inline const TMatrixDSparse *GetVxx(void) const { return fVxx; }
245 /// inverse of covariance matrix of the result
246 inline const TMatrixDSparse *GetVxxInv(void) const { return fVxxInv; }
247 /// vector of folded-back result
248 inline const TMatrixDSparse *GetAx(void) const { return fAx; }
249 /// matrix of derivatives dx/dy
250 inline const TMatrixDSparse *GetDXDY(void) const { return fDXDY; }
251 /// matrix contributions of the derivative dx/dA
252 inline const TMatrixDSparse *GetDXDAM(int i) const { return fDXDAM[i]; }
253 /// vector contributions of the derivative dx/dA
254 inline const TMatrixDSparse *GetDXDAZ(int i) const { return fDXDAZ[i]; }
255 /// matrix E<sup>-1</sup>, using internal bin counting
256 inline const TMatrixDSparse *GetEinv(void) const { return fEinv; }
257 /// matrix E, using internal bin counting
258 inline const TMatrixDSparse *GetE(void) const { return fE; }
259 /// inverse of covariance matrix of the data y
260 inline const TMatrixDSparse *GetVyyInv(void) const { return fVyyInv; }
261
262 void ErrorMatrixToHist(TH2 *ematrix,const TMatrixDSparse *emat,const Int_t *binMap,Bool_t doClear) const; // return an error matrix as histogram
263 Double_t GetRhoIFromMatrix(TH1 *rhoi,const TMatrixDSparse *eOrig,const Int_t *binMap,TH2 *invEmat) const; // return global correlation coefficients
264 /// vector of derivative dx/dtauSquared, using internal bin counting
265 inline const TMatrixDSparse *GetDXDtauSquared(void) const { return fDXDtauSquared; }
266 /// delete matrix and invalidate pointer
267 static void DeleteMatrix(TMatrixD **m);
268 /// delete sparse matrix and invalidate pointer
269 static void DeleteMatrix(TMatrixDSparse **m);
270
271 Bool_t AddRegularisationCondition(Int_t i0,Double_t f0,Int_t i1=-1,Double_t f1=0.,Int_t i2=-1,Double_t f2=0.); // add regularisation condition for a triplet of output bins
272 Bool_t AddRegularisationCondition(Int_t nEle,const Int_t *indices,const Double_t *rowData); // add a regularisation condition
273public:
274 static const char*GetTUnfoldVersion(void);
275 // Set up response matrix and regularisation scheme
276 TUnfold(const TH2 *hist_A, EHistMap histmap,
277 ERegMode regmode = kRegModeSize,
278 EConstraint constraint=kEConstraintArea);
279 // for root streamer and derived classes
280 TUnfold(void);
281 ~TUnfold(void) override;
282 // define input distribution
283 virtual Int_t SetInput(const TH1 *hist_y, Double_t scaleBias=0.0,Double_t oneOverZeroError=0.0,const TH2 *hist_vyy=nullptr,const TH2 *hist_vyy_inv=nullptr);
284 // Unfold with given choice of tau and input
285 virtual Double_t DoUnfold(Double_t tau);
286 Double_t DoUnfold(Double_t tau,const TH1 *hist_y, Double_t scaleBias=0.0);
287 // scan the L curve using successive calls to DoUnfold(Double_t) at various tau
288 virtual Int_t ScanLcurve(Int_t nPoint,Double_t tauMin,
289 Double_t tauMax,TGraph **lCurve,
290 TSpline **logTauX=nullptr,TSpline **logTauY=nullptr,
291 TSpline **logTauCurvature=nullptr);
292 // minimize Stein's unbiased risk estimator using successive calls to DoUnfold at various tau. Optionally, the contributions to SURE (DF and Chi2A) or the L-curve are saved
293 virtual Int_t ScanSURE(Int_t nPoint,Double_t tauMin,
294 Double_t tauMax,
295 TGraph **logTauSURE=nullptr,
296 TGraph **df_chi2A=nullptr,
297 TGraph **lCurve=nullptr);
298 // calculate square roots of the Eigenvalues of the Error matrix
299 TVectorD GetSqrtEvEmatrix(void) const;
300 // access unfolding results
301 Double_t GetTau(void) const;
302 void GetOutput(TH1 *output,const Int_t *binMap=nullptr) const;
303 void GetEmatrix(TH2 *ematrix,const Int_t *binMap=nullptr) const;
304 void GetRhoIJ(TH2 *rhoij,const Int_t *binMap=nullptr) const;
305 Double_t GetRhoI(TH1 *rhoi,const Int_t *binMap=nullptr,TH2 *invEmat=nullptr) const;
306 void GetFoldedOutput(TH1 *folded,const Int_t *binMap=nullptr) const;
307
308 double GetDF(void) const; // effective number of degrees of freedom
309 double GetSURE(void) const; // Stein's unbiased risk estimator
310
311 // access input parameters
312 void GetProbabilityMatrix(TH2 *A,EHistMap histmap) const;
313 void GetNormalisationVector(TH1 *s,const Int_t *binMap=nullptr) const; // get the vector of normalisation factors, equivalent to the initial bias vector
314 void GetInput(TH1 *inputData,const Int_t *binMap=nullptr) const; // get input data
315 void GetInputInverseEmatrix(TH2 *ematrix); // get input data inverse of error matrix
316 void GetBias(TH1 *bias,const Int_t *binMap=nullptr) const; // get bias (includind biasScale)
317 Int_t GetNr(void) const; // number of regularisation conditions
318 void GetL(TH2 *l) const; // get matrix of regularisation conditions
319 void GetLsquared(TH2 *lsquared) const;
320
321 // access various properties of the result
322 /// get matrix connecting input and output changes
323 void GetDXDY(TH2 *dxdy) const;
324 /// get maximum global correlation determined in recent unfolding
325 inline Double_t GetRhoMax(void) const { return fRhoMax; }
326 /// get average global correlation determined in recent unfolding
327 inline Double_t GetRhoAvg(void) const { return fRhoAvg; }
328 /// get &chi;<sup>2</sup><sub>A</sub> contribution determined in recent unfolding
329 inline Double_t GetChi2A(void) const { return fChi2A; }
330
331 Double_t GetChi2L(void) const; // get &chi;<sup>2</sup><sub>L</sub> contribution determined in recent unfolding
332 virtual Double_t GetLcurveX(void) const; // get value on x axis of L curve
333 virtual Double_t GetLcurveY(void) const; // get value on y axis of L curve
334 /// get number of degrees of freedom determined in recent unfolding
335 ///
336 /// This returns the number of valid measurements minus the number
337 /// of unfolded truth bins. If the area constraint is active, one
338 /// further degree of freedom is subtracted
339 inline Int_t GetNdf(void) const { return fNdf; }
340 Int_t GetNpar(void) const; // get number of parameters
341
342 // advanced features
343 void SetBias(const TH1 *bias); // set alternative bias
344 void SetConstraint(EConstraint constraint); // set type of constraint for the next unfolding
345 Int_t RegularizeSize(int bin, Double_t scale = 1.0); // regularise the size of one output bin
346 Int_t RegularizeDerivative(int left_bin, int right_bin, Double_t scale = 1.0); // regularize difference of two output bins (1st derivative)
347 Int_t RegularizeCurvature(int left_bin, int center_bin, int right_bin, Double_t scale_left = 1.0, Double_t scale_right = 1.0); // regularize curvature of three output bins (2nd derivative)
348 Int_t RegularizeBins(int start, int step, int nbin, ERegMode regmode); // regularize a 1-dimensional curve
349 Int_t RegularizeBins2D(int start_bin, int step1, int nbin1, int step2, int nbin2, ERegMode regmode); // regularize a 2-dimensional grid
350 /// get numerical accuracy for Eigenvalue analysis when inverting
351 /// matrices with rank problems
352 inline Double_t GetEpsMatrix(void) const { return fEpsMatrix; }
353 /// set numerical accuracy for Eigenvalue analysis when inverting
354 /// matrices with rank problems
355 void SetEpsMatrix(Double_t eps); // set accuracy for eigenvalue analysis
356
357 ClassDefOverride(TUnfold, TUnfold_CLASS_VERSION) //Unfolding with support for L-curve analysis
358};
359
360#endif
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define a(i)
Definition RSha256.hxx:99
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t dest
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
#define TUnfold_CLASS_VERSION
Definition TUnfold.h:105
Array of doubles (64 bits per element).
Definition TArrayD.h:27
Array of integers (32 bits per element).
Definition TArrayI.h:27
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
Service class for 2-D histogram classes.
Definition TH2.h:30
TMatrixTBase.
Int_t GetNrows() const
Int_t GetNcols() const
Mother of all ROOT objects.
Definition TObject.h:41
Base class for spline implementation containing the Draw/Paint methods.
Definition TSpline.h:31
Basic string class.
Definition TString.h:139
An algorithm to unfold distributions from detector to truth level.
Definition TUnfold.h:107
TArrayI fHistToX
mapping of histogram bins to matrix indices
Definition TUnfold.h:170
double GetDF(void) const
return the effecive number of degrees of freedom See e.g.
Definition TUnfold.cxx:3749
TMatrixDSparse * fE
matrix E
Definition TUnfold.h:213
TMatrixDSparse * fEinv
matrix E^(-1)
Definition TUnfold.h:211
virtual Double_t GetLcurveY(void) const
get value on y-axis of L-curve determined in recent unfolding
Definition TUnfold.cxx:3260
TMatrixDSparse * fAx
result x folded back A*x
Definition TUnfold.h:191
TMatrixDSparse * MultiplyMSparseM(const TMatrixDSparse *a, const TMatrixD *b) const
multiply sparse matrix and a non-sparse matrix
Definition TUnfold.cxx:760
virtual Double_t DoUnfold(void)
core unfolding algorithm
Definition TUnfold.cxx:246
Double_t fChi2A
chi**2 contribution from (y-Ax)Vyy-1(y-Ax)
Definition TUnfold.h:193
TMatrixD * fX0
bias vector x0
Definition TUnfold.h:164
double GetSURE(void) const
return Stein's unbiased risk estimator See e.g.
Definition TUnfold.cxx:3732
void GetBias(TH1 *bias, const Int_t *binMap=nullptr) const
get bias vector including bias scale
Definition TUnfold.cxx:2935
TMatrixDSparse * MultiplyMSparseTranspMSparse(const TMatrixDSparse *a, const TMatrixDSparse *b) const
multiply a transposed Sparse matrix with another Sparse matrix
Definition TUnfold.cxx:678
TMatrixDSparse * MultiplyMSparseMSparseTranspVector(const TMatrixDSparse *m1, const TMatrixDSparse *m2, const TMatrixTBase< Double_t > *v) const
calculate a sparse matrix product M1*V*M2T where the diagonal matrix V is given by a vector
Definition TUnfold.cxx:820
TMatrixDSparse * CreateSparseMatrix(Int_t nrow, Int_t ncol, Int_t nele, Int_t *row, Int_t *col, Double_t *data) const
create a sparse matrix, given the nonzero elements
Definition TUnfold.cxx:579
Int_t RegularizeSize(int bin, Double_t scale=1.0)
add a regularisation condition on the magnitude of a truth bin
Definition TUnfold.cxx:2025
Double_t fEpsMatrix
machine accuracy used to determine matrix rank after eigenvalue analysis
Definition TUnfold.h:181
const TMatrixDSparse * GetDXDAM(int i) const
matrix contributions of the derivative dx/dA
Definition TUnfold.h:252
void GetProbabilityMatrix(TH2 *A, EHistMap histmap) const
get matrix of probabilities
Definition TUnfold.cxx:3010
Double_t GetChi2L(void) const
get χ2L contribution determined in recent unfolding
Definition TUnfold.cxx:3231
TMatrixDSparse * fVxx
covariance matrix Vxx
Definition TUnfold.h:185
Int_t GetNy(void) const
returns the number of measurement bins
Definition TUnfold.h:238
Double_t GetRhoMax(void) const
get maximum global correlation determined in recent unfolding
Definition TUnfold.h:325
virtual TString GetOutputBinName(Int_t iBinX) const
Get bin name of an outpt bin.
Definition TUnfold.cxx:1667
Double_t fBiasScale
scale factor for the bias
Definition TUnfold.h:162
virtual Int_t ScanSURE(Int_t nPoint, Double_t tauMin, Double_t tauMax, TGraph **logTauSURE=nullptr, TGraph **df_chi2A=nullptr, TGraph **lCurve=nullptr)
minimize Stein's unbiased risk estimator "SURE" using successive calls to DoUnfold at various tau.
Definition TUnfold.cxx:3786
virtual Int_t ScanLcurve(Int_t nPoint, Double_t tauMin, Double_t tauMax, TGraph **lCurve, TSpline **logTauX=nullptr, TSpline **logTauY=nullptr, TSpline **logTauCurvature=nullptr)
scan the L curve, determine tau and unfold at the final value of tau
Definition TUnfold.cxx:2558
const TMatrixDSparse * GetDXDtauSquared(void) const
vector of derivative dx/dtauSquared, using internal bin counting
Definition TUnfold.h:265
Double_t fRhoAvg
average global correlation coefficient
Definition TUnfold.h:199
TMatrixDSparse * fDXDtauSquared
derivative of the result wrt tau squared
Definition TUnfold.h:207
static void DeleteMatrix(TMatrixD **m)
delete matrix and invalidate pointer
Definition TUnfold.cxx:188
Int_t GetBinFromRow(int ix) const
converts matrix row to truth histogram bin number
Definition TUnfold.h:236
void ClearHistogram(TH1 *h, Double_t x=0.) const
Initialize bin contents and bin errors for a given histogram.
Definition TUnfold.cxx:3680
Int_t RegularizeDerivative(int left_bin, int right_bin, Double_t scale=1.0)
add a regularisation condition on the difference of two truth bin
Definition TUnfold.cxx:2059
Int_t GetNx(void) const
returns internal number of output (truth) matrix rows
Definition TUnfold.h:230
const TMatrixDSparse * GetDXDAZ(int i) const
vector contributions of the derivative dx/dA
Definition TUnfold.h:254
static const char * GetTUnfoldVersion(void)
return a string describing the TUnfold version
Definition TUnfold.cxx:3717
void SetConstraint(EConstraint constraint)
set type of area constraint
Definition TUnfold.cxx:3211
void GetFoldedOutput(TH1 *folded, const Int_t *binMap=nullptr) const
get unfolding result on detector level
Definition TUnfold.cxx:2962
Int_t RegularizeBins(int start, int step, int nbin, ERegMode regmode)
add regularisation conditions for a group of bins
Definition TUnfold.cxx:2143
Bool_t AddRegularisationCondition(Int_t i0, Double_t f0, Int_t i1=-1, Double_t f1=0., Int_t i2=-1, Double_t f2=0.)
add a row of regularisation conditions to the matrix L
Definition TUnfold.cxx:1918
Int_t RegularizeCurvature(int left_bin, int center_bin, int right_bin, Double_t scale_left=1.0, Double_t scale_right=1.0)
add a regularisation condition on the curvature of three truth bin
Definition TUnfold.cxx:2098
void SetBias(const TH1 *bias)
set bias vector
Definition TUnfold.cxx:1895
void GetL(TH2 *l) const
get matrix of regularisation conditions
Definition TUnfold.cxx:3191
ERegMode fRegMode
type of regularisation
Definition TUnfold.h:176
Int_t GetNr(void) const
get number of regularisation conditions
Definition TUnfold.cxx:3176
TMatrixDSparse * fVxxInv
inverse of covariance matrix Vxx-1
Definition TUnfold.h:187
const TMatrixD * GetX(void) const
vector of the unfolding result
Definition TUnfold.h:242
TMatrixD * fX
unfolding result x
Definition TUnfold.h:183
EConstraint
type of extra constraint
Definition TUnfold.h:113
@ kEConstraintArea
enforce preservation of the area
Definition TUnfold.h:119
@ kEConstraintNone
use no extra constraint
Definition TUnfold.h:116
virtual Double_t GetLcurveX(void) const
get value on x-axis of L-curve determined in recent unfolding
Definition TUnfold.cxx:3251
Double_t GetRhoI(TH1 *rhoi, const Int_t *binMap=nullptr, TH2 *invEmat=nullptr) const
get global correlation coefficiencts, possibly cumulated over several bins
Definition TUnfold.cxx:3504
TMatrixDSparse * fVyy
covariance matrix Vyy corresponding to y
Definition TUnfold.h:160
const TMatrixDSparse * GetVyyInv(void) const
inverse of covariance matrix of the data y
Definition TUnfold.h:260
Double_t GetEpsMatrix(void) const
get numerical accuracy for Eigenvalue analysis when inverting matrices with rank problems
Definition TUnfold.h:352
Int_t fNdf
number of degrees of freedom
Definition TUnfold.h:201
TArrayD fSumOverY
truth vector calculated from the non-normalized response matrix
Definition TUnfold.h:172
ERegMode
choice of regularisation scheme
Definition TUnfold.h:123
@ kRegModeNone
no regularisation, or defined later by RegularizeXXX() methods
Definition TUnfold.h:126
@ kRegModeDerivative
regularize the 1st derivative of the output distribution
Definition TUnfold.h:132
@ kRegModeSize
regularise the amplitude of the output distribution
Definition TUnfold.h:129
@ kRegModeCurvature
regularize the 2nd derivative of the output distribution
Definition TUnfold.h:135
@ kRegModeMixed
mixed regularisation pattern
Definition TUnfold.h:139
void GetInput(TH1 *inputData, const Int_t *binMap=nullptr) const
Input vector of measurements.
Definition TUnfold.cxx:3069
void SetEpsMatrix(Double_t eps)
set numerical accuracy for Eigenvalue analysis when inverting matrices with rank problems
Definition TUnfold.cxx:3703
const TMatrixDSparse * GetE(void) const
matrix E, using internal bin counting
Definition TUnfold.h:258
TVectorD GetSqrtEvEmatrix(void) const
Definition TUnfold.cxx:2509
Int_t GetRowFromBin(int ix) const
converts truth histogram bin number to matrix row
Definition TUnfold.h:234
void GetOutput(TH1 *output, const Int_t *binMap=nullptr) const
get output distribution, possibly cumulated over several bins
Definition TUnfold.cxx:3289
void GetRhoIJ(TH2 *rhoij, const Int_t *binMap=nullptr) const
get correlation coefficiencts, possibly cumulated over several bins
Definition TUnfold.cxx:3461
void ErrorMatrixToHist(TH2 *ematrix, const TMatrixDSparse *emat, const Int_t *binMap, Bool_t doClear) const
add up an error matrix, also respecting the bin mapping
Definition TUnfold.cxx:3379
TArrayI fXToHist
mapping of matrix indices to histogram bins
Definition TUnfold.h:168
const TMatrixDSparse * GetAx(void) const
vector of folded-back result
Definition TUnfold.h:248
TMatrixDSparse * fDXDY
derivative of the result wrt dx/dy
Definition TUnfold.h:209
TMatrixD * fY
input (measured) data y
Definition TUnfold.h:158
TMatrixDSparse * InvertMSparseSymmPos(const TMatrixDSparse *A, Int_t *rank) const
get the inverse or pseudo-inverse of a positive, sparse matrix
Definition TUnfold.cxx:993
TMatrixDSparse * fVyyInv
inverse of the input covariance matrix Vyy-1
Definition TUnfold.h:189
Double_t fLXsquared
chi**2 contribution from (x-s*x0)TLTL(x-s*x0)
Definition TUnfold.h:195
TMatrixDSparse * fDXDAM[2]
matrix contribution to the of derivative dx_k/dA_ij
Definition TUnfold.h:203
Double_t fTauSquared
regularisation parameter tau squared
Definition TUnfold.h:166
Int_t GetNpar(void) const
get number of truth parameters determined in recent unfolding
Definition TUnfold.cxx:3242
const TMatrixDSparse * GetEinv(void) const
matrix E-1, using internal bin counting
Definition TUnfold.h:256
virtual void ClearResults(void)
reset all results
Definition TUnfold.cxx:208
Double_t fRhoMax
maximum global correlation coefficient
Definition TUnfold.h:197
void GetEmatrix(TH2 *ematrix, const Int_t *binMap=nullptr) const
get output covariance matrix, possibly cumulated over several bins
Definition TUnfold.cxx:3446
TMatrixDSparse * MultiplyMSparseMSparse(const TMatrixDSparse *a, const TMatrixDSparse *b) const
multiply two sparse matrices
Definition TUnfold.cxx:603
EConstraint fConstraint
type of constraint to use for the unfolding
Definition TUnfold.h:174
TUnfold(void)
only for use by root streamer or derived classes
Definition TUnfold.cxx:238
EHistMap
arrangement of axes for the response matrix (TH2 histogram)
Definition TUnfold.h:143
@ kHistMapOutputVert
truth level on y-axis of the response matrix
Definition TUnfold.h:149
@ kHistMapOutputHoriz
truth level on x-axis of the response matrix
Definition TUnfold.h:146
void AddMSparse(TMatrixDSparse *dest, Double_t f, const TMatrixDSparse *src) const
add a sparse matrix, scaled by a factor, to another scaled matrix
Definition TUnfold.cxx:915
const TMatrixDSparse * GetVxx(void) const
covariance matrix of the result
Definition TUnfold.h:244
const TMatrixDSparse * GetVxxInv(void) const
inverse of covariance matrix of the result
Definition TUnfold.h:246
void GetNormalisationVector(TH1 *s, const Int_t *binMap=nullptr) const
histogram of truth bins, determined from suming over the response matrix
Definition TUnfold.cxx:2910
TMatrixDSparse * fDXDAZ[2]
vector contribution to the of derivative dx_k/dA_ij
Definition TUnfold.h:205
Double_t GetRhoIFromMatrix(TH1 *rhoi, const TMatrixDSparse *eOrig, const Int_t *binMap, TH2 *invEmat) const
Definition TUnfold.cxx:3553
void InitTUnfold(void)
initialize data menbers, for use in constructors
Definition TUnfold.cxx:144
Double_t GetTau(void) const
return regularisation parameter
Definition TUnfold.cxx:3223
Double_t GetChi2A(void) const
get χ2A contribution determined in recent unfolding
Definition TUnfold.h:329
Int_t RegularizeBins2D(int start_bin, int step1, int nbin1, int step2, int nbin2, ERegMode regmode)
add regularisation conditions for 2d unfolding
Definition TUnfold.cxx:2204
const TMatrixDSparse * GetDXDY(void) const
matrix of derivatives dx/dy
Definition TUnfold.h:250
void GetLsquared(TH2 *lsquared) const
get matrix of regularisation conditions squared
Definition TUnfold.cxx:3151
void GetInputInverseEmatrix(TH2 *ematrix)
get inverse of the measurement's covariance matrix
Definition TUnfold.cxx:3098
TMatrixDSparse * fA
response matrix A
Definition TUnfold.h:154
Double_t GetRhoAvg(void) const
get average global correlation determined in recent unfolding
Definition TUnfold.h:327
TMatrixDSparse * fL
regularisation conditions L
Definition TUnfold.h:156
virtual Int_t SetInput(const TH1 *hist_y, Double_t scaleBias=0.0, Double_t oneOverZeroError=0.0, const TH2 *hist_vyy=nullptr, const TH2 *hist_vyy_inv=nullptr)
Define input data for subsequent calls to DoUnfold(tau)
Definition TUnfold.cxx:2274
Int_t fIgnoredBins
number of input bins which are dropped because they have error=nullptr
Definition TUnfold.h:179
Int_t GetNdf(void) const
get number of degrees of freedom determined in recent unfolding
Definition TUnfold.h:339
~TUnfold(void) override
Double_t x[n]
Definition legend1.C:17
TF1 * f1
Definition legend1.C:11
TMarker m
Definition textangle.C:8
TLine l
Definition textangle.C:4
static void output()