143 fRegularisationConditions=0;
146 TUnfoldDensity::~TUnfoldDensity(
void)
157 const TUnfoldBinning *inputBins,
const char *regularisationDistribution,
158 const char *regularisationAxisSteering) :
175 TAxis const *genAxis,*detAxis;
192 Error(
"TUnfoldDensity",
193 "Invalid output binning scheme (node is not the root node)");
205 Error(
"TUnfoldDensity",
206 "Invalid input binning scheme (node is not the root node)");
212 if(nOutMapped!= nOut) {
213 Error(
"TUnfoldDensity",
214 "Output binning incompatible number of bins %d!=%d",
220 if(nInputMapped!= nInput) {
221 Error(
"TUnfoldDensity",
222 "Input binning incompatible number of bins %d!=%d ",
223 nInputMapped, nInput);
227 for (
Int_t ix = 0; ix <= nOut+1; ix++) {
236 (regmode,densityMode,regularisationDistribution,
237 regularisationAxisSteering);
257 if(binSize>0.0) factor /= binSize;
269 const char *axisSteering)
296 distribution,axisSteering);
301 EDensityMode densityMode,
const char *distribution,
const char *axisSteering) {
311 if((!distribution)|| !
TString(distribution).CompareTo(binning->
GetName())) {
339 Int_t isOptionGiven[6] = {0};
342 isOptionGiven[0] |= isOptionGiven[1];
344 isOptionGiven[2] |= isOptionGiven[3];
346 isOptionGiven[4] |= isOptionGiven[5];
348 cout<<
" "<<isOptionGiven[0]
349 <<
" "<<isOptionGiven[1]
350 <<
" "<<isOptionGiven[2]
351 <<
" "<<isOptionGiven[3]
352 <<
" "<<isOptionGiven[4]
353 <<
" "<<isOptionGiven[5]
356 Info(
"RegularizeOneDistribution",
"regularizing %s regMode=%d" 357 " densityMode=%d axisSteering=%s",
359 axisSteering ? axisSteering :
"");
362 std::vector<Double_t> factor(endBin-startBin);
364 for(
Int_t bin=startBin;bin<endBin;bin++) {
366 if(factor[bin-startBin] !=0.0) nbin++;
369 cout<<
"initial number of bins "<<nbin<<
"\n";
375 for(
Int_t bin=startBin;bin<endBin;bin++) {
376 Int_t uStatus,oStatus;
378 if(uStatus & isOptionGiven[1]) factor[bin-startBin]=0.;
379 if(oStatus & isOptionGiven[3]) factor[bin-startBin]=0.;
380 if(factor[bin-startBin] !=0.0) nbin++;
383 cout<<
"after underflow/overflow bin removal "<<nbin<<
"\n";
389 for(
Int_t bin=startBin;bin<endBin;bin++) {
390 if(factor[bin-startBin]==0.0)
continue;
396 thisRegularisationBinning->
AddBinning(
"size",nRegBins);
399 for(
Int_t direction=0;direction<dimension;direction++) {
402 Int_t directionMask=(1<<direction);
404 (isOptionGiven[5] & directionMask) ?
406 (direction,isOptionGiven[0] & directionMask,
407 isOptionGiven[2] & directionMask) : 1.0;
408 for(
Int_t bin=startBin;bin<endBin;bin++) {
410 if(factor[bin-startBin]==0.0)
continue;
415 (bin,direction,&iPrev,&distPrev,&iNext,&distNext);
417 Double_t f0 = -factor[bin-startBin];
419 if(isOptionGiven[4] & directionMask) {
421 f0 *= binDistanceNormalisation/distNext;
422 f1 *= binDistanceNormalisation/distNext;
428 if((f0==0.0)||(f1==0.0))
continue;
432 std::cout<<
"Added Reg: bin "<<bin<<
" "<<f0
433 <<
" next: "<<iNext<<
" "<<f1<<
"\n";
437 Double_t f0 = factor[iPrev-startBin];
440 if(isOptionGiven[4] & directionMask) {
441 if((distPrev<0.)&&(distNext>0.)) {
446 f1 *= f*(1./distPrev+1./distNext);
454 if((f0==0.0)||(f1==0.0)||(f2==0.0))
continue;
458 std::cout<<
"Added Reg: prev "<<iPrev<<
" "<<f0
459 <<
" bin: "<<bin<<
" "<<f1
460 <<
" next: "<<iNext<<
" "<<f2<<
"\n";
473 thisRegularisationBinning->
AddBinning(name,nRegBins);
483 (
const char *histogramName,
const char *histogramTitle,
484 const char *distributionName,
const char *axisSteering,
485 Bool_t useAxisBinning)
const 504 (histogramName,useAxisBinning,&binMap,histogramTitle,axisSteering);
515 (
const char *histogramName,
const char *histogramTitle,
516 const char *distributionName,
const char *axisSteering,
517 Bool_t useAxisBinning)
const 528 (histogramName,useAxisBinning,&binMap,histogramTitle,axisSteering);
532 if(binMap)
delete [] binMap;
537 (
const char *histogramName,
const char *histogramTitle,
538 const char *distributionName,
const char *axisSteering,
551 (histogramName,useAxisBinning,&binMap,histogramTitle,axisSteering);
558 if(binMap)
delete [] binMap;
563 (
const char *histogramName,
const char *bgrSource,
const char *histogramTitle,
564 const char *distributionName,
const char *axisSteering,
Bool_t useAxisBinning,
581 (histogramName,useAxisBinning,&binMap,histogramTitle,axisSteering);
585 if(binMap)
delete [] binMap;
590 (
const char *histogramName,
const char *histogramTitle,
591 const char *distributionName,
const char *axisSteering,
592 Bool_t useAxisBinning)
const 603 (histogramName,useAxisBinning,&binMap,histogramTitle,axisSteering);
607 if(binMap)
delete [] binMap;
612 (
const char *histogramName,
const char *histogramTitle,
613 const char *distributionName,
const char *axisSteering,
637 (histogramName,useAxisBinning,&binMap,histogramTitle,axisSteering);
642 TString ematName(histogramName);
643 ematName +=
"_inverseEMAT";
646 (ematName,useAxisBinning,&binMap2D,histogramTitle,
648 if(binMap2D)
delete [] binMap2D;
650 Error(
"GetRhoItotal",
651 "can not return inverse of error matrix for this binning");
659 if(binMap)
delete [] binMap;
664 (
const char *histogramName,
const char *histogramTitle,
665 const char *distributionName,
const char *axisSteering,
689 (histogramName,useAxisBinning,&binMap,histogramTitle,axisSteering);
694 TString ematName(histogramName);
695 ematName +=
"_inverseEMAT";
698 (ematName,useAxisBinning,&binMap2D,histogramTitle,
700 if(binMap2D)
delete [] binMap2D;
702 Error(
"GetRhoItotal",
703 "can not return inverse of error matrix for this binning");
711 if(binMap)
delete [] binMap;
716 (
const char *source,
const char *histogramName,
717 const char *histogramTitle,
const char *distributionName,
718 const char *axisSteering,
Bool_t useAxisBinning) {
739 (histogramName,useAxisBinning,&binMap,histogramTitle,axisSteering);
746 if(binMap)
delete [] binMap;
751 (
const char *bgrSource,
const char *histogramName,
752 const char *histogramTitle,
const char *distributionName,
753 const char *axisSteering,
Bool_t useAxisBinning) {
775 (histogramName,useAxisBinning,&binMap,histogramTitle,axisSteering);
782 if(binMap)
delete [] binMap;
787 (
const char *histogramName,
const char *histogramTitle,
788 const char *distributionName,
const char *axisSteering,
Bool_t useAxisBinning)
809 (histogramName,useAxisBinning,&binMap,histogramTitle,axisSteering);
816 if(binMap)
delete [] binMap;
821 (
const char *histogramName,
const char *histogramTitle,
822 const char *distributionName,
const char *axisSteering,
843 (histogramName,histogramTitle,distributionName,
844 axisSteering,useAxisBinning);
856 if((e_i>0.0)&&(e_j>0.0)) {
875 (
const char *histogramName,
const char *histogramTitle,
876 const char *distributionName,
const char *axisSteering,
898 (histogramName,useAxisBinning,&binMap,histogramTitle,axisSteering);
902 if(binMap)
delete [] binMap;
908 (
const char *bgrSource,
const char *histogramName,
909 const char *histogramTitle,
const char *distributionName,
910 const char *axisSteering,
Bool_t useAxisBinning)
931 (histogramName,useAxisBinning,&binMap,histogramTitle,axisSteering);
935 if(binMap)
delete [] binMap;
940 (
const char *histogramName,
const char *histogramTitle,
941 const char *distributionName,
const char *axisSteering,
963 (histogramName,useAxisBinning,&binMap,histogramTitle,axisSteering);
967 if(binMap)
delete [] binMap;
972 (
const char *histogramName,
const char *histogramTitle,
973 Bool_t useAxisBinning)
const 982 useAxisBinning,useAxisBinning,histogramTitle);
988 (
const char *histogramName,
const char *histogramTitle,
989 const char *distributionName,
const char *axisSteering,
1011 (histogramName,useAxisBinning,&binMap,histogramTitle,axisSteering);
1015 if(binMap)
delete [] binMap;
1020 (
const char *histogramName,
const char *histogramTitle,
Bool_t useAxisBinning)
1032 "remove invalid scheme of regularisation conditions %d %d",
1035 fRegularisationConditions=0;
1039 Warning(
"GetL",
"create flat regularisation conditions scheme");
1043 useAxisBinning,useAxisBinning,histogramTitle);
1049 (
const char *histogramName,
const char *histogramTitle)
1067 "remove invalid scheme of regularisation conditions %d %d",
1070 fRegularisationConditions=0;
1074 Warning(
"GetLxMinusBias",
"create flat regularisation conditions scheme");
1077 (histogramName,
kFALSE,0,histogramTitle);
1081 if(Ldx_rows[row]<Ldx_rows[row+1]) {
1090 (
const char *distributionName)
const 1098 (
const char *distributionName)
const 1107 Int_t mode,
const char *distribution,
const char *axisSteering,
1127 typedef std::map<Double_t,Double_t> TauScan_t;
1128 typedef std::map<Double_t,std::pair<Double_t,Double_t> > LCurve_t;
1153 if((tauMin<=0)||(tauMax<=0.0)||(tauMin>=tauMax)) {
1163 Error(
"ScanTau",
"too few input bins, NDF<=0 %d",
GetNdf());
1168 Info(
"ScanTau",
"logtau=-Infinity y=%lf X=%lf Y=%lf",y0,X0,Y0);
1176 Fatal(
"ScanTau",
"problem (missing regularisation?) X=%f Y=%f",
1182 Info(
"ScanTau",
"logtau=%lf y=%lf X=%lf Y=%lf",logTau,y,
1188 while(((
int)curve.size()<nPoint-1)&&
1196 Info(
"ScanTay",
"logtau=%lf y=%lf X=%lf Y=%lf",logTau,y,
1208 Info(
"ScanTau",
"logtau=%lf y=%lf X=%lf Y=%lf",logTauMax,y,
1216 Info(
"ScanTau",
"logtau=%lf y=%lf X=%lf Y=%lf",logTauMin,y,
1223 while((
int)curve.size()<nPoint-1) {
1229 TauScan_t::const_iterator i0,i1;
1234 for(;i0!=curve.end();i0++) {
1235 if((*i0).second<yMin) {
1237 logTauYMin=(*i0).first;
1246 for(i1++;i1!=curve.end();i1++) {
1251 +0.25*
TMath::Power(0.5*((*i0).first+(*i1).first)-logTauYMin,2.)/
1252 ((*curve.rbegin()).
first-(*curve.begin()).
first)/nPoint;
1253 if((dist<=0.0)||(dist>distMax)) {
1255 logTau=0.5*((*i0).first+(*i1).first);
1263 Info(
"ScanTau",
"logtau=%lf y=%lf X=%lf Y=%lf",logTau,y,
1278 for(TauScan_t::const_iterator i=curve.begin();i!=curve.end();i++) {
1295 for(
Int_t i=iskip;i<n-1-iskip;i++) {
1318 xx = m_p_half + discr;
1320 xx = m_p_half - discr;
1324 if((xx>0.0)&&(xx<dx)) {
1325 y=splineC->
Eval(x+xx);
1338 if((xx>0.0)&&(xx<dx)) {
1339 y=splineC->
Eval(x+xx);
1362 Info(
"ScanTau",
"Result logtau=%lf y=%lf X=%lf Y=%lf",logTauFin,y,
1369 Int_t bestChoice=-1;
1370 if(curve.size()>0) {
1374 for( TauScan_t::const_iterator i=curve.begin();i!=curve.end();i++) {
1375 if(logTauFin==(*i).first) {
1385 if(distribution) name+= distribution;
1387 if(axisSteering) name += axisSteering;
1389 (*scanResult)=
new TSpline3(name+
"%log(tau)",logT,y,n);
1399 for(LCurve_t::const_iterator i=lcurve.begin();i!=lcurve.end();i++) {
1401 x[
n]=(*i).second.first;
1402 y[
n]=(*i).second.second;
1407 *lCurvePlot=
new TGraph(n,x,y);
1408 (*lCurvePlot)->SetTitle(
"L curve");
1411 *logTauXPlot=
new TSpline3(
"log(chi**2)%log(tau)",logT,x,n);
1413 *logTauYPlot=
new TSpline3(
"log(reg.cond)%log(tau)",logT,y,n);
1422 (
Int_t mode,
const char *distribution,
const char *axisSteering)
1458 if(distribution) name += distribution;
1460 if(axisSteering) name += axisSteering;
1478 if(c>rhoMax) rhoMax=
c;
1495 Fatal(
"GetScanVariable",
"mode %d not implemented",mode);
virtual const char * GetName() const
Returns name of object.
virtual const Element * GetMatrixArray() const
TUnfoldBinning const * GetChildNode(void) const
double dist(Rotation3D const &r1, Rotation3D const &r2)
static long int sum(long int i)
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
TH1 * CreateHistogram(const char *histogramName, Bool_t originalAxisBinning=kFALSE, Int_t **binMap=0, const char *histogramTitle=0, const char *axisSteering=0) const
TH2D * CreateErrorMatrixHistogram(const char *histogramName, Bool_t originalAxisBinning, Int_t **binMap=0, const char *histogramTitle=0, const char *axisSteering=0) const
const TUnfoldBinning * fConstOutputBins
virtual const Int_t * GetRowIndexArray() const
void GetEmatrixInput(TH2 *ematrix, const Int_t *binMap=0, Bool_t clearEmat=kTRUE)
virtual Double_t GetDistributionAverageBinSize(Int_t axis, Bool_t includeUnderflow, Bool_t includeOverflow) const
virtual Int_t ScanTau(Int_t nPoint, Double_t tauMin, Double_t tauMax, TSpline **scanResult, Int_t mode=kEScanTauRhoAvg, const char *distribution=0, const char *projectionMode=0, TGraph **lCurvePlot=0, TSpline **logTauXPlot=0, TSpline **logTauYPlot=0)
Bool_t GetDeltaSysSource(TH1 *hist_delta, const char *source, const Int_t *binMap=0)
TH1 * GetBias(const char *histogramName, const char *histogramTitle=0, const char *distributionName=0, const char *projectionMode=0, Bool_t useAxisBinning=kTRUE) const
Base class for spline implementation containing the Draw/Paint methods //.
Double_t GetBinSize(Int_t iBin) const
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
void GetBinNeighbours(Int_t globalBin, Int_t axis, Int_t *prev, Double_t *distPrev, Int_t *next, Double_t *distNext) const
void GetBinUnderflowOverflowStatus(Int_t iBin, Int_t *uStatus, Int_t *oStatus) const
TH2 * GetEmatrixSysUncorr(const char *histogramName, const char *histogramTitle=0, const char *distributionName=0, const char *projectionMode=0, Bool_t useAxisBinning=kTRUE)
TH1 * GetFoldedOutput(const char *histogramName, const char *histogramTitle=0, const char *distributionName=0, const char *projectionMode=0, Bool_t useAxisBinning=kTRUE, Bool_t addBgr=kFALSE) const
TMatrixDSparse * MultiplyMSparseM(const TMatrixDSparse *a, const TMatrixD *b) const
void GetEmatrixSysBackgroundUncorr(TH2 *ematrix, const char *source, const Int_t *binMap=0, Bool_t clearEmat=kTRUE)
TUnfoldBinning * fOwnedOutputBins
TH2 * GetL(const char *histogramName, const char *histogramTitle=0, Bool_t useAxisBinning=kTRUE)
void RegularizeDistribution(ERegMode regmode, EDensityMode densityMode, const char *distribution, const char *axisSteering)
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
TUnfoldBinning const * GetNextNode(void) const
Double_t GetRhoI(TH1 *rhoi, const Int_t *binMap=0, TH2 *invEmat=0) const
TH2 * GetEmatrixSysBackgroundUncorr(const char *bgrSource, const char *histogramName, const char *histogramTitle=0, const char *distributionName=0, const char *projectionMode=0, Bool_t useAxisBinning=kTRUE)
virtual Int_t GetDimension() const
Bool_t AddRegularisationCondition(Int_t i0, Double_t f0, Int_t i1=-1, Double_t f1=0., Int_t i2=-1, Double_t f2=0.)
TH1 * GetLxMinusBias(const char *histogramName, const char *histogramTitle=0)
TH2 * GetEmatrixTotal(const char *histogramName, const char *histogramTitle=0, const char *distributionName=0, const char *projectionMode=0, Bool_t useAxisBinning=kTRUE)
const TUnfoldBinning * GetOutputBinning(const char *distributionName=0) const
Int_t GetEndBin(void) const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
const TMatrixD * GetX(void) const
void GetEmatrixSysUncorr(TH2 *ematrix, const Int_t *binMap=0, Bool_t clearEmat=kTRUE)
Double_t Log10(Double_t x)
virtual Double_t GetLcurveY(void) const
TH1 * GetBackground(const char *histogramName, const char *bgrSource=0, const char *histogramTitle=0, const char *distributionName=0, const char *projectionMode=0, Bool_t useAxisBinning=kTRUE, Int_t includeError=3, Bool_t clearHist=kTRUE) const
void RegularizeOneDistribution(const TUnfoldBinning *binning, ERegMode regmode, EDensityMode densityMode, const char *axisSteering)
std::vector< std::vector< double > > Data
Int_t GetStartBin(void) const
Int_t GetDistributionDimension(void) const
TUnfoldBinning * fRegularisationConditions
TUnfoldBinning const * GetParentNode(void) const
void GetBias(TH1 *bias, const Int_t *binMap=0) const
void DecodeAxisSteering(const char *axisSteering, const char *options, Int_t *isOptionGiven) const
virtual TString GetOutputBinName(Int_t iBinX) const
virtual Double_t DoUnfold(void)
Service class for 2-Dim histogram classes.
Class to manage histogram axis.
TH2 * GetRhoIJtotal(const char *histogramName, const char *histogramTitle=0, const char *distributionName=0, const char *projectionMode=0, Bool_t useAxisBinning=kTRUE)
void GetEmatrixTotal(TH2 *ematrix, const Int_t *binMap=0)
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...
virtual Double_t GetLcurveX(void) const
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TH1 * GetInput(const char *histogramName, const char *histogramTitle=0, const char *distributionName=0, const char *projectionMode=0, Bool_t useAxisBinning=kTRUE) const
const TUnfoldBinning * GetInputBinning(const char *distributionName=0) const
Bool_t GetDeltaSysTau(TH1 *delta, const Int_t *binMap=0)
TH1 * GetDeltaSysTau(const char *histogramName, const char *histogramTitle=0, const char *distributionName=0, const char *projectionMode=0, Bool_t useAxisBinning=kTRUE)
void GetBackground(TH1 *bgr, const char *bgrSource=0, const Int_t *binMap=0, Int_t includeError=3, Bool_t clearHist=kTRUE) const
static TH2D * CreateHistogramOfMigrations(TUnfoldBinning const *xAxis, TUnfoldBinning const *yAxis, char const *histogramName, Bool_t originalXAxisBinning=kFALSE, Bool_t originalYAxisBinning=kFALSE, char const *histogramTitle=0)
TH1 * GetRhoIstatbgr(const char *histogramName, const char *histogramTitle=0, const char *distributionName=0, const char *projectionMode=0, Bool_t useAxisBinning=kTRUE, TH2 **ematInv=0)
This class serves as a container of analysis bins analysis bins are specified by defining the axes of...
TH1 * GetDeltaSysSource(const char *source, const char *histogramName, const char *histogramTitle=0, const char *distributionName=0, const char *projectionMode=0, Bool_t useAxisBinning=kTRUE)
TString GetDistributionAxisLabel(Int_t axis) const
virtual TString GetOutputBinName(Int_t iBinX) const
TH1 * GetOutput(const char *histogramName, const char *histogramTitle=0, const char *distributionName=0, const char *projectionMode=0, Bool_t useAxisBinning=kTRUE) const
void GetProbabilityMatrix(TH2 *A, EHistMap histmap) const
void GetFoldedOutput(TH1 *folded, const Int_t *binMap=0) const
void GetInput(TH1 *inputData, const Int_t *binMap=0) const
Int_t GetDistributionNumberOfBins(void) const
const TUnfoldBinning * fConstInputBins
TString GetBinName(Int_t iBin) const
Int_t GetTH1xNumberOfBins(Bool_t originalAxisBinning=kTRUE, const char *axisSteering=0) const
void GetCoeff(Int_t i, Double_t &x, Double_t &y, Double_t &b, Double_t &c, Double_t &d)
TH1 * GetDeltaSysBackgroundScale(const char *bgrSource, const char *histogramName, const char *histogramTitle=0, const char *distributionName=0, const char *projectionMode=0, Bool_t useAxisBinning=kTRUE)
TUnfoldBinning * fOwnedInputBins
double f2(const double *x)
void GetOutput(TH1 *output, const Int_t *binMap=0) const
A Graph is a graphics object made of two arrays X and Y with npoints each.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual Double_t GetScanVariable(Int_t mode, const char *distribution, const char *projectionMode)
Double_t GetDensityFactor(EDensityMode densityMode, Int_t iBin) const
TH2 * GetEmatrixInput(const char *histogramName, const char *histogramTitle=0, const char *distributionName=0, const char *projectionMode=0, Bool_t useAxisBinning=kTRUE)
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content.
TH1 * GetRhoItotal(const char *histogramName, const char *histogramTitle=0, const char *distributionName=0, const char *projectionMode=0, Bool_t useAxisBinning=kTRUE, TH2 **ematInv=0)
virtual Int_t GetNbinsX() const
Double_t Sqrt(Double_t x)
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
void GetRhoItotal(TH1 *rhoi, const Int_t *binMap=0, TH2 *invEmat=0)
Double_t Eval(Double_t x) const
Eval this spline at x.
TUnfoldBinning * AddBinning(TUnfoldBinning *binning)
Double_t GetChi2A(void) const
TUnfoldBinning const * FindNode(char const *name) const
TH2 * GetProbabilityMatrix(const char *histogramName, const char *histogramTitle=0, Bool_t useAxisBinning=kTRUE) const
Bool_t GetDeltaSysBackgroundScale(TH1 *delta, const char *source, const Int_t *binMap=0)
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual Double_t GetBinFactor(Int_t iBin) const
virtual Int_t GetNbinsY() const
void RegularizeDistributionRecursive(const TUnfoldBinning *binning, ERegMode regmode, EDensityMode densityMode, const char *distribution, const char *axisSteering)