16 #include "Riostream.h"
18 #include "TMultiGraph.h"
20 #include "TObjArray.h"
33 #include "TDataMember.h"
34 #include "TBaseClass.h"
37 #include "TGo4LockGuard.h"
82 #define fguSUBFOLDERMAXLEN 1024
85 TNamed(name,
"The Go4 Analysis Object Manager"),
86 fxGo4Dir(0),fxHistogramDir(0),fxConditionDir(0), fxParameterDir(0),
87 fxDynListDir(0),fxUserDir(0), fxTreeDir(0), fxPictureDir(0), fxCanvasDir(0),
88 fxStoreDir(0), fxSourceDir(0), fxProcessorDir(0), fxEventDir(0),
89 fxAnalysisDir(0), fxTempFolder(0),
90 fxMatchList(0), fxMatchIterator(0),
91 fiDynListCount(0), fiDynListInterval(0),
92 fbCreatedinMake(kFALSE), fbSuppressLoadHistograms(kFALSE)
130 gROOT->GetListOfCleanups()->Add(
this);
135 fxGo4Dir(0),fxHistogramDir(0),fxConditionDir(0),
136 fxDynListDir(0), fxUserDir(0), fxTreeDir(0), fxPictureDir(0), fxCanvasDir(0),
137 fxStoreDir(0), fxSourceDir(0), fxProcessorDir(0), fxEventDir(0),
138 fxAnalysisDir(0), fxTempFolder(0),
139 fiDynListCount(0), fiDynListInterval(0),
140 fbCreatedinMake(kFALSE), fbSuppressLoadHistograms(kFALSE)
144 gROOT->GetListOfCleanups()->Add(
this);
150 gROOT->GetListOfCleanups()->Remove(
this);
154 gROOT->GetListOfBrowsables()->Remove(
fxGo4Dir);
158 gROOT->GetRootFolder()->Remove(
fxGo4Dir);
189 if ((obj!=0) && (obj!=
this)) {
198 GO4TRACE((11,
"TGo4AnalysisObjectManager::AddObject(TNamed *)",__LINE__, __FILE__));
211 GO4TRACE((11,
"TGo4AnalysisObjectManager::GetAsTObject(const char*, const char*)",__LINE__, __FILE__));
220 if(ob && ob->InheritsFrom(TTree::Class())) ob=0;
221 if(ob && ob->InheritsFrom(TFolder::Class())) ob=0;
222 if(ob && ob->InheritsFrom(TGo4EventElement::Class())) ob=0;
223 if(ob && ob->InheritsFrom(TGo4EventSource::Class())) ob=0;
224 if(ob && ob->InheritsFrom(TGo4EventStore::Class())) ob=0;
225 if(ob && ob->InheritsFrom(TGo4EventProcessor::Class())) ob=0;
229 ob->GetName(), ob->ClassName());
241 return dynamic_cast<TNamed*
> (
GetAsTObject(name, folder));
247 GO4TRACE((11,
"TGo4AnalysisObjectManager::ClearObject(char *)",__LINE__, __FILE__));
250 TObject* ob =
fxGo4Dir->FindObjectAny(name);
253 if(ob->InheritsFrom(TFolder::Class()))
266 TObject* ob=
fxGo4Dir->FindObjectAny(name);
269 if(ob->InheritsFrom(TFolder::Class()))
281 TObject* ob=
fxGo4Dir->FindObjectAny(name);
284 if(ob->InheritsFrom(TFolder::Class()))
294 Int_t startindex, Int_t* skip,
295 const char* name,
const char* title)
297 GO4TRACE((11,
"TGo4AnalysisObjectManager::CreateCompositeBranchFolder(TObjArray*,...)",__LINE__, __FILE__));
298 if (branchlist==0)
return 0;
305 lastindex = startindex + branchlist->GetLast();
311 TList* nameslist =
new TList;
315 Int_t skippedentries=0;
317 for(Int_t i=startindex; i<lastindex;i++) {
320 TObject* entry=branchlist->At(i+offset);
321 if((entry!=0) && entry->InheritsFrom(TBranch::Class())) {
323 TBranch* currentbranch=
dynamic_cast<TBranch*
> (entry);
324 TObjArray* currentbranchlist=0;
325 if (currentbranch!=0) {
326 currentbranchlist=currentbranch->GetListOfBranches();
327 cl=gROOT->GetClass(currentbranch->GetClassName());
329 if((cl!=0) && cl->InheritsFrom(TGo4CompositeEvent::Class())) {
332 TString branchname(currentbranch->GetName());
333 Ssiz_t leng = branchname.Length();
334 branchname.Resize(leng-1);
337 subevent =
dynamic_cast<TGo4CompositeEvent *
>(csubevents->FindObject(branchname.Data()));
345 i+offset+1, &skippedentries,
347 subevent->GetTitle());
348 nameslist->AddLast(subnames);
349 offset+=skippedentries;
357 subnames->GetListOfFolders()->AddAll(temp->GetListOfFolders());
365 if(currentbranchlist!=0)
367 if(currentbranchlist->IsEmpty())
371 nameslist->AddLast(state);
376 currentbranch->GetName(),
377 currentbranch->GetTitle());
378 nameslist->AddLast(subnames);
388 if(currentbranchlist!=0)
390 if(currentbranchlist->IsEmpty())
394 nameslist->AddLast(state);
399 currentbranch->GetName(),
400 currentbranch->GetTitle());
401 nameslist->AddLast(subnames);
418 *skip=lastindex+offset-startindex;
419 TFolder* fold =
fxTempFolder->AddFolder(name,title,nameslist);
420 fold->SetOwner(kTRUE);
427 GO4TRACE((11,
"TGo4AnalysisObjectManager::CreateTreeStructure(TTree*)",__LINE__, __FILE__));
432 const char* treename=thetree->GetName();
433 const char* treetitle=thetree->GetTitle();
436 TObjArray* branchlist=thetree->GetListOfBranches();
446 GO4TRACE((11,
"TGo4AnalysisObjectManager::CreateTreeStructure(const char *)",__LINE__, __FILE__));
450 thetree=
dynamic_cast<TTree*
> (
fxTreeDir->FindObjectAny(treename));
463 TList* nameslist=
new TList;
466 TIter biter(cl->GetListOfBases());
468 while((bob=biter()) !=0) {
469 TBaseClass* baseclass =
dynamic_cast<TBaseClass*
>(bob);
470 if(baseclass==0)
continue;
473 TClass* bclass=baseclass->GetClassPointer();
474 if(bclass==0)
continue;
476 if(!strcmp(bclass->GetName(),
"TNamed"))
continue;
481 nameslist->AddLast(subfold);
484 TIter miter(cl->GetListOfDataMembers());
487 while((nob=miter()) !=0) {
488 TDataMember* mem =
dynamic_cast<TDataMember*
>(nob);
489 if((mem==0) || mem->IsaPointer())
continue;
494 switch(mem->GetArrayDim()) {
496 sbuf = TString::Format(
"%s[%d]", mem->GetName(), mem->GetMaxIndex(0));
500 sbuf = TString::Format(
"%s[%d][%d]", mem->GetName(), mem->GetMaxIndex(0), mem->GetMaxIndex(1));
504 sbuf = mem->GetName();
508 nameslist->AddLast(state);
512 if ((obj!=0) && (obj->InheritsFrom(TGo4CompositeEvent::Class()))) {
517 for (Int_t n=0;n<=arr->GetLast();n++) {
519 if (elem==0)
continue;
522 nameslist->AddLast(subfold);
526 TFolder* memberfolder =
fxTempFolder->AddFolder(membrfoldername, TString(
"Object of class ") + cl->GetName(), nameslist);
528 memberfolder->SetOwner(kTRUE);
534 GO4TRACE((11,
"TGo4AnalysisObjectManager::AddHistogram(TH1*)",__LINE__, __FILE__));
538 if(rev && his) his->SetDirectory(gROOT);
543 const char* foldername,
544 const char* histoname,
550 const char* ytitle) {
552 TString htype(histotype);
554 if (htype.Length()==0) htype =
"I";
558 case 'C' : cl = TH1C::Class();
break;
559 case 'D' : cl = TH1D::Class();
break;
560 case 'F' : cl = TH1F::Class();
break;
561 case 'I' : cl = TH1I::Class();
break;
562 case 'S' : cl = TH1S::Class();
break;
563 default : cl = TH1I::Class();
568 if (histo)
return histo;
571 case 'C' : histo =
new TH1C(histoname, histoname, nbinsx, xlow, xup);
break;
572 case 'D' : histo =
new TH1D(histoname, histoname, nbinsx, xlow, xup);
break;
573 case 'F' : histo =
new TH1F(histoname, histoname, nbinsx, xlow, xup);
break;
574 case 'I' : histo =
new TH1I(histoname, histoname, nbinsx, xlow, xup);
break;
575 case 'S' : histo =
new TH1S(histoname, histoname, nbinsx, xlow, xup);
break;
576 default : histo =
new TH1I(histoname, histoname, nbinsx, xlow, xup);
579 if (title) histo->SetTitle(title);
580 if (xtitle) histo->SetXTitle(xtitle);
581 if (ytitle) histo->SetYTitle(ytitle);
587 const char* foldername,
588 const char* histoname,
597 const char* ytitle) {
598 TString htype(histotype);
600 if (htype.Length()==0) htype =
"I";
605 case 'C' : cl = TH2C::Class();
break;
606 case 'D' : cl = TH2D::Class();
break;
607 case 'F' : cl = TH2F::Class();
break;
608 case 'I' : cl = TH2I::Class();
break;
609 case 'S' : cl = TH2S::Class();
break;
610 default : cl = TH2I::Class();
615 if (histo)
return histo;
618 case 'C' : histo =
new TH2C(histoname, histoname, nbinsx, xlow, xup, nbinsy, ylow, yup);
break;
619 case 'D' : histo =
new TH2D(histoname, histoname, nbinsx, xlow, xup, nbinsy, ylow, yup);
break;
620 case 'F' : histo =
new TH2F(histoname, histoname, nbinsx, xlow, xup, nbinsy, ylow, yup);
break;
621 case 'I' : histo =
new TH2I(histoname, histoname, nbinsx, xlow, xup, nbinsy, ylow, yup);
break;
622 case 'S' : histo =
new TH2S(histoname, histoname, nbinsx, xlow, xup, nbinsy, ylow, yup);
break;
623 default : histo =
new TH2I(histoname, histoname, nbinsx, xlow, xup, nbinsy, ylow, yup);
626 if (title) histo->SetTitle(title);
627 if (xtitle) histo->SetXTitle(xtitle);
628 if (ytitle) histo->SetYTitle(ytitle);
638 GO4TRACE((11,
"TGo4AnalysisObjectManager::CreateBranchFolder(TObjArray*)",__LINE__, __FILE__));
639 if (branchlist==0)
return 0;
641 TList* nameslist=
new TList;
645 TIter iter(branchlist);
646 while((entry=iter()) !=0) {
647 if(entry->InheritsFrom(TBranch::Class())) {
649 TBranch* subbranch=
dynamic_cast<TBranch*
> (entry);
650 TObjArray* subbranchlist = subbranch->GetListOfBranches();
651 if(subbranchlist!=0) {
652 if(subbranchlist->IsEmpty()) {
655 nameslist->AddLast(state);
660 TFolder* subnames = 0;
662 TClass* cl = gROOT->GetClass(subbranch->GetClassName());
663 if((cl!=0) && cl->InheritsFrom(TGo4CompositeEvent::Class()) && istopbranch) {
666 TString branchname(subbranch->GetName());
667 Ssiz_t leng = branchname.Length();
668 branchname.Resize(leng-1);
673 Int_t skippedentries=0;
676 branchlist,cevent,cursor+1,
685 subnames->GetListOfFolders()->AddAll(temp->GetListOfFolders());
686 for(Int_t t=0;t<skippedentries;++t) {
693 subbranch->GetName(),
694 subbranch->GetTitle());
699 subbranch->GetName(), subbranch->GetTitle());
701 nameslist->AddLast(subnames);
707 nameslist->AddLast(state);
713 TFolder* fold =
fxTempFolder->AddFolder(name,title,nameslist);
714 fold->SetOwner(kTRUE);
721 GO4TRACE((11,
"TGo4AnalysisObjectManager::AddTree(TTree*, char*)",__LINE__, __FILE__));
727 GO4TRACE((11,
"TGo4AnalysisObjectManager::RemoveTree(TTree*, const char*)",__LINE__, __FILE__));
728 if (tree==0)
return kFALSE;
737 GO4TRACE((11,
"TGo4AnalysisObjectManager::GetHistogram(char *)",__LINE__, __FILE__));
745 GO4TRACE((11,
"TGo4AnalysisObjectManager::GetTree(char *)",__LINE__, __FILE__));
751 GO4TRACE((11,
"TGo4AnalysisObjectManager::RemoveHistogram(char*)",__LINE__, __FILE__));
759 GO4TRACE((11,
"TGo4AnalysisObjectManager::AddAnalysisCondition(TGo4Condition *)",__LINE__, __FILE__));
764 Bool_t counter, TFolder* parent)
766 GO4TRACE((11,
"TGo4AnalysisObjectManager::SetAnalysisCondition(char*, TGo4Condition*, Bool_t)",__LINE__, __FILE__));
768 if(con==0)
return kFALSE;
772 TFolder* topfolder=0;
778 TObject* searchresult=topfolder->FindObjectAny(name);
780 searchresult=
fxUserDir->FindObjectAny(name);
783 if(searchresult && searchresult->InheritsFrom(TGo4Condition::Class())) {
786 if (searchresult && searchresult->InheritsFrom(TFolder::Class())) {
788 TFolder* subf=
dynamic_cast<TFolder*
>(searchresult);
789 searchresult=subf->FindObjectAny(name);
803 const char* separ = strrchr(name,
'/');
805 TString fname(name, separ-name);
816 GO4TRACE((11,
"TGo4AnalysisObjectManager::GetAnalysisCondition(char*)",__LINE__, __FILE__));
821 if ((cond!=0) && (cond_cl!=0))
822 if(!cond->InheritsFrom(cond_cl)) cond = 0;
828 const char* conditionname,
831 const char* bindhistogram,
837 if (wcond)
return wcond;
841 if (bindhistogram!=0)
843 if (invert) wcond->
Invert(invert);
849 const char* conditionname,
854 const char* bindhistogram,
860 if (wcond)
return wcond;
864 if (bindhistogram!=0)
866 if (invert) wcond->
Invert(invert);
872 const char* conditionname,
874 Float_t (*points)[2],
875 const char* bindhistogram,
881 if (pcond)
return pcond;
883 TArrayF fullx(size+1), fully(size+1);
884 int numpoints = size;
886 for (
int i=0;i<numpoints;i++) {
887 fullx[i] = points[i][0];
888 fully[i] = points[i][1];
892 if ((fullx[0]!=fullx[numpoints-1]) || (fully[0]!=fully[numpoints-1])) {
893 fullx[numpoints] = fullx[0];
894 fully[numpoints] = fully[0];
898 TCutG mycat(
"initialcut", numpoints, fullx.GetArray(), fully.GetArray());
900 pcond->SetValues(&mycat);
901 if (bindhistogram!=0)
902 pcond->SetHistogram(bindhistogram);
903 if (invert) pcond->Invert(invert);
911 GO4TRACE((11,
"TGo4AnalysisObjectManager::RemoveAnalysisCondition(char*)",__LINE__, __FILE__));
925 if(obj->InheritsFrom(TH1::Class()))
928 if(obj->InheritsFrom(TGo4Parameter::Class()))
936 GO4TRACE((11,
"TGo4AnalysisObjectManager::CreateNamesList()",__LINE__, __FILE__));
941 if ((name==0) || (strlen(name)==0)) name =
"Go4NamesList";
950 GO4TRACE((11,
"TGo4AnalysisObjectManager::CreateNamesFolder(TFolder*)",__LINE__, __FILE__));
951 if (objectfolder==0)
return 0;
953 TList* nameslist=
new TList;
954 TIter listiter(objectfolder->GetListOfFolders());
956 while((entry=listiter())!=0) {
957 if(entry->InheritsFrom(TFolder::Class())) {
960 TFolder* subobj=
dynamic_cast<TFolder*
> (entry);
962 nameslist->AddLast(subnames);
965 if (entry->InheritsFrom(TTree::Class())) {
967 TTree* subobj=
dynamic_cast<TTree*
> (entry);
969 nameslist->AddLast(treestruct);
972 if(entry->InheritsFrom(TGo4EventElement::Class())) {
975 nameslist->AddLast(evfolder);
980 nameslist->AddLast(state);
984 TFolder* namesfolder =
fxTempFolder->AddFolder(objectfolder->GetName(),objectfolder->GetTitle(),nameslist);
986 namesfolder->SetOwner(kTRUE);
998 GO4TRACE((11,
"TGo4AnalysisObjectManager::AddEventStore(TGo4EventStore*)",__LINE__, __FILE__));
1004 GO4TRACE((11,
"TGo4AnalysisObjectManager::RemoveEventStore(TGo4EventStore*)",__LINE__, __FILE__));
1021 GO4TRACE((11,
"TGo4AnalysisObjectManager::AddEventSource(TGo4EventSource*)",__LINE__, __FILE__));
1027 GO4TRACE((11,
"TGo4AnalysisObjectManager::RemoveEventSource(TGo4EventSource*)",__LINE__, __FILE__));
1043 GO4TRACE((11,
"TGo4AnalysisObjectManager::AddEventProcessor(TGo4EventProcessor*)",__LINE__, __FILE__));
1049 GO4TRACE((11,
"TGo4AnalysisObjectManager::RemoveEventProcessor(TGo4EventProcessr*)",__LINE__, __FILE__));
1065 GO4TRACE((11,
"TGo4AnalysisObjectManager::AddEventStructure(TGo4EventElement*)",__LINE__, __FILE__));
1071 GO4TRACE((11,
"TGo4AnalysisObjectManager::RemoveEventStructure(TGo4EventElement*)",__LINE__, __FILE__));
1085 GO4TRACE((11,
"TGo4AnalysisObjectManager::GetEvenStructure(char *)",__LINE__, __FILE__));
1087 if ((name==0) || (strlen(name)==0))
return 0;
1092 while (path.Length()>0) {
1093 Int_t pos = path.Index(
"/");
1094 if (pos==0) { path.Remove(0, 1);
continue; }
1097 if (pos>0) { sub.Resize(pos); path.Remove(0, pos+1); }
1098 else { path.Clear(); }
1108 if ((chld==0) && curr->InheritsFrom(sub.Data()))
return curr;
1112 if (curr==0)
return 0;
1120 if(entry) entry->
Reset();
1126 GO4TRACE((11,
"TGo4AnalysisObjectManager::ResetBackStores()",__LINE__, __FILE__));
1130 while((entry=iter()) !=0) {
1132 if(bs!=0) bs->
Reset(clearflag);
1139 GO4TRACE((14,
"TGo4AnalysisObjectManager::CloseAnalysis()",__LINE__, __FILE__));
1155 TDirectory* savdir=gDirectory;
1160 file->Write(0,TObject::kOverwrite);
1169 GO4TRACE((11,
"TGo4AnalysisObjectManager::AddParameter(TGo4Parameter *)",__LINE__, __FILE__));
1175 GO4TRACE((11,
"TGo4AnalysisObjectManager::SetParameter(const char*, TGo4Parameter*)",__LINE__, __FILE__));
1177 if (par==0)
return kFALSE;
1185 TGo4Log::Info(
"Updated parameter %s from parameter %s", name, par->GetName());
1191 const char* separ = strrchr(name,
'/');
1193 TString fname(name, separ-name);
1195 TGo4Log::Info(
"Added new parameter %s to folder %s/%s", clonedpar->GetName(), topfolder->GetName(), fname.Data());
1204 GO4TRACE((11,
"TGo4AnalysisObjectManager::SetParameter(char*, TGo4Parameter*)",__LINE__, __FILE__));
1206 if (status==0)
return kFALSE;
1208 Bool_t rev (kFALSE);
1220 const char* separ = strrchr(name,
'/');
1222 TString fname(name, separ-name);
1233 GO4TRACE((11,
"TGo4AnalysisObjectManager::GetParameter(char*)",__LINE__, __FILE__));
1236 if ((rev!=0) && (parameter_class!=0))
1237 if (!rev->InheritsFrom(parameter_class)) rev=0;
1243 GO4TRACE((11,
"TGo4AnalysisObjectManager::RemoveParameter(char*)",__LINE__, __FILE__));
1249 GO4TRACE((11,
"TGo4AnalysisObjectManager::AddPicture(TGo4Picture *)",__LINE__, __FILE__));
1250 if(!pic)
return kFALSE;
1258 GO4TRACE((11,
"TGo4AnalysisObjectManager::SetPicture(char*, TGo4Picture*)",__LINE__, __FILE__));
1260 if (pic==0)
return kFALSE;
1263 TFolder* topfolder=0;
1279 const char* separ = strrchr(name,
'/');
1281 TString fname(name, separ-name);
1291 GO4TRACE((11,
"TGo4AnalysisObjectManager::GetPicture(char*)",__LINE__, __FILE__));
1299 GO4TRACE((11,
"TGo4AnalysisObjectManager::RemovePicture(char*)",__LINE__, __FILE__));
1305 GO4TRACE((11,
"TGo4AnalysisObjectManager::AddCanvas(TCanvas *)",__LINE__, __FILE__));
1309 if (rev && can) can->SetBit(kMustCleanup);
1319 GO4TRACE((11,
"TGo4AnalysisObjectManager::GetPicture(char*)",__LINE__, __FILE__));
1327 GO4TRACE((11,
"TGo4AnalysisObjectManager::RemovePicture(char*)",__LINE__, __FILE__));
1334 GO4TRACE((11,
"TGo4AnalysisObjectManager::LoadObjects(TFile*)",__LINE__, __FILE__));
1339 TFolder* top=
dynamic_cast<TFolder*
>(ob);
1381 const char* hevx,
const char* hmemx,
1382 const char* hevy,
const char* hmemy,
1383 const char* hevz,
const char* hmemz,
1384 const char* condition,
1385 const char* cevx,
const char* cmemx,
1386 const char* cevy,
const char* cmemy)
1388 if(name==0 || histo==0 || hevx==0 || hmemx==0)
return kFALSE;
1393 if ((hevx!=0) && (hmemx!=0)) {
1398 if ((hevy!=0) && (hmemy!=0)) {
1403 if ((hevz!=0) && (hmemz!=0)) {
1408 if((condition!=0) && (cevx!=0) && (cmemx!=0)) {
1412 if((cevy!=0) && (cmemy!=0)) {
1423 GO4TRACE((11,
"TGo4AnalysisObjectManager::AddTreeHistogram(char*,...)",__LINE__, __FILE__));
1447 GO4TRACE((11,
"TGo4AnalysisObjectManager::FindSubFolder(TFolder*, const char*, Bool_t)",__LINE__, __FILE__));
1450 if(parent==0)
return 0;
1451 if(subfolder==0)
return parent;
1452 const char* separ = strchr(subfolder,
'/');
1455 TString subname(subfolder, separ - subfolder);
1458 TFolder* nextsubfolder =
FindSubFolder(parent, subname.Data(), create);
1462 TIter listiter(parent->GetListOfFolders());
1464 while((entry=listiter()) !=0)
1465 if(entry->InheritsFrom(TFolder::Class()))
1466 if(!strcmp(subfolder,entry->GetName())) {
1467 result=
dynamic_cast<TFolder*
>(entry);
1470 if(result==0 && create)
1471 result=parent->AddFolder(subfolder,
"UserFolder");
1479 const char* subfolder,
1484 GO4TRACE((11,
"TGo4AnalysisObjectManager::AddObjectToFolder(TObject *, TFolder*, const char*, Bool_t)",__LINE__, __FILE__));
1487 if(fold==0)
return kFALSE;
1490 GO4TRACE((12,
"TGo4AnalysisObjectManager::AddObjectToFolder - zero object",__LINE__, __FILE__));
1500 if (subfolder && (strlen(subfolder)!=0)) {
1501 subname = subfolder;
1502 if (subname[subname.Length()-1] ==
'/')
1503 subname.Resize(subname.Length()-1);
1509 oldob=fold->FindObjectAny( ob->GetName() );
1513 if (subname.Length()>0)
1514 obname = subname +
"/" + ob->GetName();
1516 obname = ob->GetName();
1519 oldob = fold->FindObjectAny(obname.Data());
1525 if(replace && ob!=oldob) {
1527 fold->RecursiveRemove(oldob);
1544 if(addDir==0) addDir = fold;
1554 GO4TRACE((11,
"TGo4AnalysisObjectManager::RemoveObjectFromFolder(const char*, TFolder*, Bool_t)",__LINE__, __FILE__));
1556 if(fold==0)
return kFALSE;
1562 strncpy(buffer,fullname,buflen-10);
1563 obj = fold->FindObjectAny(buffer);
1567 fold->RecursiveRemove(obj);
1569 if (isDel)
delete obj;
1580 if (source==0)
return kFALSE;
1581 GO4TRACE((11,
"TGo4AnalysisObjectManager::LoadFolder(TFolder*, TFolder*, Bool_t replace)",__LINE__, __FILE__));
1584 TIter folderiter(source->GetListOfFolders());
1586 while(( ob=folderiter() ) !=0)
1588 if(ob->InheritsFrom(TFolder::Class()))
1590 TFolder* subfolder =
dynamic_cast<TFolder*
> (ob);
1594 TFolder* subdest=
FindSubFolder(destination,subfolder->GetName(), kTRUE);
1608 GO4TRACE((11,
"TGo4AnalysisObjectManager::LoadFolder(TDirectory*, TFolder*, Bool_t replace)",__LINE__, __FILE__));
1609 if(!source || !destination)
return kFALSE;
1612 TDirectory* savdir=gDirectory;
1615 TIter keyiter(source->GetListOfKeys());
1618 while(( keyob=keyiter() ) !=0)
1620 key=
dynamic_cast<TKey*
>(keyob);
1628 TObject* ob = key->ReadObj();
1633 ob=source->Get(key->GetName());
1642 if(ob->InheritsFrom(TDirectory::Class()))
1644 TDirectory* subdir =
dynamic_cast<TDirectory*
> (ob);
1648 Bool_t inpicturefolder=kFALSE;
1649 if(!strcmp(subdir->GetName(),
fgcPICTFOLDER)) inpicturefolder=kTRUE;
1651 TFolder* subdest=
FindSubFolder(destination,subdir->GetName(), kTRUE);
1667 if(!ob || !destination)
return kFALSE;
1670 if (ob->InheritsFrom(TGo4DynamicEntry::Class())) {
1676 if(ob->InheritsFrom(TGo4Parameter::Class())) {
1681 if(ob->InheritsFrom(TGo4Picture::Class())) {
1687 if(ob->InheritsFrom(TGo4Condition::Class())) {
1692 if(ob->InheritsFrom(TH1::Class())) {
1695 TH1* his =
dynamic_cast<TH1*
>(ob);
1697 his->SetDirectory(gROOT);
1703 if(ob->InheritsFrom(TCanvas::Class())) {
1704 TObject* addob = ob->Clone();
1710 if (gPad==addob) gPad = 0;
1715 TObject* addob = ob->Clone();
1729 if (source==0)
return kFALSE;
1732 TIter folderiter(source->GetListOfFolders());
1734 while(( ob=folderiter() ) !=0) {
1735 if(ob->InheritsFrom(TFolder::Class())) {
1736 TFolder* subfolder =
dynamic_cast<TFolder*
> (ob);
1739 TDirectory* currentdir=gDirectory;
1740 const char* subfoldername=subfolder->GetName();
1741 TDirectory* subdir=
dynamic_cast<TDirectory*
>(currentdir->Get(subfoldername));
1744 subdir=currentdir->mkdir(subfoldername,
"subdir");
1773 if(!ob || !dir)
return;
1787 if((fold==0) || (dir==0))
return;
1789 TIter iter(fold->GetListOfFolders());
1791 while((ob = iter()) !=0) {
1792 if(ob->InheritsFrom(TFolder::Class())) {
1793 TFolder* subfolder =
dynamic_cast<TFolder*
> (ob);
1797 dir->RecursiveRemove(ob);
1803 if(fold==0)
return 0;
1805 GO4TRACE((11,
"TGo4AnalysisObjectManager::PrintFolder(TFolder*, Option_t*)",__LINE__, __FILE__));
1808 TROOT::IndentLevel();
1809 TROOT::IncreaseDirLevel();
1810 std::cout <<
"+Folder "<<fold->GetName()<<
" content:" << std::endl;
1811 TIter listiter(fold->GetListOfFolders());
1813 while((ob=listiter())!=0) {
1814 if(ob->InheritsFrom(TFolder::Class()))
1815 totalsize+=
PrintFolder(dynamic_cast<TFolder*>(ob),opt,expression);
1818 TROOT::IndentLevel();
1825 TROOT::DecreaseDirLevel();
1826 TROOT::IndentLevel();
1827 std::cout <<
"++++End "<<fold->GetName()<<
"++++++++++" << std::endl;
1833 GO4TRACE((11,
"TGo4AnalysisObjectManager::ClearFolder(TFolder*, Option_t*)",__LINE__, __FILE__));
1834 if(fold==0)
return kFALSE;
1836 TIter iter(fold->GetListOfFolders());
1838 while((ob=iter())!=0)
1839 if(ob->InheritsFrom(TFolder::Class()))
1848 GO4TRACE((11,
"TGo4AnalysisObjectManager::ClearObject(TObject*)",__LINE__, __FILE__));
1854 if(ob->InheritsFrom(TH1::Class()))
1856 TH1* his=
dynamic_cast<TH1*
>(ob);
1857 if (his) his->Reset();
1859 else if(ob->InheritsFrom(TGo4DynamicEntry::Class()))
1862 if (entry!=0) entry->
Reset();
1864 else if(ob->InheritsFrom(TGo4Picture::Class()))
1867 if (pic) pic->
Reset();
1869 else if(ob->InheritsFrom(TGraph::Class()))
1871 TGraph* gr=
dynamic_cast<TGraph*
>(ob);
1878 else if(ob->InheritsFrom(TMultiGraph::Class()))
1880 TMultiGraph* mg=
dynamic_cast<TMultiGraph*
>(ob);
1882 TIter liter(mg->GetListOfGraphs());
1884 while((ob=liter())!=0)
1888 else if(ob->InheritsFrom(TGo4EventElement::Class()))
1894 else if(ob->InheritsFrom(TTree::Class()))
1913 GO4TRACE((11,
"TGo4AnalysisObjectManager::DeleteFolder(TFolder*, Option_t*)",__LINE__, __FILE__));
1914 if (fold==0)
return kFALSE;
1917 TIter iter(fold->GetListOfFolders());
1919 while((ob=iter())!=0)
1920 if(ob->InheritsFrom(TFolder::Class()))
1929 GO4TRACE((11,
"TGo4AnalysisObjectManager::DeleteObject(TObject*)",__LINE__, __FILE__));
1941 if(fold==0)
return kFALSE;
1943 TIter listiter(fold->GetListOfFolders());
1945 while((ob=listiter.Next())!=0)
1946 if(ob->InheritsFrom(TFolder::Class()))
1955 if((ob==0) || (flags==0))
return kFALSE;
1966 GO4TRACE((11,
"TGo4AnalysisObjectManager::CleanupDynamicLists(TNamed*)",__LINE__, __FILE__));
1968 if (oldobject==0)
return;
1970 if(oldobject->InheritsFrom(TH1::Class()) ||
1971 oldobject->InheritsFrom(TGo4Condition::Class()) ||
1972 oldobject->InheritsFrom(TGo4EventElement::Class()))
1979 GO4TRACE((11,
"TGo4AnalysisObjectManager::PrintConditions(const char*)",__LINE__, __FILE__));
1981 std::cout <<
"___________________________________________________________" << std::endl;
1982 std::cout <<
"Total size of all conditions is: " << totalsize <<
" bytes." << std::endl;
1987 GO4TRACE((11,
"TGo4AnalysisObjectManager::PrintHistograms(const char*)",__LINE__, __FILE__));
1989 std::cout <<
"___________________________________________________________" << std::endl;
1990 std::cout <<
"Total size of all histograms is: " << totalsize <<
" bytes." << std::endl;
1995 GO4TRACE((11,
"TGo4AnalysisObjectManager::PrintParameters(const char*)",__LINE__, __FILE__));
1997 std::cout <<
"___________________________________________________________" << std::endl;
1998 std::cout <<
"Total size of all parameters is: " << totalsize <<
" bytes." << std::endl;
2018 TFolder* searchfold;
2029 TList* result =
new TList;
2031 TIter iter(fold->GetListOfFolders());
2033 while((entry = iter())!=0) {
2034 if(entry->InheritsFrom(TFolder::Class())) {
2035 TFolder* subfold=
dynamic_cast<TFolder*
>(entry);
2038 result->AddAll(sublist);
2040 if(entry->InheritsFrom(TTree::Class())) {
2042 if(entry->InheritsFrom(TGo4EventElement::Class())) {
2044 if(entry->InheritsFrom(TGo4EventSource::Class())) {
2046 if(entry->InheritsFrom(TGo4EventStore::Class())) {
2048 if(entry->InheritsFrom(TGo4EventProcessor::Class())) {
2051 result->AddLast(entry);
2060 if(expression==0)
return kTRUE;
2061 Bool_t ismatching=kFALSE;
2062 TString entrystring=string;
2063 TRegexp reg(expression,kTRUE);
2064 if(!strcmp(expression,
"*"))
2068 else if (entrystring.Index(reg,0)!=kNPOS)
2078 GO4TRACE((12,
"TGo4AnalysisObjectManager::FindObjectInFolder(TFolder*, const char*)",__LINE__, __FILE__));
2081 return folder ? folder->FindObjectAny(fullname) : 0;
2086 const char* &pathname,
2087 const char* objectname,
2091 if ((pathname!=0) && (strlen(pathname)==0)) pathname = 0;
2093 fullname = pathname;
2096 fullname += objectname;
2100 if ((obj!=0) && (!obj->InheritsFrom(cl))) {
2111 if (obj==0)
return kFALSE;
2115 if (fold->GetListOfFolders()->FindObject(obj)==obj) {
2120 TIter iter(fold->GetListOfFolders());
2123 while ((sub = iter())!=0) {
2124 if (!sub->InheritsFrom(TFolder::Class()))
continue;
2126 if (pathname.Length()==0)
2127 pathname = sub->GetName();
2129 pathname = TString(sub->GetName()) +
"/" + pathname;
Bool_t SetParameter(const char *name, TGo4Parameter *par, TFolder *parent=0)
TGo4PolyCond * MakePolyCond(const char *foldername, const char *conditionname, Int_t size, Float_t(*points)[2], const char *bindhistogram=0, Bool_t invert=kFALSE)
Bool_t DeleteObject(TObject *ob)
Bool_t SetAnalysisCondition(const char *name, TGo4Condition *con, Bool_t counter=kTRUE, TFolder *parent=0)
TFolder * CreateCompositeBranchFolder(TObjArray *branchlist, TGo4CompositeEvent *compevent, Int_t startindex, Int_t *skip, const char *name, const char *title)
static const char * fgcSTOREFOLDER
Bool_t ProtectObject(TObject *ob, const Option_t *flags)
Bool_t RemoveObjectFromFolder(const char *fullname, TFolder *fold, Bool_t isDel)
Bool_t RemoveEventProcessor(TGo4EventProcessor *pro)
Bool_t RemoveEventStructure(TGo4EventElement *ev)
static void CleanupPointerInEntries(TFolder *folder, TObject *obj)
virtual TGo4EventElement * GetChild(const char *name)
void UpdateFrom(TGo4Picture *source, TClass *selectedobjclass=0)
Bool_t AddObject(TNamed *anything, const char *subfolder=0, Bool_t replace=kTRUE)
virtual Bool_t UpdateFrom(TGo4Condition *cond, Bool_t counts)
void ResetCurrentDynList()
Bool_t AddDynamicEntry(TGo4DynamicEntry *entry)
TFolder * CreateBranchFolder(TObjArray *branchlist, const char *name, const char *title, Bool_t istopbranch=kFALSE)
Bool_t IsMatching(const char *string, const char *expression)
Bool_t SaveFolder(TFolder *source)
void Reset(Bool_t onlyclearflag=kFALSE)
Bool_t RemovePicture(const char *name)
void SetConditionName(const char *name)
void RemoveFromDir(TFolder *fold, TDirectory *dir)
Short_t getNElements() const
Bool_t ClearObjects(const char *name)
static const char * fgcSRCFOLDER
~TGo4AnalysisObjectManager()
Bool_t DeleteObjects(const char *name)
Bool_t RemoveObject(const char *name, Bool_t del=kTRUE)
TGo4Picture * GetPicture(const char *name)
Bool_t AddCanvas(TCanvas *can, const char *subfolder=0)
Bool_t ClearFolder(TFolder *fold)
Bool_t AddPicture(TGo4Picture *pic, const char *subfolder=0)
Bool_t RemoveDynamicEntry(const char *entryname)
TH1 * GetHistogram(const char *name)
void SetConEventName(Int_t ix, const char *name)
static void CleanupSpecials()
void SetHistogramName(const char *name)
static const char * fgcPARAFOLDER
TObjArray * getListOfComposites(Bool_t toplevel=kTRUE)
Bool_t FindObjectPathName(TObject *obj, TString &pathname, TFolder *fold=0)
TList * CreateObjectList(const char *expr, const char *folder=0)
void PrintConditions(const char *expression=0)
static const char * fgcCONDFOLDER
Bool_t UpdateParameterValues(TGo4Parameter *par)
Bool_t ProtectFolder(TFolder *fold, const Option_t *flags)
TGo4EventElement * GetEventStructure(const char *name)
Bool_t AddHistogram(TH1 *his, const char *subfolder=0, Bool_t replace=kTRUE)
Bool_t RemoveEventStore(TGo4EventStore *store)
static const char * fgcTREEFOLDER
Bool_t AddEventProcessor(TGo4EventProcessor *pro)
Bool_t AddEventSource(TGo4EventSource *source)
TGo4Parameter * CreateParameter()
TObject * FindObjectInFolder(TFolder *folder, const char *fullname)
Bool_t AddAnalysisCondition(TGo4Condition *con, const char *subfolder=0)
static void ResetEntries(TFolder *folder)
TObject * TestObject(TFolder *folder, const char *&pathname, const char *objectname, const TClass *cl)
static const char * fgcPROCFOLDER
Bool_t PutToFolder(TObject *ob, TFolder *destination, Bool_t replace=kFALSE)
void PrintHistograms(const char *expression=0)
TH1 * MakeTH1(const char *histotype, const char *foldername, const char *histoname, Int_t nbinsx, Axis_t xlow, Axis_t xup, const char *title=0, const char *xtitle=0, const char *ytitle=0)
TFolder * CreateNamesFolder(TFolder *objectfolder)
static const char * fgcUSRFOLDER
Bool_t RemoveEventSource(TGo4EventSource *source)
TObject * GetAsTObject(const char *name, const char *folder=0)
Bool_t ClearObject(TObject *ob)
void AppendToDir(TObject *ob, TDirectory *dir)
Bool_t RemoveCanvas(const char *name)
Bool_t AddEventStore(TGo4EventStore *store)
void Message(Int_t prio, const char *text,...)
Bool_t AddParameter(TGo4Parameter *par, const char *subfolder=0)
TFolder * FindSubFolder(TFolder *parent, const char *subfolder, Bool_t create=kTRUE)
Bool_t RemoveTree(TTree *tree, const char *stepname=0)
Bool_t ResetBackStores(Bool_t clearflag=kFALSE)
void SetHistogram(const char *name)
Bool_t AddTree(TTree *tree, const char *subfolder=0)
static const char * fgcTOPDYNAMICLIST
TGo4Parameter * GetParameter(const char *name, const char *parameter_class=0)
void SetHisEventName(Int_t ix, const char *name)
TGo4AnalysisObjectNames * CreateNamesList()
TObject * NextMatchingObject(const char *expr, const char *folder, Bool_t reset)
virtual void SetValues(Double_t low1, Double_t up1)
#define fguSUBFOLDERMAXLEN
virtual const char * GetName() const
TGo4Condition * GetAnalysisCondition(const char *name, const char *cond_cl=0)
Int_t GetDynListInterval() const
static const char * fgcEVENTFOLDER
static const char * fgcHISTFOLDER
Bool_t RemoveAnalysisCondition(const char *name)
void CleanupDynamicLists(TObject *oldobject)
Int_t PrintFolder(TFolder *fold, Option_t *opt, const char *expression=0)
static void PrintEntries(TFolder *folder)
TFolder * GetObjectFolder()
Bool_t RemoveHistogram(const char *name, Bool_t del=kTRUE)
void PrintParameters(const char *expression=0)
virtual Bool_t UpdateFrom(TGo4Parameter *rhs)
TFolder * CreateMembersFolder(TObject *obj, const char *membrfoldername, TClass *cl)
TGo4ObjectStatus * CreateObjectStatus(const char *name, const char *folder=0)
void ProcessDynamicList()
static const char * fgcTMPFOLDER
Bool_t ProtectObjects(const char *name, const Option_t *flags)
Bool_t AddTreeHistogram(const char *hisname, const char *treename, const char *varexp, const char *cutexp)
void SetConVarName(Int_t ix, const char *name)
TGo4WinCond * MakeWindowCond(const char *foldername, const char *conditionname, Double_t xlow, Double_t xup, const char *bindhistogram=0, Bool_t invert=kFALSE)
Bool_t SetPicture(const char *name, TGo4Picture *pic, TFolder *parent=0)
TNamed * GetObject(const char *name, const char *folder=0)
Bool_t RemoveParameter(const char *name)
Bool_t SetParameterStatus(const char *name, TGo4ParameterStatus *par, TFolder *parent=0)
Bool_t AddDynamicHistogram(const char *name, const char *histo, const char *hevx, const char *hmemx, const char *hevy=0, const char *hmemy=0, const char *hevz=0, const char *hmemz=0, const char *condition=0, const char *cevx=0, const char *cmemx=0, const char *cevy=0, const char *cmemy=0)
Bool_t DeleteFolder(TFolder *fold)
static const char * fgcANALYSISFOLDER
TH2 * MakeTH2(const char *histotype, const char *foldername, const char *histoname, Int_t nbinsx, Axis_t xlow, Axis_t xup, Int_t nbinsy, Axis_t ylow, Axis_t yup, const char *title=0, const char *xtitle=0, const char *ytitle=0)
Bool_t AddEventStructure(TGo4EventElement *ev)
Bool_t LoadObjects(TFile *statusfile)
void SaveObjects(TFile *file)
static const char * fgcCANVFOLDER
Int_t GetObjectSize() const
static TGo4Analysis * Instance()
TTree * GetTree(const char *name)
static const char * fgcDYNFOLDER
TGo4TreeStructure * CreateTreeStructure(TTree *thetree)
static void Info(const char *text,...)
Bool_t LoadFolder(TFolder *source, TFolder *destination, Bool_t replace=kFALSE)
Bool_t AddObjectToFolder(TObject *ob, TFolder *fold, const char *subfolder=0, Bool_t replace=kTRUE, Bool_t uniquename=kFALSE, Bool_t resetbits=kTRUE)
TCanvas * GetCanvas(const char *name)
virtual void Invert(Bool_t on)
TGo4AnalysisObjectManager()
virtual void RecursiveRemove(TObject *obj)
static const char * fgcTOPFOLDER
Bool_t fbSuppressLoadHistograms
void SetHisVarName(Int_t ix, const char *name)
static void ProcessEntries(TFolder *folder, Bool_t processtrees, Int_t interval)
TIterator * fxMatchIterator
static const char * fgcPICTFOLDER