25 TAxis const *genAxis,*detAxis;
52 for(
int iGen=0;iGen<nGen;iGen++) {
54 for(
int iRec=0;iRec<=nRec;iRec++) {
61 if((iRec>0)&&(iRec<=fA->GetNrows())) {
69 (*fA)(iRec,iGen) /=
sum;
70 epsilon += (*fA)(iRec,iGen);
73 (*fEpsilon)(iGen)=epsilon;
97 if(numIterations<
fStep) {
100 while(
fStep<numIterations) {
107 for(
int iRec=1;iRec<nRec;iRec++) {
130 for(
int iRec=1;iRec<nRec;iRec++) {
142 TVectorD Ax_plus_bgr=(*fA)*(*fX)+(*fBgr);
146 for(
int i=0;i<
f.GetNrows();i++) {
147 f(i,0)=(*fY)(i)/Ax_plus_bgr(i);
149 dfdy(i,i)=1./Ax_plus_bgr(i);
151 dfdy(i,j) -=
f(i,0)/Ax_plus_bgr(i)*ADXDY(i,j);
159 double factor=At_f(i,0)/(*fEpsilon)(i);
161 (*fDXDY)(i,j) *= factor;
162 (*fDXDY)(i,j) += (*
fX)(i)/(*
fEpsilon)(i)*At_dfdy(i,j);
176 std::vector<double> nIter,scanSURE,scanDeviance,scanDF;
177 nIter.push_back(
fStep);
178 scanSURE.push_back(minSURE);
180 scanDF.push_back(
GetDF());
181 Info(
"TUnfoldIterativeEM::ScanSURE",
182 "step=%d SURE=%lf DF=%lf deviance=%lf",
183 fStep,*scanSURE.rbegin(),*scanDF.rbegin(),*scanDeviance.rbegin());
184 while(
fStep<nIterMax) {
187 nIter.push_back(
fStep);
188 scanSURE.push_back(SURE);
190 scanDF.push_back(
GetDF());
191 Info(
"TUnfoldIterativeEM::ScanSURE",
192 "step=%d SURE=%lf DF=%lf deviance=%lf",
193 fStep,*scanSURE.rbegin(),*scanDF.rbegin(),*scanDeviance.rbegin());
202 *graphSURE=
new TGraph(nIter.size(),nIter.data(),scanSURE.data());
206 (scanDeviance.size(),scanDF.data(),scanDeviance.data());
217(
const char *histogramName,
const char *histogramTitle,
218 const char *distributionName,
const char *projectionMode,
219 Bool_t useAxisBinning)
const {
221 Int_t *binMap=
nullptr;
223 (histogramName,useAxisBinning,&binMap,histogramTitle,projectionMode);
226 Int_t destBin=binMap[i];
227 if(destBin<0.)
continue;
228 r->SetBinContent(destBin,
r->GetBinContent(destBin)+(*
fX)(i));
231 if(binMap[k]!=destBin)
continue;
234 Vii += (*fDXDY)(i,j)*(*
fY)(j)*(*
fDXDY)(k,j);
237 r->SetBinError(destBin,
TMath::Sqrt(
r->GetBinError(destBin)+Vii));
247(
const char *histogramName,
const char *histogramTitle,
248 const char *distributionName,
const char *projectionMode,
251 Int_t *binMap=
nullptr;
253 (histogramName,useAxisBinning,&binMap,histogramTitle,projectionMode);
256 if(addBgr) folded+= *
fBgr;
259 Int_t destBin=binMap[i];
260 if(destBin<0.)
continue;
261 r->SetBinContent(destBin,
r->GetBinContent(destBin)+folded(i-1));
264 if(binMap[k]!=destBin)
continue;
265 for(
int j=0;j<dFoldedDY.
GetNcols();j++) {
267 Vii += dFoldedDY(i-1,j)*(*fY)(j)*dFoldedDY(k-1,j);
270 r->SetBinError(destBin,
TMath::Sqrt(
r->GetBinError(destBin)+Vii));
282 TVectorD Ax_plus_bgr=(*fA)*(*fX)+(*fBgr);
284 for(
int i=0;i<Ax_plus_bgr.
GetNrows();i++) {
286 double mu=Ax_plus_bgr(i);
300 r += (*fA)(i,j)*(*
fDXDY)(j,i);
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
TMatrixT< Double_t > TMatrixD
TVectorT< Double_t > TVectorD
Class to manage histogram axis.
A TGraph is an object made of two arrays X and Y with npoints each.
TH1 is the base class of all histogram classes in ROOT.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Service class for 2-D histogram classes.
Double_t GetBinContent(Int_t binx, Int_t biny) const override
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
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
Int_t GetEndBin(void) const
last+1 bin of this node (includes children)
TUnfoldBinning const * FindNode(char const *name) const
traverse the tree and return the first node which matches the given name
const TUnfoldBinning * f_constInputBins
Double_t GetDeviance(void) const
const TUnfoldBinning * f_constOutputBins
TUnfoldBinning * f_outputBins
~TUnfoldIterativeEM() override
Double_t GetSURE(void) const
virtual void DoUnfold(Int_t numIterations)
Double_t GetDF(void) const
TH1 * GetFoldedOutput(const char *histogramName, const char *histogramTitle=nullptr, const char *distributionName=nullptr, const char *projectionMode=nullptr, Bool_t useAxisBinning=kTRUE, Bool_t addBgr=kFALSE) const
void SubtractBackground(const TH1 *hist_bgr, const char *name, Double_t scale=1.0)
virtual void IterateOnce(void)
TH1 * GetOutput(const char *histogramName, const char *histogramTitle=nullptr, const char *distributionName=nullptr, const char *projectionMode=nullptr, Bool_t useAxisBinning=kTRUE) const
virtual Int_t SetInput(const TH1 *hist_y, Double_t scaleBias=1.0)
TUnfoldBinning * f_inputBins
virtual Int_t ScanSURE(Int_t nIterMax, TGraph **SURE=nullptr, TGraph **df_deviance=nullptr)
EHistMap
arrangement of axes for the response matrix (TH2 histogram)
@ kHistMapOutputHoriz
truth level on x-axis of the response matrix
Double_t Log(Double_t x)
Returns the natural logarithm of x.
Double_t Sqrt(Double_t x)
Returns the square root of x.
static uint64_t sum(uint64_t i)