StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StPxlDb.cxx
1 
6 /***************************************************************************
7  *
8  * $Id: StPxlDb.cxx,v 1.11 2018/03/15 21:33:07 dongx Exp $
9  *
10  * Author: Qiu Hao, Jan 2014
11  ***************************************************************************
12  *
13  * Description:
14  * DB information on pxl geometry and sensor/row/column status
15  * More information at
16  * https://www.star.bnl.gov/protected/heavy/qiuh/HFT/software/PXL_software.pdf
17  *
18  ***************************************************************************
19  *
20  * $Log: StPxlDb.cxx,v $
21  * Revision 1.11 2018/03/15 21:33:07 dongx
22  * *** empty log message ***
23  *
24  * Revision 1.10 2017/09/01 03:10:49 dongx
25  * Added access functions for pxlDigmapsSim table
26  *
27  * Revision 1.9 2015/05/07 04:33:32 smirnovd
28  * StPxlDb: Set name of resulting matrix after copying from a temporary matrix object
29  *
30  * Due to the bug all matrices were given the same name. This inconsistency has
31  * been noted and reported by @MustafaMustafa
32  *
33  * Revision 1.8 2014/10/07 19:25:28 smirnovd
34  * StPxlDbMaker/: Collected all debugging print statements into a single Print() which is called only when Debug2 option is specified
35  *
36  * Revision 1.7 2014/08/27 16:52:14 qiuh
37  * change pxlRowColumnStatus to pxlBadRowColumns to decrease DB szie
38  *
39  * Revision 1.6 2014/07/15 23:28:48 smirnovd
40  * Minor style changes
41  *
42  * Revision 1.5 2014/07/15 23:28:34 smirnovd
43  * .msg
44  *
45  * Revision 1.4 2014/04/01 15:28:18 qiuh
46  * add single hot pixel masking
47  *
48  * Revision 1.3 2014/02/27 21:40:19 smirnovd
49  * Remove unnecessary print out
50  *
51  * Revision 1.2 2014/01/28 19:29:37 qiuh
52  * *** empty log message ***
53  *
54  *
55  **************************************************************************/
56 
57 #include "StPxlDb.h"
58 #include "StPxlUtil/StPxlConstants.h"
59 #include "StPxlUtil/StThinPlateSpline.h"
60 #include "StMessMgr.h"
61 #include "tables/St_Survey_Table.h"
62 #include "StTpcDb/StTpcDb.h"
63 #include "tables/St_pxlSensorStatus_Table.h"
64 #include "tables/St_pxlRowColumnStatus_Table.h"
65 #include "tables/St_pxlBadRowColumns_Table.h"
66 #include "tables/St_pxlHotPixels_Table.h"
67 #include "tables/St_pxlSensorTps_Table.h"
68 #include "tables/St_pxlControl_Table.h"
69 #include "tables/St_pxlDigmapsSim_Table.h"
70 #include "tables/St_pxlSimPar_Table.h"
71 
72 
73 ClassImp(StPxlDb)
74 
75 //_____________________________________________________________________________
77 {
78  mGeoHMatrixTpcOnGlobal = 0;
79  mSensorStatusTable = 0;
80  mRowColumnStatusTable = 0;
81  mPxlControl = 0;
82  mPxlDigmapsSim = 0;
83  mPxlSimPar = 0;
84  memset(mThinPlateSpline, 0, sizeof(mThinPlateSpline));
85 }
86 //_____________________________________________________________________________
87 void StPxlDb::setGeoHMatrices(Survey_st **tables)
88 {
89  if (gStTpcDb)
90  mGeoHMatrixTpcOnGlobal = (TGeoHMatrix *)&gStTpcDb->Tpc2GlobalMatrix();
91  else {
92  if (mGeoHMatrixTpcOnGlobal) delete mGeoHMatrixTpcOnGlobal;
93  mGeoHMatrixTpcOnGlobal = new TGeoHMatrix("tpcOnGlobal");
94  LOG_WARN << "No gStTpcDb, use null transformation for tpc on global" << endm;
95  }
96 
97  Survey_st *IdsOnTpc = tables[0];
98  Survey_st *PstOnIds = tables[1];
99  Survey_st *PxlOnPst = tables[2];
100  Survey_st *HalfOnPxl = tables[3];
101  Survey_st *SectorsOnHalf = tables[4];
102  Survey_st *LaddersOnSectors = tables[5];
103  Survey_st *SensorsOnLadders = tables[6];
104 
105  mGeoHMatrixIdsOnTpc.SetName("idsOnTpc");
106  mGeoHMatrixIdsOnTpc.SetRotation(&IdsOnTpc->r00);
107  mGeoHMatrixIdsOnTpc.SetTranslation(&IdsOnTpc->t0);
108 
109  mGeoHMatrixPstOnIds.SetName("pstOnIds");
110  mGeoHMatrixPstOnIds.SetRotation(&PstOnIds->r00);
111  mGeoHMatrixPstOnIds.SetTranslation(&PstOnIds->t0);
112 
113  mGeoHMatrixPxlOnPst.SetName("pxlOnPst");
114  mGeoHMatrixPxlOnPst.SetRotation(&PxlOnPst->r00);
115  mGeoHMatrixPxlOnPst.SetTranslation(&PxlOnPst->t0);
116 
117  for (Int_t t = 0; t < 2; t++, HalfOnPxl++) {
118  mGeoHMatrixHalfOnPxl[HalfOnPxl->Id - 1].SetName(Form("halfOnPxl%03i", HalfOnPxl->Id));
119  mGeoHMatrixHalfOnPxl[HalfOnPxl->Id - 1].SetRotation(&HalfOnPxl->r00);
120  mGeoHMatrixHalfOnPxl[HalfOnPxl->Id - 1].SetTranslation(&HalfOnPxl->t0);
121  }
122 
123  for (int i = 0; i < kNumberOfPxlSectors; i++) {
124  mGeoHMatrixSectorOnHalf[SectorsOnHalf->Id - 1].SetName(Form("sectorOnHalf%03i", SectorsOnHalf->Id));
125  mGeoHMatrixSectorOnHalf[SectorsOnHalf->Id - 1].SetRotation(&SectorsOnHalf->r00);
126  mGeoHMatrixSectorOnHalf[SectorsOnHalf->Id - 1].SetTranslation(&SectorsOnHalf->t0);
127  SectorsOnHalf++;
128  }
129 
130  for (int i = 0; i < kNumberOfPxlSectors; i++)
131  for (int j = 0; j < kNumberOfPxlLaddersPerSector; j++) {
132  int iSector = (LaddersOnSectors->Id - 1) / kNumberOfPxlLaddersPerSector;
133  int iLadder = (LaddersOnSectors->Id - 1) % kNumberOfPxlLaddersPerSector;
134  mGeoHMatrixLadderOnSector[iSector][iLadder].SetName(Form("ladderOnSector%03i%03i", iSector + 1, iLadder + 1));
135  mGeoHMatrixLadderOnSector[iSector][iLadder].SetRotation(&LaddersOnSectors->r00);
136  mGeoHMatrixLadderOnSector[iSector][iLadder].SetTranslation(&LaddersOnSectors->t0);
137  LaddersOnSectors++;
138  }
139 
140  for (int i = 0; i < kNumberOfPxlSectors; i++)
141  for (int j = 0; j < kNumberOfPxlLaddersPerSector; j++)
142  for (int k = 0; k < kNumberOfPxlSensorsPerLadder; k++) {
143  int iSector = (SensorsOnLadders->Id - 1) / kNumberOfPxlLaddersPerSector / kNumberOfPxlSensorsPerLadder;
144  int iLadder = ((SensorsOnLadders->Id - 1) / kNumberOfPxlSensorsPerLadder) % kNumberOfPxlLaddersPerSector;
145  int iSensor = (SensorsOnLadders->Id - 1) % kNumberOfPxlSensorsPerLadder;
146  mGeoHMatrixSensorOnLadder[i][j][k].SetName(Form("sensorOnLadder%03i%03i%03i", iSector + 1, iLadder + 1, iSensor + 1));
147  mGeoHMatrixSensorOnLadder[iSector][iLadder][iSensor].SetRotation(&SensorsOnLadders->r00);
148  mGeoHMatrixSensorOnLadder[iSector][iLadder][iSensor].SetTranslation(&SensorsOnLadders->t0);
149  SensorsOnLadders++;
150  }
151 
152  for (int i = 0; i < kNumberOfPxlSectors; i++)
153  for (int j = 0; j < kNumberOfPxlLaddersPerSector; j++)
154  for (int k = 0; k < kNumberOfPxlSensorsPerLadder; k++) {
155  mGeoHMatrixSensorOnGlobal[i][j][k] = (*mGeoHMatrixTpcOnGlobal) * mGeoHMatrixIdsOnTpc * mGeoHMatrixPstOnIds
156  * mGeoHMatrixPxlOnPst * mGeoHMatrixHalfOnPxl[i / 5] * mGeoHMatrixSectorOnHalf[i]
157  * mGeoHMatrixLadderOnSector[i][j] * mGeoHMatrixSensorOnLadder[i][j][k];
158  mGeoHMatrixSensorOnGlobal[i][j][k].SetName(Form("sensorOnGlobal%03i%03i%03i", i + 1, j + 1, k + 1));
159  }
160 
161 }
162 //_____________________________________________________________________________
163 Int_t StPxlDb::sensorStatus(Int_t sector, Int_t ladder, Int_t sensor) const
164 {
165  if (!mSensorStatusTable) return 255;
166  return mSensorStatusTable->status[(sector - 1) * kNumberOfPxlLaddersPerSector * kNumberOfPxlSensorsPerLadder + (ladder - 1) * kNumberOfPxlSensorsPerLadder + (sensor - 1)];
167 }
168 //_____________________________________________________________________________
169 Int_t StPxlDb::rowStatus(Int_t sector, Int_t ladder, Int_t sensor, Int_t row) const
170 {
171  if (!mRowColumnStatusTable) return 255;
172  return mRowColumnStatusTable->rows[kNumberOfPxlRowsOnSensor * ((sector - 1) * (kNumberOfPxlSensorsPerLadder * kNumberOfPxlLaddersPerSector) + (ladder - 1) * kNumberOfPxlSensorsPerLadder + (sensor - 1)) + row];
173 }
174 //_____________________________________________________________________________
175 Int_t StPxlDb::columnStatus(Int_t sector, Int_t ladder, Int_t sensor, Int_t column) const
176 {
177  if (!mRowColumnStatusTable) return 255;
178  return mRowColumnStatusTable->cols[kNumberOfPxlColumnsOnSensor * ((sector - 1) * (kNumberOfPxlSensorsPerLadder * kNumberOfPxlLaddersPerSector) + (ladder - 1) * kNumberOfPxlSensorsPerLadder + (sensor - 1)) + column];
179 }
180 //_____________________________________________________________________________
181 Int_t StPxlDb::pixelHot(Int_t sector, Int_t ladder, Int_t sensor, Int_t row, Int_t column) const
182 {
183  map<unsigned int,short>::const_iterator got;
184  got = mMapHotPixels.find(1000000*((sector-1)*40+(ladder-1)*10+sensor) + 1000*row + column);
185  if ( got == mMapHotPixels.end() ) {
186  return 0;
187  }
188  else {
189  return 1;
190  }
191 }
192 //_____________________________________________________________________________
193 void StPxlDb::setThinPlateSpline(pxlSensorTps_st *pxlSensorTps)
194 {
195  for (Int_t i = 0; i < kNumberOfPxlSectors * kNumberOfPxlLaddersPerSector * kNumberOfPxlSensorsPerLadder; i++) {
196  int id = pxlSensorTps[i].Id;
197  int iSector = (id - 1) / kNumberOfPxlSensorsPerLadder / kNumberOfPxlLaddersPerSector;
198  int iLadder = (id - 1) / kNumberOfPxlSensorsPerLadder % kNumberOfPxlLaddersPerSector;
199  int iSensor = (id - 1) % kNumberOfPxlSensorsPerLadder;
200  int nMeasurements = pxlSensorTps[i].nMeasurements;
201  if (mThinPlateSpline[iSector][iLadder][iSensor]) {delete mThinPlateSpline[iSector][iLadder][iSensor];}
202  mThinPlateSpline[iSector][iLadder][iSensor] = new StThinPlateSpline(nMeasurements, pxlSensorTps[i].X, pxlSensorTps[i].Y, pxlSensorTps[i].W, pxlSensorTps[i].A);
203  }
204 }
205 //_____________________________________________________________________________
206 void StPxlDb::setHotPixels(pxlHotPixels_st *hotPixelsTable)
207 {
208  for(Int_t i=0; i<10000; i++){
209  if(hotPixelsTable[0].hotPixel[i]>0){
210  mMapHotPixels.insert ( std::pair<unsigned long, short>(hotPixelsTable[0].hotPixel[i],i) );
211  }
212  else break;
213  }
214 }
215 //_____________________________________________________________________________
216 void StPxlDb::setBadRowColumns(pxlBadRowColumns_st *badRowColumns)
217 {
218  mRowColumnStatusTable = new pxlRowColumnStatus_st;
219  memset(mRowColumnStatusTable->rows, 1, 400000);
220  memset(mRowColumnStatusTable->cols, 1, 400000);
221  for(Int_t i=0; i<10000; i++){
222  if(badRowColumns->badRowColumns[i]){
223  int isRowOrColumn = badRowColumns->badRowColumns[i]/100000000;
224  int sensorId = badRowColumns->badRowColumns[i]/100000%1000;
225  int iSector = (sensorId - 1) / kNumberOfPxlSensorsPerLadder / kNumberOfPxlLaddersPerSector;
226  int iLadder = (sensorId - 1) / kNumberOfPxlSensorsPerLadder % kNumberOfPxlLaddersPerSector;
227  int iSensor = (sensorId - 1) % kNumberOfPxlSensorsPerLadder;
228  int rowOrColumn = badRowColumns->badRowColumns[i]/100%1000;
229  int status = badRowColumns->badRowColumns[i]%100;
230  if(isRowOrColumn==1 && iSector>=0 && iSector<10 && iLadder>=0 && iLadder<10 && iSensor>=0 && iSensor<10 && rowOrColumn>=0 && rowOrColumn<kNumberOfPxlColumnsOnSensor)
231  mRowColumnStatusTable->cols[kNumberOfPxlColumnsOnSensor * (iSector * (kNumberOfPxlSensorsPerLadder * kNumberOfPxlLaddersPerSector) + iLadder * kNumberOfPxlSensorsPerLadder + iSensor) + rowOrColumn] = status;
232  else if(isRowOrColumn==0 && iSector>=0 && iSector<10 && iLadder>=0 && iLadder<10 && iSensor>=0 && iSensor<10 && rowOrColumn>=0 && rowOrColumn<kNumberOfPxlRowsOnSensor)
233  mRowColumnStatusTable->rows[kNumberOfPxlRowsOnSensor * (iSector * (kNumberOfPxlSensorsPerLadder * kNumberOfPxlLaddersPerSector) + iLadder * kNumberOfPxlSensorsPerLadder + iSensor) + rowOrColumn] = status;
234  else { LOG_WARN<<"wrong bad row column "<<" [ "<<i<<" ]: "<<badRowColumns->badRowColumns[i]<<endm; }
235  }
236  else break;
237  }
238 }
239 
240 
241 void StPxlDb::Print(Option_t *opt) const
242 {
243  LOG_DEBUG << "Print all StPxlDb matrices:" << endm;
244 
245  mGeoHMatrixTpcOnGlobal->Print();
246  mGeoHMatrixIdsOnTpc.Print();
247  mGeoHMatrixPstOnIds.Print();
248  mGeoHMatrixPxlOnPst.Print();
249 
250  LOG_DEBUG << "geoHMatrix pxl half on pxl: " << endm;
251  for (int i = 0; i < 2; i++) {
252  mGeoHMatrixHalfOnPxl[i].Print();
253  }
254 
255  LOG_DEBUG << "geoHMatrix pxl sector on half: " << endm;
256  for (int i = 0; i < kNumberOfPxlSectors; i++) {
257  mGeoHMatrixSectorOnHalf[i].Print();
258  }
259 
260  LOG_DEBUG << "geoHMatrix pxl ladder on sector: " << endm;
261  for (int i = 0; i < kNumberOfPxlSectors; i++)
262  for (int j = 0; j < kNumberOfPxlLaddersPerSector; j++) {
263  mGeoHMatrixLadderOnSector[i][j].Print();
264  }
265 
266  LOG_DEBUG << "geoHMatrix pxl sensor on ladder: " << endm;
267  for (int i = 0; i < kNumberOfPxlSectors; i++)
268  for (int j = 0; j < kNumberOfPxlLaddersPerSector; j++)
269  for (int k = 0; k < kNumberOfPxlSensorsPerLadder; k++) {
270  mGeoHMatrixSensorOnLadder[i][j][k].Print();
271  }
272 
273  LOG_DEBUG << "geoHMatrix pxl sensor on global: " << endm;
274  for (int i = 0; i < kNumberOfPxlSectors; i++)
275  for (int j = 0; j < kNumberOfPxlLaddersPerSector; j++)
276  for (int k = 0; k < kNumberOfPxlSensorsPerLadder; k++) {
277  mGeoHMatrixSensorOnGlobal[i][j][k].Print();
278  }
279 }
void setThinPlateSpline(pxlSensorTps_st *pxlSensorTps)
create sensor thin plate spline functions and set their parameters
Definition: StPxlDb.cxx:193
void setGeoHMatrices(Survey_st **tables)
set geoHMatrix parameters with parameters from Survey_st tables
Definition: StPxlDb.cxx:87
Int_t pixelHot(Int_t sector, Int_t ladder, Int_t sensor, Int_t row, Int_t column) const
1: hot; 0: good
Definition: StPxlDb.cxx:181
Int_t sensorStatus(Int_t sector, Int_t ladder, Int_t sensor) const
status for sensor/row/column
Definition: StPxlDb.cxx:163
Int_t rowStatus(Int_t sector, Int_t ladder, Int_t sensor, Int_t row) const
1: good status
Definition: StPxlDb.cxx:169
Int_t columnStatus(Int_t sector, Int_t ladder, Int_t sensor, Int_t column) const
1: good status
Definition: StPxlDb.cxx:175