x0/y0 into the Geometry/pp2pp database
Hi,
I've written our x0,y0 offset (13 sets) --- each set contains a row of 32 numbers --- into the database of Geometry/pp2pp of StarDb in the table of "pp2ppOffset".
I'd asked Donika to use the date/time format of 2 integers such as "20090702 125011" but then I realized that in the way that I've been writing into the database following Dmitry's example, the date/time should be in the format "2009-07-02 12:50:11" (MySQL date/time representation) such as :
// TString storeTime = "2009-07-02 12:50:11";
mgr->setStoreTime(storeTime.Data());
So, I've needed to convert them back before I store into the database. This time, I remember to set "DB_ACCESS_MODE" to "write" when I stored the entries into the database. The order of 32 entries in each set is as follows :
EHI (A, B, C, D) EHO (A, B, C, D) EVU (A, B, C, D) EVD (A, B, C, D) WHI (A, B, C, D) WHO (A, B, C, D) WVD (A, B, C, D) WVU (A, B, C, D)
All number are in the unit of mm.
When reading, one does NOT need to set "DB_ACCESS_MODE" and it'd work (or you may set it to "read"). The macro to read the entries back based on a timestamp is :
{
// generic libraries, nothing special here
gSystem->Load("St_base");
gSystem->Load("StChain");
gSystem->Load("StBFChain");
gSystem->Load("StUtilities");
gSystem->Load("StIOMaker");
gSystem->Load("StarClassLibrary");
// db-related libraries
gSystem->Load("St_Tables");
gSystem->Load("StDbLib");
gSystem->Load("StDbBroker");
gSystem->Load("St_db_Maker");
// this will be in chain
St_db_Maker *dbMk = 0;
dbMk = new St_db_Maker("db", "MySQL:StarDb", "$STAR/StarDb");
if (!dbMk) {
std::cout << "Cannot create St_db_Maker! \n";
return;
}
dbMk->SetDebug();
dbMk->SetDateTime(20090704,130001);
dbMk->SetFlavor("ofl"); // for offline calibrations/mapping
// dbMk->SetFlavor("simu"); // for simulations
dbMk->Init();
dbMk->Make()
// this is done inside ::Make method
TDataSet *DB = 0;
DB = dbMk->GetInputDB("Geometry/pp2pp");
if (!DB) { std::cout << "ERROR: cannot find database Geometry_pp2pp?" << std::endl; }
// fetch ROOT fmsMap descriptor of db table
St_pp2ppOffset *descr = 0;
descr = (St_pp2ppOffset*) DB->Find("pp2ppOffset");
// fetch data and place it to appropriate structure
if (descr) {
pp2ppOffset_st *table = descr->GetTable();
std::cout << "Reading pp2ppOffset table with nrows = " << descr->GetNRows() << "\n";
for (Int_t i = 0; i < descr->GetNRows(); i++) {
// std::cout << "row " << i << " = "
for ( Int_t j = 0; j< 32 ; j++ )
std::cout << table[i].rp_offset_plane[j] << " " ;
cout << endl ;
}
} else {
std::cout << "WARNING: No data in pp2ppOffset table (wrong timestamp?). Nothing to return, then.\n";
}
std::cout << "DB work is done. EXIT." << std::endl;
}
- yipkin's blog
- Login or register to post comments