FairRoot/PandaRoot
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
RhoKinVtxFitter Class Reference

#include <RhoKinVtxFitter.h>

Inheritance diagram for RhoKinVtxFitter:
RhoFitterBase

Public Member Functions

 RhoKinVtxFitter (RhoCandidate *b)
 
virtual ~RhoKinVtxFitter ()
 
void AddMassConstraint (double mass)
 
double GetPull ()
 
void SetNMaxIterations (int nit=20)
 
void SetNIterationsExact (int nit=2)
 
void SetMinDChisq (double m=0.001)
 
Bool_t Fit ()
 
Bool_t FitAll ()
 
double Chi2Contribution (const RhoCandidate *)
 
double GetChi2 () const
 
int GetNdf () const
 
double GetProb () const
 
void SetVerbose (Bool_t v=kTRUE)
 

Protected Member Functions

RhoCandidateHeadOfTree () const
 
RhoCandidateCopyCand (RhoCandidate *)
 uppermost particle composite in tree More...
 
RhoCandidateCopyTree (RhoCandidate *)
 
void InsertChi2 (const RhoCandidate *bc, const double chi2)
 
void SetDaugthersFromComposite (RhoCandidate *cand)
 
void FindAndAddFinalStateDaughters (RhoCandidate *cand)
 
void SetFourMomentumByDaughters (RhoCandidate *composite)
 
void SetDecayVertex (RhoCandidate *composite, const TVector3 &vtx, const TMatrixD &CovVV)
 

Protected Attributes

Bool_t fVerbose
 
RhoCandidatefHeadOfTree
 
std::vector< RhoCandidate * > fDaughters
 
double fChiSquare
 
int fNDegreesOfFreedom
 

Private Member Functions

Bool_t FitNode (RhoCandidate *b)
 
void SetMatrices ()
 
void ResetMatrices ()
 
void ReadMatrix ()
 
void ReadKinMatrix ()
 
void ReadMassKinMatrix ()
 
Bool_t Compute (RhoCandidate *c)
 
void SetOutput (RhoCandidate *head)
 
void TransportToVertex (TMatrixD &, TMatrixD &, TMatrixD &, TMatrixD &, TMatrixD &)
 
void GetCovariance (TMatrixD &a_cov0, TMatrixD &cov_al_x, TMatrixD &V_vtx, TMatrixD &covS)
 

Private Attributes

TMatrixD al0
 
TMatrixD al1
 
TMatrixD V_al0
 
TMatrixD V_al1
 
TMatrixD covC
 
TMatrixD mD
 
TMatrixD mE
 
TMatrixD md
 
TMatrixD mPull
 
Int_t fNvar
 
Int_t fNpar
 
Int_t fNpart
 
Int_t fNcon
 
Int_t fNc
 
Int_t fNiter
 
Int_t fNumKnown
 
Int_t NumCon
 
int niter
 
double fChi2Diff
 
double fPull
 
TMatrixD vtx_ex
 
TMatrixD vtx_st
 
double fMass
 
int fMassConstraint
 
double fMinDChisq
 
int fNMaxIterations
 
bool fIterateExact
 
int fnDof
 
double fchiSquare
 

Detailed Description

Definition at line 22 of file RhoKinVtxFitter.h.

Constructor & Destructor Documentation

RhoKinVtxFitter::RhoKinVtxFitter ( RhoCandidate b)

Definition at line 24 of file RhoKinVtxFitter.cxx.

References fIterateExact, fMassConstraint, fMinDChisq, and fNMaxIterations.

24  :
25  RhoFitterBase( b )
26 {
27  fMassConstraint =-1;
28  //fPointConstraint=-1;
29 
30  fMinDChisq=0.01;
31  fNMaxIterations=20;
32  fIterateExact=false;
33 
34 
35 }
RhoKinVtxFitter::~RhoKinVtxFitter ( )
virtual

Definition at line 37 of file RhoKinVtxFitter.cxx.

38 {
39 }

Member Function Documentation

void RhoKinVtxFitter::AddMassConstraint ( double  mass)

Definition at line 41 of file RhoKinVtxFitter.cxx.

References fMass, and fMassConstraint.

Referenced by newana_check_eta().

42 {
43  fMassConstraint = 1;
44  fMass=mass;
45 }
Double_t RhoFitterBase::Chi2Contribution ( const RhoCandidate b)
inherited

access to the fitted candidates

Definition at line 86 of file RhoFitterBase.cxx.

References Double_t, RhoFitterBase::fChi2Map, uid(), and RhoCandidate::Uid().

87 {
88  if(!b) return -999.;
89  Int_t uid = b->Uid();
90  Double_t chi2=fChi2Map[uid];
91  return chi2 >=0.0 ? chi2 : -1.;
92 }
Int_t Uid() const
Definition: RhoCandidate.h:419
std::map< Int_t, Double_t > fChi2Map
! each particle&#39;s contribution to the chi^2
Definition: RhoFitterBase.h:80
int uid(int lev, int lrun, int lmode)
Definition: autocutx.C:122
Double_t
Bool_t RhoKinVtxFitter::Compute ( RhoCandidate c)
private

Definition at line 100 of file RhoKinVtxFitter.cxx.

References al0, al1, covC, fabs(), RhoFitterBase::fChiSquare, RhoFitterBase::fDaughters, fIterateExact, fMassConstraint, fMinDChisq, fNc, RhoFitterBase::fNDegreesOfFreedom, fNMaxIterations, fPull, RhoFitterBase::fVerbose, GetCovariance(), RhoVtxPoca::GetPocaVtx(), mD, md, mE, mPull, NumCon, ReadKinMatrix(), ReadMassKinMatrix(), ReadMatrix(), ResetMatrices(), SetMatrices(), TransportToVertex(), V_al0, V_al1, vtx_ex, and vtx_st.

Referenced by FitNode().

