StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StBTofDaqMap.cxx
1 /*******************************************************************
2  *
3  * $Id: StBTofDaqMap.cxx,v 1.5 2012/12/14 06:35:41 geurts Exp $
4  *
5  * Author: Xin Dong
6  *****************************************************************
7  *
8  * Description: (1) Mapping between Daq channel numbers and Cell numbers
9  * (2) Parameters initalize from dbase
10  *
11  *****************************************************************
12  *
13  * $Log: StBTofDaqMap.cxx,v $
14  * Revision 1.5 2012/12/14 06:35:41 geurts
15  * Changed global database calls to direct table access and/or removed deprecated database access code.
16  *
17  * Revision 1.4 2010/05/25 22:09:44 geurts
18  * improved database handling and reduced log output
19  *
20  * Revision 1.3 2009/03/17 18:32:26 fine
21  * make the print outs usefull
22  *
23  * Revision 1.2 2009/02/13 19:47:32 dongx
24  * mNValidTrays set by the tofTrayConfig in db now
25  *
26  * Revision 1.1 2009/02/02 21:56:34 dongx
27  * first release - Barrel TOF daq mapping
28  *
29  *
30  *******************************************************************/
31 #include <iostream>
32 #include "tables/St_tofDaqMap_Table.h"
33 #include "tables/St_tofTrayConfig_Table.h"
34 #include "StMessMgr.h"
35 #include "StMaker.h"
36 #include "StBTofDaqMap.h"
37 
39 {
40  Reset();
41 }
42 
43 StBTofDaqMap::~StBTofDaqMap()
44 {
45  Reset();
46 }
47 
52 
53  LOG_INFO << "[StBTofDaqMap] retrieving BTOF DAQ map and tray config ..." << endm;
55  // Load configuration parameters from dbase
56  // need "[shell] setenv Calibrations_tof reconV0"
58 
59  TDataSet *mDbTOFDataSet = maker->GetDataBase("Calibrations/tof/tofDaqMap");
60  St_tofDaqMap* tofDaqMap = static_cast<St_tofDaqMap*>(mDbTOFDataSet->Find("tofDaqMap"));
61  if(!tofDaqMap) {
62  LOG_ERROR << "unable to get tof Module map table" << endm;
63  return; // kStErr;
64  }
65  tofDaqMap_st* daqmap = static_cast<tofDaqMap_st*>(tofDaqMap->GetArray());
66  for (Int_t i=0;i<mNTOF;i++) {
67  mMRPC2TDIGChan[i] = (Int_t)(daqmap[0].MRPC2TDIGChanMap[i]);
68  mTDIG2MRPCChan[mMRPC2TDIGChan[i]] = i;
69  if(maker->Debug()) {
70  LOG_DEBUG << " MRPC = " << i << " TDC chan = " << mMRPC2TDIGChan[i] << endm;
71  }
72  }
73  for (Int_t i=0;i<mNVPD;i++) {
74  mWestPMT2TDIGLeChan[i] = (Int_t)(daqmap[0].PMT2TDIGLeChanMap[i]);
75  mWestPMT2TDIGTeChan[i] = (Int_t)(daqmap[0].PMT2TDIGTeChanMap[i]);
76  if(maker->Debug()) {
77  LOG_DEBUG << " VPD = " << i << " TDC Lechan = " << mWestPMT2TDIGLeChan[i] << " TDC TeChan = " << mWestPMT2TDIGTeChan[i] << endm;
78  }
79  mTDIGLe2WestPMTChan[mWestPMT2TDIGLeChan[i]] = i;
80  mTDIGTe2WestPMTChan[mWestPMT2TDIGTeChan[i]] = i;
81 
82  int j=i+mNVPD;
83 
84  mEastPMT2TDIGLeChan[i] = (Int_t)(daqmap[0].PMT2TDIGLeChanMap[j]);
85  mEastPMT2TDIGTeChan[i] = (Int_t)(daqmap[0].PMT2TDIGTeChanMap[j]);
86  if(maker->Debug()) {
87  LOG_DEBUG << " VPD = " << i << " TDC Lechan = " << mEastPMT2TDIGLeChan[i] << " TDC TeChan = " << mEastPMT2TDIGTeChan[i] << endm;
88  }
89  mTDIGLe2EastPMTChan[mEastPMT2TDIGLeChan[i]] = i;
90  mTDIGTe2EastPMTChan[mEastPMT2TDIGTeChan[i]] = i;
91  }
92 
93  // valid tray Id
94  mDbTOFDataSet = maker->GetDataBase("Calibrations/tof/tofTrayConfig");
95  St_tofTrayConfig* trayConfig = static_cast<St_tofTrayConfig*>(mDbTOFDataSet->Find("tofTrayConfig"));
96  if(!trayConfig) {
97  LOG_ERROR << "unable to get tof tray configuration" << endm;
98  return; // kStErr;
99  }
100  tofTrayConfig_st* trayconf = static_cast<tofTrayConfig_st*>(trayConfig->GetArray());
101  if(maker->Debug()) { LOG_DEBUG << " Valid Trays: " << endm; }
102  mNValidTrays = (Int_t)(trayconf[0].entries);
103  for (Int_t i=0;i<mNValidTrays;i++) {
104  mValidTrayId[i] = (Int_t)(trayconf[0].iTray[i]);
105  if(maker->Debug()) {
106  LOG_DEBUG << " " << mValidTrayId[i];
107  }
108  }
109  if(maker->Debug()) { LOG_DEBUG << endm; }
110 
111  LOG_DEBUG << "[StBTofDaqMap] ... done." << endm;
112  return;
113 }
114 
115 
116 void StBTofDaqMap::Reset() {
117  for(int i=0;i<mNTOF;i++) {
118  mMRPC2TDIGChan[i] = -1;
119  mTDIG2MRPCChan[i] = -1;
120  mTDIGLe2WestPMTChan[i] = -1;
121  mTDIGTe2WestPMTChan[i] = -1;
122  mTDIGLe2EastPMTChan[i] = -1;
123  mTDIGTe2EastPMTChan[i] = -1;
124  }
125  for(int i=0;i<mNVPD;i++) {
126  mEastPMT2TDIGLeChan[i] = -1;
127  mEastPMT2TDIGTeChan[i] = -1;
128  mWestPMT2TDIGLeChan[i] = -1;
129  mWestPMT2TDIGTeChan[i] = -1;
130  }
131 
132  mNValidTrays = 0;
133 }
134 
135 // tof8++
136 IntVec StBTofDaqMap::TDIGChan2Cell( const Int_t iTdc)
137 {
138  IntVec map;
139  map.clear();
140 
141  if ( iTdc<0 || iTdc>=mNTOF ) {
142  LOG_ERROR << "[TDIGChan2Cell] Uncorrected TDC Channel number for Tof! " << endm;
143  return map;
144  }
145 
146  Int_t ModuleChan = mTDIG2MRPCChan[iTdc];
147  Int_t Module = ModuleChan / mNCell + 1;
148  Int_t Cell = ModuleChan % mNCell + 1;
149  map.push_back(Module);
150  map.push_back(Cell);
151 
152  return map;
153 }
154 
155 Int_t StBTofDaqMap::Cell2TDIGChan( const Int_t iModule, const Int_t iCell )
156 {
157 
158  if(iModule<1 || iModule>mNModule ) {
159  LOG_ERROR<<"[Cell2TDIGChan] Wrong module number !"<<endm;
160  return -1;
161  }
162  if(iCell <1 || iCell > mNCell) {
163  LOG_ERROR<<"[Cell2TDIGChan] Wrong cell number ! "<<endm;
164  return -1;
165  }
166 
167  Int_t modulechan = (iModule-1)*mNCell+(iCell-1);
168 
169 // if (modulechan<1 || modulechan>=mNTOF) {
170  if (modulechan<0 || modulechan>=mNTOF) {
171  LOG_ERROR<<"[Cell2TDIGChan] Wrong Module-Cell channel number!"<<endm;
172  return -1;
173  }
174 
175  return mMRPC2TDIGChan[modulechan];
176 }
177 
178 Int_t StBTofDaqMap::WestPMT2TDIGLeChan( const Int_t iTube )
179 {
180  if ( iTube<1 || iTube>mNVPD ) {
181  LOG_ERROR<<"[WestPMT2TDIGLeChan] Wrong vpd tube number ! "<<endm;
182  return -1;
183  }
184 
185  return mWestPMT2TDIGLeChan[iTube-1];
186 }
187 
188 Int_t StBTofDaqMap::WestPMT2TDIGTeChan( const Int_t iTube )
189 {
190  if ( iTube<1 || iTube>mNVPD ) {
191  LOG_ERROR<<"[WestPMT2TDIGTeChan] Wrong vpd tube number ! "<< iTube<<endm;
192  return -1;
193  }
194 
195  return mWestPMT2TDIGTeChan[iTube-1];
196 }
197 
198 Int_t StBTofDaqMap::TDIGLeChan2WestPMT( const Int_t iTdc )
199 {
200  if ( iTdc<0 || iTdc>=mNTOF ) {
201  LOG_ERROR<<"[TDIGLeChan2WestPMT] Wrong tdc channel number ! "<< iTdc<<endm;
202  return -1;
203  }
204 
205  return mTDIGLe2WestPMTChan[iTdc] + 1;
206 }
207 
208 Int_t StBTofDaqMap::TDIGTeChan2WestPMT( const Int_t iTdc )
209 {
210  if ( iTdc<0 || iTdc>=mNTOF ) {
211  LOG_ERROR<<"[TDIGTeChan2WestPMT] Wrong tdc channel number ! "<< iTdc <<endm;
212  return -1;
213  }
214 
215  return mTDIGTe2WestPMTChan[iTdc] + 1;
216 }
217 
218 Int_t StBTofDaqMap::EastPMT2TDIGLeChan( const Int_t iTube )
219 {
220  if ( iTube<1 || iTube>mNVPD ) {
221  LOG_ERROR<<"[EastPMT2TDIGLeChan] Wrong vpd tube number ! "<<iTube<< endm;
222  return -1;
223  }
224 
225  return mEastPMT2TDIGLeChan[iTube-1];
226 }
227 
228 Int_t StBTofDaqMap::EastPMT2TDIGTeChan( const Int_t iTube )
229 {
230  if ( iTube<1 || iTube>mNVPD ) {
231  LOG_ERROR<<"[EastPMT2TDIGTeChan] Wrong vpd tube number ! "<<iTube<< endm;
232  return -1;
233  }
234 
235  return mEastPMT2TDIGTeChan[iTube-1];
236 }
237 
238 Int_t StBTofDaqMap::TDIGLeChan2EastPMT( const Int_t iTdc )
239 {
240  if ( iTdc<0 || iTdc>=mNTOF ) {
241  LOG_ERROR<<"StBTofDaqMap::TDIGLeChan2EastPMT: Wrong tdc channel number ! "<<iTdc<<endm;
242  return -1;
243  }
244 
245  return mTDIGLe2EastPMTChan[iTdc] + 1;
246 }
247 
248 Int_t StBTofDaqMap::TDIGTeChan2EastPMT( const Int_t iTdc )
249 {
250  if ( iTdc<0 || iTdc>=mNTOF ) {
251  LOG_ERROR<<"StBTofDaqMap::TDIGTeChan2EastPMT: Wrong tdc channel number ! "<<iTdc << endm;
252  return -1;
253  }
254 
255  return mTDIGTe2EastPMTChan[iTdc] + 1;
256 }
257 
259 {
260  IntVec trayId;
261  for(int i=0;i<mNValidTrays;i++) {
262  trayId.push_back(mValidTrayId[i]);
263  }
264 
265  return trayId;
266 }
void Init(StMaker *maker)
Initial function, need a maker to access the data base.
Int_t WestPMT2TDIGTeChan(const Int_t iTube)
To convert west VPD PMT number to TDIG trailing channel number.
Int_t WestPMT2TDIGLeChan(const Int_t iTube)
To convert west VPD PMT number to TDIG leading channel number.
Int_t TDIGLeChan2WestPMT(const Int_t iTdc)
To convert TDIG leading channel number to west VPD PMT number.
IntVec ValidTrays()
Returns the list of valid tray Ids.
Int_t TDIGLeChan2EastPMT(const Int_t iTdc)
To convert TDIG leading channel number to east VPD PMT number.
Int_t Cell2TDIGChan(const Int_t iModule, const Int_t iCell)
To convert module/cell number to TDIG channel number.
Int_t TDIGTeChan2EastPMT(const Int_t iTdc)
To convert TDIG trailing channel number to east VPD PMT number.
Int_t EastPMT2TDIGTeChan(const Int_t iTube)
To convert east VPD PMT number to TDIG trailing channel number.
Int_t TDIGTeChan2WestPMT(const Int_t iTdc)
To convert TDIG trailing channel number to west VPD PMT number.
IntVec TDIGChan2Cell(const Int_t iTdc)
To convert TDIG channel number to module/cell number.
StBTofDaqMap()
Default constructor.
Int_t EastPMT2TDIGLeChan(const Int_t iTube)
virtual TDataSet * Find(const char *path) const
Definition: TDataSet.cxx:362