80#define TEST_INPUT_COVARIANCE
89 TFile *outputFile=
new TFile(
"testUnfold5_results.root",
"recreate");
93 TFile *inputFile=
new TFile(
"testUnfold5_histograms.root");
99 inputFile->
GetObject(
"detector",detectorBinning);
100 inputFile->
GetObject(
"generator",generatorBinning);
102 if((!detectorBinning)||(!generatorBinning)) {
103 cout<<
"problem to read binning schemes\n";
107 detectorBinning->
Write();
108 generatorBinning->
Write();
111 TH1 *histDataReco,*histDataTruth;
114 inputFile->
GetObject(
"histDataReco",histDataReco);
115 inputFile->
GetObject(
"histDataTruth",histDataTruth);
116 inputFile->
GetObject(
"histMCGenRec",histMCGenRec);
118#ifdef TEST_ZERO_UNCORR_ERROR
122 for(
int i=0;i<=histMCGenRec->
GetNbinsX()+1;i++) {
123 for(
int j=0;j<=histMCGenRec->
GetNbinsY()+1;j++) {
129 histDataReco->
Write();
130 histDataTruth->
Write();
131 histMCGenRec->
Write();
133 if((!histDataReco)||(!histDataTruth)||(!histMCGenRec)) {
134 cout<<
"problem to read input histograms\n";
152 const char *REGULARISATION_DISTRIBUTION=0;
153 const char *REGULARISATION_AXISSTEERING=
"*[B]";
157 regMode,constraintMode,densityFlags,
158 generatorBinning,detectorBinning,
159 REGULARISATION_DISTRIBUTION,
160 REGULARISATION_AXISSTEERING);
164#ifdef TEST_INPUT_COVARIANCE
168 for(
int i=1;i<=inputEmatrix->
GetNbinsX();i++) {
174 unfold.SetInput(histDataReco,0.0,0.0,inputEmatrix);
176 unfold.SetInput(histDataReco );
180 TH2 *histL= unfold.GetL(
"L");
182 cout<<
"L["<<unfold.GetLBinning()->GetBinName(j)<<
"]";
185 if(
c!=0.0) cout<<
" ["<<i<<
"]="<<
c;
203 const char *SCAN_DISTRIBUTION=
"signal";
204 const char *SCAN_AXISSTEERING=0;
206 Int_t iBest=unfold.ScanTau(nScan,0.,0.,&rhoLogTau,
208 SCAN_DISTRIBUTION,SCAN_AXISSTEERING,
213 rhoLogTau->
GetKnot(iBest,t[0],rho[0]);
218 for(
Int_t i=0;i<nScan;i++) {
219 rhoLogTau->
GetKnot(i,tAll[i],rhoAll[i]);
223 cout<<
"chi**2="<<unfold.GetChi2A()<<
"+"<<unfold.GetChi2L()
224 <<
" / "<<unfold.GetNdf()<<
"\n";
231 TH1 *histDataUnfold=unfold.GetOutput(
"unfolded signal",0,0,0,
kFALSE);
234 TH1 *histMCTruth=histMCGenRec->
ProjectionX(
"histMCTruth",0,-1,
"e");
237 histMCReco->
Scale(scaleFactor);
238 histMCTruth->
Scale(scaleFactor);
240 TH2 *histProbability=unfold.GetProbabilityMatrix(
"histProbability");
242 unfold.GetRhoItotal(
"histGlobalCorr",0,0,0,
kFALSE);
243 TH1 *histGlobalCorrScan=unfold.GetRhoItotal
244 (
"histGlobalCorrScan",0,SCAN_DISTRIBUTION,SCAN_AXISSTEERING,
kFALSE);
245 unfold.GetRhoIJtotal(
"histCorrCoeff",0,0,0,
kFALSE);
248 canvas.
Print(
"testUnfold5.ps[");
260 histDataReco->
Draw(
"E");
262 histMCReco->
Draw(
"SAME HIST");
265 histProbability->
Draw(
"BOX");
269 histDataUnfold->
Draw(
"E");
271 histDataTruth->
Draw(
"SAME HIST");
273 histMCTruth->
Draw(
"SAME HIST");
279 bestRhoLogTau->
Draw(
"*");
284 histGlobalCorrScan->
Draw(
"HIST");
289 bestLCurve->
Draw(
"*");
292 canvas.
Print(
"testUnfold5.ps");
294 canvas.
Print(
"testUnfold5.ps]");
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
void Clear(Option_t *option="")
Remove all primitives from the canvas.
TVirtualPad * cd(Int_t subpadnumber=0)
Set current canvas & pad.
Bool_t cd(const char *path=nullptr) override
Change current directory to "this" directory.
void GetObject(const char *namecycle, T *&ptr)
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
A TGraph is an object made of two arrays X and Y with npoints each.
virtual void Draw(Option_t *chopt="")
Draw this graph with its current attributes.
virtual Int_t GetPoint(Int_t i, Double_t &x, Double_t &y) const
Get x and y values for point number i.
virtual Int_t GetNbinsY() const
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
virtual Int_t GetNbinsX() const
virtual void SetBinError(Int_t bin, Double_t error)
Set the bin Error Note that this resets the bin eror option to be of Normal Type and for the non-empt...
virtual void SetMinimum(Double_t minimum=-1111)
static void SetDefaultSumw2(Bool_t sumw2=kTRUE)
When this static function is called with sumw2=kTRUE, all new histograms will automatically activate ...
virtual void Draw(Option_t *option="")
Draw this histogram with options.
virtual void Scale(Double_t c1=1, Option_t *option="")
Multiply this histogram by a constant c1.
virtual Double_t GetSumOfWeights() const
Return the sum of weights excluding under/overflows.
2-D histogram with a double per channel (see TH1 documentation)}
Service class for 2-Dim histogram classes.
TH1D * ProjectionY(const char *name="_py", Int_t firstxbin=0, Int_t lastxbin=-1, Option_t *option="") const
Project a 2-D histogram into a 1-D histogram along Y.
TH1D * ProjectionX(const char *name="_px", Int_t firstybin=0, Int_t lastybin=-1, Option_t *option="") const
Project a 2-D histogram into a 1-D histogram along X.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content.
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)
Automatic pad generation by division.
virtual void Print(const char *filename="") const
Save Pad contents in a file in one of various formats.
Base class for spline implementation containing the Draw/Paint methods.
virtual void Draw(Option_t *option="")
Draw this function with its current attributes.
virtual void GetKnot(Int_t i, Double_t &x, Double_t &y) const =0
Binning schemes for use with the unfolding algorithm TUnfoldDensity.
TH2D * CreateErrorMatrixHistogram(const char *histogramName, Bool_t originalAxisBinning, Int_t **binMap=0, const char *histogramTitle=0, const char *axisSteering=0) const
Create a TH2D histogram capable to hold a covariance matrix.
An algorithm to unfold distributions from detector to truth level.
@ kEScanTauRhoMax
maximum global correlation coefficient (from TUnfold::GetRhoI())
EDensityMode
choice of regularisation scale factors to cinstruct the matrix L
@ kDensityModeBinWidth
scale factors from multidimensional bin width
EConstraint
type of extra constraint
@ kEConstraintArea
enforce preservation of the area
ERegMode
choice of regularisation scheme
@ kRegModeCurvature
regularize the 2nd derivative of the output distribution
@ kHistMapOutputHoriz
truth level on x-axis of the response matrix