17 void storetofTDIGOnTray() {
18 const Bool_t Debug = kFALSE;
19 const Int_t NBOARD = 8;
27 const Int_t NTRAY = 120;
28 const Int_t NVPDTRAY = 2;
29 const Int_t NMAX = 300;
32 gSystem->Load(
"St_base");
33 gSystem->Load(
"StChain");
34 gSystem->Load(
"StUtilities");
35 gSystem->Load(
"St_Tables.so");
37 gSystem->Load(
"StDbLib.so");
38 gSystem->Load(
"libStDb_Tables.so");
44 StDbConfigNode* configNode = dbManager->initConfig(
"Calibrations_tof");
53 TString ZStoreTime =
"2012-12-20 00:00:00";
56 StDbTable* tofTDIGOnTray = configNode->addDbTable(
"tofTDIGOnTray");
59 tofTDIGOnTray_st *tdig =
new tofTDIGOnTray_st[NMAX+NVPDTRAY];
128 ifstream infile(
"data/run13/INL/tdigs_20130115.txt");
129 Short_t trayId[NTRAY] = { 68, 58, 63, 6,106, 67, 61, 50, 57, 71,
130 47, 46, 87,133, 64, 72, 62, 42, 14, 11,
131 28, 7, 25, 33, 19, 17, 37, 21, 30, 35,
132 8, 20, 31, 27, 12, 9, 10, 3, 34, 13,
133 16, 77, 89, 36, 39, 23, 32, 15, 24, 18,
134 59, 66, 70, 38, 41, 45, 52, 54, 53, 55,
135 84,105, 94, 91, 95, 48, 44, 22, 26, 49,
136 5, 2, 75, 40,117, 4,121, 99,120,122,
137 111,116,118,119,109,101,100,107, 98, 56,
138 88,115,102,108, 81,110,113,114,123, 90,
139 93, 65, 51, 73, 76, 83, 69, 80, 82, 74,
140 97, 79, 43, 86, 85,132,104, 92, 96,103};
143 Short_t tdigId[NTRAY][NBOARD];
146 Short_t tdigId_Vpd[NVPDTRAY][NBOARD] = { 89, 91, 495, 0, 885, 82, 0, 0,
147 85, 79, 1101, 0, 80, 83, 0, 0};
149 Short_t tId[NMAX], boardId[NMAX][NBOARD];
151 int trayNum, oldTrayNum, iboard, boardNum;
153 cout <<
"Reading UT-Austin database info ... " << endl;
156 infile >> trayNum >> iboard >> boardNum;
157 tId[i] = (Short_t)trayNum;
158 boardId[i][iboard-1] = (Short_t)boardNum;
159 oldTrayNum = trayNum;
161 if (Debug) cout << j++ <<
" " << i <<
" " << trayNum <<
" "<< iboard <<
" " << boardNum << endl;
164 while ( infile >> trayNum >> iboard >> boardNum ) {
166 if (trayNum != oldTrayNum) {
167 tId[++i] = (Short_t)trayNum;
168 oldTrayNum = trayNum;
171 if (Debug) cout << j++ <<
" " << i <<
" " << trayNum <<
" "<< iboard <<
" " << boardNum << endl;
173 boardId[i][iboard-1] = (Short_t)boardNum;
177 cout <<
"... done reading database info" << endl;
179 for(
int i=0;i<NTRAY;i++) {
180 for(
int j=0;j<NBOARD;j++) { tdigId[i][j] = 0; }
182 Short_t thisTray = trayId[i];
184 for(
int j=0;j<NMAX;j++) {
185 if(thisTray==tId[j]) {
190 if (Debug) cout <<
"pos = " << i+1 <<
" tray = " << thisTray <<
" index = " << index <<
" : ";
191 if(index<0||index>=NMAX) { cout<<
"ERROR: unexpected index "<< index << endl;
continue;}
192 for(
int j=0;j<NBOARD;j++) {
193 tdigId[i][j] = boardId[index][j];
194 if (Debug) cout << tdigId[i][j] <<
" ";
196 if (Debug) cout << endl;
206 for(
int i=0;i<NTRAY+NVPDTRAY;i++) {
207 tdig[i].trayId = i+1;
208 for(
int j=0;j<NBOARD;j++) {
210 tdig[i].tdigId[j] = tdigId[i][j];
212 tdig[i].tdigId[j] = tdigId_Vpd[i-NTRAY][j];
218 ofstream outData(
"testTDIGMap.dat");
219 for(
int i=0;i<NTRAY+NVPDTRAY;i++) {
220 for(
int j=0;j<NBOARD;j++) {
221 outData << setw(5) << tdig[i].tdigId[j];
228 tofTDIGOnTray->
SetTable((
char*)tdig, NTRAY+NVPDTRAY);
230 dbManager->setStoreTime(ZStoreTime.Data());
232 cout<<
"Preparing to upload ... "<<endl;
233 dbManager->storeDbTable(tofTDIGOnTray);
234 cout <<
"... done" << endl;
virtual void SetTable(char *data, int nrows, int *idList=0)
calloc'd version of data for StRoot
static StDbManager * Instance()
strdup(..) is not ANSI