FairRoot/PandaRoot
Public Member Functions | Protected Attributes | Private Attributes | List of all members
TGo4EventElement Class Reference

#include <TGo4EventElement.h>

Inheritance diagram for TGo4EventElement:
TProtoUnpackEvent

Public Member Functions

 TGo4EventElement ()
 
 TGo4EventElement (const char *name)
 
 TGo4EventElement (const char *aName, const char *aTitle, Short_t aBaseCat=0)
 
virtual ~TGo4EventElement (void)
 
void SetValid (Bool_t on)
 
Bool_t IsValid () const
 
void SetEventSource (TGo4EventSource *src)
 
void SetParent (TGo4EventElement *par)
 
TGo4EventElementGetParent () const
 
TGo4EventSource * GetEventSource () const
 
Bool_t CheckEventSource (const char *classname)
 
virtual Int_t Fill ()
 
virtual Int_t Init ()
 
virtual void PrintEvent ()
 
virtual void makeBranch (TBranch *parent)
 
virtual void deactivate ()
 
virtual void activate ()
 
virtual void Clear (Option_t *t="")
 
virtual void clearAll (Int_t)
 
virtual Bool_t isComposed ()
 
virtual Short_t getId ()
 
virtual void setDebug (Bool_t debug)
 
virtual TGo4EventElementoperator[] (Int_t)
 
virtual void Print (Option_t *option="") const
 
virtual void synchronizeWithTree (TTree *tree, TGo4EventElement **var_ptr=0)
 
virtual Int_t activateBranch (TBranch *branch, Int_t index=0, TGo4EventElement **var_ptr=0)
 

Protected Attributes

Short_t fIdentifier
 
Bool_t fDebug
 

Private Attributes

Bool_t fbIsValid
 
TGo4EventElementfxParent
 
TGo4EventSource * fxEventSource
 

Detailed Description

Definition at line 36 of file TGo4EventElement.h.

Constructor & Destructor Documentation

TGo4EventElement::TGo4EventElement ( )

Definition at line 23 of file TGo4EventElement.cxx.

23  :
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 }
TGo4EventElement * fxParent
TGo4EventSource * fxEventSource
TGo4EventElement::TGo4EventElement ( const char *  name)

Definition at line 33 of file TGo4EventElement.cxx.

33  :
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 }
TGo4EventElement * fxParent
TString name
TGo4EventSource * fxEventSource
TGo4EventElement::TGo4EventElement ( const char *  aName,
const char *  aTitle,
Short_t  aBaseCat = 0 
)

Definition at line 43 of file TGo4EventElement.cxx.

43  :
44  TNamed(aName,aTitle),
45  fbIsValid(kTRUE),
46  fxParent(0),
47  fxEventSource(0),
48  fIdentifier(aBaseCat),
49  fDebug(kFALSE)
50 {
51 }
TGo4EventElement * fxParent
TGo4EventSource * fxEventSource
TGo4EventElement::~TGo4EventElement ( void  )
virtual

Definition at line 53 of file TGo4EventElement.cxx.

54 {
55 }

Member Function Documentation

void TGo4EventElement::activate ( )
virtual

Definition at line 168 of file TGo4EventElement.cxx.

References gTree, name, and TString.

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 }
R__EXTERN TTree * gTree
TString name
Int_t TGo4EventElement::activateBranch ( TBranch *  branch,
Int_t  index = 0,
TGo4EventElement **  var_ptr = 0 
)
virtual
THIS WAS OLD CODE FROM TGo4FileSource

void TGo4EventElement::synchronizeWithTree(TTree *tree, TGo4EventElement** var_ptr)

