00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <iostream>
00029 #include "tables/St_tofDaqMap_Table.h"
00030 #include "tables/St_tofTrayConfig_Table.h"
00031 #include "StMessMgr.h"
00032 #include "StMaker.h"
00033 #include "StBTofDaqMap.h"
00034
00035 StBTofDaqMap::StBTofDaqMap()
00036 {
00037 Reset();
00038 }
00039
00040 StBTofDaqMap::~StBTofDaqMap()
00041 {
00042 Reset();
00043 }
00044
00048 void StBTofDaqMap::Init(StMaker *maker) {
00049
00050 LOG_INFO << "[StBTofDaqMap] retrieving BTOF DAQ map and tray config ..." << endm;
00052
00053
00055
00056
00057
00058
00059
00060
00061
00062
00063 TDataSet *mDbTOFDataSet = maker->GetDataBase("Calibrations/tof/tofDaqMap");
00064 St_tofDaqMap* tofDaqMap = static_cast<St_tofDaqMap*>(mDbTOFDataSet->Find("tofDaqMap"));
00065 if(!tofDaqMap) {
00066 LOG_ERROR << "unable to get tof Module map table" << endm;
00067 return;
00068 }
00069 tofDaqMap_st* daqmap = static_cast<tofDaqMap_st*>(tofDaqMap->GetArray());
00070 for (Int_t i=0;i<mNTOF;i++) {
00071 mMRPC2TDIGChan[i] = (Int_t)(daqmap[0].MRPC2TDIGChanMap[i]);
00072 mTDIG2MRPCChan[mMRPC2TDIGChan[i]] = i;
00073 if(maker->Debug()) {
00074 LOG_DEBUG << " MRPC = " << i << " TDC chan = " << mMRPC2TDIGChan[i] << endm;
00075 }
00076 }
00077 for (Int_t i=0;i<mNVPD;i++) {
00078 mWestPMT2TDIGLeChan[i] = (Int_t)(daqmap[0].PMT2TDIGLeChanMap[i]);
00079 mWestPMT2TDIGTeChan[i] = (Int_t)(daqmap[0].PMT2TDIGTeChanMap[i]);
00080 if(maker->Debug()) {
00081 LOG_DEBUG << " VPD = " << i << " TDC Lechan = " << mWestPMT2TDIGLeChan[i] << " TDC TeChan = " << mWestPMT2TDIGTeChan[i] << endm;
00082 }
00083 mTDIGLe2WestPMTChan[mWestPMT2TDIGLeChan[i]] = i;
00084 mTDIGTe2WestPMTChan[mWestPMT2TDIGTeChan[i]] = i;
00085
00086 int j=i+mNVPD;
00087
00088 mEastPMT2TDIGLeChan[i] = (Int_t)(daqmap[0].PMT2TDIGLeChanMap[j]);
00089 mEastPMT2TDIGTeChan[i] = (Int_t)(daqmap[0].PMT2TDIGTeChanMap[j]);
00090 if(maker->Debug()) {
00091 LOG_DEBUG << " VPD = " << i << " TDC Lechan = " << mEastPMT2TDIGLeChan[i] << " TDC TeChan = " << mEastPMT2TDIGTeChan[i] << endm;
00092 }
00093 mTDIGLe2EastPMTChan[mEastPMT2TDIGLeChan[i]] = i;
00094 mTDIGTe2EastPMTChan[mEastPMT2TDIGTeChan[i]] = i;
00095 }
00096
00097
00098 mDbTOFDataSet = maker->GetDataBase("Calibrations/tof/tofTrayConfig");
00099 St_tofTrayConfig* trayConfig = static_cast<St_tofTrayConfig*>(mDbTOFDataSet->Find("tofTrayConfig"));
00100 if(!trayConfig) {
00101 LOG_ERROR << "unable to get tof tray configuration" << endm;
00102 return;
00103 }
00104 tofTrayConfig_st* trayconf = static_cast<tofTrayConfig_st*>(trayConfig->GetArray());
00105 if(maker->Debug()) { LOG_DEBUG << " Valid Trays: " << endm; }
00106 mNValidTrays = (Int_t)(trayconf[0].entries);
00107 for (Int_t i=0;i<mNValidTrays;i++) {
00108 mValidTrayId[i] = (Int_t)(trayconf[0].iTray[i]);
00109 if(maker->Debug()) {
00110 LOG_DEBUG << " " << mValidTrayId[i];
00111 }
00112 }
00113 if(maker->Debug()) { LOG_DEBUG << endm; }
00114
00115 LOG_DEBUG << "[StBTofDaqMap] ... done." << endm;
00116 return;
00117 }
00118
00119
00120 void StBTofDaqMap::Reset() {
00121 for(int i=0;i<mNTOF;i++) {
00122 mMRPC2TDIGChan[i] = -1;
00123 mTDIG2MRPCChan[i] = -1;
00124 mTDIGLe2WestPMTChan[i] = -1;
00125 mTDIGTe2WestPMTChan[i] = -1;
00126 mTDIGLe2EastPMTChan[i] = -1;
00127 mTDIGTe2EastPMTChan[i] = -1;
00128 }
00129 for(int i=0;i<mNVPD;i++) {
00130 mEastPMT2TDIGLeChan[i] = -1;
00131 mEastPMT2TDIGTeChan[i] = -1;
00132 mWestPMT2TDIGLeChan[i] = -1;
00133 mWestPMT2TDIGTeChan[i] = -1;
00134 }
00135
00136 mNValidTrays = 0;
00137 }
00138
00139
00140 IntVec StBTofDaqMap::TDIGChan2Cell( const Int_t iTdc)
00141 {
00142 IntVec map;
00143 map.clear();
00144
00145 if ( iTdc<0 || iTdc>=mNTOF ) {
00146 LOG_ERROR << "[TDIGChan2Cell] Uncorrected TDC Channel number for Tof! " << endm;
00147 return map;
00148 }
00149
00150 Int_t ModuleChan = mTDIG2MRPCChan[iTdc];
00151 Int_t Module = ModuleChan / mNCell + 1;
00152 Int_t Cell = ModuleChan % mNCell + 1;
00153 map.push_back(Module);
00154 map.push_back(Cell);
00155
00156 return map;
00157 }
00158
00159 Int_t StBTofDaqMap::Cell2TDIGChan( const Int_t iModule, const Int_t iCell )
00160 {
00161
00162 if(iModule<1 || iModule>mNModule ) {
00163 LOG_ERROR<<"[Cell2TDIGChan] Wrong module number !"<<endm;
00164 return -1;
00165 }
00166 if(iCell <1 || iCell > mNCell) {
00167 LOG_ERROR<<"[Cell2TDIGChan] Wrong cell number ! "<<endm;
00168 return -1;
00169 }
00170
00171 Int_t modulechan = (iModule-1)*mNCell+(iCell-1);
00172
00173
00174 if (modulechan<0 || modulechan>=mNTOF) {
00175 LOG_ERROR<<"[Cell2TDIGChan] Wrong Module-Cell channel number!"<<endm;
00176 return -1;
00177 }
00178
00179 return mMRPC2TDIGChan[modulechan];
00180 }
00181
00182 Int_t StBTofDaqMap::WestPMT2TDIGLeChan( const Int_t iTube )
00183 {
00184 if ( iTube<1 || iTube>mNVPD ) {
00185 LOG_ERROR<<"[WestPMT2TDIGLeChan] Wrong vpd tube number ! "<<endm;
00186 return -1;
00187 }
00188
00189 return mWestPMT2TDIGLeChan[iTube-1];
00190 }
00191
00192 Int_t StBTofDaqMap::WestPMT2TDIGTeChan( const Int_t iTube )
00193 {
00194 if ( iTube<1 || iTube>mNVPD ) {
00195 LOG_ERROR<<"[WestPMT2TDIGTeChan] Wrong vpd tube number ! "<< iTube<<endm;
00196 return -1;
00197 }
00198
00199 return mWestPMT2TDIGTeChan[iTube-1];
00200 }
00201
00202 Int_t StBTofDaqMap::TDIGLeChan2WestPMT( const Int_t iTdc )
00203 {
00204 if ( iTdc<0 || iTdc>=mNTOF ) {
00205 LOG_ERROR<<"[TDIGLeChan2WestPMT] Wrong tdc channel number ! "<< iTdc<<endm;
00206 return -1;
00207 }
00208
00209 return mTDIGLe2WestPMTChan[iTdc] + 1;
00210 }
00211
00212 Int_t StBTofDaqMap::TDIGTeChan2WestPMT( const Int_t iTdc )
00213 {
00214 if ( iTdc<0 || iTdc>=mNTOF ) {
00215 LOG_ERROR<<"[TDIGTeChan2WestPMT] Wrong tdc channel number ! "<< iTdc <<endm;
00216 return -1;
00217 }
00218
00219 return mTDIGTe2WestPMTChan[iTdc] + 1;
00220 }
00221
00222 Int_t StBTofDaqMap::EastPMT2TDIGLeChan( const Int_t iTube )
00223 {
00224 if ( iTube<1 || iTube>mNVPD ) {
00225 LOG_ERROR<<"[EastPMT2TDIGLeChan] Wrong vpd tube number ! "<<iTube<< endm;
00226 return -1;
00227 }
00228
00229 return mEastPMT2TDIGLeChan[iTube-1];
00230 }
00231
00232 Int_t StBTofDaqMap::EastPMT2TDIGTeChan( const Int_t iTube )
00233 {
00234 if ( iTube<1 || iTube>mNVPD ) {
00235 LOG_ERROR<<"[EastPMT2TDIGTeChan] Wrong vpd tube number ! "<<iTube<< endm;
00236 return -1;
00237 }
00238
00239 return mEastPMT2TDIGTeChan[iTube-1];
00240 }
00241
00242 Int_t StBTofDaqMap::TDIGLeChan2EastPMT( const Int_t iTdc )
00243 {
00244 if ( iTdc<0 || iTdc>=mNTOF ) {
00245 LOG_ERROR<<"StBTofDaqMap::TDIGLeChan2EastPMT: Wrong tdc channel number ! "<<iTdc<<endm;
00246 return -1;
00247 }
00248
00249 return mTDIGLe2EastPMTChan[iTdc] + 1;
00250 }
00251
00252 Int_t StBTofDaqMap::TDIGTeChan2EastPMT( const Int_t iTdc )
00253 {
00254 if ( iTdc<0 || iTdc>=mNTOF ) {
00255 LOG_ERROR<<"StBTofDaqMap::TDIGTeChan2EastPMT: Wrong tdc channel number ! "<<iTdc << endm;
00256 return -1;
00257 }
00258
00259 return mTDIGTe2EastPMTChan[iTdc] + 1;
00260 }
00261
00262 IntVec StBTofDaqMap::ValidTrays()
00263 {
00264 IntVec trayId;
00265 for(int i=0;i<mNValidTrays;i++) {
00266 trayId.push_back(mValidTrayId[i]);
00267 }
00268
00269 return trayId;
00270 }