93using std::vector, std::pair, std::cout;
97#define TEST_INPUT_COVARIANCE
167 cout<<
"problem to read binning schemes\n";
175#define READ(TYPE,binning,name) \
176 TYPE *name[3]; inputFile->GetObject(#name,name[0]); \
178 if(!name[0]) cout<<"Error reading " #name "\n"; \
179 CreateHistogramCopies(name,binning);
229 tunfoldC->GetRhoIJtotal(
"histRhoCLCurve");
263 tunfoldF->GetRhoIJtotal(
"histRhoFLCurve");
371 cout<<
"maximum number of iterations: "<<
niter<<
"\n";
387 for(
int i=0;i<
nx;i++) {
389 for(
int j=0;
j<
ny;
j++) {
392 for(
int j=0;
j<
ny;
j++) {
398 for(
int i=0;i<
nx;i++) {
403 for(
int i=0;i<
ny;i++) {
420 for(
int i=0;i<
nx;i++) {
424 (*
x[
nr])(i)=(*
x[0])(i);
427 for(
int i=0;i<
ny;i++) {
440 for(
int iter=0;iter<=
niter;iter++) {
441 if(!(iter %100)) cout<<iter<<
"\n";
445 for(
int j=0;
j<
ny;
j++) {
450 for(
int i=0;i<
nx;i++) {
451 xx(i) = (*
x[
nr])(i) *
f(i);
455 for(
int i=0;i<
nx;i++) {
456 for(
int j=0;
j<
ny;
j++) {
461 for(
int j=0;
j<
ny;
j++) {
463 for(
int i=0;i<
nx;i++) {
469 for(
int i=0;i<
nx;i++) {
472 for(
int i=0;i<
ny;i++) {
481 ((iter<=100)&&(iter %5==0))||
482 ((iter<=1000)&&(iter %50==0))||
484 nIter.push_back(iter);
488 for(
int i=0;i<
nx;i++) {
489 double bw=
h->GetXaxis()->GetBinWidth(i+1);
490 h->SetBinContent(i+1,(*
x[0])(i)/
bw);
496 for(
int i=0;i<
nx;i++) {
497 for(
int j=0;
j<
nx;
j++) {
500 cout<<
"bad error matrix: iter="<<iter<<
"\n";
523 for(
int i=0;i<
nx;i++) {
524 dx(i,0)= (*
x[
nr])(i)-(*
x[0])(i);
529 for(
int i=0;i<
nx;i++) {
530 double bw=
h->GetXaxis()->GetBinWidth(i+1);
531 h->SetBinContent(i+1,(*
x[0])(i)/
bw);
535 for(
int i=0;i<
nx;i++) {
536 for(
int j=0;
j<
nx;
j++) {
540 cout<<
"bad error matrix: iter="<<iter<<
"\n";
553 cout<<
"IDS number of iterations: "<<
niterIDS<<
"\n";
559 for(
int iy=0;iy<
ny;iy++) {
560 for(
int ix=0;ix<
nx;ix++) {
576 for(
int iter=1;iter<=
niterIDS;iter++) {
577 if(!(iter %10)) cout<<iter<<
"\n";
589 for(ix=0;ix<
nIter.size();ix++) {
590 if(
nIter[ix]==iter)
break;
592 if(ix<
nIter.size()) {
608 for(
int i=0;i<
nx;i++) {
613 for(
int i=0;i<
nx;i++) {
614 double bw=
h->GetXaxis()->GetBinWidth(i+1);
621 for(
int i=0;i<
nx;i++) {
622 for(
int j=0;
j<
nx;
j++) {
626 cout<<
"bad error matrix: iter="<<iter<<
"\n";
650 subn[0]=
new TPad(
"subn0",
"",0.,0.5,1.,1.);
652 subn[1]=
new TPad(
"subn1",
"",0.,0.,0.5,0.5);
653 subn[2]=
new TPad(
"subn2",
"",0.5,0.0,1.,0.5);
654 for(
int i=0;i<3;i++) {
655 subn[i]->SetFillStyle(0);
661 subc[0]=
new TPad(
"sub0",
"",0.,0.5,1.,1.);
663 subc[1]=
new TPad(
"sub1",
"",0.,0.,0.5,0.5);
665 subc[2]=
new TPad(
"sub2",
"",0.5,0.0,1.,0.5);
666 for(
int i=0;i<3;i++) {
667 subc[i]->SetFillStyle(0);
677 c2w->SaveAs(
"exampleTR.eps");
685 c2w->SaveAs(
"exampleAE.eps");
693 &table[table.size()-1].second);
699 c3c->SaveAs(
"inversion.eps");
707 &table[table.size()-1].second);
713 c3c->SaveAs(
"template.eps");
720 &table[table.size()-1].second);
726 c3c->SaveAs(
"templateA.eps");
733 &table[table.size()-1].second);
739 c3c->SaveAs(
"lcurveFA.eps");
746 &table[table.size()-1].second);
752 c3c->SaveAs(
"rhoscanFA.eps");
766 &table[table.size()-1].second);
767 c2sq->SaveAs(
"binbybin.eps");
781 isFitted ? &table[table.size()-1].second : nullptr);
805 isFitted ? &table[table.size()-1].second : 0);
816 int nfit=table.size();
821 for(
int fit=0;fit<
nfit;fit++) {
822 TF1 *
f=table[fit].first;
824 fitChindf->GetXaxis()->SetBinLabel(fit+1,
f->GetName());
825 fitNorm->GetXaxis()->SetBinLabel(fit+1,
f->GetName());
826 fitMu->GetXaxis()->SetBinLabel(fit+1,
f->GetName());
827 fitSigma->GetXaxis()->SetBinLabel(fit+1,
f->GetName());
832 fitNorm->SetBinContent(fit+1,
f->GetParameter(0));
833 fitNorm->SetBinError(fit+1,
f->GetParError(0));
834 fitMu->SetBinContent(fit+1,
f->GetParameter(1));
835 fitMu->SetBinError(fit+1,
f->GetParError(1));
836 fitSigma->SetBinContent(fit+1,
f->GetParameter(2));
837 fitSigma->SetBinError(fit+1,
f->GetParError(2));
838 cout<<
"\""<<
f->GetName()<<
"\","<<
r[2]/
r[3]<<
","<<
r[3]
844 for(
int i=1;i<3;i++) {
845 cout<<
","<<
f->GetParameter(i)<<
",\"\302\261\","<<
f->GetParError(i);
852 lCurve->SetTitle(
"L curve;log_{10} L_{x};log_{10} L_{y}");
858 logTauX->SetTitle(
";log_{10} #tau;log_{10} L_{x}");
862 logTauY->SetTitle(
";log_{10} #tau;log_{10} L_{y}");
865 c4->SaveAs(
"lcurveL.eps");
873 rhoScan->SetTitle(
";log_{10}(#tau);average(#rho_{i})");
883 c4->SaveAs(
"scanTau.eps");
910 for(
int i=0;i<2;i++) {
913 gPad->SetLogy((i<1));
932 legend->SetFillStyle(1001);
957 gPad->SetLogy(
false);
988 legend->SetFillStyle(1001);
1003 c2sq->SaveAs(
"fitSigma.eps");
1027 TF1 const *
f=table[ifit].first;
1028 mean(ifit-
iFirst)=
f->GetParameter(1);
1037 for(
int g=0;
g<4;
g++) {
1049 TF1 const *
f=table[ifit].first;
1050 hist[0]=
new TH1D(table[ifit].first->GetName()+
TString(
"_chi2"),
1051 ";iteration;unfold-truth #chi^{2}/N_{D.F.}",1,0.2,1500.);
1054 hist[1]=
new TH1D(table[ifit].first->GetName()+
TString(
"_gcor"),
1055 ";iteration;avg(#rho_{i})",1,0.2,1500.);
1057 hist[2]=
new TH1D(table[ifit].first->GetName()+
TString(
"_mu"),
1058 ";iteration;parameter #mu",1,0.2,1500.);
1061 hist[3]=
new TH1D(table[ifit].first->GetName()+
TString(
"_sigma"),
1062 ";iteration;parameter #sigma",1,0.2,1500.);
1065 for(
int h=0;
h<4;
h++) {
1086 double c=
h[0]->GetBinContent(
iSrc)+
h[1]->GetBinContent(
iDest);
1094 double c=
h[2]->GetBinContent(
iDest);
1095 double e=
h[2]->GetBinError(
iDest);
1116 int nx=
h->GetNbinsX();
1117 int ny=
h->GetNbinsY();
1118 double *
xBins=
new double[
nx+2];
1119 double *
yBins=
new double[
ny+2];
1120 for(
int i=1;i<=
nx;i++) {
1121 xBins[i-1]=
h->GetXaxis()->GetBinLowEdge(i);
1125 for(
int i=1;i<=
ny;i++) {
1126 yBins[i-1]=
h->GetYaxis()->GetBinLowEdge(i);
1133 for(
int ix=0;ix<=
nx+1;ix++) {
1134 for(
int iy=0;iy<=
ny+1;iy++) {
1135 r->SetBinContent(ix,iy,
h->GetBinContent(ix,iy));
1136 r->SetBinError(ix,iy,
h->GetBinError(ix,iy));
1146 int nx=
h->GetNbinsX();
1147 double *
xBins=
new double[
nx+2];
1148 for(
int i=1;i<=
nx;i++) {
1149 xBins[i-1]=
h->GetXaxis()->GetBinLowEdge(i);
1156 for(
int ix=0;ix<=
nx+1;ix++) {
1157 r->SetBinContent(ix,
h->GetBinContent(ix));
1158 r->SetBinError(ix,
h->GetBinError(ix));
1165 double x1=
h->GetXaxis()->GetBinLowEdge(
h->GetNbinsX());
1166 double x2=
h->GetXaxis()->GetBinUpEdge(
h->GetNbinsX());
1167 double y0=
h->GetYaxis()->GetBinLowEdge(1);
1168 double y2=
h->GetYaxis()->GetBinUpEdge(
h->GetNbinsY());;
1169 if(
h->GetDimension()==1) {
1176 textX->SetTextSize(0.05);
1177 textX->SetTextAngle(90.);
1184 double x0=
h->GetXaxis()->GetBinLowEdge(1);
1185 double x2=
h->GetXaxis()->GetBinUpEdge(
h->GetNbinsX());
1186 double y1=
h->GetYaxis()->GetBinLowEdge(
h->GetNbinsY());;
1187 double y2=
h->GetYaxis()->GetBinUpEdge(
h->GetNbinsY());;
1191 textY->SetTextSize(0.05);
1199 h->SetTitle(
"migration probabilities;P_{T}(gen) [GeV];P_{T}(rec) [GeV]");
1205 h->SetTitle(
"efficiency;P_{T}(gen) [GeV];#epsilon");
1207 h->SetMinimum(0.75);
1224 for(
int i=1;i<=
histMcRec->GetNbinsX();i++) {
1230 histMcRec->SetTitle(
"Reconstructed;P_{T}(rec);Nevent / GeV");
1249 for(
int ix=1;ix<=
nrec;ix++) {
1273 cout<<
"can not fold back: "<<
nrec
1292 legRec->SetBorderSize(0);
1381 (
"#chi^{2}/%d=%.1f prob=%.3f",
1382 (
int)(*
r)[3],(*
r)[2]/(*
r)[3],
1433 h->SetTitle(
"correlation coefficients;P_{T}(gen) [GeV];P_{T}(gen) [GeV]");
1455 cout<<
"fcn flag=0: npar="<<
npar<<
" gin="<<
gin<<
" par=[";
1456 for(
int i=0;i<
npar;i++) {
1464 for(
int i=0;i<=
n;i++) {
1466 if(i<1)
x1=
g_fcnHist->GetXaxis()->GetBinLowEdge(i+1);
1470 double iy=
u[0]*
u[2]*(
y1-
y0)/(
x1-x0);
1488 cout<<
h->GetName()<<
"\n";
1494 int n=
h->GetNbinsX()-1;
1497 for(
int i=0;i<
n;i++) {
1498 for(
int j=0;
j<
n;
j++) {
1500 (
h->GetBinError(i+1)*
h->GetBinError(
j+1));
1506 for(
int i=0;i<
n;i++) {
1510 cout<<
"bad eigenvalue i="<<i<<
" di="<<
di(i)<<
"\n";
1519 for(
int i=0;i<
n;i++) {
1523 for(
int j=0;
j<
n;
j++) {
1532 for(
int i=0;i<=
n;i++) {
1533 for(
int j=0;
j<=
n;
j++) {
1536 (
h->GetBinError(i+1)*
h->GetBinError(
j+1));
1546 for(
int i=0;i<=
n;i++) {
1550 cout<<
"bad eigenvalue i="<<i<<
" di1="<<
di1(i)<<
"\n";
1557 for(
int i=0;i<=
n;i++) {
1563 cout<<
"bad global correlation "<<i<<
" "<<
gcor2<<
"\n";
1585 double xmax=
h->GetXaxis()->GetBinUpEdge(
h->GetNbinsX()-1);
1588 landau->SetParameter(0,6000.);
1589 landau->SetParameter(1,5.);
1590 landau->SetParameter(2,2.);
1591 landau->SetParError(0,10.);
1592 landau->SetParError(1,0.5);
1593 landau->SetParError(2,0.1);
1598 r[1]=
h->GetNbinsX()-1-
landau->GetNpar();
1599 for(
int i=0;i<
h->GetNbinsX()-1;i++) {
1600 double di=
h->GetBinContent(i+1)-
truth->GetBinContent(i+1);
1602 for(
int j=0;
j<
h->GetNbinsX()-1;
j++) {
1603 double dj=
h->GetBinContent(
j+1)-
truth->GetBinContent(
j+1);
1604 r[2]+=
di*
dj*(*g_fcnMatrix)(i,
j);
1607 double pull=
di/
h->GetBinError(i+1);
1622 table.push_back(make_pair(landau,
r));
1631#include "ids_code.cc"
1637 for(
Int_t i=0; i<
N_; i++ ){ (*soustr)[i] = 0.; }
int Int_t
Signed integer 4 bytes (int)
double Double_t
Double 8 bytes.
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Int_t gErrorIgnoreLevel
errors with level below this value will be ignored. Default is kUnset.
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 WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char text
Option_t Option_t TPoint TPoint const char y1
Double_t GetBinError(Int_t bin) const override
TMatrixT< Double_t > TMatrixD
R__EXTERN TStyle * gStyle
TVectorT< Double_t > TVectorD
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
A TGraphErrors is a TGraph with error bars.
A TGraph is an object made of two arrays X and Y with npoints each.
1-D histogram with a double per channel (see TH1 documentation)
TH1 is the base class of all histogram classes in ROOT.
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...
static void SetDefaultSumw2(Bool_t sumw2=kTRUE)
When this static function is called with sumw2=kTRUE, all new histograms will automatically activate ...
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
2-D histogram with a double per channel (see TH1 documentation)
Service class for 2-D histogram classes.
Double_t GetBinContent(Int_t binx, Int_t biny) const override
This class displays a legend box (TPaveText) containing several legend entries.
Use the TLine constructor to create a simple line.
Mother of all ROOT objects.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
The most important graphics class in the ROOT system.
Random number generator class based on M.
Base class for spline implementation containing the Draw/Paint methods.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
Base class for several text objects.
Binning schemes for use with the unfolding algorithm TUnfoldDensity.
TH1 * CreateHistogram(const char *histogramName, Bool_t originalAxisBinning=kFALSE, Int_t **binMap=nullptr, const char *histogramTitle=nullptr, const char *axisSteering=nullptr) const
create a THxx histogram capable to hold the bins of this binning node and its children
Double_t GetBinSize(Int_t iBin) const
get N-dimensional bin size
Int_t GetEndBin(void) const
last+1 bin of this node (includes children)
An algorithm to unfold distributions from detector to truth level.
@ kEScanTauRhoAvg
average global correlation coefficient (from TUnfold::GetRhoI())
@ kDensityModeNone
no scale factors, matrix L is similar to unity matrix
@ kEConstraintArea
enforce preservation of the area
@ kEConstraintNone
use no extra constraint
ERegMode
choice of regularisation scheme
@ kRegModeSize
regularise the amplitude of the output distribution
@ kHistMapOutputHoriz
truth level on x-axis of the response matrix
static TVirtualFitter * Fitter(TObject *obj, Int_t maxpar=25)
Static function returning a pointer to the current fitter.
double landau(double x, double mu, double sigma)
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Double_t Prob(Double_t chi2, Int_t ndf)
Computation of the probability for a certain Chi-squared (chi2) and number of degrees of freedom (ndf...
Double_t Sqrt(Double_t x)
Returns the square root of x.
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
Returns x raised to the power y.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Double_t Hypot(Double_t x, Double_t y)
Returns sqrt(x*x + y*y)
Double_t LandauI(Double_t x)
Returns the cumulative (lower tail integral) of the Landau distribution function at point x.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
static uint64_t sum(uint64_t i)