28 void storetofTotbCorr(
const Bool_t mTest = 1)
30 const int mNTray = 120;
33 const int mNMODULE = 32;
35 const int mNMODPERBOARD = 4;
38 gSystem->Load(
"St_base");
39 gSystem->Load(
"StChain");
40 gSystem->Load(
"StUtilities");
41 gSystem->Load(
"St_Tables.so");
43 gSystem->Load(
"StDbLib.so");
44 gSystem->Load(
"libStDb_Tables.so");
50 StDbConfigNode* configNode = dbManager->initConfig(
"Calibrations_tof");
60 inTime.open(
"input/timestamp");
62 if (inTime.is_open()) {
63 getline(inTime, time);
66 cout <<
" Unable to open the TimeStamp file! EXIT! " << endl;
69 TString StoreTime = time;
70 cout <<
" Store Time " << StoreTime.Data() << endl;
73 StDbTable* tofTotbCorr = configNode->addDbTable(
"tofTotbCorr");
77 tofTotbCorr_st *totcorr=
new tofTotbCorr_st[23040];
82 Double_t diff[mNVPD*2];
89 Double_t X[mNTray][mNMODULE][mNCELL][60];
90 Double_t Y[mNTray][mNMODULE][mNCELL][60];
92 infile.open(
"input/totCali_4DB.dat");
93 if (!infile.is_open()){
94 cerr <<
" unable to open input/totCali_4DB.dat; bailing out ..." << endl;
100 cout <<
"reading in " << calibSize <<
" calibration records ... " << endl;
103 for(
int i=0;i<mNTray;i++) {
104 for(
int j=0;j<mNTDIG;j++) {
105 int tray, board, nnn;
106 infile >> tray >> board;
109 for(
int k=0;k<60;k++) {
111 infile >> X[tray-1][board-1][0][k];
113 X[tray-1][board-1][0][k] = 0.0;
116 for(
int k=0;k<60;k++) {
118 infile >> Y[tray-1][board-1][0][k];
120 Y[tray-1][board-1][0][k] = 0.0;
127 for(
int i=0;i<mNTray;i++) {
128 for(
int j=0;j<mNMODULE;j++) {
129 for(
int jj=0;jj<mNCELL;jj++) {
130 int tray, module, cell, nnn;
131 infile >> tray >> module >> cell;
134 for(
int k=0;k<60;k++) {
136 infile >> X[tray-1][module-1][cell-1][k];
138 X[tray-1][module-1][cell-1][k] = 0.0;
141 for(
int k=0;k<60;k++) {
143 infile >> Y[tray-1][module-1][cell-1][k];
145 Y[tray-1][module-1][cell-1][k] = 0.0;
153 cerr<<
"Unknown calib-size " << calibSize <<
"; bailing out ... " << endl;
159 cout <<
"preparing database records ... " << endl;
163 for (
int tray=1;tray<mNTray+1;tray++){
164 for (
int module=1;module<mNMODULE+1;module++){
165 for (
int cell=1;cell<mNCELL+1;cell++){
167 totcorr[index].trayId = (Short_t)tray;
168 totcorr[index].moduleId = (Short_t)module;
169 totcorr[index].cellId = (Short_t)cell;
170 totcorr[index].tdcId = 0;
171 int board = ((module-1)/mNMODPERBOARD) + 1 ;
172 for(
int j=0;j<60;j++) {
173 totcorr[index].tot[j] = X[tray-1][board-1][0][j];
174 totcorr[index].corr[j] = Y[tray-1][board-1][0][j];
197 for (
int tray=1;tray<mNTray+1;tray++){
198 for (
int module=1;module<mNMODULE+1;module++){
199 for (
int cell=1;cell<mNCELL+1;cell++){
201 totcorr[index].trayId = (Short_t)tray;
202 totcorr[index].moduleId = (Short_t)module;
203 totcorr[index].cellId = (Short_t)cell;
204 totcorr[index].tdcId = 0;
205 for(
int j=0;j<60;j++) {
206 totcorr[index].tot[j] = X[tray-1][module-1][cell-1][j];
207 totcorr[index].corr[j] = Y[tray-1][module-1][cell-1][j];
217 cout <<
"Storing records in totCorr_test.dat (this may take a long time) ... " << endl;
222 outData.open(
"totCorr_test.dat");
223 for(
int i=0;i<nRow;i++) {
224 outData << setw(6) << totcorr[i].trayId << setw(6) << totcorr[i].moduleId << setw(6) << totcorr[i].cellId << setw(6) << totcorr[i].tdcId << endl;
225 for(
int j=0;j<60;j++) {
226 outData << setw(15) << totcorr[i].tot[j];
229 for(
int j=0;j<60;j++) {
230 outData << setw(15) << totcorr[i].corr[j];
238 cout<<
" prepare to upload data to DB"<<endl;
240 tofTotbCorr->
SetTable((
char*)totcorr, nRow);
242 dbManager->setStoreTime(StoreTime.Data());
244 dbManager->storeDbTable(tofTotbCorr);
245 cout<<
"uploaded"<<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