StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcread_geantBranch.C
1 // $Id: bfcread_geantBranch.C,v 1.13 2006/08/15 21:43:11 jeromel Exp $
2 // $Log: bfcread_geantBranch.C,v $
3 // Revision 1.13 2006/08/15 21:43:11 jeromel
4 // Fix rhic -> rhic.bnl.gov
5 //
6 // Revision 1.12 2000/06/20 19:07:23 lansdell
7 // had to load libglobal_Tables to prevent crashes
8 //
9 // Revision 1.11 2000/06/01 18:57:07 kathy
10 // updating to separate out BfcStatus stats
11 //
12 // Revision 1.10 2000/05/31 21:25:28 kathy
13 // updated so it now finds all tables/objects (e.g. BfcStatus) under geantBranch
14 //
15 //
16 //======================================================================
17 // owner: Kathy Turner
18 // what it does: reads .dst.root file produced from bfc & then goes to
19 // the geant.root branch
20 // - finds data set "geant"
21 // - loops over and prints out list of objects
22 // and tables
23 //
24 // Inputs to macro:
25 // nevents - # events to process
26 // MainFile - input *.dst.root file (you can use any branch here)
27 // fname - output file name with qa info
28 //
29 //
30 //=======================================================================
31 
32 class StChain;
33 StChain *chain;
34 
35 void bfcread_geantBranch(
36  Int_t nevents=2,
37  const char *MainFile=
38  "/afs/rhic.bnl.gov/star/data/samples/gstar.geant.root",
39  const char *fname="qa_geant.out")
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_geantBranch.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  gSystem->Load("St_base");
55  gSystem->Load("StChain");
56  gSystem->Load("libsim_Tables");
57  gSystem->Load("libgen_Tables");
58  gSystem->Load("libglobal_Tables");
59  gSystem->Load("StIOMaker");
60 
61 
62 // Setup top part of chain
63  chain = new StChain("bfc");
64  chain->SetDebug();
65 
66  StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,"bfcTree");
67  IOMk->SetDebug();
68  IOMk->SetIOMode("r");
69  IOMk->SetBranch("*",0,"0"); //deactivate all branches
70  IOMk->SetBranch("geantBranch",0,"r"); //activate geant Branch
71 
72 // --- now execute chain member functions
73  chain->Init();
74  cout << " Finished Init()..." << endl;
75  TDataSet *ddb=0;
76  TTable *tabl=0;
77  TDataSet *obj=0;
78  TDataSet *dgeantBranch=0;
79 
80  int istat=0;
81  int iev=0;
82 
83  Float_t countev=0.0;
84 
85  Float_t countevgB=0.0;
86  Float_t countevg=0.0;
87  Float_t countevobjg=0.0;
88  Float_t countevtabg=0.0;
89  Float_t countevobjb=0.0;
90  Float_t countevtabb=0.0;
91 
92 
93 // Event loop
94 EventLoop: if (iev < nevents && !istat) {
95 
96  Int_t Countevobjg=0;
97  Int_t Countevtabg=0;
98  Int_t Countevobjb=0;
99  Int_t Countevtabb=0;
100 
101 
102  chain->Clear();
103  cout << " Calling Make()..." << endl;
104  istat = chain->Make(iev);
105  cout << " Make() finished..." << endl;
106 
107 // count # times Make is called
108  iev++;
109 
110  cout << " Call Make # " << iev << endl;
111  cout << " istat value returned from chain Make = " << istat << endl;
112 
113 // Now look at the data in the event:
114 
115 
116  if (!istat) {
117 
118  countev++;
119 
120  cout << " start event # " << countev << endl;
121  fout << " start event # " << countev << endl;
122 
123  dgeantBranch=chain->GetDataSet("geantBranch");
124  TDataSetIter geantBIter(dgeantBranch);
125 
126  if (dgeantBranch) {
127  countevgB++;
128 
129  cout << endl << " QAInfo: in geantBranch " << endl;
130  fout << endl << " QAInfo: in geantBranch " << endl;
131 
132  while (ddb=geantBIter.Next()) {
133 
134  cout << " QAInfo: found object: " << ddb->GetName() << endl;
135  fout << " QAInfo: found object: " << ddb->GetName() << endl;
136 
137  TString dsName = ddb->GetName();
138 
139  if (dsName == "BfcStatus") {
140  countevobjb++;
141  Countevobjb++;
142  }
143  else {
144  countevobjg++;
145  Countevobjg++;
146  }
147 
148  if (ddb->InheritsFrom("TTable")) {
149 
150  if (dsName == "BfcStatus") {
151  countevtabb++;
152  Countevtabb++;
153  }
154  else{
155  countevtabg++;
156  Countevtabg++;
157  }
158 
159  tabl = (TTable *)ddb;
160  cout << " QAInfo: it's a table with #rows = "
161  << tabl->GetNRows() << endl;
162  fout << " QAInfo: it's a table with #rows = "
163  << tabl->GetNRows() << endl;
164  }
165 
166 
167  } // while geantBranch
168 
169  cout << endl << " QAInfo: ev# " << countev <<
170  ", #geant obj/tab, #Bfc obj/tab found = " <<
171  Countevobjg << " " <<
172  Countevtabg << " " <<
173  Countevobjb << " " <<
174  Countevtabb << endl << endl;
175 
176  fout << endl << " QAInfo: ev# " << countev <<
177  ", #geant obj/tab, #Bfc obj/tab found = " <<
178  Countevobjg << " " <<
179  Countevtabg << " " <<
180  Countevobjb << " " <<
181  Countevtabb << endl << endl;
182 
183 
184  } // if geantBranch
185 
186  } // istat
187 
188  else // if (istat)
189  {
190  cout << "Last event processed. Status = " << istat << endl;
191  }
192 
193  goto EventLoop;
194 
195 } // EventLoop
196 
197  countevobjg /= countev;
198  countevtabg /= countev;
199  countevobjb /= countev;
200  countevtabb /= countev;
201 
202  cout << endl;
203  cout << "QAInfo: End of Job " << endl;
204  cout << "QAInfo: # times Make called = " << iev << endl;
205  cout << "QAInfo: # events read = " << countev << endl;
206  cout << "QAInfo: # events with geantBranch dataset = " <<
207  countevgB << endl;
208  // cout << "QAInfo: # events with geant dataset = " <<
209  // countevg << endl;
210  cout << "QAInfo: avg # geant tables per event = " << countevtabg << endl;
211  cout << "QAInfo: avg # geant objects per event = " << countevobjg << endl;
212  cout << "QAInfo: avg # Bfc tables per event = " << countevtabb << endl;
213  cout << "QAInfo: avg # Bfc objects per event = " << countevobjb << endl << endl;
214 
215 
216  fout << endl;
217  fout << "QAInfo: End of Job " << endl;
218  fout << "QAInfo: # times Make called = " << iev << endl;
219  fout << "QAInfo: # events read = " << countev << endl;
220  fout << "QAInfo: # events with geantBranch dataset = " <<
221  countevgB << endl;
222  //fout << "QAInfo: # events with geant dataset = " <<
223  // countevg << endl;
224  fout << "QAInfo: avg # geant tables per event = " << countevtabg << endl;
225  fout << "QAInfo: avg # geant objects per event = " << countevobjg << endl;
226  fout << "QAInfo: avg # Bfc tables per event = " << countevtabb << endl;
227  fout << "QAInfo: avg # Bfc objects per event = " << countevobjb << endl << endl;
228 
229  chain->Finish();
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
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