FairRoot/PandaRoot
TGo4EventElement.cxx
Go to the documentation of this file.
1 // $Id: TGo4EventElement.cxx 760 2011-06-22 12:03:48Z linev $
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 für 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 "TGo4EventElement.h"
15 
16 #include "TTree.h"
17 #include <iostream>
18 
19 #if ROOT_VERSION_CODE <= ROOT_VERSION(5,34,19)
20 R__EXTERN TTree *gTree;
21 #endif
22 
24  TNamed("Go4Element","This is a Go4 EventElement"),
25  fbIsValid(kTRUE),
26  fxParent(0),
27  fxEventSource(0),
28  fIdentifier(-1),
29  fDebug(kFALSE)
30 {
31 }
32 
34  TNamed(name,"This is a Go4 EventElement"),
35  fbIsValid(kTRUE),
36  fxParent(0),
37  fxEventSource(0),
38  fIdentifier(-1),
39  fDebug(kFALSE)
40 {
41 }
42 
43 TGo4EventElement::TGo4EventElement(const char* aName, const char* aTitle, Short_t aBaseCat) :
44  TNamed(aName,aTitle),
45  fbIsValid(kTRUE),
46  fxParent(0),
47  fxEventSource(0),
48  fIdentifier(aBaseCat),
49  fDebug(kFALSE)
50 {
51 }
52 
54 {
55 }
56 
57 Bool_t TGo4EventElement::CheckEventSource(const char* ) // classname //[R.K.03/2017] unused variable(s)
58 {
59  return kFALSE;
60 }
61 
63 {
64 }
65 
66 void TGo4EventElement::Print(Option_t* ) const
67 {
68  ((TGo4EventElement*)this) -> PrintEvent();
69 }
70 
71 void TGo4EventElement::makeBranch(TBranch *) //parent //[R.K.03/2017] unused variable(s)
72 {
73  // method for recursive branching algorithm
74 
75 }
76 
78 {
79 
80  if (tree==0) return;
81 
82  TBranch* topb = 0;
83  TString searchname = GetName();
84  if (searchname.Length()>0) {
85  searchname += ".";
86  topb = tree->FindBranch(searchname.Data());
87  }
88 
89  // if no appropriate branches found, use first branch for the event
90  // TODO: should we check class name of the branch?
91  if (topb==0) topb = (TBranch*) tree->GetListOfBranches()->First();
92 
93  Int_t index = tree->GetListOfBranches()->IndexOf(topb);
94 
95  // FIXME SL: should we activate other branches, reading not working when all branches disabled in the beginning
96  // note: only deactivate subleafs _after_ address of top branch is set!
97  // tree->SetBranchStatus("*",0);
98 
99  activateBranch(topb, index, var_ptr);
100 }
101 
137 Int_t TGo4EventElement::activateBranch(TBranch *branch, Int_t , TGo4EventElement** var_ptr) // init //[R.K.03/2017] unused variable(s)
138 {
139  if (branch==0) return 0;
140 
141  TString cad = branch->GetName();
142 
143  TTree* tree = branch->GetTree();
144 
145  if (var_ptr!=0)
146  tree->SetBranchAddress(cad.Data(), (void**)var_ptr);
147 
148  tree->SetBranchStatus(cad.Data(), 1);
149  cad+="*";
150  tree->SetBranchStatus(cad.Data(), 1);
151 
152  return 0;
153 }
154 
156 {
157  TString name = GetName();
158 #if ROOT_VERSION_CODE <= ROOT_VERSION(5,34,19)
159  name+=".";
160  gTree->SetBranchStatus(name.Data(), 0);
161  name+="*";
162  gTree->SetBranchStatus(name.Data(), 0);
163 #else
164  std::cout << "-W- Could not deactivate() event element %s in this ROOT Version, do not use!" << name.Data() << std::endl;
165 #endif
166 }
167 
169 {
170  TString name=GetName();
171 #if ROOT_VERSION_CODE <= ROOT_VERSION(5,34,19)
172  name+=".";
173  gTree->SetBranchStatus(name.Data(), 1);
174  name+="*";
175  gTree->SetBranchStatus(name.Data(), 1);
176 #else
177  std::cout << "-W- Could not activate() element %s in this ROOT Version, do not use!" << name.Data() << std::endl;
178 #endif
179 }
180 
181 void TGo4EventElement::Clear(Option_t *)
182 {
183 }
184 
186 {
187  Int_t res(0);
188  Clear();
189  SetValid(kTRUE);
190  if (fxEventSource) {
191  } else {
192  res = 1;
193  }
194  return res;
195 }
196 
198 {
199  Clear();
200 
201  if (fxEventSource==0) { SetValid(kFALSE); return 1; }
202 
203 
204  Int_t res =0;
205  SetValid(kFALSE);
206 
207  return res==0 ? 1 : res;
208 }
Int_t res
Definition: anadigi.C:166
void SetValid(Bool_t on)
virtual void makeBranch(TBranch *parent)
R__EXTERN TTree * gTree
TTree * tree
Definition: plot_dirc.C:12
virtual ~TGo4EventElement(void)
virtual void deactivate()
virtual void PrintEvent()
Bool_t CheckEventSource(const char *classname)
virtual Int_t Fill()
virtual void Clear(Option_t *t="")
TString name
virtual void synchronizeWithTree(TTree *tree, TGo4EventElement **var_ptr=0)
virtual Int_t Init()
virtual void activate()
virtual void Print(Option_t *option="") const
TGo4EventSource * fxEventSource
virtual Int_t activateBranch(TBranch *branch, Int_t index=0, TGo4EventElement **var_ptr=0)