18 #include "TObjArray.h" 19 #include "TDirectory.h" 27 fEventElements(nullptr),
69 TBranch *b = parent->GetTree()->TTree::Branch(TString::Format(
"%s.", (*par)->GetName()).Data(),
70 (*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());
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);
198 TGo4Log::Error(
"<TGo4CompositeEvent::addEventElement> object:%s already in structure => not added !",
199 aElement->GetName());
203 if ( aElement->
getId() < 0 ) {
204 TGo4Log::Error(
"<TGo4CompositeEvent::addEventElement> object:%s with invalid Id:%d => not added !",
205 aElement->GetName(), aElement->
getId());
210 TGo4Log::Error(
"<TGo4CompositeEvent::addEventElement> object:%s with Id:%d already used => not added !",
211 aElement->GetName(), aElement->
getId());
218 TGo4Log::Debug(
"-I adding element in :%s :%p of id:%i",GetName(),aElement, aElement->
getId());
243 if(strcmp(name,ev->GetName()) == 0)
return ev;
244 if (ev->isComposed()) {
246 if (inter)
return inter;
249 if(final_element == 0)
250 TGo4Log::Debug(
"TGo4CompositeEvent => Element:%s not found in Composite:%s", name, GetName());
277 TObjArray *comp =
new TObjArray(12);
278 if (toplevel) comp->Add(
this);
283 if (ev->isComposed()) {
300 TGo4Log::Error(
"Wrong index %d in TGo4CompositeEvent::operator[]", i);
326 TDirectory *filsav = gDirectory;
328 if (sample)
delete *sample;
330 TTree *thetree =
new TTree(clone->GetName(),
"Single Event Tree");
331 thetree->SetDirectory(
nullptr);
332 if (sample) *sample = clone;
334 thetree->Branch(
"Go4EventSample", clone->ClassName(), sample ? (
TGo4CompositeEvent **) sample : &clone, 64000, 99);
338 if (!sample)
delete clone;
TGo4EventElement & operator[](Int_t i) override
virtual void makeBranch(TBranch *parent)
virtual TGo4EventElement * GetChild(const char *name)
virtual ~TGo4CompositeEvent()
virtual Bool_t isComposed()
Bool_t addEventElement(TGo4EventElement *aElement, Bool_t reading=kFALSE)
void deactivate() override
TObjArray * getListOfComposites(Bool_t toplevel=kTRUE)
virtual void deactivate()
TObjArray * fEventElements
static void Debug(const char *text,...) GO4_PRINTF_ARGS
TGo4EventElement * GetChild(const char *name) override
TTree * CreateSampleTree(TGo4EventElement **sample=nullptr) override
void makeBranch(TBranch *parent) override
void Clear(Option_t *opt="") override
TGo4EventElement * getEventElement(Int_t idx)
void Clear(Option_t *opt="") override
static void Error(const char *text,...) GO4_PRINTF_ARGS
Int_t activateBranch(TBranch *branch, Int_t init=0, TGo4EventElement **var_ptr=nullptr) override
virtual Int_t activateBranch(TBranch *branch, Int_t index=0, TGo4EventElement **var_ptr=nullptr)