00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "StEvent.h"
00016 #include "StEventBranch.h"
00017 #include "TObjectSet.h"
00018 #include "TError.h"
00019 #include "TDataSetIter.h"
00020
00021
00022 ClassImp(StEventBranch)
00023
00024 StEventBranch::StEventBranch(const char *brName, StEvent *evt,UInt_t tally)
00025 : StXRef(brName,evt, tally)
00026 {
00027 }
00028
00029 void StEventBranch::AddKlass(const char* className)
00030 {
00031 assert(FindByName(className)==0);
00032 TObjectSet *to = new TObjectSet(className,0,0);
00033 Add(to);
00034 }
00035
00036 void StEventBranch::Synchro(int toMain)
00037 {
00038 TDataSetIter next(this);
00039
00040 TObjectSet *os;
00041 TDataSet *ds;
00042 TObject *to;
00043 StObject *so;
00044 StEvent *ste = (StEvent*)GetMain();
00045 assert(ste);
00046 StSPtrVecObject &cnt = ste->content();
00047 int icl,cntSize = cnt.size();
00048 while ((ds=next())) {
00049 if (ds->IsA() != TObjectSet::Class()) continue;
00050 const char *className = ds->GetName();
00051 if (strncmp("St",className,2)!=0) continue;
00052 os = (TObjectSet*)ds;
00053 for (icl=0;icl<cntSize;icl++) {
00054 if (!(so = cnt[icl])) continue;
00055 if (strcmp(className,so->ClassName())!=0) continue;
00056 if (so->IsZombie()) continue;
00057 break;
00058 }
00059 if (icl>=cntSize) so = 0;
00060 os->DoOwner(0);
00061 if (toMain) {
00062 if (so) cnt.erase(cnt.begin()+icl);
00063 to = os->GetObject();
00064 if(to) cnt.StObjArray::push_back((StObject*)to);
00065 os->SetObject(0,0);
00066 } else {
00067 os->SetObject(so,0);
00068 }
00069 }
00070 }
00071
00072
00073 StXRefMain *StEventBranch::MakeMain()
00074 {
00075 StEvent *e = new StEvent();
00076 return e;
00077 }
00078
00079 void StEventBranch::Streamer(TBuffer &buf)
00080 {
00081 StXRef::Streamer(buf);
00082 }