CbmRoot
CbmPVFinderIdeal.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- CbmPVFinderIdeal source file -----
3 // ----- Created 28/11/05 by V. Friese -----
4 // -------------------------------------------------------------------------
5 #include "CbmPVFinderIdeal.h"
6 
7 #include "CbmVertex.h"
8 
9 #include "CbmMCTrack.h"
10 #include "FairLogger.h"
11 #include "FairRootManager.h"
12 
13 #include "TClonesArray.h"
14 #include "TMatrixTSym.h"
15 
16 #include <iostream>
17 
18 using std::cout;
19 using std::endl;
20 
21 
22 // ----- Default constructor -------------------------------------------
24  : CbmPrimaryVertexFinder(), fMCTracks(NULL) {}
25 // -------------------------------------------------------------------------
26 
27 
28 // ----- Destructor ----------------------------------------------------
30 // -------------------------------------------------------------------------
31 
32 
33 // ----- Public method Init --------------------------------------------
35 
36  // Get and check FairRootManager
37  FairRootManager* ioman = FairRootManager::Instance();
38  if (!ioman) {
39  cout << "-E- CbmPVFinderIdeal::Init: "
40  << "RootManager not instantised!" << endl;
41  return;
42  }
43 
44  // Get MCTrack array
45  fMCTracks = (TClonesArray*) ioman->GetObject("MCTrack");
46  if (!fMCTracks) {
47  cout << "-E- CbmPVFinderIdeal::Init: No MCTrack array!" << endl;
48  return;
49  }
50 }
51 // -------------------------------------------------------------------------
52 
53 
54 // ----- Public method FindPrimaryVertex -------------------------------
55 Int_t CbmPVFinderIdeal::FindPrimaryVertex(TClonesArray*, CbmVertex* vertex) {
56 
57  if (!fMCTracks) return 1;
58 
59  CbmMCTrack* mcTrack = NULL;
60  CbmMCTrack* refTrack = NULL;
61  Int_t nPrim = 0;
62  Int_t nTracks = fMCTracks->GetEntriesFast();
63 
64  for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
65  mcTrack = (CbmMCTrack*) fMCTracks->At(iTrack);
66  if (!mcTrack) continue;
67  if (mcTrack->GetMotherId() != -1) continue; // secondary
68  nPrim++;
69  refTrack = mcTrack;
70  }
71 
72  Double_t x = 0.;
73  Double_t y = 0.;
74  Double_t z = 0;
75  Double_t chi2 = 0.;
76  Int_t ndf = 0;
77  TMatrixFSym covMat(3);
78  if (refTrack) {
79  x = refTrack->GetStartX();
80  y = refTrack->GetStartY();
81  z = refTrack->GetStartZ();
82  } else
83  cout << "-W- CbmPVFinderIdeal::FindPrimaryVertex: "
84  << "No primary MCTracks found!" << endl;
85 
86 
87  vertex->SetVertex(x, y, z, chi2, ndf, nPrim, covMat);
88 
89  return 0;
90 }
91 // -------------------------------------------------------------------------
92 
93 
94 // ---- Find event vertex ----------------------------------------------
96  TClonesArray* /*tracks*/) {
97  LOG(fatal) << GetName()
98  << ": handling of event objects is not implemented yet.";
99  return 1;
100 }
101 // -------------------------------------------------------------------------
102 
103 
CbmVertex::SetVertex
void SetVertex(Double_t x, Double_t y, Double_t z, Double_t chi2, Int_t ndf, Int_t nTracks, const TMatrixFSym &covMat)
Definition: CbmVertex.cxx:129
CbmMCTrack::GetMotherId
Int_t GetMotherId() const
Definition: CbmMCTrack.h:71
CbmMCTrack::GetStartX
Double_t GetStartX() const
Definition: CbmMCTrack.h:75
CbmVertex.h
CbmPVFinderIdeal::Init
virtual void Init()
Definition: CbmPVFinderIdeal.cxx:34
CbmMCTrack::GetStartZ
Double_t GetStartZ() const
Definition: CbmMCTrack.h:77
CbmPrimaryVertexFinder
Definition: CbmPrimaryVertexFinder.h:29
CbmVertex
Definition: CbmVertex.h:26
CbmPVFinderIdeal
Definition: CbmPVFinderIdeal.h:26
CbmPVFinderIdeal.h
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmPVFinderIdeal::FindEventVertex
virtual Int_t FindEventVertex(CbmEvent *event, TClonesArray *tracks)
Definition: CbmPVFinderIdeal.cxx:95
CbmPVFinderIdeal::~CbmPVFinderIdeal
virtual ~CbmPVFinderIdeal()
Definition: CbmPVFinderIdeal.cxx:29
CbmMCTrack::GetStartY
Double_t GetStartY() const
Definition: CbmMCTrack.h:76
CbmMCTrack.h
CbmMCTrack
Definition: CbmMCTrack.h:34
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmEvent
Class characterising one event by a collection of links (indices) to data objects,...
Definition: CbmEvent.h:30
CbmPVFinderIdeal::fMCTracks
TClonesArray * fMCTracks
Definition: CbmPVFinderIdeal.h:53
CbmPVFinderIdeal::FindPrimaryVertex
virtual Int_t FindPrimaryVertex(TClonesArray *tracks, CbmVertex *vertex)
Definition: CbmPVFinderIdeal.cxx:55
CbmPVFinderIdeal::CbmPVFinderIdeal
CbmPVFinderIdeal()
Definition: CbmPVFinderIdeal.cxx:23