101 {
102 
103  // int nd=fDaughters.size();
104  int nd=fDaughters.size();
105  NumCon=2*nd;
106 
107  if(fMassConstraint >0) {
108  NumCon += 1;
109  }
110 // if(fPointConstraint >0) {
111 // NumCon += 2;
112 // }
113 
115 
116 
117  SetMatrices();
118  ResetMatrices();
119  ReadMatrix();
120 
121  TMatrixD cov_al_x(7*nd,3);
122 
123  TVector3 startVtx;
124  //Getting point of closed approach as start vertex point
125  RhoVtxPoca poca; //changed from internal method to class RhoVtxPoca by J.Puetz
126  poca.GetPocaVtx(startVtx, c);
127 
128  vtx_st[0][0]=startVtx.X();
129  vtx_st[1][0]=startVtx.Y();
130  vtx_st[2][0]=startVtx.Z();
131 
132  vtx_ex=vtx_st;
133  if(fVerbose) { cout<<"Initial vertex Position is "<<vtx_ex[0][0]<<" "<<vtx_ex[1][0]<<" "<<vtx_ex[2][0]<<endl; }
134 
135  // al1=al0;
136  // V_al1=V_al0;
138 
139 
140  al0=al1;
141  V_al0=V_al1;
142  TMatrixD V_vtx(3,3);
143  V_vtx[0][0] = 9000.;
144  V_vtx[1][1] = 9000.;
145  V_vtx[2][2] = 9000.;
146  // vtx_ex=vtx_st;
147 
148  double ierr =0 ; // used to check inversions
149  TMatrixD chi2(1,1);
150  TMatrixD chi2_1(1,1);
151 
152  chi2[0][0]=2000000.;
153  //double tmp_chiSq = 999;
154 
155  for(Int_t j1=0; j1<fNMaxIterations; ++j1) {
156 
157 
158  fNc=0;
159  if(fMassConstraint >0) {
161  } else {
162  ReadKinMatrix();
163  }
164 
165  TMatrixD mD_t=mD;
166  mD_t.T();
167  // mD_t=mD_t.Transpose(mD);
168 
169 
170  TMatrixD Vd_inv = mD*V_al0*mD_t;
171  if(Vd_inv==0) { continue; }
172  TMatrixD Vd = Vd_inv.Invert(&ierr);
173 
174 
175  // if( ierr != 0 ){
176  // if(fVerbose) cout << "Inversion of constraint-matrix failed! " << endl;
177  // return 0;}
178  // Vd.Print();
179 
180 
181  TMatrixD del_al = al0 - al1;
182 
183 
184  // Lagrange multiplier
185 
186  //TMatrixD lam0=Vd*md;
187  TMatrixD lam0 = Vd* ( mD*del_al + md);
188  // if(fVerbose) cout << " lam0 calculated" << endl;
189 
190 
191  // Position Derivative matrix ...............
192  TMatrixD mE_t=mE;
193  mE_t.T();
194  TMatrixD Vx_inv = mE_t*Vd*mE;
195  TMatrixD Vx=Vx_inv.Invert(&ierr);
196 // cout<<" *** *** *** *** ***"<<endl;
197 // cout<<"mE "; mE.Print();
198 // cout<<"mE_t "; mE_t.Print();
199 // cout<<"Vd "; Vd.Print();
200 // cout<<"Vx_inv "; Vx_inv.Print();
201 // cout<<"Vx "; Vx.Print();
202 // cout<<" *******************"<<endl;
203 
204  // New vertex and covariance ........
205  TMatrixD V_vtx_new(3,3);
206  TMatrixD vtx_new(vtx_ex);
207 
208 
209 
210  vtx_new -= Vx*mE_t*lam0;
211 // cout << " New vtx calculated" << endl;
212 // vtx_new.Print();
213  V_vtx_new = Vx;
214 
215 
216 
217  // Final Lagarange multiplier ........
218  TMatrixD lam = lam0 + (Vd * mE) * (vtx_new - vtx_ex);
219  // if(fVerbose) cout << " New lam calculated" << endl;
220 
221 
222 
223  // New track parameters.............
224  TMatrixD al_new(al0);
225  al_new -= V_al0*mD_t*lam;
226  // if(fVerbose) cout << " New track param calculated" << endl;
227 
228 
229 
230  //chiSquared
231  TMatrixD lam_t=lam;
232  lam_t.T();
233  // TMatrixD chi2_new = lam_t* md;
234  //TMatrixD chi2_new = lam_t*(mD*(al0 - al_new) );
235  TMatrixD chi2_new = lam_t*(mD*(al0 - al_new) + md);
236  //TMatrixD chi2_new = lam_t*(mD*(al0 - al_new) + mE*(vtx_st-vtx_ex) + md);
237 
238 
239 
240  // New Covariance Matrix................
241  // TMatrixD V_al_new(V_al0);
242  // V_al_new-=V_al0*mD_t*Vd*mD*V_al0_t;
243 
244 
245  // protect against errors. RK: is that safe to do?
246  if(TMath::IsNaN(chi2_new[0][0])) continue;
247 
248  double deltaChi=chi2_new[0][0]-chi2[0][0];
249 
250  // Check chi^2. If better yes update the values ..............................
251  if (deltaChi>0.1*chi2[0][0]) {continue;}
252  if( chi2_new[0][0] < chi2[0][0] ) {
253  //if(true){
254  vtx_ex = vtx_new;
255  al1 = al_new;
256  // V_al0 = V_al_new;
257  }
258 
259 
260  // if (j1==0) {chi2=chi2_new;continue;}
261 
262  // If Chi^2 change is small then go out of iteration......................
263  if( (j1+1 == fNMaxIterations) ||
264  (!fIterateExact && ( fabs(chi2[0][0]-chi2_new[0][0])<fMinDChisq) ) ) {
265  chi2 = chi2_new;
266  vtx_ex = vtx_new;
267  al0 =al_new;
268  //
269  TMatrixD Vd_new(Vd);
270  Vd_new -= Vd*(mE*Vx*mE_t)*Vd.T();
271  TMatrixD V_al_new(V_al0);
272  V_al_new -= V_al0*(mD_t*Vd_new*mD)*V_al0.T();
273  cov_al_x -= V_al0*mD_t*Vd*mE*Vx; // Vertex-track Correlation
274 
275  //double covdif=(V_al0[6][6]-V_al_new[6][6]);
276  // if (covdif > 0 ) {mPull[0][0] =(al0[6][0]-al_new[6][0])/sqrt(covdif);}
277  mPull[0][0] =(al0[6][0]-al_new[6][0]);
278  fPull=mPull[0][0];
279 
280  V_al0 = V_al_new;
281  V_vtx = V_vtx_new;
282  if(fVerbose) { cout <<"iteration Number " << " " << j1 <<" final." <<endl; }
283  if(fVerbose) { cout <<" chi2 in iteration" << " " << chi2[0][0] << " pull="<<fPull<< endl; }
284  break; // that was the final iteration, stop the loop
285  }
286  chi2 = chi2_new;
287  if(fVerbose) { cout << "iteration Number " << " " << j1 << endl; }
288  if(fVerbose) { cout <<" vertex Position is "<<vtx_new[0][0]<<" "<<vtx_new[1][0]<<" "<<vtx_new[2][0]<<endl; }
289  if(fVerbose) { cout << " chi2 in iteration" << " " << chi2[0][0] << endl; }
290  } // end of iteration-loop
291 
292  // tell that the fit failed if we have no updated chi2
293  if( TMath::IsNaN(chi2[0][0]) || chi2[0][0]==2000000. ) return kFALSE;
294 
295  TMatrixD al_new_vtx(7*nd,1);
296  TMatrixD Va_new_vtx(7*nd,7*nd);
297 
298 
299 
300 
301  // Trivial way for covariance matrix of composite
302 // covC=
303 // for(Int_t k=0;k<nd;k++) {
304 // for(int j = 0; j< nd ; ++j) {
305 // {if(k<=j) CovS(k,j) = V_al_0(k,j);}}
306 // CovC -= CovS;
307 // covC+=V_al0.GetSub(k*7,(k+1)*7-1,k*7,(k+1)*7-1);}
308 
309  GetCovariance(V_al0,cov_al_x,V_vtx,covC);
310 
311 
312  // al_new_vtx=al1;
313  // Va_new_vtx=V_al1;
314 // TransportToVertex(al0, V_al0, al_new_vtx, Va_new_vtx, vtx_ex);
315 // al0=al_new_vtx;
316 // V_al0=Va_new_vtx;
317  fChiSquare=chi2[0][0];
318  // fChi2Diff=chi2_1[0][0]-chi2[0][0];
319 
320  return kTRUE;
321 }
void TransportToVertex(TMatrixD &, TMatrixD &, TMatrixD &, TMatrixD &, TMatrixD &)
Double_t GetPocaVtx(TVector3 &vertex, RhoCandidate *composite)
Definition: RhoVtxPoca.cxx:27
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
std::vector< RhoCandidate * > fDaughters
Definition: RhoFitterBase.h:69
void GetCovariance(TMatrixD &a_cov0, TMatrixD &cov_al_x, TMatrixD &V_vtx, TMatrixD &covS)
double fChiSquare
Definition: RhoFitterBase.h:74
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52
int fNDegreesOfFreedom
Definition: RhoFitterBase.h:75
RhoCandidate * RhoFitterBase::CopyCand ( RhoCandidate b)
protectedinherited

uppermost particle composite in tree

Definition at line 51 of file RhoFitterBase.cxx.

References RhoFactory::Instance(), RhoFactory::NewCandidate(), RhoCandidate::RemoveAssociations(), and RhoCandidate::SetFit().

Referenced by RhoFitterBase::CopyTree().

52 {
54  newCand->RemoveAssociations();
55  b->SetFit(newCand);//ready to be modified
56  return newCand;
57 }
void RemoveAssociations()
static RhoFactory * Instance()
Definition: RhoFactory.cxx:34
void SetFit(RhoCandidate *b)
Definition: RhoCandidate.h:292
static RhoCandidate * NewCandidate()
Definition: RhoFactory.cxx:52
RhoCandidate * RhoFitterBase::CopyTree ( RhoCandidate head)
protectedinherited

Definition at line 61 of file RhoFitterBase.cxx.

References RhoFitterBase::CopyCand(), RhoCandidate::Daughter(), i, RhoCandidate::IsComposite(), RhoCandidate::NDaughters(), and RhoCandidate::SetMotherLink().

Referenced by RhoFitterBase::RhoFitterBase().

62 {
63  //std::cout<<"\n\tcopy tree "<<head->Uid()<<" "<<&head<<" "<<head->PdgCode()<<" "<<head->NDaughters()<<"...";
64  RhoCandidate* headcopy=CopyCand(head);
65  RhoCandidate* daucopy=0;
66  RhoCandidate* dau=0;
67  for(Int_t i=0;i<head->NDaughters();i++)
68  {
69  dau=head->Daughter(i);
70  //std::cout<<" daugter "<<dau->Uid()<<" "<<i<<" "<<dau->PdgCode()<<" at "<<dau<<" ";
71  if(dau == head) {
72  std::cout<<endl<<"*** Candidate is its own mother??? *** \n"<<std::endl;
73  std::cout<<" print: "<<*head<<std::endl;;
74  }
75  assert(dau != head);
76  if(dau->IsComposite()) daucopy=CopyTree(dau);
77  else daucopy=CopyCand(dau);
78  //std::cout<<"CopyTree: copied candidate "<<dau->Uid()<<std::endl;
79  daucopy->SetMotherLink(headcopy); //daughter link is set automatically, too
80  }
81  return headcopy;
82 }
Int_t i
Definition: run_full.C:25
void SetMotherLink(RhoCandidate *m, bool verbose=true)
Bool_t IsComposite() const
RhoCandidate * Daughter(Int_t n)
Int_t NDaughters() const
RhoCandidate * CopyTree(RhoCandidate *)
RhoCandidate * CopyCand(RhoCandidate *)
uppermost particle composite in tree
void RhoFitterBase::FindAndAddFinalStateDaughters ( RhoCandidate cand)
protectedinherited

