30 if (gSystem.Load(
"xdf2root")) printf(
" Loading DLL \"xdf2root\" failed \n");
31 if (gSystem.Load(
"St_Tables")) printf(
" Loading DLL \"St_Tables\" failed \n");
33 void TestSorter(Char_t *xdffilename=
"/afs/rhic.bnl.gov/star/data/samples/test.xdf",
const Char_t *col=
"phep[3]")
37 St_XDFFile xdf(xdffilename);
38 TDataSet *
event = xdf.NextEventGet();
39 if (!event) { printf(
" NO events \n");
return;}
42 table = (St_particle *)root[
"/evgen/particle"];
44 TString colName = col;
48 int cols = sorter->GetFirstRow() + sorter->GetNRows() -1;
49 cout <<
" Result of the ordering the table: " << endl
53 <<
"[" << cols <<
"]> "
54 <<
" along: \"" << sorter->GetName() <<
"\" column" << endl;
55 cout <<
"This table contains " << sorter->
CountKeys() <<
" different keys" << endl;
59 for (i=0; i < sorter->GetNRows(); i++) cout <<
" [" << sorter->
GetIndex(i) <<
"] ";
63 particle_st *particle = table->GetTable();
64 for (i=0; i < sorter->GetNRows(); i++) cout << particle[sorter->
GetIndex(i)]->phep[3] <<
" ";
67 cout <<
" Binary Search test:"<< endl;
68 for (i=sorter->GetNRows()-1; i >= 0 ; i--) {
69 Float_t ph = particle[sorter->
GetIndex(i)]->phep[3];
70 Int_t lastFound = sorter->BinarySearch(ph);
71 cout << i <<
". " << ph <<
" == " << lastFound <<
" : " << sorter->GetLastFound() << endl;
81 cout <<
" Second pass " << endl;
82 St_XDFFile xd(
"/afs/rhic.bnl.gov/star/data/samples/gstar.dst.xdf");
83 event = xd.NextEventGet();
85 St_dst_vertex *table=0;
86 table = (St_dst_vertex *)event->FindByName(
"vertex");
88 TString colName =
"vtx_id";
94 int cols = sorter->GetFirstRow() + sorter->GetNRows() - 1;
95 cout <<
" Result of the ordering the table: " << endl
99 <<
"[" << cols <<
"]> "
100 <<
" along: \"" << sorter->GetName() <<
"\" column" << endl;
101 cout <<
"This table contains " << sorter->
CountKeys() <<
" different keys" << endl;
104 for (i=0; i < sorter->GetNRows(); i++) cout <<
" [" << sorter->
GetIndex(i) <<
"] ";
108 dst_vertex_st *
vertex = table->GetTable();
109 for (i=0; i < sorter->GetNRows(); i++) cout << vertex[sorter->
GetIndex(i)]->vtx_id <<
" ";
111 for (i=0; i < sorter->GetNRows(); i++) cout << vertex[sorter->
GetIndex(i)]->z <<
" ";
114 cout <<
" Binary Search test:"<< endl;
115 Int_t nrows = sorter->GetNRows() - 1;
116 for (i=nrows; i >= 0 ; i--) {
117 Short_t vtx = vertex[sorter->
GetIndex(i)]->vtx_id;
118 Int_t lastFound = sorter->BinarySearch(vtx);
119 cout << i <<
". " << vtx <<
" == " << lastFound <<
" : " << sorter->GetLastFound() << endl;
120 if (sort[vtx] != lastFound)
121 cout <<
" *** Error **** " << lastFound <<
" != " << sorter[vtx] << endl;
131 else cout <<
" NO events" << endl;
Int_t GetIndex(UInt_t sortedIndex) const
returns the original index of the row by its sorted index
virtual const char * GetTableType() const
to be documented
virtual const char * GetTableName() const
to be documented
virtual Char_t * Print(Char_t *buf, Int_t n) const
Create IDL table defintion (to be used for XDF I/O)
virtual Int_t CountKeys() const