94using std::vector, std::pair, std::cout;
98#define TEST_INPUT_COVARIANCE
168 cout<<
"problem to read binning schemes\n";
176#define READ(TYPE,binning,name) \
177 TYPE *name[3]; inputFile->GetObject(#name,name[0]); \
179 if(!name[0]) cout<<"Error reading " #name "\n"; \
180 CreateHistogramCopies(name,binning);
230 tunfoldC->GetRhoIJtotal(
"histRhoCLCurve");
264 tunfoldF->GetRhoIJtotal(
"histRhoFLCurve");
372 cout<<
"maximum number of iterations: "<<
niter<<
"\n";
388 for(
int i=0;i<
nx;i++) {
390 for(
int j=0;
j<
ny;
j++) {
393 for(
int j=0;
j<
ny;
j++) {
399 for(
int i=0;i<
nx;i++) {
404 for(
int i=0;i<
ny;i++) {
421 for(
int i=0;i<
nx;i++) {
425 (*
x[
nr])(i)=(*
x[0])(i);
428 for(
int i=0;i<
ny;i++) {
441 for(
int iter=0;iter<=
niter;iter++) {
442 if(!(iter %100)) cout<<iter<<
"\n";
446 for(
int j=0;
j<
ny;
j++) {
451 for(
int i=0;i<
nx;i++) {
452 xx(i) = (*
x[
nr])(i) *
f(i);
456 for(
int i=0;i<
nx;i++) {
457 for(
int j=0;
j<
ny;
j++) {
462 for(
int j=0;
j<
ny;
j++) {
464 for(
int i=0;i<
nx;i++) {
470 for(
int i=0;i<
nx;i++) {
473 for(
int i=0;i<
ny;i++) {
482 ((iter<=100)&&(iter %5==0))||
483 ((iter<=1000)&&(iter %50==0))||
485 nIter.push_back(iter);
489 for(
int i=0;i<
nx;i++) {
490 double bw=
h->GetXaxis()->GetBinWidth(i+1);
491 h->SetBinContent(i+1,(*
x[0])(i)/
bw);
497 for(
int i=0;i<
nx;i++) {
498 for(
int j=0;
j<
nx;
j++) {
501 cout<<
"bad error matrix: iter="<<iter<<
"\n";
504 h2->SetBinContent(i+1,
j+1,rho);
524 for(
int i=0;i<
nx;i++) {
525 dx(i,0)= (*
x[
nr])(i)-(*
x[0])(i);
530 for(
int i=0;i<
nx;i++) {
531 double bw=
h->GetXaxis()->GetBinWidth(i+1);
532 h->SetBinContent(i+1,(*
x[0])(i)/
bw);
536 for(
int i=0;i<
nx;i++) {
537 for(
int j=0;
j<
nx;
j++) {
541 cout<<
"bad error matrix: iter="<<iter<<
"\n";
544 h2->SetBinContent(i+1,
j+1,rho);
554 cout<<
"IDS number of iterations: "<<
niterIDS<<
"\n";
560 for(
int iy=0;iy<
ny;iy++) {
561 for(
int ix=0;ix<
nx;ix++) {
577 for(
int iter=1;iter<=
niterIDS;iter++) {
578 if(!(iter %10)) cout<<iter<<
"\n";
590 for(ix=0;ix<
nIter.size();ix++) {
591 if(
nIter[ix]==iter)
break;
593 if(ix<
nIter.size()) {
609 for(
int i=0;i<
nx;i++) {
614 for(
int i=0;i<
nx;i++) {
615 double bw=
h->GetXaxis()->GetBinWidth(i+1);
622 for(
int i=0;i<
nx;i++) {
623 for(
int j=0;
j<
nx;
j++) {
627 cout<<
"bad error matrix: iter="<<iter<<
"\n";
630 h2->SetBinContent(i+1,
j+1,rho);
651 subn[0]=
new TPad(
"subn0",
"",0.,0.5,1.,1.);
653 subn[1]=
new TPad(
"subn1",
"",0.,0.,0.5,0.5);
654 subn[2]=
new TPad(
"subn2",
"",0.5,0.0,1.,0.5);
655 for(
int i=0;i<3;i++) {
656 subn[i]->SetFillStyle(0);
662 subc[0]=
new TPad(
"sub0",
"",0.,0.5,1.,1.);
664 subc[1]=
new TPad(
"sub1",
"",0.,0.,0.5,0.5);
666 subc[2]=
new TPad(
"sub2",
"",0.5,0.0,1.,0.5);
667 for(
int i=0;i<3;i++) {
668 subc[i]->SetFillStyle(0);
678 c2w->SaveAs(
"exampleTR.eps");
686 c2w->SaveAs(
"exampleAE.eps");
694 &table[table.size()-1].second);
700 c3c->SaveAs(
"inversion.eps");
708 &table[table.size()-1].second);
714 c3c->SaveAs(
"template.eps");
721 &table[table.size()-1].second);
727 c3c->SaveAs(
"templateA.eps");
734 &table[table.size()-1].second);
740 c3c->SaveAs(
"lcurveFA.eps");
747 &table[table.size()-1].second);
753 c3c->SaveAs(
"rhoscanFA.eps");
767 &table[table.size()-1].second);
768 c2sq->SaveAs(
"binbybin.eps");
782 isFitted ? &table[table.size()-1].second : nullptr);
806 isFitted ? &table[table.size()-1].second : 0);
817 int nfit=table.size();
825 fitChindf->GetXaxis()->SetBinLabel(fit+1,
f->GetName());
826 fitNorm->GetXaxis()->SetBinLabel(fit+1,
f->GetName());
827 fitMu->GetXaxis()->SetBinLabel(fit+1,
f->GetName());
828 fitSigma->GetXaxis()->SetBinLabel(fit+1,
f->GetName());
833 fitNorm->SetBinContent(fit+1,
f->GetParameter(0));
834 fitNorm->SetBinError(fit+1,
f->GetParError(0));
835 fitMu->SetBinContent(fit+1,
f->GetParameter(1));
836 fitMu->SetBinError(fit+1,
f->GetParError(1));
837 fitSigma->SetBinContent(fit+1,
f->GetParameter(2));
838 fitSigma->SetBinError(fit+1,
f->GetParError(2));
839 cout<<
"\""<<
f->GetName()<<
"\","<<
r[2]/
r[3]<<
","<<
r[3]
845 for(
int i=1;i<3;i++) {
846 cout<<
","<<
f->GetParameter(i)<<
",\"\302\261\","<<
f->GetParError(i);
853 lCurve->SetTitle(
"L curve;log_{10} L_{x};log_{10} L_{y}");
859 logTauX->SetTitle(
";log_{10} #tau;log_{10} L_{x}");
863 logTauY->SetTitle(
";log_{10} #tau;log_{10} L_{y}");
866 c4->SaveAs(
"lcurveL.eps");
874 rhoScan->SetTitle(
";log_{10}(#tau);average(#rho_{i})");
884 c4->SaveAs(
"scanTau.eps");
911 for(
int i=0;i<2;i++) {
914 gPad->SetLogy((i<1));
933 legend->SetFillStyle(1001);
958 gPad->SetLogy(
false);
989 legend->SetFillStyle(1001);
1004 c2sq->SaveAs(
"fitSigma.eps");
1028 TF1 const *
f=table[ifit].first;
1029 mean(ifit-
iFirst)=
f->GetParameter(1);
1038 for(
int g=0;
g<4;
g++) {
1050 TF1 const *
f=table[ifit].first;
1051 hist[0]=
new TH1D(table[ifit].first->GetName()+
TString(
"_chi2"),
1052 ";iteration;unfold-truth #chi^{2}/N_{D.F.}",1,0.2,1500.);
1055 hist[1]=
new TH1D(table[ifit].first->GetName()+
TString(
"_gcor"),
1056 ";iteration;avg(#rho_{i})",1,0.2,1500.);
1058 hist[2]=
new TH1D(table[ifit].first->GetName()+
TString(
"_mu"),
1059 ";iteration;parameter #mu",1,0.2,1500.);
1062 hist[3]=
new TH1D(table[ifit].first->GetName()+
TString(
"_sigma"),
1063 ";iteration;parameter #sigma",1,0.2,1500.);
1066 for(
int h=0;
h<4;
h++) {
1070 if( hist[
h]->GetBinError(1)>0.0) {
1087 double c=
h[0]->GetBinContent(
iSrc)+
h[1]->GetBinContent(
iDest);
1095 double c=
h[2]->GetBinContent(
iDest);
1096 double e=
h[2]->GetBinError(
iDest);
1117 int nx=
h->GetNbinsX();
1118 int ny=
h->GetNbinsY();
1119 double *
xBins=
new double[
nx+2];
1120 double *
yBins=
new double[
ny+2];
1121 for(
int i=1;i<=
nx;i++) {
1122 xBins[i-1]=
h->GetXaxis()->GetBinLowEdge(i);
1126 for(
int i=1;i<=
ny;i++) {
1127 yBins[i-1]=
h->GetYaxis()->GetBinLowEdge(i);
1134 for(
int ix=0;ix<=
nx+1;ix++) {
1135 for(
int iy=0;iy<=
ny+1;iy++) {
1136 r->SetBinContent(ix,iy,
h->GetBinContent(ix,iy));
1137 r->SetBinError(ix,iy,
h->GetBinError(ix,iy));
1147 int nx=
h->GetNbinsX();
1148 double *
xBins=
new double[
nx+2];
1149 for(
int i=1;i<=
nx;i++) {
1150 xBins[i-1]=
h->GetXaxis()->GetBinLowEdge(i);
1157 for(
int ix=0;ix<=
nx+1;ix++) {
1158 r->SetBinContent(ix,
h->GetBinContent(ix));
1159 r->SetBinError(ix,
h->GetBinError(ix));
1166 double x1=
h->GetXaxis()->GetBinLowEdge(
h->GetNbinsX());
1167 double x2=
h->GetXaxis()->GetBinUpEdge(
h->GetNbinsX());
1168 double y0=
h->GetYaxis()->GetBinLowEdge(1);
1169 double y2=
h->GetYaxis()->GetBinUpEdge(
h->GetNbinsY());;
1170 if(
h->GetDimension()==1) {
1177 textX->SetTextSize(0.05);
1178 textX->SetTextAngle(90.);
1185 double x0=
h->GetXaxis()->GetBinLowEdge(1);
1186 double x2=
h->GetXaxis()->GetBinUpEdge(
h->GetNbinsX());
1187 double y1=
h->GetYaxis()->GetBinLowEdge(
h->GetNbinsY());;
1188 double y2=
h->GetYaxis()->GetBinUpEdge(
h->GetNbinsY());;
1192 textY->SetTextSize(0.05);
1200 h->SetTitle(
"migration probabilities;P_{T}(gen) [GeV];P_{T}(rec) [GeV]");
1206 h->SetTitle(
"efficiency;P_{T}(gen) [GeV];#epsilon");
1208 h->SetMinimum(0.75);
1225 for(
int i=1;i<=
histMcRec->GetNbinsX();i++) {
1231 histMcRec->SetTitle(
"Reconstructed;P_{T}(rec);Nevent / GeV");
1250 for(
int ix=1;ix<=
nrec;ix++) {
1274 cout<<
"can not fold back: "<<
nrec
1293 legRec->SetBorderSize(0);
1382 (
"#chi^{2}/%d=%.1f prob=%.3f",
1383 (
int)(*
r)[3],(*
r)[2]/(*
r)[3],
1434 h->SetTitle(
"correlation coefficients;P_{T}(gen) [GeV];P_{T}(gen) [GeV]");
1456 cout<<
"fcn flag=0: npar="<<
npar<<
" gin="<<
gin<<
" par=[";
1457 for(
int i=0;i<
npar;i++) {
1465 for(
int i=0;i<=
n;i++) {
1467 if(i<1)
x1=
g_fcnHist->GetXaxis()->GetBinLowEdge(i+1);
1471 double iy=
u[0]*
u[2]*(
y1-
y0)/(
x1-x0);
1489 cout<<
h->GetName()<<
"\n";
1495 int n=
h->GetNbinsX()-1;
1498 for(
int i=0;i<
n;i++) {
1499 for(
int j=0;
j<
n;
j++) {
1501 (
h->GetBinError(i+1)*
h->GetBinError(
j+1));
1507 for(
int i=0;i<
n;i++) {
1511 cout<<
"bad eigenvalue i="<<i<<
" di="<<
di(i)<<
"\n";
1520 for(
int i=0;i<
n;i++) {
1524 for(
int j=0;
j<
n;
j++) {
1533 for(
int i=0;i<=
n;i++) {
1534 for(
int j=0;
j<=
n;
j++) {
1537 (
h->GetBinError(i+1)*
h->GetBinError(
j+1));
1547 for(
int i=0;i<=
n;i++) {
1551 cout<<
"bad eigenvalue i="<<i<<
" di1="<<
di1(i)<<
"\n";
1558 for(
int i=0;i<=
n;i++) {
1564 cout<<
"bad global correlation "<<i<<
" "<<
gcor2<<
"\n";
1586 double xmax=
h->GetXaxis()->GetBinUpEdge(
h->GetNbinsX()-1);
1589 landau->SetParameter(0,6000.);
1590 landau->SetParameter(1,5.);
1591 landau->SetParameter(2,2.);
1592 landau->SetParError(0,10.);
1593 landau->SetParError(1,0.5);
1594 landau->SetParError(2,0.1);
1599 r[1]=
h->GetNbinsX()-1-
landau->GetNpar();
1600 for(
int i=0;i<
h->GetNbinsX()-1;i++) {
1601 double di=
h->GetBinContent(i+1)-
truth->GetBinContent(i+1);
1603 for(
int j=0;
j<
h->GetNbinsX()-1;
j++) {
1604 double dj=
h->GetBinContent(
j+1)-
truth->GetBinContent(
j+1);
1605 r[2]+=
di*
dj*(*g_fcnMatrix)(i,
j);
1608 double pull=
di/
h->GetBinError(i+1);
1623 table.push_back(make_pair(landau,
r));
1632#include "ids_code.cc"
1638 for(
Int_t i=0; i<
N_; i++ ){ (*soustr)[i] = 0.; }
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Int_t gErrorIgnoreLevel
Error handling routines.
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
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.
fit(model, train_loader, val_loader, num_epochs, batch_size, optimizer, criterion, save_best, scheduler)
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)