79#define TEST_INPUT_COVARIANCE
88 TFile *outputFile=
new TFile(
"testUnfold5_results.root",
"recreate");
92 TFile *inputFile=
new TFile(
"testUnfold5_histograms.root");
98 inputFile->
GetObject(
"detector",detectorBinning);
99 inputFile->
GetObject(
"generator",generatorBinning);
101 if((!detectorBinning)||(!generatorBinning)) {
102 cout<<
"problem to read binning schemes\n";
106 detectorBinning->
Write();
107 generatorBinning->
Write();
110 TH1 *histDataReco,*histDataTruth;
113 inputFile->
GetObject(
"histDataReco",histDataReco);
114 inputFile->
GetObject(
"histDataTruth",histDataTruth);
115 inputFile->
GetObject(
"histMCGenRec",histMCGenRec);
117#ifdef TEST_ZERO_UNCORR_ERROR
121 for(
int i=0;i<=histMCGenRec->
GetNbinsX()+1;i++) {
122 for(
int j=0;j<=histMCGenRec->
GetNbinsY()+1;j++) {
128 histDataReco->
Write();
129 histDataTruth->
Write();
130 histMCGenRec->
Write();
132 if((!histDataReco)||(!histDataTruth)||(!histMCGenRec)) {
133 cout<<
"problem to read input histograms\n";
151 const char *REGULARISATION_DISTRIBUTION=
nullptr;
152 const char *REGULARISATION_AXISSTEERING=
"*[B]";
156 regMode,constraintMode,densityFlags,
157 generatorBinning,detectorBinning,
158 REGULARISATION_DISTRIBUTION,
159 REGULARISATION_AXISSTEERING);
163#ifdef TEST_INPUT_COVARIANCE
167 for(
int i=1;i<=inputEmatrix->
GetNbinsX();i++) {
173 unfold.SetInput(histDataReco,0.0,0.0,inputEmatrix);
175 unfold.SetInput(histDataReco );
179 TH2 *histL= unfold.GetL(
"L");
181 cout<<
"L["<<unfold.GetLBinning()->GetBinName(j)<<
"]";
184 if(
c!=0.0) cout<<
" ["<<i<<
"]="<<
c;
202 const char *SCAN_DISTRIBUTION=
"signal";
203 const char *SCAN_AXISSTEERING=
nullptr;
205 Int_t iBest=unfold.ScanTau(nScan,0.,0.,&rhoLogTau,
207 SCAN_DISTRIBUTION,SCAN_AXISSTEERING,
212 rhoLogTau->
GetKnot(iBest,t[0],rho[0]);
217 for(
Int_t i=0;i<nScan;i++) {
218 rhoLogTau->
GetKnot(i,tAll[i],rhoAll[i]);
222 cout<<
"chi**2="<<unfold.GetChi2A()<<
"+"<<unfold.GetChi2L()
223 <<
" / "<<unfold.GetNdf()<<
"\n";
230 TH1 *histDataUnfold=unfold.GetOutput(
"unfolded signal",
nullptr,
nullptr,
nullptr,
kFALSE);
233 TH1 *histMCTruth=histMCGenRec->
ProjectionX(
"histMCTruth",0,-1,
"e");
236 histMCReco->
Scale(scaleFactor);
237 histMCTruth->
Scale(scaleFactor);
239 TH2 *histProbability=unfold.GetProbabilityMatrix(
"histProbability");
241 unfold.GetRhoItotal(
"histGlobalCorr",
nullptr,
nullptr,
nullptr,
kFALSE);
242 TH1 *histGlobalCorrScan=unfold.GetRhoItotal
243 (
"histGlobalCorrScan",
nullptr,SCAN_DISTRIBUTION,SCAN_AXISSTEERING,
kFALSE);
244 unfold.GetRhoIJtotal(
"histCorrCoeff",
nullptr,
nullptr,
nullptr,
kFALSE);
247 canvas.
Print(
"testUnfold5.ps[");
259 histDataReco->
Draw(
"E");
261 histMCReco->
Draw(
"SAME HIST");
264 histProbability->
Draw(
"BOX");
268 histDataUnfold->
Draw(
"E");
270 histDataTruth->
Draw(
"SAME HIST");
272 histMCTruth->
Draw(
"SAME HIST");
278 bestRhoLogTau->
Draw(
"*");
283 histGlobalCorrScan->
Draw(
"HIST");
288 bestLCurve->
Draw(
"*");
291 canvas.
Print(
"testUnfold5.ps");
293 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="") override
Remove all primitives from the canvas.
TVirtualPad * cd(Int_t subpadnumber=0) override
Set current canvas & pad.
Bool_t cd() override
Change current directory to "this" directory.
void GetObject(const char *namecycle, T *&ptr)
Get an object with proper type checking.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
A TGraph is an object made of two arrays X and Y with npoints each.
void Draw(Option_t *chopt="") override
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.
TH1 is the base class of all histogram classes in ROOT.
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...
void Draw(Option_t *option="") override
Draw this histogram with options.
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 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-D 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.
void SetBinContent(Int_t bin, Double_t content) override
Set bin content.
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.
Double_t GetBinContent(Int_t binx, Int_t biny) const override
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override
Automatic pad generation by division.
void Print(const char *filename="") const override
This method is equivalent to SaveAs("filename"). See TPad::SaveAs for details.
Base class for spline implementation containing the Draw/Paint methods.
void Draw(Option_t *option="") override
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=nullptr, const char *histogramTitle=nullptr, const char *axisSteering=nullptr) 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
virtual void SetLogy(Int_t value=1)=0