StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcread_dstBranch.C
1 // $Id: bfcread_dstBranch.C,v 1.18 2006/08/15 21:43:08 jeromel Exp $
2 // $Log: bfcread_dstBranch.C,v $
3 // Revision 1.18 2006/08/15 21:43:08 jeromel
4 // Fix rhic -> rhic.bnl.gov
5 //
6 // Revision 1.17 2000/06/20 14:03:04 kathy
7 // now unpack and print out BfcStatus table, if it exists, from .event.root file
8 //
9 // Revision 1.16 2000/06/19 16:19:56 kathy
10 // fixed counthold defnition
11 //
12 // Revision 1.15 2000/06/13 15:41:44 kathy
13 // add a few more counters so we know how many events have dst tables and how many have RunEvent object
14 //
15 // Revision 1.14 2000/06/02 19:33:35 kathy
16 // now unpack and print out contents of BfcStatus table every event
17 //
18 // Revision 1.13 2000/06/01 18:57:03 kathy
19 // updating to separate out BfcStatus stats
20 //
21 // Revision 1.12 2000/06/01 18:13:27 kathy
22 // update to print out info needed properly
23 //
24 // Revision 1.11 2000/05/31 21:25:17 kathy
25 // updated so it now finds all tables/objects (e.g. BfcStatus) under dstBranch
26 //
27 // Revision 1.10 2000/05/03 18:36:30 kathy
28 // ooopps - my mistake - autoQA is using bfcread_dstBranch now instead of QA_bfcread_dst_tables - so put it back in...
29 //
30 //======================================================================
31 // owner: Kathy Turner
32 // what it does: reads .dst.root file produced from bfc & then goes to
33 // the dst branch
34 // - finds data set "dst"
35 // - loops over and prints out list of objects
36 // and tables
37 //
38 // Inputs to macro:
39 // nevents - # events to process
40 // MainFile - input *.dst.root file (you can use any branch here)
41 // fname - output file name with qa info
42 //
43 //
44 //======================================================================
45 
46 class StChain;
47 StChain *chain;
48 
49 void bfcread_dstBranch(
50  Int_t nevents=2,
51  const char *MainFile=
52  "/afs/rhic.bnl.gov/star/data/samples/gstar.dst.root",
53  const char *fname="qa_dst.out")
54 {
55 //
56  cout << " events to process = " << nevents << endl;
57  cout << " Input File Name = " << MainFile << endl;
58  cout << " Output file containing printouts = " << fname << endl;
59 
60  ofstream fout(fname);
61 
62  fout << " Running: bfcread_dstBranch.C " << endl;
63  fout << " events to process = " << nevents << endl;
64  fout << " Input File Name = " << MainFile << endl;
65  fout << " Output file containing printouts = " << fname << endl;
66  fout << endl << endl;
67 
68  gSystem->Load("St_base");
69  gSystem->Load("StChain");
70  gSystem->Load("libglobal_Tables");
71  gSystem->Load("StIOMaker");
72 
73 // Setup top part of chain
74  chain = new StChain("bfc");
75  chain->SetDebug();
76 
77  StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,"bfcTree");
78  IOMk->SetDebug();
79  IOMk->SetIOMode("r");
80  IOMk->SetBranch("*",0,"0"); //deactivate all branches
81  IOMk->SetBranch("dstBranch",0,"r"); //activate dst Branch
82 
83 // --- now execute chain member functions
84  chain->Init();
85 
86  TTable *tabl=0;
87 
88  TDataSet *obj=0;
89  TDataSet *ddb=0;
90  TDataSet *ddstBranch=0;
91 
92  int istat=0;
93  int iev=0;
94 
95  Float_t countev=0.0;
96 
97  Float_t countevdstB=0.0;
98  Float_t countevdst=0.0;
99  Float_t countevdstTab=0.0;
100  Float_t countevdstRE=0.0;
101  Float_t countevobjd=0.0;
102  Float_t countevtabd=0.0;
103  Float_t countevobjb=0.0;
104  Float_t countevtabb=0.0;
105 
106 // Event loop
107 EventLoop: if (iev < nevents && !istat) {
108 
109  Int_t Countevobjd=0;
110  Int_t Countevtabd=0;
111  Int_t Countevobjb=0;
112  Int_t Countevtabb=0;
113 
114  Int_t counthold=0;
115  Int_t countre=0;
116 
117  chain->Clear();
118  istat = chain->Make(iev);
119 
120 // count # times Make is called
121  iev++;
122 
123  cout << " Call Make # " << iev << endl;
124  cout << " istat value returned from chain Make = " << istat << endl;
125 
126  if (!istat) {
127 
128  countev++;
129  cout << " start event # " << countev << endl;
130  fout << " start event # " << countev << endl;
131 
132  ddstBranch=chain->GetDataSet("dstBranch");
133 
134  TDataSetIter dstbranchIter(ddstBranch);
135 
136  if (ddstBranch) {
137 
138  countevdstB++;
139 
140  cout << endl << " QAInfo: in dstBranch " << endl;
141  fout << endl << " QAInfo: in dstBranch " << endl;
142 
143  while (ddb=dstbranchIter.Next()) {
144 
145  cout << endl << " QAInfo: found object: " << ddb->GetName() << endl;
146  fout << endl << " QAInfo: found object: " << ddb->GetName() << endl;
147 
148  TString dsName = ddb->GetName();
149 
150  if (dsName == "BfcStatus") {
151  countevobjb++;
152  Countevobjb++;
153  }
154  else {
155  countevobjd++;
156  Countevobjd++;
157  }
158 
159  if (ddb->InheritsFrom("TTable")) {
160 
161  tabl = (TTable *)ddb;
162  cout << " QAInfo: it's a table with #rows = "
163  << tabl->GetNRows() << endl;
164  fout << " QAInfo: it's a table with #rows = "
165  << tabl->GetNRows() << endl;
166 
167  if (dsName == "BfcStatus") {
168  countevtabb++;
169  Countevtabb++;
170 // Now print out contents of BfcStatus for QA purposes
171  TDataSetIter bfcstatiter(ddb);
172  St_dst_bfc_status *bfcstat =
173  (St_dst_bfc_status *) bfcstatiter.Find("BfcStatus");
174  dst_bfc_status_st *bth = bfcstat->GetTable();
175 // loop over all rows in table BfcStatus:
176  Int_t ij = 0;
177  for (ij=0; ij< bfcstat->GetNRows(); ij++)
178  {
179  cout << " QAInfo: BfcStatus table -- row " << ij <<
180  ", Maker: " << bth[ij]->maker_name <<
181  " has istat = " << bth[ij]->status << endl;
182  fout << " QAInfo: BfcStatus table -- row " << ij <<
183  ", Maker: " << bth[ij]->maker_name <<
184  " has istat = " << bth[ij]->status << endl;
185  }
186  }
187  else{
188  countevtabd++;
189  Countevtabd++;
190  }
191 
192  }
193 
194 // now look under dst branch
195  if (dsName == "dst") {
196 
197  countevdst++;
198 
199  cout << " QAInfo: in dst object " << endl;
200  fout << " QAInfo: in dst object " << endl;
201 
202 // look for dst objects/tables
203 
204  TDataSetIter tabiter(ddb);
205 
206 // ddb->ls(2);
207  while (obj = tabiter.Next()) {
208 
209  cout << " QAInfo: found object: " << obj->GetName() << endl;
210  fout << " QAInfo: found object: " << obj->GetName() << endl;
211 
212  countevobjd++;
213  Countevobjd++;
214 
215  TString dstobjName = obj->GetName();
216  if (dstobjName == "RunEvent") {
217  countre=1;
218  }
219 
220 //.. count all tables that exist:
221  if (obj->InheritsFrom("TTable")) {
222  tabl = (TTable *)tabiter.Find(obj->GetName());
223  if (tabl) {
224  counthold=1;
225  countevtabd++;
226  Countevtabd++;
227 
228  cout << " QAInfo: it's a table with #rows = "
229  << tabl->GetNRows() << endl;
230  fout << " QAInfo: it's a table with #rows = "
231  << tabl->GetNRows() << endl;
232 
233  } // tabl
234  } // obj
235 //.. end of counting all tables that exist
236 
237  } // while obj
238 
239  } // dsName = dst
240 
241 
242  } // while dstBranch
243 
244  cout << endl << " QAInfo: ev# " << countev <<
245  ", #dst obj/tab, #Bfc obj/tab found = " <<
246  Countevobjd << " " <<
247  Countevtabd << " " <<
248  Countevobjb << " " <<
249  Countevtabb << endl << endl;
250 
251  fout << endl << " QAInfo: ev# " << countev <<
252  ", #dst obj/tab, #Bfc obj/tab found = " <<
253  Countevobjd << " " <<
254  Countevtabd << " " <<
255  Countevobjb << " " <<
256  Countevtabb << endl << endl;
257 
258 
259  } // if dstBranch
260 
261  if (counthold) countevdstTab++;
262  if (countre) countevdstRE++;
263 
264  } // istat
265 
266  else // if (istat)
267  {
268  cout << "Last event processed. Status = " << istat << endl;
269  }
270 
271  goto EventLoop;
272 
273 } // EventLoop
274 
275  countevobjd /= countev;
276  countevtabd /= countev;
277  countevobjb /= countev;
278  countevtabb /= countev;
279 
280  cout << endl;
281  cout << " QAInfo: End of Job " << endl;
282  cout << " QAInfo: # times Make called = " << iev << endl;
283  cout << " QAInfo: # events read = " << countev << endl;
284  cout << " QAInfo: # events with dstBranch dataset = " << countevdstB << endl;
285  cout << " QAInfo: # events with dst dataset = " << countevdst << endl;
286  cout << " QAInfo: # events with RunEvent object = " << countevdstRE << endl;
287  cout << " QAInfo: # events with dst Tables = " << countevdstTab << endl;
288  cout << " QAInfo: avg # dst tables per event = " << countevtabd << endl;
289  cout << " QAInfo: avg # dst objects per event = " << countevobjd << endl;
290  cout << " QAInfo: avg # Bfc tables per event = " << countevtabb << endl;
291  cout << " QAInfo: avg # Bfc objects per event = " << countevobjb << endl << endl;
292 
293  fout << endl;
294  fout << " QAInfo: End of Job " << endl;
295  fout << " QAInfo: # times Make called = " << iev << endl;
296  fout << " QAInfo: # events read = " << countev << endl;
297  fout << " QAInfo: # events with dstBranch dataset = " << countevdstB << endl;
298  fout << " QAInfo: # events with dst dataset = " << countevdst << endl;
299  fout << " QAInfo: # events with RunEvent object = " << countevdstRE << endl;
300  fout << " QAInfo: # events with dst Tables = " << countevdstTab << endl;
301  fout << " QAInfo: avg # dst tables per event = " << countevtabd << endl;
302  fout << " QAInfo: avg # dst objects per event = " << countevobjd << endl;
303  fout << " QAInfo: avg # Bfc tables per event = " << countevtabb << endl;
304  fout << " QAInfo: avg # Bfc objects per event = " << countevobjb << endl << endl;
305 
306  chain->Finish();
307 
308 }
309 
310 
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