ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitModels                                                     *
 *    File: $Id: RooMultiVarGaussian.h 30333 2009-09-21 15:39:17Z wouter $
 * Authors:                                                                  *
 *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
 *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
 *                                                                           *
 * Copyright (c) 2000-2005, Regents of the University of California          *
 *                          and Stanford University. All rights reserved.    *
 *                                                                           *
 * Redistribution and use in source and binary forms,                        *
 * with or without modification, are permitted according to the terms        *
 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
 *****************************************************************************/
#ifndef ROO_MULTI_VAR_GAUSSIAN
#define ROO_MULTI_VAR_GAUSSIAN

#include "RooAbsPdf.h"
#include "RooListProxy.h"
#include "TMatrixDSym.h"
#include "TMatrixD.h"
#include "TVectorD.h"

class RooRealVar;
class RooFitResult ;

class RooMultiVarGaussian : public RooAbsPdf {
public:

  RooMultiVarGaussian() {} ;
  RooMultiVarGaussian(const char *name, const char *title, const RooArgList& xvec, const RooFitResult& fr) ;
  RooMultiVarGaussian(const char *name, const char *title, const RooArgList& xvec, const RooArgList& mu, const TMatrixDSym& covMatrix) ;
  RooMultiVarGaussian(const char *name, const char *title, const RooArgList& xvec, const TVectorD& mu, const TMatrixDSym& covMatrix) ;
  RooMultiVarGaussian(const char *name, const char *title, const RooArgList& xvec,const TMatrixDSym& covMatrix) ;
  void setAnaIntZ(Double_t z) { _z = z ; }

  RooMultiVarGaussian(const RooMultiVarGaussian& other, const char* name=0) ;
  virtual TObject* clone(const char* newname) const { return new RooMultiVarGaussian(*this,newname); }
  inline virtual ~RooMultiVarGaussian() { }

  Int_t getAnalyticalIntegral(RooArgSet& allVars, RooArgSet& analVars, const char* rangeName=0) const ; 
  Double_t analyticalIntegral(Int_t code, const char* rangeName=0) const ; 

  Int_t getGenerator(const RooArgSet& directVars, RooArgSet &generateVars, Bool_t staticInitOK=kTRUE) const; 
  void initGenerator(Int_t code) ;
  void generateEvent(Int_t code); 

  const TMatrixDSym& covarianceMatrix() const { return _cov ; }
  
  class AnaIntData {
  public:
    TMatrixD    S22bar ;
    Double_t    S22det ;
    vector<int> pmap ;
    Int_t       nint ;
  } ;

  class GenData {
  public:
    TMatrixD    UT ;
    vector<int> omap ;
    vector<int> pmap ;
    TVectorD    mu1 ;
    TVectorD    mu2 ;
    TMatrixD    S12S22I ;
  } ;

  static void blockDecompose(const TMatrixD& input, const vector<int>& map1, const vector<int>& map2, TMatrixDSym& S11, TMatrixD& S12, TMatrixD& S21, TMatrixDSym& S22) ;

protected:

  void decodeCode(Int_t code, vector<int>& map1, vector<int>& map2) const;
  AnaIntData& anaIntData(Int_t code) const ;
  GenData& genData(Int_t code) const ;

  mutable map<int,AnaIntData> _anaIntCache ; //!
  mutable map<int,GenData> _genCache ; //!

  RooListProxy _x ;
  RooListProxy _mu ;
  TMatrixDSym _cov ;
  TMatrixDSym _covI ;
  Double_t    _det ; 
  Double_t    _z ; 

  void syncMuVec() const ;
  mutable TVectorD _muVec ; //! Do not persist

  Double_t evaluate() const ;

private:

  ClassDef(RooMultiVarGaussian,1) // Multivariate Gaussian PDF with correlations
};

