19#include "TDirectory.h"
27 TNamed(
"Go4Element",
"This is a Go4 EventElement")
29 GO4TRACE((15,
"TGo4EventElement::TGo4EventElement()",__LINE__, __FILE__));
33 TNamed(name,
"This is a Go4 EventElement")
35 GO4TRACE((15,
"TGo4EventElement::TGo4EventElement(const char *)",__LINE__, __FILE__));
46 GO4TRACE((15,
"TGo4EventElement::~TGo4EventElement()",__LINE__, __FILE__));
51 GO4TRACE((12,
"TGo4EventElement::CheckEventSource(const char *)",__LINE__, __FILE__));
57 GO4TRACE((12,
"TGo4EventElement::PrintEvent()",__LINE__, __FILE__));
73 if (!name || (strlen(name) == 0))
return this;
75 if (strcmp(name,
".") == 0)
return this;
77 if (strcmp(name,
"..") == 0)
return GetParent();
87 TBranch *topb =
nullptr;
88 TString searchname = GetName();
89 if (searchname.Length()>0) {
91 topb = tree->FindBranch(searchname.Data());
96 if (!topb) topb = (TBranch *) tree->GetListOfBranches()->First();
98 Int_t index = tree->GetListOfBranches()->IndexOf(topb);
109 if (!branch)
return 0;
111 TString cad = branch->GetName();
113 TTree *tree = branch->GetTree();
123 TClass *cl = *var_ptr ? (*var_ptr)->IsA() :
nullptr;
124 tree->SetBranchAddress(cad.Data(), var_ptr,
nullptr, cl, kOther_t,
true);
128 tree->SetBranchStatus(cad.Data(), 1);
130 tree->SetBranchStatus(cad.Data(), 1);
137 TGo4Log::Warn(
"-W- Could not deactivate() event element %s in this ROOT Version, do not use!", GetName());
142 TGo4Log::Warn(
"-W- Could not activate() element %s in this ROOT Version, do not use!", GetName());
157 TGo4Log::Error(
"Event %s, mismatch between event source and event class", GetName());
182 return res == 0 ? 1 : res;
192 TDirectory *filsav = gDirectory;
199 TTree *thetree =
new TTree(clone->GetName(),
"Single Event Tree");
200 thetree->SetDirectory(
nullptr);
201 if (sample) *sample = clone;
202 thetree->Branch(
"Go4EventSample", clone->ClassName(), sample ? sample : &clone, 64000, 99);
205 if (!sample)
delete clone;
216 std::cout << std::endl;
void SetValid(Bool_t on)
Switches the valid state of this event.
virtual ~TGo4EventElement()
virtual Int_t Init()
Method called on initialization of event classes.
virtual TTree * CreateSampleTree(TGo4EventElement **sample=nullptr)
virtual void deactivate()
virtual TGo4EventElement * GetChild(const char *name)
virtual void PrintEvent()
Method prints content of the event.
virtual void synchronizeWithTree(TTree *tree, TGo4EventElement **var_ptr=nullptr)
Use this method to map event structure with the Tree branch(es)
virtual Int_t Fill()
Method called by the event owner (analysis step) to fill the event element from the set event source.
Bool_t fbIsValid
Indicates if this event is valid or not.
void Clear(Option_t *opt="") override
TGo4EventElement * GetParent() const
void Print(Option_t *option="") const override
virtual Int_t activateBranch(TBranch *branch, Int_t index=0, TGo4EventElement **var_ptr=nullptr)
Bool_t CheckEventSource(const char *classname)
Check if event source is valid.
Bool_t fbKeepContents
Debug level.
TGo4EventSource * fxEventSource
The external event source instance which is used to fill this event structure from the raw event.
static void Warn(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 2.
static void Info(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 1.
static void Error(const char *text,...) GO4_PRINTF_ARGS
User shortcut for message with prio 3.