SND@LHC Software
Loading...
Searching...
No Matches
read.cc File Reference
#include <Track.h>
#include <GFRaveVertex.h>
#include <TDatabasePDG.h>
#include <TEveManager.h>
#include <TGeoManager.h>
#include <TRandom.h>
#include <TVector3.h>
#include <vector>
#include <TROOT.h>
#include <TClonesArray.h>
#include <TFile.h>
#include <TTree.h>
#include <iostream>
Include dependency graph for read.cc:

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 19 of file read.cc.

19 {
20
21 genfit::Track tr; // pull in genfit libraries
22
23 //genfit::Track* aTrackPtr(NULL);
24 genfit::GFRaveVertex* aVertexPtr(NULL);
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}
GFRaveVertex class.
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
Definition Track.h:71
int i
Definition ShipAna.py:86