FairRoot/PandaRoot
PndPidTrackInfo.cxx
Go to the documentation of this file.
1 #include "PndPidCorrelator.h"
2 #include "PndPidCandidate.h"
3 #include "PndTrack.h"
4 #include "FairTrackParH.h"
5 #include "FairRun.h"
6 #include "FairRunSim.h"
7 #include "FairRunAna.h"
8 #include "FairField.h"
9 #include "RhoCalculationTools.h"
10 #include "TVector3.h"
11 #include "TDatabasePDG.h"
12 #include <cmath>
13 
14 //_________________________________________________________________
16 {
17  Int_t charge = TMath::Sign(1, track->GetParamFirst().GetQ());
18  pidCand->SetCharge(charge);
19 
20  TVector3 first(track->GetParamFirst().GetX(),
21  track->GetParamFirst().GetY(),
22  track->GetParamFirst().GetZ());
23  TVector3 last(track->GetParamLast().GetX(),
24  track->GetParamLast().GetY(),
25  track->GetParamLast().GetZ());
26  FairTrackParP par = track->GetParamFirst();
27  Int_t ierr = 0;
28  FairTrackParH *fRes;
29  TVector3 momentum, startpos;
30 
31  if (fGeanePro && fBackPropagate) // Overwrites vertex if Geane is used and if backpropagation
32  {
33  FairTrackParH *helix = new FairTrackParH(&par, ierr);
34  fRes= new FairTrackParH();
35 
36  // track back to Origin
37  // [ralfk: changed to propagate to z axis - 03/2011]
38  //fPro0->SetPoint(TVector3(0,0,0));
39  //fPro0->PropagateToPCA(1, -1);
40  // Propagatetrack back to z Axis
41  fGeanePropagator->PropagateToPCA(2, -1);// track back to z axis
42  TVector3 ex1(0.,0.,-50.); // virtual wire, dimensions chosen arbitrarily
43  TVector3 ex2(0.,0.,100.); // we expect fast decaying tracks to be close to that
44  fGeanePropagator->SetWire(ex1,ex2);
45 
46  Bool_t rc = fGeanePropagator->Propagate(helix, fRes, fPidHyp*charge);
47  if (!rc)
48  {
49  std::cout << "-W- PndPidCorrelator::GetTrackInfo :: Failed backward propagation" << std::endl;
50  if (fVerbose>0) helix->Print();
51  return kFALSE;
52  }
53  }
54  else
55  {
56  // If no backpropagation, use the first params
57  fRes = new FairTrackParH(&par, ierr);
58  }
59  startpos.SetXYZ(fRes->GetX(), fRes->GetY(), fRes->GetZ()); //cm
60  momentum = fRes->GetMomentum();
61 
62  // ******** this block replaces
63  TVector3 di = momentum;
64  di.SetMag(1.);
65  TVector3 dj = di.Orthogonal();
66  TVector3 dk = di.Cross(dj);
67  FairTrackParP *fParab = new FairTrackParP(fRes, dj, dk, ierr);
68  // ******* that line (recipe by Lia)
69  //FairTrackParP *fParab = new FairTrackParP(fRes, TVector3(1.,0.,0.), TVector3(0.,1.,0.), ierr);
70  // ******* that line (recipe by Lia)
71 
72  Double_t globalCov[6][6];
73  fParab->GetMARSCov(globalCov);
74 
75  Int_t ii,jj;
76  TMatrixD err(6,6);
77  for (ii=0;ii<6;ii++) for(jj=0;jj<6;jj++) err[ii][jj]=globalCov[ii][jj];
78 
79  //err.Print();
80 
81  TLorentzVector lv;
82  lv.SetVectM(momentum, TDatabasePDG::Instance()->GetParticle(fPidHyp)->Mass()); // set mass hypothesis
83  Float_t energy = lv.E();
85 
86  pidCand->SetPosition(startpos);
87  pidCand->SetMomentum(momentum);
88  pidCand->SetEnergy(energy);
89  pidCand->SetCov7(mat);
90 
91  // Adding the helix parameters to the candidate (TFitParams)
92  // It is nice to know at analysis stage
93  //rho helix: (D0,Phi0,rho(omega),Z0,tan(dip))
94  //fair helix: (q/p,lambda, phi, y_perp, z_perp)
95  Double_t Q=fRes->GetQ();
96  //if(0==Q) ??? break/return?;
97  Double_t pnt[3], Bf[3];
98  pnt[0]=startpos.X();
99  pnt[1]=startpos.Y();
100  pnt[2]=startpos.Z();
101  if(FairRun::Instance()->IsAna()){
102  FairRunAna::Instance()->GetField()->GetFieldValue(pnt, Bf); //[kGs]
103  }else{
104  FairRunSim::Instance()->GetField()->GetFieldValue(pnt, Bf); //[kGs]
105  }
106  //Double_t B = sqrt(Bf[0]*Bf[0]+Bf[1]*Bf[1]+Bf[2]*Bf[2]);
107  Double_t B = Bf[2];
108  Double_t qBc = -0.000299792458*B*Q;
109  Double_t icL = 1. / cos(fRes->GetLambda()); // inverted for practical reasons (better to multiply than to divide)
110  Double_t icLs = icL*icL;
111  Double_t helixparams[5];
112  //helixparams[0]=startpos.Perp(); //D0
113  helixparams[0]=fRes->GetY_sc() ; //D0
114  //helixparams[1]=fRes->GetPhi(); //phi0
115  helixparams[1]=fRes->GetMomentum().Phi(); //phi0
116  helixparams[2]=qBc/(fRes->GetMomentum().Perp()); //omega=rho=1/R[cm]=-2.998e-4*B[kGs]*Q[e]/p_perp[GeV/c]
117  //helixparams[3]=startpos.Z(); //z0
118  helixparams[3]=fRes->GetZ_sc()*icL; //z0
119  helixparams[4]=tan(fRes->GetLambda()); //lambda(averey)=cot(theta)=tan(lambda(geane))
120  pidCand->SetHelixParams(helixparams);
121  Double_t fairhelixcov[15];
122  fRes->GetCov(fairhelixcov);
123  Double_t rhohelixcov[15];
124  // in the poca to z axis yperp=D0, x_perp^2+z_perp^2 = z_perp/cos(Lambda)= Z0
125  rhohelixcov[0] = fairhelixcov[12]; // sigma^2 D0
126  rhohelixcov[1] = fairhelixcov[10]; // cov D0 - Phi0
127  rhohelixcov[2] = fairhelixcov[3] * qBc * icL; // cov D0 - rho
128  rhohelixcov[3] = fairhelixcov[13] * icL; // cov D0 - Z0
129  rhohelixcov[4] = fairhelixcov[7] * icLs; // cov D0 - tan(dip)
130  rhohelixcov[5] = fairhelixcov[9]; // sigma^2 Phi0
131  rhohelixcov[6] = fairhelixcov[2] * qBc * icL; // cov Phi0 - rho
132  rhohelixcov[7] = fairhelixcov[11] * icL; // cov Phi0 - Z0
133  rhohelixcov[8] = fairhelixcov[6] * icLs; // cov Phi0 - tan(dip)
134  rhohelixcov[9] = fairhelixcov[0] * qBc * qBc * icLs; // sigma^2 rho
135  rhohelixcov[10] = fairhelixcov[4] * qBc * icLs; // cov rho - Z0
136  rhohelixcov[11] = fairhelixcov[1] * qBc * icL * icLs; // cov rho - tan(dip)
137  rhohelixcov[12] = fairhelixcov[14] * icLs; // sigma^2 Z0
138  rhohelixcov[13] = fairhelixcov[8] * icL * icLs; //cov Z0 - tan(dip)
139  rhohelixcov[14] = fairhelixcov[5] * icLs * icLs; // sigma^2 tan(dip) - from
140  pidCand->SetHelixCov(rhohelixcov);
141 
142  pidCand->SetFirstHit(first);
143  pidCand->SetLastHit(last);
144  pidCand->SetDegreesOfFreedom(track->GetNDF());
145  pidCand->SetFitStatus(track->GetFlag());
146  pidCand->SetChiSquared(track->GetChi2());
147 
148  return kTRUE;
149 }
150 
void SetMomentum(TVector3 &mom)
int fVerbose
Definition: poormantracks.C:24
friend F32vec4 cos(const F32vec4 &a)
Definition: P4_F32vec4.h:112
Int_t GetFlag() const
Definition: PndTrack.h:33
void SetPosition(TVector3 &pos)
TClonesArray * pnt
void SetCov7(const TMatrixD &cov7)
Double_t par[3]
void SetHelixCov(Double_t *cov)
void SetFirstHit(TVector3 &pos)
void SetEnergy(Double_t en)
void SetHelixParams(Double_t *par)
Double_t
PndMCTrack * track
Definition: anaLmdCluster.C:89
Int_t GetNDF() const
Definition: PndTrack.h:35
FairTrackParP GetParamLast()
Definition: PndTrack.h:50
void SetChiSquared(Double_t val)
static TMatrixD GetConverted7(TMatrixD)
FairGeanePro * fGeanePropagator
Refitter for MDT tracks.
void SetCharge(Int_t charge)
void SetFitStatus(Int_t val)
Double_t GetChi2() const
Definition: PndTrack.h:34
ClassImp(PndAnaContFact)
static TMatrixDSym GetFitError(TMatrixDSym)
void SetLastHit(TVector3 &pos)
Bool_t GetTrackInfo(PndTrack *track, PndPidCandidate *pid)
void SetDegreesOfFreedom(Int_t val)
FairTrackParP GetParamFirst()
Definition: PndTrack.h:49
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52
Double_t energy
Definition: plot_dirc.C:15