TString topname; Bool_t masterbranch=kFALSE; TString branchName = dest->GetName(); if(!fxBranchName.Contains(".")) { fxBranchName+="."; // for master branch, add dot. Subbranch names with dot separators do not get final dot masterbranch=kTRUE; } TObjArray* blist = tree->GetListOfBranches(); TBranch* topb = (TBranch*) blist->At(0); if(topb) { topname = topb->GetName(); cout <<"Activating top branch "<<topname.Data() << endl; tree->SetBranchAddress(topname.Data(),(void**) var_ptr); topb->SetAddress(&fxTopEvent); // this will not set address of possible cloned tree. we use the set address of the tree } tree->SetBranchStatus("*",0); // note: only deactivate subleafs after address of top branch is set! tree->SetBranchStatus(topname.Data(),1); // required to process any of the subbranches! TString wildbranch = branchName; wildbranch += "*"; tree->SetBranchStatus(wildbranch.Data(),1); cout <<"Build event activates: "<<wildbranch.Data() << endl; wildbranch = branchName; if(!masterbranch) wildbranch+="."; wildbranch+="*"; tree->SetBranchStatus(wildbranch.Data(),1); cout <<"Build event activates: "<<wildbranch.Data() << endl; fbActivated = kTRUE;

Definition at line 137 of file TGo4EventElement.cxx.

References tree, and TString.

Referenced by synchronizeWithTree().

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 }
TTree * tree
Definition: plot_dirc.C:12
Bool_t TGo4EventElement::CheckEventSource ( const char *  classname)

Check if event source is valid. Tests the pointer for zero, and if not zero, compares classname of the event source with given string. To be used from the Fill method and from the analysis method init event classes.

Definition at line 57 of file TGo4EventElement.cxx.

58 {
59  return kFALSE;
60 }
void TGo4EventElement::Clear ( Option_t *  t = "")
virtual

Reimplemented in TProtoUnpackEvent.

Definition at line 181 of file TGo4EventElement.cxx.

Referenced by Fill(), and Init().

182 {
183 }
virtual void TGo4EventElement::clearAll ( Int_t  )
inlinevirtual

Definition at line 91 of file TGo4EventElement.h.

91 {}
void TGo4EventElement::deactivate ( )
virtual

Definition at line 155 of file TGo4EventElement.cxx.

References gTree, name, and TString.

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 }
R__EXTERN TTree * gTree
TString name
Int_t TGo4EventElement::Fill ( )
virtual

Method called by the event owner (analysis step) to fill the event element from the set event source. Event source can be the source of the analysis step (if this is a raw event) or the event processor (if this is a reduced event). Fill method has to specify how the event source writes to the members of this event structure. Either by calling methods of the source (like myevent.a=fxEventSource->GetA(); etc ), or by direct copy to the member (like fxEventSource->FillMemoryAt(&myevent.a);)

Definition at line 197 of file TGo4EventElement.cxx.

References Clear(), fxEventSource, res, and SetValid().

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 Clear(Option_t *t="")
TGo4EventSource * fxEventSource
TGo4EventSource* TGo4EventElement::GetEventSource ( ) const
inline

Definition at line 60 of file TGo4EventElement.h.

References fxEventSource.

60 { return fxEventSource; }
TGo4EventSource * fxEventSource
virtual Short_t TGo4EventElement::getId ( )
inlinevirtual

Definition at line 93 of file TGo4EventElement.h.

References fIdentifier.

93 { return fIdentifier;}
TGo4EventElement* TGo4EventElement::GetParent ( ) const
inline

Definition at line 58 of file TGo4EventElement.h.

References fxParent.

58 { return fxParent; }
TGo4EventElement * fxParent
Int_t TGo4EventElement::Init ( )
virtual

Method called on initialization of event classes. User might check the correct type of the eventsource here and assign this to a subclass pointer.

Definition at line 185 of file TGo4EventElement.cxx.

References Clear(), fxEventSource, res, and SetValid().

186 {
187  Int_t res(0);
188  Clear();
189  SetValid(kTRUE);
190  if (fxEventSource) {
191  } else {
192  res = 1;
193  }
194  return res;
195 }
Int_t res
Definition: anadigi.C:166
void SetValid(Bool_t on)
virtual void Clear(Option_t *t="")
TGo4EventSource * fxEventSource
virtual Bool_t TGo4EventElement::isComposed ( )
inlinevirtual

