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