StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcread_eventBranch.C
1 // $Id: bfcread_eventBranch.C,v 1.10 2006/08/15 21:43:10 jeromel Exp $
2 // $Log: bfcread_eventBranch.C,v $
3 // Revision 1.10 2006/08/15 21:43:10 jeromel
4 // Fix rhic -> rhic.bnl.gov
5 //
6 // Revision 1.9 2004/01/23 15:06:23 fisyak
7 // Add gSystem->Load(StBichsel) by Lee request
8 //
9 // Revision 1.8 2001/09/20 20:13:57 genevb
10 // Remove StEventMaker
11 //
12 // Revision 1.7 2000/06/20 14:03:05 kathy
13 // now unpack and print out BfcStatus table, if it exists, from .event.root file
14 //
15 // Revision 1.6 2000/06/13 01:41:50 lansdell
16 // load libglobal_Tables to prevent crash
17 //
18 // Revision 1.5 2000/06/02 18:54:38 kathy
19 // updated to find new BfcStatus table and report
20 //
21 // Revision 1.4 2000/05/19 21:43:07 kathy
22 // change print statements so that autoQA can find events easily
23 //
24 // Revision 1.3 2000/05/16 21:00:00 kathy
25 // clean up
26 //
27 // Revision 1.2 2000/05/16 19:29:27 kathy
28 // update some print statements
29 //
30 // Revision 1.1 2000/05/15 20:42:08 kathy
31 // adding new example macro to show how to read in a .event.root file and print info about it
32 //
33 
34 //======================================================================
35 // owner: Kathy Turner
36 // what it does: reads .event.root file produced from bfc
37 // runs StAnalysisMaker
38 //
39 // Inputs to macro:
40 // nevents - # events to process
41 // MainFile - input *.event.root file (you can use any branch here)
42 // fname - output file name with qa info
43 //
44 //
45 //======================================================================
46 
47 class StChain;
48 StChain *chain;
49 
50 void bfcread_eventBranch(
51  Int_t nevents=2,
52  const char *MainFile=
53  "/afs/rhic.bnl.gov/star/data/samples/gstar.event.root",
54  const char *fname="qa_event.out")
55 {
56 //
57  cout << " events to process = " << nevents << endl;
58  cout << " Input File Name = " << MainFile << endl;
59  cout << " Output file containing printouts = " << fname << endl;
60 
61  ofstream fout(fname);
62 
63  fout << " Running: bfcread_eventBranch.C " << endl;
64  fout << " events to process = " << nevents << endl;
65  fout << " Input File Name = " << MainFile << endl;
66  fout << " Output file containing printouts = " << fname << endl;
67  fout << endl << endl;
68 
69  gSystem->Load("St_base");
70  gSystem->Load("StChain");
71  gSystem->Load("libglobal_Tables");
72  gSystem->Load("StUtilities");
73  gSystem->Load("StIOMaker");
74  gSystem->Load("StarClassLibrary");
75  gSystem->Load("StBichsel");
76  gSystem->Load("StEvent");
77  // gSystem->Load("StMagF");
78  gSystem->Load("StAnalysisMaker");
79 
80 
81 // Setup top part of chain
82  chain = new StChain("AChain");
83  chain->SetDebug();
84 
85  StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,"bfcTree");
86  IOMk->SetDebug();
87  IOMk->SetIOMode("r");
88  IOMk->SetBranch("*",0,"0"); //deactivate all branches
89  IOMk->SetBranch("eventBranch",0,"r"); //activate event Branch
90 
91 
92 // sample analysis Maker to check StEvent objects
93  StAnalysisMaker *analysisMaker = new StAnalysisMaker("analysis");
94 
95 // --- now execute chain member functions
96  chain->Init();
97 
98  TTable *tabl=0;
99  TDataSet *deventBranch=0;
100  TDataSet *dde=0;
101 
102  int countev=0;
103  int countevB=0;
104  int countevBfc=0;
105  int countevSt=0;
106 
107  Float_t countevobj=0.0;
108  Float_t countevtab=0.0;
109 
110  int istat=0;
111  int ijk=1;
112 
113  EventLoop: if (ijk <= nevents && istat!=2) {
114 
115  Int_t Countevobj=0;
116  Int_t Countevtab=0;
117 
118  cout << endl << "============================ Event " << ijk
119  << " start ============================" << endl;
120 
121  fout << endl << "============================ Event " << ijk
122  << " start ============================" << endl;
123 
124  chain->Clear();
125  istat = chain->Make(ijk);
126 
127  if (!istat) {
128  countev++;
129  deventBranch=chain->GetDataSet("eventBranch");
130  TDataSetIter eventBIter(deventBranch);
131 
132  if (deventBranch) {
133  countevB++;
134  cout << endl << " QAInfo: in eventBranch " << endl;
135  fout << endl << " QAInfo: in eventBranch " << endl;
136 
137  while (dde=eventBIter.Next()) {
138  countevobj++;
139  Countevobj++;
140 
141  cout << " QAInfo: found object: " << dde->GetName() << endl;
142  fout << " QAInfo: found object: " << dde->GetName() << endl;
143 
144  if (dde->InheritsFrom("TTable")) {
145  tabl = (TTable *)dde;
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  countevtab++;
151  Countevtab++;
152  }
153 
154  TString deName = dde->GetName();
155  if (deName == "BfcStatus") {
156  countevBfc++;
157 // Now print out contents of BfcStatus for QA purposes
158  TDataSetIter bfcstatiter(dde);
159  St_dst_bfc_status *bfcstat =
160  (St_dst_bfc_status *) bfcstatiter.Find("BfcStatus");
161  dst_bfc_status_st *bth = bfcstat->GetTable();
162 // loop over all rows in table BfcStatus:
163  Int_t ij = 0;
164  for (ij=0; ij< bfcstat->GetNRows(); ij++)
165  {
166  cout <<
167  " QAInfo: BfcStatus table -- row " << ij <<
168  ", Maker: " << bth[ij]->maker_name <<
169  " has istat = " << bth[ij]->status << endl;
170  fout <<
171  " QAInfo: BfcStatus table -- row " << ij <<
172  ", Maker: " << bth[ij]->maker_name <<
173  " has istat = " << bth[ij]->status << endl;
174  }
175  }
176  elseif (deName == "StEvent") {
177  countevSt++;
178  }
179  }
180  }
181 
182  cout << endl << " QAInfo: ev# " << countev <<
183  ", # objects/tables found in eventBranch = " <<
184  Countevobj << " " <<
185  Countevtab << endl << endl;
186 
187  fout << endl << " QAInfo: ev# " << countev <<
188  ", # objects/tables found in eventBranch = " <<
189  Countevobj << " " <<
190  Countevtab << endl << endl;
191 
192  }
193 
194  elseif (istat==2)
195  {cout << "Last event processed. Status = " << istat << endl;}
196 
197  elseif (istat==3)
198  {cout << "Error event processed. Status = " << istat << endl;}
199 
200  ijk++;
201 
202  goto EventLoop;
203  }
204 
205  countevobj /= countev;
206  countevtab /= countev;
207 
208  cout << endl;
209  cout << " QAInfo: End of Job " << endl;
210  cout << " QAInfo: # times Make called = " << ijk << endl;
211  cout << " QAInfo: # events read = " << countev << endl;
212  cout << " QAInfo: #ev with eventBranch dataset = " << countevB << endl;
213  cout << " QAInfo: #ev with StEvent dataset = " << countevSt << endl;
214  cout << " QAInfo: #ev with BfcStatus table = " << countevBfc << endl;
215  cout << " QAInfo: avg # tables per event = " << countevtab << endl;
216  cout << " QAInfo: avg # objects per event = " << countevobj << endl << endl;
217 
218  fout << endl;
219  fout << " QAInfo: End of Job " << endl;
220  fout << " QAInfo: # times Make called = " << ijk << endl;
221  fout << " QAInfo: # events read = " << countev << endl;
222  fout << " QAInfo: #ev with eventBranch dataset = " << countevB << endl;
223  fout << " QAInfo: #ev with StEvent dataset = " << countevSt << endl;
224  fout << " QAInfo: #ev with BfcStatus table = " << countevBfc << endl;
225  fout << " QAInfo: avg # tables per event = " << countevtab << endl;
226  fout << " QAInfo: avg # objects per event = " << countevobj << endl << endl;
227 
228  chain->Finish();
229 
230 }
231 
232 
233 
234 
235 
236 
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
A typical Analysis Class.
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