Definition at line 92 of file TGo4EventElement.h.

92 { return kFALSE; }
Bool_t TGo4EventElement::IsValid ( ) const
inline

Returns the valid state of this event.

Definition at line 50 of file TGo4EventElement.h.

References fbIsValid.

50 { return fbIsValid; }
void TGo4EventElement::makeBranch ( TBranch *  parent)
virtual

Definition at line 71 of file TGo4EventElement.cxx.

72 {
73  // method for recursive branching algorithm
74 
75 }
virtual TGo4EventElement& TGo4EventElement::operator[] ( Int_t  )
inlinevirtual

Definition at line 95 of file TGo4EventElement.h.

95 { return *this; }
void TGo4EventElement::Print ( Option_t *  option = "") const
virtual

Definition at line 66 of file TGo4EventElement.cxx.

References PrintEvent().

67 {
68  ((TGo4EventElement*)this) -> PrintEvent();
69 }
virtual void PrintEvent()
void TGo4EventElement::PrintEvent ( )
virtual

Method prints content of the event

Definition at line 62 of file TGo4EventElement.cxx.

Referenced by Print().

63 {
64 }
virtual void TGo4EventElement::setDebug ( Bool_t  debug)
inlinevirtual

Definition at line 94 of file TGo4EventElement.h.

References fDebug.

94 { fDebug=debug;}
void TGo4EventElement::SetEventSource ( TGo4EventSource *  src)
inline

Setter for the event source that is currently used by the Fill method.

Definition at line 53 of file TGo4EventElement.h.

References fxEventSource.

53 { fxEventSource=src; }
TGo4EventSource * fxEventSource
void TGo4EventElement::SetParent ( TGo4EventElement par)
inline

Setter for the parent event structure reference.

Definition at line 56 of file TGo4EventElement.h.

References fxParent, and par.

56 { fxParent=par; }
Double_t par[3]
TGo4EventElement * fxParent
void TGo4EventElement::SetValid ( Bool_t  on)
inline

Switches the valid state of this event.

Definition at line 47 of file TGo4EventElement.h.

References fbIsValid.

Referenced by Fill(), and Init().

47 { fbIsValid=on; }
void TGo4EventElement::synchronizeWithTree ( TTree *  tree,
TGo4EventElement **  var_ptr = 0 
)
virtual

Use this method to map event structure with the Tree branch(es)

Definition at line 77 of file TGo4EventElement.cxx.

References activateBranch(), and TString.

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 }
TTree * tree
Definition: plot_dirc.C:12
virtual Int_t activateBranch(TBranch *branch, Int_t index=0, TGo4EventElement **var_ptr=0)

Member Data Documentation

Bool_t TGo4EventElement::fbIsValid
private

Indicates if this event is valid or not. If false, the event store will not write the event.

Definition at line 108 of file TGo4EventElement.h.

Referenced by IsValid(), and SetValid().

Bool_t TGo4EventElement::fDebug
protected

Definition at line 124 of file TGo4EventElement.h.

Referenced by setDebug().

Short_t TGo4EventElement::fIdentifier
protected

Definition at line 123 of file TGo4EventElement.h.

Referenced by getId().

TGo4EventSource* TGo4EventElement::fxEventSource
private

The external event source instance which is used to fill this event structure from the raw event. Lazy initialization as zero; the pointer is set by analysis only for top level Event Elements with subevents. Might be exchanged on the fly to switch the unpack of different subevents into the same event structure. 0..1

Definition at line 120 of file TGo4EventElement.h.

Referenced by Fill(), GetEventSource(), Init(), and SetEventSource().

TGo4EventElement* TGo4EventElement::fxParent
private

The higher level event element that owns this instance 1

Definition at line 112 of file TGo4EventElement.h.

Referenced by GetParent(), and SetParent().


The documentation for this class was generated from the following files: