FairRoot/PandaRoot
RecoPhoton.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 #include <stdio.h>
9 //#include "Event/Particle.h"
10 //#include "Event/CaloHypo.h"
11 //#include "Event/CaloPosition.h"
12 
13 #include "RecoPhoton.h"
14 #include "FitParams.h"
15 #include "TVector3.h"
16 #include "RhoCalculationTools.h"
17 
18 using namespace DecayTreeFitter;
20 
21 extern int vtxverbose ;
22 
24 : RecoParticle(bc,aMother), m_V(3)
25 {
26  updCache() ; // read from candidate
27 }
28 
30 
32  const TVector3& motherpos) const
33 {
34  TVector3 dx( m_m(0) - motherpos.x(),
35  m_m(1) - motherpos.y(),
36  m_z - motherpos.z()) ;
37  double l = dx.Mag() ;
38 
39  // get the energy
40  double energy = m_m(2) ;
41 
42  // assign the momentum
43  int momindex = momIndex() ;
44  fitparams->par(momindex+0) = energy*dx.x()/l ;
45  fitparams->par(momindex+1) = energy*dx.y()/l ;
46  fitparams->par(momindex+2) = energy*dx.z()/l ;
47 
48  return ErrCode() ;
49 }
50 
51 ErrCode
53 {
54  if(vtxverbose>5){std::cout<<"RecoPhoton::initPar1: - "<<std::endl;}
55  return initParPhoton( fitparams, TVector3(0,0,0) ) ;
56 }
57 
58 ErrCode
60 {
61  if(vtxverbose>5){std::cout<<"RecoPhoton::initPar2: - "<<std::endl;}
62  // calculate the direction
63  int posindexmother = mother()->posIndex() ;
64  TVector3 motherpos(fitparams->par(posindexmother+0),
65  fitparams->par(posindexmother+1),
66  fitparams->par(posindexmother+2)) ;
67  return initParPhoton(fitparams, motherpos ) ;
68 }
69 
70 ErrCode
72 {
73  int momindex = momIndex() ;
74  double varEnergy = m_V(2,2) ;
75  const double factor = 1000;
76  for(int row=0; row<3; row++)
77  fitparams->cov()(momindex+row,momindex+row) = factor * varEnergy ;
78  return ErrCode() ;
79 }
80 
81 ErrCode
83 {
84  // const LHCb::CaloHypo* hypo = particle().proto()->calo()[0] ;
85  // // this works for photons
86  // const LHCb::CaloPosition* pos = hypo->position() ;
87  // and this seems to work for merged pi0 ...
88  // if(!pos && hypo->clusters().size()>0)
89  // pos = &(hypo->clusters()[0]->position()) ;
90  ErrCode rc ;
91 
92  // if(pos) {
93  // FIXME: Welche Parameter hat das?
94  // Parameters: X, Y, of Cluster (in crystal plane?), E
95  // FIXME: LHCb is a fixed-target experiment, all detectors line up along Z!
96  PndPidCandidate* rec = particle()->GetRecoCandidate();
97  m_m(0) = rec->GetLastHit().X(); // x
98  m_m(1) = rec->GetLastHit().Y(); // y
99  m_z = rec->GetLastHit().Z(); // z
100  m_m(2) = rec->GetEnergy(); // E
101  if(vtxverbose>4) std::cout<<"RecoPhoton::updCache() l."<<__LINE__ <<" m_m(0) = "<<m_m(0) <<" cm; m_m(1) = "<<m_m(1) <<" cm; m_z = "<<m_z <<"cm; m_M(2) = "<<m_m(2)<<" GeV" <<std::endl;
102  TMatrixD cov7 = rec->Cov7(); //error matrix for
103  m_V[0][0]=cov7[0][0]; // x-x
104  m_V[0][1]=cov7[0][1]; // x-y
105  m_V[0][2]=cov7[0][6]; // x-E
106  m_V[1][0]=cov7[1][0]; // y-x
107  m_V[1][1]=cov7[1][1]; // y-y
108  m_V[1][2]=cov7[1][6]; // y-E
109  m_V[2][0]=cov7[6][0]; // E-x
110  m_V[2][1]=cov7[6][1]; // E-y
111  m_V[2][2]=cov7[6][6]; // E-E
112  // m_m = pos->parameters() ;
113  // m_V = pos->covariance() ;
114  // m_z = pos->z() ;
115  // } else {
116  // std::cout << "DecayTreeFitter::RecoPhoton: cannot find position info for cluster" << std::endl ;
117  // rc = ErrCode::badsetup ;
118  // }
119  return ErrCode() ;
120 }
121 
122 ErrCode
124 {
125  // residual of photon:
126  // r(0-2) = motherpos + mu * photon momentum - cluster position
127  // r(3) = |momentum| - cluster energy
128  // mu is calculated from the 'chi2-closest approach' (see below)
129 
130  ErrCode status ;
131 
132  // calculate the total momentum and energy:
133  int momindex = momIndex() ;
134  double px = fitparams->par()(momindex+0) ;
135  double py = fitparams->par()(momindex+1) ;
136  double pz = fitparams->par()(momindex+2) ;
137  double m = pdtMass() ; // could be non-zero for mergedpi0
138 
139  double energy = std::sqrt(px*px+py*py+pz*pz+m*m) ;
140  double dedpx = px/energy ;
141  double dedpy = py/energy ;
142  double dedpz = pz/energy ;
143 
144  double tx = px/pz ;
145  double ty = py/pz ;
146  double dtxdpx = 1/pz ;
147  double dtxdpz = -tx/pz ;
148  double dtydpy = 1/pz ;
149  double dtydpz = -ty/pz ;
150 
151  // calculate dX = Xc - Xmother
152  int posindex = mother()->posIndex() ;
153 
154  double dz = m_z - fitparams->par(posindex+2) ;
155  double dx = m_m(0) - fitparams->par(posindex+0) - dz * tx ;
156  double dy = m_m(1) - fitparams->par(posindex+1) - dz * ty ;
157  double dE = m_m(2) - energy ;
158 
159  p.r(0) = dx ;
160  p.r(1) = dy ;
161  p.r(2) = dE ;
162 
163  // calculate the projection matrix
164  // first the 'position' part
165 
166  // derivative of position to position of mother
167  p.H(0,posindex+0) = -1 ;
168  p.H(1,posindex+1) = -1 ;
169 
170  // derivative to position to 3-momentum
171  p.H(0,momindex+0) = -dz * dtxdpx ;
172  p.H(0,momindex+2) = -dz * dtxdpz ;
173  p.H(1,momindex+1) = -dz * dtydpy ;
174  p.H(1,momindex+2) = -dz * dtydpz ;
175 
176  // derivative of momentum to 3-momentum
177  p.H(2,momindex+0) = -dedpx ;
178  p.H(2,momindex+1) = -dedpy ;
179  p.H(2,momindex+2) = -dedpz ;
180 
181  // error
182  for(int irow=0; irow<3; irow++)
183  for(int icol=0; icol<3/*=irow*/; icol++)
184  p.Vfast(irow,icol) = m_V(irow,icol) ;
185  if(vtxverbose>6){
186  std::cout<<"RecoPhoton::projectRecoConstraint(): projection is:"<<posindex<<std::endl;
187  std::cout<<"r "; p.r().Print();
188  std::cout<<"V "; p.V().Print();
189  std::cout<<"H "; RhoCalculationTools::PrintMatrix(p.H());
190  }
191 
192  return status ;
193 }
int row
Definition: anaLmdDigi.C:67
double dy
int vtxverbose
const TVectorD & r() const
Definition: Projection.h:37
__m128 m
Definition: P4_F32vec4.h:28
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
virtual ErrCode initParPhoton(FitParams *, const TVector3 &motherpos) const
Definition: RecoPhoton.cxx:31
Double_t GetEnergy() const
const TMatrixD & H() const
Definition: Projection.h:28
ClassImp(RecoPhoton)
virtual ErrCode projectRecoConstraint(const FitParams *, Projection &) const
Definition: RecoPhoton.cxx:123
Double_t p
Definition: anasim.C:58
const int particle
const TMatrixDSym & V() const
Definition: Projection.h:47
virtual ErrCode initPar1(FitParams *)
Definition: RecoPhoton.cxx:52
Double_t dE
Definition: anasim.C:58
static void PrintMatrix(TMatrixT< double > m)
TVector3 GetLastHit() const
virtual ErrCode initCov(FitParams *) const
Definition: RecoPhoton.cxx:71
TMatrixD & Cov7() const
double dx
RecoPhoton(RhoCandidate *bc, const ParticleBase *mother)
Definition: RecoPhoton.cxx:23
Int_t rec
Definition: autocutx.C:47
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52
double pz[39]
Definition: pipisigmas.h:14
TMatrixDSym & cov()
Definition: FitParams.h:34
int status[10]
Definition: f_Init.h:28
Double_t energy
Definition: plot_dirc.C:15
virtual ErrCode initPar2(FitParams *)
Definition: RecoPhoton.cxx:59
double & Vfast(int row, int col)
Definition: Projection.h:50