GSI Object Oriented Online Offline (Go4)
GO4-6.4.0
Loading...
Searching...
No Matches
Go4EventServer
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
"
23
#include "
TGo4TreeSourceParameter.h
"
24
25
TGo4TreeSource::TGo4TreeSource
(
const
char
*name)
26
:
TGo4EventSource
(name)
27
{
28
GO4TRACE
((15,
"TGo4TreeSource::TGo4TreeSource(const char *)"
,__LINE__, __FILE__));
29
Open
();
30
}
31
32
TGo4TreeSource::TGo4TreeSource
(
TGo4TreeSourceParameter
* par)
33
:
TGo4EventSource
(par->GetName())
34
{
35
GO4TRACE
((15,
"TGo4TreeSource::TGo4TreeSource(TGo4TreeSourceParameter*)"
,__LINE__, __FILE__));
36
Open
();
37
}
38
39
40
TGo4TreeSource::TGo4TreeSource
()
41
:
TGo4EventSource
(
"Go4TreeSource"
)
42
{
43
GO4TRACE
((15,
"TGo4TreeSource::TGo4TreeSource()"
,__LINE__, __FILE__));
44
}
45
46
TGo4TreeSource::~TGo4TreeSource
()
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
63
Int_t
TGo4TreeSource::Open
()
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
70
fxSingletonTree
=
TGo4MainTree::Instance
();
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
83
Bool_t
TGo4TreeSource::BuildEvent
(
TGo4EventElement
*dest)
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
}
TGo4Log.h
GO4TRACE
#define GO4TRACE(X)
Definition
TGo4Log.h:25
TGo4MainTree.h
TGo4TreeSourceParameter.h
TGo4TreeSource.h
TGo4EventElement
The abstract base class for the data elements of which the unpacked events (or detector structure dat...
Definition
TGo4EventElement.h:39
TGo4EventSource::ThrowError
void ThrowError(Int_t creastat, Int_t errstat, const char *message,...)
Exception thrower.
Definition
TGo4EventSource.cxx:44
TGo4EventSource::TGo4EventSource
TGo4EventSource()
Definition
TGo4EventSource.cxx:27
TGo4Log::Debug
static void Debug(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 0.
Definition
TGo4Log.cxx:281
TGo4MainTree::Instance
static TGo4MainTree * Instance()
Definition
TGo4MainTree.cxx:58
TGo4TreeSourceParameter
Tree source parameter.
Definition
TGo4TreeSourceParameter.h:22
TGo4TreeSource::BuildEvent
Bool_t BuildEvent(TGo4EventElement *dest) override
Fill the destination event dest from the tree.
Definition
TGo4TreeSource.cxx:83
TGo4TreeSource::fxBranch
TBranch * fxBranch
The branch representing our source.
Definition
TGo4TreeSource.h:59
TGo4TreeSource::fxSingletonTree
TGo4MainTree * fxSingletonTree
Reference to external tree singleton wrapper instance.
Definition
TGo4TreeSource.h:53
TGo4TreeSource::TGo4TreeSource
TGo4TreeSource()
Definition
TGo4TreeSource.cxx:40
TGo4TreeSource::fxTree
TTree * fxTree
Reference to external root tree singleton.
Definition
TGo4TreeSource.h:56
TGo4TreeSource::~TGo4TreeSource
virtual ~TGo4TreeSource()
Definition
TGo4TreeSource.cxx:46
TGo4TreeSource::Open
Int_t Open()
Definition
TGo4TreeSource.cxx:63
Generated by
1.13.2