18 #include "TObjArray.h"
19 #include "TDirectory.h"
69 TBranch *b = parent->GetTree()->TTree::Branch(Form(
"%s.",(*par)->GetName()), (*par)->ClassName(),par,4000,99);
89 TGo4Log::Debug(
"##### TGo4CompositeEvent::activateBranch called from obj:%s",this->GetName());
91 TTree* tree = branch->GetTree();
92 TObjArray *br = tree->GetListOfBranches();
102 TGo4Log::Debug(
"-I-TGo4CompositeEvent::activateBranch from obj:%s bname:%s Elements:%d index:%d",
103 GetName(), branch->GetName(),
fNElements, init);
105 while (i < init + all_branches) {
107 TBranch* b = (TBranch*) br->At(i);
108 Bool_t readentry = kFALSE;
111 TString sub = b->GetName();
112 sub.Remove(sub.Length()-1);
116 TGo4Log::Debug(
"-I TGo4CompositeEvent::activateBranch use subbranch %s", b->GetName());
120 TClass* cl = gROOT->GetClass(b->GetClassName());
122 TGo4Log::Debug(
"-I class %s cannot be reconstructed", b->GetClassName());
128 par->SetName(sub.Data());
130 TGo4Log::Debug(
"-I Created new instance of class %s, name:%s", cl->GetName(), par->GetName());
134 TGo4Log::Error(
"-I class %s instance cannot be created", b->GetClassName());
146 TGo4Log::Debug(
"-I activate from obj:%s elems:%d index:%d adding:%s",
147 this->GetName(), init+
fNElements, i, par->GetName());
150 if (readentry) b->GetEntry(0);
153 TGo4Log::Debug(
"Add branch %s event %s offset %d", b->GetName(), par->GetName(), offset);
157 tree->SetBranchAddress(b->GetName(), par_ptr);
161 all_branches+=offset;
163 TGo4Log::Debug(
"-I from obj:%s activate indexing after offset:%d index:%d max:%d",
164 this->GetName(), offset, i, init+all_branches);
171 TGo4Log::Debug(
"-I activate return value from obj:%s offset:%i", GetName(), all_branches);
200 TGo4Log::Error(
"<TGo4CompositeEvent::addEventElement> object:%s already in structure => not added !",
201 aElement->GetName());
205 if ( aElement->
getId() < 0 ) {
206 TGo4Log::Error(
"<TGo4CompositeEvent::addEventElement> object:%s with invalid Id:%d => not added !",
207 aElement->GetName(), aElement->
getId());
212 TGo4Log::Error(
"<TGo4CompositeEvent::addEventElement> object:%s with Id:%d already used => not added !",
213 aElement->GetName(), aElement->
getId());
220 TGo4Log::Debug(
"-I adding element in :%s :%p of id:%i",GetName(),aElement, aElement->
getId());
246 if(strcmp(name,ev->GetName())==0)
return ev;
249 if (inter !=0)
return inter;
253 TGo4Log::Debug(
"TGo4CompositeEvent => Element:%s not found in Composite:%s", name, GetName());
283 TObjArray *comp =
new TObjArray(12);
284 if (toplevel) comp->Add(
this);
307 TGo4Log::Error(
"Wrong index %d in TGo4CompositeEvent::operator[]", i);
333 TDirectory* filsav = gDirectory;
335 if (sample!=0)
delete *sample;
337 TTree* thetree =
new TTree(clone->GetName(),
"Single Event Tree");
338 thetree->SetDirectory(0);
339 if (sample) *sample = clone;
341 thetree->Branch(
"Go4EventSample", clone->ClassName(), sample ? (
TGo4CompositeEvent**) sample : &clone, 64000, 99);
345 if (sample==0)
delete clone;
virtual void makeBranch(TBranch *parent)
void Clear(Option_t *opt="")
virtual TGo4EventElement * GetChild(const char *name)
virtual void makeBranch(TBranch *parent)
virtual ~TGo4CompositeEvent()
virtual TGo4EventElement * GetChild(const char *name)
virtual Bool_t isComposed()
Bool_t addEventElement(TGo4EventElement *aElement, Bool_t reading=kFALSE)
TObjArray * getListOfComposites(Bool_t toplevel=kTRUE)
virtual void deactivate()
TObjArray * fEventElements
virtual void Clear(Option_t *t="")
TGo4EventElement & operator[](Int_t i)
TGo4EventElement * getEventElement(Int_t idx)
virtual void deactivate()
virtual Int_t activateBranch(TBranch *branch, Int_t init=0, TGo4EventElement **var_ptr=0)
virtual TTree * CreateSampleTree(TGo4EventElement **sample=0)
static void Error(const char *text,...)
virtual Int_t activateBranch(TBranch *branch, Int_t index=0, TGo4EventElement **var_ptr=0)
static void Debug(const char *text,...)