56 #include "tables/St_tofModuleConfig_Table.h"
57 #include "tables/St_tofCamacDaqMap_Table.h"
58 #include "tables/St_tofr5Maptable_Table.h"
59 #include "tables/St_tofDaqMap_Table.h"
60 #include "tables/St_tofTrayConfig_Table.h"
61 #include "StMessMgr.h"
63 #include "StTofrDaqMap.h"
65 StTofrDaqMap::StTofrDaqMap()
70 StTofrDaqMap::~StTofrDaqMap()
75 void StTofrDaqMap::init() {
79 void StTofrDaqMap::init(
StMaker *maker) {
83 void StTofrDaqMap::initFromDbase(
StMaker *maker) {
85 gMessMgr->Info(
"StTofrDaqMap -- retrieving the daq mapping",
"OS");
91 TDataSet *mDbTOFDataSet = maker->GetDataBase(
"Calibrations/tof/tofModuleConfig");
93 gMessMgr->Error(
"unable to access TOF tofModuleConfig table",
"OS");
98 St_tofModuleConfig* tofModuleConf =
static_cast<St_tofModuleConfig*
>(mDbTOFDataSet->
Find(
"tofModuleConfig"));
100 gMessMgr->Error(
"unable to get tof Module Configuration parameters",
"OS");
104 tofModuleConfig_st* moduleConf =
static_cast<tofModuleConfig_st*
>(tofModuleConf->GetArray());
106 Int_t entries = (Int_t)(moduleConf[0].entries);
107 if(entries*mNCell!=mNTOFR) {
108 gMessMgr->Warning(
" # TOFr channels incosistency in dbase");
110 for (Int_t i=0;i<entries;i++) {
111 for (Int_t j=0;j<mNCell;j++) {
113 Int_t
id = (Int_t)(moduleConf[0].iChannel[ic]);
114 mTrayId[id] = (Int_t)(moduleConf[0].iTray[i]);
115 mModuleId[id] = (Int_t)(moduleConf[0].iModule[i]);
118 LOG_INFO <<
" id=" <<
id <<
" tray=" << mTrayId[id] <<
" module=" << mModuleId[id] <<
" cell=" << mCellId[id] << endm;
123 mDbTOFDataSet = maker->GetDataBase(
"Calibrations/tof/tofCamacDaqMap");
125 gMessMgr->Error(
"unable to access TOF tofCamacDaqMap table",
"OS");
129 St_tofCamacDaqMap* tofDaqMap =
static_cast<St_tofCamacDaqMap*
>(mDbTOFDataSet->
Find(
"tofCamacDaqMap"));
131 gMessMgr->Error(
"unable to get tof daq map",
"OS");
135 tofCamacDaqMap_st* tofmap =
static_cast<tofCamacDaqMap_st*
>(tofDaqMap->GetArray());
137 Int_t daqentries = (Int_t)(tofmap[0].entries);
139 bool chanMatch = kTRUE;
140 for(Int_t i=0;i<daqentries;i++) {
142 if(tofmap[0].detectorId[i]!=2||tofmap[0].adcChan[i]<0)
continue;
147 Int_t daqChan = (Int_t)(tofmap[0].daqChannel[i]);
148 mAdc[daqChan] = (Int_t)(tofmap[0].adcChan[i]);
149 mTdc[daqChan] = (Int_t)(tofmap[0].tdcChan[i]);
152 if(!chanMatch || nChans!=mNTOFR) {
153 gMessMgr->Warning(
" # TOFr daq channels inconsistency in dbase");
158 void StTofrDaqMap::initFromDbaseY5(
StMaker *maker) {
160 gMessMgr->Info(
"StTofrDaqMap -- retrieving the tofr5 channel mapping",
"OS");
166 TDataSet *mDbTOFDataSet = maker->GetDataBase(
"Calibrations/tof/tofr5Maptable");
168 gMessMgr->Error(
"unable to access Calibrations TOF parameters",
"OS");
173 St_tofr5Maptable* tofr5maptable =
static_cast<St_tofr5Maptable*
>(mDbTOFDataSet->
Find(
"tofr5Maptable"));
175 gMessMgr->Error(
"unable to get tof Module map table",
"OS");
178 tofr5Maptable_st* maptable =
static_cast<tofr5Maptable_st*
>(tofr5maptable->GetArray());
179 for (Int_t i=0;i<mNTOFR5;i++) {
180 mGlobalTDCChan[i]=(Int_t)(maptable[0].tdigchan[i]);
181 mGlobalModuleChan[i]=(Int_t)(maptable[0].modulechan[i]);
183 LOG_INFO <<
" i=" << i <<
" TDC chan =" << mGlobalTDCChan[i] <<
" module chan=" <<mGlobalModuleChan[i]<<endm;
191 void StTofrDaqMap::initFromDbaseGeneral(
StMaker *maker) {
193 gMessMgr->Info(
"StTofrDaqMap -- retrieving the tof8++ channel mapping",
"OS");
199 TDataSet *mDbTOFDataSet = maker->GetDataBase(
"Calibrations/tof/tofDaqMap");
201 gMessMgr->Error(
"unable to access TOF tofDaqMap table",
"OS");
206 St_tofDaqMap* tofDaqMap =
static_cast<St_tofDaqMap*
>(mDbTOFDataSet->
Find(
"tofDaqMap"));
208 gMessMgr->Error(
"unable to get tof Module map table",
"OS");
211 tofDaqMap_st* daqmap =
static_cast<tofDaqMap_st*
>(tofDaqMap->GetArray());
212 for (Int_t i=0;i<mNTOF;i++) {
213 mMRPC2TDIGChan[i] = (Int_t)(daqmap[0].MRPC2TDIGChanMap[i]);
214 mTDIG2MRPCChan[mMRPC2TDIGChan[i]] = i;
216 LOG_INFO <<
" MRPC = " << i <<
" TDC chan = " << mMRPC2TDIGChan[i] << endm;
219 for (Int_t i=0;i<mNVPD;i++) {
220 mWestPMT2TDIGLeChan[i] = (Int_t)(daqmap[0].PMT2TDIGLeChanMap[i]);
221 mWestPMT2TDIGTeChan[i] = (Int_t)(daqmap[0].PMT2TDIGTeChanMap[i]);
223 LOG_INFO <<
" VPD = " << i <<
" TDC Lechan = " << mWestPMT2TDIGLeChan[i] <<
" TDC TeChan = " << mWestPMT2TDIGTeChan[i] << endm;
225 mTDIGLe2WestPMTChan[mWestPMT2TDIGLeChan[i]] = i;
226 mTDIGTe2WestPMTChan[mWestPMT2TDIGTeChan[i]] = i;
230 mEastPMT2TDIGLeChan[i] = (Int_t)(daqmap[0].PMT2TDIGLeChanMap[j]);
231 mEastPMT2TDIGTeChan[i] = (Int_t)(daqmap[0].PMT2TDIGTeChanMap[j]);
233 LOG_INFO <<
" VPD = " << i <<
" TDC Lechan = " << mEastPMT2TDIGLeChan[i] <<
" TDC TeChan = " << mEastPMT2TDIGTeChan[i] << endm;
235 mTDIGLe2EastPMTChan[mEastPMT2TDIGLeChan[i]] = i;
236 mTDIGTe2EastPMTChan[mEastPMT2TDIGTeChan[i]] = i;
240 mDbTOFDataSet = maker->GetDataBase(
"Calibrations/tof/tofTrayConfig");
242 gMessMgr->Error(
"unable to access TOF tofTrayConfig table",
"OS");
246 St_tofTrayConfig* trayConfig =
static_cast<St_tofTrayConfig*
>(mDbTOFDataSet->
Find(
"tofTrayConfig"));
248 gMessMgr->Error(
"unable to get tof tray configuration",
"OS");
251 tofTrayConfig_st* trayconf =
static_cast<tofTrayConfig_st*
>(trayConfig->GetArray());
252 if(maker->Debug()) LOG_INFO <<
" Valid Trays: " << endm;
253 for (Int_t i=0;i<mNValidTrays;i++) {
254 mValidTrayId[i] = (Int_t)(trayconf[0].iTray[i]);
256 cout <<
" " << mValidTrayId[i];
259 if(maker->Debug()) cout << endl;
265 void StTofrDaqMap::Reset() {
266 for(Int_t i=0;i<mNTOFR;i++) {
274 for(
int i=0;i<mNTOFR5;i++){
276 mGlobalModuleChan[i]=0;
279 for(
int i=0;i<mNTOF;i++) {
280 mMRPC2TDIGChan[i] = -1;
281 mTDIG2MRPCChan[i] = -1;
282 mTDIGLe2WestPMTChan[i] = -1;
283 mTDIGTe2WestPMTChan[i] = -1;
284 mTDIGLe2EastPMTChan[i] = -1;
285 mTDIGTe2EastPMTChan[i] = -1;
287 for(
int i=0;i<mNVPD;i++) {
288 mEastPMT2TDIGLeChan[i] = -1;
289 mEastPMT2TDIGTeChan[i] = -1;
290 mWestPMT2TDIGLeChan[i] = -1;
291 mWestPMT2TDIGTeChan[i] = -1;
297 IntVec StTofrDaqMap::DaqChan2Cell(
const Int_t iTofrDaq )
301 if ( iTofrDaq<0 || iTofrDaq>=mNTOFR ) {
302 LOG_INFO <<
" ERROR! Uncorrected iTofrDaq number for Tofr! " << endm;
306 map.push_back(mTrayId[iTofrDaq]);
307 map.push_back(mModuleId[iTofrDaq]);
308 map.push_back(mCellId[iTofrDaq]);
315 Int_t StTofrDaqMap::Cell2DaqChan(
const Int_t iTray,
const Int_t iModule,
const Int_t iCell )
317 Int_t daq = mDAQOVERFLOW;
319 for(Int_t i=0;i<mNTOFR;i++) {
320 if( mTrayId[i]==iTray && mModuleId[i]==iModule && mCellId[i]==iCell ) {
330 IntVec StTofrDaqMap::ADCChan2Cell(
const Int_t iAdc )
332 Int_t daq = ADCChan2DaqChan(iAdc);
336 if(daq==mDAQOVERFLOW) {
337 gMessMgr->Warning(
" iAdc is out of ADC channels");
341 return DaqChan2Cell(daq);
344 IntVec StTofrDaqMap::TDCChan2Cell(
const Int_t iTdc )
346 Int_t daq = TDCChan2DaqChan(iTdc);
350 if(daq==mDAQOVERFLOW) {
351 gMessMgr->Warning(
" iTdc is out of TDC channels");
355 return DaqChan2Cell(daq);
358 Int_t StTofrDaqMap::Cell2ADCChan(
const Int_t iTray ,
const Int_t iModule,
const Int_t iCell )
360 Int_t daq = Cell2DaqChan(iTray, iModule, iCell);
361 if(daq==mDAQOVERFLOW) {
367 Int_t StTofrDaqMap::Cell2TDCChan(
const Int_t iTray ,
const Int_t iModule,
const Int_t iCell )
369 Int_t daq = Cell2DaqChan(iTray, iModule, iCell);
370 if (daq==mDAQOVERFLOW) {
376 Int_t StTofrDaqMap::DaqChan2ADCChan(
const Int_t iTofrDaq )
378 if(iTofrDaq<0 || iTofrDaq>=mNTOFR ) {
379 LOG_INFO <<
" ERROR! Uncorrected iTofrDaq number for Tofr! " << endm;
383 return mAdc[iTofrDaq];
386 Int_t StTofrDaqMap::DaqChan2TDCChan(
const Int_t iTofrDaq )
388 if(iTofrDaq<0 || iTofrDaq>=mNTOFR ) {
389 LOG_INFO <<
" ERROR! Uncorrected iTofrDaq number for Tofr! " << endm;
393 return mTdc[iTofrDaq];
397 Int_t StTofrDaqMap::ADCChan2DaqChan(
const Int_t iAdc )
399 Int_t daq = mDAQOVERFLOW;
400 for(Int_t i=0;i<mNTOFR;i++) {
410 Int_t StTofrDaqMap::TDCChan2DaqChan(
const Int_t iTdc )
412 Int_t daq = mDAQOVERFLOW;
413 for(Int_t i=0;i<mNTOFR;i++) {
424 IntVec StTofrDaqMap::Tofr5TDCChan2Cell(
const Int_t iTdc)
429 if ( iTdc<0 || iTdc>=mNTOFR5 ) {
430 LOG_INFO <<
" ERROR! Uncorrected TDC Channel number for Tofr5! " << endm;
435 Int_t ModuleChan = mGlobalModuleChan[iTdc];
436 Int_t Module = ModuleChan/6+1;
437 Int_t Cell = ModuleChan%6+1;
439 map.push_back(Module);
445 Int_t StTofrDaqMap::Tofr5Cell2TDCChan(
const Int_t iTray ,
const Int_t iModule,
const Int_t iCell )
449 LOG_INFO<<
"ERROR!!! Wrong tray number !"<<endm;
452 if(iModule<1 || iModule>32 ) {
453 LOG_INFO<<
"ERROR!!! Wrong module number !"<<endm;
456 if(iCell <1 || iCell > 6) {
457 LOG_INFO<<
"ERROR!!! Wrong cell number ! "<<endm;
461 Int_t modulechan = (iModule-1)*6+(iCell-1);
464 if (modulechan<0 || modulechan>=mNTOFR5) {
465 LOG_INFO<<
"ERROR!!! Wrong Module Cell channel number!"<<endm;
469 return mGlobalTDCChan[modulechan];
473 IntVec StTofrDaqMap::TDIGChan2Cell(
const Int_t iTdc)
478 if ( iTdc<0 || iTdc>=mNTOF ) {
479 LOG_INFO <<
" ERROR! Uncorrected TDC Channel number for Tof! " << endm;
483 Int_t ModuleChan = mTDIG2MRPCChan[iTdc];
484 Int_t Module = ModuleChan / mNCell + 1;
485 Int_t Cell = ModuleChan % mNCell + 1;
486 map.push_back(Module);
492 Int_t StTofrDaqMap::Cell2TDIGChan(
const Int_t iModule,
const Int_t iCell )
495 if(iModule<1 || iModule>mNModule ) {
496 LOG_INFO<<
"ERROR!!! Wrong module number !"<<endm;
499 if(iCell <1 || iCell > mNCell) {
500 LOG_INFO<<
"ERROR!!! Wrong cell number ! "<<endm;
504 Int_t modulechan = (iModule-1)*mNCell+(iCell-1);
507 if (modulechan<0 || modulechan>=mNTOF) {
508 LOG_INFO<<
"ERROR!!! Wrong Module Cell channel number!"<<endm;
512 return mMRPC2TDIGChan[modulechan];
515 Int_t StTofrDaqMap::WestPMT2TDIGLeChan(
const Int_t iTube )
517 if ( iTube<1 || iTube>mNVPD ) {
518 LOG_INFO<<
"ERROR!!! Wrong vpd tube number ! "<<endm;
522 return mWestPMT2TDIGLeChan[iTube-1];
525 Int_t StTofrDaqMap::WestPMT2TDIGTeChan(
const Int_t iTube )
527 if ( iTube<1 || iTube>mNVPD ) {
528 LOG_INFO<<
"ERROR!!! Wrong vpd tube number ! "<<endm;
532 return mWestPMT2TDIGTeChan[iTube-1];
535 Int_t StTofrDaqMap::TDIGLeChan2WestPMT(
const Int_t iTdc )
537 if ( iTdc<0 || iTdc>=mNTOF ) {
538 LOG_INFO<<
"ERROR!!! Wrong tdc channel number ! "<<endm;
542 return mTDIGLe2WestPMTChan[iTdc] + 1;
545 Int_t StTofrDaqMap::TDIGTeChan2WestPMT(
const Int_t iTdc )
547 if ( iTdc<0 || iTdc>=mNTOF ) {
548 LOG_INFO<<
"ERROR!!! Wrong tdc channel number ! "<<endm;
552 return mTDIGTe2WestPMTChan[iTdc] + 1;
555 Int_t StTofrDaqMap::EastPMT2TDIGLeChan(
const Int_t iTube )
557 if ( iTube<1 || iTube>mNVPD ) {
558 LOG_INFO<<
"ERROR!!! Wrong vpd tube number ! "<<endm;
562 return mEastPMT2TDIGLeChan[iTube-1];
565 Int_t StTofrDaqMap::EastPMT2TDIGTeChan(
const Int_t iTube )
567 if ( iTube<1 || iTube>mNVPD ) {
568 LOG_INFO<<
"ERROR!!! Wrong vpd tube number ! "<<endm;
572 return mEastPMT2TDIGTeChan[iTube-1];
575 Int_t StTofrDaqMap::TDIGLeChan2EastPMT(
const Int_t iTdc )
577 if ( iTdc<0 || iTdc>=mNTOF ) {
578 LOG_INFO<<
"ERROR!!! Wrong tdc channel number ! "<<endm;
582 return mTDIGLe2EastPMTChan[iTdc] + 1;
585 Int_t StTofrDaqMap::TDIGTeChan2EastPMT(
const Int_t iTdc )
587 if ( iTdc<0 || iTdc>=mNTOF ) {
588 LOG_INFO<<
"ERROR!!! Wrong tdc channel number ! "<<endm;
592 return mTDIGTe2EastPMTChan[iTdc] + 1;
595 IntVec StTofrDaqMap::ValidTrays()
598 for(
int i=0;i<mNValidTrays;i++) {
599 trayId.push_back(mValidTrayId[i]);
virtual TDataSet * Find(const char *path) const