CbmRoot
CbmPVFinderKF.cxx
Go to the documentation of this file.
1 #include "CbmPVFinderKF.h"
2 
4 #include "CbmKFTrack.h"
5 #include "CbmKFVertex.h"
6 
7 #include "CbmEvent.h"
8 #include "CbmStsTrack.h"
9 
10 #include "TClonesArray.h"
11 
12 #include "math.h"
13 
15 
16  Int_t CbmPVFinderKF::FindPrimaryVertex(TClonesArray* tracks,
17  CbmVertex* vertex) {
18 
19  Int_t NTracks = tracks->GetEntries();
20 
22  CbmKFTrack* CloneArray = new CbmKFTrack[NTracks];
23  for (Int_t i = 0; i < NTracks; i++) {
24  CbmStsTrack* st = (CbmStsTrack*) tracks->At(i);
25  Int_t NHits = st->GetNofHits();
26  if (NHits < 4) continue;
27  if (st->GetFlag()) continue;
28  if (st->GetChiSq() < 0. || st->GetChiSq() > 3.5 * 3.5 * st->GetNDF())
29  continue;
30  CbmKFTrack& T = CloneArray[i];
31  T.SetStsTrack(*st);
32  if (!finite(T.GetTrack()[0]) || !finite(T.GetCovMatrix()[0])) continue;
33  Finder.AddTrack(&T);
34  }
35  CbmKFVertex v;
36  Finder.Fit(v);
37  v.GetVertex(*vertex);
38  delete[] CloneArray;
39  return 0;
40 }
41 
42 
43 // ---- Find vertex for one event ---------------------------------------
44 Int_t CbmPVFinderKF::FindEventVertex(CbmEvent* event, TClonesArray* tracks) {
45 
46  assert(event);
48 
49  // Get vertex object
50  CbmVertex* vertex = event->GetVertex();
51 
52  // Copy input tracks to KF tracks
53  Int_t nTracks = event->GetNofData(ECbmDataType::kStsTrack);
54  CbmKFTrack* trackArray = new CbmKFTrack[nTracks];
55  for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
56  Int_t trackIndex = event->GetIndex(ECbmDataType::kStsTrack, iTrack);
57  CbmStsTrack* track = (CbmStsTrack*) tracks->At(trackIndex);
58  Int_t nHits = track->GetNofHits();
59  if (nHits < 4) continue; // use only tracks with at least 4 hits
60  if (track->GetFlag()) continue; // do not use suspicious tracks
61  if (track->GetChiSq() < 0. // use only good-quality tracks
62  || track->GetChiSq() > 12.25 * track->GetNDF())
63  continue;
64  CbmKFTrack& kTrack = trackArray[iTrack];
65  kTrack.SetStsTrack(*track);
66  if (!finite(kTrack.GetTrack()[0]) || !finite(kTrack.GetCovMatrix()[0]))
67  continue;
68  vFinder.AddTrack(&kTrack);
69  }
70 
71  // Do the vertex finding
72  CbmKFVertex v;
73  vFinder.Fit(v);
74 
75  // Copy KFVertex into CbmVertex
76  v.GetVertex(*vertex);
77 
78  delete[] trackArray;
79  return 0;
80 }
81 // --------------------------------------------------------------------------
CbmTrack::GetChiSq
Double_t GetChiSq() const
Definition: CbmTrack.h:58
CbmKFPrimaryVertexFinder.h
CbmTrack::GetFlag
Int_t GetFlag() const
Definition: CbmTrack.h:57
CbmKFTrack::GetTrack
Double_t * GetTrack()
Is it electron.
Definition: CbmKFTrack.h:58
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmKFPrimaryVertexFinder::AddTrack
void AddTrack(CbmKFTrackInterface *Track)
Definition: CbmKFPrimaryVertexFinder.cxx:23
CbmKFPrimaryVertexFinder::Fit
void Fit(CbmKFVertexInterface &vtx)
Definition: CbmKFPrimaryVertexFinder.cxx:31
CbmStsTrack::GetNofHits
virtual Int_t GetNofHits() const
Definition: CbmStsTrack.h:76
CbmPVFinderKF.h
CbmKFPrimaryVertexFinder
Definition: CbmKFPrimaryVertexFinder.h:18
CbmEvent.h
CbmPVFinderKF
Definition: CbmPVFinderKF.h:15
ECbmDataType::kStsTrack
@ kStsTrack
finite
T finite(T x)
Definition: CbmL1Def.h:21
CbmKFTrack::SetStsTrack
void SetStsTrack(CbmStsTrack &track, bool first=1)
Definition: CbmKFTrack.cxx:38
CbmStsTrack.h
Data class for STS tracks.
CbmPVFinderKF::FindEventVertex
virtual Int_t FindEventVertex(CbmEvent *event, TClonesArray *tracks)
Definition: CbmPVFinderKF.cxx:44
ClassImp
ClassImp(CbmPVFinderKF) Int_t CbmPVFinderKF
Definition: CbmPVFinderKF.cxx:14
tracks
TClonesArray * tracks
Definition: Analyze_matching.h:17
CbmKFTrack::GetCovMatrix
Double_t * GetCovMatrix()
array[6] of track parameters(x,y,tx,ty,qp,z)
Definition: CbmKFTrack.h:59
CbmVertex
Definition: CbmVertex.h:26
CbmTrack::GetNDF
Int_t GetNDF() const
Definition: CbmTrack.h:59
CbmKFTrack.h
CbmPVFinderKF::FindPrimaryVertex
virtual Int_t FindPrimaryVertex(TClonesArray *tracks, CbmVertex *vertex)
v
__m128 v
Definition: L1/vectors/P4_F32vec4.h:1
CbmEvent
Class characterising one event by a collection of links (indices) to data objects,...
Definition: CbmEvent.h:30
CbmStsTrack
Definition: CbmStsTrack.h:37
CbmKFTrack
Definition: CbmKFTrack.h:21
CbmKFVertex.h
CbmKFVertex
Definition: CbmKFVertex.h:6