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
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #include <iostream>
00050 #include "tables/St_tofModuleConfig_Table.h"
00051 #include "tables/St_tofCamacDaqMap_Table.h"
00052 #include "tables/St_tofr5Maptable_Table.h"
00053 #include "tables/St_tofDaqMap_Table.h"
00054 #include "tables/St_tofTrayConfig_Table.h"
00055 #include "StMessMgr.h"
00056 #include "StMaker.h"
00057 #include "StTofrDaqMap.h"
00058
00059 StTofrDaqMap::StTofrDaqMap()
00060 {
00061 Reset();
00062 }
00063
00064 StTofrDaqMap::~StTofrDaqMap()
00065 {
00066 Reset();
00067 }
00068
00069 void StTofrDaqMap::init() {
00070 Reset();
00071 }
00072
00073 void StTofrDaqMap::init(StMaker *maker) {
00074 initFromDbase(maker);
00075 }
00076
00077 void StTofrDaqMap::initFromDbase(StMaker *maker) {
00078
00079 gMessMgr->Info("StTofrDaqMap -- retrieving the daq mapping","OS");
00081
00082
00084
00085 TDataSet *mDbTOFDataSet = maker->GetDataBase("Calibrations/tof");
00086 if(!mDbTOFDataSet) {
00087 gMessMgr->Error("unable to access Calibrations TOF parameters","OS");
00088
00089 return;
00090 }
00091
00092 St_tofModuleConfig* tofModuleConf = static_cast<St_tofModuleConfig*>(mDbTOFDataSet->Find("tofModuleConfig"));
00093 if(!tofModuleConf) {
00094 gMessMgr->Error("unable to get tof Module Configuration parameters","OS");
00095
00096 return;
00097 }
00098 tofModuleConfig_st* moduleConf = static_cast<tofModuleConfig_st*>(tofModuleConf->GetArray());
00099
00100 Int_t entries = (Int_t)(moduleConf[0].entries);
00101 if(entries*mNCell!=mNTOFR) {
00102 gMessMgr->Warning(" # TOFr channels incosistency in dbase");
00103 }
00104 for (Int_t i=0;i<entries;i++) {
00105 for (Int_t j=0;j<mNCell;j++) {
00106 Int_t ic = i*6+j;
00107 Int_t id = (Int_t)(moduleConf[0].iChannel[ic]);
00108 mTrayId[id] = (Int_t)(moduleConf[0].iTray[i]);
00109 mModuleId[id] = (Int_t)(moduleConf[0].iModule[i]);
00110 mCellId[id] = j+1;
00111 if(maker->Debug()) {
00112 LOG_INFO << " id=" << id << " tray=" << mTrayId[id] << " module=" << mModuleId[id] << " cell=" << mCellId[id] << endm;
00113 }
00114 }
00115 }
00116
00117 St_tofCamacDaqMap* tofDaqMap = static_cast<St_tofCamacDaqMap*>(mDbTOFDataSet->Find("tofCamacDaqMap"));
00118 if(!tofDaqMap) {
00119 gMessMgr->Error("unable to get tof daq map","OS");
00120
00121 return;
00122 }
00123 tofCamacDaqMap_st* tofmap = static_cast<tofCamacDaqMap_st*>(tofDaqMap->GetArray());
00124
00125 Int_t daqentries = (Int_t)(tofmap[0].entries);
00126 Int_t nChans = 0;
00127 bool chanMatch = kTRUE;
00128 for(Int_t i=0;i<daqentries;i++) {
00129
00130 if(tofmap[0].detectorId[i]!=2||tofmap[0].adcChan[i]<0) continue;
00131 if(nChans>=mNTOFR) {
00132 break;
00133 chanMatch = kFALSE;
00134 }
00135 Int_t daqChan = (Int_t)(tofmap[0].daqChannel[i]);
00136 mAdc[daqChan] = (Int_t)(tofmap[0].adcChan[i]);
00137 mTdc[daqChan] = (Int_t)(tofmap[0].tdcChan[i]);
00138 nChans++;
00139 }
00140 if(!chanMatch || nChans!=mNTOFR) {
00141 gMessMgr->Warning(" # TOFr daq channels inconsistency in dbase");
00142 }
00143
00144 }
00145
00146 void StTofrDaqMap::initFromDbaseY5(StMaker *maker) {
00147
00148 gMessMgr->Info("StTofrDaqMap -- retrieving the tofr5 channel mapping","OS");
00150
00151
00153
00154 TDataSet *mDbTOFDataSet = maker->GetDataBase("Calibrations/tof");
00155 if(!mDbTOFDataSet) {
00156 gMessMgr->Error("unable to access Calibrations TOF parameters","OS");
00157
00158 return;
00159 }
00160
00161 St_tofr5Maptable* tofr5maptable = static_cast<St_tofr5Maptable*>(mDbTOFDataSet->Find("tofr5Maptable"));
00162 if(!tofr5maptable) {
00163 gMessMgr->Error("unable to get tof Module map table","OS");
00164 return;
00165 }
00166 tofr5Maptable_st* maptable = static_cast<tofr5Maptable_st*>(tofr5maptable->GetArray());
00167 for (Int_t i=0;i<mNTOFR5;i++) {
00168 mGlobalTDCChan[i]=(Int_t)(maptable[0].tdigchan[i]);
00169 mGlobalModuleChan[i]=(Int_t)(maptable[0].modulechan[i]);
00170 if(maker->Debug()) {
00171 LOG_INFO << " i=" << i << " TDC chan =" << mGlobalTDCChan[i] << " module chan=" <<mGlobalModuleChan[i]<<endm;
00172 }
00173 }
00174
00175
00176 return;
00177 }
00178
00179 void StTofrDaqMap::initFromDbaseGeneral(StMaker *maker) {
00180
00181 gMessMgr->Info("StTofrDaqMap -- retrieving the tof8++ channel mapping","OS");
00183
00184
00186
00187 TDataSet *mDbTOFDataSet = maker->GetDataBase("Calibrations/tof");
00188 if(!mDbTOFDataSet) {
00189 gMessMgr->Error("unable to access Calibrations TOF parameters","OS");
00190
00191 return;
00192 }
00193
00194 St_tofDaqMap* tofDaqMap = static_cast<St_tofDaqMap*>(mDbTOFDataSet->Find("tofDaqMap"));
00195 if(!tofDaqMap) {
00196 gMessMgr->Error("unable to get tof Module map table","OS");
00197 return;
00198 }
00199 tofDaqMap_st* daqmap = static_cast<tofDaqMap_st*>(tofDaqMap->GetArray());
00200 for (Int_t i=0;i<mNTOF;i++) {
00201 mMRPC2TDIGChan[i] = (Int_t)(daqmap[0].MRPC2TDIGChanMap[i]);
00202 mTDIG2MRPCChan[mMRPC2TDIGChan[i]] = i;
00203 if(maker->Debug()) {
00204 LOG_INFO << " MRPC = " << i << " TDC chan = " << mMRPC2TDIGChan[i] << endm;
00205 }
00206 }
00207 for (Int_t i=0;i<mNVPD;i++) {
00208 mWestPMT2TDIGLeChan[i] = (Int_t)(daqmap[0].PMT2TDIGLeChanMap[i]);
00209 mWestPMT2TDIGTeChan[i] = (Int_t)(daqmap[0].PMT2TDIGTeChanMap[i]);
00210 if(maker->Debug()) {
00211 LOG_INFO << " VPD = " << i << " TDC Lechan = " << mWestPMT2TDIGLeChan[i] << " TDC TeChan = " << mWestPMT2TDIGTeChan[i] << endm;
00212 }
00213 mTDIGLe2WestPMTChan[mWestPMT2TDIGLeChan[i]] = i;
00214 mTDIGTe2WestPMTChan[mWestPMT2TDIGTeChan[i]] = i;
00215
00216 int j=i+mNVPD;
00217
00218 mEastPMT2TDIGLeChan[i] = (Int_t)(daqmap[0].PMT2TDIGLeChanMap[j]);
00219 mEastPMT2TDIGTeChan[i] = (Int_t)(daqmap[0].PMT2TDIGTeChanMap[j]);
00220 if(maker->Debug()) {
00221 LOG_INFO << " VPD = " << i << " TDC Lechan = " << mEastPMT2TDIGLeChan[i] << " TDC TeChan = " << mEastPMT2TDIGTeChan[i] << endm;
00222 }
00223 mTDIGLe2EastPMTChan[mEastPMT2TDIGLeChan[i]] = i;
00224 mTDIGTe2EastPMTChan[mEastPMT2TDIGTeChan[i]] = i;
00225 }
00226
00227
00228 St_tofTrayConfig* trayConfig = static_cast<St_tofTrayConfig*>(mDbTOFDataSet->Find("tofTrayConfig"));
00229 if(!trayConfig) {
00230 gMessMgr->Error("unable to get tof tray configuration","OS");
00231 return;
00232 }
00233 tofTrayConfig_st* trayconf = static_cast<tofTrayConfig_st*>(trayConfig->GetArray());
00234 if(maker->Debug()) LOG_INFO << " Valid Trays: " << endm;
00235 for (Int_t i=0;i<mNValidTrays;i++) {
00236 mValidTrayId[i] = (Int_t)(trayconf[0].iTray[i]);
00237 if(maker->Debug()) {
00238 cout << " " << mValidTrayId[i];
00239 }
00240 }
00241 if(maker->Debug()) cout << endl;
00242
00243 return;
00244 }
00245
00246
00247 void StTofrDaqMap::Reset() {
00248 for(Int_t i=0;i<mNTOFR;i++) {
00249 mTrayId[i] = 0;
00250 mModuleId[i] = 0;
00251 mCellId[i] = 0;
00252 mAdc[i] = -1;
00253 mTdc[i] = -1;
00254 }
00255
00256 for(int i=0;i<mNTOFR5;i++){
00257 mGlobalTDCChan[i]=0;
00258 mGlobalModuleChan[i]=0;
00259 }
00260
00261 for(int i=0;i<mNTOF;i++) {
00262 mMRPC2TDIGChan[i] = -1;
00263 mTDIG2MRPCChan[i] = -1;
00264 mTDIGLe2WestPMTChan[i] = -1;
00265 mTDIGTe2WestPMTChan[i] = -1;
00266 mTDIGLe2EastPMTChan[i] = -1;
00267 mTDIGTe2EastPMTChan[i] = -1;
00268 }
00269 for(int i=0;i<mNVPD;i++) {
00270 mEastPMT2TDIGLeChan[i] = -1;
00271 mEastPMT2TDIGTeChan[i] = -1;
00272 mWestPMT2TDIGLeChan[i] = -1;
00273 mWestPMT2TDIGTeChan[i] = -1;
00274 }
00275
00276 mNValidTrays = 0;
00277 }
00278
00279 IntVec StTofrDaqMap::DaqChan2Cell( const Int_t iTofrDaq )
00280 {
00281 IntVec map;
00282 map.clear();
00283 if ( iTofrDaq<0 || iTofrDaq>=mNTOFR ) {
00284 LOG_INFO << " ERROR! Uncorrected iTofrDaq number for Tofr! " << endm;
00285 return map;
00286 }
00287
00288 map.push_back(mTrayId[iTofrDaq]);
00289 map.push_back(mModuleId[iTofrDaq]);
00290 map.push_back(mCellId[iTofrDaq]);
00291
00292 return map;
00293 }
00294
00295
00296
00297 Int_t StTofrDaqMap::Cell2DaqChan( const Int_t iTray, const Int_t iModule, const Int_t iCell )
00298 {
00299 Int_t daq = mDAQOVERFLOW;
00300
00301 for(Int_t i=0;i<mNTOFR;i++) {
00302 if( mTrayId[i]==iTray && mModuleId[i]==iModule && mCellId[i]==iCell ) {
00303 daq = i;
00304 break;
00305 }
00306 }
00307
00308 return daq;
00309 }
00310
00311
00312 IntVec StTofrDaqMap::ADCChan2Cell( const Int_t iAdc )
00313 {
00314 Int_t daq = ADCChan2DaqChan(iAdc);
00315
00316 IntVec map;
00317 map.clear();
00318 if(daq==mDAQOVERFLOW) {
00319 gMessMgr->Warning(" iAdc is out of ADC channels");
00320 return map;
00321 }
00322
00323 return DaqChan2Cell(daq);
00324 }
00325
00326 IntVec StTofrDaqMap::TDCChan2Cell( const Int_t iTdc )
00327 {
00328 Int_t daq = TDCChan2DaqChan(iTdc);
00329
00330 IntVec map;
00331 map.clear();
00332 if(daq==mDAQOVERFLOW) {
00333 gMessMgr->Warning(" iTdc is out of TDC channels");
00334 return map;
00335 }
00336
00337 return DaqChan2Cell(daq);
00338 }
00339
00340 Int_t StTofrDaqMap::Cell2ADCChan( const Int_t iTray , const Int_t iModule, const Int_t iCell )
00341 {
00342 Int_t daq = Cell2DaqChan(iTray, iModule, iCell);
00343 if(daq==mDAQOVERFLOW) {
00344 return -1;
00345 }
00346 return mAdc[daq];
00347 }
00348
00349 Int_t StTofrDaqMap::Cell2TDCChan( const Int_t iTray , const Int_t iModule, const Int_t iCell )
00350 {
00351 Int_t daq = Cell2DaqChan(iTray, iModule, iCell);
00352 if (daq==mDAQOVERFLOW) {
00353 return -1;
00354 }
00355 return mTdc[daq];
00356 }
00357
00358 Int_t StTofrDaqMap::DaqChan2ADCChan( const Int_t iTofrDaq )
00359 {
00360 if(iTofrDaq<0 || iTofrDaq>=mNTOFR ) {
00361 LOG_INFO << " ERROR! Uncorrected iTofrDaq number for Tofr! " << endm;
00362 return -1;
00363 }
00364
00365 return mAdc[iTofrDaq];
00366 }
00367
00368 Int_t StTofrDaqMap::DaqChan2TDCChan( const Int_t iTofrDaq )
00369 {
00370 if(iTofrDaq<0 || iTofrDaq>=mNTOFR ) {
00371 LOG_INFO << " ERROR! Uncorrected iTofrDaq number for Tofr! " << endm;
00372 return -1;
00373 }
00374
00375 return mTdc[iTofrDaq];
00376 }
00377
00378
00379 Int_t StTofrDaqMap::ADCChan2DaqChan( const Int_t iAdc )
00380 {
00381 Int_t daq = mDAQOVERFLOW;
00382 for(Int_t i=0;i<mNTOFR;i++) {
00383 if(mAdc[i]==iAdc) {
00384 daq = i;
00385 break;
00386 }
00387 }
00388
00389 return daq;
00390 }
00391
00392 Int_t StTofrDaqMap::TDCChan2DaqChan( const Int_t iTdc )
00393 {
00394 Int_t daq = mDAQOVERFLOW;
00395 for(Int_t i=0;i<mNTOFR;i++) {
00396 if(mTdc[i]==iTdc) {
00397 daq = i;
00398 break;
00399 }
00400 }
00401 return daq;
00402 }
00403
00404
00405
00406 IntVec StTofrDaqMap::Tofr5TDCChan2Cell( const Int_t iTdc)
00407 {
00408 IntVec map;
00409 map.clear();
00410
00411 if ( iTdc<0 || iTdc>=mNTOFR5 ) {
00412 LOG_INFO << " ERROR! Uncorrected TDC Channel number for Tofr5! " << endm;
00413 return map;
00414 }
00415
00416 Int_t Tray=93;
00417 Int_t ModuleChan = mGlobalModuleChan[iTdc];
00418 Int_t Module = ModuleChan/6+1;
00419 Int_t Cell = ModuleChan%6+1;
00420 map.push_back(Tray);
00421 map.push_back(Module);
00422 map.push_back(Cell);
00423
00424 return map;
00425 }
00426
00427 Int_t StTofrDaqMap::Tofr5Cell2TDCChan( const Int_t iTray , const Int_t iModule, const Int_t iCell )
00428 {
00429
00430 if(iTray!=93 ) {
00431 LOG_INFO<<"ERROR!!! Wrong tray number !"<<endm;
00432 return -1;
00433 }
00434 if(iModule<1 || iModule>32 ) {
00435 LOG_INFO<<"ERROR!!! Wrong module number !"<<endm;
00436 return -1;
00437 }
00438 if(iCell <1 || iCell > 6) {
00439 LOG_INFO<<"ERROR!!! Wrong cell number ! "<<endm;
00440 return -1;
00441 }
00442
00443 Int_t modulechan = (iModule-1)*6+(iCell-1);
00444
00445
00446 if (modulechan<0 || modulechan>=mNTOFR5) {
00447 LOG_INFO<<"ERROR!!! Wrong Module Cell channel number!"<<endm;
00448 return -1;
00449 }
00450
00451 return mGlobalTDCChan[modulechan];
00452 }
00453
00454
00455 IntVec StTofrDaqMap::TDIGChan2Cell( const Int_t iTdc)
00456 {
00457 IntVec map;
00458 map.clear();
00459
00460 if ( iTdc<0 || iTdc>=mNTOF ) {
00461 LOG_INFO << " ERROR! Uncorrected TDC Channel number for Tof! " << endm;
00462 return map;
00463 }
00464
00465 Int_t ModuleChan = mTDIG2MRPCChan[iTdc];
00466 Int_t Module = ModuleChan / mNCell + 1;
00467 Int_t Cell = ModuleChan % mNCell + 1;
00468 map.push_back(Module);
00469 map.push_back(Cell);
00470
00471 return map;
00472 }
00473
00474 Int_t StTofrDaqMap::Cell2TDIGChan( const Int_t iModule, const Int_t iCell )
00475 {
00476
00477 if(iModule<1 || iModule>mNModule ) {
00478 LOG_INFO<<"ERROR!!! Wrong module number !"<<endm;
00479 return -1;
00480 }
00481 if(iCell <1 || iCell > mNCell) {
00482 LOG_INFO<<"ERROR!!! Wrong cell number ! "<<endm;
00483 return -1;
00484 }
00485
00486 Int_t modulechan = (iModule-1)*mNCell+(iCell-1);
00487
00488
00489 if (modulechan<0 || modulechan>=mNTOF) {
00490 LOG_INFO<<"ERROR!!! Wrong Module Cell channel number!"<<endm;
00491 return -1;
00492 }
00493
00494 return mMRPC2TDIGChan[modulechan];
00495 }
00496
00497 Int_t StTofrDaqMap::WestPMT2TDIGLeChan( const Int_t iTube )
00498 {
00499 if ( iTube<1 || iTube>mNVPD ) {
00500 LOG_INFO<<"ERROR!!! Wrong vpd tube number ! "<<endm;
00501 return -1;
00502 }
00503
00504 return mWestPMT2TDIGLeChan[iTube-1];
00505 }
00506
00507 Int_t StTofrDaqMap::WestPMT2TDIGTeChan( const Int_t iTube )
00508 {
00509 if ( iTube<1 || iTube>mNVPD ) {
00510 LOG_INFO<<"ERROR!!! Wrong vpd tube number ! "<<endm;
00511 return -1;
00512 }
00513
00514 return mWestPMT2TDIGTeChan[iTube-1];
00515 }
00516
00517 Int_t StTofrDaqMap::TDIGLeChan2WestPMT( const Int_t iTdc )
00518 {
00519 if ( iTdc<0 || iTdc>=mNTOF ) {
00520 LOG_INFO<<"ERROR!!! Wrong tdc channel number ! "<<endm;
00521 return -1;
00522 }
00523
00524 return mTDIGLe2WestPMTChan[iTdc] + 1;
00525 }
00526
00527 Int_t StTofrDaqMap::TDIGTeChan2WestPMT( const Int_t iTdc )
00528 {
00529 if ( iTdc<0 || iTdc>=mNTOF ) {
00530 LOG_INFO<<"ERROR!!! Wrong tdc channel number ! "<<endm;
00531 return -1;
00532 }
00533
00534 return mTDIGTe2WestPMTChan[iTdc] + 1;
00535 }
00536
00537 Int_t StTofrDaqMap::EastPMT2TDIGLeChan( const Int_t iTube )
00538 {
00539 if ( iTube<1 || iTube>mNVPD ) {
00540 LOG_INFO<<"ERROR!!! Wrong vpd tube number ! "<<endm;
00541 return -1;
00542 }
00543
00544 return mEastPMT2TDIGLeChan[iTube-1];
00545 }
00546
00547 Int_t StTofrDaqMap::EastPMT2TDIGTeChan( const Int_t iTube )
00548 {
00549 if ( iTube<1 || iTube>mNVPD ) {
00550 LOG_INFO<<"ERROR!!! Wrong vpd tube number ! "<<endm;
00551 return -1;
00552 }
00553
00554 return mEastPMT2TDIGTeChan[iTube-1];
00555 }
00556
00557 Int_t StTofrDaqMap::TDIGLeChan2EastPMT( const Int_t iTdc )
00558 {
00559 if ( iTdc<0 || iTdc>=mNTOF ) {
00560 LOG_INFO<<"ERROR!!! Wrong tdc channel number ! "<<endm;
00561 return -1;
00562 }
00563
00564 return mTDIGLe2EastPMTChan[iTdc] + 1;
00565 }
00566
00567 Int_t StTofrDaqMap::TDIGTeChan2EastPMT( const Int_t iTdc )
00568 {
00569 if ( iTdc<0 || iTdc>=mNTOF ) {
00570 LOG_INFO<<"ERROR!!! Wrong tdc channel number ! "<<endm;
00571 return -1;
00572 }
00573
00574 return mTDIGTe2EastPMTChan[iTdc] + 1;
00575 }
00576
00577 IntVec StTofrDaqMap::ValidTrays()
00578 {
00579 IntVec trayId;
00580 for(int i=0;i<mNValidTrays;i++) {
00581 trayId.push_back(mValidTrayId[i]);
00582 }
00583
00584 return trayId;
00585 }