Belle II Software
release-08-01-10
read.cc
1
#include <Track.h>
2
#include <GFRaveVertex.h>
3
4
#include <TDatabasePDG.h>
5
#include <TEveManager.h>
6
#include <TGeoManager.h>
7
#include <TRandom.h>
8
#include <TVector3.h>
9
#include <vector>
10
11
#include <TROOT.h>
12
#include <TClonesArray.h>
13
#include <TFile.h>
14
#include <TTree.h>
15
16
#include <iostream>
17
18
19
int
main
() {
20
21
genfit::Track
tr;
// pull in genfit libraries
22
23
//genfit::Track* aTrackPtr(nullptr);
24
genfit::GFRaveVertex
* aVertexPtr(
nullptr
);
25
26
TFile* trackFile = TFile::Open(
"tracks.root"
,
"READ"
);
27
if
(!trackFile) {
28
std::cerr <<
"Couldn't open 'tracks.root'."
<< std::endl;
29
return
-1;
30
}
31
TTree* tree = (TTree*)trackFile->Get(
"tree"
);
32
if
(!tree) {
33
std::cerr <<
"Couldn't find tree 'tree' in file 'tracks.root'."
<< std::endl;
34
return
-1;
35
}
36
TClonesArray* trackArray =
new
TClonesArray(
"genfit::Track"
);
37
tree->SetBranchAddress(
"trackBranch"
, &trackArray);
38
39
tree->Print();
40
41
TClonesArray* vertexArray =
new
TClonesArray(
"genfit::GFRaveVertex"
);
42
tree->SetBranchAddress(
"vertexBranch"
, &vertexArray);
43
44
45
for
(Long_t i = 0; i < tree->GetEntries(); ++i) {
46
tree->GetEntry(i);
47
48
std::cout <<
"trackArray nr of entries: "
<< trackArray->GetEntries() <<
"\n"
;
49
50
for
(Long_t j = 0; j < trackArray->GetEntriesFast(); ++j) {
51
std::cout <<
"track uniqueID: "
<<
static_cast<
genfit::Track
*
>
(trackArray->At(j))->GetUniqueID() <<
52
" ("
<<
static_cast<
genfit::Track
*
>
(trackArray->At(j))->GetUniqueID() - 16777216 <<
")\n"
;
53
}
54
55
for
(Long_t j = 0; j < vertexArray->GetEntriesFast(); ++j) {
56
57
aVertexPtr = (
genfit::GFRaveVertex
*)(vertexArray->At(j));
58
//aVertexPtr->Print();
59
60
for
(
unsigned
int
k=0; k<aVertexPtr->getNTracks(); ++k) {
61
std::cout <<
"track parameters uniqueID: "
<< aVertexPtr->getParameters(k)->GetUniqueID() <<
"\n"
;
62
}
63
64
// when the track branch from the tracks.root file is loaded, the TRefs to the tracks
65
// in the GFRaveTrackParameters are again pointing to them.
66
for
(
unsigned
int
k = 0; k<aVertexPtr->getNTracks(); ++k) {
67
if
(aVertexPtr->getParameters(k)->hasTrack()) {
68
std::cout <<
"track parameters have track \n"
;
69
}
70
else
{
71
std::cout <<
"track parameters have NO track <--------------------------------- \n"
;
72
}
73
}
74
75
}
76
77
}
78
79
80
}
81
82
genfit::GFRaveVertex
GFRaveVertex class.
Definition:
GFRaveVertex.h:48
genfit::Track
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
Definition:
Track.h:71
main
int main(int argc, char **argv)
Run all tests.
Definition:
test_main.cc:91
genfit2
code2
test
vertexingTest
read.cc
Generated on Mon Sep 23 2024 14:02:56 for Belle II Software by
1.9.1