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"
78 mGeoHMatrixTpcOnGlobal = 0;
79 mSensorStatusTable = 0;
80 mRowColumnStatusTable = 0;
84 memset(mThinPlateSpline, 0,
sizeof(mThinPlateSpline));
90 mGeoHMatrixTpcOnGlobal = (TGeoHMatrix *)&gStTpcDb->Tpc2GlobalMatrix();
92 if (mGeoHMatrixTpcOnGlobal)
delete mGeoHMatrixTpcOnGlobal;
93 mGeoHMatrixTpcOnGlobal =
new TGeoHMatrix(
"tpcOnGlobal");
94 LOG_WARN <<
"No gStTpcDb, use null transformation for tpc on global" << endm;
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];
105 mGeoHMatrixIdsOnTpc.SetName(
"idsOnTpc");
106 mGeoHMatrixIdsOnTpc.SetRotation(&IdsOnTpc->r00);
107 mGeoHMatrixIdsOnTpc.SetTranslation(&IdsOnTpc->t0);
109 mGeoHMatrixPstOnIds.SetName(
"pstOnIds");
110 mGeoHMatrixPstOnIds.SetRotation(&PstOnIds->r00);
111 mGeoHMatrixPstOnIds.SetTranslation(&PstOnIds->t0);
113 mGeoHMatrixPxlOnPst.SetName(
"pxlOnPst");
114 mGeoHMatrixPxlOnPst.SetRotation(&PxlOnPst->r00);
115 mGeoHMatrixPxlOnPst.SetTranslation(&PxlOnPst->t0);
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);
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);
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);
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);
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));
165 if (!mSensorStatusTable)
return 255;
166 return mSensorStatusTable->status[(sector - 1) * kNumberOfPxlLaddersPerSector * kNumberOfPxlSensorsPerLadder + (ladder - 1) * kNumberOfPxlSensorsPerLadder + (sensor - 1)];
171 if (!mRowColumnStatusTable)
return 255;
172 return mRowColumnStatusTable->rows[kNumberOfPxlRowsOnSensor * ((sector - 1) * (kNumberOfPxlSensorsPerLadder * kNumberOfPxlLaddersPerSector) + (ladder - 1) * kNumberOfPxlSensorsPerLadder + (sensor - 1)) + row];
177 if (!mRowColumnStatusTable)
return 255;
178 return mRowColumnStatusTable->cols[kNumberOfPxlColumnsOnSensor * ((sector - 1) * (kNumberOfPxlSensorsPerLadder * kNumberOfPxlLaddersPerSector) + (ladder - 1) * kNumberOfPxlSensorsPerLadder + (sensor - 1)) + column];
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() ) {
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);
206 void StPxlDb::setHotPixels(pxlHotPixels_st *hotPixelsTable)
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) );
216 void StPxlDb::setBadRowColumns(pxlBadRowColumns_st *badRowColumns)
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; }
241 void StPxlDb::Print(Option_t *opt)
const
243 LOG_DEBUG <<
"Print all StPxlDb matrices:" << endm;
245 mGeoHMatrixTpcOnGlobal->Print();
246 mGeoHMatrixIdsOnTpc.Print();
247 mGeoHMatrixPstOnIds.Print();
248 mGeoHMatrixPxlOnPst.Print();
250 LOG_DEBUG <<
"geoHMatrix pxl half on pxl: " << endm;
251 for (
int i = 0; i < 2; i++) {
252 mGeoHMatrixHalfOnPxl[i].Print();
255 LOG_DEBUG <<
"geoHMatrix pxl sector on half: " << endm;
256 for (
int i = 0; i < kNumberOfPxlSectors; i++) {
257 mGeoHMatrixSectorOnHalf[i].Print();
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();
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();
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();
void setThinPlateSpline(pxlSensorTps_st *pxlSensorTps)
create sensor thin plate spline functions and set their parameters
void setGeoHMatrices(Survey_st **tables)
set geoHMatrix parameters with parameters from Survey_st tables
Int_t pixelHot(Int_t sector, Int_t ladder, Int_t sensor, Int_t row, Int_t column) const
1: hot; 0: good
Int_t sensorStatus(Int_t sector, Int_t ladder, Int_t sensor) const
status for sensor/row/column
Int_t rowStatus(Int_t sector, Int_t ladder, Int_t sensor, Int_t row) const
1: good status
Int_t columnStatus(Int_t sector, Int_t ladder, Int_t sensor, Int_t column) const
1: good status