FairRoot/PandaRoot
RecoComposite.cxx
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 
9 //#include "Event/Particle.h"
10 #include "RecoComposite.h"
11 #include "FitParams.h"
12 #include "TMatrixD.h"
13 #include "RhoCalculationTools.h"
14 
15 using namespace DecayTreeFitter;
17 
18 extern int vtxverbose ;
19 
21 : ParticleBase(bc,amother),m_m(),m_matrixV(),m_hasEnergy(true)
22 {
23  //bool massconstraint = bc && bc->constraint(RecoConstraint::Mass) ;
24  //m_hasEnergy = !massconstraint ;
25  updCache() ;
26 }
27 
28 TMatrixDSym convertToHepSymMatrix(const TMatrixD& M)
29 { //FIXME does that go with the RhoCandidate?
30  int dim = M.GetNrows() ;
31  TMatrixDSym rc(dim) ;
32  for(int irow=0; irow<dim; ++irow)
33  for(int icol=0; icol<=irow; ++icol)
34  {
35  rc(irow,icol) = M(irow,icol);
36  if(icol!=irow) rc(icol,irow) = M(irow,icol);
37  }
38  return rc ;
39 }
40 
42 {
43  // cache par7 (x,y,z,px,py,pz,E) cov7
44  TVector3 pos = particle()->Pos() ;
45  TLorentzVector mom = particle()->P4() ;
46  m_m = TVectorD(dimM()) ;
47  m_m(0) = pos.x() ;
48  m_m(1) = pos.y() ;
49  m_m(2) = pos.z() ;
50  m_m(3) = mom.Px() ;
51  m_m(4) = mom.Py() ;
52  m_m(5) = mom.Pz() ;
53  if(hasEnergy()) m_m(6) = mom.E() ;
54  TMatrixDSym cov7 = convertToHepSymMatrix( particle()->Cov7()) ;//FIXME The conversion shall be checked
55  cov7.GetSub(0,dimM(),m_matrixV) ; // so either 7 or 6, depending on mass constraint
56  if(vtxverbose>=4) {
57  std::cout << "cov matrix of external candidate: " << name().c_str()
58  << " " << dimM() << std::endl;
59  m_matrixV.Print();
60  }
61 }
62 
64 
65 ErrCode
67 {
68  if(vtxverbose>5){std::cout<<"RecoComposite::initPar1: - "<<std::endl;}
69  int posindex = posIndex() ;
70  int momindex = momIndex() ;
71 
72  //quick map for parameters
73  int indmap[7] ;
74  for(int i=0; i<3; ++i) indmap[i] = posindex+i ;
75  for(int i=0; i<4; ++i) indmap[i+3] = momindex+i ;
76  // copy the 'measurement'
77  for(int row=0; row<dimM(); ++row)
78  fitparams->par()(indmap[row]) = m_m(row) ;
79 
80  return ErrCode::success ;
81 }
82 
83 ErrCode
85 {
86  if(vtxverbose>5){std::cout<<"RecoComposite::initPar2: - "<<std::endl;}
87  // call default lifetime initialization
88  return initTau(fitparams) ;
89 }
90 
91 ErrCode
93  Projection& p) const
94 {
95  int posindex = posIndex() ;
96  int momindex = momIndex() ;
97 
98  // quick map for parameters
99  int indmap[7] ;
100  for(int i=0; i<3; i++) indmap[i] = posindex+i ;
101  for(int i=0; i<4; i++) indmap[i+3] = momindex+i ;
102  for(int row=0; row<dimM(); row++) {
103  //p.r(row) = fitparams->par()(indmap[row]) - m_m(row) ;
104  p.r(row) = m_m(row) - fitparams->par()(indmap[row]) ; //RK turned sign. It's "measurement - step before".
105  p.H(row,indmap[row]) = 1 ;
106  for(int col=0; col<dimM()/*=row*/; col++)
107  p.Vfast(row,col) = m_matrixV(row,col) ;
108  }
109  if(vtxverbose>6){
110  std::cout<<"RecoComposite::projectRecoComposite(): projection is:"<<posindex<<std::endl;
111  std::cout<<"r "; p.r().Print();
112  std::cout<<"V "; p.V().Print();
113  std::cout<<"H "; RhoCalculationTools::PrintMatrix(p.H());
114  }
115 
116  return ErrCode::success ;
117 }
118 
119 ErrCode
121  const FitParams* fitparams,
122  Projection& p) const
123 {
124  ErrCode aStatus ;
125  switch(aType) {
127  aStatus |= projectRecoComposite(fitparams,p) ;
128  break ;
130  aStatus |= projectGeoConstraint(fitparams,p) ;
131  break ;
132  default:
133  aStatus |= ParticleBase::projectConstraint(aType,fitparams,p) ;
134  }
135  return aStatus ;
136 }
137 
138 double
140 {
141  Projection p(fitparams->dim(),dimM()) ;
142  projectRecoComposite(fitparams,p) ;
143  return p.chiSquare() ;
144 }
int row
Definition: anaLmdDigi.C:67
TVector3 pos
const TVectorD & r() const
Definition: Projection.h:37
Int_t i
Definition: run_full.C:25
int col
Definition: anaLmdDigi.C:67
RecoComposite(RhoCandidate *bc, const ParticleBase *mother)
virtual ErrCode initPar2(FitParams *)
ErrCode projectRecoComposite(const FitParams *, Projection &) const
Double_t mom
Definition: plot_dirc.C:14
virtual ErrCode initPar1(FitParams *)
const TMatrixD & H() const
Definition: Projection.h:28
Double_t p
Definition: anasim.C:58
const int particle
const TMatrixDSym & V() const
Definition: Projection.h:47
static void PrintMatrix(TMatrixT< double > m)
virtual ErrCode projectConstraint(Constraint::Type, const FitParams *, Projection &) const
virtual ErrCode projectConstraint(Constraint::Type, const FitParams *, Projection &) const
TString name
ClassImp(RecoComposite)
int vtxverbose
virtual double chiSquare(const FitParams *fitparams) const
TMatrixDSym convertToHepSymMatrix(const TMatrixD &M)
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52
double & Vfast(int row, int col)
Definition: Projection.h:50