FairRoot/PandaRoot
PndPidFtofInfo.cxx
Go to the documentation of this file.
1 #include "PndDetectorList.h"
2 #include "PndPidCorrelator.h"
3 #include "PndPidCandidate.h"
4 #include "PndMCTrack.h"
5 #include "PndTrack.h"
6 #include "PndTrackID.h"
7 
8 #include "PndFtofHit.h"
9 #include "PndFtofPoint.h"
10 
11 #include "FairTrackParH.h"
12 #include "FairMCApplication.h"
13 #include "FairRunAna.h"
14 #include "FairRootManager.h"
15 #include "FairRuntimeDb.h"
16 
17 Bool_t PndPidCorrelator::GetFtofInfo(FairTrackParH* helix, PndPidCandidate* pidCand)
18 {
19  if(!helix)
20  {
21  std::cerr << "<Error> PndPidCorrelator::GetFtofInfo: FairTrackParH NULL pointer parameter."<<std::endl;
22  return kFALSE;
23  }
24  if(!pidCand)
25  {
26  std::cerr << "<Error> PndPidCorrelator::GetFtofInfo: pidCand NULL pointer parameter."<<std::endl;
27  return kFALSE;
28  }
29 
30  if(helix->GetZ() < fCorrPar->GetZLastPlane())
31  {
32  if (fVerbose>0) std::cout << "-W- PndPidCorrelator::GetFtofInfo: Skipping tracks not reaching the last FTS layer" << std::endl;
33  return kFALSE;
34  }
35 
36  if(helix->GetPz() <= 0.)
37  {
38  std::cout << "-W- PndPidCorrelator::GetFtofInfo: Skipping tracks going backward" << std::endl;
39  return kFALSE;
40  }
41 
42  PndFtofHit *tofHit = NULL;
43  Int_t tofEntries = fFtofHit->GetEntriesFast();
44  Int_t tofIndex = -1;
45  Float_t tofTof = 0., tofLength = -1000, tofGLength = -1000, tofTrackLength = -1000;;
46  Float_t tofQuality = 1000000;
47 
48  //Float_t chi2 = 0; //[R.K. 01/2017] unused variable
49  TVector3 vertex(0., 0., -10000.);
50  TVector3 vertexrec(0., 0., -10000.);
51  TVector3 momrec(0., 0., -10000.);
52  TVector3 tofPos(0., 0., 0.);
53  TVector3 momentum(0., 0., 0.);
54 
55  if (fGeanePro) // Overwrites vertex if Geane is used
56  {
57  // calculates track length from (0,0,0) to last point
58  fGeanePropagator->SetPoint(TVector3(0,0,0));
59  fGeanePropagator->PropagateToPCA(1, -1);
60  FairTrackParH *fRes= new FairTrackParH();
61  Bool_t rc = fGeanePropagator->Propagate(helix, fRes, fPidHyp*pidCand->GetCharge());
62  if (rc)
63  {
64  tofTrackLength = fGeanePropagator->GetLengthAtPCA();
65  vertexrec.SetXYZ(fRes->GetX(), fRes->GetY(), fRes->GetZ());
66  momrec.SetXYZ(fRes->GetPx(), fRes->GetPy(), fRes->GetPz());
67  }
68  }
69 
70  for (Int_t tt = 0; tt<tofEntries; tt++)
71  {
72  tofHit = (PndFtofHit*)fFtofHit->At(tt);
73  if ( fIdeal && ( ((PndFtofPoint*)fFtofPoint->At(tofHit->GetRefIndex()))->GetTrackID() !=pidCand->GetMcIndex()) ) continue;
74  tofHit->Position(tofPos);
75 
76  Float_t propX = helix->GetX() + (fCorrPar->GetFtofZ() - helix->GetZ()) * helix->GetPx() / helix->GetPz();
77  Float_t propY = helix->GetY() + (fCorrPar->GetFtofZ() - helix->GetZ()) * helix->GetPy() / helix->GetPz();
78  Float_t propZ = fCorrPar->GetFtofZ();
79  vertex.SetXYZ(propX, propY, propZ);
80  tofGLength = (vertex-helix->GetPosition()).Mag();
81 
82  if (fGeanePro) // Overwrites vertex if Geane is used
83  {
84  fGeanePropagator->SetPoint(tofPos);
85  fGeanePropagator->PropagateToPCA(1, 1);
86  FairTrackParH *fRes= new FairTrackParH();
87  Bool_t rc = fGeanePropagator->Propagate(helix, fRes, fPidHyp*pidCand->GetCharge());
88  if (!rc) continue;
89  tofGLength = fGeanePropagator->GetLengthAtPCA();
90  vertex.SetXYZ(fRes->GetX(), fRes->GetY(), fRes->GetZ());
91  }
92 
93  Float_t dist = (tofPos-vertex).Mag2();
94 
95  if ( tofQuality > dist)
96  {
97  tofIndex = tt;
98  tofQuality = dist;
99  tofTof = tofHit->GetTime();
100  tofLength = tofTrackLength+tofGLength;
101  }
102 
103  if (fDebugMode)
104  {
105  Float_t ntuple[] = {static_cast<Float_t>(vertex.X()), static_cast<Float_t>(vertex.Y()), static_cast<Float_t>(vertex.Z()),
106  static_cast<Float_t>(vertexrec.X()), static_cast<Float_t>(vertexrec.Y()), static_cast<Float_t>(vertexrec.Z()),
107  static_cast<Float_t>(momrec.X()), static_cast<Float_t>(momrec.Y()), static_cast<Float_t>(momrec.Z()),
108  static_cast<Float_t>(helix->GetMomentum().Mag()), static_cast<Float_t>(helix->GetQ()), static_cast<Float_t>(helix->GetMomentum().Theta()), static_cast<Float_t>(helix->GetZ()),
109  static_cast<Float_t>(tofPos.X()), static_cast<Float_t>(tofPos.Y()), static_cast<Float_t>(tofPos.Z()),
110  dist, tofLength, tofGLength, tofTrackLength};
111  // Float_t ntuple[] = {vertex.X(), vertex.Y(), vertex.Z(),
112  // vertexrec.X(), vertexrec.Y(), vertexrec.Z(),
113  // momrec.X(), momrec.Y(), momrec.Z(),
114  // helix->GetMomentum().Mag(), helix->GetQ(), helix->GetMomentum().Theta(), helix->GetZ(),
115  // tofPos.X(), tofPos.Y(), tofPos.Z(),
116  // dist, tofLength, tofGLength,tofTrackLength};
117  ftofCorr->Fill(ntuple);
118  }
119  }
120 
121  if ( (tofQuality<fCorrPar->GetFTofCut()) || (fIdeal && tofIndex!=-1) )
122  {
123  pidCand->SetTofQuality(tofQuality);
124  pidCand->SetTofStopTime(tofTof);
125  pidCand->SetTofTrackLength(tofLength);
126  pidCand->SetTofIndex(tofIndex);
127  if (tofLength>0.)
128  {
129  // mass^2 = p^2 * ( 1/beta^2 - 1 )
130  Float_t mass2 = helix->GetMomentum().Mag()*helix->GetMomentum().Mag()*(30.*30.*tofTof*tofTof/tofLength/tofLength-1.);
131  pidCand->SetTofM2(mass2);
132  }
133  }
134 
135  return kTRUE;
136 }
Double_t GetTime()
Definition: PndFtofHit.h:60
int fVerbose
Definition: poormantracks.C:24
Int_t GetCharge() const
void SetTofStopTime(Double_t val)
PndPidCorrPar * fCorrPar
PndRichHit TCA.
void SetTofM2(Double_t val)
Float_t GetFtofZ()
Definition: PndPidCorrPar.h:23
void SetTofTrackLength(Double_t val)
Int_t GetMcIndex() const
Bool_t GetFtofInfo(FairTrackParH *helix, PndPidCandidate *pid)
FairGeanePro * fGeanePropagator
Refitter for MDT tracks.
TClonesArray * fFtofPoint
PndFtofHit TCA.
void SetTofQuality(Double_t val)
void SetTofIndex(Int_t val)
TClonesArray * fFtofHit
PndTofPoint TCA.
Float_t GetZLastPlane()
Definition: PndPidCorrPar.h:22