18 #include "TObjArray.h"
19 #include "TDirectory.h"
68 TBranch *b = parent->GetTree()->TTree::Branch(Form(
"%s.",(*par)->GetName()), (*par)->ClassName(),par,4000,99);
88 TGo4Log::Debug(
"##### TGo4CompositeEvent::activateBranch called from obj:%s",this->GetName());
90 TTree* tree = branch->GetTree();
91 TObjArray *br = tree->GetListOfBranches();
101 TGo4Log::Debug(
"-I-TGo4CompositeEvent::activateBranch from obj:%s bname:%s Elements:%d index:%d",
102 GetName(), branch->GetName(),
fNElements, init);
104 while (i < init + all_branches) {
106 TBranch* b = (TBranch*) br->At(i);
107 Bool_t readentry = kFALSE;
110 TString sub = b->GetName();
111 sub.Remove(sub.Length()-1);
115 TGo4Log::Debug(
"-I TGo4CompositeEvent::activateBranch use subbranch %s", b->GetName());
119 TClass* cl = gROOT->GetClass(b->GetClassName());
121 TGo4Log::Debug(
"-I class %s cannot be reconstructed", b->GetClassName());
127 par->SetName(sub.Data());
129 TGo4Log::Debug(
"-I Created new instance of class %s, name:%s", cl->GetName(), par->GetName());
133 TGo4Log::Error(
"-I class %s instance cannot be created", b->GetClassName());
145 TGo4Log::Debug(
"-I activate from obj:%s elems:%d index:%d adding:%s",
146 this->GetName(), init+
fNElements, i, par->GetName());
149 if (readentry) b->GetEntry(0);
152 TGo4Log::Debug(
"Add branch %s event %s offset %d", b->GetName(), par->GetName(), offset);
156 tree->SetBranchAddress(b->GetName(), par_ptr);
160 all_branches+=offset;
162 TGo4Log::Debug(
"-I from obj:%s activate indexing after offset:%d index:%d max:%d",
163 this->GetName(), offset, i, init+all_branches);
170 TGo4Log::Debug(
"-I activate return value from obj:%s offset:%i", GetName(), all_branches);
199 TGo4Log::Error(
"<TGo4CompositeEvent::addEventElement> object:%s already in structure => not added !",
200 aElement->GetName());
204 if ( aElement->
getId() < 0 ) {
205 TGo4Log::Error(
"<TGo4CompositeEvent::addEventElement> object:%s with invalid Id:%d => not added !",
206 aElement->GetName(), aElement->
getId());
211 TGo4Log::Error(
"<TGo4CompositeEvent::addEventElement> object:%s with Id:%d already used => not added !",
212 aElement->GetName(), aElement->
getId());
219 TGo4Log::Debug(
"-I adding element in :%s :%p of id:%i",GetName(),aElement, aElement->
getId());
245 if(strcmp(name,ev->GetName())==0)
return ev;
248 if (inter !=0)
return inter;
252 TGo4Log::Debug(
"TGo4CompositeEvent => Element:%s not found in Composite:%s", name, GetName());
282 TObjArray *comp =
new TObjArray(12);
283 if (toplevel) comp->Add(
this);
306 TGo4Log::Error(
"Wrong index %d in TGo4CompositeEvent::operator[]", i);
332 TDirectory* filsav = gDirectory;
334 if (sample!=0)
delete *sample;
336 TTree* thetree =
new TTree(clone->GetName(),
"Single Event Tree");
337 thetree->SetDirectory(0);
338 if (sample) *sample = clone;
340 thetree->Branch(
"Go4EventSample", clone->ClassName(), sample ? (
TGo4CompositeEvent**) sample : &clone, 64000, 99);
344 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,...)