Definition at line 149 of file RhoFitterBase.cxx.

References RhoCandidate::Daughter(), RhoFitterBase::fDaughters, RhoCandidate::IsComposite(), RhoCandidate::IsLocked(), and RhoCandidate::NDaughters().

Referenced by Rho4CFitter::Fit(), RhoKinFitter::Fit(), and Rho4CFitter::FitConserveMasses().

150 {
151  RhoCandidate* tc;
152  for (int k=0;k<cand->NDaughters();k++) {
153  tc=cand->Daughter(k);
154  if (!tc->IsComposite() || tc->IsLocked()) { fDaughters.push_back(tc); }
155  else { FindAndAddFinalStateDaughters(tc); }
156  }
157  return;
158 }
void FindAndAddFinalStateDaughters(RhoCandidate *cand)
Bool_t IsComposite() const
RhoCandidate * Daughter(Int_t n)
Bool_t IsLocked()
Definition: RhoCandidate.h:330
std::vector< RhoCandidate * > fDaughters
Definition: RhoFitterBase.h:69
Int_t NDaughters() const
Bool_t RhoFitterBase::Fit ( )
inherited
Bool_t RhoFitterBase::FitAll ( )
inherited

Definition at line 101 of file RhoFitterBase.cxx.

References RhoFitterBase::fHeadOfTree, RhoCandidate::IsLocked(), and RhoFitterBase::IterateAndFit().

102 {
103  if(fHeadOfTree->IsLocked())
104  {
105  Warning("RhoFitterBase::FitAll","You tried to fit a locked candidate. Retuning kFALSE now.");
106  return kFALSE;
107  }
108  return IterateAndFit(fHeadOfTree);
109 }
Bool_t IsLocked()
Definition: RhoCandidate.h:330
RhoCandidate * fHeadOfTree
Definition: RhoFitterBase.h:62
Bool_t IterateAndFit(RhoCandidate *b)
Bool_t RhoKinVtxFitter::FitNode ( RhoCandidate b)
privatevirtual

Reimplemented from RhoFitterBase.

Definition at line 54 of file RhoKinVtxFitter.cxx.

References Bool_t, Compute(), RhoFitterBase::SetDaugthersFromComposite(), and SetOutput().

55 {
57  Bool_t check=Compute(cand);
58  SetOutput(cand);
59  return check;
60 }
Bool_t Compute(RhoCandidate *c)
void SetOutput(RhoCandidate *head)
void SetDaugthersFromComposite(RhoCandidate *cand)
double RhoFitterBase::GetChi2 ( ) const
inlineinherited
void RhoKinVtxFitter::GetCovariance ( TMatrixD a_cov0,
TMatrixD cov_al_x,
TMatrixD V_vtx,
TMatrixD covS 
)
private

Definition at line 944 of file RhoKinVtxFitter.cxx.

References a, Double_t, RhoFitterBase::fDaughters, RhoCalculationTools::GetBz(), i, and jj.

Referenced by Compute().

946 {
947  int fNDau=fDaughters.size();
948  int nd=fNDau;
949 
950 
951  TMatrixD cov_al_x_temp=cov_al_x;
952 
953  TMatrixD pA(4*nd,7*nd);
954  pA.Zero();
955  double sumA=0;
956  double a;
957  int kN, jN;
958  for (int k=0; k<nd; k++) {
959  kN=k*7;
960  jN=k*4;
961  Double_t bField = 0.1*RhoCalculationTools::GetBz(fDaughters[k]->Pos()); // T, assume field in z only
962  a = -0.00299792458*bField*fDaughters[k]->GetCharge();
963  sumA += a;
964  pA[jN][kN]=pA[jN+1][kN+1]=pA[jN+2][kN+2]=pA[jN+3][kN+3]=1;
965  pA[jN+1][kN+4]=-a;
966  pA[jN][kN+5]=a;
967  }
968 
969  TMatrixD pB(4,3);
970  TMatrixD pB_t(3,4);
971  pB.Zero();
972  pB[0][1]=-sumA;
973  pB[1][0]=sumA;
974 
975  TMatrixD covA_al_xi=pA*cov_al_x;
976 //TMatrixD covB_al_xi=pB*cov_al_x;
977  TMatrixD cov_al_xT(3,7*nd);
978  cov_al_xT = cov_al_x_temp.T();
979 
980  TMatrixD pA_t(7*nd,4*nd);
981 //pA_t=pA.T();
982 
983 //TMatrixD covP(4*nd,4*nd);
984  TMatrixD covP = pA*a_cov0*(pA_t.Transpose(pA));
985  TMatrixD covA=covA_al_xi*(pB_t.Transpose(pB));
986  TMatrixD covB=pB*(cov_al_xT)*(pA_t.Transpose(pA));
987  TMatrixD covBV=pB*(V_vtx)*(pB_t.Transpose(pB));
988 
989  TMatrixD covA_al_x(4,3);
990  TMatrixD SumcovP(4,4);
991  SumcovP=covBV;
992 
993  for (int k=0; k<nd; k++) {
994  kN=k*7;
995  jN=k*4;
996  for (int i=0; i<4; i++) {
997  for (int j=0; j<4; j++) {
998  SumcovP[i][j] += covP[jN+i][jN+j];
999  SumcovP[i][j] += covA[jN+i][j];
1000  SumcovP[i][j] += covB[i][jN+j];
1001  }
1002  for (int jj=0; jj<3; jj++) {
1003  covA_al_x[i][jj] += covA_al_xi[jN+i][jj];
1004  }
1005  }
1006  }
1007 
1008 
1009  TMatrixD covPX(4,3);
1010  covPX = covA_al_x ;
1011  covPX += (pB *V_vtx);
1012  TMatrixD covPX_t(3,4);
1013  covPX_t=covPX_t.Transpose(covPX);
1014 
1015 
1016 
1017  covS.SetSub(0,0,V_vtx);
1018  covS.SetSub(0,3,covPX_t);
1019  covS.SetSub(3,0,covPX);
1020  covS.SetSub(3,3,SumcovP);
1021 
1022 }
Int_t i
Definition: run_full.C:25
Int_t a
Definition: anaLmdDigi.C:126
Double_t
std::vector< RhoCandidate * > fDaughters
Definition: RhoFitterBase.h:69
static Double_t GetBz(const TVector3 &position)
Return the magnetic field along the z-axis in kGs
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52
int RhoFitterBase::GetNdf ( ) const
inlineinherited

Definition at line 49 of file RhoFitterBase.h.

References RhoFitterBase::fNDegreesOfFreedom.

Referenced by poormantracks(), and PndRhoTupleQA::qaFitter().

49 {return fNDegreesOfFreedom;};
int fNDegreesOfFreedom
Definition: RhoFitterBase.h:75
double RhoFitterBase::GetProb ( ) const
inlineinherited
double RhoKinVtxFitter::GetPull ( )
inline

Definition at line 29 of file RhoKinVtxFitter.h.

References fPull.

29 {return fPull;}
RhoCandidate& RhoFitterBase::HeadOfTree ( ) const
inlineprotectedinherited

Definition at line 57 of file RhoFitterBase.h.

References RhoFitterBase::fHeadOfTree.

57 { return *fHeadOfTree; }
RhoCandidate * fHeadOfTree
Definition: RhoFitterBase.h:62
void RhoFitterBase::InsertChi2 ( const RhoCandidate bc,
const double  chi2 
)
inlineprotectedinherited

Definition at line 66 of file RhoFitterBase.h.

References RhoFitterBase::fChi2Map, and RhoCandidate::Uid().

Referenced by RhoKalmanVtxFitter::Calculate().

66 {fChi2Map[ bc->Uid()] = chi2;}
Int_t Uid() const
Definition: RhoCandidate.h:419
std::map< Int_t, Double_t > fChi2Map
! each particle&#39;s contribution to the chi^2
Definition: RhoFitterBase.h:80
void RhoKinVtxFitter::ReadKinMatrix ( )
private

