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