StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StStrangeControllerBase.h
1 // $Id: StStrangeControllerBase.h,v 3.6 2003/05/30 21:20:19 genevb Exp $
2 // $Log: StStrangeControllerBase.h,v $
3 // Revision 3.6 2003/05/30 21:20:19 genevb
4 // doxygen savvy, encoding of FTPC mults, change virtual funcs
5 //
6 // Revision 3.5 2001/09/14 21:39:02 genevb
7 // Adjustments to not depend on order in which maker Clear() is called
8 //
9 // Revision 3.4 2001/08/23 13:20:53 genevb
10 // Many bug workarounds...
11 //
12 // Revision 3.2 2000/12/18 21:35:18 genevb
13 // Introduced variable buffer-sizing
14 //
15 // Revision 3.1 2000/07/17 20:28:40 genevb
16 // File size limitation workaround, some under the hood improvements
17 //
18 // Revision 3.0 2000/07/14 12:56:48 genevb
19 // Revision 3 has event multiplicities and dedx information for vertex tracks
20 //
21 // Revision 2.1 2000/06/09 22:17:10 genevb
22 // Allow MC data to be copied between DSTs, other small improvements
23 //
24 // Revision 2.0 2000/06/05 05:19:41 genevb
25 // New version of Strangeness micro DST package
26 //
27 //
28 #ifndef STAR_StStrangeControllerBase
29 #define STAR_StStrangeControllerBase
30 // //
32 // StStrangeControllerBase strangeness micro DST controller base class //
33 // //
35 #include "TNamed.h"
36 #include "TClonesArray.h"
37 
38 class TTree;
39 class TArrayI;
40 class TArrayS;
41 class StEvent;
42 class StMcVertex;
43 class StAssociationMaker;
44 class StStrangeMuDst;
45 class StStrangeAssoc;
47 class TBranch;
48 class TClass;
49 
50 enum StrBranchType {dataBranch=0, mcBranch=1, assocBranch};
51 
52 class StStrangeControllerBase : public TNamed {
53  public:
54  StStrangeControllerBase(Int_t type);
55  virtual ~StStrangeControllerBase();
56  static StStrangeControllerBase* Instantiate(Int_t type);
57 
58  TClonesArray* GetArray(Int_t branchType);
59  TClonesArray* GetDataArray();
60  TClonesArray* GetMcArray();
61  TClonesArray* GetAssocArray();
62 
63  Int_t GetN(Int_t branchType);
64  Int_t GetN();
65  Int_t GetNMc();
66  Int_t GetNAssoc();
67 
68  StStrangeMuDst* Get(Int_t i, Int_t branchType);
69  StStrangeMuDst* Get(Int_t i=0);
70  StStrangeMuDst* GetMc(Int_t i = 0);
71  StStrangeAssoc* GetAssoc(Int_t i = 0);
72 
73  virtual void Clear(Option_t* opt=0);
74  virtual void Finish();
75 
76  // Functions for sub-dsts:
77  virtual void Select(Int_t i=-1); // use i<0 to specify whole event
78  virtual void Unselect(Int_t i=-1); // use i<0 to specify whole event
79 
80  virtual void InitReadDst();
81  virtual void InitCreateDst();
82  virtual void InitCreateSubDst();
83  virtual Int_t MakeReadDst() = 0;
84  virtual Int_t MakeCreateDst(StEvent& event) = 0;
85  virtual Int_t MakeCreateMcDst(StMcVertex* mcVert) = 0;
86  virtual Int_t MakeCreateSubDst();
87 
88  TClass* GetDataClass() const;
89  TClass* GetMcClass() const;
90  TClass* GetAssocClass() const;
91 
92  void PrintNumMc();
93  const char* GetMcName() const;
94  const char* GetAssocName() const;
95  void SetBufferSize(Int_t b);
96  static StStrangeMuDstMaker* currentMaker;
97 
98  protected:
99  StStrangeControllerBase* GetDstController();
100  void PrintNumCand(const char* text, Int_t num);
101  TBranch* AssignBranch(const char* name, TClonesArray** address);
102 
103  Bool_t doMc;
104 
105  TClonesArray* dataArray;
106  TClonesArray* mcArray;
107  TClonesArray* assocArray;
108  TClonesArray* tempArray;
109 
110  StStrangeMuDstMaker* masterMaker;
111  StStrangeMuDstMaker* dstMaker;
112  StAssociationMaker* assocMaker;
113 
114  TTree* tree;
115  char* file;
116  Int_t dstType;
117  TClass* dataClass;
118  TClass* mcClass;
119  TClass* assocClass;
120 
121  // Array of muDst indices to copy
122  TArrayI* selections;
123  TArrayS* keepers;
124 
125  // Totals for entire set
126  Int_t nEntries;
127 
128  // Totals for events
129  Int_t entries;
130  Int_t mcEntries;
131  Int_t assocEntries;
132 
133  Int_t increment;
134  Int_t max;
135  Int_t bsize;
136  TString mcName;
137  TString assocName;
138 
139  private:
140  ClassDef(StStrangeControllerBase,3)
141 };
142 
143 inline TClonesArray* StStrangeControllerBase::GetDataArray()
144  { return dataArray; }
145 inline TClonesArray* StStrangeControllerBase::GetMcArray()
146  { return mcArray; }
147 inline TClonesArray* StStrangeControllerBase::GetAssocArray()
148  { return assocArray; }
149 
150 inline Int_t StStrangeControllerBase::GetN(Int_t branchType)
151  { TClonesArray* array = GetArray(branchType);
152  return (array ? array->GetEntriesFast() : 0); }
153 inline Int_t StStrangeControllerBase::GetN()
154  { return (dataArray ? dataArray->GetEntriesFast() : 0); }
155 inline Int_t StStrangeControllerBase::GetNMc()
156  { return (mcArray ? mcArray->GetEntriesFast() : 0); }
157 inline Int_t StStrangeControllerBase::GetNAssoc()
158  { return (assocArray ? assocArray->GetEntriesFast() : 0); }
159 
160 inline StStrangeMuDst* StStrangeControllerBase::Get(Int_t i, Int_t branchType)
161  { TClonesArray* array = GetArray(branchType);
162  return (array ? (StStrangeMuDst*) (*array)[i] : 0); }
163 inline StStrangeMuDst* StStrangeControllerBase::Get(Int_t i)
164  { return (dataArray ? (StStrangeMuDst*) (*dataArray)[i] : 0); }
165 inline StStrangeMuDst* StStrangeControllerBase::GetMc(Int_t i)
166  { return (mcArray ? (StStrangeMuDst*) (*mcArray)[i] : 0); }
167 inline StStrangeAssoc* StStrangeControllerBase::GetAssoc(Int_t i)
168  { return (assocArray ? (StStrangeAssoc*) (*assocArray)[i] : 0); }
169 
170 inline TClass* StStrangeControllerBase::GetDataClass() const
171  { return dataClass; }
172 inline TClass* StStrangeControllerBase::GetMcClass() const
173  { return mcClass; }
174 inline TClass* StStrangeControllerBase::GetAssocClass() const
175  { return assocClass; }
176 
177 inline const char* StStrangeControllerBase::GetMcName() const
178  { return mcName.Data(); }
179 inline const char* StStrangeControllerBase::GetAssocName() const
180  { return assocName.Data(); }
181 
182 inline void StStrangeControllerBase::SetBufferSize(Int_t b) { bsize = b; }
183 #endif