Definition at line 511 of file RhoKinVtxFitter.cxx.

References a, al1, Double_t, RhoFitterBase::fDaughters, fNc, fNcon, fNpar, RhoCalculationTools::GetBz(), mD, md, mE, pz, sqrt(), and vtx_ex.

Referenced by Compute().

512 {
513 
514  int nd=fDaughters.size();
515  fNc=0;
516  mD.ResizeTo(fNcon,fNpar);
517  mE.ResizeTo(fNcon,3);
518  md.ResizeTo(fNcon,1);
519  for (int k=0; k<nd; k++) {
520 
521 
522  int kN=k*7;
523  int k2=k*2;
524  double delX = vtx_ex[0][0] - al1[kN+4][0];
525  double delY = vtx_ex[1][0] - al1[kN+5][0];
526  double delZ = vtx_ex[2][0] - al1[kN+6][0];
527  double px = al1[kN+0][0];
528  double py = al1[kN+1][0];
529  double pz = al1[kN+2][0];
530  double ch=fDaughters[k]->GetCharge();
531  Double_t bField = 0.1*RhoCalculationTools::GetBz(fDaughters[k]->Pos()); // T, assume field in z only
532  double a = -0.0029979246*ch*bField;
533  double pT_2 = px*px + py*py;
534 
535  double J = a*(delX*px + delY*py)/pT_2;
536  double Rx = delX - 2.*px*(delX*px + delY*py)/pT_2;
537  double Ry = delY - 2.*py*(delX*px + delY*py)/pT_2;
538 
539  // if(fabs(J) > 1) {return 0;}
540  if (J>=1.0 || J<= -1.0) { J = (J>=1.0 ? 0.99 : -0.99);}
541 
542  double S = 1./(pT_2*sqrt(1-(J*J)));
543  // if(fVerbose) cout << ch << "ch" << S << "pt2" << J << "bField" << bField <<endl;
544  double asin_J = asin(J);
545  //charged particle
546  if(ch !=0) {
547  mD[fNc+0+k2][kN+0] = delY ;
548  //if(fVerbose) cout << al0[kN+4][0] << " " << delY << endl;
549  mD[fNc+0+k2][kN+1] = -(delX) ;
550  mD[fNc+0+k2][kN+2] = 0. ;
551  mD[fNc+0+k2][kN+3] = 0. ;
552  mD[fNc+0+k2][kN+4] = py + a*delX ;
553  mD[fNc+0+k2][kN+5] = -px + a*delY ;
554  mD[fNc+0+k2][kN+6] = 0. ;
555 
556  mD[fNc+1+k2][kN+0] = -pz*S*Rx ;
557  mD[fNc+1+k2][kN+1] = -pz*S*Ry ;
558  mD[fNc+1+k2][kN+2] = -asin_J/a ;
559  mD[fNc+1+k2][kN+3] = 0.;
560  mD[fNc+1+k2][kN+4] = px*pz*S;
561  mD[fNc+1+k2][kN+5] = py*pz*S;
562  mD[fNc+1+k2][kN+6] = -1.;
563  } else {
564  //neutral particle
565  mD[fNc+0+k2][kN+0] = delY ;
566  mD[fNc+0+k2][kN+1] = -(delX) ;
567  mD[fNc+0+k2][kN+2] = 0. ;
568  mD[fNc+0+k2][kN+3] = 0. ;
569  mD[fNc+0+k2][kN+4] = py;
570  mD[fNc+0+k2][kN+5] = -px;
571  mD[fNc+0+k2][kN+6] = 0. ;
572 
573  mD[fNc+1+k2][kN+0] = 2*(delX*px+delY*py)*px*pz/(pT_2*pT_2) - pz*delX/(pT_2);
574  mD[fNc+1+k2][kN+1] = 2*(delX*px+delY*py)*py*pz/(pT_2*pT_2) - pz*delY/(pT_2);
575  mD[fNc+1+k2][kN+2] =-(delX*px+delY*py)/(pT_2);
576  mD[fNc+1+k2][kN+3] = 0.;
577  mD[fNc+1+k2][kN+4] = px*pz/pT_2;
578  mD[fNc+1+k2][kN+5] = py*pz/pT_2;
579  mD[fNc+1+k2][kN+6] = -1.;
580  }
581  //DMat_trk.push_back(DMat_tmp);
582  //E jacobian matrix
583  if(ch !=0 ) {
584  mE[fNc+0+k2][0] = -(py + a*delX);
585  mE[fNc+0+k2][1] = (px - a*delY);
586  mE[fNc+0+k2][2] = 0.;
587  mE[fNc+1+k2][0] = -px*pz*S;
588  mE[fNc+1+k2][1] = -py*pz*S;
589  mE[fNc+1+k2][2] = 1.;
590  } else {
591  mE[fNc+0+k2][0] = -py ;
592  mE[fNc+0+k2][1] = px;
593  mE[fNc+0+k2][2] = 0.;
594  mE[fNc+1+k2][0] = -px*pz/pT_2;
595  mE[fNc+1+k2][1] = -py*pz/pT_2;
596  mE[fNc+1+k2][2] = 1.;
597  }
598  if(ch !=0 ) {
599  md[fNc+0+k2][0] = delY*px - delX*py - (a/2.)*(delX*delX + delY*delY);
600  md[fNc+1+k2][0] = delZ - (pz/a)*asin_J;
601  } else {
602  md[fNc+0+k2][0] = delY*px - delX*py;
603  md[fNc+1+k2][0] = delZ - pz*(delX * px + delY * py)/(pT_2);
604  }
605 
606  }
607  fNc +=2*nd;
608 
609 
610 
611 
612 }
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
Int_t a
Definition: anaLmdDigi.C:126
Double_t
std::vector< RhoCandidate * > fDaughters
Definition: RhoFitterBase.h:69
static Double_t GetBz(const TVector3 &position)
Return the magnetic field along the z-axis in kGs
double pz[39]
Definition: pipisigmas.h:14
void RhoKinVtxFitter::ReadMassKinMatrix ( )
private

Definition at line 615 of file RhoKinVtxFitter.cxx.

References a, al1, Double_t, RhoFitterBase::fDaughters, fMass, fNc, fNcon, fNpar, RhoCalculationTools::GetBz(), m, mD, md, mE, p1, pz, CAMath::Sqrt(), and vtx_ex.

Referenced by Compute().

