00001 class St_db_Maker;
00002 St_db_Maker *dbMk = 0;
00003 class TTable;
00004 TTable *table = 0;
00005
00006 void Load() {
00007 if (gClassTable->GetID("StDbManager") < 0) {
00008
00009 gSystem->Load("libTable");
00010 gSystem->Load("St_base");
00011 gSystem->Load("StChain");
00012 gSystem->Load("StUtilities");
00013
00014
00015
00016
00017 gSystem->Load("St_Tables.so");
00018 gSystem->Load("StDbLib.so");
00019 gSystem->Load("StDbBroker.so");
00020 gSystem->Load("St_db_Maker.so");
00021 }
00022 dbMk = new St_db_Maker("db","MySQL:StarDb");
00023 dbMk->SetDebug(1);
00024
00025 dbMk->Init();
00026 }
00027
00028 void Db_PrintTable(const Char_t *tabNam = "Calibrations/ftpc/ftpcCoordTrans",
00029 Int_t date = 20040227,
00030 Int_t time = 1){
00031 fprintf(stderr," 0. cout = %x \n", (void*)cout);
00032 if (dbMk == 0) Load();
00033 dbMk->SetDateTime(date,time);
00034 fprintf(stderr," 1. cout = %x \n",(void*) cout);
00035 #if 0
00036
00037 const char* dbs[] = {"Geometry","Calibrations","RunLog","Conditions",0};
00038 for(int i=0;dbs[i]!=0;i++)dbMk->GetDataBase(dbs[i]);
00039 #else
00040
00041 TDataSet *set = dbMk->GetDataBase(gSystem->DirName(tabNam));
00042 table = (TTable *) set->Find(gSystem->BaseName(tabNam));
00043 if (table) {
00044 TDatime t[2];
00045 dbMk->GetValidity(table,t);
00046 cout << "Validity:" << t[0].GetDate() << "/" << t[0].GetTime()
00047 << " ----- " << t[1].GetDate() << "/" << t[1].GetTime() << endl;
00048 Int_t Nrows = table->GetNRows();
00049 if (Nrows > 10) Nrows = 10;
00050 table->Print(0,Nrows);
00051 #if 0
00052 TString name(gSystem->BaseName(tabNam));
00053 name += Form(".%06i.%06i.root",t[0].GetDate(),t[0].GetTime());
00054 TFile *f = new TFile(name.Data(),"RECREATE");
00055 table->Write();
00056 delete f;
00057 #endif
00058 }
00059 else cout << "Table:" << tabNam << " has not been found" << endl;
00060 #endif
00061 fprintf(stderr," 2. cout = %x \n",(void*) cout);
00062
00063
00064 }
00065
00066