00001 // $Id: Example_read_dst_print_tables.C,v 1.9 2006/08/15 21:42:55 jeromel Exp $ 00002 // $Log: Example_read_dst_print_tables.C,v $ 00003 // Revision 1.9 2006/08/15 21:42:55 jeromel 00004 // Fix rhic -> rhic.bnl.gov 00005 // 00006 // Revision 1.8 2000/06/05 16:35:35 kathy 00007 // remove use of member function GetHeader since it is no longer available - now use memb functions of TTable 00008 // 00009 // Revision 1.7 2000/04/18 20:37:25 kathy 00010 // St_DataSet,St_DataSetIter,St_Table classes are nowchanged to TDataSet,TDataSetIter,TTable 00011 // 00012 // Revision 1.6 2000/04/13 21:46:21 kathy 00013 // remove loading of libtpc_Tables since l3Track table is now dst_track type from global 00014 // 00015 // Revision 1.5 2000/04/12 16:13:40 kathy 00016 // have changed so that macro loads only table libraries needed instead of all table libraries 00017 // 00018 // Revision 1.4 2000/01/19 15:46:04 kathy 00019 // change default input files to point to ones in /afs/rhic.bnl.gov/star/data/samples 00020 // 00021 // Revision 1.3 1999/11/30 20:04:17 kathy 00022 // fix Example macros so that they work from .dst.root files or .dst.xdf files & update documentation; also had to change which values printed in *read_dst_print_tables* macro since the names have changed in dst tables 00023 // 00024 // Revision 1.2 1999/11/03 16:57:00 kathy 00025 // fix macros to use StIOMaker instead of StTreeMaker 00026 // 00027 // Revision 1.1 1999/10/11 17:17:57 kathy 00028 // changed names of some macros to make them more standard; changed default input file to MakeHists since previous no longer existed; combined some macros so that the one example will show all functionality 00029 // 00030 // 00031 //====================================================================== 00032 // owner: Kathy Turner 00033 // what it does: 00034 // Kathy's notes (10/11/99): 00035 // - read dstbranch from *.dst.root or *.dst.xdf file 00036 // - read 1 event and print out information from the tables 00037 //====================================================================== 00038 00039 class StChain; 00040 StChain *chain; 00041 00042 class TDataSet; 00043 TDataSet *Event; 00044 00045 void Example_read_dst_print_tables( 00046 Int_t nevents=1, 00047 const char *MainFile= 00048 "/afs/rhic.bnl.gov/star/data/samples/gstar.dst.root") 00049 { 00050 // 00051 gSystem->Load("St_base"); 00052 gSystem->Load("StChain"); 00053 00054 gSystem->Load("libglobal_Tables"); 00055 gSystem->Load("libgen_Tables"); 00056 gSystem->Load("libsim_Tables"); 00057 gSystem->Load("libtpc_Tables"); 00058 00059 gSystem->Load("StIOMaker"); 00060 gSystem->Load("StarClassLibrary"); 00061 00062 cout << " .. Example_read_dst_print_tables.C, have loaded libraries " << endl; 00063 00064 // Setup top part of chain 00065 chain = new StChain("bfc"); 00066 chain->SetDebug(); 00067 00068 // 00069 // setup chain with IOMaker - can read in .dst.root, .dst.xdf files 00070 StIOMaker *IOMk = new StIOMaker("IO","r",MainFile,"bfcTree"); 00071 IOMk->SetDebug(); 00072 IOMk->SetIOMode("r"); 00073 IOMk->SetBranch("*",0,"0"); //deactivate all branches 00074 // IOMk->SetBranch("tpc_tracks",0,"r"); //activate tpc_tracks Branch 00075 // IOMk->SetBranch("geantBranch",0,"r"); //activate geant Branch 00076 IOMk->SetBranch("dstBranch",0,"r"); //activate dst Branch 00077 00078 00079 // --- now execute chain member functions 00080 chain->Init(); 00081 00082 for (int iev=0;iev<nevents; iev++) 00083 { 00084 chain->Clear(); 00085 int iret = chain->Make(); 00086 if (iret) break; 00087 00088 cout << endl << endl << 00089 " !!! Now print info about event # " << iev << endl; 00090 00091 // ------ List all tables ----------- 00092 // GetDataSet is a member function of St_Maker 00093 Event = chain->GetDataSet("dst"); 00094 00095 // ls() returns a virtual void, so don't have to set it = to anything 00096 if (Event) Event->ls(); 00097 00098 00099 // ---------------------- globtrk table --------------------- 00100 // get dataset for globtrk 00101 TDataSet *ds=chain->GetDataSet("dst/globtrk"); 00102 00103 if (ds) { 00104 00105 cout << " Now print info about globtrk table " << endl; 00106 00107 // create iterator for the dataset 00108 TDataSetIter globtrkiter(ds); 00109 00110 // Du,Pwd return things, but we choose not to keep the return value 00111 globtrkiter.Du(); 00112 globtrkiter.Pwd(); 00113 00114 // find the table 00115 St_dst_track *glob = (St_dst_track *) globtrkiter.Find("globtrk"); 00116 00117 // print out info about it 00118 // using ls() from TDataSetIter 00119 glob->ls(); 00120 00121 // Print() is a member function of TTable 00122 //glob->Print(9,1); 00123 //glob->Print(8,1); 00124 //glob->Print(8,2); 00125 //glob->Print(1,1); 00126 glob->Print(0,5); 00127 00128 00129 // can't use this method anymore!!! 5June00 Kathy 00130 // get the table header data using member function of TTable 00131 //table_head_st *tdt_h = glob->GetHeader(); 00132 // cout << " header name = " << tdt_h->name << endl; 00133 // cout << " header type = " << tdt_h->type << endl; 00134 // cout << " header maxlen = " << tdt_h->maxlen << endl; 00135 // cout << " header nok = " << tdt_h->nok << endl; 00136 00137 00138 // get the table header data using member functions of TTable 00139 cout << " table header info: name = " << glob->GetName() << endl; 00140 cout << " table header info: type = " << glob->GetType() << endl; 00141 cout << " table header info: #rows used = " << glob->GetNRows() << endl; 00142 cout << " table header info: #rows allocated = " << glob->GetTableSize() << endl; 00143 cout << " table header info: row size (bytes) = " << glob->GetRowSize() << endl; 00144 cout << " table header info: #columns = " << glob->GetNumberOfColumns() << endl; 00145 00146 // get the table and print out info about it (it's printing row 0) 00147 dst_track_st *sth = glob->GetTable(); 00148 cout << " globtrk: row0 " << endl; 00149 cout << " r0 = " << sth->r0 << endl; 00150 cout << " impact = " << sth->impact << endl; 00151 cout << " invpt = " << sth->invpt << endl; 00152 cout << " z0 = " << sth->z0 << endl; 00153 00154 // now go to next row 00155 // - just increment the pointer to do this (probably just STAR-specific 00156 // way - can't always increment pointers and get to right place! 00157 00158 sth++; 00159 cout << " globtrk: row1 " << endl; 00160 cout << " r0 = " << sth->r0 << endl; 00161 cout << " impact = " << sth->impact << endl; 00162 cout << " invpt = " << sth->invpt << endl; 00163 cout << " z0 = " << sth->z0 << endl; 00164 00165 } 00166 00167 //-------------------------------------------------------- 00168 } 00169 00170 chain->Finish(); 00171 00172 } 00173 00174 00175 00176 00177 00178
1.5.9