617 {
618  // if(m_fitIncludingVertex == 0)
619  //{
620  int nd=fDaughters.size();
621 
622  mD.ResizeTo(fNcon,fNpar);
623  mE.ResizeTo(fNcon,3);
624  md.ResizeTo(fNcon,1);
625 
626  double Etot = 0.;
627  double Px = 0.;
628  double Py = 0.;
629  double Pz = 0.;
630 
631  TMatrixD al1p(al1);
632  double a=0; //TODO: is that right to initialize with 0?
633  TMatrixD m(nd,1);
634 
635  /*
636  // Mass Constraint without vertex Info.............................
637 
638  for(unsigned k=0;k<nd;++k){
639  int kN=k*7;
640  TLorentzVector p1=fDaughters[k]->P4();
641  m[k][0]=p1.M();
642  double px = al1p[kN+0][0];
643  double py = al1p[kN+1][0];
644  double pz = al1p[kN+2][0];
645  double E = TMath::Sqrt(px*px+py*py+pz*pz+m[k][0]*m[k][0]);
646 
647  // Etot += E; Px +=px; Py +=py; Pz += pz;}
648  // md[fNc+0][0] = Etot*Etot - Px*Px - Py*Py - Pz*Pz - fMass*fMass ;
649 
650  a = -0.00299792458*2.0*fDaughters[k]->GetCharge();
651  Double_t invE = 1./E;
652 
653  mD[fNc+0][kN+0] = 2.*(Etot*px*invE-Px);
654  mD[fNc+0][kN+1] = 2.*(Etot*py*invE-Py);
655  mD[fNc+0][kN+2] = 2.*(Etot*pz*invE-Pz);
656  // mD[fNc+0][kN+3] = 0.0;
657  mD[fNc+0][kN+3] = 2* m[k][0]*Etot*invE;
658  mD[fNc+0][kN+4] = 2.*Py*a;
659  mD[fNc+0][kN+5] = -2.*Px*a;
660  mD[fNc+0][kN+6] = 0.0;
661 
662  //................Simple....................
663 
664  // mD[fNc+0][kN+0] = -2.*Px;
665  // mD[fNc+0][kN+1] = -2.*Py;;
666  // mD[fNc+0][kN+2] = -2.*Pz;
667  // mD[fNc+0][kN+3] = 2.*Etot;
668  // mD[fNc+0][kN+3] = 2* m[k][0]*Etot*invE;
669  // mD[fNc+0][kN+4] = 2.*(Etot*py*invE-Py)*a;
670  // mD[fNc+0][kN+5] = 2.*(Etot*px*invE-Px)*a;
671  // mD[fNc+0][kN+4] = 0.0;
672  // mD[fNc+0][kN+5] = 0.0;
673  // mD[fNc+0][kN+6] = 0.0;
674  }
675  */
676 
677  // With Vertex Info.............................................
678  for(int k=0; k<nd; ++k) {
679  int kN=k*7;
680  TLorentzVector p1=fDaughters[k]->P4();
681  m[k][0]=p1.M();
682  double delX = vtx_ex[0][0] - al1p[kN+4][0];
683  double delY = vtx_ex[1][0] - al1p[kN+5][0];
684  // double delX=0.;
685  // double delY=0.;
686 
687  al1p[kN+0][0] = al1p[kN+0][0]-a*delY;
688  al1p[kN+1][0] = al1p[kN+1][0]+a*delX;
689  // al1p[kN+2][0] = al1p[kN+2][0];
690  double E = TMath::Sqrt(al1p[kN+0][0]* al1p[kN+0][0]+al1p[kN+1][0]*al1p[kN+1][0]+al1p[kN+2][0]*al1p[kN+2][0]+m[k][0]*m[k][0]);
691  Etot += E;
692 
693  Px += al1p[kN+0][0] ;
694  Py += al1p[kN+1][0];
695  Pz += al1p[kN+2][0];
696  }
697  md[fNc+0][0] = Etot*Etot - Px*Px - Py*Py - Pz*Pz - fMass*fMass ;
698 
699  double sumA=0;
700  for(int k=0; k<nd; ++k) {
701  int kN=k*7;
702  double px = al1p[kN+0][0];
703  double py = al1p[kN+1][0];
704  double pz = al1p[kN+2][0];
705  // double E = al1p[kN+3][0];
706  double E = TMath::Sqrt(px*px+py*py+pz*pz+m[k][0]*m[k][0]);
707 
708  //here there should be implemented the algorithm for neutral particles
709 
710  Double_t bField = 0.1*RhoCalculationTools::GetBz(fDaughters[k]->Pos()); // T, assume field in z only
711  a = -0.00299792458*bField*fDaughters[k]->GetCharge();//TODO BField
712  sumA += a;
713  Double_t invE = 1./E;
714 
715  mD[fNc+0][kN+0] = 2.*(Etot*al1p[kN+0][0]*invE-Px);
716  mD[fNc+0][kN+1] = 2.*(Etot*al1p[kN+1][0]*invE-Py);
717  mD[fNc+0][kN+2] = 2.*(Etot*al1p[kN+2][0]*invE-Pz);
718  mD[fNc+0][kN+3] = 0.;
719  mD[fNc+0][kN+4] =-2.*(Etot*al1p[kN+1][0]*invE-Py)*a;
720  mD[fNc+0][kN+5] = 2.*(Etot*al1p[kN+0][0]*invE-Px)*a;
721  mD[fNc+0][kN+6] = 0.;
722  }
723  cout << "Sum A: " << sumA << endl;
724 
725 
726  mE[fNc+0][0] = 2*sumA*Px;
727  mE[fNc+0][1] = -2*sumA*Py;
728  mE[fNc+0][2] = 0.;
729  fNc +=1;
730 }
__m128 m
Definition: P4_F32vec4.h:28
static T Sqrt(const T &x)
Definition: PndCAMath.h:37
Int_t a
Definition: anaLmdDigi.C:126
Double_t
std::vector< RhoCandidate * > fDaughters
Definition: RhoFitterBase.h:69
static Double_t GetBz(const TVector3 &position)
Return the magnetic field along the z-axis in kGs
TPad * p1
Definition: hist-t7.C:116
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52
double pz[39]
Definition: pipisigmas.h:14
void RhoKinVtxFitter::ReadMatrix ( )
private

Definition at line 448 of file RhoKinVtxFitter.cxx.

References al0, RhoFitterBase::fDaughters, i, jj, m, p1, p2, sqrt(), and V_al0.

Referenced by Compute().

449 {
450  int nd =fDaughters.size();
451  TMatrixD m(nd,1);
452  for (int k=0; k<nd; k++) {
453  int kN=k*7;
454  //px,py,pz,E,x,y,z
455  TLorentzVector p1=fDaughters[k]->P4(); //4-momentum of the daughter
456  TVector3 p2=fDaughters[k]->Pos(); // position of the daughter
457  al0[kN+0][0]=p1.X();
458  al0[kN+1][0]=p1.Y();
459  al0[kN+2][0]=p1.Z();
460  // al0[kN+3][0]=p1.E();
461  al0[kN+4][0]=p2.X();
462  al0[kN+5][0]=p2.Y();
463  al0[kN+6][0]=p2.Z();
464 
465  double fm=fDaughters[k]->Mass();
466  al0[kN+3][0]=sqrt(al0[kN+0][0]*al0[kN+0][0]+ al0[kN+1][0]*al0[kN+1][0]+al0[kN+2][0]*al0[kN+2][0]+fm*fm);
467 
468  // Read Covariance Matrix .... Can read 6x6 matrices..................
469  TMatrixD p1Cov(7,7);
470  TMatrixD p3Cov(6,6); //Why 6x6 here if 7x7 should be cpoied (below)
471  TMatrixD p2Cov(7,7);
472  TMatrixD p4Cov(7,7);
473  p1Cov=fDaughters[k]->Cov7(); //Cov Matrix x,y,z,px,py,pz,E
474 
475  for (int ii=0; ii<6; ii++) {for(int jj=0; jj<6; jj++) {p3Cov[ii][jj]=p1Cov[ii][jj];}} //test
476 
477  //Extend matrix for energy for each candidates .....6x6 to 7x7
478  TMatrixD J(7,6) ;
479  J.Zero();
480  TMatrixD J_t(6,7);
481  for (int ii=0; ii<6; ii++) {for(int jj=0; jj<6; jj++) {J[ii][jj] = 1;}}
482  for(int i=3; i<6; ++i) {J[6][i] = al0[kN+i-3][0]/al0[kN+3][0];}
483  // p2Cov= J*p3Cov*(J_t.Transpose(J));
484  p2Cov=p1Cov;
485  //Change to px,py,pz,E,x,y,z
486  for(int i=0; i<7; i++) {
487  for(int j=0; j<7; j++) {
488  if(i>=3) {
489  if(j>=3) {
490  p4Cov[i-3][j-3] = p2Cov[i][j];
491  } else { p4Cov[i-3][j+4] = p2Cov[i][j]; }
492  } else {
493  if(j>=3) {
494  p4Cov[i+4][j-3] = p2Cov[i][j];
495  } else { p4Cov[i+4][j+4] = p2Cov[i][j]; }
496  }
497  }
498  }
499 
500  for(int i=0; i<7; i++) {
501  for (int j=0; j<7; j++) {
502  V_al0[k*7+i][k*7+j] = p4Cov[i][j];
503  }
504  }
505  }
506 }
Int_t i
Definition: run_full.C:25
__m128 m
Definition: P4_F32vec4.h:28
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
std::vector< RhoCandidate * > fDaughters
Definition: RhoFitterBase.h:69
TPad * p2
Definition: hist-t7.C:117
TPad * p1
Definition: hist-t7.C:116
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52
void RhoKinVtxFitter::ResetMatrices ( )
private

Definition at line 86 of file RhoKinVtxFitter.cxx.

References al0, al1, covC, mPull, V_al0, V_al1, vtx_ex, and vtx_st.

Referenced by Compute().

87 {
88  al0.Zero();
89  V_al0.Zero();
90  al1.Zero();
91  V_al1.Zero();
92  mPull.Zero();
93  vtx_ex.Zero();
94  vtx_st.Zero();
95  covC.Zero();
96 }
void RhoFitterBase::SetDaugthersFromComposite ( RhoCandidate cand)
protectedinherited

Definition at line 136 of file RhoFitterBase.cxx.

References RhoCandidate::Daughter(), RhoFitterBase::fDaughters, RhoCandidate::IsComposite(), and RhoCandidate::NDaughters().

Referenced by RhoKinHyperonFitter::Fit(), FitNode(), RhoKinHyperonVtxFitter::FitNode(), and RhoKinHyperonFitter::SetMatrices().

