Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

TGo4AnalysisObjectManager.cxx

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 #include "TGo4AnalysisObjectManager.h"
00017 
00018 #include "Riostream.h"
00019 
00020 #include "TRegexp.h"
00021 #include "TMultiGraph.h"
00022 #include "TKey.h"
00023 #include "TObjArray.h"
00024 #include "TArrayF.h"
00025 #include "TFolder.h"
00026 #include "TFile.h"
00027 #include "TList.h"
00028 #include "TThread.h"
00029 #include "TH2.h"
00030 #include "TCanvas.h"
00031 #include "TCutG.h"
00032 #include "TROOT.h"
00033 #include "TTree.h"
00034 #include "TDataMember.h"
00035 #include "TBaseClass.h"
00036 #include "snprintf.h"
00037 
00038 #include "TGo4Log.h"
00039 #include "TGo4LockGuard.h"
00040 #include "TGo4ObjectStatus.h"
00041 #include "TGo4BranchStatus.h"
00042 #include "TGo4Parameter.h"
00043 #include "TGo4Condition.h"
00044 #include "TGo4WinCond.h"
00045 #include "TGo4PolyCond.h"
00046 #include "TGo4HistogramEntry.h"
00047 #include "TGo4TreeHistogramEntry.h"
00048 #include "TGo4DynamicListException.h"
00049 #include "TGo4DynamicList.h"
00050 #include "TGo4MainTree.h"
00051 #include "TGo4AnalysisObjectNames.h"
00052 #include "TGo4HistogramStatus.h"
00053 #include "TGo4TreeStructure.h"
00054 
00055 #include "TGo4EventStore.h"
00056 #include "TGo4EventSource.h"
00057 #include "TGo4EventProcessor.h"
00058 #include "TGo4BackStore.h"
00059 
00060 #include "TGo4Picture.h"
00061 #include "TGo4CompositeEvent.h"
00062 #include "TGo4ParameterStatus.h"
00063 #include "TGo4MemberStatus.h"
00064 #include "TGo4PolyCond.h"
00065 #include "TGo4AnalysisImp.h"
00066 
00067 const Text_t TGo4AnalysisObjectManager::fgcTOPDYNAMICLIST[]="Go4DynamicList";
00068 const Text_t TGo4AnalysisObjectManager::fgcTOPFOLDER[]="Go4";
00069 const Text_t TGo4AnalysisObjectManager::fgcHISTFOLDER[]="Histograms";
00070 const Text_t TGo4AnalysisObjectManager::fgcDYNFOLDER[]="DynamicLists";
00071 const Text_t TGo4AnalysisObjectManager::fgcCONDFOLDER[]="Conditions";
00072 const Text_t TGo4AnalysisObjectManager::fgcPARAFOLDER[]="Parameters";
00073 const Text_t TGo4AnalysisObjectManager::fgcTREEFOLDER[]="Trees";
00074 const Text_t TGo4AnalysisObjectManager::fgcPICTFOLDER[]="Pictures";
00075 const Text_t TGo4AnalysisObjectManager::fgcCANVFOLDER[]="Canvases";
00076 const Text_t TGo4AnalysisObjectManager::fgcANALYSISFOLDER[]="EventObjects";
00077 const Text_t TGo4AnalysisObjectManager::fgcEVENTFOLDER[]="Events";
00078 const Text_t TGo4AnalysisObjectManager::fgcSRCFOLDER[]="EventSources";
00079 const Text_t TGo4AnalysisObjectManager::fgcSTOREFOLDER[]="EventStores";
00080 const Text_t TGo4AnalysisObjectManager::fgcPROCFOLDER[]="EventProcessors";
00081 const Text_t TGo4AnalysisObjectManager::fgcUSRFOLDER[]="UserObjects";
00082 const Text_t TGo4AnalysisObjectManager::fgcTMPFOLDER[]="Go4-tmp";
00083 
00084 #define fguSUBFOLDERMAXLEN 1024
00085 
00086 TGo4AnalysisObjectManager::TGo4AnalysisObjectManager(const char* name)
00087 :TNamed(name,"The Go4 Analysis Object Manager"),
00088       fxGo4Dir(0),fxHistogramDir(0),fxConditionDir(0), fxParameterDir(0),
00089       fxDynListDir(0),fxUserDir(0), fxAnalysisDir(0), fxTempFolder(0),
00090       fxMatchList(0), fxMatchIterator(0),
00091       fiDynListCount(0), fiDynListInterval(0),
00092       fbCreatedinMake(kFALSE), fbSuppressLoadHistograms(kFALSE)
00093 {
00094          fxDirMutex=new TMutex(kTRUE);
00095          fxGo4Dir=gROOT->GetRootFolder()->AddFolder(fgcTOPFOLDER,"The Go4 Object folder");
00096          fxGo4Dir->SetOwner(kTRUE); // top go4 dir owns subfolders
00097          gROOT->GetListOfBrowsables()->Add(fxGo4Dir, fxGo4Dir->GetName());
00098          fxHistogramDir=fxGo4Dir->AddFolder(fgcHISTFOLDER,"All Histogram objects");
00099          fxHistogramDir->SetOwner(kTRUE);
00100          fxConditionDir=fxGo4Dir->AddFolder(fgcCONDFOLDER,"All Condition objects");
00101          fxConditionDir->SetOwner(kTRUE);
00102          fxParameterDir=fxGo4Dir->AddFolder(fgcPARAFOLDER,"All Parameter objects");
00103          fxParameterDir->SetOwner(kTRUE);
00104          fxDynListDir=fxGo4Dir->AddFolder(fgcDYNFOLDER,"Dynamic List Instances");
00105          fxDynListDir->SetOwner(kTRUE);
00106          fxTreeDir=fxGo4Dir->AddFolder(fgcTREEFOLDER,"References to trees");
00107          fxTreeDir->SetOwner(kFALSE); // tree dir does not own objects,
00108          fxPictureDir=fxGo4Dir->AddFolder(fgcPICTFOLDER,"Picture objects");
00109          fxPictureDir->SetOwner(kTRUE);
00110          fxCanvasDir=fxGo4Dir->AddFolder(fgcCANVFOLDER,"All TCanvases");
00111          fxCanvasDir->SetOwner(kTRUE);
00112          fxAnalysisDir=fxGo4Dir->AddFolder(fgcANALYSISFOLDER,"Event objects of current analysis");
00113          fxAnalysisDir->SetOwner(kTRUE); // owns folders, but not objects in folders
00114          fxStoreDir=fxAnalysisDir->AddFolder(fgcSTOREFOLDER,"References to event stores");
00115          fxStoreDir->SetOwner(kFALSE); // event  classes dir does not own objects,
00116          fxSourceDir=fxAnalysisDir->AddFolder(fgcSRCFOLDER,"References to event sources");
00117          fxSourceDir->SetOwner(kFALSE); // event  classes dir does not own objects,
00118          fxProcessorDir=fxAnalysisDir->AddFolder(fgcPROCFOLDER,"References to event processors");
00119          fxProcessorDir->SetOwner(kFALSE); // event  classes dir does not own objects,
00120          fxEventDir=fxAnalysisDir->AddFolder(fgcEVENTFOLDER,"References to event structures");
00121          fxEventDir->SetOwner(kFALSE); // event  classes dir does not own objects,
00122          fxUserDir=fxGo4Dir->AddFolder(fgcUSRFOLDER,"For User Objects");
00123          fxGo4Dir->SetOwner(kFALSE);
00124          fxTempFolder=gROOT->GetRootFolder()->AddFolder(fgcTMPFOLDER,"The Go4 temporary object folder");
00125          fxTempFolder->SetOwner(kFALSE);
00126 }
00127 
00128 TGo4AnalysisObjectManager::TGo4AnalysisObjectManager()
00129 :fxGo4Dir(0),fxHistogramDir(0),fxConditionDir(0),
00130 fxDynListDir(0),fxUserDir(0), fxAnalysisDir(0), fxTempFolder(0),
00131 fiDynListCount(0), fiDynListInterval(0),
00132 fbCreatedinMake(kFALSE), fbSuppressLoadHistograms(kFALSE)
00133 {
00134 // ctor for streamer only!
00135 }
00136 
00137 
00138 TGo4AnalysisObjectManager::~TGo4AnalysisObjectManager()
00139 {
00140 
00141 delete fxMatchIterator;
00142 delete fxMatchList;
00143 //delete fxDirMutex;
00144 gROOT->GetListOfBrowsables()->Remove(fxGo4Dir);
00145 //cout <<"Removed all folders from list of browsables" << endl;
00146 
00147 gROOT->GetRootFolder()->Remove(fxTempFolder);
00148 gROOT->GetRootFolder()->Remove(fxGo4Dir);
00149 
00150 fxHistogramDir->Clear();
00151 fxConditionDir->Clear();
00152 fxParameterDir->Clear();
00153 fxDynListDir->Clear();
00154 fxUserDir->Clear();
00155 fxTreeDir->Clear();
00156 fxPictureDir->Clear();
00157 fxCanvasDir->Clear();
00158 fxEventDir->Clear();
00159 fxProcessorDir->Clear();
00160 fxStoreDir->Clear();
00161 fxSourceDir->Clear();
00162 fxGo4Dir->Clear();
00163 fxTempFolder->Clear();
00164 //cout <<"Cleared all folders" << endl;
00165 delete fxTempFolder;
00166 //cout <<"deleted temporary folder" << endl;
00167 delete fxGo4Dir;
00168 //cout <<"deleted top folder" << endl;
00169 }
00170 
00171 
00172 Bool_t TGo4AnalysisObjectManager::AddObject(TNamed * anything, const Text_t* subfolder, Bool_t replace)
00173 {
00174 TRACE((11,"TGo4AnalysisObjectManager::AddObject(TNamed *)",__LINE__, __FILE__));
00175    // unspecified objects are only allowed to put into userdir
00176  return (AddObjectToFolder(anything,fxUserDir,subfolder,replace));
00177 }
00178 
00179 Bool_t TGo4AnalysisObjectManager::RemoveObject(const Text_t * name, Bool_t del)
00180 {
00181    return RemoveObjectFromFolder(name, fxUserDir, del);
00182 }
00183 
00184 
00185 
00186 TNamed * TGo4AnalysisObjectManager::GetObject(const Text_t * name, const Text_t* folder)
00187 {
00188 TRACE((11,"TGo4AnalysisObjectManager::GetObject(Text_t *)",__LINE__, __FILE__));
00189    //
00190    TNamed* ob=0;
00191    TFolder* searchfold;
00192    if(folder==0 || !strcmp(folder,fgcTOPFOLDER))
00193       searchfold=fxGo4Dir; // default: search topfolder
00194    else
00195       searchfold=FindSubFolder(fxGo4Dir, folder, kFALSE);
00196    if(searchfold)
00197       {
00198       ob= dynamic_cast<TNamed*> (FindObjectInFolder(searchfold, name));
00199       //cout << "found object in top folder :" << ob  <<endl;
00200       if(ob && ob->InheritsFrom(TTree::Class())) ob=0; // disable sending tree to gui!
00201       if(ob && ob->InheritsFrom(TFolder::Class())) ob=0; // disable sending complete folder
00202       if(ob && ob->InheritsFrom(TGo4EventElement::Class())) ob=0; // disable events
00203       if(ob && ob->InheritsFrom(TGo4EventSource::Class())) ob=0; // disable events
00204       if(ob && ob->InheritsFrom(TGo4EventStore::Class())) ob=0; // disable events
00205       if(ob && ob->InheritsFrom(TGo4EventProcessor::Class())) ob=0; // disable events
00206       }
00207    else
00208       {
00209          ob=0;
00210       }
00211    if(ob)
00212       {
00213          TGo4Analysis::Instance()->Message(0,"AnalysisObjectManager - found object %s of class %s",
00214                ob->GetName(), ob->ClassName());
00215       }
00216    else
00217       {
00218          TGo4Analysis::Instance()->Message(0,"!!! AnalysisObjectManager - no such object %s !!!",
00219                name);
00220       }
00221    return ob;
00222 }
00223 
00224 
00225 
00226 Bool_t TGo4AnalysisObjectManager::ClearObjects(const Text_t * name)
00227 {
00228    TRACE((11,"TGo4AnalysisObjectManager::ClearObject(Text_t *)",__LINE__, __FILE__));
00229    Bool_t rev=kTRUE;
00230    TGo4LockGuard  dirguard(fxDirMutex);
00231    TObject* ob = fxGo4Dir->FindObjectAny(name);
00232    if(ob!=0)
00233      { 
00234         if(ob->InheritsFrom(TFolder::Class()))
00235            rev=ClearFolder(dynamic_cast<TFolder*>(ob));
00236         else
00237            rev=ClearObject(ob);
00238      }
00239    return rev;
00240 }
00241 
00242 
00243 Bool_t TGo4AnalysisObjectManager::DeleteObjects(const Text_t * name)
00244 {
00245    Bool_t rev=kFALSE;
00246    TGo4LockGuard  dirguard(fxDirMutex);
00247    TObject* ob= fxGo4Dir->FindObjectAny(name);
00248    if(ob!=0)
00249       {
00250          if(ob->InheritsFrom(TFolder::Class()))
00251            rev=DeleteFolder(dynamic_cast<TFolder*>(ob));
00252          else
00253            rev=DeleteObject(ob);
00254       }
00255    return rev;
00256 }
00257 
00258 Bool_t TGo4AnalysisObjectManager::ProtectObjects(const Text_t* name, const Option_t* flags)
00259 {
00260    Bool_t rev = kFALSE;
00261    TGo4LockGuard  dirguard(fxDirMutex);
00262    TObject* ob= fxGo4Dir->FindObjectAny(name);
00263    if(ob!=0)
00264       {
00265          if(ob->InheritsFrom(TFolder::Class()))
00266             rev=ProtectFolder(dynamic_cast<TFolder*>(ob), flags);
00267          else
00268             rev=ProtectObject(ob, flags);
00269       }
00270    return rev;
00271 }
00272 
00273 TFolder * TGo4AnalysisObjectManager::CreateBranchFolder(TObjArray* branchlist,
00274                                                         const char* name,
00275                                                         const char* title,
00276                                                         Bool_t istopbranch)
00277 {
00278    TRACE((11,"TGo4AnalysisObjectManager::CreateBranchFolder(TObjArray*)",__LINE__, __FILE__));
00279    if (branchlist==0) return 0;
00280 
00281    TList* nameslist= new TList;
00282    TGo4ObjectStatus* state;
00283    Int_t cursor=0;
00284    TObject* entry = 0;
00285    TIter iter(branchlist);
00286    while((entry=iter()) !=0) {
00287       if(entry->InheritsFrom(TBranch::Class())) {
00288          // found subfolder, process it recursively
00289          TBranch* subbranch= dynamic_cast<TBranch*> (entry);
00290          TObjArray* subbranchlist = subbranch->GetListOfBranches();
00291          if(subbranchlist!=0) {
00292              if(subbranchlist->IsEmpty()) {
00293                 // subbranchlist is empty, add status object to folder
00294                 state=new TGo4BranchStatus(subbranch);
00295                 nameslist->AddLast(state);
00296              } else {
00297                 // found subbranchlist
00298                 // test for composite event:
00299 
00300                 TFolder* subnames = 0;
00301 
00302                 TClass* cl = gROOT->GetClass(subbranch->GetClassName());
00303                 if((cl!=0) && cl->InheritsFrom(TGo4CompositeEvent::Class()) && istopbranch) {
00304                     // search for composite event of that name in Go4 (only if top level call)
00305                     TGo4CompositeEvent* cevent=0;
00306                     TString branchname(subbranch->GetName());
00307                     Ssiz_t leng = branchname.Length();
00308                     branchname.Resize(leng-1); // strip dot from branchname
00309                     //cout <<"searching for composite event "<< branchname.Data() << endl;
00310                     cevent = dynamic_cast<TGo4CompositeEvent*> (GetEventStructure(branchname.Data()));
00311                     if(cevent!=0) {
00312                         //cout <<"found top comp event" << endl;
00313                         Int_t skippedentries=0;
00314                         // we pass complete top branchlist to method
00315                         subnames = CreateCompositeBranchFolder(
00316                                      branchlist,cevent,cursor+1,
00317                                      &skippedentries,
00318                                      cevent->GetName(),
00319                                      cevent->GetTitle());
00320                         // skip comp subelements in iterator:
00321                         //cout <<"top skipped:"<<skippedentries<< endl;
00322                         // now process subbranchlist  of top compevent,
00323                         // add members of this folder to existing folder subnames!
00324                         TFolder* temp = CreateBranchFolder(subbranchlist, "dummy","dummy");
00325                         subnames->GetListOfFolders()->AddAll(temp->GetListOfFolders());
00326                         for(Int_t t=0;t<skippedentries;++t) {
00327                            iter();
00328                            cursor++;
00329                         }
00330                     } else {
00331                        //cout <<"not found top comp event" << endl;
00332                        subnames=CreateBranchFolder(subbranchlist,
00333                                                    subbranch->GetName(),
00334                                                    subbranch->GetTitle());
00335                     }
00336                 } else {
00337                   //cout <<"no class or not top branch" << endl;
00338                      subnames=CreateBranchFolder(subbranchlist,
00339                                  subbranch->GetName(), subbranch->GetTitle());
00340                 }
00341                 nameslist->AddLast(subnames);
00342              } // if(subbranchlist->IsEmpty())
00343          } else {
00344             // no subbranchlist, should not happen...
00345             // add status object to folder
00346             state=new TGo4BranchStatus(subbranch);
00347             nameslist->AddLast(state);
00348           } // if(subbranchlist)
00349       }
00350       cursor++;
00351    } // while((entry=iter()) !=0)
00352 
00353    TFolder* fold = fxTempFolder->AddFolder(name,title,nameslist);
00354    fold->SetOwner(kTRUE);
00355    fxTempFolder->Remove(fold);
00356    return fold;
00357 }
00358 
00359 TFolder * TGo4AnalysisObjectManager::CreateCompositeBranchFolder(TObjArray* branchlist,
00360                                            TGo4CompositeEvent* compevent,
00361                                            Int_t startindex, Int_t* skip,
00362                                            const Text_t* name, const Text_t* title)
00363 {
00364    TRACE((11,"TGo4AnalysisObjectManager::CreateCompositeBranchFolder(TObjArray*,...)",__LINE__, __FILE__));
00365    if (branchlist==0) return 0;
00366 
00367    if (compevent==0) return CreateBranchFolder(branchlist,name,title);
00368 
00369    Int_t lastindex=0;
00370    if(startindex==1)
00371       // top event: scan everything
00372       lastindex = startindex + branchlist->GetLast();
00373    else
00374       // subevent: scan only own members
00375       lastindex = startindex + compevent->getNElements();
00376 
00377    TFolder* subnames=0;
00378    TList* nameslist = new TList;
00379    TGo4ObjectStatus* state;
00380    TObjArray* csubevents = compevent->getListOfComposites();
00381 
00382    Int_t skippedentries=0;
00383    Int_t offset=0;
00384    for(Int_t i=startindex; i<lastindex;i++) {
00385         //cout <<"i+offset="<<i+offset << endl;
00386         TClass* cl=0;
00387         TObject* entry=branchlist->At(i+offset);
00388         if((entry!=0) && entry->InheritsFrom(TBranch::Class()))  {
00389                      // found subfolder, process it recursively
00390            TBranch* currentbranch= dynamic_cast<TBranch*> (entry);
00391            TObjArray* currentbranchlist=0;
00392            if (currentbranch!=0) {
00393                currentbranchlist=currentbranch->GetListOfBranches();
00394                cl=gROOT->GetClass(currentbranch->GetClassName());
00395            }
00396            if((cl!=0)  && cl->InheritsFrom(TGo4CompositeEvent::Class())) {
00397               // subevent is also composite event, treat next n branches as subbranches:
00398               TGo4CompositeEvent* subevent=0;
00399               TString branchname(currentbranch->GetName());
00400               Ssiz_t leng = branchname.Length();
00401               branchname.Resize(leng-1); // strip dot from branchname
00402               //cout <<"searching for composite sub event "<< branchname.Data() << endl;
00403               if(csubevents!=0)
00404                  subevent = dynamic_cast<TGo4CompositeEvent *>(csubevents->FindObject(branchname.Data()));
00405 
00406               if((subevent!=0) && subevent->getNElements()>0)
00407                  {
00408                      //cout <<"found composite subevent "<< subevent->GetName() << endl;
00409                      // found subbranch, add it to folder struct
00410 
00411                      subnames=CreateCompositeBranchFolder(branchlist,
00412                                                       subevent,
00413                                                       i+offset+1, &skippedentries,
00414                                                       subevent->GetName(),
00415                                                       subevent->GetTitle());
00416                      nameslist->AddLast(subnames);
00417                      offset+=skippedentries;
00418                      //cout <<"skipped:"<<skippedentries<<", i:"<<i << endl;
00419                      //cout <<"offset:"<<offset<< endl;
00420                      // now process subbranchlist currentbranchlist of compevent,
00421                      // add members of this folder to existing folder subnames!
00422                      TFolder* temp=CreateBranchFolder(currentbranchlist,
00423                                                 "dummy",
00424                                                 "dummy");
00425                      subnames->GetListOfFolders()->AddAll(temp->GetListOfFolders());
00426 
00427 
00428                  }
00429               else
00430                  {
00431                      //cout <<"composite subevent is basic member..." << endl;
00432                      // subevent not in list, normal operation:
00433                     //state=new TGo4ObjectStatus(dynamic_cast<TNamed*> (entry) );
00434                     //nameslist->AddLast(state);
00435                     if(currentbranchlist!=0)
00436                      {
00437                         if(currentbranchlist->IsEmpty())
00438                            {
00439                              // subbranchlist is empty, add status object to folder
00440                                 state=new TGo4BranchStatus(currentbranch);
00441                                 nameslist->AddLast(state);
00442                            }
00443                         else
00444                            {
00445                              subnames=CreateBranchFolder(currentbranchlist,
00446                                                 currentbranch->GetName(),
00447                                                 currentbranch->GetTitle());
00448                              nameslist->AddLast(subnames);
00449                            }
00450                      } // if(currentbranchlist)
00451                  } //if(subevent && subevent->getNElements()>0)
00452 
00453            }   //  if(cl  && cl->InheritsFrom(TGo4CompositeEvent))
00454         else
00455            {
00456               // subevent is not a composite event, normal operation:
00457 //                  state=new TGo4ObjectStatus(dynamic_cast<TNamed*> (entry) );
00458 //                  nameslist->AddLast(state);
00459               if(currentbranchlist!=0)
00460                      {
00461                         if(currentbranchlist->IsEmpty())
00462                            {
00463                              // subbranchlist is empty, add status object to folder
00464                                 state=new TGo4BranchStatus(currentbranch);
00465                                 nameslist->AddLast(state);
00466                            }
00467                         else
00468                            {
00469                              subnames=CreateBranchFolder(currentbranchlist,
00470                                                 currentbranch->GetName(),
00471                                                 currentbranch->GetTitle());
00472                              nameslist->AddLast(subnames);
00473                            }
00474                  }
00475               //cout <<"added entry"<< entry->GetName() << endl;
00476            }
00477         }
00478         else
00479            {
00480               break;
00481 //            if(entry)
00482 //               cout <<"ERROR: no branch in branchlist, class:"<< entry->ClassName() << endl;
00483 //             else
00484 //               cout << "ZERO entry in branchlist"<< endl;
00485 
00486           } //if(entry->InheritsFrom(TBranch))
00487      } // for()
00488 
00489    *skip=lastindex+offset-startindex;
00490    TFolder* fold = fxTempFolder->AddFolder(name,title,nameslist);
00491    fold->SetOwner(kTRUE);
00492    fxTempFolder->Remove(fold);
00493    return fold;
00494 
00495 }
00496 
00497 
00498 
00499 TGo4TreeStructure * TGo4AnalysisObjectManager::CreateTreeStructure(TTree* thetree)
00500 {
00501 TRACE((11,"TGo4AnalysisObjectManager::CreateTreeStructure(TTree*)",__LINE__, __FILE__));
00502    //
00503    TGo4TreeStructure* tstructure=0;
00504    if(thetree)
00505       {
00506          const Text_t* treename=thetree->GetName();
00507          const Text_t* treetitle=thetree->GetTitle();
00508          TGo4Analysis::Instance()->Message(0,"AnalysisObjectManager - creating structure of tree %s",
00509                 treename);
00510          TObjArray* branchlist=thetree->GetListOfBranches();
00511          tstructure= new TGo4TreeStructure(treename);
00512          tstructure->fxTopFolder=CreateBranchFolder(branchlist,treename,treetitle, kTRUE);
00513       }
00514    else {}
00515    return tstructure;
00516 }
00517 
00518 TGo4TreeStructure * TGo4AnalysisObjectManager::CreateTreeStructure(const Text_t* treename)
00519 {
00520 TRACE((11,"TGo4AnalysisObjectManager::CreateTreeStructure(const Text_t *)",__LINE__, __FILE__));
00521    TTree* thetree=0;
00522    if(fxTreeDir)
00523       {
00524          thetree=dynamic_cast<TTree*> (fxTreeDir->FindObjectAny(treename));
00525       }
00526    else
00527       {
00528          thetree=0;
00529       }
00530    return (CreateTreeStructure(thetree));
00531 }
00532 
00533 
00534 TFolder* TGo4AnalysisObjectManager::CreateMembersFolder(const char* membrfoldername, TClass* cl)
00535 {
00536    if(cl==0) return 0;
00537    TList* nameslist= new TList;
00538    TIter miter(cl->GetListOfDataMembers());
00539    TObject* nob=0;
00540    // scan members of this event class:
00541    while((nob=miter()) !=0) {
00542        TDataMember* mem=dynamic_cast<TDataMember*>(nob);
00543        if((mem==0) || mem->IsaPointer()) continue; // suppress heap aggregates
00544        // later, we might scan these recursively
00545 
00546         char buffer[501];
00547 
00548         switch(mem->GetArrayDim()) {
00549            case 1:
00550              snprintf(buffer,500,"%s[%d]",
00551                 mem->GetName(),mem->GetMaxIndex(0));
00552              break;
00553 
00554            case 2:
00555              snprintf(buffer,500,"%s[%d][%d]",
00556                 mem->GetName(),mem->GetMaxIndex(0),mem->GetMaxIndex(1));
00557              break;
00558 
00559            default:
00560                snprintf(buffer,500,"%s",mem->GetName());
00561         }
00562 
00563        TGo4MemberStatus* state = new TGo4MemberStatus(buffer, mem->GetFullTypeName());
00564        nameslist->AddLast(state);
00565     } // while
00566 
00567    // now process baseclasses of event:
00568    TIter biter(cl->GetListOfBases());
00569    TObject* bob=0;
00570    while((bob=biter()) !=0) {
00571        TBaseClass* baseclass = dynamic_cast<TBaseClass*>(bob);
00572        if(baseclass==0) continue;
00573 
00574        // we have a baseclass
00575        TClass* bclass=baseclass->GetClassPointer();
00576        if(bclass==0) continue;
00577 
00578        if(!strcmp(bclass->GetName(),"TNamed")) continue; // suppress bases above
00579 
00580        // recursively find out members of all baseclasses
00581        TFolder* subfold = CreateMembersFolder(bclass->GetName(), bclass);
00582        if(subfold!=0)
00583           nameslist->AddLast(subfold);
00584    } // while((bob=baseiter->Next()) !=0)
00585 
00586    TFolder* memberfolder = fxTempFolder->AddFolder(membrfoldername, TString("Object of class ") + cl->GetName(), nameslist);
00587    fxTempFolder->Remove(memberfolder);
00588    memberfolder->SetOwner(kTRUE);
00589    return memberfolder;
00590 }
00591 
00592 Bool_t TGo4AnalysisObjectManager::AddHistogram(TH1 * his, const Text_t* subfolder, Bool_t replace)
00593 {
00594 TRACE((11,"TGo4AnalysisObjectManager::AddHistogram(TH1*)",__LINE__, __FILE__));
00595    Bool_t rev=AddObjectToFolder(his,fxHistogramDir,subfolder,replace,kTRUE);
00596    // for histograms: add with unique object names within histogramdir
00597    // to avoid errors in TTree::Draw()
00598    if(rev && his) his->SetDirectory(gROOT); // assign histo to the top dir, no file!
00599    return rev;
00600 }
00601 
00602 TH1* TGo4AnalysisObjectManager::MakeH1(const Text_t* histotype,
00603                                        const Text_t* foldername,
00604                                        const Text_t* histoname,
00605                                        Int_t         nbinsx,
00606                                        Axis_t        xlow,
00607                                        Axis_t        xup,
00608                                        const Text_t* title,
00609                                        const Text_t* xtitle,
00610                                        const Text_t* ytitle) {
00611 
00612    TString htype(histotype);
00613    htype.ToUpper();
00614    if (htype.Length()==0) htype = "I";
00615    TClass* cl = 0;
00616 
00617    switch (htype[0]) {
00618      case 'C' : cl = TH1C::Class(); break;
00619      case 'D' : cl = TH1D::Class(); break;
00620      case 'F' : cl = TH1F::Class(); break;
00621      case 'I' : cl = TH1I::Class(); break;
00622      case 'S' : cl = TH1S::Class(); break;
00623      default : cl = TH1I::Class();
00624    }
00625 
00626    TH1* histo = (TH1*) TestObject(fxHistogramDir, foldername, histoname, cl);
00627 
00628    if (histo) return histo;
00629 
00630    switch(htype[0]) {
00631       case 'C' : histo = new TH1C(histoname, histoname, nbinsx, xlow, xup); break;
00632       case 'D' : histo = new TH1D(histoname, histoname, nbinsx, xlow, xup); break;
00633       case 'F' : histo = new TH1F(histoname, histoname, nbinsx, xlow, xup); break;
00634       case 'I' : histo = new TH1I(histoname, histoname, nbinsx, xlow, xup); break;
00635       case 'S' : histo = new TH1S(histoname, histoname, nbinsx, xlow, xup); break;
00636       default :  histo = new TH1I(histoname, histoname, nbinsx, xlow, xup);
00637    }
00638 
00639    if (title) histo->SetTitle(title);
00640    if (xtitle) histo->SetXTitle(xtitle);
00641    if (ytitle) histo->SetYTitle(ytitle);
00642    AddHistogram(histo, foldername);
00643    return histo;
00644 }
00645 
00646 TH2* TGo4AnalysisObjectManager::MakeH2(const Text_t* histotype,
00647                                        const Text_t* foldername,
00648                                        const Text_t* histoname,
00649                                        Int_t         nbinsx,
00650                                        Axis_t        xlow,
00651                                        Axis_t        xup,
00652                                        Int_t         nbinsy,
00653                                        Axis_t        ylow,
00654                                        Axis_t        yup,
00655                                        const Text_t* title,
00656                                        const Text_t* xtitle,
00657                                        const Text_t* ytitle) {
00658    TString htype(histotype);
00659    htype.ToUpper();
00660    if (htype.Length()==0) htype = "I";
00661 
00662    TClass* cl = 0;
00663 
00664    switch (htype[0]) {
00665      case 'C' : cl = TH2C::Class(); break;
00666      case 'D' : cl = TH2D::Class(); break;
00667      case 'F' : cl = TH2F::Class(); break;
00668      case 'I' : cl = TH2I::Class(); break;
00669      case 'S' : cl = TH2S::Class(); break;
00670      default : cl = TH2I::Class();
00671    }
00672 
00673    TH2* histo = (TH2*) TestObject(fxHistogramDir, foldername, histoname, cl);
00674 
00675    if (histo) return histo;
00676 
00677    switch(htype[0]) {
00678       case 'C' : histo = new TH2C(histoname, histoname, nbinsx, xlow, xup, nbinsy, ylow, yup); break;
00679       case 'D' : histo = new TH2D(histoname, histoname, nbinsx, xlow, xup, nbinsy, ylow, yup); break;
00680       case 'F' : histo = new TH2F(histoname, histoname, nbinsx, xlow, xup, nbinsy, ylow, yup); break;
00681       case 'I' : histo = new TH2I(histoname, histoname, nbinsx, xlow, xup, nbinsy, ylow, yup); break;
00682       case 'S' : histo = new TH2S(histoname, histoname, nbinsx, xlow, xup, nbinsy, ylow, yup); break;
00683       default :  histo = new TH2I(histoname, histoname, nbinsx, xlow, xup, nbinsy, ylow, yup);
00684    }
00685 
00686    if (title) histo->SetTitle(title);
00687    if (xtitle) histo->SetXTitle(xtitle);
00688    if (ytitle) histo->SetYTitle(ytitle);
00689    AddHistogram(histo, foldername);
00690    return histo;
00691 }
00692 
00693 Bool_t TGo4AnalysisObjectManager::AddTree(TTree* tree, const Text_t* subfolder)
00694 {
00695 TRACE((11,"TGo4AnalysisObjectManager::AddTree(TTree*, Text_t*)",__LINE__, __FILE__));
00696   return (AddObjectToFolder(tree,fxTreeDir,subfolder,kFALSE));
00697 }
00698 
00699 Bool_t TGo4AnalysisObjectManager::RemoveTree(TTree * tree, const Text_t* stepname)
00700 {
00701    TRACE((11,"TGo4AnalysisObjectManager::RemoveTree(TTree*, Text_t*)",__LINE__, __FILE__));
00702    Bool_t rev=kFALSE;
00703    if(tree)
00704       {
00705                TGo4LockGuard listguard(fxDirMutex);
00706                   fxTreeDir->Remove(tree);
00707                   // later: we use directory with name stepname to put tree in
00708       }
00709    else
00710       {
00711          rev=kFALSE;
00712       }
00713    return rev;
00714 }
00715 TH1* TGo4AnalysisObjectManager::GetHistogram(const Text_t * name)
00716 {
00717 TRACE((11,"TGo4AnalysisObjectManager::GetHistogram(Text_t *)",__LINE__, __FILE__));
00718    TH1* rev= dynamic_cast<TH1*> (FindObjectInFolder(fxHistogramDir, name));
00719    if(rev==0) rev= dynamic_cast<TH1*> (FindObjectInFolder(fxUserDir, name)); // also check user objects dir
00720    return rev;
00721 }
00722 
00723 TTree * TGo4AnalysisObjectManager::GetTree(const Text_t * name)
00724 {
00725 TRACE((11,"TGo4AnalysisObjectManager::GetTree(Text_t *)",__LINE__, __FILE__));
00726   return dynamic_cast<TTree*> (FindObjectInFolder(fxTreeDir, name));
00727 }
00728 
00729 Bool_t TGo4AnalysisObjectManager::RemoveHistogram(const Text_t * name, Bool_t del)
00730 {
00731 TRACE((11,"TGo4AnalysisObjectManager::RemoveHistogram(Text_t*)",__LINE__, __FILE__));
00732    //
00733    return RemoveObjectFromFolder(name, fxHistogramDir, del);
00734 }
00735 
00736 
00737 Bool_t TGo4AnalysisObjectManager::AddAnalysisCondition(TGo4Condition * con, const Text_t* subfolder)
00738 {
00739 TRACE((11,"TGo4AnalysisObjectManager::AddAnalysisCondition(TGo4Condition *)",__LINE__, __FILE__));
00740 return(AddObjectToFolder(con,fxConditionDir,subfolder,kTRUE));
00741 }
00742 
00743 Bool_t TGo4AnalysisObjectManager::SetAnalysisCondition(const Text_t * name, TGo4Condition* con,
00744                                    Bool_t counter, TFolder* parent)
00745 {
00746 TRACE((11,"TGo4AnalysisObjectManager::SetAnalysisCondition(Text_t*, TGo4Condition*, Bool_t)",__LINE__, __FILE__));
00747 TGo4LockGuard   listguard(fxDirMutex);
00748 Bool_t rev=kFALSE;
00749 TFolder* topfolder=0;
00750 if(parent)
00751    topfolder=parent;
00752 else
00753    topfolder=fxConditionDir;
00754 if(con)
00755    {
00756       TObject* searchresult=topfolder->FindObjectAny(name);
00757       if(searchresult==0)
00758          searchresult=fxUserDir->FindObjectAny(name);
00759          // condition may be under user objects folder if not found in topfolder
00760       TGo4Condition* oldcon;
00761       if(searchresult && searchresult->InheritsFrom(TGo4Condition::Class()))
00762          {
00763             oldcon= dynamic_cast<TGo4Condition *> (searchresult);
00764          }
00765       else if (searchresult && searchresult->InheritsFrom(TFolder::Class()))
00766          {
00767             // this is for the case that condition has same name as its folder!
00768             TFolder* subf=dynamic_cast<TFolder*>(searchresult);
00769             searchresult=subf->FindObjectAny(name);
00770             oldcon= dynamic_cast<TGo4Condition *> (searchresult);
00771          }
00772       else
00773          {
00774              oldcon=0;
00775          }
00776       if(oldcon!=0)
00777          {
00778             // update existing condition of given name
00779             rev=oldcon->UpdateFrom(con,counter);
00780             //cout << "++++ Updated condition "<< name<<" from condition "<< con->GetName() << endl;
00781             //oldcon->PrintCondition(true);
00782          }
00783       else
00784          {
00785             // condition not yet exisiting, add external condition
00786              TGo4Condition* clonedcon= dynamic_cast<TGo4Condition*>(con->Clone());
00787              TGo4PolyCond::CleanupSpecials(); // remove reference to cloned cut
00788              // find out destination folder for new condition from name:
00789             Text_t subfolder[fguSUBFOLDERMAXLEN];
00790             size_t fnamelen=0;
00791             const char* endname = name;
00792             const char* foldername = name;
00793             while (endname!=0)
00794                {
00795                   endname=strstr(foldername,"/");
00796                   if(endname==0) break;
00797                   clonedcon->SetName(endname+1);
00798                   fnamelen= endname-name; // length of path string
00799                   //cout <<"SetAnalysiscondition: namelen="<< (Int_t) fnamelen << endl;
00800                   foldername=endname+1;
00801                }
00802 
00803              if(fnamelen>0)
00804                 {
00805                    // we have a subfolder for condition
00806                    if(fnamelen>fguSUBFOLDERMAXLEN) fnamelen=fguSUBFOLDERMAXLEN;
00807                    snprintf(subfolder,fnamelen+1,"%s",name);
00808                    rev=AddObjectToFolder(clonedcon,topfolder,subfolder,kTRUE,kFALSE,kFALSE);
00809                    //cout << "++++ Added new condition "<< clonedcon->GetName()<<" to folder "<<topfolder->GetName()<<"/"<< subfolder << endl;
00810                 }
00811              else
00812                 {
00813                    // no subfolder, condition is directly under topfolder
00814                    rev=AddObjectToFolder(clonedcon,topfolder,0,kTRUE,kFALSE,kFALSE);
00815                    //cout << "++++ Added new condition "<< clonedcon->GetName()<<" to folder "<<topfolder->GetName()<<", no subfolder!!!"<< endl;
00816                 }
00817          }
00818    }
00819 else
00820    {
00821       rev=kFALSE;
00822    }
00823 return rev;
00824 }
00825 
00826 TGo4Condition * TGo4AnalysisObjectManager::GetAnalysisCondition(const Text_t * name)
00827 {
00828 TRACE((11,"TGo4AnalysisObjectManager::GetAnalysisCondition(Text_t*)",__LINE__, __FILE__));
00829    TGo4Condition* cond = dynamic_cast<TGo4Condition *> (FindObjectInFolder(fxConditionDir, name));
00830    if(cond==0) cond=dynamic_cast<TGo4Condition *> (FindObjectInFolder(fxUserDir, name));
00831       // some users have their conditions rather in user folder...
00832    return cond;
00833 }
00834 
00835 TGo4WinCond* TGo4AnalysisObjectManager::MakeWindowCond(const Text_t* foldername,
00836                                                        const Text_t* conditionname,
00837                                                        Double_t      xlow,
00838                                                        Double_t      xup,
00839                                                        const Text_t* bindhistogram,
00840                                                        Bool_t        invert) {
00841    TGo4WinCond* wcond = (TGo4WinCond*)
00842      TestObject(fxConditionDir, foldername, conditionname, TGo4WinCond::Class());
00843 
00844    if (wcond) return wcond;
00845 
00846    wcond = new TGo4WinCond(conditionname);
00847    wcond->SetValues(xlow, xup);
00848    if (bindhistogram!=0)
00849      wcond->SetHistogram(bindhistogram);
00850    if (invert) wcond->Invert(invert);
00851    AddAnalysisCondition(wcond, foldername);
00852    return wcond;
00853 }
00854 
00855 TGo4WinCond* TGo4AnalysisObjectManager::MakeWindowCond(const Text_t* foldername,
00856                                                        const Text_t* conditionname,
00857                                                        Double_t      xlow,
00858                                                        Double_t      xup,
00859                                                        Double_t      ylow,
00860                                                        Double_t      yup,
00861                                                        const Text_t* bindhistogram,
00862                                                        Bool_t      invert) {
00863    TGo4WinCond* wcond = (TGo4WinCond*)
00864      TestObject(fxConditionDir, foldername, conditionname, TGo4WinCond::Class());
00865 
00866    if (wcond) return wcond;
00867 
00868    wcond = new TGo4WinCond(conditionname);
00869    wcond->SetValues(xlow, xup, ylow, yup);
00870    if (bindhistogram!=0)
00871      wcond->SetHistogram(bindhistogram);
00872    if (invert) wcond->Invert(invert);
00873    AddAnalysisCondition(wcond, foldername);
00874    return wcond;
00875 }
00876 
00877 TGo4PolyCond* TGo4AnalysisObjectManager::MakePolyCond(const Text_t* foldername,
00878                                                       const Text_t* conditionname,
00879                                                       Int_t         size,
00880                                                       Float_t      (*points)[2],
00881                                                       const Text_t* bindhistogram,
00882                                                       Bool_t        invert)
00883 {
00884    TGo4PolyCond* pcond = (TGo4PolyCond*)
00885       TestObject(fxConditionDir, foldername, conditionname, TGo4PolyCond::Class());
00886 
00887    if (pcond) return pcond;
00888 
00889    TArrayF fullx(size+1), fully(size+1);
00890    int numpoints = size;
00891 
00892    for (int i=0;i<numpoints;i++) {
00893      fullx[i] = points[i][0];
00894      fully[i] = points[i][1];
00895    }
00896 
00897    // connect first and last points
00898    if ((fullx[0]!=fullx[numpoints-1]) || (fully[0]!=fully[numpoints-1])) {
00899       fullx[numpoints] = fullx[0];
00900       fully[numpoints] = fully[0];
00901       numpoints++;
00902    }
00903 
00904    TCutG mycat("initialcut", numpoints, fullx.GetArray(), fully.GetArray());
00905    pcond = new TGo4PolyCond(conditionname);
00906    pcond->SetValues(&mycat);
00907    if (bindhistogram!=0)
00908      pcond->SetHistogram(bindhistogram);
00909    if (invert) pcond->Invert(invert);
00910    AddAnalysisCondition(pcond, foldername);
00911    return pcond;
00912 }
00913 
00914 
00915 Bool_t TGo4AnalysisObjectManager::RemoveAnalysisCondition(const Text_t * name)
00916 {
00917 TRACE((11,"TGo4AnalysisObjectManager::RemoveAnalysisCondition(Text_t*)",__LINE__, __FILE__));
00918    return RemoveObjectFromFolder(name, fxConditionDir, kTRUE);
00919 }
00920 
00921 TGo4ObjectStatus * TGo4AnalysisObjectManager::CreateObjectStatus(const Text_t * name, const Text_t* folder)
00922 {
00923    TNamed* object=GetObject(name, folder);
00924    return CreateObjectStatus(object);
00925 }
00926 
00927 TGo4ObjectStatus * TGo4AnalysisObjectManager::CreateObjectStatus(TObject* ob, Bool_t fullinfo)
00928 {
00929 if(ob==0) return 0;
00930 TGo4ObjectStatus* state=0;
00931 if(ob->InheritsFrom(TH1::Class()))
00932    {
00933        // found histogram
00934        TH1* his= dynamic_cast<TH1*> (ob);
00935        state=new TGo4HistogramStatus(his,fullinfo);
00936   }
00937 else if(ob->InheritsFrom(TGo4Parameter::Class()))
00938    {
00939        TGo4Parameter* par= dynamic_cast<TGo4Parameter*> (ob);
00940        state=new TGo4ParameterStatus(par, fullinfo);
00941    }
00942 else
00943    {
00944       state=new TGo4ObjectStatus(dynamic_cast<TNamed*> (ob) );
00945    }
00946 return state;
00947 }
00948 
00949 TGo4AnalysisObjectNames * TGo4AnalysisObjectManager::CreateNamesList()
00950 {
00951 TRACE((11,"TGo4AnalysisObjectManager::CreateNamesList()",__LINE__, __FILE__));
00952    TGo4LockGuard   listguard(fxDirMutex);
00953    TGo4AnalysisObjectNames* namesobject=0;
00954    //fxTempFolder->Clear();
00955    namesobject= new TGo4AnalysisObjectNames("Go4NamesList");
00956    namesobject->fxTopFolder=CreateNamesFolder(fxGo4Dir);
00957    TGo4PolyCond::CleanupSpecials(); // remove references to cloned TCutG in status
00958    return namesobject;
00959 }
00960 
00961 TFolder * TGo4AnalysisObjectManager::CreateNamesFolder(TFolder * objectfolder)
00962 {
00963    TRACE((11,"TGo4AnalysisObjectManager::CreateNamesFolder(TFolder*)",__LINE__, __FILE__));
00964    if (objectfolder==0) return 0;
00965 
00966  TList* nameslist= new TList;
00967  TIter listiter(objectfolder->GetListOfFolders());
00968  TObject* entry;
00969  while((entry=listiter()) !=0)
00970     {
00971        if(entry->InheritsFrom(TFolder::Class()))
00972           {
00973               // found subfolder, process it recursively
00974               //cout <<"##### parsing folder "<< entry->GetName() << endl;
00975               TFolder* subobj= dynamic_cast<TFolder*> (entry);
00976               TFolder* subnames=CreateNamesFolder(subobj);
00977               nameslist->AddLast(subnames);
00978           }
00979         else if (entry->InheritsFrom(TTree::Class()))
00980            {
00981               // treestructure should be ObjectStatus?
00982               TTree* subobj= dynamic_cast<TTree*> (entry);
00983               TGo4TreeStructure* treestruct=CreateTreeStructure(subobj);
00984               nameslist->AddLast(treestruct);
00985            }
00986         else if(entry->InheritsFrom(TGo4EventElement::Class()))
00987            {
00988               TFolder* evfolder = CreateMembersFolder(entry->GetName(), entry->IsA());
00989               if (evfolder!=0)
00990                  nameslist->AddLast(evfolder);
00991            }
00992         else
00993            {
00994              TGo4ObjectStatus*state = CreateObjectStatus(entry,kFALSE); // do not use full status info for nameslist
00995              if(state!=0)
00996                  nameslist->AddLast(state);
00997           }
00998     } // while
00999 
01000    TFolder* namesfolder=fxTempFolder->AddFolder(objectfolder->GetName(),objectfolder->GetTitle(),nameslist);
01001    fxTempFolder->Remove(namesfolder);
01002    namesfolder->SetOwner(kTRUE);
01003 
01004    return namesfolder;
01005 }
01006 
01007 TFolder * TGo4AnalysisObjectManager::GetObjectFolder()
01008 {
01009    return fxGo4Dir;
01010 }
01011 
01012 Bool_t TGo4AnalysisObjectManager::AddEventStore(TGo4EventStore * store)
01013 {
01014 TRACE((11,"TGo4AnalysisObjectManager::AddEventStore(TGo4EventStore*)",__LINE__, __FILE__));
01015  return (AddObjectToFolder(store,fxStoreDir,0,kFALSE));
01016 }
01017 Bool_t TGo4AnalysisObjectManager::RemoveEventStore(TGo4EventStore * store)
01018 {
01019 TRACE((11,"TGo4AnalysisObjectManager::RemoveEventStore(TGo4EventStore*)",__LINE__, __FILE__));
01020    Bool_t rev=kFALSE;
01021    if(store)
01022       {
01023          TGo4LockGuard listguard(fxDirMutex);
01024             fxStoreDir->Remove(store);
01025             rev=kTRUE;
01026       }
01027    else
01028       {
01029          rev=kFALSE;
01030       }
01031    return rev;
01032 }
01033 
01034 Bool_t TGo4AnalysisObjectManager::AddEventSource(TGo4EventSource * source)
01035 {
01036 TRACE((11,"TGo4AnalysisObjectManager::AddEventSource(TGo4EventSource*)",__LINE__, __FILE__));
01037  return (AddObjectToFolder(source,fxSourceDir,0,kFALSE));
01038 }
01039 
01040 Bool_t TGo4AnalysisObjectManager::RemoveEventSource(TGo4EventSource* source)
01041 {
01042 TRACE((11,"TGo4AnalysisObjectManager::RemoveEventSource(TGo4EventSource*)",__LINE__, __FILE__));
01043    Bool_t rev=kFALSE;
01044    if(source)
01045       {
01046          TGo4LockGuard listguard(fxDirMutex);
01047             fxSourceDir->Remove(source);
01048             rev=kTRUE;
01049       }
01050    else
01051       {
01052          rev=kFALSE;
01053       }
01054    return rev;
01055 }
01056 Bool_t TGo4AnalysisObjectManager::AddEventProcessor(TGo4EventProcessor * pro)
01057 {
01058 TRACE((11,"TGo4AnalysisObjectManager::AddEventProcessor(TGo4EventProcessor*)",__LINE__, __FILE__));
01059   return (AddObjectToFolder(pro,fxProcessorDir,0,kFALSE));
01060 }
01061 
01062 Bool_t TGo4AnalysisObjectManager::RemoveEventProcessor(TGo4EventProcessor * pro)
01063 {
01064 TRACE((11,"TGo4AnalysisObjectManager::RemoveEventProcessor(TGo4EventProcessr*)",__LINE__, __FILE__));
01065    Bool_t rev=kFALSE;
01066    if(pro)
01067       {
01068          TGo4LockGuard listguard(fxDirMutex);
01069             fxProcessorDir->Remove(pro);
01070             rev=kTRUE;
01071       }
01072    else
01073       {
01074          rev=kFALSE;
01075       }
01076    return rev;
01077 }
01078 Bool_t TGo4AnalysisObjectManager::AddEventStructure(TGo4EventElement * ev)
01079 {
01080 TRACE((11,"TGo4AnalysisObjectManager::AddEventStructure(TGo4EventElement*)",__LINE__, __FILE__));
01081   return (AddObjectToFolder(ev,fxEventDir,0,kFALSE));
01082 }
01083 
01084 Bool_t TGo4AnalysisObjectManager::RemoveEventStructure(TGo4EventElement * ev)
01085 {
01086 TRACE((11,"TGo4AnalysisObjectManager::RemoveEventStructure(TGo4EventElement*)",__LINE__, __FILE__));
01087    Bool_t rev=kFALSE;
01088    if(ev!=0) {
01089       TGo4LockGuard listguard(fxDirMutex);
01090       fxEventDir->Remove(ev);
01091       // remove pointers to event data from all dynamic lists:
01092       CleanupDynamicLists(ev);
01093       rev=kTRUE;
01094    }
01095    return rev;
01096 }
01097 TGo4EventElement * TGo4AnalysisObjectManager::GetEventStructure(const Text_t * name)
01098 {
01099 TRACE((11,"TGo4AnalysisObjectManager::GetEvenStructure(Text_t *)",__LINE__, __FILE__));
01100    return dynamic_cast<TGo4EventElement*> (FindObjectInFolder(fxEventDir, name));
01101 }
01102 
01103 Bool_t TGo4AnalysisObjectManager::AddDynamicEntry(TGo4DynamicEntry* entry)
01104 {
01105    if(entry) entry->Reset();
01106    return AddObjectToFolder(entry, fxDynListDir, 0, kTRUE, kFALSE, kFALSE);
01107 }
01108 
01109 Bool_t TGo4AnalysisObjectManager::ResetBackStores(Bool_t clearflag)
01110 {
01111 TRACE((11,"TGo4AnalysisObjectManager::ResetBackStores()",__LINE__, __FILE__));
01112    Bool_t rev=kTRUE;
01113    TIter iter(fxStoreDir->GetListOfFolders());
01114    TObject* entry = 0;
01115    while((entry=iter()) !=0) {
01116       TGo4BackStore* bs= dynamic_cast<TGo4BackStore*>(entry);
01117       if(bs!=0) bs->Reset(clearflag);
01118    } // while
01119    return rev;
01120 }
01121 
01122 void TGo4AnalysisObjectManager::CloseAnalysis()
01123 {
01124 TRACE((14,"TGo4AnalysisObjectManager::CloseAnalysis()",__LINE__, __FILE__));
01125    ResetCurrentDynList();
01126    fiDynListCount=0;
01127    TGo4Analysis::Instance()->Message(0,"Analysis Object Manager  --  Dynamic List was reset.");
01128 }
01129 
01130 void TGo4AnalysisObjectManager::SaveObjects(TFile* file)
01131 {
01132    if(!file) return;
01133    TGo4Analysis::Instance()->Message(0,"Analysis Object Manager  --  Saving objects to file %s",file->GetName());
01134    fxGo4Dir->RecursiveRemove(fxTreeDir); // do not save the trees twice!
01135    fxGo4Dir->RecursiveRemove(fxAnalysisDir); // do not save eventclass refs
01137    //fxGo4Dir->Write(0, TObject::kOverwrite);
01140    TDirectory* savdir=gDirectory;
01141    file->cd();
01142    // file->Delete("T*;*"); // remove old contents (get rid of deleted dynamic objects)
01143    // note: we always use RECREATE option on saving now. No need to cleanup old file!
01144    SaveFolder(fxGo4Dir);
01145    file->Write(0,TObject::kOverwrite); // write all appended objects and subdirs
01146    savdir->cd();
01147    RemoveFromDir(fxGo4Dir,file); // prevent object deletion on closing the file
01149    fxGo4Dir->Add(fxTreeDir);
01150    fxGo4Dir->Add(fxAnalysisDir);
01151 }
01152 Bool_t TGo4AnalysisObjectManager::AddParameter(TGo4Parameter * par, const Text_t* subfolder)
01153 {
01154 TRACE((11,"TGo4AnalysisObjectManager::AddParameter(TGo4Parameter *)",__LINE__, __FILE__));
01155    return (AddObjectToFolder(par,fxParameterDir,subfolder,kTRUE));
01156 }
01157 
01158 Bool_t TGo4AnalysisObjectManager::SetParameter(const Text_t * name, TGo4Parameter * par, TFolder* parent)
01159 {
01160 TRACE((11,"TGo4AnalysisObjectManager::SetParameter(Text_t*, TGo4Parameter*)",__LINE__, __FILE__));
01161 Bool_t rev=kFALSE;
01162 TFolder* topfolder=0;
01163 if(parent)
01164    topfolder=parent;
01165 else
01166    topfolder=fxParameterDir;
01167 if(par)
01168    {
01169       TGo4Parameter* oldpar= dynamic_cast<TGo4Parameter *> (topfolder->FindObjectAny(name));
01170       if(oldpar!=0)
01171          {
01172             // update existing parameter of given name
01173             rev=oldpar->UpdateFrom(par);
01174             //cout << "++++ Updated parameter "<< name<<" from parameter "<< par->GetName() << endl;
01175             //oldpar->PrintParameter();
01176          }
01177       else
01178          {
01179             // parameter not yet exisiting, add external paramter as a copy:
01180              TGo4Parameter* clonedpar=dynamic_cast<TGo4Parameter*>(par->Clone());
01181               // find out destination folder for new parameter from name:
01182             Text_t subfolder[fguSUBFOLDERMAXLEN];
01183             size_t fnamelen=0;
01184             const char* endname = name;
01185             const char* foldername = name;
01186             while (endname!=0)
01187                {
01188                   endname=strstr(foldername,"/");
01189                   if(endname==0) break;
01190                   fnamelen= endname-name; // length of path string
01191                   foldername=endname+1;
01192                }
01193             if(fnamelen>0)
01194                 {
01195                    // we have a subfolder for condition
01196                    if(fnamelen>fguSUBFOLDERMAXLEN) fnamelen=fguSUBFOLDERMAXLEN;
01197                    snprintf(subfolder,fnamelen,"%s",name);
01198                    rev=AddObjectToFolder(clonedpar,topfolder,subfolder,kTRUE);
01199                    //cout << "++++ Added new parameter "<< clonedpar->GetName()<<" to folder "<<topfolder->GetName()<<"/"<< subfolder << endl;
01200                 }
01201              else
01202                 {
01203                    // no subfolder, condition is directly under topfolder
01204                    rev=AddObjectToFolder(clonedpar,topfolder,0,kTRUE);
01205                    //cout << "++++ Added new parameter "<< clonedpar->GetName()<<" to folder "<<topfolder->GetName()<<", no subfolder!!!"<< endl;
01206                 }
01207          }
01208    }
01209 else
01210    {
01211       rev=kFALSE;
01212    }
01213 return rev;
01214 }
01215 
01216 Bool_t TGo4AnalysisObjectManager::SetParameterStatus(const char* name, TGo4ParameterStatus* status, TFolder* parent)
01217 {
01218    TRACE((11,"TGo4AnalysisObjectManager::SetParameter(Text_t*, TGo4Parameter*)",__LINE__, __FILE__));
01219 
01220    if (status==0) return kFALSE;
01221 
01222    Bool_t rev=kFALSE;
01223    TFolder* topfolder = (parent!=0) ? parent : fxParameterDir;
01224 
01225    TGo4Parameter* oldpar= dynamic_cast<TGo4Parameter*> (topfolder->FindObjectAny(name));
01226    if(oldpar!=0) {
01227       // update existing parameter of given name
01228       rev = status->UpdateParameterValues(oldpar);
01229    } else {
01230       // parameter not yet exisiting, add external paramter as a copy:
01231       TGo4Parameter* clonedpar = status->CreateParameter();
01232       // find out destination folder for new parameter from name:
01233       Text_t subfolder[fguSUBFOLDERMAXLEN];
01234       size_t fnamelen=0;
01235       const char* endname = name;
01236       const char* foldername = name;
01237       while (endname!=0) {
01238           endname=strstr(foldername,"/");
01239           if(endname==0) break;
01240           fnamelen= endname-name; // length of path string
01241           foldername=endname+1;
01242       }
01243       if(fnamelen>0) {
01244          if(fnamelen>fguSUBFOLDERMAXLEN) fnamelen=fguSUBFOLDERMAXLEN;
01245          snprintf(subfolder,fnamelen,"%s",name);
01246          rev=AddObjectToFolder(clonedpar,topfolder,subfolder,kTRUE);
01247       } else {
01248          rev=AddObjectToFolder(clonedpar,topfolder,0,kTRUE);
01249       }
01250    }
01251    return rev;
01252 }
01253 
01254 
01255 
01256 TGo4Parameter * TGo4AnalysisObjectManager::GetParameter(const Text_t * name)
01257 {
01258 TRACE((11,"TGo4AnalysisObjectManager::GetParameter(Text_t*)",__LINE__, __FILE__));
01259    TGo4Parameter* rev=dynamic_cast<TGo4Parameter *> (FindObjectInFolder(fxParameterDir,name));
01260    if(rev==0) rev= dynamic_cast<TGo4Parameter *> (FindObjectInFolder(fxUserDir,name));
01261    return rev;
01262 }
01263 
01264 Bool_t TGo4AnalysisObjectManager::RemoveParameter(const Text_t * name)
01265 {
01266 TRACE((11,"TGo4AnalysisObjectManager::RemoveParameter(Text_t*)",__LINE__, __FILE__));
01267    return RemoveObjectFromFolder(name, fxParameterDir, kTRUE);
01268 }
01269 
01270 Bool_t TGo4AnalysisObjectManager::AddPicture(TGo4Picture * pic, const Text_t* subfolder)
01271 {
01272 TRACE((11,"TGo4AnalysisObjectManager::AddPicture(TGo4Picture *)",__LINE__, __FILE__));
01273 if(pic)
01274 {
01275    //pic->LocateObjectsFrom(fxGo4Dir);
01276    return (AddObjectToFolder(pic,fxPictureDir,subfolder,kTRUE));
01277 }
01278 else
01279    return kFALSE;
01280 }
01281 
01282 Bool_t TGo4AnalysisObjectManager::SetPicture(const Text_t * name, TGo4Picture * pic, TFolder* parent)
01283 {
01284 TRACE((11,"TGo4AnalysisObjectManager::SetPicture(Text_t*, TGo4Picture*)",__LINE__, __FILE__));
01285 Bool_t rev=kFALSE;
01286 TFolder* topfolder=0;
01287 if(parent)
01288    topfolder=parent;
01289 else
01290    topfolder=fxPictureDir;
01291 if(pic)
01292    {
01293       TGo4Picture* oldpic= dynamic_cast<TGo4Picture *> (topfolder->FindObjectAny(name));
01294       if(oldpic!=0)
01295          {
01296             // update existing picture of given name
01297             oldpic->UpdateFrom(pic);
01298 //            cout << "++++ Updated picture "<< name<<" from picture "<< pic->GetName() << endl;
01299          }
01300       else
01301          {
01302             // picture not yet exisiting, add external as a copy:
01303              TGo4Picture* clonedpic=dynamic_cast<TGo4Picture*>(pic->Clone());
01304               // find out destination folder for new pic from name:
01305             Text_t subfolder[fguSUBFOLDERMAXLEN];
01306             size_t fnamelen=0;
01307             const char* endname = name;
01308             const char* foldername = name;
01309             while (endname!=0)
01310                {
01311                   endname=strstr(foldername,"/");
01312                   if(endname==0) break;
01313                   fnamelen= endname-name; // length of path string
01314                   foldername=endname+1;
01315                }
01316             if(fnamelen>0)
01317                 {
01318                    // we have a subfolder for condition
01319                    if(fnamelen>fguSUBFOLDERMAXLEN) fnamelen=fguSUBFOLDERMAXLEN;
01320                    snprintf(subfolder,fnamelen,"%s",name);
01321                    rev=AddObjectToFolder(clonedpic,topfolder,subfolder,kTRUE);
01322                 }
01323              else
01324                 {
01325                    // no subfolder, condition is directly under topfolder
01326                    rev=AddObjectToFolder(clonedpic,topfolder,0,kTRUE);
01327                 }
01328          }
01329    }
01330 else
01331    {
01332       rev=kFALSE;
01333    }
01334 return rev;
01335 }
01336 
01337 TGo4Picture * TGo4AnalysisObjectManager::GetPicture(const Text_t * name)
01338 {
01339 TRACE((11,"TGo4AnalysisObjectManager::GetPicture(Text_t*)",__LINE__, __FILE__));
01340    TGo4Picture* rev=dynamic_cast<TGo4Picture *> (FindObjectInFolder(fxPictureDir, name));
01341    if(rev==0) rev=dynamic_cast<TGo4Picture *> (FindObjectInFolder(fxUserDir, name));
01342    return rev;
01343 }
01344 
01345 Bool_t TGo4AnalysisObjectManager::RemovePicture(const Text_t * name)
01346 {
01347 TRACE((11,"TGo4AnalysisObjectManager::RemovePicture(Text_t*)",__LINE__, __FILE__));
01348    return RemoveObjectFromFolder(name, fxPictureDir, kTRUE);
01349 }
01350 
01351 Bool_t TGo4AnalysisObjectManager::AddCanvas(TCanvas * can, const Text_t* subfolder)
01352 {
01353 TRACE((11,"TGo4AnalysisObjectManager::AddCanvas(TCanvas *)",__LINE__, __FILE__));
01354 Bool_t rev=AddObjectToFolder(can,fxCanvasDir,subfolder,kFALSE);
01355 if(rev && can) gROOT->GetListOfCanvases()->Remove(can);
01356    // make sure that root has no other reference to our canvas
01357 return rev;
01358 }
01359 
01360 TCanvas * TGo4AnalysisObjectManager::GetCanvas(const Text_t * name)
01361 {
01362 TRACE((11,"TGo4AnalysisObjectManager::GetPicture(Text_t*)",__LINE__, __FILE__));
01363    TCanvas* rev=dynamic_cast<TCanvas*> (FindObjectInFolder(fxCanvasDir, name));
01364    if(rev==0) rev=dynamic_cast<TCanvas*> (FindObjectInFolder(fxCanvasDir, name));
01365    return rev;
01366 }
01367 
01368 Bool_t TGo4AnalysisObjectManager::RemoveCanvas(const Text_t * name)
01369 {
01370 TRACE((11,"TGo4AnalysisObjectManager::RemovePicture(Text_t*)",__LINE__, __FILE__));
01371    return RemoveObjectFromFolder(name, fxCanvasDir, kTRUE);
01372 }
01373 
01374 
01375 
01376 
01377 
01378 Bool_t TGo4AnalysisObjectManager::LoadObjects(TFile* obfile)
01379 {
01380    TRACE((11,"TGo4AnalysisObjectManager::LoadObjects(TFile*)",__LINE__, __FILE__));
01381    Bool_t rev=kFALSE;
01382    if(obfile)
01383       {
01384          TObject* ob=obfile->Get(TGo4AnalysisObjectManager::fgcTOPFOLDER);
01385          TFolder* top= dynamic_cast<TFolder*>(ob);
01386          if(top)
01387             {
01388                // kept for backward compatibility: read folder struct directly
01389                //cout << "found top go4 folder "<< endl;
01390                rev=LoadFolder(top,fxGo4Dir,kFALSE);
01391             }
01392          else
01393             {
01394                // new: convert directory structure of file into folders
01395                //cout <<"LoadObjects with Dirscan..." << endl;
01396                rev=LoadFolder(obfile,fxGo4Dir,kFALSE);
01397             }
01398          TGo4PolyCond::CleanupSpecials(); // remove references to file cuts
01399          ResetCurrentDynList();
01400 
01401       }
01402    return rev;
01403 }
01404 
01405 void TGo4AnalysisObjectManager::ResetCurrentDynList()
01406 {
01407    TGo4DynamicList::ResetEntries(fxDynListDir);
01408 }
01409 
01410 void TGo4AnalysisObjectManager::ProcessDynamicList()
01411 {
01412    fiDynListCount++;
01413    // normally, all entries are processed eventwise
01414    // except for treehistogramentries
01415    Bool_t processtrees = (fiDynListCount % fiDynListInterval)==0;
01416    TGo4DynamicList::ProcessEntries(fxDynListDir, processtrees, GetDynListInterval());
01417    if(processtrees) ResetBackStores();
01418 }
01419 
01420 void TGo4AnalysisObjectManager::PrintDynamicList()
01421 {
01422    TGo4DynamicList::PrintEntries(fxDynListDir);
01423 }
01424 
01425 Bool_t TGo4AnalysisObjectManager::AddDynamicHistogram(const char* name,
01426                                                       const char* histo,
01427                                                       const char* hevx, const char* hmemx,
01428                                                       const char* hevy, const char* hmemy,
01429                                                       const char* hevz, const char* hmemz,
01430                                                       const char* condition,
01431                                                       const char* cevx, const char* cmemx,
01432                                                       const char* cevy, const char* cmemy)
01433 {
01434    if(name==0 || histo==0 || hevx==0 || hmemx==0) return kFALSE;
01435    TGo4HistogramEntry* entry = new TGo4HistogramEntry(name);
01436 
01437    entry->SetHistogramName(histo);
01438 
01439    if ((hevx!=0) && (hmemx!=0)) {
01440       entry->SetHisEventName(0, hevx);
01441       entry->SetHisVarName(0, hmemx);
01442    }
01443 
01444    if ((hevy!=0) && (hmemy!=0)) {
01445      entry->SetHisEventName(1, hevy);
01446      entry->SetHisVarName(1, hmemy);
01447    }
01448 
01449    if ((hevz!=0) && (hmemz!=0)) {
01450      entry->SetHisEventName(2, hevz);
01451      entry->SetHisVarName(2, hmemz);
01452    }
01453 
01454    if((condition!=0) && (cevx!=0) && (cmemx!=0)) {
01455        entry->SetConditionName(condition);
01456        entry->SetConEventName(0, cevx);
01457        entry->SetConVarName(0, cmemx);
01458        if((cevy!=0) && (cmemy!=0)) {
01459           entry->SetConEventName(1, cevy);
01460           entry->SetConVarName(1, cmemy);
01461        }
01462    }
01463 
01464    return AddDynamicEntry(entry);
01465 }
01466 
01467 Bool_t TGo4AnalysisObjectManager::AddTreeHistogram(const char* hisname, const char* treename, const char* varexp, const char* cutexp)
01468 {
01469 TRACE((11,"TGo4AnalysisObjectManager::AddTreeHistogram(Text_t*,...)",__LINE__, __FILE__));
01470   //
01471    Bool_t rev=kFALSE;
01472    TGo4TreeHistogramEntry* tentry =
01473       new TGo4TreeHistogramEntry(hisname, treename, varexp, cutexp);
01474    if(AddDynamicEntry(tentry)) {
01475       TGo4Analysis::Instance()->Message(0,"Analysis added tree histogram %s to dynamic list", tentry->GetName());
01476       rev=kTRUE;
01477    } else {
01478       TGo4Analysis::Instance()->Message(0,"!!! Analysis AddTreeHistogram- ERROR: entry %s already exists !!!", tentry->GetName());
01479       delete tentry;
01480    }
01481    return rev;
01482 }
01483 
01484 
01485 Bool_t TGo4AnalysisObjectManager::RemoveDynamicEntry(const char* entryname)
01486 {
01487    return RemoveObjectFromFolder(entryname, fxDynListDir, kTRUE);
01488 }
01489 
01490 
01491 TFolder* TGo4AnalysisObjectManager::FindSubFolder(TFolder* parent, const Text_t* subfolder, Bool_t create)
01492 {
01493 TRACE((11,"TGo4AnalysisObjectManager::FindSubFolder(TFolder*, const Text_t*, Bool_t)",__LINE__, __FILE__));
01494 TGo4LockGuard  dirguard(fxDirMutex);
01495    TFolder* result=0;
01496    if(parent==0) return 0;
01497    if(subfolder==0) return parent;
01498    Text_t subname[fguSUBFOLDERMAXLEN];
01499    size_t fnamelen=0;
01500    const char* endname = subfolder;
01501    const char* searchname = subfolder;
01502    endname=strstr(searchname,"/"); // find end of first subfolder string
01503    if(endname!=0)
01504       {
01505          // we have subfolder of subfolder, process recursively
01506          endname+=1;
01507          fnamelen= endname-searchname; // length of first subfolder name
01508          if(fnamelen>fguSUBFOLDERMAXLEN) fnamelen=fguSUBFOLDERMAXLEN;
01509          snprintf(subname,fnamelen,"%s",searchname);
01510          //cout <<" fffffff Searching for subfolder "<< subname << endl;
01511          TFolder* nextsubfolder=FindSubFolder(parent,subname,create); // get folder directly under parent
01512          result=FindSubFolder(nextsubfolder,endname,create); // search rest of path in this folder
01513       }
01514    else
01515       {
01516          // only one level of subfolder, find it directly
01517          TIter listiter(parent->GetListOfFolders());
01518          TObject* entry;
01519          while((entry=listiter()) !=0)
01520             if(entry->InheritsFrom(TFolder::Class()))
01521                  if(!strcmp(subfolder,entry->GetName())) {
01522                      result= dynamic_cast<TFolder*>(entry);
01523                      break;
01524                  }
01525          if(result==0 && create)
01526             {
01527                result=parent->AddFolder(subfolder,"UserFolder"); // create new subfolder if not found
01528             }
01529       } // if (endname!=0)
01530    return result;
01531 }
01532 
01533 
01534 Bool_t TGo4AnalysisObjectManager::AddObjectToFolder(TObject * ob,
01535                                                     TFolder* fold,
01536                                                     const char* subfolder,
01537                                                     Bool_t replace,
01538                                                     Bool_t uniquename,
01539                                                     Bool_t resetbits)
01540 {
01541 TRACE((11,"TGo4AnalysisObjectManager::AddObjectToFolder(TObject *, TFolder*, const Text_t*, Bool_t)",__LINE__, __FILE__));
01542 
01543 Bool_t rev=kTRUE;
01544 TGo4LockGuard  dirguard(fxDirMutex);
01545 if(fold==0) return kFALSE;
01546 if(ob)
01547    {
01548       if(resetbits)
01549          {
01550             ob->ResetBit(TGo4Status::kGo4NoReset);
01551             ob->ResetBit(TGo4Status::kGo4CanDelete); // default behaviour: allow reset, disable delete
01552          }
01553       Text_t obname[fguSUBFOLDERMAXLEN];
01554       Text_t subname[fguSUBFOLDERMAXLEN];
01555       if(subfolder)
01556          {
01557             // prepare given name of subfolder:
01558             snprintf(subname,fguSUBFOLDERMAXLEN,"%s",subfolder);
01559             Text_t* lastchar=subname + strlen(subname)-1;
01560             if (*lastchar=='/')
01561                *lastchar = 0;
01562 /*            if(!strcmp("/",lastchar))
01563                {
01564                   // last character of foldername is slash, ignore it!
01565                   snprintf(lastchar,1,"\0");
01566                }
01567 */
01568             snprintf(obname,fguSUBFOLDERMAXLEN,"%s/%s",subname,ob->GetName());
01569          }
01570       else
01571          {
01572             snprintf(obname,fguSUBFOLDERMAXLEN,"%s",ob->GetName());
01573          }
01574 
01575       TObject* oldob=0;
01576       if(uniquename)
01577          {
01578             // look for object of identical name anywhere in top folder
01579             oldob=fold->FindObjectAny( ob->GetName() );
01580          }
01581       else
01582          {
01583             // only check for objects that are in given subfolder
01584             oldob= fold->FindObjectAny(obname);
01585          }
01586       if(oldob)
01587          // is object already in folder?
01588          {
01589                //yes, shall we replace? check if pointers are identical first!
01590             if(replace && ob!=oldob)
01591                {
01592                   // remove old reference before adding new one:
01593                   fold->RecursiveRemove(oldob);
01594                   CleanupDynamicLists(oldob);
01595                   delete oldob;
01596                }
01597             else
01598                {
01599                   return kFALSE; // do not overwrite old one
01600                }
01601          }
01602       else   {}
01603     TFolder* addDir=0;
01604     if(subfolder)
01605        {
01606          addDir=FindSubFolder(fold,subname,kTRUE);
01607          if(addDir==0)
01608             {
01609             // should not happen: all specified subfolders should be created!
01610             addDir=fold;
01611             }
01612        }
01613     else
01614        {
01615           addDir=fold;
01616        } // if(subfolder)
01617     addDir->Add(ob);
01618     rev=kTRUE;
01619    }
01620 else
01621    {
01622       TRACE((12,"TGo4AnalysisObjectManager::AddObjectToFolder - zero object",__LINE__, __FILE__));
01623       rev=kFALSE;
01624    } // if(his)
01625 
01626 
01627 
01628 return rev;
01629 }
01630 
01631 
01632 Bool_t TGo4AnalysisObjectManager::RemoveObjectFromFolder(const Text_t* fullname, TFolder* fold, Bool_t isDel)
01633 {
01634 TRACE((11,"TGo4AnalysisObjectManager::RemoveObjectFromFolder(const Text_t*, TFolder*, Bool_t)",__LINE__, __FILE__));
01635 //
01636    if(fold==0) return kFALSE;
01637    TGo4LockGuard  dirguard(fxDirMutex);
01638    TNamed* obj = 0;
01639    Int_t buflen=fguSUBFOLDERMAXLEN;
01640    Text_t buffer[fguSUBFOLDERMAXLEN];
01641    if(fullname) {
01642       strncpy(buffer,fullname,buflen-10);
01643       obj = dynamic_cast<TNamed*> (fold->FindObjectAny(buffer));
01644    }
01645 
01646    if(obj!=0) {
01647       fold->RecursiveRemove(obj);
01648       CleanupDynamicLists(obj);
01649       if (isDel) delete obj;
01650       TGo4Analysis::Instance()->Message(0,"Analysis: removed object %s",buffer);
01651       return kTRUE;
01652    }
01653 
01654    TGo4Analysis::Instance()->Message(0,"!!! Analysis: removing object %s FAILED !!!",buffer);
01655    return kFALSE;
01656 }
01657 
01658 Bool_t TGo4AnalysisObjectManager::LoadFolder(TFolder* source, TFolder* destination, Bool_t replace)
01659 {
01660    if (source==0) return kFALSE;
01661 TRACE((11,"TGo4AnalysisObjectManager::LoadFolder(TFolder*, TFolder*, Bool_t replace)",__LINE__, __FILE__));
01662 TGo4LockGuard  dirguard(fxDirMutex);
01663 Bool_t rev=kTRUE;
01664 TIter folderiter(source->GetListOfFolders());
01665 TObject* ob=0;
01666 while(( ob=folderiter() ) !=0)
01667    {
01668       if(ob->InheritsFrom(TFolder::Class()))
01669          {
01670             TFolder* subfolder =dynamic_cast<TFolder*> (ob);
01671             if(subfolder)
01672                {
01673                   //cout <<"LLLLLL Load folder scanning subfolder "<< subfolder->GetName() << endl;
01674                   TFolder* subdest=FindSubFolder(destination,subfolder->GetName(), kTRUE);
01675                   LoadFolder(subfolder,subdest,replace); // recursively scan all subfolders
01676                }
01677          }
01678       else
01679          {
01680             rev=PutToFolder(ob,destination,replace);
01681          }
01682 } // while(..)
01683 return rev;
01684 }
01685 
01686 Bool_t TGo4AnalysisObjectManager::LoadFolder(TDirectory* source, TFolder* destination, Bool_t replace)
01687 {
01688 TRACE((11,"TGo4AnalysisObjectManager::LoadFolder(TDirectory*, TFolder*, Bool_t replace)",__LINE__, __FILE__));
01689 if(!source || !destination) return kFALSE;
01690 TGo4LockGuard  dirguard(fxDirMutex);
01691 Bool_t rev=kTRUE;
01692 TDirectory* savdir=gDirectory;
01693 source->cd(); // this is necessary to let the TKey::ReadObj work!
01694 source->ReadKeys();
01695 TIter keyiter(source->GetListOfKeys());
01696 TObject* keyob=0;
01697 TKey* key=0;
01698 while(( keyob=keyiter() ) !=0)
01699    {
01700       key=dynamic_cast<TKey*>(keyob);
01701       if(key==0)
01702         {
01703            TGo4Analysis::Instance()->Message(3,"Analysis LoadFolder: ZERO key in directory %s",
01704                           source->GetName());
01705            return kFALSE;
01706         }
01707       //cout <<"Reading key "<<key->GetName() << endl;
01708       TObject* ob=key->ReadObj();
01709       if(ob==0)
01710          {
01711              TGo4Analysis::Instance()->Message(2,"Analysis LoadFolder: Retrying to read key %s ...",
01712                           key->GetName());
01713             ob=source->Get(key->GetName());
01714             if(ob==0)
01715                {
01716                   TGo4Analysis::Instance()->Message(3,"Analysis LoadFolder: Failed to read key %s !",
01717                           key->GetName());
01718                   return kFALSE;
01719                }
01720          }
01721 
01722       if(ob->InheritsFrom(TDirectory::Class()))
01723          {
01724             TDirectory* subdir =dynamic_cast<TDirectory*> (ob);
01725             if(subdir)
01726                {
01727                   //cout <<"LLLLLL Load folder dir scanning for subdir "<< subdir->GetName() << endl;
01728                   Bool_t inpicturefolder=kFALSE;
01729                   if(!strcmp(subdir->GetName(),fgcPICTFOLDER)) inpicturefolder=kTRUE;
01730                   if(inpicturefolder) fbSuppressLoadHistograms=kTRUE;
01731                   TFolder* subdest=FindSubFolder(destination,subdir->GetName(), kTRUE);
01732                   rev=LoadFolder(subdir,subdest,replace); // recursively scan all subfolders
01733                   if(inpicturefolder) fbSuppressLoadHistograms=kFALSE;
01734                }
01735          }
01736       else
01737          {
01738             rev=PutToFolder(ob,destination,replace);
01739          }
01740 } // while(..)
01741 savdir->cd();
01742 return rev;
01743 }
01744 
01745 Bool_t TGo4AnalysisObjectManager::PutToFolder(TObject* ob, TFolder* destination, Bool_t replace)
01746 {
01747 if(!ob || !destination) return kFALSE;
01748 Bool_t rev=kTRUE;
01749 //cout <<"put to folder for "<<ob->GetName() << endl;
01750 if (ob->InheritsFrom(TGo4DynamicEntry::Class()))
01751 {
01752    // new autosave file structure will save dynamic entries independently:
01753    TGo4DynamicEntry* dentry =dynamic_cast<TGo4DynamicEntry*> ( ob->Clone() ); // deep copy of source object!
01754    AddDynamicEntry(dentry);
01755    //cout <<"Added dynamic entry from file: "<<dentry->GetName() << endl;
01756 }
01757 
01758 else if(ob->InheritsFrom(TGo4Parameter::Class()))
01759    {
01760       // parameters never replaced, but updated
01761       TGo4Parameter* par =dynamic_cast<TGo4Parameter*>(ob);
01762       SetParameter(ob->GetName(),par,destination);
01763    }
01764 else if(ob->InheritsFrom(TGo4Picture::Class()))
01765    {
01766       // pictures never replaced, but updated
01767       TGo4Picture* pic =dynamic_cast<TGo4Picture*>(ob);
01768       //cout <<"LLLLLoad Folder SetsPicture!!!!!" << endl;
01769       SetPicture(ob->GetName(),pic,destination);
01770    }
01771 else if(ob->InheritsFrom(TGo4Condition::Class()))
01772    {
01773       // conditions not replaced, but updated
01774       TGo4Condition* con =dynamic_cast<TGo4Condition*>(ob);
01775       SetAnalysisCondition(ob->GetName(),con,kTRUE, destination);
01776    }
01777 else if(ob->InheritsFrom(TH1::Class()))
01778    {
01779       if(fbSuppressLoadHistograms) return kFALSE;
01780       // test: do not clone histos, but change dir from asf file to memory
01781       TH1* his =dynamic_cast<TH1*>(ob);
01782        if(AddObjectToFolder(his,destination,0,replace,kFALSE,kFALSE))
01783          {
01784             his->SetDirectory(gROOT); // set directory for histos, needed for TTree::Draw
01785             TGo4Analysis::Instance()->Message(0,"Analysis LoadFolder: Histogram %s was loaded.",
01786                           his->GetName());
01787             //cout <<"Changed directory of histo "<<his->GetName() << endl;
01788          }
01789        else
01790         {
01791             // object already there and noreplace set: do not change dir
01792         }
01793    }
01794 else
01795    {
01796       TObject* addob =ob->Clone(); // deep copy of source object!
01797       if(AddObjectToFolder(addob,destination,0,replace))
01798          {
01799 
01800             TGo4Analysis::Instance()->Message(-1,"Analysis LoadFolder: Object %s was loaded.",
01801                           addob->GetName());
01802          }
01803       else
01804          {
01805             // object already there and noreplace set: delete clone
01806             delete addob;
01807          } // if(AddObjectToFolder(addob,destination,0,replace))
01808    }
01809 return rev;
01810 }
01811 
01812 
01813 
01814 Bool_t TGo4AnalysisObjectManager::SaveFolder(TFolder* source)
01815 {
01816    if (source==0) return kFALSE;
01817 TGo4LockGuard  dirguard(fxDirMutex);
01818 Bool_t rev=kTRUE;
01819 TIter folderiter(source->GetListOfFolders());
01820 TObject* ob=0;
01821 while(( ob=folderiter() ) !=0) {
01822       if(ob->InheritsFrom(TFolder::Class())) {
01823             TFolder* subfolder =dynamic_cast<TFolder*> (ob);
01824             if(subfolder)
01825                {
01826                   TDirectory* currentdir=gDirectory;
01827                   const Text_t* subfoldername=subfolder->GetName();
01828                   TDirectory* subdir=dynamic_cast<TDirectory*>(currentdir->Get(subfoldername));
01829                   if(subdir==0)
01830                      {
01831                         subdir=currentdir->mkdir(subfoldername,"subdir");
01832                         //cout <<"SSSS Save folder created subdir "<<subfoldername << endl;
01833                      }
01834                   else
01835                      {
01836                          //cout <<"SSSS Save folder found existing subdir "<<subfoldername << endl;
01837                      }
01838 
01839                   if(subdir)
01840                      {
01841                         subdir->cd();
01842                         //cout <<"SSSS Save folder scanning subfolder "<< subfolder->GetName() << endl;
01843                         SaveFolder(subfolder); // recursively scan all subfolders
01844                      }
01845                   else
01846                      {
01847                           TGo4Analysis::Instance()->Message(2,"Analysis SaveFolder: Could not assign subdirectory %s to folder.",
01848                                 subfoldername);
01849                      }
01850                   currentdir->cd();
01851                }
01852       } else
01853          AppendToDir(ob,gDirectory);
01854 } // while(..)
01855 return rev;
01856 }
01857 
01858 void TGo4AnalysisObjectManager::AppendToDir(TObject* ob, TDirectory* dir)
01859 {
01860 if(!ob || !dir) return;
01861 // note: we do not check for old objects anymore, because
01862 // file is generally cleaned up before writing now JA
01863 //TObject* oldob=dir->Get(ob->GetName());
01864 //if(oldob)
01865 //   {
01868 //   }
01869 dir->Append(ob);
01870 }
01871 
01872 void TGo4AnalysisObjectManager::RemoveFromDir(TFolder* fold, TDirectory* dir)
01873 {
01874    if((fold==0) || (dir==0)) return;
01875 
01876    TIter iter(fold->GetListOfFolders());
01877    TObject* ob = 0;
01878    while((ob = iter()) !=0) {
01879       if(ob->InheritsFrom(TFolder::Class())) {
01880          TFolder* subfolder =dynamic_cast<TFolder*> (ob);
01881          if(subfolder!=0)
01882             RemoveFromDir(subfolder,dir); // recursively scan all subfolders
01883       } else
01884          dir->RecursiveRemove(ob);
01885    }
01886 }
01887 
01888 Int_t TGo4AnalysisObjectManager::PrintFolder(TFolder* fold, Option_t* opt, const Text_t* expression)
01889 {
01890    if(fold==0) return 0;
01891 
01892    TRACE((11,"TGo4AnalysisObjectManager::PrintFolder(TFolder*, Option_t*)",__LINE__, __FILE__));
01893    TGo4LockGuard  dirguard(fxDirMutex);
01894    Int_t totalsize=0;
01895    TROOT::IndentLevel();
01896    TROOT::IncreaseDirLevel();
01897    cout <<"+Folder "<<fold->GetName()<<" content:" << endl;
01898    TIter listiter(fold->GetListOfFolders());
01899    TObject* ob=0;
01900    while((ob=listiter())!=0) {
01901       if(ob->InheritsFrom(TFolder::Class()))
01902           totalsize+=PrintFolder(dynamic_cast<TFolder*>(ob),opt,expression);
01903       else
01904 
01905       if(IsMatching(ob->GetName(),expression)) {
01906           TROOT::IndentLevel();
01907           ob->Print(opt);
01908           TGo4ObjectStatus* temp=CreateObjectStatus(ob);
01909           if(temp!=0) totalsize+=temp->GetObjectSize();
01910           delete temp;
01911       }
01912    }// while
01913    TROOT::DecreaseDirLevel();
01914    TROOT::IndentLevel();
01915    cout <<"++++End "<<fold->GetName()<<"++++++++++" << endl;
01916    return totalsize;
01917 }
01918 
01919 Bool_t TGo4AnalysisObjectManager::ClearFolder(TFolder* fold)
01920 {
01921    TRACE((11,"TGo4AnalysisObjectManager::ClearFolder(TFolder*, Option_t*)",__LINE__, __FILE__));
01922    if(fold==0) return kFALSE;
01923    TGo4LockGuard  dirguard(fxDirMutex);
01924    TIter iter(fold->GetListOfFolders());
01925    TObject* ob=0;
01926    while((ob=iter())!=0)
01927      if(ob->InheritsFrom(TFolder::Class()))
01928          ClearFolder(dynamic_cast<TFolder*>(ob));
01929      else
01930          ClearObject(ob);
01931    return kTRUE;
01932 }
01933 
01934 Bool_t TGo4AnalysisObjectManager::ClearObject(TObject* ob)
01935 {
01936 TRACE((11,"TGo4AnalysisObjectManager::ClearObject(TObject*)",__LINE__, __FILE__));
01937 Bool_t rev=kFALSE;
01938 if(ob)
01939    {
01940       if(ob->TestBit(TGo4Status::kGo4NoReset)) return kFALSE;
01941       rev=kTRUE;
01942       if(ob->InheritsFrom(TH1::Class()))
01943          {
01944              TH1* his= dynamic_cast<TH1*>(ob);
01945              his->Reset(); // histogram has no Clear implementation!
01946          }
01947       else if(ob->InheritsFrom(TGo4DynamicEntry::Class()))
01948          {
01949              TGo4DynamicEntry* entry = dynamic_cast<TGo4DynamicEntry*>(ob);
01950              if (entry!=0) entry->Reset(); // dynamic entry has no Clear implementation!
01951          }
01952       else if(ob->InheritsFrom(TGo4Picture::Class()))
01953          {
01954              TGo4Picture* pic= dynamic_cast<TGo4Picture*>(ob);
01955              pic->Reset(); // picture has no Clear implementation!
01956          }
01957       else if(ob->InheritsFrom(TGraph::Class()))
01958          {
01959             TGraph* gr= dynamic_cast<TGraph*>(ob);
01960             Int_t pn=gr->GetN();
01961             gr->Set(0); // clear array of points
01962             gr->Set(pn); // this should set all to 0
01963          }
01964      else if(ob->InheritsFrom(TMultiGraph::Class()))
01965          {
01966             TMultiGraph* mg= dynamic_cast<TMultiGraph*>(ob);
01967             TIter liter(mg->GetListOfGraphs());
01968             TObject* ob=0;
01969             while((ob=liter())!=0)
01970                   ClearObject(ob);
01971          }
01972       else if(ob->InheritsFrom(TGo4EventElement::Class()))
01973          {
01974             // nop, we do not allow a user clear from gui
01975             // on any event
01976             rev=kFALSE;
01977          }
01978       else if(ob->InheritsFrom(TTree::Class()))
01979          {
01980             // nop, we do not allow a user clear from gui
01981             // on any tree
01982             rev=kFALSE;
01983          }
01984       else
01985          {
01986              ob->Clear();
01987              // use virtual Clear of all objects
01988              // make sure that TNamed::Clear is overwritten in subclasses
01989          }
01990    }
01991 return rev;
01992 }
01993 
01994 
01995 Bool_t TGo4AnalysisObjectManager::DeleteFolder(TFolder* fold)
01996 {
01997    TRACE((11,"TGo4AnalysisObjectManager::DeleteFolder(TFolder*, Option_t*)",__LINE__, __FILE__));
01998    if (fold==0) return kFALSE;
01999 
02000    TGo4LockGuard  dirguard(fxDirMutex);
02001    TIter iter(fold->GetListOfFolders());
02002    TObject* ob=0;
02003    while((ob=iter())!=0)
02004      if(ob->InheritsFrom(TFolder::Class()))
02005         DeleteFolder(dynamic_cast<TFolder*>(ob));
02006      else
02007         DeleteObject(ob);
02008    return kTRUE;
02009 }
02010 
02011 Bool_t TGo4AnalysisObjectManager::DeleteObject(TObject* ob)
02012 {
02013 TRACE((11,"TGo4AnalysisObjectManager::DeleteObject(TObject*)",__LINE__, __FILE__));
02014 if(ob==0 || !ob->TestBit(TGo4Status::kGo4CanDelete) ) return kFALSE;
02015 fxGo4Dir->RecursiveRemove(ob);
02016 CleanupDynamicLists(ob);
02017 delete ob;
02018 return kTRUE;;
02019 }
02020 
02021 
02022 
02023 Bool_t TGo4AnalysisObjectManager::ProtectFolder(TFolder* fold, const Option_t* flags)
02024 {
02025    if(fold==0) return kFALSE;
02026    TGo4LockGuard  dirguard(fxDirMutex);
02027    TIter listiter(fold->GetListOfFolders());
02028    TObject* ob=0;
02029    while((ob=listiter.Next())!=0)
02030       if(ob->InheritsFrom(TFolder::Class()))
02031          ProtectFolder(dynamic_cast<TFolder*>(ob), flags);
02032       else
02033          ProtectObject(ob, flags);
02034    return kTRUE;
02035 }
02036 
02037 Bool_t TGo4AnalysisObjectManager::ProtectObject(TObject* ob, const Option_t* flags)
02038 {
02039   if((ob==0) || (flags==0)) return kFALSE;
02040   TString opt=flags;
02041   if(opt.Contains("+D")) ob->ResetBit(TGo4Status::kGo4CanDelete);
02042   if(opt.Contains("-D")) ob->SetBit(TGo4Status::kGo4CanDelete);
02043   if(opt.Contains("+C")) ob->SetBit(TGo4Status::kGo4NoReset);
02044   if(opt.Contains("-C")) ob->ResetBit(TGo4Status::kGo4NoReset);
02045   return kTRUE;
02046 }
02047 
02048 void TGo4AnalysisObjectManager::CleanupDynamicLists(TObject* oldobject)
02049 {
02050    TRACE((11,"TGo4AnalysisObjectManager::CleanupDynamicLists(TNamed*)",__LINE__, __FILE__));
02051    TGo4LockGuard  dirguard(fxDirMutex);
02052    if (oldobject==0) return;
02053    // scan all dynamic lists for this object:
02054     if(oldobject->InheritsFrom(TH1::Class()) ||
02055        oldobject->InheritsFrom(TGo4Condition::Class()) ||
02056        oldobject->InheritsFrom(TGo4EventElement::Class()))
02057          TGo4DynamicList::CleanupPointerInEntries(fxDynListDir, oldobject);
02058 }
02059 
02060 
02061 void TGo4AnalysisObjectManager::PrintConditions(const Text_t* expression)
02062 {
02063 TRACE((11,"TGo4AnalysisObjectManager::PrintConditions()",__LINE__, __FILE__));
02064 Int_t totalsize=PrintFolder(fxConditionDir,"*",expression);
02065 cout<<"___________________________________________________________"<<endl;
02066 cout << "Total size of all conditions is: "<<totalsize<<" bytes."<<endl;
02067 }
02068 
02069 void TGo4AnalysisObjectManager::PrintHistograms(const Text_t* expression)
02070 {
02071 TRACE((11,"TGo4AnalysisObjectManager::PrintHistograms()",__LINE__, __FILE__));
02072 Int_t totalsize=PrintFolder(fxHistogramDir,"*",expression);
02073 cout<<"___________________________________________________________"<<endl;
02074 cout << "Total size of all histograms is: "<<totalsize<<" bytes."<<endl;
02075 
02076 }
02077 
02078 TObject* TGo4AnalysisObjectManager::NextMatchingObject(const Text_t* expr,
02079                         const Text_t* folder,
02080                         Bool_t reset)
02081 {
02082    if(reset) {
02083       delete fxMatchIterator;
02084       delete fxMatchList;
02085       fxMatchList=CreateObjectList(expr,folder);
02086       fxMatchIterator=fxMatchList->MakeIterator();
02087    }
02088    return fxMatchIterator->Next();
02089 }
02090 
02091 TList* TGo4AnalysisObjectManager::CreateObjectList(const Text_t* expr, const Text_t* folder)
02092 {
02093 TGo4LockGuard  dirguard(fxDirMutex);
02094 TFolder* searchfold;
02095 if(folder==0 || !strcmp(folder,fgcTOPFOLDER))
02096    searchfold=fxGo4Dir; // default: search topfolder
02097 else
02098    searchfold=FindSubFolder(fxGo4Dir, folder, kFALSE);
02099 return (CreateObjectList(expr, searchfold));
02100 }
02101 
02102 
02103 TList* TGo4AnalysisObjectManager::CreateObjectList(const Text_t* expr, TFolder* fold)
02104 {
02105  TList* result=new TList;
02106  if(fold!=0) {
02107    TIter iter(fold->GetListOfFolders());
02108    TObject* entry=0;
02109    while((entry = iter())!=0) {
02110        if(entry->InheritsFrom(TFolder::Class())) {
02111            TFolder* subfold=dynamic_cast<TFolder*>(entry);
02112            TList* sublist=CreateObjectList(expr,subfold);
02113            // add sublist contents to our result list:
02114            result->AddAll(sublist);
02115        } else
02116        if(entry->InheritsFrom(TTree::Class())) {
02117        } else  // disable sending tree to gui!
02118        if(entry->InheritsFrom(TGo4EventElement::Class())) {
02119        } else // disable events
02120        if(entry->InheritsFrom(TGo4EventSource::Class())) {
02121        } else  // disable events
02122        if(entry->InheritsFrom(TGo4EventStore::Class())) {
02123        } else // disable events
02124        if(entry->InheritsFrom(TGo4EventProcessor::Class())) {
02125        } else { // disable events
02126          if(IsMatching(entry->GetName(),expr))
02127             result->AddLast(entry);
02128        }
02129    } // while
02130  } // if(fold)
02131  return result;
02132 }
02133 
02134 Bool_t TGo4AnalysisObjectManager::IsMatching(const Text_t* string, const Text_t* expression)
02135 {
02136 if(expression==0) return kTRUE;
02137 Bool_t ismatching=kFALSE;
02138 TString entrystring=string;
02139 TRegexp reg(expression,kTRUE);
02140 if(!strcmp(expression,"*"))
02141    ismatching=kTRUE; // take all in this folder
02142 //               else if (strstr(expression,string))
02143 //                  ismatching=kTRUE; // expression just contained in name
02144 else if (entrystring.Index(reg,0)!=kNPOS)
02145    ismatching=kTRUE; // root regular expression class
02146 else
02147    ismatching=kFALSE;
02148 return ismatching;
02149 }
02150 
02151 
02152 TObject* TGo4AnalysisObjectManager::FindObjectInFolder(TFolder*      folder,
02153                                                        const Text_t* fullname)
02154 {
02155    TRACE((12,"TGo4AnalysisObjectManager::FindObjectInFolder(TFolder*, const Text_t*)",__LINE__, __FILE__));
02156    TGo4LockGuard  listguard(fxDirMutex);
02157    return folder ? folder->FindObjectAny(fullname) : 0;
02158 }
02159 
02160 
02161 TObject* TGo4AnalysisObjectManager::TestObject(TFolder*     folder,
02162                                                const Text_t* &pathname,
02163                                                const Text_t* objectname,
02164                                                const TClass* cl)
02165 {
02166    TString fullname;
02167    if ((pathname!=0) && (strlen(pathname)==0)) pathname = 0;
02168    if (pathname) {
02169      fullname = pathname;
02170      fullname += "/";
02171    }
02172    fullname += objectname;
02173 
02174    TObject* obj = FindObjectInFolder(folder, fullname);
02175 
02176    if ((obj!=0) && (!obj->InheritsFrom(cl))) {
02177       RemoveObjectFromFolder(fullname, folder, kTRUE);
02178       obj = 0;
02179    }
02180 
02181    fbCreatedinMake = (obj==0);
02182    return obj;
02183 }
02184 
02185 
02186 
02187 
02188 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:04 2008 for Go4-v3.04-1 by  doxygen 1.4.2