27 void storetofZbCorr(
const Bool_t mTest = 1)
29 const int mNTray = 120;
32 const int mNMODULE = 32;
34 const int mNMODPERBOARD = 4;
37 gSystem->Load(
"St_base");
38 gSystem->Load(
"StChain");
39 gSystem->Load(
"StUtilities");
40 gSystem->Load(
"St_Tables.so");
42 gSystem->Load(
"StDbLib.so");
43 gSystem->Load(
"libStDb_Tables.so");
49 StDbConfigNode* configNode = dbManager->initConfig(
"Calibrations_tof");
59 inTime.open(
"input/timestamp");
61 if (inTime.is_open()) {
62 getline(inTime, time);
65 cout <<
" Unable to open the TimeStamp file! EXIT! " << endl;
68 TString StoreTime = time;
69 cout <<
" Store Time " << StoreTime.Data() << endl;
72 StDbTable* tofZbCorr = configNode->addDbTable(
"tofZbCorr");
76 tofZbCorr_st *zcorr=
new tofZbCorr_st[23040];
83 Double_t X[mNTray][mNMODULE][mNCELL][60];
84 Double_t Y[mNTray][mNMODULE][mNCELL][60];
86 infile.open(
"input/zCali_4DB.dat");
87 if (!infile.is_open()){
88 cerr <<
" unable to open input/zCali_4DB.dat; bailing out ..." << endl;
94 cout <<
"reading in " << calibSize <<
" calibration records ... " << endl;
97 for(
int i=0;i<mNTray;i++) {
98 for(
int j=0;j<mNTDIG;j++) {
100 infile >> tray >> board;
103 for(
int k=0;k<60;k++) {
105 infile >> X[tray-1][board-1][0][k];
107 X[tray-1][board-1][0][k] = 0.0;
110 for(
int k=0;k<60;k++) {
112 infile >> Y[tray-1][board-1][0][k];
114 Y[tray-1][board-1][0][k] = 0.0;
121 for(
int i=0;i<mNTray;i++) {
122 for(
int j=0;j<mNMODULE;j++) {
123 for(
int jj=0;jj<mNCELL;jj++) {
124 int tray, module, cell, nnn;
125 infile >> tray >> module >> cell;
128 for(
int k=0;k<60;k++) {
130 infile >> X[tray-1][module-1][cell-1][k];
132 X[tray-1][module-1][cell-1][k] = 0.0;
135 for(
int k=0;k<60;k++) {
137 infile >> Y[tray-1][module-1][cell-1][k];
139 Y[tray-1][module-1][cell-1][k] = 0.0;
147 cerr<<
"Unknown calib-size " << calibSize <<
"; bailing out ... " << endl;
154 cout <<
"preparing database records ... " << endl;
158 for (
int tray=1;tray<mNTray+1;tray++){
159 for (
int module=1;module<mNMODULE+1;module++){
160 for (
int cell=1;cell<mNCELL+1;cell++){
162 zcorr[index].trayId = (Short_t)tray;
163 zcorr[index].moduleId = (Short_t)module;
164 zcorr[index].cellId = (Short_t)cell;
165 int board = ((module-1)/mNMODPERBOARD) + 1;
166 for(
int j=0;j<60;j++) {
167 zcorr[index].z[j] = X[tray-1][board-1][0][j];
168 zcorr[index].corr[j] = Y[tray-1][board-1][0][j];
189 for (
int tray=1;tray<mNTray+1;tray++){
190 for (
int module=1;module<mNMODULE+1;module++){
191 for (
int cell=1;cell<mNCELL+1;cell++){
193 zcorr[index].trayId = tray;
194 zcorr[index].moduleId = module;
195 zcorr[index].cellId = cell;
196 for(
int j=0;j<60;j++) {
197 zcorr[index].z[j] = X[tray-1][module-1][cell-1][j];
198 zcorr[index].corr[j] = Y[tray-1][module-1][cell-1][j];
205 cerr<<
"Unknown calib-size " << calibSize <<
"; bailing out ... " << endl;
210 cout <<
"Storing records in zCorr_test.dat (this may take a long time) ... " << endl;
215 outData.open(
"zCorr_test.dat");
216 for(
int i=0;i<nRow;i++) {
217 outData << setw(6) << zcorr[i].trayId << setw(6) << zcorr[i].moduleId << setw(6) << zcorr[i].cellId << endl;
218 for(
int j=0;j<60;j++) {
219 if(fabs(zcorr[i].z[j])<1.e-4 && fabs(zcorr[i].corr[j])<1.e-4)
continue;
220 outData << setw(15) << zcorr[i].z[j];
223 for(
int j=0;j<60;j++) {
224 if(fabs(zcorr[i].z[j])<1.e-4 && fabs(zcorr[i].corr[j])<1.e-4)
continue;
225 outData << setw(15) << zcorr[i].corr[j];
232 cout<<
" prepare to upload data to DB"<<endl;
234 tofZbCorr->
SetTable((
char*)zcorr, nRow);
236 dbManager->setStoreTime(StoreTime.Data());
238 dbManager->storeDbTable(tofZbCorr);
239 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