BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
CbmStsTrackFitterIdeal.cxx
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- CbmStsTrackFitterIdeal source file -----
3// ----- Created 12/05/06 by D. Kresan -----
4// -------------------------------------------------------------------------
5
7
8#include "CbmMCTrack.h"
9#include "CbmStsHit.h"
10#include "CbmStsPoint.h"
11#include "CbmStsTrack.h"
12#include "FairRootManager.h"
13#include "TClonesArray.h"
14#include "TParticlePDG.h"
15#include "TVector3.h"
16
17#include <iostream>
18
19using std::cerr;
20using std::cout;
21using std::endl;
22
23// ---------------------------- Constructor --------------------------------
30// -------------------------------------------------------------------------
31
32// ---------------------------- Destructor ---------------------------------
34// -------------------------------------------------------------------------
35
36// -------------------------- Initialisation -------------------------------
38{
40 if (NULL == dbPDG) {
41 cout << "-W- CbmStsTrackFitterIdeal::Init : "
42 << "Database PDG is not instantiated!" << endl;
43 }
44
45 FairRootManager* rootMgr = FairRootManager::Instance();
46 if (NULL == rootMgr) {
47 cerr << "-E- CbmStsTrackFitterIdeal::Init : "
48 << "ROOT manager is not instantiated!" << endl;
49 return;
50 }
51
52 fArrayMCTrack = (TClonesArray*)rootMgr->GetObject("MCTrack");
53 if (NULL == fArrayMCTrack) {
54 cout << "-W- CbmStsTrackFitterIdeal::Init : "
55 << "no MC track array!" << endl;
56 }
57
58 fArrayStsPoint = (TClonesArray*)rootMgr->GetObject("StsPoint");
59 if (NULL == fArrayStsPoint) {
60 cout << "-W- CbmStsTrackFitterIdeal::Init : "
61 << "no STS point array!" << endl;
62 }
63
64 fArrayStsHit = (TClonesArray*)rootMgr->GetObject("StsHit");
65 if (NULL == fArrayStsHit) {
66 cout << "-W- CbmStsTrackFitterIdeal::Init : "
67 << "no STS hit array!" << endl;
68 }
69}
70// -------------------------------------------------------------------------
71
72// ------------------------ Fitting algorithm ------------------------------
74{
75 if (NULL == fArrayStsPoint || NULL == fArrayStsHit)
76 return 0;
77
78 // Parameters at the first plane
79 Int_t hitIndex = -1;
80 CbmStsHit* hit;
81 Int_t pointIndex;
82 if (pTrack->GetNStsHits() > 0) {
83 hitIndex = pTrack->GetStsHitIndex(0);
84 if (hitIndex < 0)
85 return 0;
86 hit = (CbmStsHit*)fArrayStsHit->At(hitIndex);
87 if (NULL == hit)
88 return 0;
89 pointIndex = hit->GetRefIndex();
90 }
91 if (pointIndex < 0)
92 return 0;
93 CbmStsPoint* point = (CbmStsPoint*)fArrayStsPoint->At(pointIndex);
94 if (NULL == point)
95 return 0;
96 SetTrackParam(point, pTrack->GetParamFirst());
97
98 // Parameters at the last plane
99 if (pTrack->GetNStsHits() > 0) {
100 hitIndex = pTrack->GetStsHitIndex(pTrack->GetNStsHits() - 1);
101 if (hitIndex < 0)
102 return 0;
103 hit = (CbmStsHit*)fArrayStsHit->At(hitIndex);
104 if (NULL == hit)
105 return 0;
106 pointIndex = hit->GetRefIndex();
107 }
108 if (pointIndex < 0)
109 return 0;
110 point = (CbmStsPoint*)fArrayStsPoint->At(pointIndex);
111 if (NULL == point)
112 return 0;
113 SetTrackParam(point, pTrack->GetParamLast(), 1);
114
115 return 1;
116}
117// -------------------------------------------------------------------------
118
119// -------------------------- Set track parameters -------------------------
120void CbmStsTrackFitterIdeal::SetTrackParam(CbmStsPoint* point, FairTrackParam* trackParam, Int_t out)
121{
122 TVector3 pos;
123 TVector3 mom;
124 if (0 == out) {
125 point->Position(pos);
126 point->Momentum(mom);
127 } else {
128 point->PositionOut(pos);
129 point->MomentumOut(mom);
130 }
131 trackParam->SetX(pos.X());
132 trackParam->SetY(pos.Y());
133 trackParam->SetZ(pos.Z());
134 trackParam->SetTx(mom.X() / mom.Z());
135 trackParam->SetTy(mom.Y() / mom.Z());
136 Int_t mcTrackIndex = point->GetTrackID();
137 if (mcTrackIndex < 0)
138 return;
139 CbmMCTrack* mcTrack = (CbmMCTrack*)fArrayMCTrack->At(mcTrackIndex);
140 if (NULL == mcTrack)
141 return;
142 Int_t pdgCode = mcTrack->GetPdgCode();
143 TParticlePDG* particle = dbPDG->GetParticle(pdgCode);
144 if (NULL == particle)
145 return;
146 trackParam->SetQp(particle->Charge() / mom.Mag());
147}
148// -------------------------------------------------------------------------
int Int_t
CbmMCTrack.h.
Definition CbmMCTrack.h:26
Int_t GetPdgCode() const
Accessors.
Definition CbmMCTrack.h:56
void PositionOut(TVector3 &pos)
Definition CbmStsPoint.h:74
void MomentumOut(TVector3 &mom)
Definition CbmStsPoint.h:75
void SetTrackParam(CbmStsPoint *point, FairTrackParam *trackParam, Int_t out=0)
Set tracks parameters from the MC point.
Int_t DoFit(CbmStsTrack *pTrack, Int_t pidHypo=211)
Fitting algorithm.
virtual ~CbmStsTrackFitterIdeal()
Destructor.
TClonesArray * fArrayMCTrack
Data branches.
CbmStsTrackFitterIdeal()
Default constructor.
FairTrackParam * GetParamLast()
Definition CbmStsTrack.h:70
Int_t GetNStsHits() const
Accessors.
Definition CbmStsTrack.h:60
Int_t GetStsHitIndex(Int_t iHit) const
Definition CbmStsTrack.h:62
FairTrackParam * GetParamFirst()
Definition CbmStsTrack.h:69
static TDatabasePDG * Instance()
friend friend class TClonesArray
Double_t Charge() const
Double_t Z() const
Double_t Y() const
Double_t X() const
Double_t Mag() const