FairRoot/PandaRoot
Projection.h
Go to the documentation of this file.
1 // ******************************************************
2 // DecayTreeFitter Package
3 // We thank the original author Wouter Hulsbergen
4 // (BaBar, LHCb) for providing the sources.
5 // http://arxiv.org/abs/physics/0503191v1 (2005)
6 // Adaptation & Development for PANDA: Ralf Kliemt (2015)
7 // ******************************************************
8 #ifndef PROJECTION_H
9 #define PROJECTION_H 1
10 #include "Rtypes.h"
11 
12 #include "TVectorD.h"
13 #include "TMatrixDSym.h"
14 #include "TMatrixD.h"
15 #include <string.h> // for memset
16 #include "ParticleBase.h"
17 namespace DecayTreeFitter
18 {
19 
20  class Projection
21  {
22  public:
23  // constructor
24  Projection(int dimP, int dimC) : m_matrixH(dimC,dimP),m_r(dimC),m_matrixV(dimC),m_offset(0),m_particle(0),m_nHidden(0) {}
25  virtual ~Projection(){};
26 
27  // accessors to the projection matrix
28  const TMatrixD& H() const { return m_matrixH ; }
29  //HepMatrix& H() { return m_matrixH ; }
30  double& H(int row, int col) {
31 #ifdef VTK_BOUNDSCHECKING
32  assert( m_offset+row >0 && col>0 && m_offset+row <= m_matrixH.GetNrows() && col <= m_matrixH.GetNcols() ) ;
33 #endif
34  return m_matrixH(m_offset+row,col) ; }
35 
36  // accessors to the residual (or the 'value' of the constraint)
37  const TVectorD& r() const { return m_r ; }
38  TVectorD& r() { return m_r ; }
39  //HepVector& r() { return m_r ; }
40  double& r(int row) {
41 #ifdef VTK_BOUNDSCHECKING
42  assert( m_offset+row >0 && m_offset+row <= m_r.GetNrows() ) ;
43 #endif
44  return m_r(m_offset+row) ; }
45 
46  // accessors to the covariance matrix
47  const TMatrixDSym& V() const { return m_matrixV ; }
48  //HepSymMatrix& V() { return m_matrixV ; }
49  double& V(int row, int col) { return m_matrixV(m_offset+row,m_offset+col) ; }
50  double& Vfast(int row, int col) {
51 #ifdef VTK_BOUNDSCHECKING
52  assert( m_offset+row >0 && m_offset+col>0 && m_offset+row <= m_matrixV.GetNrows() && m_offset+col <= m_matrixV.GetNcols() && row>=col ) ;
53 #endif
54  return m_matrixV(m_offset+row,m_offset+col) ; }
55 
56  // reset
57  //FIXME: Will this work for TMatixD, too?
58  void reset() {
59  // fill everything with '0'. this implementation is kind of
60  // tricky, but it is fast.
61  // int dimC = m_matrixH.GetNrows() ;
62  // int dimP = m_matrixH.GetNcols() ;
63  // memset(&(m_matrixH(1,1)),0,dimP*dimC*sizeof(double));
64  // memset(&(m_r(1)) ,0,dimC*sizeof(double));
65  // memset(&(m_matrixV(1,1)),0,dimC*(dimC+1)/2*sizeof(double));
66  m_matrixH.Zero();
67  m_r.Zero();
68  m_matrixV.Zero();
69  m_offset = 0 ;
70  }
71 
72  // globalChisq
73  double chiSquare() const {
74  TMatrixDSym W=m_matrixV ;
75  double det=0;
76  W.InvertFast(&det);
77  return W.Similarity(m_r) ;
78  }
79 
80  void incrementOffset(unsigned int i) { m_offset+=i ; }
81  unsigned int offset() const { return m_offset ; }
82 
83  void setParticle( const ParticleBase& p ) { m_particle = &p ; }
84  const ParticleBase* particle() const { return m_particle ; }
85 
86  private:
87  TMatrixD m_matrixH ; // projection matrix
88  TVectorD m_r ; // constraint residual
89  TMatrixDSym m_matrixV ; // constraint variance (zero for lagrange constraints)
90  unsigned int m_offset ; // offset for constraint index. only non-zero for merged constraints.
91  const ParticleBase* m_particle ; // particle where chi2 should be added
92  // the number of hidden 'degrees of freedom'. always zero except for the 'photon' constraint
93  unsigned int m_nHidden ;
94  ClassDef ( Projection,1 )
95  } ;
96 }
97 #endif
int row
Definition: anaLmdDigi.C:67
Double_t p
Definition: anasim.C:58
double & V(int row, int col)
Definition: Projection.h:49
const TVectorD & r() const
Definition: Projection.h:37
Int_t i
Definition: run_full.C:25
int col
Definition: anaLmdDigi.C:67
void setParticle(const ParticleBase &p)
Definition: Projection.h:83
const TMatrixD & H() const
Definition: Projection.h:28
void incrementOffset(unsigned int i)
Definition: Projection.h:80
const TMatrixDSym & V() const
Definition: Projection.h:47
#define W
Definition: createSTT.C:76
double chiSquare() const
Definition: Projection.h:73
Projection(int dimP, int dimC)
Definition: Projection.h:24
double & r(int row)
Definition: Projection.h:40
double & H(int row, int col)
Definition: Projection.h:30
const ParticleBase * particle() const
Definition: Projection.h:84
const ParticleBase * m_particle
Definition: Projection.h:91
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52
unsigned int offset() const
Definition: Projection.h:81
double & Vfast(int row, int col)
Definition: Projection.h:50