FairRoot/PandaRoot
PndPidRichInfo.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 "PndRichBarPoint.h"
9 #include "PndRichHit.h"
10 
11 #include "FairTrackParH.h"
12 #include "FairMCApplication.h"
13 #include "FairRunAna.h"
14 #include "FairRootManager.h"
15 #include "FairRuntimeDb.h"
16 
17 #include "TRandom.h"
18 
19 #include <iomanip>
20 
21 Bool_t PndPidCorrelator::GetRichInfo(FairTrackParH* helix, PndPidCandidate* pidCand)
22 {
23  if(!helix)
24  {
25  std::cerr << "<Error> PndPidCorrelator::GetRichInfo: FairTrackParH NULL pointer parameter."<<std::endl;
26  return kFALSE;
27  }
28  if(!pidCand)
29  {
30  std::cerr << "<Error> PndPidCorrelator::GetRichInfo: pidCand NULL pointer parameter."<<std::endl;
31  return kFALSE;
32  }
33 
34  if(helix->GetZ() < fCorrPar->GetZLastPlane())
35  {
36  if (fVerbose>0) std::cout << "-W- PndPidCorrelator::GetRichInfo: Skipping tracks not reaching the last FTS layer" << std::endl;
37  return kFALSE;
38  }
39 
40  if(helix->GetPz() <= 0.)
41  {
42  std::cout << "-W- PndPidCorrelator::GetRichInfo: Skipping tracks going backward" << std::endl;
43  return kFALSE;
44  }
45 
46  Int_t richIndex = -1, richPhot = 0;
47  Float_t richThetaC = -1000, richThetaCErr = 0, richGLength = -1000;
48  Float_t richQuality = 1000000;
49 
50  TVector3 vertex(0., 0., -10000.);
51  TVector3 momentum(0., 0., 0.);
52 
53  if (fGeanePro) // Overwrites vertex if Geane is used
54  {
55  // calculates track length from (0,0,0) to last point
56  fGeanePropagator->PropagateToVolume("RichAerogelSensor",0,1);
57  fGeanePropagator->SetPoint(TVector3(0,0,0));
58  FairTrackParH *fRes= new FairTrackParH();
59  Bool_t rc = fGeanePropagator->Propagate(helix, fRes, fPidHyp*pidCand->GetCharge());
60  if (!rc) return kFALSE;
61  //richGLength = fGeanePropagator->GetLengthAtPCA();
62  vertex.SetXYZ(fRes->GetX(), fRes->GetY(), fRes->GetZ());
63  momentum.SetXYZ(fRes->GetPx(), fRes->GetPy(), fRes->GetPz());
64  }
65 
66  PndRichHit *richHit = NULL;
67  Int_t richEntries = fRichHit->GetEntriesFast();
68  TVector3 richPos(0., 0., 0.);
69 
70  for (Int_t dd = 0; dd<richEntries; dd++)
71  {
72  richHit = (PndRichHit*)fRichHit->At(dd);
73  if ( fIdeal && ( ((PndRichBarPoint*)fRichPoint->At(richHit->GetRefIndex()))->GetTrackID() != pidCand->GetMcIndex()) ) continue;
74 
75  richHit->Position(richPos);
76 
77  Float_t dX = vertex.X()-richPos.X();
78  Float_t dY = vertex.Y()-richPos.Y();
79  Float_t dist = dX*dX + dY*dY;
80  if (richQuality > dist)
81  {
82  richIndex = dd;
83  richQuality = dist;
84  // inside richThetaC is value of beta
85  richThetaC = richHit->GetThetaC();
86  richThetaCErr = richHit->GetErrThetaC();
87  richPhot = 0;
88  }
89  if (fDebugMode)
90  {
91  Float_t ntuple[] = {static_cast<Float_t>(vertex.X()), static_cast<Float_t>(vertex.Y()), static_cast<Float_t>(vertex.Z()), static_cast<Float_t>(vertex.Phi()),
92  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()),
93  static_cast<Float_t>(richPos.X()), static_cast<Float_t>(richPos.Y()), static_cast<Float_t>(richPos.Phi()),
94  dist, static_cast<Float_t>(richHit->GetThetaC()), 0., static_cast<Float_t>(vertex.DeltaPhi(richPos)), richGLength,
95  static_cast<Float_t>(pidCand->GetFitStatus())
96  };
97  richCorr->Fill(ntuple);
98  }
99  }
100  richQuality = std::sqrt(richQuality);
101 
102  if (richIndex!=-1)
103  {
104  pidCand->SetRichQuality(richQuality);
105  pidCand->SetRichThetaC(richThetaC);
106  pidCand->SetRichThetaCErr(richThetaCErr);
107  pidCand->SetRichNumberOfPhotons(richPhot);
108  pidCand->SetRichIndex(richIndex);
109  }
110 
111  return kTRUE;
112 }
void SetRichQuality(Double_t val)
virtual Int_t GetRefIndex()
Definition: PndRichHit.h:44
int fVerbose
Definition: poormantracks.C:24
Int_t GetCharge() const
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
PndPidCorrPar * fCorrPar
PndRichHit TCA.
virtual Double_t GetErrThetaC()
Definition: PndRichHit.h:43
virtual Double_t GetThetaC()
Definition: PndRichHit.h:42
TClonesArray * fRichHit
PndRichBarPoint TCA.
Int_t GetMcIndex() const
void SetRichIndex(Int_t val)
Bool_t GetRichInfo(FairTrackParH *helix, PndPidCandidate *pid)
void SetRichNumberOfPhotons(Int_t val)
FairGeanePro * fGeanePropagator
Refitter for MDT tracks.
void SetRichThetaC(Double_t val)
TClonesArray * fRichPoint
PndFtsHit TCA.
Int_t GetFitStatus() const
void SetRichThetaCErr(Double_t val)
Float_t GetZLastPlane()
Definition: PndPidCorrPar.h:22