38using std::string, std::list, std::map, std::vector, std::cout, std::endl;
47 _x(
"x",
"Observables",this,
true,false),
48 _mu(
"mu",
"Offset vector",this,
true,false),
50 _covI{cov.GetNrows()},
54 std::stringstream errorMsg;
55 errorMsg <<
"RooMultiVarGaussian::RooMultiVarGaussian(" << GetName()
56 <<
") input covariance matrix is not symmetric!";
57 coutE(InputArguments) << errorMsg.str() << std::endl;
58 throw std::invalid_argument(errorMsg.str().c_str());
80 _x(
"x",
"Observables", this,
true, false),
81 _mu(
"mu",
"Offset vector", this,
true, false),
82 _cov(reduceToConditional ? fr.conditionalCovarianceMatrix(xvec) : fr.reducedCovarianceMatrix(xvec)),
89 list<string> munames ;
91 for (std::size_t
i=0 ;
i<fpf.
size() ;
i++) {
94 parclone->setConstant(
true) ;
95 _mu.addOwned(std::move(parclone));
101 for (list<string>::iterator iter=munames.begin() ; iter!=munames.end() ; ++iter) {
102 RooRealVar* xvar = static_cast<RooRealVar*>(xvec.find(iter->c_str())) ;
125 for (std::size_t
i = 0;
i <
n;
i++) {
166 for (std::size_t
i=0 ;
i<
_mu.size() ;
i++) {
178 for (std::size_t
i=0 ;
i<
_x.size() ;
i++) {
186 double alpha = x_min_mu * (
_covI * x_min_mu) ;
187 return exp(-0.5*alpha) ;
199 for (std::size_t
i=0 ;
i<
_x.size() ;
i++) {
207 if (allVars.
size()==
_x.size() && !rangeName) {
208 analVars.
add(allVars) ;
217 coutW(Integration) <<
"RooMultiVarGaussian::getAnalyticalIntegral(" <<
GetName() <<
") WARNING: p.d.f. has " <<
_x.size()
218 <<
" observables, analytical integration is only implemented for the first 127 observables" << endl ;
225 bool anyBits(
false) ;
227 for (std::size_t
i=0 ;
i<
_x.size() ;
i++) {
230 if (allVars.
find(
_x.at(
i)->GetName())) {
234 cxcoutD(Integration) <<
"RooMultiVarGaussian::getAnalyticalIntegral(" <<
GetName()
235 <<
") Advertising analytical integral over " << xi->
GetName() <<
" as range is >" <<
_z <<
" sigma" << endl ;
238 analVars.
add(*allVars.
find(
_x.at(
i)->GetName())) ;
240 cxcoutD(Integration) <<
"RooMultiVarGaussian::getAnalyticalIntegral(" <<
GetName() <<
") Range of " << xi->
GetName() <<
" is <"
241 <<
_z <<
" sigma, relying on numeric integral" << endl ;
246 if (allVars.
find(
_mu.at(
i)->GetName())) {
250 cxcoutD(Integration) <<
"RooMultiVarGaussian::getAnalyticalIntegral(" <<
GetName()
251 <<
") Advertising analytical integral over " << pi->
GetName() <<
" as range is >" <<
_z <<
" sigma" << endl ;
254 analVars.
add(*allVars.
find(
_mu.at(
i)->GetName())) ;
256 cxcoutD(Integration) <<
"RooMultiVarGaussian::getAnalyticalIntegral(" <<
GetName() <<
") Range of " << pi->
GetName() <<
" is <"
257 <<
_z <<
" sigma, relying on numeric integral" << endl ;
291 return pow(2*3.14159268,
_x.size()/2.)*sqrt(std::abs(
_det)) ;
307 double ret = pow(2*3.14159268,aid.
nint/2.)/sqrt(std::abs(aid.
S22det))*exp(-0.5*u*(aid.
S22bar*u)) ;
321 return iter->second ;
356 TMatrixD S22bar = S11 - S12*S22inv*S21 ;
363 cacheData.
pmap = map1 ;
364 cacheData.
nint = map2.size() ;
376 if (directVars.
size()==
_x.size()) {
377 generateVars.
add(directVars) ;
384 coutW(Integration) <<
"RooMultiVarGaussian::getGenerator(" <<
GetName() <<
") WARNING: p.d.f. has " <<
_x.size()
385 <<
" observables, partial internal generation is only implemented for the first 127 observables" << endl ;
392 for (std::size_t
i=0 ;
i<
_x.size() ;
i++) {
397 generateVars.
add(*arg) ;
439 vector<int>& omap = gd.
omap ;
445 for(
Int_t k= 0; k <nobs; k++) {
476 for (
int i=0 ;
i<nobs ;
i++) {
506 return iter->second ;
523 cacheData.
omap.resize(
_x.size()) ;
524 for (std::size_t
i=0 ;
i<
_x.size() ;
i++) {
553 TMatrixD S22bar = S11 - S12 * (S22Inv * S21) ;
578 cacheData.
omap = map1 ;
579 cacheData.
pmap = map2 ;
582 cacheData.
mu1 = mu1 ;
583 cacheData.
mu2 = mu2 ;
585 cacheData.
S12S22I = S12S22Inv ;
603 cout <<
"RooMultiVarGaussian::decodeCode(" <<
GetName() <<
") ERROR don't have bit pattern for code " << code << endl ;
604 throw string(
"RooMultiVarGaussian::decodeCode() ERROR don't have bit pattern for code") ;
610 for (std::size_t
i=0 ;
i<
_x.size() ;
i++) {
627 S11.
ResizeTo(map1.size(),map1.size()) ;
628 S12.
ResizeTo(map1.size(),map2.size()) ;
629 S21.
ResizeTo(map2.size(),map1.size()) ;
630 S22.
ResizeTo(map2.size(),map2.size()) ;
633 for (
UInt_t j=0 ; j<map1.size() ; j++)
634 S11(
i,j) =
input(map1[
i],map1[j]) ;
635 for (
UInt_t j=0 ; j<map2.size() ; j++)
636 S12(
i,j) =
input(map1[
i],map2[j]) ;
639 for (
UInt_t j=0 ; j<map1.size() ; j++)
640 S21(
i,j) =
input(map2[
i],map1[j]) ;
641 for (
UInt_t j=0 ; j<map2.size() ; j++)
642 S22(
i,j) =
input(map2[
i],map2[j]) ;
650 if (ibit<32) {
b0 |= (1<<ibit) ;
return ; }
651 if (ibit<64) {
b1 |= (1<<(ibit-32)) ;
return ; }
652 if (ibit<96) {
b2 |= (1<<(ibit-64)) ;
return ; }
653 if (ibit<128) {
b3 |= (1<<(ibit-96)) ;
return ; }
658 if (ibit<32)
return (
b0 & (1<<ibit)) ;
659 if (ibit<64)
return (
b1 & (1<<(ibit-32))) ;
660 if (ibit<96)
return (
b2 & (1<<(ibit-64))) ;
661 if (ibit<128)
return (
b3 & (1<<(ibit-96))) ;
667 if (lhs.
b0 != rhs.
b0)
669 if (lhs.
b1 != rhs.
b1)
671 if (lhs.
b2 != rhs.
b2)
673 if (lhs.
b3 != rhs.
b3)
true
Register systematic variations for multiple existing columns using auto-generated tags.
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
return
Invalidate stored TCling state for declarations included in transaction âTâ.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char x2
TMatrixTBase< Double_t > TMatrixDBase
TMatrixTSym< Double_t > TMatrixDSym
TMatrixT< Double_t > TMatrixD
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
TVectorT< Double_t > TVectorD
TObject * Clone(const char *newname=nullptr) const override
Make a clone of an object using the Streamer facility.
RooAbsArg()
Default constructor.
virtual bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
bool contains(const RooAbsArg &var) const
Check if collection contains an argument with the same name as var.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
RooAbsArg * find(const char *name) const
Find object with given name in list.
RooAbsPdf()
Default constructor.
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
bool operator==(double value) const
Equality operator comparing to a double.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
const RooArgList & floatParsFinal() const
Return list of floating parameters after fit.
Multivariate Gaussian p.d.f.
double analyticalIntegral(Int_t code, const char *rangeName=nullptr) const override
Handle full integral here.
Int_t getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char *rangeName=nullptr) const override
Interface function getAnalyticalIntergral advertises the analytical integrals that are supported.
void decodeCode(Int_t code, std::vector< int > &map1, std::vector< int > &map2) const
Decode analytical integration/generation code into index map of integrated/generated (map2) and non-i...
std::vector< BitBlock > _aicMap
!
static void blockDecompose(const TMatrixD &input, const std::vector< int > &map1, const std::vector< int > &map2, TMatrixDSym &S11, TMatrixD &S12, TMatrixD &S21, TMatrixDSym &S22)
Block decomposition of covI according to given maps of observables.
AnaIntData & anaIntData(Int_t code) const
Check if cache entry was previously created.
double evaluate() const override
Do not persist.
std::map< int, GenData > _genCache
!
Int_t getGenerator(const RooArgSet &directVars, RooArgSet &generateVars, bool staticInitOK=true) const override
Special case: generate all observables.
void initGenerator(Int_t code) override
Clear the GenData cache as its content is not invariant under changes in the mu vector.
GenData & genData(Int_t code) const
WVE â CHECK THAT GENDATA IS VALID GIVEN CURRENT VALUES OF _MU.
std::map< int, AnaIntData > _anaIntCache
!
void generateEvent(Int_t code) override
Retrieve generator config from cache.
static double gaussian(TRandom *generator=randomGenerator())
Return a Gaussian random variable with mean 0 and variance 1.
Variable that can be changed from the outside.
void setVal(double value) override
Set value of variable to 'value'.
Cholesky Decomposition class.
Bool_t Decompose() override
Matrix A is decomposed in component U so that A = U^T * U If the decomposition succeeds,...
const TMatrixD & GetU() const
virtual Bool_t IsSymmetric() const
Check whether matrix is symmetric.
TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1) override
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
Double_t Determinant() const override
TMatrixTBase< Element > & ResizeTo(Int_t nrows, Int_t ncols, Int_t=-1) override
Set size of the matrix to nrows x ncols New dynamic elements are created, the overlapping part of the...
TMatrixT< Element > & Invert(Double_t *det=nullptr)
Invert the matrix and calculate its determinant.
const char * GetName() const override
Returns name of object.
TVectorT< Element > & ResizeTo(Int_t lwb, Int_t upb)
Resize the vector to [lwb:upb] .
RooConstVar & RooConst(double val)