test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
LeastSquares.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_MVATrainer_LeastSquares_h
2 #define PhysicsTools_MVATrainer_LeastSquares_h
3 
4 #include <string>
5 #include <vector>
6 
7 #include <TMatrixD.h>
8 #include <TVectorD.h>
9 
10 #include <xercesc/dom/DOM.hpp>
11 
12 namespace PhysicsTools {
13 
15 {
16  public:
17  LeastSquares(unsigned int n);
18  virtual ~LeastSquares();
19 
20  void add(const std::vector<double> &values, double dest,
21  double weight = 1.0);
22  void add(const LeastSquares &other, double weight = 1.0);
23  void calculate();
24 
25  std::vector<double> getWeights() const;
26  std::vector<double> getMeans() const;
27  double getConstant() const;
28 
29  inline unsigned int getSize() const { return n; }
30  inline const TMatrixDSym &getCoefficients() const { return coeffs; }
31  inline const TMatrixDSym &getCovariance() const { return covar; }
32  inline const TMatrixDSym &getCorrelations() const { return corr; }
33  inline const TMatrixD &getRotation() { return rotation; }
34 
35  void load(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *elem);
37  XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc) const;
38 
39  static TVectorD solveFisher(const TMatrixDSym &coeffs);
40  static TMatrixD solveRotation(const TMatrixDSym &covar,
41  TVectorD &trace);
42 
43  private:
44  TMatrixDSym coeffs;
45  TMatrixDSym covar;
46  TMatrixDSym corr;
47  TMatrixD rotation;
48  TVectorD weights;
49  TVectorD variance;
50  TVectorD trace;
51  const unsigned int n;
52 };
53 
54 } // namespace PhysicsTools
55 
56 #endif // PhysicsTools_MVATrainer_LeastSquares_h
const TMatrixDSym & getCovariance() const
Definition: LeastSquares.h:31
LeastSquares(unsigned int n)
Definition: LeastSquares.cc:22
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement * save(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument *doc) const
void add(const std::vector< double > &values, double dest, double weight=1.0)
Definition: LeastSquares.cc:32
unsigned int getSize() const
Definition: LeastSquares.h:29
void load(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *elem)
#define XERCES_CPP_NAMESPACE_QUALIFIER
Definition: LHERunInfo.h:16
double getConstant() const
const TMatrixDSym & getCoefficients() const
Definition: LeastSquares.h:30
static TVectorD solveFisher(const TMatrixDSym &coeffs)
Definition: LeastSquares.cc:64
const unsigned int n
Definition: LeastSquares.h:51
tuple doc
Definition: asciidump.py:381
std::vector< double > getWeights() const
static TMatrixD solveRotation(const TMatrixDSym &covar, TVectorD &trace)
Definition: LeastSquares.cc:78
int weight
Definition: histoStyle.py:50
std::vector< double > getMeans() const
const TMatrixDSym & getCorrelations() const
Definition: LeastSquares.h:32
const TMatrixD & getRotation()
Definition: LeastSquares.h:33