137 {
138  fDaughters.clear();
139  if(cand->IsComposite()){
140  RhoCandidate* tc;
141  for (int k=0;k<cand->NDaughters();k++) {
142  tc=cand->Daughter(k);
143  fDaughters.push_back(tc);
144  }
145  }
146  return;
147 }
Bool_t IsComposite() const
RhoCandidate * Daughter(Int_t n)
std::vector< RhoCandidate * > fDaughters
Definition: RhoFitterBase.h:69
Int_t NDaughters() const
void RhoFitterBase::SetDecayVertex ( RhoCandidate composite,
const TVector3 &  vtx,
const TMatrixD CovVV 
)
protectedinherited

Definition at line 178 of file RhoFitterBase.cxx.

References RhoCandidate::SetDecayVtx().

Referenced by RhoKalmanVtxFitter::Calculate(), SetOutput(), and RhoKinHyperonVtxFitter::SetOutput().

179 {
180  RhoError decaypointcov(CovVV);
181  RhoVector3Err decayvertex(vtx,decaypointcov);
182  composite->SetDecayVtx(decayvertex);
183 }
void SetDecayVtx(RhoVector3Err theVtx)
void RhoFitterBase::SetFourMomentumByDaughters ( RhoCandidate composite)
protectedinherited

Definition at line 160 of file RhoFitterBase.cxx.

References RhoCandidate::Cov7(), RhoCandidate::Daughter(), RhoCandidate::IsComposite(), RhoCandidate::IsLocked(), RhoCandidate::NDaughters(), RhoCandidate::P4(), RhoCandidate::SetCov7(), and RhoCandidate::SetP4().

Referenced by RhoKalmanVtxFitter::Calculate(), Rho4CFitter::Fit(), Rho4CFitter::FitConserveMasses(), SetOutput(), and RhoKinFitter::SetOutput().

161 {
162  RhoCandidate* tc;
163  TLorentzVector tmpLV;
164  TMatrixD tmpCov(7,7);
165  // Sum daughter fourmomenta, dive into nodes if necessary
166  for (int k=0;k<composite->NDaughters();k++) {
167  tc=composite->Daughter(k);
168  if (tc->IsComposite() && !tc->IsLocked()) { SetFourMomentumByDaughters(tc); }
169  tmpLV += tc->P4();
170  tmpCov = tmpCov + tc->Cov7();
171  }
172  composite->SetP4(tmpLV);
173  composite->SetCov7(tmpCov);
174  //std::cout<<" Base fitter cov7 from tc "<<tc->Uid()<<"/"<<tc->Charge()<<"/"<<tc->PdgCode()<<": ";tmpCov.Print();
175  return;
176 }
Bool_t IsComposite() const
RhoCandidate * Daughter(Int_t n)
void SetFourMomentumByDaughters(RhoCandidate *composite)
void SetP4(Double_t mass, const TVector3 &p3)
Bool_t IsLocked()
Definition: RhoCandidate.h:330
TLorentzVector P4() const
Definition: RhoCandidate.h:195
TMatrixD Cov7() const
Int_t NDaughters() const
void SetCov7(const TMatrixD &cov7)
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52
void RhoKinVtxFitter::SetMatrices ( )
private

Definition at line 63 of file RhoKinVtxFitter.cxx.

References al0, al1, covC, RhoFitterBase::fDaughters, fNc, fNcon, fNiter, fNpar, fNpart, fNvar, mPull, NumCon, V_al0, V_al1, vtx_ex, and vtx_st.

Referenced by Compute().

64 {
65  int nd=fDaughters.size();
66 
67  fNvar=7;
68  fNpart=nd;
69  fNpar =nd*fNvar;
70  fNcon=NumCon;
71  // if(fVerbose) cout << fNcon << "Num " << endl;
72  fNc=0;
73  fNiter=0;
74 
75  al0.ResizeTo(7*nd,1);
76  V_al0.ResizeTo(fNpar,fNpar);
77  al1.ResizeTo(7*nd,1);
78  V_al1.ResizeTo(fNpar,fNpar);
79  vtx_ex.ResizeTo(3,1);
80  vtx_st.ResizeTo(3,1);
81  mPull.ResizeTo(7*nd,1);
82  covC.ResizeTo(7,7);
83 }
std::vector< RhoCandidate * > fDaughters
Definition: RhoFitterBase.h:69
void RhoKinVtxFitter::SetMinDChisq ( double  m = 0.001)
inline

Definition at line 33 of file RhoKinVtxFitter.h.

References fabs(), fMinDChisq, and m.

33 {fMinDChisq=fabs(m);};
__m128 m
Definition: P4_F32vec4.h:28
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
void RhoKinVtxFitter::SetNIterationsExact ( int  nit = 2)
inline

Definition at line 32 of file RhoKinVtxFitter.h.

References fIterateExact, and fNMaxIterations.

Referenced by PndPmtTask::Exec().

void RhoKinVtxFitter::SetNMaxIterations ( int  nit = 20)
inline

Definition at line 31 of file RhoKinVtxFitter.h.

References fIterateExact, and fNMaxIterations.

void RhoKinVtxFitter::SetOutput ( RhoCandidate head)
private

[ralfk:28.5.2013] Use flat Fourmomentum sum from RhoFitterBase

Definition at line 329 of file RhoKinVtxFitter.cxx.

References a, al0, al1, covC, Double_t, RhoFitterBase::fDaughters, RhoFitterBase::fVerbose, RhoCalculationTools::GetBz(), i, m, p1, pos, RhoFitterBase::SetDecayVertex(), RhoFitterBase::SetFourMomentumByDaughters(), RhoCandidate::SetPos(), V_al0, and vtx_ex.

Referenced by FitNode().

