44 void bfcread_tagsBranch(
45 const char *MainFile=
"/afs/rhic.bnl.gov/star/data/samples/gstar.tags.root",
47 const char *fname=
"qa_tags.out",
55 cout <<
" bfcread_tagsBranch.C: input file = " << MainFile << endl;
56 cout <<
" bfcread_tagsBranch.C: print event # " << printEvent << endl;
57 cout <<
" bfcread_tagsBranch.C: output file = " << fname << endl;
58 cout <<
" bfcread_tagsBranch.C: full printout = " << fullPrint << endl;
64 fout <<
" bfcread_tagsBranch.C: input file = " << MainFile << endl;
65 fout <<
" bfcread_tagsBranch.C: print evt# = " << printEvent << endl;
66 fout <<
" bfcread_tagsBranch.C: output file = " << fname << endl;
67 fout <<
" bfcread_tagsBranch.C: full printout = " << fullPrint << endl;
70 TFile *file = TFile::Open(MainFile);
71 TTree *tree = (TTree*)file->Get(
"Tag");
73 cout <<
" read file: " << file->GetName() << endl << endl;
75 Int_t nEntries = tree->GetEntries();
76 cout <<
" Total # events = " << nEntries << endl;
78 TObjArray *leaves = tree->GetListOfLeaves();
79 Int_t nLeaves = leaves->GetEntriesFast();
81 cout <<
" Total # leaves = " << nLeaves << endl;
83 TString *tName =
new TString(
" ");
85 TObjArray *tagTable =
new TObjArray;
87 Int_t *tableIndex =
new Int_t[nLeaves];
95 for (Int_t l=0;l<nLeaves;l++) {
96 leaf = (TLeaf*)leaves->UncheckedAt(l);
97 tagCount+=leaf->GetNdata();
98 branch = leaf->GetBranch();
99 cout <<
"leaf # " << l <<
" br name = " <<
100 branch->GetName() << endl;
102 if ( strstr(branch->GetName(), tName->Data()) == 0 ) {
103 tName =
new TString(branch->GetName());
104 tName->Resize(tName->Index(
"."));
106 tableName =
new TNamed(tName->Data(),
"Tag");
107 tagTable->AddLast(tableName);
110 tableIndex[l]=tableCount-1;
113 cout << endl <<
" Total num tables(branches),tags = "
114 << tableCount <<
" " << tagCount << endl << endl;
116 Int_t *countTagsTable =
new Int_t[tableCount];
117 Int_t *countLeavesTable =
new Int_t[tableCount];
118 Float_t *sumTagsLeaf =
new Float_t[nLeaves];
119 Int_t *countTagsLeaf =
new Int_t[nLeaves];
123 Int_t setBranch = -1;
124 Int_t nowBranch = -1;
126 for (Int_t l=0;l<nLeaves;l++) {
128 leaf = (TLeaf*)leaves->UncheckedAt(l);
129 branch = leaf->GetBranch();
130 ndim = leaf->GetNdata();
132 nowBranch = tableIndex[l];
137 Float_t RtableIndex=tableIndex[l];
139 if (nowBranch != setBranch){
141 cout <<
" QAInfo: branch ";
143 cout << tableIndex[l] <<
" = ";
145 cout << ((TNamed*)tagTable->UncheckedAt(tableIndex[l]))->
GetName();
147 fout <<
" QAInfo: branch ";
149 fout << RtableIndex <<
" = ";
151 fout << ((TNamed*)tagTable->UncheckedAt(tableIndex[l]))->
GetName();
155 countTagsTable[tableIndex[l]]+=leaf->GetNdata();
156 countLeavesTable[tableIndex[l]]++;
157 countTagsLeaf[l]+=ndim;
161 cout <<
" QAInfo: leaf ";
163 cout << l <<
" has ";
165 cout << ndim <<
" tags:";
167 fout <<
" QAInfo: leaf ";
169 fout << Rl <<
" has ";
171 fout << Rndim <<
" tags:";
176 for (Int_t nev=0; nev<nEntries; nev++) {
177 branch->GetEntry(nev);
181 for (Int_t itag=0;itag<ndim;itag++) {
184 if (ik==printEvent) {
186 cout <<
" QAInfo: " << leaf->GetName();
187 if (ndim>1) cout <<
'['<<itag<<
']';
188 cout <<
" = " << leaf->GetValue(itag) << endl;
190 fout <<
" QAInfo: " << leaf->GetName();
191 if (ndim>1) fout <<
'['<<itag<<
']';
192 fout <<
" = " << leaf->GetValue(itag) << endl;
195 sumTagsLeaf[l]+=leaf->GetValue(itag);
200 cout << endl << endl;
201 fout << endl << endl;
206 for (Int_t m=0; m<nLeaves; m++){
208 leaf = (TLeaf*)leaves->UncheckedAt(m);
209 branch = leaf->GetBranch();
210 ndim = leaf->GetNdata();
212 cout <<
" QAInfo: branch ";
214 cout << tableIndex[m] <<
" = ";
216 cout << ((TNamed*)tagTable->UncheckedAt(tableIndex[m]))->
GetName();
221 cout << leaf->GetName();
222 cout <<
", #tags = ";
227 Float_t RtableIndex=tableIndex[m];
230 fout <<
" QAInfo: branch ";
232 fout << RtableIndex <<
" = ";
234 fout << ((TNamed*)tagTable->UncheckedAt(tableIndex[m]))->
GetName();
239 fout << leaf->GetName();
240 fout <<
", #tags = ";
247 cout << endl << endl;
248 fout << endl << endl;
253 cout <<
" QAInfo: each leaf's avg over all tags,evts: " << endl;
254 fout <<
" QAInfo: each leaf's avg over all tags,evts: " << endl;
256 for (Int_t m=0; m<nLeaves; m++){
258 leaf = (TLeaf*)leaves->UncheckedAt(m);
260 sumTagsLeaf[m]/=countTagsLeaf[m]*nEntries;
262 cout <<
" QAInfo: avg leaf #";
266 cout << leaf->GetName() <<
" = ";
268 cout << sumTagsLeaf[m];
272 fout <<
" QAInfo: avg leaf #";
276 fout << leaf->GetName() <<
" = ";
278 fout << sumTagsLeaf[m];
282 cout << endl << endl;
283 fout << endl << endl;
288 for (Int_t m=0; m<tableCount; m++){
290 cout <<
" QAInfo: branch(table) ";
292 cout << ((TNamed*)tagTable->UncheckedAt(m))->
GetName() <<
" has ";
294 cout << countLeavesTable[m] <<
" leaves,";
296 cout << countTagsTable[m] <<
" tags" << endl;
298 Float_t RcountLeavesTable=countLeavesTable[m];
299 Float_t RcountTagsTable=countTagsTable[m];
300 fout <<
" QAInfo: branch(table) ";
302 fout << ((TNamed*)tagTable->UncheckedAt(m))->
GetName() <<
" has ";
304 fout << RcountLeavesTable <<
" leaves,";
306 fout << RcountTagsTable <<
" tags" << endl;
309 cout << endl << endl;
310 fout << endl << endl;
313 Float_t RnEntries=nEntries;
314 Float_t RtableCount=tableCount;
315 Float_t RnLeaves=nLeaves;
316 Float_t RtagCount=tagCount;
318 cout <<
" QAInfo: tot num events = " << nEntries << endl;
319 fout <<
" QAInfo: tot num events = " << RnEntries << endl;
321 cout <<
" QAInfo: tot num branches = " << tableCount << endl;
322 fout <<
" QAInfo: tot num branches = " << RtableCount << endl;
324 cout <<
" QAInfo: tot num leaves = " << nLeaves << endl;
325 fout <<
" QAInfo: tot num leaves = " << RnLeaves << endl;
327 cout <<
" QAInfo: tot num tags = " << tagCount << endl;
328 fout <<
" QAInfo: tot num tags = " << RtagCount << endl;
333 cout<< endl << endl <<
"RealTime="<<timer.RealTime()<<
334 " seconds, CpuTime="<<timer.CpuTime()<<
" seconds"<<endl;
virtual const char * GetName() const
special overload