CbmRoot
CbmTrdTrackFitterIdeal.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- CbmTrdTrackFitterIdeal source file -----
3 // ----- Created 12/05/06 by D. Kresan -----
4 // -------------------------------------------------------------------------
6 
7 #include "CbmTrdHit.h"
8 #include "CbmTrdPoint.h"
9 #include "CbmTrdTrack.h"
10 
11 #include "FairRootManager.h"
12 
13 #include "TClonesArray.h"
14 #include "TVector3.h"
15 
16 #include <iostream>
17 using std::cerr;
18 using std::cout;
19 using std::endl;
20 
21 
22 //__________________________________________________________________________
23 //
24 // CbmTrdTrackFitterIdeal
25 //
26 // Concrete implementation of TRD track fitting algorithm, based on MC
27 //
28 
29 
30 // -------------------------------------------------------------------------
32  : CbmTrdTrackFitter(), fArrayTrdPoint(NULL), fArrayTrdHit(NULL) {}
33 // -------------------------------------------------------------------------
34 
35 
36 // -------------------------------------------------------------------------
38 // -------------------------------------------------------------------------
39 
40 
41 // -------------------------------------------------------------------------
43  // Task initialisation
44  FairRootManager* rootMgr = FairRootManager::Instance();
45  if (NULL == rootMgr) {
46  cerr << "-E- CbmTrdTrackFitterIdeal::Init : "
47  << "ROOT manager is not instantiated!" << endl;
48  return;
49  }
50 
51  fArrayTrdPoint = (TClonesArray*) rootMgr->GetObject("TrdPoint");
52  if (NULL == fArrayTrdPoint) {
53  cout << "-W- CbmTrdTrackFitterIdeal::Init : "
54  << "no TRD point array!" << endl;
55  }
56 
57  fArrayTrdHit = (TClonesArray*) rootMgr->GetObject("TrdHit");
58  if (NULL == fArrayTrdHit) {
59  cout << "-W- CbmTrdTrackFitterIdeal::Init : "
60  << "no TRD hit array!" << endl;
61  }
62 }
63 // -------------------------------------------------------------------------
64 
65 
66 // -------------------------------------------------------------------------
68  // Implementation of the fitting algorithm
69  if (NULL == fArrayTrdPoint || NULL == fArrayTrdHit) return 0;
70 
71  // Parameters at the first plane
72  Int_t hitIndex = pTrack->GetHitIndex(0);
73  if (hitIndex < 0) return 0;
74  CbmTrdHit* hit = (CbmTrdHit*) fArrayTrdHit->At(hitIndex);
75  if (NULL == hit) return 0;
76  Int_t pointIndex = hit->GetRefId();
77  if (pointIndex < 0) return 0;
78  CbmTrdPoint* point = (CbmTrdPoint*) fArrayTrdPoint->At(pointIndex);
79  if (NULL == point) return 0;
80  FairTrackParam par1;
81  SetTrackParam(point, &par1);
82  pTrack->SetParamFirst(&par1);
83 
84  // Parameters at the last plane
85  hitIndex = pTrack->GetHitIndex(pTrack->GetNofHits() - 1);
86  if (hitIndex < 0) return 0;
87  hit = (CbmTrdHit*) fArrayTrdHit->At(hitIndex);
88  if (NULL == hit) return 0;
89  pointIndex = hit->GetRefId();
90  if (pointIndex < 0) return 0;
91  point = (CbmTrdPoint*) fArrayTrdPoint->At(pointIndex);
92  if (NULL == point) return 0;
93  FairTrackParam par2;
94  SetTrackParam(point, &par2);
95  pTrack->SetParamLast(&par2);
96 
97  return 1;
98 }
99 // -------------------------------------------------------------------------
100 
101 
102 // -------------------------------------------------------------------------
104  FairTrackParam* trackParam) {
105  // Set track parameters from the MC point
106  TVector3 pos;
107  TVector3 mom;
108  point->Position(pos);
109  point->Momentum(mom);
110  trackParam->SetX(pos.X());
111  trackParam->SetY(pos.Y());
112  trackParam->SetZ(pos.Z());
113  trackParam->SetTx(mom.X() / mom.Z());
114  trackParam->SetTy(mom.Y() / mom.Z());
115 }
116 // -------------------------------------------------------------------------
117 
118 
CbmTrack::GetNofHits
virtual Int_t GetNofHits() const
Definition: CbmTrack.h:53
rootMgr
static FairRootManager * rootMgr
Definition: CbmDeviceHitBuilderTof.cxx:72
CbmTrdTrackFitterIdeal
Definition: CbmTrdTrackFitterIdeal.h:16
CbmTrdHit
data class for a reconstructed Energy-4D measurement in the TRD
Definition: CbmTrdHit.h:35
CbmTrdTrackFitterIdeal.h
CbmTrdTrackFitterIdeal::fArrayTrdHit
TClonesArray * fArrayTrdHit
Definition: CbmTrdTrackFitterIdeal.h:20
CbmHit::GetRefId
Int_t GetRefId() const
Definition: CbmHit.h:72
CbmTrack::SetParamLast
void SetParamLast(const FairTrackParam *par)
Definition: CbmTrack.h:76
CbmTrdTrackFitter
Definition: CbmTrdTrackFitter.h:25
CbmTrdTrackFitterIdeal::DoFit
Int_t DoFit(CbmTrdTrack *pTrack)
Definition: CbmTrdTrackFitterIdeal.cxx:67
CbmTrdTrackFitterIdeal::fArrayTrdPoint
TClonesArray * fArrayTrdPoint
Definition: CbmTrdTrackFitterIdeal.h:19
CbmTrack::GetHitIndex
Int_t GetHitIndex(Int_t iHit) const
Definition: CbmTrack.h:54
CbmTrdTrackFitterIdeal::CbmTrdTrackFitterIdeal
CbmTrdTrackFitterIdeal()
Definition: CbmTrdTrackFitterIdeal.cxx:31
CbmTrdHit.h
Class for hits in TRD detector.
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmTrdTrackFitterIdeal::Init
void Init()
Definition: CbmTrdTrackFitterIdeal.cxx:42
CbmTrdPoint
Definition: CbmTrdPoint.h:23
CbmTrdTrack
Definition: CbmTrdTrack.h:22
CbmTrdPoint.h
CbmTrack::SetParamFirst
void SetParamFirst(const FairTrackParam *par)
Definition: CbmTrack.h:75
pos
TVector3 pos
Definition: CbmMvdSensorDigiToHitTask.cxx:60
CbmTrdTrackFitterIdeal::SetTrackParam
void SetTrackParam(CbmTrdPoint *point, FairTrackParam *trackParam)
Definition: CbmTrdTrackFitterIdeal.cxx:103
CbmTrdTrack.h
CbmTrdTrackFitterIdeal::~CbmTrdTrackFitterIdeal
virtual ~CbmTrdTrackFitterIdeal()
Definition: CbmTrdTrackFitterIdeal.cxx:37