Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TUnfoldDensity.h
Go to the documentation of this file.
1// Author: Stefan Schmitt
2// DESY, 11/08/11
3
4// Version 17.9, parallel to changes in TUnfold
5//
6// History:
7// Version 17.8, new method GetDXDY()
8// Version 17.7, with bug-fix for curvature regularisation
9// Version 17.6, with updated doxygen comments and bug-fixes in TUnfoldBinning
10// Version 17.5, bug fix in TUnfold also corrects GetEmatrixSysUncorr()
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, add scan type RhoSquare
15// Version 17.0, support for density regularisation and complex binning schemes
16
17#ifndef ROOT_TUnfoldDensity
18#define ROOT_TUnfoldDensity
19
20//////////////////////////////////////////////////////////////////////////
21// //
22// //
23// TUnfoldDensity, an extension of the class TUnfoldSys to correct for //
24// migration effects. TUnfoldDensity provides methods to deal with //
25// multidimensional complex binning schemes and variable bin widths //
26// //
27// Citation: S.Schmitt, JINST 7 (2012) T10003 [arXiv:1205.6201] //
28// //
29//////////////////////////////////////////////////////////////////////////
30
31/*
32 This file is part of TUnfold.
33
34 TUnfold is free software: you can redistribute it and/or modify
35 it under the terms of the GNU General Public License as published by
36 the Free Software Foundation, either version 3 of the License, or
37 (at your option) any later version.
38
39 TUnfold is distributed in the hope that it will be useful,
40 but WITHOUT ANY WARRANTY; without even the implied warranty of
41 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42 GNU General Public License for more details.
43
44 You should have received a copy of the GNU General Public License
45 along with TUnfold. If not, see <http://www.gnu.org/licenses/>.
46*/
47
48#include "TUnfoldSys.h"
49#include "TUnfoldBinning.h"
50
51
52class TUnfoldDensity : public TUnfoldSys {
53 protected:
54 /// binning scheme for the output (truth level)
56 /// binning scheme for the input (detector level)
58 /// pointer to output binning scheme if owned by this class
60 /// pointer to input binning scheme if owned by this class
62 /// binning scheme for the regularisation conditions
64
65 public:
66 /// choice of regularisation scale factors to cinstruct the matrix L
68 /// no scale factors, matrix L is similar to unity matrix
70 /// scale factors from multidimensional bin width
72 /// scale factors from user function in TUnfoldBinning
74 /// scale factors from multidimensional bin width and user function
76 };
77 protected:
78
79 TString GetOutputBinName(Int_t iBinX) const override; // name a bin
80
81 Double_t GetDensityFactor(EDensityMode densityMode,Int_t iBin) const; // density correction factor for this bin
83 (const TUnfoldBinning *binning,ERegMode regmode,
84 EDensityMode densityMode,const char *distribution,
85 const char *axisSteering); // regularize the given binning recursively
87 (const TUnfoldBinning *binning,ERegMode regmode,
88 EDensityMode densityMode,const char *axisSteering); // regularize the distribution of one binning node
89
90 public:
91 TUnfoldDensity(void); // constructor for derived classes, do nothing
92
93 TUnfoldDensity(const TH2 *hist_A, EHistMap histmap,
97 const TUnfoldBinning *outputBins=nullptr,
98 const TUnfoldBinning *inputBins=nullptr,
99 const char *regularisationDistribution=nullptr,
100 const char *regularisationAxisSteering="*[UOB]"); // constructor for using the histogram classes. Default regularisation is on the curvature of the bin-width normalized density, excluding underflow and overflow bins
101
102 ~ TUnfoldDensity(void) override; // delete data members
103
104 void RegularizeDistribution(ERegMode regmode,EDensityMode densityMode,
105 const char *distribution,
106 const char *axisSteering); // regularize distribution(s) of the output binning scheme
107
108 /// scan mode for correlation scan
110 /// average global correlation coefficient (from TUnfold::GetRhoI())
112 /// maximum global correlation coefficient (from TUnfold::GetRhoI())
114 /// average global correlation coefficient (from TUnfoldSys::GetRhoItotal())
116 /// maximum global correlation coefficient (from TUnfoldSys::GetRhoItotal())
118 /// average global correlation coefficient squared (from TUnfold::GetRhoI())
120 /// average global correlation coefficient squared (from TUnfoldSys::GetRhoItotal())
122 };
123
124 virtual Int_t ScanTau(Int_t nPoint,Double_t tauMin,Double_t tauMax,
125 TSpline **scanResult,Int_t mode=kEScanTauRhoAvg,
126 const char *distribution=nullptr,const char *projectionMode=nullptr,TGraph **lCurvePlot=nullptr,TSpline **logTauXPlot=nullptr,TSpline **logTauYPlot=nullptr); // scan some variable (e.g. global correlation) and find a minimum using successive calls to DoUnfold(Double_t) at various tau
127 virtual Double_t GetScanVariable(Int_t mode,const char *distribution,const char *projectionMode); // calculate variable for ScanTau()
128
129 TH1 *GetOutput(const char *histogramName,
130 const char *histogramTitle=nullptr,const char *distributionName=nullptr,
131 const char *projectionMode=nullptr,Bool_t useAxisBinning=kTRUE) const; // get unfolding result
132 TH1 *GetBias(const char *histogramName,
133 const char *histogramTitle=nullptr,const char *distributionName=nullptr,
134 const char *projectionMode=nullptr,Bool_t useAxisBinning=kTRUE) const; // get bias
135 TH1 *GetFoldedOutput(const char *histogramName,
136 const char *histogramTitle=nullptr,
137 const char *distributionName=nullptr,
138 const char *projectionMode=nullptr,Bool_t useAxisBinning=kTRUE,
139 Bool_t addBgr=kFALSE) const; // get unfolding result folded back
140 TH1 *GetBackground(const char *histogramName,const char *bgrSource=nullptr,
141 const char *histogramTitle=nullptr,
142 const char *distributionName=nullptr,
143 const char *projectionMode=nullptr,Bool_t useAxisBinning=kTRUE,Int_t includeError=3) const; // get background source
144 TH1 *GetInput(const char *histogramName,const char *histogramTitle=nullptr,
145 const char *distributionName=nullptr,
146 const char *projectionMode=nullptr,Bool_t useAxisBinning=kTRUE) const; // get unfolding input
147 TH1 *GetDeltaSysSource(const char *source,
148 const char *histogramName,
149 const char *histogramTitle=nullptr,
150 const char *distributionName=nullptr,
151 const char *projectionMode=nullptr,Bool_t useAxisBinning=kTRUE); // get systematic shifts from one systematic source
152 TH1 *GetDeltaSysBackgroundScale(const char *bgrSource,
153 const char *histogramName,
154 const char *histogramTitle=nullptr,
155 const char *distributionName=nullptr,
156 const char *projectionMode=nullptr,Bool_t useAxisBinning=kTRUE); // get correlated uncertainty induced by the scale uncertainty of a background source
157 TH1 *GetDeltaSysTau(const char *histogramName,
158 const char *histogramTitle=nullptr,
159 const char *distributionName=nullptr,
160 const char *projectionMode=nullptr,Bool_t useAxisBinning=kTRUE); // get correlated uncertainty from varying tau
161 TH2 *GetEmatrixSysUncorr(const char *histogramName,
162 const char *histogramTitle=nullptr,
163 const char *distributionName=nullptr,
164 const char *projectionMode=nullptr,Bool_t useAxisBinning=kTRUE); // get error matrix contribution from uncorrelated errors on the matrix A
165 TH2 *GetEmatrixSysBackgroundUncorr(const char *bgrSource,
166 const char *histogramName,
167 const char *histogramTitle=nullptr,
168 const char *distributionName=nullptr,
169 const char *projectionMode=nullptr,Bool_t useAxisBinning=kTRUE); // get error matrix from uncorrelated error of one background source
170 TH2 *GetEmatrixInput(const char *histogramName,
171 const char *histogramTitle=nullptr,
172 const char *distributionName=nullptr,
173 const char *projectionMode=nullptr,Bool_t useAxisBinning=kTRUE); // get error contribution from input vector
174 TH2 *GetEmatrixTotal(const char *histogramName,
175 const char *histogramTitle=nullptr,
176 const char *distributionName=nullptr,
177 const char *projectionMode=nullptr,Bool_t useAxisBinning=kTRUE); // get total error including systematic,statistical,background,tau errors
178 TH1 *GetRhoIstatbgr(const char *histogramName,const char *histogramTitle=nullptr,
179 const char *distributionName=nullptr,
180 const char *projectionMode=nullptr,Bool_t useAxisBinning=kTRUE,
181 TH2 **ematInv=nullptr); // get global correlation coefficients, stat+bgr errors only (from TUnfold)
182 TH1 *GetRhoItotal(const char *histogramName,const char *histogramTitle=nullptr,
183 const char *distributionName=nullptr,
184 const char *projectionMode=nullptr,Bool_t useAxisBinning=kTRUE,
185 TH2 **ematInv=nullptr); // get global correlation coefficients, including systematic errors (from TUnfoldSys)
186 TH2 *GetRhoIJtotal(const char *histogramName,
187 const char *histogramTitle=nullptr,
188 const char *distributionName=nullptr,
189 const char *projectionMode=nullptr,Bool_t useAxisBinning=kTRUE); // get correlation coefficients
190 TH2 *GetL(const char *histogramName,
191 const char *histogramTitle=nullptr,
192 Bool_t useAxisBinning=kTRUE); // get regularisation matrix
193 TH1 *GetLxMinusBias(const char *histogramName,const char *histogramTitle=nullptr); // get vector L(x-bias) of regularisation conditions
194
195 TH2 *GetProbabilityMatrix(const char *histogramName,
196 const char *histogramTitle=nullptr,Bool_t useAxisBinning=kTRUE) const; // get matrix of probabilities
197 TH2 *GetDXDY(const char *histogramName,
198 const char *histogramTitle=nullptr,bool useAxisBinning=true) const; // get matrix DX/DY
199
200 const TUnfoldBinning *GetInputBinning(const char *distributionName=nullptr) const; // find binning scheme for input bins
201 const TUnfoldBinning *GetOutputBinning(const char *distributionName=nullptr) const; // find binning scheme for output bins
202 /// return binning scheme for regularisation conditions (matrix L)
204
205 ClassDefOverride(TUnfoldDensity, TUnfold_CLASS_VERSION) //Unfolding with density regularisation
206};
207
208#endif
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
Option_t Option_t TPoint TPoint const char mode
#define TUnfold_CLASS_VERSION
Definition TUnfold.h:105
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
Base class for spline implementation containing the Draw/Paint methods.
Definition TSpline.h:31
Basic string class.
Definition TString.h:139
Binning schemes for use with the unfolding algorithm TUnfoldDensity.
An algorithm to unfold distributions from detector to truth level.
void RegularizeOneDistribution(const TUnfoldBinning *binning, ERegMode regmode, EDensityMode densityMode, const char *axisSteering)
regularize the distribution fof the given node
EScanTauMode
scan mode for correlation scan
@ kEScanTauRhoAvg
average global correlation coefficient (from TUnfold::GetRhoI())
@ kEScanTauRhoMax
maximum global correlation coefficient (from TUnfold::GetRhoI())
@ kEScanTauRhoSquareAvgSys
average global correlation coefficient squared (from TUnfoldSys::GetRhoItotal())
@ kEScanTauRhoMaxSys
maximum global correlation coefficient (from TUnfoldSys::GetRhoItotal())
@ kEScanTauRhoSquareAvg
average global correlation coefficient squared (from TUnfold::GetRhoI())
@ kEScanTauRhoAvgSys
average global correlation coefficient (from TUnfoldSys::GetRhoItotal())
TH1 * GetRhoItotal(const char *histogramName, const char *histogramTitle=nullptr, const char *distributionName=nullptr, const char *projectionMode=nullptr, Bool_t useAxisBinning=kTRUE, TH2 **ematInv=nullptr)
retreive global correlation coefficients including all uncertainty sources
TH2 * GetEmatrixSysUncorr(const char *histogramName, const char *histogramTitle=nullptr, const char *distributionName=nullptr, const char *projectionMode=nullptr, Bool_t useAxisBinning=kTRUE)
retreive covaraince contribution from uncorrelated (statistical) uncertainties of the response matrix
Double_t GetDensityFactor(EDensityMode densityMode, Int_t iBin) const
density correction factor for a given bin
TH2 * GetRhoIJtotal(const char *histogramName, const char *histogramTitle=nullptr, const char *distributionName=nullptr, const char *projectionMode=nullptr, Bool_t useAxisBinning=kTRUE)
retreive correlation coefficients, including all uncertainties
TString GetOutputBinName(Int_t iBinX) const override
Get bin name of an outpt bin.
const TUnfoldBinning * fConstOutputBins
binning scheme for the output (truth level)
const TUnfoldBinning * GetOutputBinning(const char *distributionName=nullptr) const
locate a binning node for the unfolded (truth level) quantities
TUnfoldBinning * GetLBinning(void) const
return binning scheme for regularisation conditions (matrix L)
TH2 * GetEmatrixInput(const char *histogramName, const char *histogramTitle=nullptr, const char *distributionName=nullptr, const char *projectionMode=nullptr, Bool_t useAxisBinning=kTRUE)
get covariance contribution from the input uncertainties (data statistical uncertainties)
TUnfoldBinning * fRegularisationConditions
binning scheme for the regularisation conditions
TH2 * GetL(const char *histogramName, const char *histogramTitle=nullptr, Bool_t useAxisBinning=kTRUE)
access matrix of regularisation conditions in a new histogram
TUnfoldBinning * fOwnedOutputBins
pointer to output binning scheme if owned by this class
TH2 * GetEmatrixTotal(const char *histogramName, const char *histogramTitle=nullptr, const char *distributionName=nullptr, const char *projectionMode=nullptr, Bool_t useAxisBinning=kTRUE)
get covariance matrix including all contributions
TUnfoldBinning * fOwnedInputBins
pointer to input binning scheme if owned by this class
TH1 * GetDeltaSysBackgroundScale(const char *bgrSource, const char *histogramName, const char *histogramTitle=nullptr, const char *distributionName=nullptr, const char *projectionMode=nullptr, Bool_t useAxisBinning=kTRUE)
retreive systematic 1-sigma shift corresponding to a background scale uncertainty
void RegularizeDistribution(ERegMode regmode, EDensityMode densityMode, const char *distribution, const char *axisSteering)
set up regularisation conditions
TH2 * GetProbabilityMatrix(const char *histogramName, const char *histogramTitle=nullptr, Bool_t useAxisBinning=kTRUE) const
get matrix of probabilities in a new histogram
TH1 * GetOutput(const char *histogramName, const char *histogramTitle=nullptr, const char *distributionName=nullptr, const char *projectionMode=nullptr, Bool_t useAxisBinning=kTRUE) const
retreive unfolding result as a new histogram
TH1 * GetFoldedOutput(const char *histogramName, const char *histogramTitle=nullptr, const char *distributionName=nullptr, const char *projectionMode=nullptr, Bool_t useAxisBinning=kTRUE, Bool_t addBgr=kFALSE) const
retreive unfolding result folded back as a new histogram
const TUnfoldBinning * GetInputBinning(const char *distributionName=nullptr) const
locate a binning node for the input (measured) quantities
TH1 * GetInput(const char *histogramName, const char *histogramTitle=nullptr, const char *distributionName=nullptr, const char *projectionMode=nullptr, Bool_t useAxisBinning=kTRUE) const
retreive input distribution in a new histogram
TH1 * GetRhoIstatbgr(const char *histogramName, const char *histogramTitle=nullptr, const char *distributionName=nullptr, const char *projectionMode=nullptr, Bool_t useAxisBinning=kTRUE, TH2 **ematInv=nullptr)
retreive global correlation coefficients including input (statistical) and background uncertainties
TH1 * GetDeltaSysSource(const char *source, const char *histogramName, const char *histogramTitle=nullptr, const char *distributionName=nullptr, const char *projectionMode=nullptr, Bool_t useAxisBinning=kTRUE)
retreive a correlated systematic 1-sigma shift
TH1 * GetDeltaSysTau(const char *histogramName, const char *histogramTitle=nullptr, const char *distributionName=nullptr, const char *projectionMode=nullptr, Bool_t useAxisBinning=kTRUE)
retreive1-sigma shift corresponding to the previously specified uncertainty on tau
TH2 * GetEmatrixSysBackgroundUncorr(const char *bgrSource, const char *histogramName, const char *histogramTitle=nullptr, const char *distributionName=nullptr, const char *projectionMode=nullptr, Bool_t useAxisBinning=kTRUE)
retreive covariance contribution from uncorrelated background uncertainties
const TUnfoldBinning * fConstInputBins
binning scheme for the input (detector level)
TH1 * GetLxMinusBias(const char *histogramName, const char *histogramTitle=nullptr)
get regularisation conditions multiplied by result vector minus bias L(x-biasScale*biasVector)
void RegularizeDistributionRecursive(const TUnfoldBinning *binning, ERegMode regmode, EDensityMode densityMode, const char *distribution, const char *axisSteering)
recursively add regularisation conditions for this node and its children
TUnfoldDensity(void)
only for use by root streamer or derived classes
TH1 * GetBias(const char *histogramName, const char *histogramTitle=nullptr, const char *distributionName=nullptr, const char *projectionMode=nullptr, Bool_t useAxisBinning=kTRUE) const
retreive bias vector as a new histogram
virtual Int_t ScanTau(Int_t nPoint, Double_t tauMin, Double_t tauMax, TSpline **scanResult, Int_t mode=kEScanTauRhoAvg, const char *distribution=nullptr, const char *projectionMode=nullptr, TGraph **lCurvePlot=nullptr, TSpline **logTauXPlot=nullptr, TSpline **logTauYPlot=nullptr)
scan a function wrt tau and determine the minimum
virtual Double_t GetScanVariable(Int_t mode, const char *distribution, const char *projectionMode)
calculate the function for ScanTau()
EDensityMode
choice of regularisation scale factors to cinstruct the matrix L
@ kDensityModeUser
scale factors from user function in TUnfoldBinning
@ kDensityModeNone
no scale factors, matrix L is similar to unity matrix
@ kDensityModeBinWidthAndUser
scale factors from multidimensional bin width and user function
@ kDensityModeBinWidth
scale factors from multidimensional bin width
TH1 * GetBackground(const char *histogramName, const char *bgrSource=nullptr, const char *histogramTitle=nullptr, const char *distributionName=nullptr, const char *projectionMode=nullptr, Bool_t useAxisBinning=kTRUE, Int_t includeError=3) const
retreive a background source in a new histogram
An algorithm to unfold distributions from detector to truth level, with background subtraction and pr...
Definition TUnfoldSys.h:59
EConstraint
type of extra constraint
Definition TUnfold.h:113
@ kEConstraintArea
enforce preservation of the area
Definition TUnfold.h:119
ERegMode
choice of regularisation scheme
Definition TUnfold.h:123
@ kRegModeCurvature
regularize the 2nd derivative of the output distribution
Definition TUnfold.h:135
EHistMap
arrangement of axes for the response matrix (TH2 histogram)
Definition TUnfold.h:143
const TMatrixDSparse * GetDXDY(void) const
matrix of derivatives dx/dy
Definition TUnfold.h:250