#endif
 RooMultiVarGaussian.h:1
 RooMultiVarGaussian.h:2
 RooMultiVarGaussian.h:3
 RooMultiVarGaussian.h:4
 RooMultiVarGaussian.h:5
 RooMultiVarGaussian.h:6
 RooMultiVarGaussian.h:7
 RooMultiVarGaussian.h:8
 RooMultiVarGaussian.h:9
 RooMultiVarGaussian.h:10
 RooMultiVarGaussian.h:11
 RooMultiVarGaussian.h:12
 RooMultiVarGaussian.h:13
 RooMultiVarGaussian.h:14
 RooMultiVarGaussian.h:15
 RooMultiVarGaussian.h:16
 RooMultiVarGaussian.h:17
 RooMultiVarGaussian.h:18
 RooMultiVarGaussian.h:19
 RooMultiVarGaussian.h:20
 RooMultiVarGaussian.h:21
 RooMultiVarGaussian.h:22
 RooMultiVarGaussian.h:23
 RooMultiVarGaussian.h:24
 RooMultiVarGaussian.h:25
 RooMultiVarGaussian.h:26
 RooMultiVarGaussian.h:27
 RooMultiVarGaussian.h:28
 RooMultiVarGaussian.h:29
 RooMultiVarGaussian.h:30
 RooMultiVarGaussian.h:31
 RooMultiVarGaussian.h:32
 RooMultiVarGaussian.h:33
 RooMultiVarGaussian.h:34
 RooMultiVarGaussian.h:35
 RooMultiVarGaussian.h:36
 RooMultiVarGaussian.h:37
 RooMultiVarGaussian.h:38
 RooMultiVarGaussian.h:39
 RooMultiVarGaussian.h:40
 RooMultiVarGaussian.h:41
 RooMultiVarGaussian.h:42
 RooMultiVarGaussian.h:43
 RooMultiVarGaussian.h:44
 RooMultiVarGaussian.h:45
 RooMultiVarGaussian.h:46
 RooMultiVarGaussian.h:47
 RooMultiVarGaussian.h:48
 RooMultiVarGaussian.h:49
 RooMultiVarGaussian.h:50
 RooMultiVarGaussian.h:51
 RooMultiVarGaussian.h:52
 RooMultiVarGaussian.h:53
 RooMultiVarGaussian.h:54
 RooMultiVarGaussian.h:55
 RooMultiVarGaussian.h:56
 RooMultiVarGaussian.h:57
 RooMultiVarGaussian.h:58
 RooMultiVarGaussian.h:59
 RooMultiVarGaussian.h:60
 RooMultiVarGaussian.h:61
 RooMultiVarGaussian.h:62
 RooMultiVarGaussian.h:63
 RooMultiVarGaussian.h:64
 RooMultiVarGaussian.h:65
 RooMultiVarGaussian.h:66
 RooMultiVarGaussian.h:67
 RooMultiVarGaussian.h:68
 RooMultiVarGaussian.h:69
 RooMultiVarGaussian.h:70
 RooMultiVarGaussian.h:71
 RooMultiVarGaussian.h:72
 RooMultiVarGaussian.h:73
 RooMultiVarGaussian.h:74
 RooMultiVarGaussian.h:75
 RooMultiVarGaussian.h:76
 RooMultiVarGaussian.h:77
 RooMultiVarGaussian.h:78
 RooMultiVarGaussian.h:79
 RooMultiVarGaussian.h:80
 RooMultiVarGaussian.h:81
 RooMultiVarGaussian.h:82
 RooMultiVarGaussian.h:83
 RooMultiVarGaussian.h:84
 RooMultiVarGaussian.h:85
 RooMultiVarGaussian.h:86
 RooMultiVarGaussian.h:87
 RooMultiVarGaussian.h:88
 RooMultiVarGaussian.h:89
 RooMultiVarGaussian.h:90
 RooMultiVarGaussian.h:91
 RooMultiVarGaussian.h:92
 RooMultiVarGaussian.h:93
 RooMultiVarGaussian.h:94
 RooMultiVarGaussian.h:95
 RooMultiVarGaussian.h:96
 RooMultiVarGaussian.h:97