143 :
TUnfold(hist_A,histmap,regmode,constraint)
156 fAoutside =
new TMatrixD(GetNx(),2);
159 fDAinColRelSq =
new TMatrixD(GetNx(),1);
161 Int_t nmax=GetNx()*GetNy();
167 for (
Int_t ix = 0; ix < GetNx(); ix++) {
168 Int_t ibinx = fXToHist[ix];
169 Double_t sum_sq= fSumOverY[ix]*fSumOverY[ix];
170 for (
Int_t ibiny = 0; ibiny <= GetNy()+1; ibiny++) {
172 if (histmap == kHistMapOutputHoriz) {
180 (*fDAinColRelSq)(ix,0) += normerr_sq;
184 if (histmap == kHistMapOutputHoriz) {
189 }
else if(ibiny==GetNy()+1) {
191 if (histmap == kHistMapOutputHoriz) {
198 rowDAinRelSq[da_nonzero]=ibiny-1;
199 colDAinRelSq[da_nonzero] = ix;
200 dataDAinRelSq[da_nonzero] = normerr_sq;
201 if(dataDAinRelSq[da_nonzero]>0.0) da_nonzero++;
206 fDAinRelSq = CreateSparseMatrix(GetNy(),GetNx(),da_nonzero,
207 rowDAinRelSq,colDAinRelSq,dataDAinRelSq);
209 DeleteMatrix(&fDAinColRelSq);
211 delete[] rowDAinRelSq;
212 delete[] colDAinRelSq;
213 delete[] dataDAinRelSq;
225 if(fSysIn->FindObject(name)) {
226 Error(
"AddSysError",
"Source %s given twice, ignoring 2nd call.\n",name);
233 Int_t nmax= GetNx()*GetNy();
238 for (
Int_t ix = 0; ix < GetNx(); ix++) {
239 Int_t ibinx = fXToHist[ix];
241 for(
Int_t loop=0;loop<2;loop++) {
242 for (
Int_t ibiny = 0; ibiny <= GetNy()+1; ibiny++) {
245 if (histmap == kHistMapOutputHoriz) {
251 if(mode!=kSysErrModeMatrix) {
253 if((ibiny>0)&&(ibiny<=GetNy())) {
254 z0=aCopy(ibiny-1,ix)*fSumOverY[ix];
255 }
else if(ibiny==0) {
256 z0=(*fAoutside)(ix,0);
258 z0=(*fAoutside)(ix,1);
260 if(mode==kSysErrModeShift) {
262 }
else if(mode==kSysErrModeRelative) {
270 if((ibiny>0)&&(ibiny<=GetNy())) {
276 data[nmax]=z/sum-aCopy(ibiny-1,ix);
280 if(data[nmax] != 0.0) nmax++;
288 "source %s has no influence and has not been added.\n",name);
291 nmax,rows,cols,data);
316 Warning(
"DoBackgroundSubtraction",
317 "inverse error matrix from user input," 318 " not corrected for background");
326 for(key=bgrPtr.
Next();key;key=bgrPtr.
Next()) {
329 ((
const TPair *)*bgrPtr)->Value()
335 (*fY)(i,0) -= (*bgr)(i,0);
351 for(
Int_t k=vyydata_rows[i];k<vyydata_rows[i+1];k++) {
352 if(vyydata_data[k]>0.0) {
354 usedBin[vyydata_cols[k]]++;
361 for(key=bgrErrUncorrSqPtr.
Next();key;
362 key=bgrErrUncorrSqPtr.
Next()) {
365 ((
const TPair *)*bgrErrUncorrSqPtr)->Value()
372 if(!usedBin[yi])
continue;
373 vyy(yi,yi) +=(*bgrerruncorrSquared)(yi,0);
380 for(key=bgrErrScalePtr.
Next();key;key=bgrErrScalePtr.
Next()) {
383 ((
const TPair *)*bgrErrScalePtr)->Value()
390 if(!usedBin[yi])
continue;
392 if(!usedBin[yj])
continue;
393 vyy(yi,yj) +=(*bgrerrscale)(yi,0)* (*bgrerrscale)(yj,0);
406 Fatal(
"DoBackgroundSubtraction",
"No input vector defined");
412 const TH2 *hist_vyy_inv)
455 Error(
"SubtractBackground",
"Source %s given twice, ignoring 2nd call.\n",
463 (*bgrErrUncSq)(row,0) =
465 (*bgrErrCorr)(row,0) = scale_error*bgr->
GetBinContent(row+1);
473 Info(
"SubtractBackground",
474 "Background subtraction prior to setting input data");
480 (
TH1 *bgrHist,
const char *bgrSource,
const Int_t *binMap,
490 for(key=bgrPtr.
Next();key;key=bgrPtr.
Next()) {
492 if(bgrSource && bgrName.
CompareTo(bgrSource))
continue;
495 ((
const TPair *)*bgrPtr)->Value()
501 Int_t destBin=binMap[i];
508 if(includeError &1) {
510 for(key=bgrErrUncorrSqPtr.
Next();key;key=bgrErrUncorrSqPtr.
Next()) {
512 if(bgrSource && bgrName.
CompareTo(bgrSource))
continue;
515 ((
const TPair *)*bgrErrUncorrSqPtr)->Value()
522 Int_t destBin=binMap[i];
525 ((*bgrerruncorrSquared)(i,0)+
530 if(includeError & 2) {
532 for(key=bgrErrScalePtr.
Next();key;key=bgrErrScalePtr.
Next()) {
534 if(bgrSource && bgrName.
CompareTo(bgrSource))
continue;
537 ((
const TPair *)*bgrErrScalePtr)->Value()
543 Int_t destBin=binMap[i];
544 bgrHist->
SetBinError(destBin,hypot((*bgrerrscale)(i,0),
563 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,20,00) 579 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,20,00) 592 TUnfoldSys::~TUnfoldSys(
void)
663 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,20,00) 859 for(
int index=0;index<Z0sq_rows[Z0sq.
GetNrows()];index++) {
860 Z0sq_data[index] *= Z0sq_data[index];
872 for(
int index=0;index<Z1sq_rows[Z1sq.
GetNrows()];index++) {
873 Z1sq_data[index] *= Z1sq_data[index];
958 (
TH1 *hist_delta,
const char *source,
const Int_t *binMap)
1104 for(key=sysErrPtr.
Next();key;key=sysErrPtr.
Next()) {
1125 for(key=sysErrPtr.
Next();key;key=sysErrPtr.
Next()) {
1128 ((
const TPair *)*sysErrPtr)->Value()
1163 for(key=sysErrPtr.
Next();key;key=sysErrPtr.
Next()) {
1166 ((
const TPair *)*sysErrPtr)->Value()
1202 if(vdy_rows[i+1]>vdy_rows[i]) {
1203 r += vdy_data[vdy_rows[i]] * dy(i,0);
1234 Fatal(
"ScaleColumnsByVector error",
1235 "matrix cols/vector rows %d!=%d OR vector cols %d !=1\n",
1246 for(
Int_t index_m=rows_m[i];index_m<rows_m[i+1];index_m++) {
1247 Int_t j=cols_m[index_m];
1248 Int_t index_v=rows_v[j];
1249 if(index_v<rows_v[j+1]) {
1250 data_m[index_m] *= data_v[index_v];
1252 data_m[index_m] =0.0;
1258 for(
Int_t index=rows_m[i];index<rows_m[i+1];index++) {
1259 data_m[index] *= (*v)(cols_m[index],0);
1273 for(
Int_t i=0;i<nbin+2;i++) {
1280 for(
Int_t i=0;i<binMapSize;i++) {
1281 Int_t destBinI=binMap ? binMap[i] : i;
1283 if((destBinI>=0)&&(destBinI<nbin+2)&&(srcBinI>=0)) {
1284 Int_t index=delta_rows[srcBinI];
1285 if(index<delta_rows[srcBinI+1]) {
1286 c[destBinI]+=delta_data[index];
1291 for(
Int_t i=0;i<nbin+2;i++) {
void InitTUnfoldSys(void)
virtual const Element * GetMatrixArray() const
static long int sum(long int i)
TMatrixDSparse * InvertMSparseSymmPos(const TMatrixDSparse *A, Int_t *rank) const
TMatrixDSparse * fEmatUncorrX
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
static void DeleteMatrix(TMatrixD **m)
virtual void ClearResults(void)
Double_t GetChi2Sys(void)
virtual const Int_t * GetRowIndexArray() const
void GetEmatrixInput(TH2 *ematrix, const Int_t *binMap=0, Bool_t clearEmat=kTRUE)
Collectable string class.
Bool_t GetDeltaSysSource(TH1 *hist_delta, const char *source, const Int_t *binMap=0)
Double_t GetRhoIFromMatrix(TH1 *rhoi, const TMatrixDSparse *eOrig, const Int_t *binMap, TH2 *invEmat) const
void VectorMapToHist(TH1 *hist_delta, const TMatrixDSparse *delta, const Int_t *binMap)
virtual TMatrixDSparse * PrepareCorrEmat(const TMatrixDSparse *m1, const TMatrixDSparse *m2, const TMatrixDSparse *dsys)
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
TMatrixDSparse * fDAinRelSq
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual Int_t GetEntries() const
virtual void PrepareSysError(void)
void Add(TObject *obj)
This function may not be used (but we need to provide it since it is a pure virtual in TCollection)...
TUnfold is used to decompose a measurement y into several sources x given the measurement uncertainti...
void SetTauError(Double_t delta_tau)
TMatrixDSparse * MultiplyMSparseMSparse(const TMatrixDSparse *a, const TMatrixDSparse *b) const
TMatrixDSparse * MultiplyMSparseM(const TMatrixDSparse *a, const TMatrixD *b) const
virtual Int_t SetInput(const TH1 *hist_y, Double_t scaleBias=0.0, Double_t oneOverZeroError=0.0, const TH2 *hist_vyy=0, const TH2 *hist_vyy_inv=0)
#define ROOT_VERSION_CODE
void GetEmatrixSysBackgroundUncorr(TH2 *ematrix, const char *source, const Int_t *binMap=0, Bool_t clearEmat=kTRUE)
TMatrixDSparse * MultiplyMSparseMSparseTranspVector(const TMatrixDSparse *m1, const TMatrixDSparse *m2, const TMatrixTBase< Double_t > *v) const
TMatrixDSparse * CreateSparseMatrix(Int_t nrow, Int_t ncol, Int_t nele, Int_t *row, Int_t *col, Double_t *data) const
LongDouble_t Power(LongDouble_t x, LongDouble_t y)
const TMatrixDSparse * GetDXDY(void) const
void ScaleColumnsByVector(TMatrixDSparse *m, const TMatrixTBase< Double_t > *v) const
you should not use this method at all Int_t Int_t Double_t Double_t em
void GetEmatrixSysUncorr(TH2 *ematrix, const Int_t *binMap=0, Bool_t clearEmat=kTRUE)
unsigned int r3[N_CITIES]
TMatrixDSparse * fDeltaSysTau
const TMatrixDSparse * GetVxx(void) const
void GetEmatrixSysBackgroundScale(TH2 *ematrix, const char *source, const Int_t *binMap=0, Bool_t clearEmat=kTRUE)
TMatrixDSparse * MultiplyMSparseTranspMSparse(const TMatrixDSparse *a, const TMatrixDSparse *b) const
void DoBackgroundSubtraction(void)
const TMatrixDSparse * GetDXDAM(int i) const
TMatrixDSparse * GetSummedErrorMatrixXX(void)
virtual void SetBinError(Int_t bin, Double_t error)
See convention for numbering bins in TH1::GetBin.
TMatrixDSparse * GetSummedErrorMatrixYY(void)
void Error(const char *location, const char *msgfmt,...)
TMatrixTSparse< Double_t > TMatrixDSparse
const TMatrixDSparse * GetDXDtauSquared(void) const
TMatrixT< Double_t > TMatrixD
virtual void SetOwnerKeyValue(Bool_t ownkeys=kTRUE, Bool_t ownvals=kTRUE)
Set ownership for keys and values.
void GetEmatrixSysSource(TH2 *ematrix, const char *source, const Int_t *binMap=0, Bool_t clearEmat=kTRUE)
virtual Int_t SetInput(const TH1 *hist_y, Double_t scaleBias=0.0, Double_t oneOverZeroError=0.0, const TH2 *hist_vyy=0, const TH2 *hist_vyy_inv=0)
Service class for 2-Dim histogram classes.
virtual TMatrixDSparse * PrepareUncorrEmat(const TMatrixDSparse *m1, const TMatrixDSparse *m2)
void GetEmatrixTotal(TH2 *ematrix, const Int_t *binMap=0)
unsigned int r1[N_CITIES]
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...
void ClearHistogram(TH1 *h, Double_t x=0.) const
const TMatrixDSparse * GetVyyInv(void) const
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Bool_t GetDeltaSysTau(TH1 *delta, const Int_t *binMap=0)
void GetBackground(TH1 *bgr, const char *bgrSource=0, const Int_t *binMap=0, Int_t includeError=3, Bool_t clearHist=kTRUE) const
TString GetString() const
virtual const Int_t * GetColIndexArray() const
void SubtractBackground(const TH1 *hist_bgr, const char *name, Double_t scale=1.0, Double_t scale_error=0.0)
TMatrixDSparse * fVyyData
Class used by TMap to store (key,value) pairs.
void GetEmatrixSysTau(TH2 *ematrix, const Int_t *binMap=0, Bool_t clearEmat=kTRUE)
virtual void ClearResults(void)
TMap implements an associative array of (key,value) pairs using a THashTable for efficient retrieval ...
const TMatrixDSparse * GetDXDAZ(int i) const
const TMatrixDSparse * GetAx(void) const
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
TMatrixDSparse * fEmatUncorrAx
void AddSysError(const TH2 *sysError, const char *name, EHistMap histmap, ESysErrMode mode)
#define ROOT_VERSION(a, b, c)
Mother of all ROOT objects.
you should not use this method at all Int_t Int_t z
TObject * FindObject(const char *keyname) const
Check if a (key,value) pair exists with keyname as name of the key.
TUnfold is used to decompose a measurement y into several sources x given the measurement uncertainti...
TObject * Next()
Returns the next key from a map.
void ErrorMatrixToHist(TH2 *ematrix, const TMatrixDSparse *emat, const Int_t *binMap, Bool_t doClear) const
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
TObject * GetValue(const char *keyname) const
Returns a pointer to the value associated with keyname as name of the key.
void AddMSparse(TMatrixDSparse *dest, Double_t f, const TMatrixDSparse *src) const
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)
void GetEmatrixFromVyy(const TMatrixDSparse *vyy, TH2 *ematrix, const Int_t *binMap, Bool_t clearEmat)
void GetEmatrix(TH2 *ematrix, const Int_t *binMap=0) const
Bool_t GetDeltaSysBackgroundScale(TH1 *delta, const char *source, const Int_t *binMap=0)
unsigned int r2[N_CITIES]
void Clear(Option_t *option="")
Remove all (key,value) pairs from the map.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.