CbmRoot
CbmLitTrackFitterImp.cxx
Go to the documentation of this file.
1 
7 
8 #include "data/CbmLitFitNode.h"
9 #include "data/CbmLitHit.h"
10 #include "data/CbmLitStripHit.h"
11 #include "data/CbmLitTrack.h"
12 #include "data/CbmLitTrackParam.h"
15 #include "utils/CbmLitMath.h"
16 
17 #include <iostream>
18 
20  TrackUpdatePtr update) {
21  fPropagator = propagator;
22  fUpdate = update;
23 }
24 
26 
27 LitStatus CbmLitTrackFitterImp::Fit(CbmLitTrack* track, Bool_t downstream) {
28  track->SortHits(downstream);
29  track->SetChi2(0.0);
30  Int_t nofHits = track->GetNofHits();
31  FitNodeVector nodes(nofHits);
32  CbmLitTrackParam par;
33  std::vector<litfloat> F(36);
34 
35  if (downstream) {
36  track->SetParamLast(track->GetParamFirst());
37  par = *track->GetParamLast();
38  } else {
39  track->SetParamFirst(track->GetParamLast());
40  par = *track->GetParamFirst();
41  }
42 
43  litfloat totalLength = 0.;
44 
45  for (Int_t iHit = 0; iHit < nofHits; iHit++) {
46  const CbmLitHit* hit = track->GetHit(iHit);
47  litfloat Ze = hit->GetZ();
48  litfloat length = 0;
49  if (fPropagator->Propagate(&par, Ze, track->GetPDG(), &F, &length)
50  == kLITERROR) {
51  track->SetQuality(kLITBAD);
52  //std::cout << "PROP ERROR: Ze=" << Ze << " length=" << length << " par=" << par.ToString();
53  return kLITERROR;
54  }
55  totalLength += length;
56  nodes[iHit].SetPredictedParam(&par);
57  nodes[iHit].SetF(F);
58  litfloat chi2Hit = 0.;
59  if (fUpdate->Update(&par, hit, chi2Hit) == kLITERROR) {
60  track->SetQuality(kLITBAD);
61  //std::cout << "UPD ERROR: Ze=" << Ze << " length=" << length << " par=" << par.ToString();
62  return kLITERROR;
63  }
64  nodes[iHit].SetUpdatedParam(&par);
65  nodes[iHit].SetChiSqFiltered(chi2Hit);
66  track->SetChi2(track->GetChi2() + chi2Hit);
67  if (iHit == 0) {
68  if (downstream) {
69  track->SetParamFirst(&par);
70  } else {
71  track->SetParamLast(&par);
72  }
73  }
74  }
75  if (downstream) {
76  track->SetParamLast(&par);
77  } else {
78  track->SetParamFirst(&par);
79  }
80 
81  track->SetFitNodes(nodes);
82  track->SetNDF(lit::NDF(track));
83  track->SetLength(totalLength);
84 
85  return kLITSUCCESS;
86 }
CbmLitTrackParam.h
Data class for track parameters.
litfloat
double litfloat
Definition: CbmLitFloat.h:15
CbmLitStripHit.h
Base data class for strip hits.
CbmLitTrackFitterImp::fUpdate
TrackUpdatePtr fUpdate
Definition: CbmLitTrackFitterImp.h:41
TrackPropagatorPtr
boost::shared_ptr< CbmLitTrackPropagator > TrackPropagatorPtr
Definition: CbmTofPtrTypes.h:23
CbmLitHit::GetZ
litfloat GetZ() const
Definition: CbmLitHit.h:48
CbmLitTrackParam
Data class for track parameters.
Definition: CbmLitTrackParam.h:29
CbmLitTrackFitterImp::fPropagator
TrackPropagatorPtr fPropagator
Definition: CbmLitTrackFitterImp.h:40
CbmLitTrack::GetChi2
litfloat GetChi2() const
Definition: CbmLitTrack.h:58
TrackUpdatePtr
boost::shared_ptr< CbmLitTrackUpdate > TrackUpdatePtr
Definition: CbmTofPtrTypes.h:26
CbmLitTrack::SetParamFirst
void SetParamFirst(const CbmLitTrackParam *par)
Definition: CbmLitTrack.h:81
CbmLitFitNode.h
Data class for storage of fitted track parameters, transport matrix and chi-square on each detector s...
CbmLitTrackUpdate.h
Interface for track update algorithm.
CbmLitTrack::SetParamLast
void SetParamLast(const CbmLitTrackParam *par)
Definition: CbmLitTrack.h:82
kLITSUCCESS
@ kLITSUCCESS
Definition: CbmLitEnums.h:24
CbmLitTrack::GetPDG
Int_t GetPDG() const
Definition: CbmLitTrack.h:61
CbmLitTrack::SetNDF
void SetNDF(Int_t ndf)
Definition: CbmLitTrack.h:78
lit::NDF
Int_t NDF(const CbmLitTrack *track)
Definition: CbmLitMath.cxx:79
CbmLitTrackFitterImp::Fit
virtual LitStatus Fit(CbmLitTrack *track, bool downstream=true)
Inherited from CbmLitTrackFitter.
Definition: CbmLitTrackFitterImp.cxx:27
CbmLitTrack::SetLength
void SetLength(litfloat length)
Definition: CbmLitTrack.h:91
CbmLitHit
Base data class for hits.
Definition: CbmLitHit.h:26
CbmLitMath.h
CbmLitTrackPropagator.h
kLITERROR
@ kLITERROR
Definition: CbmLitEnums.h:25
CbmLitTrack
Base data class for track.
Definition: CbmLitTrack.h:30
kLITBAD
@ kLITBAD
Definition: CbmLitEnums.h:33
FitNodeVector
vector< CbmLitFitNode > FitNodeVector
Definition: CbmLitTypes.h:34
CbmLitTrackFitterImp::~CbmLitTrackFitterImp
virtual ~CbmLitTrackFitterImp()
Destructor.
Definition: CbmLitTrackFitterImp.cxx:25
CbmLitTrack::GetParamLast
const CbmLitTrackParam * GetParamLast() const
Definition: CbmLitTrack.h:63
CbmLitTrackFitterImp::CbmLitTrackFitterImp
CbmLitTrackFitterImp(TrackPropagatorPtr propagator, TrackUpdatePtr update)
Constructor.
Definition: CbmLitTrackFitterImp.cxx:19
CbmLitTrack::SetFitNodes
void SetFitNodes(const vector< CbmLitFitNode > &nodes)
Definition: CbmLitTrack.h:86
CbmLitTrack::SetQuality
void SetQuality(LitTrackQa quality)
Definition: CbmLitTrack.h:76
CbmLitTrack::GetParamFirst
const CbmLitTrackParam * GetParamFirst() const
Definition: CbmLitTrack.h:62
CbmLitTrack::SortHits
void SortHits(Bool_t downstream=true)
Sort hits by Z position.
Definition: CbmLitTrack.h:115
CbmLitTrack.h
Base data class for track.
CbmLitTrackFitterImp.h
Implementation of Kalman Filter track fit.
LitStatus
LitStatus
Definition: CbmLitEnums.h:23
CbmLitTrack::GetHit
const CbmLitHit * GetHit(Int_t index) const
Definition: CbmLitTrack.h:65
CbmLitHit.h
Base data class for hits.
CbmLitTrack::SetChi2
void SetChi2(litfloat chi2)
Definition: CbmLitTrack.h:77
CbmLitTrack::GetNofHits
Int_t GetNofHits() const
Definition: CbmLitTrack.h:56