void fpsChannelGeometry_db(char* opt="", char* year="15sim") { TString option(opt), yr(year); TString storeTime; // storetime is begin time for validity range for WRITING DB int date,time; // time for READING DB std::cout << "year = " << year << "\n"; if(yr.Contains("15ofl")){ storeTime="2014-12-20 00:00:01"; date = 20141220; time = 1; }else if(yr.Contains("15sim")){ storeTime="2014-12-10 00:00:01"; date = 20141210; time = 1; }else if (yr.Contains("17ofl")){ storeTime="2016-12-20 00:00:00"; date = 20161220; time = 0; }else if(yr.Contains("17sim")){ storeTime="2016-12-10 00:00:00"; date = 20161210; time = 0; }else{ std::cout << "Please specify valid year tag\n"; exit; } std::cout << "Opt =" << opt << "\n"; std::cout << "write = " << option.Contains("writedb") << "\n"; std::cout << "storetime =" << storeTime << "\n"; std::cout << "date,time =" << date <<" "<< time << "\n"; gROOT->Macro("loadlib.C"); const Int_t MAX_DB_INDEX = 12; fpsChannelGeometry_st table[MAX_DB_INDEX]; if(option.Contains("writedb")) { gSystem->Setenv("DB_ACCESS_MODE","write"); StDbManager* mgr = StDbManager::Instance(); StDbConfigNode* node = mgr->initConfig("Geometry_fps"); StDbTable* dbtable = node->addDbTable("fpsChannelGeometry"); mgr->setStoreTime(storeTime.Data()); table[ 0].quad = 1; table[ 0].layer = 1; table[ 0].nslat = 21; table[ 1].quad = 1; table[ 1].layer = 2; table[ 1].nslat = 21; table[ 2].quad = 1; table[ 2].layer = 3; table[ 2].nslat = 21; table[ 3].quad = 2; table[ 3].layer = 1; table[ 3].nslat = 19; table[ 4].quad = 2; table[ 4].layer = 2; table[ 4].nslat = 19; table[ 5].quad = 2; table[ 5].layer = 3; table[ 5].nslat = 19; table[ 6].quad = 3; table[ 6].layer = 1; table[ 6].nslat = 21; table[ 7].quad = 3; table[ 7].layer = 2; table[ 7].nslat = 21; table[ 8].quad = 3; table[ 8].layer = 3; table[ 8].nslat = 21; table[ 9].quad = 4; table[ 9].layer = 1; table[ 9].nslat = 19; table[10].quad = 4; table[10].layer = 2; table[10].nslat = 19; table[11].quad = 4; table[11].layer = 3; table[11].nslat = 19; dbtable->SetTable((char*)&table, MAX_DB_INDEX); if(yr.Contains("sim")) dbtable->setFlavor("sim"); mgr->storeDbTable(dbtable); std::cout << "INFO: table saved to database" << std::endl; } std::cout << "INFO: Reading database" << std::endl; gSystem->Unsetenv("DB_ACCESS_MODE"); //gSystem->Unsetenv("DB_SERVER_LOCAL_CONFIG"); St_db_Maker *dbMk=new St_db_Maker("db", "MySQL:StarDb", "$STAR/StarDb"); dbMk->SetDebug(); dbMk->SetDateTime(date,time); // event or run start time, set to your liking if(yr.Contains("ofl")) {dbMk->SetFlavor("ofl");} else if(yr.Contains("sim")) {dbMk->SetFlavor("sim");} dbMk->Init(); dbMk->Make(); TDataSet *DB = 0; DB = dbMk->GetDataBase("Geometry/fps/fpsChannelGeometry"); if (!DB) std::cout << "ERROR: no table found in db, or malformed local db config" << std::endl; St_fpsChannelGeometry *dataset = 0; dataset = (St_fpsChannelGeometry*) DB->Find("fpsChannelGeometry"); if (!dataset) { td::cout << "ERROR: dataset does not contain requested table" << std::endl; return; } Int_t rows = dataset->GetNRows(); if (rows > 1) { std::cout << "INFO: found INDEXED table with " << rows << " rows" << std::endl; } TDatime val[2]; dbMk->GetValidity((TTable*)dataset,val); std::cout << "Dataset validity range: [ " << val[0].GetDate() << "." << val[0].GetTime() << " - " << val[1].GetDate() << "." << val[1].GetTime() << " ] " << std::endl; fpsChannelGeometry_st *tbl = dataset->GetTable(); for (Int_t i = 0; i < rows; i++) { std::cout << Form("Row=%4d quad=%1d layer=%1d nslat=%2d\n",i, tbl[i].quad,tbl[i].layer,tbl[i].nslat); } }
void storetofTDIGOnTray() { const Bool_t Debug = kFALSE; const Int_t NBOARD = 8; //-- year8 // const Int_t NTRAY = 5; //-- year9 // const Int_t NTRAY = 94; // const Int_t NVPDTRAY = 2; // const Int_t NMAX = 120; //-- year10/year11 const Int_t NTRAY = 120; const Int_t NVPDTRAY = 2; const Int_t NMAX = 300; //123; //-- load dBase and Table definition libraries gSystem->Load("St_base"); gSystem->Load("StChain"); gSystem->Load("StUtilities"); gSystem->Load("St_Tables.so"); gSystem->Load("StDbLib.so"); gSystem->Load("libStDb_Tables.so"); //-- get the singleton manager StDbManager* dbManager = StDbManager::Instance(); //-- connect to the db & get an empty container StDbConfigNode* configNode = dbManager->initConfig("Calibrations_tof"); //---------------------------------------- // TString ZStoreTime = "2007-11-01 00:00:03"; // TString ZStoreTime = "2008-11-01 00:00:00"; // TString ZStoreTime = "2009-11-01 00:00:00"; // TString ZStoreTime = "2010-12-20 00:00:01"; // TString ZStoreTime = "2011-04-20 00:00:00"; // TString ZStoreTime = "2011-12-20 00:00:00"; TString ZStoreTime = "2012-12-20 00:00:00"; //-- add table to the container with descriptor given by Database StDbTable* tofTDIGOnTray = configNode->addDbTable("tofTDIGOnTray"); //-- fill structures & store times tofTDIGOnTray_st *tdig = new tofTDIGOnTray_st[NMAX+NVPDTRAY]; //-- year8 // Short_t trayId[NTRAY+NVPDTRAY] = {76, 77, 78, 79, 80, 121, 122}; // Short_t tdigId[NTRAY+NVPDTRAY][NBOARD] = { // 36, 26, 27, 29, 25, 23, 22, 21, // 30, 31, 33, 35, 28, 32, 34, 37, // 74, 63, 49, 72, 64, 53, 59, 52, // 70, 51, 75, 65, 66, 50, 71, 68, // 46, 62, 72, 69, 61, 58, 42, 43, // 89, 91, 0, 0, 84, 82, 0, 0, // 85, 79, 0, 0, 80, 83, 0, 0 // }; // ------------------------------ //-- year10 // Short_t trayId[NMAX] = { 68, 58, 63, 6,106, 67, 61, 50, 57, 60, // 47, 46, 87,133, 64, 72, 62, 42, 14, 11, // 28, 7, 25, 33, 19, 17, 37, 21, 30, 35, // 8, 20, 31, 27, 12, 9, 10, 29, 34, 13, // 16, 77, 89, 36, 39, 23, 32, 15, 24, 18, // 59, 66, 70, 38, 41, 45, 52, 54, 53, 55, // 84,105, 94, 91, 95, 48, 44, 22, 26, 49, // 5, 2, 75, 40,117, 4,121, 99,120,122, // 111,116,118,119,109,101,100,107, 98, 56, // 88,115,102,108,112,110,113,114,123, 90, // 93, 65, 51, 73, 76, 83, 69, 80, 82, 74, // 97, 79, 43, 86, 85,132,104, 92, 96,103}; // // B-132; C-133 renamed // ------------------------------ //-- year11 // ifstream infile("data/run11/INL/tdigs_01122011.txt"); // VPD boards until April 2011 // Short_t tdigId_Vpd[NVPDTRAY][NBOARD] = { 89, 91, 1102, 0, 885, 82, 0, 0, // 85, 79, 1101, 0, 80, 83, 0, 0}; // // Short_t trayId[NMAX] = { 68, 58, 63, 6,106, 67, 61, 50, 57, 71, // 47, 46, 87,133, 64, 72, 62, 42, 14, 11, // 28, 7, 25, 33, 19, 17, 37, 21, 30, 35, // 8, 20, 31, 27, 12, 9, 10, 29, 34, 13, // 16, 77, 89, 36, 39, 23, 32, 15, 24, 18, // 59, 66, 70, 38, 41, 45, 52, 54, 53, 55, // 84,105, 94, 91, 95, 48, 44, 22, 26, 49, // 5, 2, 75, 40,117, 4,121, 99,120,122, // 111,116,118,119,109,101,100,107, 98, 56, // 88,115,102,108,112,110,113,114,123, 90, // 93, 65, 51, 73, 76, 83, 69, 80, 82, 74, // 97, 79, 43, 86, 85,132,104, 92, 96,103}; // // B-132; C-133 renamed // ------------------------------ //-- year12 // changed trays at W8, W23, E93 // ifstream infile("data/run12/INL/tdigs_120106.txt"); // Short_t trayId[NTRAY] = { 68, 58, 63, 6,106, 67, 61, 81, 57, 71, // 47, 46, 87,133, 64, 72, 62, 42, 14, 11, // 28, 7, 3, 33, 19, 17, 37, 21, 30, 35, // 8, 20, 31, 27, 12, 9, 10, 29, 34, 13, // 16, 77, 89, 36, 39, 23, 32, 15, 24, 18, // 59, 66, 70, 38, 41, 45, 52, 54, 53, 55, // 84,105, 94, 91, 95, 48, 44, 22, 26, 49, // 5, 2, 75, 40,117, 4,121, 99,120,122, // 111,116,118,119,109,101,100,107, 98, 56, // 88,115, 78,108,112,110,113,114,123, 90, // 93, 65, 51, 73, 76, 83, 69, 60, 82, 74, // 97, 79, 43, 86, 85,132,104, 92, 96,103}; // // B-132; C-133 renamed // ------------------------------ //-- year13 // changed trays at W8, W23, W38, E93, E95, E109 // see http://www.star.bnl.gov/HyperNews-star/protected/get/startof/2675.html ifstream infile("data/run13/INL/tdigs_20130115.txt"); Short_t trayId[NTRAY] = { 68, 58, 63, 6,106, 67, 61, 50, 57, 71, 47, 46, 87,133, 64, 72, 62, 42, 14, 11, 28, 7, 25, 33, 19, 17, 37, 21, 30, 35, 8, 20, 31, 27, 12, 9, 10, 3, 34, 13, 16, 77, 89, 36, 39, 23, 32, 15, 24, 18, 59, 66, 70, 38, 41, 45, 52, 54, 53, 55, 84,105, 94, 91, 95, 48, 44, 22, 26, 49, 5, 2, 75, 40,117, 4,121, 99,120,122, 111,116,118,119,109,101,100,107, 98, 56, 88,115,102,108, 81,110,113,114,123, 90, 93, 65, 51, 73, 76, 83, 69, 80, 82, 74, 97, 79, 43, 86, 85,132,104, 92, 96,103}; // B-132; C-133 renamed // ------------------------------ Short_t tdigId[NTRAY][NBOARD]; //-- run 11 AuAu@18GeV, run 12, run 13 Short_t tdigId_Vpd[NVPDTRAY][NBOARD] = { 89, 91, 495, 0, 885, 82, 0, 0, 85, 79, 1101, 0, 80, 83, 0, 0}; Short_t tId[NMAX], boardId[NMAX][NBOARD]; // two additional trays int i(0),j(0); // clear counters int trayNum, oldTrayNum, iboard, boardNum; cout << "Reading UT-Austin database info ... " << endl; if (infile) { // read first entry infile >> trayNum >> iboard >> boardNum; tId[i] = (Short_t)trayNum; boardId[i][iboard-1] = (Short_t)boardNum; oldTrayNum = trayNum; // increment general counter (total# of TDIGs, only for debugging) and dump data if (Debug) cout << j++ << " " << i << " " << trayNum << " "<< iboard << " " << boardNum << endl; // loop in the remaining entries while ( infile >> trayNum >> iboard >> boardNum ) { // increment i only when trayNum incrememts ... if (trayNum != oldTrayNum) { tId[++i] = (Short_t)trayNum; oldTrayNum = trayNum; } // increment general counter (total# of TDIGs, only for debugging) and dump data if (Debug) cout << j++ << " " << i << " " << trayNum << " "<< iboard << " " << boardNum << endl; boardId[i][iboard-1] = (Short_t)boardNum; } } infile.close(); cout << "... done reading database info" << endl; for(int i=0;i<NTRAY;i++) { for(int j=0;j<NBOARD;j++) { tdigId[i][j] = 0; } Short_t thisTray = trayId[i]; int index = -1; for(int j=0;j<NMAX;j++) { if(thisTray==tId[j]) { index = j; break; } } if (Debug) cout << "pos = " << i+1 << " tray = " << thisTray << " index = " << index << " : "; if(index<0||index>=NMAX) { cout<< "ERROR: unexpected index "<< index << endl; continue;} for(int j=0;j<NBOARD;j++) { tdigId[i][j] = boardId[index][j]; if (Debug) cout << tdigId[i][j] << " "; } if (Debug) cout << endl; } /* { 89, 91, 0, 0, 84, 82, 0, 0, 85, 79, 0, 0, 80, 83, 0, 0 }; */ //-- include the VPD TDIG mapping for(int i=0;i<NTRAY+NVPDTRAY;i++) { tdig[i].trayId = i+1; for(int j=0;j<NBOARD;j++) { if(i<NTRAY) { tdig[i].tdigId[j] = tdigId[i][j]; } else { tdig[i].tdigId[j] = tdigId_Vpd[i-NTRAY][j]; } } } //-- create output file for test/verification purposes ofstream outData("testTDIGMap.dat"); for(int i=0;i<NTRAY+NVPDTRAY;i++) { for(int j=0;j<NBOARD;j++) { outData << setw(5) << tdig[i].tdigId[j]; } outData << endl; } outData.close(); //-- store data in table tofTDIGOnTray->SetTable((char*)tdig, NTRAY+NVPDTRAY); //- set store time dbManager->setStoreTime(ZStoreTime.Data()); //- store table in dBase cout<<"Preparing to upload ... "<<endl; dbManager->storeDbTable(tofTDIGOnTray); cout << "... done" << endl; }
void storetofINLSCorrStep2() //int main(int argc, char *argv[]) { const Int_t NMAX = 1200; const Int_t NTDC = 3; // # of tdcs per board const Int_t NCHAN = 8; // # of channels per tdc //-- load dBase and Table definition libraries gSystem->Load("St_base"); gSystem->Load("StChain"); gSystem->Load("StUtilities"); gSystem->Load("St_Tables.so"); gSystem->Load("StDbLib.so"); gSystem->Load("libStDb_Tables.so"); //-- get the singleton manager StDbManager* dbManager = StDbManager::Instance(); //-- connect to the db & get an empty container StDbConfigNode* configNode = dbManager->initConfig("Calibrations_tof"); //---------------------------------------- TString ZStoreTime = "2009-09-01 00:00:00"; //-- add table to the container with descriptor given by Database StDbTable* tofINLSCorr = configNode->addDbTable("tofINLSCorr"); //-- fill structures & store times tofINLSCorr_st *inlcorr= new tofINLSCorr_st[NMAX*NTDC*NCHAN]; Int_t NFILL = 0; Int_t NBOARD = 0; // read in inltable file by file. TH1S *hINLSCorr[NMAX][NTDC][NCHAN]; Bool_t *hFlag[NMAX]; for(int i=0;i<NMAX;i++) hFlag[i] = false; TFile *f1 = new TFile("INL_test_0_300.root"); TFile *f2 = new TFile("INL_test_300_600.root"); TFile *f3 = new TFile("INL_test_600_900.root"); TFile *f4 = new TFile("INL_test_900_1200.root"); for(int iboard=0;iboard<NMAX;iboard++) { if(iboard%100==0) cout << " Processing board Id = " << iboard << endl; for(int itdc=0;itdc<NTDC;itdc++){ for(int ichan=0;ichan<NCHAN;ichan++) { char hisname[512]; sprintf(hisname,"b_%d_tdc_%d_chan_%d",iboard,itdc,ichan); if(iboard<300) { hINLSCorr[iboard][itdc][ichan] = (TH1S *)f1->Get(hisname); } else if(iboard<600) { hINLSCorr[iboard][itdc][ichan] = (TH1S *)f2->Get(hisname); } else if(iboard<900) { hINLSCorr[iboard][itdc][ichan] = (TH1S *)f3->Get(hisname); } else { hINLSCorr[iboard][itdc][ichan] = (TH1S *)f4->Get(hisname); } if(!hINLSCorr[iboard][itdc][ichan]) { // cout << " Histogram board " << iboard << " itdc " << itdc << " ichan " << ichan << " doesn't exist!" << endl; continue; } inlcorr[NFILL].tdigId = (Short_t)iboard; inlcorr[NFILL].tdcChanId = (Short_t)(itdc*NCHAN+ichan); for(int j=0;j<1024;j++) { inlcorr[NFILL].INLCorr[j]=(Short_t)(hINLSCorr[iboard][itdc][ichan]->GetBinContent(j+1)); } NFILL++; } // end of loop channel } // end of loop TDC NBOARD++; hFlag[iboard] = true; } // end of loop board cout<<" prepare to upload data to DB NFILL="<<NFILL<<" NBOARD="<<NBOARD<<endl; char rootname[100]; sprintf(rootname,"INL_test.root"); TFile *fout = new TFile(rootname,"recreate"); int index = 0; for(int iboard=0;iboard<NMAX;iboard++) { if(!hFlag[iboard]) continue; for(int itdc=0;itdc<NTDC;itdc++){ for(int ichan=0;ichan<NCHAN;ichan++) { if(!hINLSCorr[iboard][itdc][ichan]) continue; hINLSCorr[iboard][itdc][ichan]->Write(); /* cout << " Ids = " << iboard << " " << itdc << " " << ichan << endl; cout << " IN Ids = " << inlcorr[index].tdigId << " " << inlcorr[index].tdcChanId << endl; for(int j=0;j<1024;j++) { if(j%100==0) cout << " INL j = " << j << " " << inlcorr[index].INLCorr[j] << endl; } */ index++; } } } fout->Close(); //- store data in table /* tofINLSCorr->SetTable((char*)inlcorr, NFILL); //- set store time dbManager->setStoreTime(ZStoreTime.Data()); //- store table in dBase cout<<" here "<<endl; dbManager->storeDbTable(tofINLSCorr); cout<<"uploaded"<<endl; // return 0; */ }
void write_ist_mapping() { gSystem->Setenv("DB_ACCESS_MODE", "write"); gROOT->Macro("LoadLogger.C"); gSystem->Load("St_base.so"); gSystem->Load("libStDb_Tables.so"); gSystem->Load("StDbLib.so"); TString storeTime = "2014-01-29 00:00:01"; cout <<"The RTS Start date and time is " << storeTime<<endl; StDbManager* mgr = StDbManager::Instance(); StDbConfigNode* node = mgr->initConfig("Calibrations_ist"); StDbTable* dbtable = node->addDbTable("istMapping"); mgr->setStoreTime(storeTime.Data()); Int_t elecId=-1, ladder=-1, sensor=-1, column=-1, row=-1; istMapping_st table; for (int i = 0; i < 110592; i++) { table.mapping[i] = i+1; } for(int rdo=1; rdo<=6; rdo++) { for(int arm=0; arm<6; arm++) { for(int apv=0; apv<24; apv++) { for(int chan=0; chan<128; chan++) { elecId = (rdo-1)*6*24*128+arm*24*128+apv*128+chan; // the following mapping refered from IST readout channel datasheet if(elecId<101376) ladder = 22 - elecId/4608; else ladder = 46 - elecId/4608; //sections B and C swapped on ladder 13 if(elecId>=43008 && elecId<44544) //section C sensor = 4 - (elecId%4608)/768; else if(elecId>=44544 && elecId<46080) //section B sensor = 8 - (elecId%4608)/768; else sensor = 6 - (elecId%4608)/768; Int_t pad = (elecId%4608)%768; column = 12 - pad/64; if(column%2) row = 64 - pad%64; else row = 1 + pad%64; table.mapping[elecId] = (ladder-1)*4608 + (sensor-1)*768 + (column-1)*64 + row; } } } } // Store data to the StDbTable dbtable->SetTable((char*)&table, 1); // Store table to database mgr->storeDbTable(dbtable); };
void storetofTotbCorr(const Bool_t mTest = 1) { const int mNTray = 120; // for test const int mNTDIG = 8; const int mNVPD = 19; const int mNMODULE = 32; const int mNCELL = 6; const int mNMODPERBOARD = 4; //-- load dBase and Table definition libraries gSystem->Load("St_base"); gSystem->Load("StChain"); gSystem->Load("StUtilities"); gSystem->Load("St_Tables.so"); gSystem->Load("StDbLib.so"); gSystem->Load("libStDb_Tables.so"); //-- get the singleton manager StDbManager* dbManager = StDbManager::Instance(); //-- connect to the db & get an empty container StDbConfigNode* configNode = dbManager->initConfig("Calibrations_tof"); //---------------------------------------- // TString StoreTime = "2008-02-01 00:00:03"; // TString StoreTime = "2008-03-04 16:00:01"; // TString StoreTime = "2009-03-15 00:00:00"; // TString StoreTime = "2009-11-01 00:00:00"; // 200 GeV preliminary // TString StoreTime = "2010-03-18 18:00:00"; // 62 GeV preliminary // TString StoreTime = "2010-04-08 15:00:00"; // 39 GeV preliminary ifstream inTime; inTime.open("input/timestamp"); string time; if (inTime.is_open()) { getline(inTime, time); inTime.close(); } else { cout << " Unable to open the TimeStamp file! EXIT! " << endl; return; } TString StoreTime = time; cout << " Store Time " << StoreTime.Data() << endl; //-- add table to the container with descriptor given by Database StDbTable* tofTotbCorr = configNode->addDbTable("tofTotbCorr"); //-- fill structures & store times //tofTotbCorr_st *totcorr= new tofTotbCorr_st[mNTray*mNTDIG]; tofTotbCorr_st *totcorr= new tofTotbCorr_st[23040]; //======================================= // read in pvpdTot file by file. Double_t diff[mNVPD*2]; Double_t toffset; ifstream infile; //======================================== //Double_t X[mNTray][mNTDIG][60]; //Double_t Y[mNTray][mNTDIG][60]; Double_t X[mNTray][mNMODULE][mNCELL][60]; Double_t Y[mNTray][mNMODULE][mNCELL][60]; infile.open("input/totCali_4DB.dat"); if (!infile.is_open()){ cerr <<" unable to open input/totCali_4DB.dat; bailing out ..." << endl; exit(-1); } int calibSize; infile >> calibSize; cout << "reading in " << calibSize << " calibration records ... " << endl; switch (calibSize) { case 960 : // TDIG BOARD BASED for(int i=0;i<mNTray;i++) { for(int j=0;j<mNTDIG;j++) { int tray, board, nnn; infile >> tray >> board; infile >> nnn; //cout << " tray = " << tray << " board = " << board << endl; for(int k=0;k<60;k++) { if(nnn>0&&k<nnn+1) { infile >> X[tray-1][board-1][0][k]; } else { X[tray-1][board-1][0][k] = 0.0; } } for(int k=0;k<60;k++) { if(nnn>0&&k<nnn+1) { infile >> Y[tray-1][board-1][0][k]; } else { Y[tray-1][board-1][0][k] = 0.0; } }
void fPostSlatId_db( const char* opt = "", const char* year = "17sim", const char* input = "fPostSlatId.txt") { // storeTime is beginning time for validity range in case of WRITING DB TString option(opt), yr(year), storeTime; int date, time; // time for READING DB std::cout <<"year = " <<year <<std::endl; if (yr.Contains("17sim")) { storeTime = "2016-12-10 00:00:00"; date = 20161210; time = 0; } else if (yr.Contains("17ofl")) { storeTime = "2016-12-20 00:00:01"; date = 20161220; time = 1; } else { std::cout << "Please specify valid year tag\n"; exit; } std::cout << "Opt =" << opt << "\n"; std::cout << "write = " << option.Contains("writedb") << "\n"; std::cout << "storetime = " << storeTime << "\n"; std::cout << "date, time = " << date <<" "<< time << "\n"; gROOT->Macro("./loadlib.C"); //------------------------------------------- const Int_t MAX_DB_INDEX = 241; fpostSlatId_st in[MAX_DB_INDEX]; FILE *FP = fopen(input, "r"); if (!FP) { printf("Could not open %s\n", input); exit; } printf("\nReading %s\n", input); char line[1000]; int n = 0; while (fgets(line, 1000, FP) != NULL) { sscanf(line,"%d %d %d %d ", &in[n].slatid, &in[n].quad, &in[n].layer, &in[n].slat); printf("slatId=%3d quad=%2d layer=%2d slat=%2d\n", in[n].slatid, in[n].quad, in[n].layer, in[n].slat); n++; } printf("Found %d entries\n", n); //------------------------------------------- if (option.Contains("writedb")) { gSystem->Setenv("DB_ACCESS_MODE", "write"); StDbManager* mgr = StDbManager::Instance(); StDbConfigNode* node = mgr->initConfig("Geometry_fps"); StDbTable* dbtable = node->addDbTable("fpostSlatId"); mgr->setStoreTime(storeTime.Data()); dbtable->SetTable((char*)&in, MAX_DB_INDEX); if (yr.Contains("sim")) dbtable->setFlavor("sim"); mgr->storeDbTable(dbtable); std::cout << "INFO: table saved to database" << std::endl; } //------------------------------------------- if (option.Contains("readdb")) { std::cout << "INFO: Reading database" << std::endl; gSystem->Unsetenv("DB_ACCESS_MODE"); //gSystem->Unsetenv("DB_SERVER_LOCAL_CONFIG"); St_db_Maker* dbMk = new St_db_Maker("db", "MySQL:StarDb", "$STAR/StarDb"); dbMk->SetDebug(); dbMk->SetDateTime(date, time); // event or run start time, set to your liking if (yr.Contains("ofl")) { dbMk->SetFlavor("ofl"); } else if (yr.Contains("sim")) { dbMk->SetFlavor("sim"); } dbMk->Init(); dbMk->Make(); TDataSet *DB = 0; DB = dbMk->GetDataBase("Geometry/fps/fpostSlatId"); if (!DB) std::cout << "ERROR: no table found in db, or malformed local db config" << std::endl; St_fpostSlatId *dataset = 0; dataset = (St_fpostSlatId*) DB->Find("fpostSlatId"); if (!dataset) { std::cout << "ERROR: dataset does not contain requested table" << std::endl; return; } Int_t rows = dataset->GetNRows(); if (rows > 1) std::cout << "INFO: found INDEXED table with " << rows << " rows" << std::endl; TDatime val[2]; dbMk->GetValidity((TTable*)dataset, val); std::cout << "Dataset validity range: [ " << val[0].GetDate() << "." << val[0].GetTime() << " - " << val[1].GetDate() << "." << val[1].GetTime() << " ] " << std::endl; fpostSlatId_st *table = (fpostSlatId_st*)dataset->GetTable(); for (Int_t i = 0; i < rows; i++) { std::cout << Form("Row=%3d slatid=%3d quad=%2d layer=%2d slat=%2d\n", i, table[i].slatid, table[i].quad, table[i].layer, table[i].slat); } } return; }//Main