330 {
331 
332  int nd=fDaughters.size();
333  TMatrixD m(nd,1);
334 
335 
336  double sumA=0;
337  double a;
338  for (int k=0; k<nd; k++) {
339 
340 
341  //skip locked daughters
342  if(fDaughters[k]->IsLocked()) continue;
343  Double_t bField = 0.1*RhoCalculationTools::GetBz(fDaughters[k]->Pos()); // T, assume field in z only
344  a = -0.00299792458*bField*fDaughters[k]->GetCharge();
345  sumA += a;
346  TVector3 pos(al0[k*7+4][0],al0[k*7+5][0],al0[k*7+6][0]);
347 //std::cout<<" --"<<k<<"-- ("<<pos.x()<<";"<<pos.y()<<";"<<pos.z()<<")"<<std::endl;
348 
349  TLorentzVector mom4(al0[k*7+0][0],al0[k*7+1][0],al0[k*7+2][0], al0[k*7+3][0]);
350 // fDaughters[k]->SetP7(pos,mom4);
351 //better to put daugthers with mass hypothesis .......?? VJ
352  TLorentzVector momM;
353  double fM=fDaughters[k]->Mass();
354  momM.SetXYZM(al0[k*7+0][0],al0[k*7+1][0],al0[k*7+2][0],fM);
355 // momM.SetP4(fM,al0[k*7+0][0],al0[k*7+1][0],al0[k*7+2][0]);
356  fDaughters[k]->SetP7(pos,momM);
357 
358 
359  //Extend matrix for energy for each candidates if daughters from mass hypothesis 6x6 covariance
360  TMatrixD p1Cov(7,7);
361  TLorentzVector p1=fDaughters[k]->P4();
362  TMatrixD p2Cov(7,7);
363 
364  for(int i=0; i<7; i++) {
365  for (int j=0; j<7; j++) {
366  p1Cov[i][j]= V_al0[k*7+i][k*7+j];
367  }
368  }
369 
370 
371  //Change from px,py,pz,E,x,y,z
372  // to x,y,z,px,py,pz,E
373  for(int i=0; i<7; i++) {
374  for(int j=0; j<7; j++) {
375  if(i>=4) {
376  if(j>=4) {
377  p2Cov[i-4][j-4] = p1Cov[i][j];
378  } else { p2Cov[i-4][j+3] = p1Cov[i][j]; }
379  } else {
380  if(j>=4) {
381  p2Cov[i+3][j-4] = p1Cov[i][j];
382  } else { p2Cov[i+3][j+3] = p1Cov[i][j]; }
383  }
384  }
385  }
386 
387  // create cov with E... check it
388  double invE = 1./al0[k*7+3][0];
389  p2Cov[3][6] = p2Cov[6][3] = (p1.X()*p1Cov[0][0]+p1.Y()*p1Cov[0][1]+p1.Z()*p1Cov[0][2])*invE;
390  p2Cov[4][6] = p2Cov[6][4] = (p1.X()*p1Cov[1][0]+p1.Y()*p1Cov[1][1]+p1.Z()*p1Cov[1][2])*invE;
391  p2Cov[5][6] = p2Cov[6][5] = (p1.X()*p1Cov[2][0]+p1.Y()*p1Cov[2][1]+p1.Z()*p1Cov[2][2])*invE;
392 
393  p2Cov[6][6] = (p1.X()*p1.X()*p1Cov[0][0]+p1.Y()*p1.Y()*p1Cov[1][1]+p1.Z()*p1.Z()*p1Cov[2][2]
394  +2.0*p1.X()*p1.Y()*p1Cov[0][1]
395  +2.0*p1.X()*p1.Z()*p1Cov[0][2]
396  +2.0*p1.Y()*p1.Z()*p1Cov[1][2])*invE*invE;
397 
398  p2Cov[6][0] = p2Cov[0][6] = (p1.X()*p1Cov[0][4]+p1.Y()*p1Cov[1][4]+p1.Z()*p1Cov[2][4])*invE;
399  p2Cov[6][1] = p2Cov[1][6] = (p1.X()*p1Cov[0][5]+p1.Y()*p1Cov[1][5]+p1.Z()*p1Cov[2][5])*invE;
400  p2Cov[6][2] = p2Cov[2][6] = (p1.X()*p1Cov[0][6]+p1.Y()*p1Cov[1][6]+p1.Z()*p1Cov[2][6])*invE;
401 
402  fDaughters[k]->SetCov7(p2Cov); //New covariance matrix with correlations
403  //cout<< " ####### KinVtx daughter cov check... " << endl;
404  //cout<<"p1Cov"; p1Cov.Print();
405  //cout<<"p2Cov"; p2Cov.Print();
406 
407  }
408 
409 
411 //
412 // // For the composite particle ..............................
414 // double fpx=0,fpy=0,fpz=0,fe=0;
415 // for (int k=0; k<nd; k++) {
416 // fpx+= al0[k*7+0][0]-a*(vtx_ex[1][0]*sumA/a - al0[k*7+5][0]);
417 // fpy+= al0[k*7+1][0]+a*(vtx_ex[0][0]*sumA/a - al0[k*7+4][0]);
418 // fpz+= al0[k*7+2][0];
419 // fe += al0[k*7+3][0];
420 // }
421 // // double TotE=(fpx*fpx+fpy*fpy+fpz*fpz+fe*fe);
422 // //double fM=sqrt(fe*fe-(fpx*fpx+fpy*fpy*fpz*fpz));
423 // TLorentzVector sum(fpx,fpy,fpz,fe);
424 // // TLorentzVector sum;
425 // // sum.SetXYZM(fpx,fpy,fpz,fM);
426 // TVector3 vtx(vtx_ex[0][0],vtx_ex[1][0],vtx_ex[2][0]);
427 // //fHeadOfTree->SetP7(vtx,sum);
428 // head->SetP7(vtx,sum); //[ralfk:01.12.11 Try to make it a leaf-by-leaf fit]
429 // //fHeadOfTree->SetCov7(covC); //New covariance matrix
430 // head->SetCov7(covC); //New covariance matrix //[ralfk:01.12.11]
431  //We set the decay vertex of the mother! [R.K.]
432 
433  TVector3 vtx(vtx_ex[0][0],vtx_ex[1][0],vtx_ex[2][0]);
434  TMatrixD CovV = covC.GetSub(0,2,0,2);
435 
436  head->SetPos(vtx);//P4 is defined here
437  SetDecayVertex(head,vtx,CovV);
438  SetFourMomentumByDaughters(head);//propagates cov7 from daughters
439  //head->SetCov7(covC);//which one to use???
440  //cout<<" KinVtx Cov7: ";covC.Print();
441  if(fVerbose) { cout<<"Final vertex Position is "<<vtx_ex[0][0]<<" "<<vtx_ex[1][0]<<" "<<vtx_ex[2][0]<<endl; }
442  if(fVerbose) { cout<<"Final Momenta are "<<al0[0][0]<<" "<<al1[1][0]<<" "<<al1[2][0]<<endl; }
443 }
TVector3 pos
void SetPos(const TVector3 &pos)
Definition: RhoCandidate.h:235
Int_t i
Definition: run_full.C:25
__m128 m
Definition: P4_F32vec4.h:28
void SetFourMomentumByDaughters(RhoCandidate *composite)
Int_t a
Definition: anaLmdDigi.C:126
Double_t
std::vector< RhoCandidate * > fDaughters
Definition: RhoFitterBase.h:69
static Double_t GetBz(const TVector3 &position)
Return the magnetic field along the z-axis in kGs
TPad * p1
Definition: hist-t7.C:116
void SetDecayVertex(RhoCandidate *composite, const TVector3 &vtx, const TMatrixD &CovVV)
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52
void RhoFitterBase::SetVerbose ( Bool_t  v = kTRUE)
inlineinherited

Definition at line 52 of file RhoFitterBase.h.

References RhoFitterBase::fVerbose, and v.

52 {fVerbose=v;}
__m128 v
Definition: P4_F32vec4.h:4
void RhoKinVtxFitter::TransportToVertex ( TMatrixD a_in,
TMatrixD a_cov_in,
TMatrixD a_out,
TMatrixD a_cov_out,
TMatrixD xref 
)
private

Correct one helix and/or track(s) to vertex point for charged and/or neutral particles

Definition at line 816 of file RhoKinVtxFitter.cxx.

References a, atan2(), Double_t, fabs(), RhoFitterBase::fDaughters, RhoCalculationTools::GetBz(), ptot, pz, s, sqrt(), x, y, and z.

Referenced by Compute().

