GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
TGo4TreeSource.cxx
Go to the documentation of this file.
1// $Id$
2//-----------------------------------------------------------------------
3// The GSI Online Offline Object Oriented (Go4) Project
4// Experiment Data Processing at EE department, GSI
5//-----------------------------------------------------------------------
6// Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7// Planckstr. 1, 64291 Darmstadt, Germany
8// Contact: http://go4.gsi.de
9//-----------------------------------------------------------------------
10// This software can be used under the license agreements as stated
11// in Go4License.txt file which is part of the distribution.
12//-----------------------------------------------------------------------
13
14#include "TGo4TreeSource.h"
15
16#include <iostream>
17
18#include "TTree.h"
19#include "TBranch.h"
20
21#include "TGo4Log.h"
22#include "TGo4MainTree.h"
24
26: TGo4EventSource(name)
27{
28 GO4TRACE((15,"TGo4TreeSource::TGo4TreeSource(const char *)",__LINE__, __FILE__));
29 Open();
30}
31
33: TGo4EventSource(par->GetName())
34{
35 GO4TRACE((15,"TGo4TreeSource::TGo4TreeSource(TGo4TreeSourceParameter*)",__LINE__, __FILE__));
36 Open();
37}
38
39
41: TGo4EventSource("Go4TreeSource")
42{
43 GO4TRACE((15,"TGo4TreeSource::TGo4TreeSource()",__LINE__, __FILE__));
44}
45
47{
48 GO4TRACE((15,"TGo4TreeSource::~TGo4TreeSource()",__LINE__, __FILE__));
49 // we have to readout rest of branch into memory before whole tree is written again
50 Int_t current = fxSingletonTree->GetCurrentIndex();
51 Int_t max = fxSingletonTree->GetMaxIndex();
52 Int_t z = 0;
53 for (Int_t ix = current; ix < max; ++ix) {
54 z++;
55 if (fxBranch->GetEntry(ix) == 0) {
56 std::cout << "reached end of branch after " << z << " dummy event retrieves" << std::endl;
57 break;
58 }
59 }
60 std::cout << "treesource " << GetName() << " is destroyed after " << z << "dummy retrieves." << std::endl;
61}
62
64{
65 GO4TRACE((15,"TGo4TreeSource::Open()",__LINE__, __FILE__));
66
67 // for branches containing the same event structure
68 TString buffer = TString::Format("%s.",GetName());
69
71 fxTree = fxSingletonTree->GetTree();
72 fxBranch = fxTree->GetBranch(buffer.Data());
73 if(fxBranch)
74 TGo4Log::Debug(" TreeSource: Found existing branch %s ", buffer.Data());
75 else
76 ThrowError(77,0, "!!! ERROR: Branch %s not found!!!", buffer.Data());
77
78 return 0;
79}
80
81
82
84{
85 GO4TRACE((12,"TGo4TreeSource::BuildEvent(TGo4EventElement *)",__LINE__, __FILE__));
86 //
87 Bool_t rev=kTRUE;
88 if(!dest) ThrowError(0,22,"!!! ERROR BuildEvent: no destination event!!!");
89 if(!fxBranch) ThrowError(0,23,"!!! ERROR BuildEvent: branch was not initialized !!!");
90 fxBranch->SetAddress(&dest);
91 Int_t current=fxSingletonTree->GetCurrentIndex();
92 if(fxBranch->GetEntry(current) == 0) {
93 ThrowError(0,24,"!!! ERROR BuildEvent: getting branch entry failed !!!");
94 } else {
95 rev=kTRUE;
96 }
97 return rev;
98}
#define GO4TRACE(X)
Definition TGo4Log.h:25
The abstract base class for the data elements of which the unpacked events (or detector structure dat...
void ThrowError(Int_t creastat, Int_t errstat, const char *message,...)
Exception thrower.
static void Debug(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 0.
Definition TGo4Log.cxx:281
static TGo4MainTree * Instance()
Bool_t BuildEvent(TGo4EventElement *dest) override
Fill the destination event dest from the tree.
TBranch * fxBranch
The branch representing our source.
TGo4MainTree * fxSingletonTree
Reference to external tree singleton wrapper instance.
TTree * fxTree
Reference to external root tree singleton.
virtual ~TGo4TreeSource()