34 #include "tables/St_tofTDIGOnTray_Table.h"
35 #include "tables/St_tofINLCorr_Table.h"
36 #include "StMessMgr.h"
38 #include "StTofINLCorr.h"
40 StTofINLCorr::StTofINLCorr()
45 StTofINLCorr::~StTofINLCorr()
50 void StTofINLCorr::init() {
54 void StTofINLCorr::init(
StMaker *maker) {
58 void StTofINLCorr::initFromDbase(
StMaker *maker) {
60 gMessMgr->Info(
"StTofINLCorr -- rertieving the INL correction table",
"OS");
66 TDataSet *mDbTOFDataSet = maker->GetDataBase(
"Calibrations/tof/tofTDIGOnTray");
68 gMessMgr->Error(
"unable to access TOF tofTDIGonTray table",
"OS");
73 St_tofTDIGOnTray* tofTDIGOnTray =
static_cast<St_tofTDIGOnTray*
>(mDbTOFDataSet->
Find(
"tofTDIGOnTray"));
75 gMessMgr->Error(
"unable to get tof INL correction parameters",
"OS");
79 tofTDIGOnTray_st* tdigOnTray =
static_cast<tofTDIGOnTray_st*
>(tofTDIGOnTray->GetArray());
81 Int_t numRows = tofTDIGOnTray->GetNRows();
82 LOG_INFO <<
"number of rows = " << numRows << endm;
83 for (Int_t i=0;i<mNValidTrays+2;i++) {
84 Int_t trayId = (Int_t)tdigOnTray[i].trayId;
86 if(trayId==mEastVpdTrayId) {
87 for(Int_t j=0;j<mNTDIGOnTray;j++)
88 mTdigOnEastVpd[j] = (Int_t)tdigOnTray[i].tdigId[j];
89 }
else if (trayId==mWestVpdTrayId) {
90 for(Int_t j=0;j<mNTDIGOnTray;j++)
91 mTdigOnWestVpd[j] = (Int_t)tdigOnTray[i].tdigId[j];
92 }
else if (trayId>0 && trayId<= mNTray) {
93 for(Int_t j=0;j<mNTDIGOnTray;j++)
94 mTdigOnTray[trayId-1][j] = (Int_t)tdigOnTray[i].tdigId[j];
98 cout <<
" tray id=" << trayId;
99 for(
int j=0;j<mNTDIGOnTray;j++) {
100 cout <<
" " << tdigOnTray[i].tdigId[j];
107 mDbTOFDataSet = maker->GetDataBase(
"Calibrations/tof/tofINLCorr");
109 gMessMgr->Error(
"unable to access TOF tofINLCorr table",
"OS");
113 St_tofINLCorr* tofINLCorr =
static_cast<St_tofINLCorr*
>(mDbTOFDataSet->
Find(
"tofINLCorr"));
115 gMessMgr->Error(
"unable to get tof INL correction parameters",
"OS");
119 tofINLCorr_st* inlcorr =
static_cast<tofINLCorr_st*
>(tofINLCorr->GetArray());
121 numRows = tofINLCorr->GetNRows();
122 if(numRows>mNTDIGMAX*mNChanOnTDIG) {
123 { LOG_INFO <<
" !!! # of Rows in tofINLCorr table exceed the array limit in this function !!! Trancated !!! " << endm; }
126 Int_t tdigId_old = 0;
127 for (Int_t i=0;i<numRows;i++) {
128 if(NTdig>mNTDIGMAX) {
129 { LOG_INFO <<
" !!! # of boards read-in exceeds the array limit in this function !!! Trancated !!! " << endm; }
134 int tdigId = (Int_t)(inlcorr[i].tdigId);
135 int tdcChanId = (Int_t)(inlcorr[i].tdcChanId);
136 if(tdigId!=tdigId_old) {
137 mBoardId[NTdig] = tdigId;
143 if(maker->Debug()) { LOG_INFO <<
" tdigId=" << tdigId <<
" tdcChanId=" << tdcChanId << endm; }
144 for(Int_t j=0;j<mNChanMAX;j++) {
145 float corr = (Float_t)(inlcorr[i].INLCorr[j]);
146 mINLCorr[NTdig-1][tdcChanId][j] = corr;
148 if(maker->Debug()&&(j%200==0)) {
152 if(maker->Debug()) cout << endl;
155 LOG_INFO <<
" Total # of boards read in : " << NTdig << endm;
158 for(Int_t i=0;i<NTdig;i++) {
159 int boardId = mBoardId[i];
160 if(boardId>0 && boardId<=mNBoardIdMAX) {
161 mBoardId2Index[boardId] = i;
163 { LOG_INFO <<
" Warning! boardId " << boardId <<
" out of range!" << endm; }
170 void StTofINLCorr::Reset() {
172 for(Int_t i=0;i<mNTray;i++) {
173 for(Int_t j=0;j<mNTDIGOnTray;j++) {
174 mTdigOnTray[i][j] = 0;
177 for(Int_t i=0;i<mNTDIGOnTray;i++) {
178 mTdigOnEastVpd[i] = 0;
179 mTdigOnWestVpd[i] = 0;
182 for(Int_t i=0;i<mNTDIGMAX;i++) {
184 for(
int j=0;j<mNChanOnTDIG;j++) {
185 for(
int k=0;k<mNChanMAX;k++) {
186 mINLCorr[i][j][k] = 0.0;
190 for(Int_t i=0;i<mNBoardIdMAX;i++) {
191 mBoardId2Index[i] = -1;
197 float StTofINLCorr::getTrayINLCorr(
int trayId,
int globalTdcChan,
int bin) {
198 if(trayId<=0 || trayId>mNTray)
return 0.0;
199 if(globalTdcChan<0 || globalTdcChan>=mNGLOBALCHANMAX)
return 0.0;
200 if(bin<0 || bin>=mNChanMAX)
return 0.0;
202 int iTdig = globalTdcChan/mNChanOnTDIG;
203 int boardId = mTdigOnTray[trayId-1][iTdig];
204 if(boardId<=0 || boardId>mNBoardIdMAX)
return 0.0;
206 int index = mBoardId2Index[boardId];
207 int tdcChan = globalTdcChan % mNChanOnTDIG;
208 return mINLCorr[index][tdcChan][bin];
211 float StTofINLCorr::getVpdINLCorr(
int ewId,
int globalTdcChan,
int bin) {
212 if(ewId!=1 && ewId!=2)
return 0.0;
213 if(globalTdcChan<0 || globalTdcChan>=mNGLOBALCHANMAX)
return 0.0;
214 if(bin<0 || bin>=mNChanMAX)
return 0.0;
215 int iTdig = globalTdcChan/mNChanOnTDIG;
219 boardId = mTdigOnEastVpd[iTdig];
221 boardId = mTdigOnWestVpd[iTdig];
223 if(boardId<=0 || boardId>mNBoardIdMAX)
return 0.0;
225 int index = mBoardId2Index[boardId];
226 int tdcChan = globalTdcChan % mNChanOnTDIG;
227 return mINLCorr[index][tdcChan][bin];
virtual TDataSet * Find(const char *path) const