817 {
818  //edited by J.Puetz
819  //added parametrization for neutral daughter particles
820 
822  int fNDau=fDaughters.size();
823  int nd=fNDau;
824  TMatrixD U(7*nd,7*nd);
825  int kN=0;
826  for(int k=0; k<nd; k++) {
827  kN=7*k;
828 
829  //double m = fDaughters[k]->Mass(); //[R.K. 01/2017] unused variable?
830  //check, if daughter particle is either neutral or charged
831  if (fabs(fDaughters[k]->GetCharge())<1e-6){//begin neutral
832  double a = 0.00299792458; // unit conversion constant
833  double inva = 1/a;
834  //Get position, energy and momentum for the daughter particle
835  double px=a_in[kN+0][0];
836  double py=a_in[kN+1][0];
837  double pz=a_in[kN+2][0];
838  //double p2=px*px+py*py+pz*pz; //[R.K. 01/2017] unused variable?
839  //double E= sqrt(m*m+p2);
840  double x=a_in[kN+4][0];
841  double y=a_in[kN+5][0];
842  double z=a_in[kN+6][0];
843 
844  //correct particle position to vertex, keep momentum and energy
845  a_out[kN+0][0] = px;
846  a_out[kN+1][0] = py;
847  a_out[kN+2][0] = pz;
848  a_out[kN+3][0] = a_in[kN+3][0];
849  a_out[kN+4][0] = x+px*inva;
850  a_out[kN+5][0] = y+py*inva;
851  a_out[kN+6][0] = z+pz*inva;
852 
853  //matrix U corrects the covariant matrix a_cov_in to a_cov_out= U * a_cov_in * U^T
854  U[kN+0][kN+0] = 1.;
855  U[kN+1][kN+1] = 1.;
856  U[kN+2][kN+2] = 1.;
857  U[kN+3][kN+3] = 1.;
858 
859  U[kN+4][kN+4] = 1.;
860  U[kN+4][kN+0] = inva;
861 
862  U[kN+5][kN+5] = 1.;
863  U[kN+5][kN+1] = inva;
864 
865  U[kN+6][kN+6] = 1.;
866  U[kN+6][kN+2] = inva;
867 
868 
869  }//end neutral
870 
871  else{ // if particle is charged
872 
873  Double_t bField = 0.1*RhoCalculationTools::GetBz(fDaughters[k]->Pos()); // T, assume field in z only
874  double a = -0.00299792458*bField*fDaughters[k]->GetCharge();
875 
876  // if(fVerbose)cout << "a " << a << endl;
877 
878  //Get position, energy and momentum for the daughter particle
879 
880  double px=a_in[kN+0][0];
881  double py=a_in[kN+1][0];
882  double pz=a_in[kN+2][0];
883  double x=a_in[kN+4][0];
884  double y=a_in[kN+5][0];
885  double z=a_in[kN+6][0];
886 
887  double ptot = sqrt(px*px + py*py + pz*pz);
888  //double E=sqrt(m*m+ptot*ptot);
889  double rho = a/ptot; //1/R with R: the radius of the trajectory
890  double A1 = 1 - pow(pz/ptot,2) - ( (x-xref[0][0])*py - (y-xref[1][0])*px )*rho/ptot ;
891  double A2 = (x-xref[0][0])*px + (y-xref[1][0])*py;
892  A2 = A2/ptot;
893 
894 
895  double det = sqrt(A1*A1+rho*rho*A2*A2);
896  double cos_rho_s = A1/det;
897  double sin_rho_s = -rho*A2/det;
898 
899 
900 
901  //double s = atan2(sin_rho_s,cos_rho_s);
902  double s = atan2(sin_rho_s,cos_rho_s)/rho ;
903  a_out[kN+0][0] = px*cos_rho_s-py*sin_rho_s;
904  a_out[kN+1][0] = py*cos_rho_s+px*sin_rho_s;
905  a_out[kN+2][0] = pz;
906  a_out[kN+3][0] = a_in[kN+3][0];
907  a_out[kN+4][0] = x + (px*sin_rho_s - py*(1-cos_rho_s))/a;
908  a_out[kN+5][0] = y + (py*sin_rho_s + px*(1-cos_rho_s))/a;
909  a_out[kN+6][0] = z + (pz/ptot)*s;
910 
911 
912  //matrix to calculate the corrected covariance matrix
913  U[kN+0][kN+0] = cos_rho_s;
914  U[kN+0][kN+1] = -sin_rho_s;
915 
916  U[kN+1][kN+0] = sin_rho_s;
917  U[kN+1][kN+1] = cos_rho_s;
918 
919  U[kN+2][kN+2] = 1.;
920  U[3+kN][3+kN] = 1.;
921 
922  U[4+kN][0+kN] = sin_rho_s/a;
923  U[4+kN][1+kN] = (1.-cos_rho_s)/a;
924  U[4+kN][4+kN] = 1.;
925 
926  U[5+kN][0+kN] = (1.-cos_rho_s)/a;
927  U[5+kN][1+kN] = sin_rho_s/a;
928  U[5+kN][5+kN] = 1.;
929 
930  U[6+kN][2+kN] = s/ptot;
931  U[6+kN][6+kN] = 1.;
932 
933 
934  }// end charged
935 
936  }//end k
937 
938  TMatrixD U_t=U;
939  U_t=U_t.T();
940  a_cov_out = U*a_cov_in*U_t;
941 
942 }
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
TLorentzVector s
Definition: Pnd2DStar.C:50
Double_t ptot
Definition: checkhelixhit.C:68
Int_t a
Definition: anaLmdDigi.C:126
Double_t
Double_t z
friend F32vec4 fabs(const F32vec4 &a)
Definition: P4_F32vec4.h:47
std::vector< RhoCandidate * > fDaughters
Definition: RhoFitterBase.h:69
friend F32vec4 atan2(const F32vec4 &y, const F32vec4 &x)
Definition: P4_F32vec4.h:117
Double_t x
static Double_t GetBz(const TVector3 &position)
Return the magnetic field along the z-axis in kGs
Double_t y
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52
double pz[39]
Definition: pipisigmas.h:14

Member Data Documentation

TMatrixD RhoKinVtxFitter::al0
private

Definition at line 55 of file RhoKinVtxFitter.h.

Referenced by Compute(), ReadMatrix(), ResetMatrices(), SetMatrices(), and SetOutput().

TMatrixD RhoKinVtxFitter::al1
private
TMatrixD RhoKinVtxFitter::covC
private

Definition at line 59 of file RhoKinVtxFitter.h.

Referenced by Compute(), ResetMatrices(), SetMatrices(), and SetOutput().

double RhoKinVtxFitter::fChi2Diff
private

Definition at line 81 of file RhoKinVtxFitter.h.

double RhoFitterBase::fChiSquare
protectedinherited
double RhoKinVtxFitter::fchiSquare
private

Definition at line 103 of file RhoKinVtxFitter.h.

std::vector<RhoCandidate*> RhoFitterBase::fDaughters
protectedinherited
RhoCandidate* RhoFitterBase::fHeadOfTree
protectedinherited
bool RhoKinVtxFitter::fIterateExact
private

Definition at line 99 of file RhoKinVtxFitter.h.

Referenced by Compute(), RhoKinVtxFitter(), SetNIterationsExact(), and SetNMaxIterations().

double RhoKinVtxFitter::fMass
private

Definition at line 90 of file RhoKinVtxFitter.h.

Referenced by AddMassConstraint(), and ReadMassKinMatrix().

int RhoKinVtxFitter::fMassConstraint
private

Definition at line 93 of file RhoKinVtxFitter.h.

Referenced by AddMassConstraint(), Compute(), and RhoKinVtxFitter().

double RhoKinVtxFitter::fMinDChisq
private

Definition at line 97 of file RhoKinVtxFitter.h.

Referenced by Compute(), RhoKinVtxFitter(), and SetMinDChisq().

Int_t RhoKinVtxFitter::fNc
private

Definition at line 73 of file RhoKinVtxFitter.h.

Referenced by Compute(), ReadKinMatrix(), ReadMassKinMatrix(), and SetMatrices().

Int_t RhoKinVtxFitter::fNcon
private

Definition at line 70 of file RhoKinVtxFitter.h.

Referenced by ReadKinMatrix(), ReadMassKinMatrix(), and SetMatrices().

int RhoFitterBase::fNDegreesOfFreedom
protectedinherited
int RhoKinVtxFitter::fnDof
private

Definition at line 102 of file RhoKinVtxFitter.h.

Int_t RhoKinVtxFitter::fNiter
private

Definition at line 74 of file RhoKinVtxFitter.h.

Referenced by SetMatrices().

int RhoKinVtxFitter::fNMaxIterations
private

Definition at line 98 of file RhoKinVtxFitter.h.

Referenced by Compute(), RhoKinVtxFitter(), SetNIterationsExact(), and SetNMaxIterations().

Int_t RhoKinVtxFitter::fNpar
private

Definition at line 68 of file RhoKinVtxFitter.h.

Referenced by ReadKinMatrix(), ReadMassKinMatrix(), and SetMatrices().

Int_t RhoKinVtxFitter::fNpart
private

Definition at line 69 of file RhoKinVtxFitter.h.

Referenced by SetMatrices().

Int_t RhoKinVtxFitter::fNumKnown
private

Definition at line 75 of file RhoKinVtxFitter.h.

Int_t RhoKinVtxFitter::fNvar
private

Definition at line 67 of file RhoKinVtxFitter.h.

Referenced by SetMatrices().

double RhoKinVtxFitter::fPull
private

Definition at line 82 of file RhoKinVtxFitter.h.

Referenced by Compute(), and GetPull().

Bool_t RhoFitterBase::fVerbose
protectedinherited
TMatrixD RhoKinVtxFitter::mD
private

Definition at line 61 of file RhoKinVtxFitter.h.

Referenced by Compute(), ReadKinMatrix(), and ReadMassKinMatrix().

TMatrixD RhoKinVtxFitter::md
private

Definition at line 63 of file RhoKinVtxFitter.h.

Referenced by Compute(), ReadKinMatrix(), and ReadMassKinMatrix().

TMatrixD RhoKinVtxFitter::mE
private

Definition at line 62 of file RhoKinVtxFitter.h.

Referenced by Compute(), ReadKinMatrix(), and ReadMassKinMatrix().

TMatrixD RhoKinVtxFitter::mPull
private

Definition at line 64 of file RhoKinVtxFitter.h.

Referenced by Compute(), ResetMatrices(), and SetMatrices().

int RhoKinVtxFitter::niter
private

Definition at line 80 of file RhoKinVtxFitter.h.

Int_t RhoKinVtxFitter::NumCon
private

Definition at line 76 of file RhoKinVtxFitter.h.

Referenced by Compute(), and SetMatrices().

TMatrixD RhoKinVtxFitter::V_al0
private

Definition at line 57 of file RhoKinVtxFitter.h.

Referenced by Compute(), ReadMatrix(), ResetMatrices(), SetMatrices(), and SetOutput().

TMatrixD RhoKinVtxFitter::V_al1
private

Definition at line 58 of file RhoKinVtxFitter.h.

Referenced by Compute(), ResetMatrices(), and SetMatrices().

TMatrixD RhoKinVtxFitter::vtx_ex
private
TMatrixD RhoKinVtxFitter::vtx_st
private

Definition at line 87 of file RhoKinVtxFitter.h.

Referenced by Compute(), ResetMatrices(), and SetMatrices().


The documentation for this class was generated from the following files: