MultiVarGauss Class Reference

#include <MultiVarGauss.h>

List of all members.

Public Member Functions

 MultiVarGauss (TH1D *hMean, TMatrixD *hCov)
 ~MultiVarGauss ()
TH1D * Generate ()
void SetRandomSeed (UInt_t s)

Private Member Functions

 ClassDef (MultiVarGauss, 0)

Private Attributes

TRandom3 * _generator
Int_t _npar
TVectorD _bestValues
TH1D * _hVaried
TMatrixDSym _cov
Double_t _det
TMatrixD _UT

Detailed Description

Definition at line 19 of file MultiVarGauss.h.


Constructor & Destructor Documentation

MultiVarGauss::MultiVarGauss ( TH1D *  hMean,
TMatrixD *  hCov 
)

Definition at line 31 of file MultiVarGauss.cxx.

References exit().

00031                                                         : _generator(0)
00032 {
00033   _generator = new TRandom3();
00034   _generator->SetSeed(0);
00035 
00036   if(((hMean->GetXaxis()->GetNbins()-1) != hCov->GetNrows()) 
00037      || (hCov->GetNcols() != hCov->GetNrows())){
00038     cout << "hMean and hCov don't have the same number of bins! Aborting." << endl;
00039     exit(0);
00040   }
00041 
00042   _npar = (hMean->GetXaxis()->GetNbins() - 1);
00043 
00044   _bestValues.ResizeTo(_npar);
00045   _cov.ResizeTo(_npar, _npar);
00046 
00047   double max_abs(-9999);
00048 
00049   for(int ipar = 0; ipar < _npar; ++ipar){
00050 
00051       _bestValues(ipar) = hMean->GetBinContent(ipar+1); 
00052 
00053       for (int jpar = 0; jpar < _npar; ++jpar){
00054 
00055         _cov(ipar, jpar) = (*hCov)(ipar, jpar);
00056 
00057           if (Abs( _cov(ipar, jpar) ) > max_abs) {max_abs = Abs(_cov(ipar,jpar));}
00058       }
00059   }
00060   
00061   //for (int ipar = 0; ipar < _npar; ++ipar){
00062   //  cout << "Cov(" << ipar << "," << ipar << "): " << _cov(ipar,ipar) << endl;
00063   //}
00064   //_cov.Print();
00065   
00066   _hVaried = (TH1D*)hMean->Clone("VariedHisto");
00067   _hVaried->SetDirectory(0);
00068   
00069   
00070   TDecompChol tdc(_cov);
00071   double tol = tdc.GetTol();
00072   //cout << "Original tolerance = " << tol << endl;
00073   //cout << "Max_Abs = " << max_abs << endl;
00074   const Double_t scale = TMath::Min(max_abs, 1.);
00075   tdc.SetTol(tol*scale);
00076   //cout << "New tolerance = " << tdc.GetTol() << endl;
00077 
00078   tdc.Decompose();
00079   TMatrixD U = tdc.GetU();
00080   TMatrixD TU(TMatrixD::kTransposed, U);
00081   _UT.ResizeTo(TU);
00082   _UT = TU;
00083 
00084   return;
00085 }

MultiVarGauss::~MultiVarGauss (  ) 

Definition at line 87 of file MultiVarGauss.cxx.

References _generator, and _hVaried.

00088 {
00089   delete _generator;
00090   delete _hVaried;
00091   return;
00092 }


Member Function Documentation

MultiVarGauss::ClassDef ( MultiVarGauss  ,
 
) [private]
TH1D * MultiVarGauss::Generate (  ) 

Definition at line 94 of file MultiVarGauss.cxx.

References _bestValues, _generator, _hVaried, _npar, and _UT.

Referenced by FarOverNearFitLED::FluctuateFakeData(), FarOverNearFitPQ::MakeFlucuatedRatios(), and FarOverNearFit::MakeFlucuatedRatios().

00095 {
00096   // This is the main function that generates the histo from the matrix
00097 
00098   TVectorD nextValues;
00099   nextValues.ResizeTo(_npar);
00100 
00101   for(Int_t ipar = 0; ipar < _npar; ++ipar){
00102       nextValues(ipar) = _generator->Gaus(0.0, 1.0);
00103     }
00104   nextValues *= _UT;
00105   //for(int ipar = 0; ipar < _npar; ++ipar){
00106   //  std::cout << "bin " << ipar << " shift = " << nextValues(ipar) << std::endl;
00107   //}  
00108 
00109   nextValues += _bestValues;
00110   
00111   for(int ipar = 0; ipar < _npar; ++ipar){
00112       _hVaried->SetBinContent(ipar+1, nextValues(ipar) );
00113     }
00114 
00115   return _hVaried;
00116 }

void MultiVarGauss::SetRandomSeed ( UInt_t  s  )  [inline]

Definition at line 26 of file MultiVarGauss.h.

References _generator.

Referenced by FarOverNearFitLED::FluctuateFakeData().

00026 {_generator->SetSeed(s);};


Member Data Documentation

TVectorD MultiVarGauss::_bestValues [private]

Definition at line 31 of file MultiVarGauss.h.

Referenced by Generate().

TMatrixDSym MultiVarGauss::_cov [private]

Definition at line 34 of file MultiVarGauss.h.

Double_t MultiVarGauss::_det [private]

Definition at line 35 of file MultiVarGauss.h.

TRandom3* MultiVarGauss::_generator [private]

Definition at line 26 of file MultiVarGauss.h.

Referenced by Generate(), SetRandomSeed(), and ~MultiVarGauss().

TH1D* MultiVarGauss::_hVaried [private]

Definition at line 32 of file MultiVarGauss.h.

Referenced by Generate(), and ~MultiVarGauss().

Int_t MultiVarGauss::_npar [private]

Definition at line 30 of file MultiVarGauss.h.

Referenced by Generate().

TMatrixD MultiVarGauss::_UT [private]

Definition at line 36 of file MultiVarGauss.h.

Referenced by Generate().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1