00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "StBTofTables.h"
00014 #include "StMaker.h"
00015
00016 ClassImp(StBTofTables)
00017
00018
00019 StBTofTables::StBTofTables() {
00020 Reset();
00021 }
00022
00023
00024 StBTofTables::~StBTofTables() {
00025 Reset();
00026 }
00027
00028
00029 void StBTofTables::Reset() {
00030 memset(mBTofTrayConfig, 0, sizeof(mBTofTrayConfig));
00031 memset(mBTofStatus, 0, sizeof(mBTofStatus));
00032 }
00033
00034
00035 void StBTofTables::loadTables(StMaker* maker) {
00036
00037 LOG_INFO << "StBTofTables -- loading the BTOF tray/channel status tables ..." << endm;
00038
00039 TDataSet *mDbTOFDataSet = maker->GetDataBase("Calibrations/tof");
00040 if(!mDbTOFDataSet) {
00041 LOG_ERROR << "unable to access Calibrations TOF parameters" << endm;
00042
00043 return;
00044 }
00045
00046 St_tofTrayConfig* trayConfig = static_cast<St_tofTrayConfig*>(mDbTOFDataSet->Find("tofTrayConfig"));
00047 if(!trayConfig) {
00048 LOG_ERROR << "unable to get tof tray configuration" << endm;
00049 return;
00050 }
00051 tofTrayConfig_st* trayconf = static_cast<tofTrayConfig_st*>(trayConfig->GetArray());
00052 if(maker->Debug()) { LOG_INFO << " Valid Trays: " << endm; }
00053
00054 Int_t nValidTrays = (Int_t)(trayconf[0].entries);
00055 for (Int_t i=0;i<nValidTrays;i++) {
00056 int trayId = (Int_t)(trayconf[0].iTray[i]);
00057 mBTofTrayConfig[trayId-1] = 1;
00058 if(maker->Debug()) {
00059 LOG_INFO << " " << trayId;
00060 }
00061 }
00062 if(maker->Debug()) { LOG_INFO << endm; }
00063
00064 St_tofStatus* tofStatus = static_cast<St_tofStatus*>(mDbTOFDataSet->Find("tofStatus"));
00065 if(!tofStatus) {
00066 LOG_ERROR << "unable to get tof status table" << endm;
00067 return;
00068 }
00069
00070 tofStatus_st* status = static_cast<tofStatus_st*>(tofStatus->GetArray());
00071 for(int i=0;i<mNChanMax;i++) {
00072 int trayId = i/(mNModule*mNCell) + 1;
00073 int moduleId = (i%(mNModule*mNCell))/mNCell + 1;
00074 int cellId = i%mNCell + 1;
00075 if(trayId<=0||trayId>mNTray||moduleId<=0||moduleId>mNModule||cellId<=0||cellId>mNCell) continue;
00076 mBTofStatus[trayId-1][moduleId-1][cellId-1] = (UShort_t)status[0].status[i];
00077 }
00078
00079 return;
00080 }
00081
00082
00083 bool StBTofTables::trayValid(int trayId) const {
00084 return mBTofTrayConfig[trayId-1];
00085 }
00086
00087
00088 int StBTofTables::status(int trayId, int moduleId, int cellId) const {
00089 return mBTofStatus[trayId-1][moduleId-1][cellId-1];
00090 }