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 <TObject.h>
96#include <TArrayI.h>
97#include <TSpline.h>
98#include <TMatrixDSparse.h>
99#include <TMatrixD.h>
100#include <TObjArray.h>
101#include <TString.h>
102
103#define TUnfold_VERSION "V17.9"
104#define TUnfold_CLASS_VERSION 17
105
106class TUnfold : public TObject {
107 private:
108 void InitTUnfold(void); // initialize all data members
109 public:
110
111 /// type of extra constraint
113
114 /// use no extra constraint
116
117 /// enforce preservation of the area
119 };
120
121 /// choice of regularisation scheme
122 enum ERegMode {
123
124 /// no regularisation, or defined later by RegularizeXXX() methods
126
127 /// regularise the amplitude of the output distribution
129
130 /// regularize the 1st derivative of the output distribution
132
133 /// regularize the 2nd derivative of the output distribution
135
136
137 /// mixed regularisation pattern
138 kRegModeMixed = 4
139 };
140
141 /// arrangement of axes for the response matrix (TH2 histogram)
142 enum EHistMap {
143
144 /// truth level on x-axis of the response matrix
146
147 /// truth level on y-axis of the response matrix
149 };
150
151 protected:
152 /// response matrix A
154 /// regularisation conditions L
156 /// input (measured) data y
158 /// covariance matrix Vyy corresponding to y
160 /// scale factor for the bias
162 /// bias vector x0
164 /// regularisation parameter tau squared
166 /// mapping of matrix indices to histogram bins
168 /// mapping of histogram bins to matrix indices
170 /// truth vector calculated from the non-normalized response matrix
172 /// type of constraint to use for the unfolding
174 /// type of regularisation
176 private:
177 /// number of input bins which are dropped because they have error=nullptr
179 /// machine accuracy used to determine matrix rank after eigenvalue analysis
181 /// unfolding result x
183 /// covariance matrix Vxx
185 /// inverse of covariance matrix Vxx<sup>-1</sup>
187 /// inverse of the input covariance matrix Vyy<sup>-1</sup>
189 /// result x folded back A*x
191 /// chi**2 contribution from (y-Ax)Vyy<sup>-1</sup>(y-Ax)
193 /// chi**2 contribution from (x-s*x0)<sup>T</sup>L<sup>T</sup>L(x-s*x0)
195 /// maximum global correlation coefficient
197 /// average global correlation coefficient
199 /// number of degrees of freedom
201 /// matrix contribution to the of derivative dx_k/dA_ij
203 /// vector contribution to the of derivative dx_k/dA_ij
205 /// derivative of the result wrt tau squared
207 /// derivative of the result wrt dx/dy
209 /// matrix E^(-1)
211 /// matrix E
213 protected:
214 // Int_t IsNotSymmetric(TMatrixDSparse const &m) const;
215 virtual Double_t DoUnfold(void); // the unfolding algorithm
216 virtual void ClearResults(void); // clear all results
217 void ClearHistogram(TH1 *h,Double_t x=0.) const;
218 virtual TString GetOutputBinName(Int_t iBinX) const; // name a bin
219 TMatrixDSparse *MultiplyMSparseM(const TMatrixDSparse *a,const TMatrixD *b) const; // multiply sparse and non-sparse matrix
220 TMatrixDSparse *MultiplyMSparseMSparse(const TMatrixDSparse *a,const TMatrixDSparse *b) const; // multiply sparse and sparse matrix
221 TMatrixDSparse *MultiplyMSparseTranspMSparse(const TMatrixDSparse *a,const TMatrixDSparse *b) const; // multiply transposed sparse and sparse matrix
223 (const TMatrixDSparse *m1,const TMatrixDSparse *m2,
224 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).
225 TMatrixDSparse *InvertMSparseSymmPos(const TMatrixDSparse *A,Int_t *rank) const; // invert symmetric (semi-)positive sparse matrix
226 void AddMSparse(TMatrixDSparse *dest,Double_t f,const TMatrixDSparse *src) const; // replacement for dest += f*src
227 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
228 /// returns internal number of output (truth) matrix rows
229 inline Int_t GetNx(void) const {
230 return fA->GetNcols();
231 }
232 /// converts truth histogram bin number to matrix row
233 inline Int_t GetRowFromBin(int ix) const { return fHistToX[ix]; }
234 /// converts matrix row to truth histogram bin number
235 inline Int_t GetBinFromRow(int ix) const { return fXToHist[ix]; }
236 /// returns the number of measurement bins
237 inline Int_t GetNy(void) const {
238 return fA->GetNrows();
239 }
240 /// vector of the unfolding result
241 inline const TMatrixD *GetX(void) const { return fX; }
242 /// covariance matrix of the result
243 inline const TMatrixDSparse *GetVxx(void) const { return fVxx; }
244 /// inverse of covariance matrix of the result
245 inline const TMatrixDSparse *GetVxxInv(void) const { return fVxxInv; }
246 /// vector of folded-back result
247 inline const TMatrixDSparse *GetAx(void) const { return fAx; }
248 /// matrix of derivatives dx/dy
249 inline const TMatrixDSparse *GetDXDY(void) const { return fDXDY; }
250 /// matrix contributions of the derivative dx/dA
251 inline const TMatrixDSparse *GetDXDAM(int i) const { return fDXDAM[i]; }
252 /// vector contributions of the derivative dx/dA
253 inline const TMatrixDSparse *GetDXDAZ(int i) const { return fDXDAZ[i]; }
254 /// matrix E<sup>-1</sup>, using internal bin counting
255 inline const TMatrixDSparse *GetEinv(void) const { return fEinv; }
256 /// matrix E, using internal bin counting
257 inline const TMatrixDSparse *GetE(void) const { return fE; }
258 /// inverse of covariance matrix of the data y
259 inline const TMatrixDSparse *GetVyyInv(void) const { return fVyyInv; }
260
261 void ErrorMatrixToHist(TH2 *ematrix,const TMatrixDSparse *emat,const Int_t *binMap,Bool_t doClear) const; // return an error matrix as histogram
262 Double_t GetRhoIFromMatrix(TH1 *rhoi,const TMatrixDSparse *eOrig,const Int_t *binMap,TH2 *invEmat) const; // return global correlation coefficients
263 /// vector of derivative dx/dtauSquared, using internal bin counting
264 inline const TMatrixDSparse *GetDXDtauSquared(void) const { return fDXDtauSquared; }
265 /// delete matrix and invalidate pointer
266 static void DeleteMatrix(TMatrixD **m);
267 /// delete sparse matrix and invalidate pointer
268 static void DeleteMatrix(TMatrixDSparse **m);
269
270 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
271 Bool_t AddRegularisationCondition(Int_t nEle,const Int_t *indices,const Double_t *rowData); // add a regularisation condition
272public:
273 static const char*GetTUnfoldVersion(void);
274 // Set up response matrix and regularisation scheme
275 TUnfold(const TH2 *hist_A, EHistMap histmap,
276 ERegMode regmode = kRegModeSize,
277 EConstraint constraint=kEConstraintArea);
278 // for root streamer and derived classes
279 TUnfold(void);
280 ~TUnfold(void) override;
281 // define input distribution
282 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);
283 // Unfold with given choice of tau and input
284 virtual Double_t DoUnfold(Double_t tau);
285 Double_t DoUnfold(Double_t tau,const TH1 *hist_y, Double_t scaleBias=0.0);
286 // scan the L curve using successive calls to DoUnfold(Double_t) at various tau
287 virtual Int_t ScanLcurve(Int_t nPoint,Double_t tauMin,
288 Double_t tauMax,TGraph **lCurve,
289 TSpline **logTauX=nullptr,TSpline **logTauY=nullptr,
290 TSpline **logTauCurvature=nullptr);
291 // 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
292 virtual Int_t ScanSURE(Int_t nPoint,Double_t tauMin,
293 Double_t tauMax,
294 TGraph **logTauSURE=nullptr,
295 TGraph **df_chi2A=nullptr,
296 TGraph **lCurve=nullptr);
297 // calculate square roots of the Eigenvalues of the Error matrix
298 TVectorD GetSqrtEvEmatrix(void) const;
299 // access unfolding results
300 Double_t GetTau(void) const;
301 void GetOutput(TH1 *output,const Int_t *binMap=nullptr) const;
302 void GetEmatrix(TH2 *ematrix,const Int_t *binMap=nullptr) const;
303 void GetRhoIJ(TH2 *rhoij,const Int_t *binMap=nullptr) const;
304 Double_t GetRhoI(TH1 *rhoi,const Int_t *binMap=nullptr,TH2 *invEmat=nullptr) const;
305 void GetFoldedOutput(TH1 *folded,const Int_t *binMap=nullptr) const;
306
307 double GetDF(void) const; // effective number of degrees of freedom
308 double GetSURE(void) const; // Stein's unbiased risk estimator
309
310 // access input parameters
311 void GetProbabilityMatrix(TH2 *A,EHistMap histmap) const;
312 void GetNormalisationVector(TH1 *s,const Int_t *binMap=nullptr) const; // get the vector of normalisation factors, equivalent to the initial bias vector
313 void GetInput(TH1 *inputData,const Int_t *binMap=nullptr) const; // get input data
314 void GetInputInverseEmatrix(TH2 *ematrix); // get input data inverse of error matrix
315 void GetBias(TH1 *bias,const Int_t *binMap=nullptr) const; // get bias (includind biasScale)
316 Int_t GetNr(void) const; // number of regularisation conditions
317 void GetL(TH2 *l) const; // get matrix of regularisation conditions
318 void GetLsquared(TH2 *lsquared) const;
319
320 // access various properties of the result
321 /// get matrix connecting input and output changes
322 void GetDXDY(TH2 *dxdy) const;
323 /// get maximum global correlation determined in recent unfolding
324 inline Double_t GetRhoMax(void) const { return fRhoMax; }
325 /// get average global correlation determined in recent unfolding
326 inline Double_t GetRhoAvg(void) const { return fRhoAvg; }
327 /// get &chi;<sup>2</sup><sub>A</sub> contribution determined in recent unfolding
328 inline Double_t GetChi2A(void) const { return fChi2A; }
329
330 Double_t GetChi2L(void) const; // get &chi;<sup>2</sup><sub>L</sub> contribution determined in recent unfolding
331 virtual Double_t GetLcurveX(void) const; // get value on x axis of L curve
332 virtual Double_t GetLcurveY(void) const; // get value on y axis of L curve
333 /// get number of degrees of freedom determined in recent unfolding
334 ///
335 /// This returns the number of valid measurements minus the number
336 /// of unfolded truth bins. If the area constraint is active, one
337 /// further degree of freedom is subtracted
338 inline Int_t GetNdf(void) const { return fNdf; }
339 Int_t GetNpar(void) const; // get number of parameters
340
341 // advanced features
342 void SetBias(const TH1 *bias); // set alternative bias
343 void SetConstraint(EConstraint constraint); // set type of constraint for the next unfolding
344 Int_t RegularizeSize(int bin, Double_t scale = 1.0); // regularise the size of one output bin
345 Int_t RegularizeDerivative(int left_bin, int right_bin, Double_t scale = 1.0); // regularize difference of two output bins (1st derivative)
346 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)
347 Int_t RegularizeBins(int start, int step, int nbin, ERegMode regmode); // regularize a 1-dimensional curve
348 Int_t RegularizeBins2D(int start_bin, int step1, int nbin1, int step2, int nbin2, ERegMode regmode); // regularize a 2-dimensional grid
349 /// get numerical accuracy for Eigenvalue analysis when inverting
350 /// matrices with rank problems
351 inline Double_t GetEpsMatrix(void) const { return fEpsMatrix; }
352 /// set numerical accuracy for Eigenvalue analysis when inverting
353 /// matrices with rank problems
354 void SetEpsMatrix(Double_t eps); // set accuracy for eigenvalue analysis
355
356 ClassDefOverride(TUnfold, TUnfold_CLASS_VERSION) //Unfolding with support for L-curve analysis
357};
358
359#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:341
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:104
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:106
TArrayI fHistToX
mapping of histogram bins to matrix indices
Definition TUnfold.h:169
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:212
TMatrixDSparse * fEinv
matrix E^(-1)
Definition TUnfold.h:210
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:190
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:192
TMatrixD * fX0
bias vector x0
Definition TUnfold.h:163
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:180
const TMatrixDSparse * GetDXDAM(int i) const
matrix contributions of the derivative dx/dA
Definition TUnfold.h:251
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:184
Int_t GetNy(void) const
returns the number of measurement bins
Definition TUnfold.h:237
Double_t GetRhoMax(void) const
get maximum global correlation determined in recent unfolding
Definition TUnfold.h:324
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:161
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:264
Double_t fRhoAvg
average global correlation coefficient
Definition TUnfold.h:198
TMatrixDSparse * fDXDtauSquared
derivative of the result wrt tau squared
Definition TUnfold.h:206
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:235
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:229
const TMatrixDSparse * GetDXDAZ(int i) const
vector contributions of the derivative dx/dA
Definition TUnfold.h:253
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:175
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:186
const TMatrixD * GetX(void) const
vector of the unfolding result
Definition TUnfold.h:241
TMatrixD * fX
unfolding result x
Definition TUnfold.h:182
EConstraint
type of extra constraint
Definition TUnfold.h:112
@ kEConstraintArea
enforce preservation of the area
Definition TUnfold.h:118
@ kEConstraintNone
use no extra constraint
Definition TUnfold.h:115
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:159
const TMatrixDSparse * GetVyyInv(void) const
inverse of covariance matrix of the data y
Definition TUnfold.h:259
Double_t GetEpsMatrix(void) const
get numerical accuracy for Eigenvalue analysis when inverting matrices with rank problems
Definition TUnfold.h:351
Int_t fNdf
number of degrees of freedom
Definition TUnfold.h:200
TArrayD fSumOverY
truth vector calculated from the non-normalized response matrix
Definition TUnfold.h:171
ERegMode
choice of regularisation scheme
Definition TUnfold.h:122
@ kRegModeNone
no regularisation, or defined later by RegularizeXXX() methods
Definition TUnfold.h:125
@ kRegModeDerivative
regularize the 1st derivative of the output distribution
Definition TUnfold.h:131
@ kRegModeSize
regularise the amplitude of the output distribution
Definition TUnfold.h:128
@ kRegModeCurvature
regularize the 2nd derivative of the output distribution
Definition TUnfold.h:134
@ kRegModeMixed
mixed regularisation pattern
Definition TUnfold.h:138
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:257
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:233
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:167
const TMatrixDSparse * GetAx(void) const
vector of folded-back result
Definition TUnfold.h:247
TMatrixDSparse * fDXDY
derivative of the result wrt dx/dy
Definition TUnfold.h:208
TMatrixD * fY
input (measured) data y
Definition TUnfold.h:157
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:188
Double_t fLXsquared
chi**2 contribution from (x-s*x0)TLTL(x-s*x0)
Definition TUnfold.h:194
TMatrixDSparse * fDXDAM[2]
matrix contribution to the of derivative dx_k/dA_ij
Definition TUnfold.h:202
Double_t fTauSquared
regularisation parameter tau squared
Definition TUnfold.h:165
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:255
virtual void ClearResults(void)
reset all results
Definition TUnfold.cxx:208
Double_t fRhoMax
maximum global correlation coefficient
Definition TUnfold.h:196
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:173
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:142
@ kHistMapOutputVert
truth level on y-axis of the response matrix
Definition TUnfold.h:148
@ kHistMapOutputHoriz
truth level on x-axis of the response matrix
Definition TUnfold.h:145
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:243
const TMatrixDSparse * GetVxxInv(void) const
inverse of covariance matrix of the result
Definition TUnfold.h:245
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:204
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:328
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:249
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:153
Double_t GetRhoAvg(void) const
get average global correlation determined in recent unfolding
Definition TUnfold.h:326
TMatrixDSparse * fL
regularisation conditions L
Definition TUnfold.h:155
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:178
Int_t GetNdf(void) const
get number of degrees of freedom determined in recent unfolding
Definition TUnfold.h:338
~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()