StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
bfcread_runcoBranch.C
1 // $Id: bfcread_runcoBranch.C,v 1.12 2006/08/15 21:43:13 jeromel Exp $
2 // $Log: bfcread_runcoBranch.C,v $
3 // Revision 1.12 2006/08/15 21:43:13 jeromel
4 // Fix rhic -> rhic.bnl.gov
5 //
6 // Revision 1.11 2000/06/22 21:24:07 kathy
7 // force only 1 event to be processed in runco Branch
8 //
9 // Revision 1.10 2000/05/03 19:04:34 kathy
10 // update to make consistent with other macros of same type
11 //
12 // Revision 1.9 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.8 2000/04/12 16:20:12 kathy
16 // fixing library loads to only do minimum
17 //
18 // Revision 1.6 2000/03/23 19:54:36 kathy
19 // update branch macros so they write out to a file, and clean up
20 //
21 // Revision 1.5 2000/03/21 15:45:07 kathy
22 // updated the bfcread_*Branch.C macros so they printout info that can be used by autoQA system
23 //
24 // Revision 1.4 2000/03/20 17:50:41 kathy
25 // fix all macros so that they set all branches on that are needed - otherwise won't work with soft links
26 //
27 // Revision 1.3 2000/03/13 17:50:18 kathy
28 // putting in example macro to show how to read and navigate through each type of bfc DST production output files - still working on tags.root
29 //
30 // Revision 1.2 2000/01/19 15:46:05 kathy
31 // change default input files to point to ones in /afs/rhic.bnl.gov/star/data/samples
32 //
33 // Revision 1.1 2000/01/07 19:22:52 kathy
34 // add bfcread_dstBranch,bfcread_runcoBranch macros to show how to read dst produced from bfc.C and navigate through different branches of the file and find and list table information
35 //
36 //======================================================================
37 // owner: Kathy Turner
38 // what it does: reads .dst.root file produced from bfc & then goes to
39 // the runco.root branch
40 // - finds data set "runco"
41 // - loops over and prints out list of objects
42 // - then for each object (which is a directory)
43 // prints out all objects (I'm calling them sub-objects)
44 // inside it
45 // - also checks if the sub-object is a table and prints
46 // info if it is
47 //
48 // - the runco branch only has 1 "event" per dst run!
49 //
50 // Inputs to macro:
51 // nevents - # events to process (should always leave at 1 !!)
52 // MainFile - input *.dst.root file (you can use any branch here)
53 // fname - output file name with qa info
54 //
55 //=======================================================================
56 
57 class StChain;
58 StChain *chain;
59 
60 void bfcread_runcoBranch(
61  Int_t nevents=1,
62  const char *MainFile=
63  "/afs/rhic.bnl.gov/star/data/samples/gstar.dst.root",
64  const char *fname="qa_runco.out")
65 {
66 //
67  if (nevents != 1){
68  cout << " there is only 1 event in this branch!! " << endl;
69  }
70  nevents=1;
71 
72  cout << " events to process = " << nevents << endl;
73  cout << " Input File Name = " << MainFile << endl;
74  cout << " Output file containing printouts = " << fname << endl;
75 
76  ofstream fout(fname);
77 
78  fout << " Running: bfcread_runcoBranch.C " << endl;
79  fout << " events to process = " << nevents << endl;
80  fout << " Input File Name = " << MainFile << endl;
81  fout << " Output file containing printouts = " << fname << endl;
82  fout << endl << endl;
83 
84  gSystem->Load("St_base");
85  gSystem->Load("StChain");
86  gSystem->Load("libglobal_Tables");
87  gSystem->Load("StIOMaker");
88 
89 // Setup top part of chain
90  chain = new StChain("bfc");
91  chain->SetDebug();
92 
93  StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,"bfcTree");
94  IOMk->SetDebug();
95  IOMk->SetIOMode("r");
96  IOMk->SetBranch("*",0,"0"); //deactivate all branches
97  IOMk->SetBranch("runcoBranch",0,"r"); //activate runco Branch
98 
99 // --- now execute chain member functions
100  chain->Init();
101 
102  TDataSet *ds=0;
103  TTable *tabl=0;
104  TDataSet *obj=0;
105 
106 
107  int istat=0;
108  int i=0;
109  int countev=0;
110  int countevrds=0;
111 
112 // Event loop
113 EventLoop: if (i < nevents && !istat) {
114 
115  chain->Clear();
116  istat = chain->Make(i);
117 
118 // count # times Make is called
119  i++;
120 
121 // Now look at the data in the event:
122  int countObj=0;
123  int countObjInDir=0;
124  int countTable=0;
125 
126  if (!istat) {
127 
128  countev++;
129 
130  cout << " start event # " << countev << endl;
131 
132  ds=chain->GetDataSet("runco");
133  TDataSetIter tabiter(ds);
134  if (ds) {
135  countevrds++;
136 
137  while (obj = tabiter.Next()) {
138  cout << " QAInfo: found object: " << obj->GetName() << endl;
139  fout << " QAInfo: found object: " << obj->GetName() << endl;
140 
141  countObj++;
142 
143 //.. now loop over each subdirectory and look at objects in it
144 
145  TDataSet *objindir=0;
146  TDataSetIter objindiriter(obj);
147  while(objindir = objindiriter.Next()) {
148  cout << " QAInfo: has sub-object = " << objindir->GetName() << endl;
149  fout << " QAInfo: has sub-object = " << objindir->GetName() << endl;
150  countObjInDir++;
151 
152  // if it's a table, print more info:
153  if (objindir->InheritsFrom("TTable")) {
154  tabl = (TTable *)objindiriter.Find(objindir->GetName());
155  if (tabl) {
156  countTable++;
157  cout << " QAInfo: it's a table with #rows = "
158  << objindir->GetName() << ", " << tabl->GetNRows() << endl;
159  fout << " QAInfo: it's a table with #rows = "
160  << objindir->GetName() << ", " << tabl->GetNRows() << endl;
161 
162  } //tabl
163  } //objindir
164  } //while objindir
165  } //while obj
166  } //ds
167 
168  cout << " QAInfo: event # " << countev
169  << ", # directories found = " << countObj
170  << ", # sub-objects found = " << countObjInDir
171  << ", # tables found = " << countTable
172  << endl << endl;
173 
174  fout << " QAInfo: event # " << countev
175  << ", # directories found = " << countObj
176  << ", # sub-objects found = " << countObjInDir
177  << ", # tables found = " << countTable
178  << endl << endl;
179 
180  } //istat
181 
182  else // if (istat)
183  {
184  cout << "Last event processed. Status = " << istat << endl;
185  }
186 
187 
188  goto EventLoop;
189 } //EventLoop
190 
191 
192 
193  cout << endl;
194  cout << "QAInfo: End of Job " << endl;
195  cout << "QAInfo: # times Make called = " << i << endl;
196  cout << "QAInfo: # events read = " << countev << endl;
197  cout << "QAInfo: # events with runco dataset = " << countevrds << endl;
198 
199  fout << endl;
200  fout << "QAInfo: End of Job " << endl;
201  fout << "QAInfo: # times Make called = " << i << endl;
202  fout << "QAInfo: # events read = " << countev << endl;
203  fout << "QAInfo: # events with runco dataset = " << countevrds << endl;
204 
205  chain->Finish();
206 }
207 
208 
209 
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