StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEventBranch.cxx
1 /***************************************************************************
2  *
3  * $Id: StEventBranch.cxx,v 2.4 2004/01/30 20:24:03 perev Exp $
4  *
5  * Author: Victor Perev, May 2001
6  ***************************************************************************
7  *
8  * Description:
9  *
10  * Do not touch anything here unless you really know what you are doing.
11  *
12  ***************************************************************************
13  *
14  **************************************************************************/
15 #include "StEvent.h"
16 #include "StEventBranch.h"
17 #include "TObjectSet.h"
18 #include "TError.h"
19 #include "TDataSetIter.h"
20 //_____________________________________________________________________________
21 
22 ClassImp(StEventBranch)
23 //_____________________________________________________________________________
24 StEventBranch::StEventBranch(const char *brName, StEvent *evt,UInt_t tally)
25 : StXRef(brName,evt, tally)
26 {
27 }
28 //_____________________________________________________________________________
29 void StEventBranch::AddKlass(const char* className)
30 {
31  assert(FindByName(className)==0);
32  TObjectSet *to = new TObjectSet(className,0,0);
33  Add(to);
34 }
35 //_____________________________________________________________________________
36 void StEventBranch::Synchro(int toMain)
37 {
38  TDataSetIter next(this);
39 
40  TObjectSet *os;
41  TDataSet *ds;
42  TObject *to;
43  StObject *so;
44  StEvent *ste = (StEvent*)GetMain();
45  assert(ste);
46  StSPtrVecObject &cnt = ste->content();
47  int icl,cntSize = cnt.size();
48  while ((ds=next())) {// set loop
49  if (ds->IsA() != TObjectSet::Class()) continue;
50  const char *className = ds->GetName();
51  if (strncmp("St",className,2)!=0) continue;
52  os = (TObjectSet*)ds;
53  for (icl=0;icl<cntSize;icl++) {//contLoop
54  if (!(so = cnt[icl])) continue;
55  if (strcmp(className,so->ClassName())!=0) continue;
56  if (so->IsZombie()) continue;
57  break;
58  }//end contLoop
59  if (icl>=cntSize) so = 0;
60  os->DoOwner(0);
61  if (toMain) {
62  if (so) cnt.erase(cnt.begin()+icl);
63  to = os->GetObject();
64  if(to) cnt.StObjArray::push_back((StObject*)to);
65  os->SetObject(0,0);
66  } else {
67  os->SetObject(so,0);
68  }
69  } // set loop
70 }
71 
72 //_____________________________________________________________________________
73 StXRefMain *StEventBranch::MakeMain()
74 {
75  StEvent *e = new StEvent();
76  return e;
77 }
78 //_____________________________________________________________________________
79 void StEventBranch::Streamer(TBuffer &buf)
80 {
81  StXRef::Streamer(buf);
82 }
virtual Bool_t DoOwner(Bool_t done=kTRUE)
Definition: TObjectSet.cxx:85
virtual void SetObject(TObject *obj)
The depricated method (left here for the sake of the backward compatibility)
Definition: TObjectSet.h:59
virtual TDataSet * FindByName(const char *name, const char *path="", Option_t *opt="") const
Definition: TDataSet.cxx:378
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
Definition: TObjectSet.h:56