38 #include "StSstDbMaker.h"
39 #include "TDataSetIter.h"
40 #include "StMessMgr.h"
41 #include "tables/St_sstWafersPosition_Table.h"
42 #include "tables/St_sstConfiguration_Table.h"
43 #include "tables/St_sstDimensions_Table.h"
44 #include "tables/St_sstMaskChip_Table.h"
45 #include "tables/St_sstSlsCtrl_Table.h"
46 #include "tables/St_Survey_Table.h"
49 #include "StTpcDb/StTpcDb.h"
50 #include "StSstUtil/StSstConsts.h"
53 THashList *StSstDbMaker::fRotList = 0;
58 StMaker(name), mySst(0), dimensions(0), config(0), ctrl(0), mode(0),
59 mReady(
kStErr),m_positions(0)
64 StSstDbMaker::~StSstDbMaker() {SafeDelete(mySst); gStSstDbMaker = 0;}
66 Int_t StSstDbMaker::InitRun(Int_t runNumber)
70 St_sstMaskChip *maskChipTable = (St_sstMaskChip*)GetDataBase(
"Calibrations/sst/sstMaskChip");
72 LOG_INFO <<
"sst mask chips table found ... initialize" << endm;
73 setMaskChips(maskChipTable->GetTable());}
74 else {LOG_ERROR <<
" no sst masking chips table " << endm;
78 St_sstSlsCtrl *m_ctrl = (St_sstSlsCtrl *)GetDataBase(
"Geometry/sst/sstSlsCtrl");
80 LOG_ERROR <<
"InitRun: No relevant entry found in 'Geometry/sst/sstSlsCtrl' table" << endm;
84 ctrl = m_ctrl->GetTable();
86 St_sstDimensions *m_dimensions = (St_sstDimensions *) GetDataBase(
"Geometry/sst/sstDimensions");
89 LOG_ERROR <<
"InitRun: No relevant entry found in 'Geometry/sst/sstDimensions' table" << endm;
94 dimensions = m_dimensions->GetTable();
96 m_positions = calculateWafersPosition();
103 St_sstConfiguration *configTable = (St_sstConfiguration *) GetDataBase(
"Geometry/sst/sstConfiguration");
106 LOG_ERROR <<
"InitRun: No relevant entry found in 'Geometry/sst/sstConfiguration' table" << endm;
111 config = configTable->GetTable() ;
112 sstDimensions_st *dimensions = m_dimensions->GetTable();
115 if (Debug()) mySst->SetDebug(Debug());
117 mySst->initLadders(m_positions);
130 St_sstWafersPosition *StSstDbMaker::calculateWafersPosition()
132 SafeDelete(fRotList);
133 fRotList =
new THashList(320, 0);
134 fRotList->SetOwner(kFALSE);
142 TGeoHMatrix LS, OT, SO, SG, LA, WG;
144 const TGeoHMatrix &Tpc2Global = gStTpcDb->Tpc2GlobalMatrix();
147 St_Survey *sstOnOsc = (St_Survey *) GetDataBase(
"Geometry/sst/sstOnOsc");
150 LOG_ERROR <<
"CalculateWafersPosition: No relevant entry found in 'Geometry/sst/sstOnOsc' table" << endm;
154 St_Survey *oscOnTpc = (St_Survey *) GetDataBase(
"Geometry/sst/oscOnTpc");
156 LOG_ERROR <<
"CalculateWafersPosition: No relevant entry found in 'Geometry/sst/oscOnTpc' table" << endm;
160 St_Survey *sstLadderOnSst = (St_Survey *) GetDataBase(
"Geometry/sst/sstLadderOnSst");
162 if (!sstLadderOnSst) {
163 LOG_ERROR <<
"CalculateWafersPosition: No relevant entry found in 'Geometry/sst/sstLadderOnSst' table" << endm;
167 St_Survey *sstSensorOnLadder = (St_Survey *) GetDataBase(
"Geometry/sst/sstSensorOnLadder");
169 if (!sstSensorOnLadder) {
170 LOG_ERROR <<
"CalculateWafersPosition: No relevant entry found in 'Geometry/sst/sstSensorOnLadder' table" << endm;
174 Survey_st *oscOnTpc_st = oscOnTpc->GetTable();
175 Survey_st *sstOnOsc_st = sstOnOsc->GetTable();
176 Survey_st *ladderOnSst = sstLadderOnSst->GetTable();
177 Survey_st *sensorOnLadder = sstSensorOnLadder->GetTable();
179 Int_t NoOsc = sstOnOsc->GetNRows();
180 Int_t NoLadders = sstLadderOnSst->GetNRows();
181 Int_t NoSensors = sstSensorOnLadder->GetNRows();
183 LOG_DEBUG <<
"CalculateWafersPosition:\n"
184 <<
" Number of Osc: " << NoOsc <<
"\n"
185 <<
" Number of Ladders: " << NoLadders <<
"\n"
186 <<
" Number of Sensors: " << NoSensors << endm;
188 St_sstWafersPosition *sstwafer =
new St_sstWafersPosition(
"sstWafersPosition", NoSensors);
191 sstWafersPosition_st *row =
new sstWafersPosition_st();
192 memset(row,0, 4*960*
sizeof(Double_t));
194 OT.SetRotation(&oscOnTpc_st->r00);
195 OT.SetTranslation(&oscOnTpc_st->t0);
197 for (Int_t i = 0; i < NoSensors; i++, sensorOnLadder++) {
198 Int_t Id = sensorOnLadder->Id;
200 TGeoHMatrix *comb = (TGeoHMatrix *) fRotList->FindObject(Form(
"R%04i", Id));
204 comb =
new TGeoHMatrix(Form(
"R%04i", Id));
205 Int_t layer = Id / 1000;
207 if (layer > 7) layer = 7;
209 Int_t ladder = Id % 100;
211 WLL.SetRotation(&sensorOnLadder->r00);
212 WLL.SetTranslation(&sensorOnLadder->t0);
215 LOG_DEBUG <<
"CalculateWafersPosition: WL" << endm;
219 TGeoHMatrix *WL = (TGeoHMatrix *) fRotList->FindObject(Form(
"WL%04i", Id));
222 WL =
new TGeoHMatrix(Form(
"WL%04i", Id));
223 Double_t *r = WLL.GetRotationMatrix();
224 Double_t rot[9] = {r[0], r[1], r[2],
228 WL->SetRotation(rot);
229 WL->SetTranslation(WLL.GetTranslation());
233 ladderOnSst = sstLadderOnSst->GetTable();
237 for (Int_t l = 0; l < NoLadders; l++, ladderOnSst++) {
238 Ladder = ladderOnSst->Id % 100;
240 if (Ladder == ladder) {
241 OSC = ladderOnSst->Id / 100;
242 LS.SetRotation(&ladderOnSst->r00);
243 LS.SetTranslation(&ladderOnSst->t0);
246 LOG_DEBUG <<
"CalculateWafersPosition: LS" << endm;
255 LOG_WARN <<
"CalculateWafersPosition: OSC has not been defined. Skipping to next sensor..." << endm;
259 sstOnOsc_st = sstOnOsc->GetTable();
262 for (Int_t s = 0; s < NoOsc; s++, sstOnOsc_st++) {
263 if (sstOnOsc_st->Id != OSC)
continue;
266 SO.SetRotation(&sstOnOsc_st->r00);
267 SO.SetTranslation(&sstOnOsc_st->t0);
274 LOG_WARN <<
"CalculateWafersPosition: OSC " << OSC <<
" has not been found. Skipping to next sensor..." << endm;
279 LOG_DEBUG <<
"CalculateWafersPosition: Tpc2Global" << endm;
283 WG = Tpc2Global * SG * LS * WLL;
286 LOG_DEBUG <<
"CalculateWafersPosition: WG" << endm;
290 Double_t *r = WG.GetRotationMatrix();
292 row->driftDirection[index+0] = r[0];
293 row->driftDirection[index+1] = r[3];
294 row->driftDirection[index+2] = r[6];
296 row->normalDirection[index+0] = r[1];
297 row->normalDirection[index+1] = r[4];
298 row->normalDirection[index+2] = r[7];
300 row->transverseDirection[index+0] = r[2];
301 row->transverseDirection[index+1] = r[5];
302 row->transverseDirection[index+2] = r[8];
304 Double_t *wgtr = WG.GetTranslation();
305 row->centerPosition[index+0] = wgtr[0];
306 row->centerPosition[index+1] = wgtr[1];
307 row->centerPosition[index+2] = wgtr[2];
309 comb->SetRotation(WG.GetRotationMatrix());
310 comb->SetTranslation(WG.GetTranslation());
316 LOG_DEBUG <<
"CalculateWafersPosition: R" << endm;
320 sstwafer->AddAt(row);
337 if (ladder < 1 || ladder > kSstNumLadders || sensor < 1 || sensor > kSstNumSensorsPerLadder)
340 int id = 7000 + 100*sensor + ladder;
341 return fRotList ? (TGeoHMatrix *) fRotList->FindObject(Form(
"R%04i",
id)) : 0;
344 Int_t StSstDbMaker::maskChip(Int_t side, Int_t ladder, Int_t wafer, Int_t chip)
const
346 map<unsigned int,short>::const_iterator got;
347 got = mMapMaskChips.find(side*1920 + ladder*96 + wafer*6 + chip);
348 if ( got == mMapMaskChips.end() ) {
356 void StSstDbMaker::setMaskChips(sstMaskChip_st *maskChipTable)
358 for(Int_t i=0; i<3840; ++i){
359 if(maskChipTable[0].chip[i]>0){
360 mMapMaskChips.insert ( std::pair<unsigned long, short>(i,maskChipTable[0].chip[i]) );
361 LOG_DEBUG <<
" found chip to mask : adress : " << i << endm;
static const TGeoHMatrix * getHMatrixSensorOnGlobal(int ladder, int sensor)