StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StIstDb.cxx
1 /* $Id: StIstDb.cxx,v 1.15 2018/03/15 21:35:48 dongx Exp $ */
2 
3 #include <assert.h>
4 #include "StIstDb.h"
5 #include "StMessMgr.h"
6 #include "StTpcDb/StTpcDb.h"
7 #include "St_db_Maker/St_db_Maker.h"
8 
9 #include "tables/St_Survey_Table.h"
10 #include "tables/St_istPedNoise_Table.h"
11 #include "tables/St_istGain_Table.h"
12 #include "tables/St_istMapping_Table.h"
13 #include "tables/St_istControl_Table.h"
14 #include "tables/St_istChipConfig_Table.h"
15 #include "tables/St_istSimPar_Table.h"
16 
17 THashList *StIstDb::mgRotList = 0;
18 
19 ClassImp(StIstDb)
20 
21 
22 
27 {
28  mGeoHMatrixTpcOnGlobal = NULL;
29  mIstPedNoise = NULL;
30  mIstGain = NULL;
31  mIstMapping = NULL;
32  mIstControl = NULL;
33  mIstChipStatus = NULL;
34  mIstSimPar = 0;
35 }
36 //_____________________________________________________________________________
37 Int_t StIstDb::setGeoHMatrices(Survey_st **tables)
38 {
39  using namespace StIstConsts;
40 
41  SafeDelete(mgRotList);
42  mgRotList = new THashList(kIstNumLadders * kIstNumSensorsPerLadder, 0);
43  mgRotList->SetOwner(kFALSE);
44 
45  //get TPC positionement relative to STAR
46  if (gStTpcDb) {
47  mGeoHMatrixTpcOnGlobal = (TGeoHMatrix *)&gStTpcDb->Tpc2GlobalMatrix();
48  }
49  else {
50  if (mGeoHMatrixTpcOnGlobal) delete mGeoHMatrixTpcOnGlobal;
51 
52  mGeoHMatrixTpcOnGlobal = new TGeoHMatrix("tpcOnGlobal");
53  LOG_WARN << "No gStTpcDb, use null transformation for tpc on global" << endm;
54  }
55 
56  //obtain IST geomery tables
57  Survey_st *idsOnTpc = tables[0];
58  Survey_st *pstOnIds = tables[1];
59  Survey_st *istOnPst = tables[2];
60  Survey_st *laddersOnIst = tables[3];
61  Survey_st *sensorsOnLadders = tables[4];
62 
63  mGeoHMatrixIdsOnTpc.SetName("idsOnTpc");
64  mGeoHMatrixIdsOnTpc.SetRotation(&idsOnTpc->r00);
65  mGeoHMatrixIdsOnTpc.SetTranslation(&idsOnTpc->t0);
66 
67  mGeoHMatrixPstOnIds.SetName("pstOnIds");
68  mGeoHMatrixPstOnIds.SetRotation(&pstOnIds->r00);
69  mGeoHMatrixPstOnIds.SetTranslation(&pstOnIds->t0);
70 
71  mGeoHMatrixIstOnPst.SetName("istOnPst");
72  mGeoHMatrixIstOnPst.SetRotation(&istOnPst->r00);
73  mGeoHMatrixIstOnPst.SetTranslation(&istOnPst->t0);
74 
75  for (int i = 0; i < kIstNumSensors; i++, sensorsOnLadders++) {
76  int id = sensorsOnLadders->Id;
77  TGeoHMatrix *comb = (TGeoHMatrix *) mgRotList->FindObject(Form("R%04i", id));
78 
79  if (comb) continue;
80 
81  comb = new TGeoHMatrix(Form("R%04i", id));
82  int ladder = ((id - 1000) - 1) / kIstNumSensorsPerLadder + 1; // 1 <= ladder <= 24
83  int sensor = ((id - 1000) - 1) % kIstNumSensorsPerLadder + 1; // 1 <= sensor <= 6
84 
85  if (ladder <= 0 || ladder > kIstNumLadders) {
86  LOG_WARN << "Ladder ID is out of range (1 - 24)!" << endm;
87  continue;
88  }
89 
90  if (sensor <= 0 || sensor > kIstNumSensorsPerLadder) {
91  LOG_WARN << "Sensor ID is out of range (1 - 6)!" << endm;
92  continue;
93  }
94 
95  //setting rotation/translation for sensor geometry matrix
96  mGeoHMatrixSensorOnLadder[ladder - 1][sensor - 1].SetName(Form("sensorOnLadder%4i%4i", ladder, sensor));
97  mGeoHMatrixSensorOnLadder[ladder - 1][sensor - 1].SetRotation(&sensorsOnLadders->r00);
98  mGeoHMatrixSensorOnLadder[ladder - 1][sensor - 1].SetTranslation(&sensorsOnLadders->t0);
99 
100  TGeoHMatrix *sensorLocal = (TGeoHMatrix *) mgRotList->FindObject(Form("sensorLocal%04i", id));
101 
102  if (!sensorLocal) {
103  sensorLocal = new TGeoHMatrix(Form("sensorLocal%04i", id));
104  sensorLocal->SetRotation(mGeoHMatrixSensorOnLadder[ladder - 1][sensor - 1].GetRotationMatrix());
105  sensorLocal->SetTranslation(mGeoHMatrixSensorOnLadder[ladder - 1][sensor - 1].GetTranslation());
106  mgRotList->Add(sensorLocal);
107  }
108 
109  //seeting rotation/translation for ladder geometry matrix
110  for (int l = 0; l < kIstNumLadders; l++, laddersOnIst++) {
111  if (ladder == laddersOnIst->Id) {
112  mGeoHMatrixLadderOnIst[ladder - 1].SetName(Form("ladderOnIst%4i", ladder));
113  mGeoHMatrixLadderOnIst[ladder - 1].SetRotation(&laddersOnIst->r00);
114  mGeoHMatrixLadderOnIst[ladder - 1].SetTranslation(&laddersOnIst->t0);
115  break;
116  }
117  }
118 
119  //calculate sensor global position
120  TGeoHMatrix sensorGlobal = (*mGeoHMatrixTpcOnGlobal) * mGeoHMatrixIdsOnTpc * mGeoHMatrixPstOnIds * mGeoHMatrixIstOnPst * mGeoHMatrixLadderOnIst[ladder - 1] * mGeoHMatrixSensorOnLadder[ladder - 1][sensor - 1];
121 
122  comb->SetRotation(sensorGlobal.GetRotationMatrix());
123  comb->SetTranslation(sensorGlobal.GetTranslation());
124  mgRotList->Add(comb);
125  }
126 
127  return kStOk;
128 }
129 
130 
136 const TGeoHMatrix *StIstDb::getHMatrixSensorOnGlobal(int ladder, int sensor)
137 {
138  if (ladder < 1 || ladder > kIstNumLadders || sensor < 1 || sensor > kIstNumSensorsPerLadder)
139  return 0;
140 
141  int id = 1000 + (ladder - 1) * kIstNumSensorsPerLadder + sensor;
142  return mgRotList ? (const TGeoHMatrix *) mgRotList->FindObject(Form("R%04i", id)) : 0;
143 }
144 
145 
146 void StIstDb::Print(Option_t *opt) const
147 {
148  mGeoHMatrixTpcOnGlobal->Print();
149  mGeoHMatrixIdsOnTpc.Print();
150  mGeoHMatrixPstOnIds.Print();
151  mGeoHMatrixIstOnPst.Print();
152 
153  for (Int_t iL = 0; iL < kIstNumLadders; iL++) {
154  mGeoHMatrixLadderOnIst[iL].Print();
155  }
156 
157  for (Int_t iL = 0; iL < kIstNumLadders; iL++) {
158  for (Int_t iS = 0; iS < kIstNumSensorsPerLadder; iS++) {
159  mGeoHMatrixSensorOnLadder[iL][iS].Print();
160  }
161  }
162 
163  for (Int_t iS = 1; iS <= kIstNumSensors; iS++) {
164  TGeoHMatrix *sensorOnGlobal = (TGeoHMatrix *) mgRotList->FindObject(Form("R%04i", iS + 1000));
165  sensorOnGlobal->Print();
166  }
167 }
168 
169 
170 /***************************************************************************
171 *
172 * $Log: StIstDb.cxx,v $
173 * Revision 1.15 2018/03/15 21:35:48 dongx
174 * Added the access to new table istSimPar
175 *
176 * Revision 1.14 2015/08/03 14:26:03 smirnovd
177 * Corrected style with 'astyle -s3 -p -H -A3 -k3 -O -o -y -Y -f'
178 *
179 * Revision 1.13 2014/12/17 19:37:47 smirnovd
180 * StiIstDb: Corrected mapping of ladder/sensor to global aggregate sensor id.
181 *
182 * The global sensor index (id) used in the istSensorOnLadder DB table spans the
183 * range from 1001 to 1144. This bug was reported by Michael Lomnitz
184 *
185 * Revision 1.12 2014/12/12 21:41:09 smirnovd
186 * StIstDb: Modified getter for sensors transormation matrix to accept ladder and sensor id-s using human friendly numbering starting with 1. The input values outside of possible ranges will return a null pointer
187 *
188 * Revision 1.11 2014/11/18 23:11:57 smirnovd
189 * StIstDb: Added method to access transformation matrix for a given IST ladder/sensor pair
190 *
191 * Revision 1.10 2014/11/18 23:10:20 smirnovd
192 * Renamed printGeoHMatrices to customary Print as that what users of ROOT framework normaly expect
193 *
194 * Revision 1.9 2014/11/18 23:08:37 smirnovd
195 * Moved CVS log to the end of file and updated doxygen-style comments
196 *
197 * Revision 1.8 2014/08/06 18:44:21 ypwang
198 * replace assert statement for gStTpcDb with normal variable check and LOG_WARN printout; non-ROOT methods formatted with STAR coding style
199 *
200 * Revision 1.7 2014/08/05 17:48:58 ypwang
201 * update Print() function to PrintGeoHMatrices()
202 *
203 * Revision 1.6 2014/08/05 15:00:45 ypwang
204 * minor updates on the ladder/sensor ID check output log, using LOG_WARN instead of cout
205 *
206 * Revision 1.5 2014/08/01 22:25:48 ypwang
207 * Add several simple getters and data members for sub-level geometry matrices obtain; Add Print() function which print out all IST geometry matrices
208 *
209 * Revision 1.4 2014/07/31 22:40:59 smirnovd
210 * StIstDb: Reduced the scope of the using namespace
211 *
212 * Revision 1.3 2014/07/31 22:40:52 smirnovd
213 * StIstDb: Removed unused header includes
214 *
215 * Revision 1.2 2014/07/31 18:29:51 ypwang
216 * replace the LOG_INFO with LOG_DEBUG to slim the log file
217 *
218 * Revision 1.1 2014/07/29 19:50:25 ypwang
219 * IST DB dataset in order to separate from IST Db maker
220 *
221 *
222 *
223 ****************************************************************************
224 * StIstDb.cxx,v 1.0
225 * Revision 1.0 2014/7/28 16:15:30 Yaping
226 * Initial version
227 ****************************************************************************/
const int kIstNumLadders
24 IST Ladders
const int kIstNumSensorsPerLadder
6 sensor per one IST Ladder
static const TGeoHMatrix * getHMatrixSensorOnGlobal(int ladder, int sensor)
Definition: StIstDb.cxx:136
Definition: Stypes.h:41
const int kIstNumSensors
144 sensors