StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcread_dst_geant_Branch.C
1 // $Id: bfcread_dst_geant_Branch.C,v 1.6 2006/08/15 21:43:09 jeromel Exp $
2 // $Log: bfcread_dst_geant_Branch.C,v $
3 // Revision 1.6 2006/08/15 21:43:09 jeromel
4 // Fix rhic -> rhic.bnl.gov
5 //
6 // Revision 1.5 2000/05/09 20:15:44 kathy
7 // transfer obsolete macros to /macros/obsolete; update other macros so that they use standard default inputs plus only few events by default so they'll be easy to run in autoQA macro testing
8 //
9 // Revision 1.4 2000/05/03 18:25:46 kathy
10 // update to make consistent with other macros of same type
11 //
12 // Revision 1.3 2000/04/18 20:37:26 kathy
13 // St_DataSet,St_DataSetIter,St_Table classes are nowchanged to TDataSet,TDataSetIter,TTable
14 //
15 // Revision 1.2 2000/04/14 14:40:16 kathy
16 // put in correct default input data set
17 //
18 // Revision 1.1 2000/04/14 14:36:58 kathy
19 // new example to read and examine 2 different branchs - dst & geant - of DST output
20 //
21 //======================================================================
22 // owner: Kathy Turner
23 // what it does: reads .dst.root file produced from bfc & shows how
24 // to find the dst tables
25 // - sets branch to dstBranch
26 // - gets Data Set "dst"
27 // - prints out list of tables & # rows it finds
28 //
29 //=======================================================================
30 
31 class StChain;
32 StChain *chain;
33 
34 void bfcread_dst_geant_Branch(
35  Int_t nevents=2,
36  const char *MainFile=
37  "/afs/rhic.bnl.gov/star/data/samples/gstar.dst.root",
38  const char *fname="qa_dst_geant.out")
39 {
40 //
41 
42  cout << " events to process = " << nevents << endl;
43  cout << " Input File Name = " << MainFile << endl;
44  cout << " Output file containing printouts = " << fname << endl;
45 
46  ofstream fout(fname);
47 
48  fout << " Running: bfcread_dst_geant_Branch.C " << endl;
49  fout << " events to process = " << nevents << endl;
50  fout << " Input File Name = " << MainFile << endl;
51  fout << " Output file containing printouts = " << fname << endl;
52  fout << endl << endl;
53 
54 
55  gSystem->Load("St_base");
56  gSystem->Load("StChain");
57 
58  gSystem->Load("libglobal_Tables");
59  gSystem->Load("libgen_Tables");
60  gSystem->Load("libsim_Tables");
61 
62  gSystem->Load("StIOMaker");
63 
64 // Setup top part of chain
65  chain = new StChain("bfc");
66  chain->SetDebug();
67 
68  StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,"bfcTree");
69  IOMk->SetDebug();
70  IOMk->SetIOMode("r");
71  IOMk->SetBranch("*",0,"0"); //deactivate all branches
72  IOMk->SetBranch("dstBranch",0,"r"); //activate dst Branch
73  IOMk->SetBranch("geantBranch",0,"r"); //activate dst Branch
74 
75 // --- now execute chain member functions
76  chain->Init();
77 
78  TDataSet *ds=0;
79  TTable *tabl=0;
80  TDataSet *obj=0;
81 
82  Float_t tottabcntrdst=0;
83  Float_t tottabcntrgeant=0;
84 
85  Float_t totobjcntrdst=0;
86  Float_t totobjcntrgeant=0;
87 
88  int istat=0;
89  int i=0;
90 
91  int countev=0;
92 
93  int countevgds=0;
94  int countevgobj=0;
95  int countevgtab=0;
96 
97  int countevdds=0;
98  int countevdobj=0;
99  int countevdtab=0;
100 
101 // Event loop
102 EventLoop: if (i < nevents && !istat) {
103 
104  chain->Clear();
105  istat = chain->Make(i);
106 
107 // count # times Make is called
108  i++;
109 
110  // cout << " Call Make # " << i << endl;
111  // cout << " istat value returned from chain Make = " << istat << endl;
112 
113 
114 // Now look at the data in the event:
115  int countObjDst=0;
116  int countObjGeant=0;
117  int countTableDst=0;
118  int countTableGeant=0;
119 
120  if (!istat) {
121 
122  countev++;
123 
124  cout << " start event # " << countev << endl;
125 
126 // ------------ dst branch ------------------------------
127 
128  ds=chain->GetDataSet("dst");
129  TDataSetIter tabiter(ds);
130  if (ds) {
131  countevdds++;
132 
133  while (obj = tabiter.Next()) {
134  cout << " QAInfo: dst, found object: " << obj->GetName() << endl;
135  fout << " QAInfo: dst, found object: " << obj->GetName() << endl;
136 
137  countObjDst++;
138  totobjcntrdst++;
139 
140 //.. count all tables that exist:
141  if (obj->InheritsFrom("TTable")) {
142  tabl = (TTable *)tabiter.Find(obj->GetName());
143  if (tabl) {
144  countTableDst++;
145  tottabcntrdst++;
146  cout << " QAInfo: it's a table with #rows = "
147  << tabl->GetNRows() << endl;
148  fout << " QAInfo: it's a table with #rows = "
149  << tabl->GetNRows() << endl;
150  } // tabl
151  } // obj
152 
153 //.. end of counting all tables that exist
154  } // while
155  if (countObjDst) countevdobj++;
156  if (countTableDst) countevdtab++;
157  } // ds
158 
159 // ------------ dst branch ------------------------------
160 
161 
162 // ------------ geant branch ------------------------------
163 
164  ds=chain->GetDataSet("geant");
165  TDataSetIter tabiter(ds);
166  if (ds) {
167  countevgds++;
168 
169  while (obj = tabiter.Next()) {
170  cout << " QAInfo: geant, found object: " << obj->GetName() << endl;
171  fout << " QAInfo: geant, found object: " << obj->GetName() << endl;
172 
173  countObjGeant++;
174  totobjcntrgeant++;
175 
176 //.. count all tables that exist:
177  if (obj->InheritsFrom("TTable")) {
178  tabl = (TTable *)tabiter.Find(obj->GetName());
179  if (tabl) {
180  countTableGeant++;
181  tottabcntrgeant++;
182  cout << " QAInfo: it's a table with #rows = "
183  << tabl->GetNRows() << endl;
184  fout << " QAInfo: it's a table with #rows = "
185  << tabl->GetNRows() << endl;
186  } // tabl
187  } // obj
188 
189 //.. end of counting all tables that exist
190  } // while
191  if (countObjGeant) countevgobj++;
192  if (countTableGeant) countevgtab++;
193  } // ds
194 
195 // ------------ geant branch ------------------------------
196 
197  cout << " QAInfo: event # " << countev <<
198  ", DST Branch - # objects found = "
199  << countObjDst << ", # tables found = "
200  << countTableDst << endl;
201  cout << " QAInfo: event # " << countev <<
202  ", GEANT Branch - # objects found = "
203  << countObjGeant << ", # tables found = "
204  << countTableGeant << endl << endl;
205 
206 
207  fout << " QAInfo: event # " << countev <<
208  ", DST Branch - # objects found = "
209  << countObjDst << ", # tables found = "
210  << countTableDst << endl;
211  fout << " QAInfo: event # " << countev <<
212  ", GEANT Branch - # objects found = "
213  << countObjGeant << ", # tables found = "
214  << countTableGeant << endl << endl;
215 
216  } // istat
217 
218  else // if (istat)
219  {
220  cout << "Last event processed. Status = " << istat << endl;
221  }
222 
223  goto EventLoop;
224 
225 } // EventLoop
226 
227  tottabcntrdst /= countev;
228  totobjcntrdst /= countev;
229  tottabcntrgeant /= countev;
230  totobjcntrgeant /= countev;
231 
232  cout << endl;
233  cout << "QAInfo: End of Job " << endl;
234  cout << "QAInfo: # times Make called = " << i << endl;
235  cout << "QAInfo: # events read = " << countev << endl;
236  cout << "QAInfo: # events with geant dataset = " << countevgds << endl;
237  cout << "QAInfo: # with objects = " << countevgobj << endl;
238  cout << "QAInfo: # with tables = " << countevgtab << endl;
239  cout << "QAInfo: avg # tables per event = " << tottabcntrgeant << endl;
240  cout << "QAInfo: avg # objects per event = " << totobjcntrgeant << endl
241  << endl;
242  cout << "QAInfo: # events with dst dataset = " << countevdds << endl;
243  cout << "QAInfo: # with objects = " << countevdobj << endl;
244  cout << "QAInfo: # with tables = " << countevdtab << endl;
245  cout << "QAInfo: avg # tables per event = " << tottabcntrdst << endl;
246  cout << "QAInfo: avg # objects per event = " << totobjcntrdst << endl
247  << endl;
248 
249  fout << endl;
250  fout << "QAInfo: # times Make called = " << i << endl;
251  fout << "QAInfo: # events read = " << countev << endl;
252  fout << "QAInfo: # events with geant dataset = " << countevgds << endl;
253  fout << "QAInfo: # with objects = " << countevgobj << endl;
254  fout << "QAInfo: # with tables = " << countevgtab << endl;
255  fout << "QAInfo: avg # tables per event = " << tottabcntrgeant << endl;
256  fout << "QAInfo: avg # objects per event = " << totobjcntrgeant << endl
257  << endl;
258  fout << "QAInfo: # events with dst dataset = " << countevdds << endl;
259  fout << "QAInfo: # with objects = " << countevdobj << endl;
260  fout << "QAInfo: # with tables = " << countevdtab << endl;
261  fout << "QAInfo: avg # tables per event = " << tottabcntrdst << endl;
262  fout << "QAInfo: avg # objects per event = " << totobjcntrdst << endl
263  << endl;
264 
265 
266  chain->Finish();
267 }
268 
269 
270 
271 
272 
273 
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
Definition: StIOInterFace.h:35
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Finish()
Definition: StChain.cxx:85
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
Definition: TTable.cxx:1388
virtual TDataSet * Next() const
Definition: TDataSet.cxx:447
virtual Int_t Make()
Definition: StChain.cxx:110
Definition: TTable.h:48
virtual TDataSet * Find(const char *path) const
Definition: TDataSet.cxx:362