StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFstDb.cxx
1 /* $Id: StFstDb.cxx,v */
2 
3 #include <assert.h>
4 #include "StFstDb.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_fstPedNoise_Table.h"
11 #include "tables/St_fstGain_Table.h"
12 #include "tables/St_fstMapping_Table.h"
13 #include "tables/St_fstControl_Table.h"
14 #include "tables/St_fstChipConfig_Table.h"
15 
16 THashList *StFstDb::mgRotList = 0;
17 
18 ClassImp(StFstDb)
19 
20 
21 
26 {
27  mGeoHMatrixTpcOnGlobal = NULL;
28  mFstPedNoise = NULL;
29  mFstGain = NULL;
30  mFstMapping = NULL;
31  mFstControl = NULL;
32  mFstChipStatus = NULL;
33 }
34 //_____________________________________________________________________________
35 Int_t StFstDb::setGeoHMatrices(Survey_st **tables)
36 {
37  //using namespace StFstConsts;
38 
39  SafeDelete(mgRotList);
40  mgRotList = new THashList(kFstNumWedges * kFstNumSensorsPerWedge, 0);
41  mgRotList->SetOwner(kFALSE);
42 
43  //get TPC positionement relative to STAR
44  if (gStTpcDb) {
45  mGeoHMatrixTpcOnGlobal = (TGeoHMatrix *)&gStTpcDb->Tpc2GlobalMatrix();
46  }
47  else {
48  if (mGeoHMatrixTpcOnGlobal) delete mGeoHMatrixTpcOnGlobal;
49 
50  mGeoHMatrixTpcOnGlobal = new TGeoHMatrix("tpcOnGlobal");
51  LOG_WARN << "No gStTpcDb, use null transformation for tpc on global" << endm;
52  }
53 
54  //obtain FST geomery tables
55  Survey_st *fstOnTpc = tables[0];
56  Survey_st *hssOnFst = tables[1];
57  Survey_st *wedgeOnHss = tables[2];
58  Survey_st *sensorsOnWedges = tables[3];
59 
60  mGeoHMatrixFstOnTpc.SetName("fstOnTpc");
61  mGeoHMatrixFstOnTpc.SetRotation(&fstOnTpc->r00);
62  mGeoHMatrixFstOnTpc.SetTranslation(&fstOnTpc->t0);
63 
64  mGeoHMatrixHssOnFst.SetName("hssOnFst");
65  mGeoHMatrixHssOnFst.SetRotation(&hssOnFst->r00);
66  mGeoHMatrixHssOnFst.SetTranslation(&hssOnFst->t0);
67 
68  mGeoHMatrixWedgeOnHss.SetName("wedgeOnHss");
69  mGeoHMatrixWedgeOnHss.SetRotation(&wedgeOnHss->r00);
70  mGeoHMatrixWedgeOnHss.SetTranslation(&wedgeOnHss->t0);
71  for (int i = 0; i < kFstNumSensors; i++, sensorsOnWedges++) {
72  int id = sensorsOnWedges->Id;
73  TGeoHMatrix *comb = (TGeoHMatrix *) mgRotList->FindObject(Form("R%04i", id));
74 
75  if (comb) continue;
76 
77  comb = new TGeoHMatrix(Form("R%04i", id));
78  int wedge = (id - 1000) / kFstNumSensorsPerWedge + 1; // 1 <= wedge <= 36
79  int sensor = (id - 1000) % kFstNumSensorsPerWedge; // 0 <= sensor <= 2
80  cout<<"id"<<id<<" "<<"wedge"<<wedge<<"sensor"<<sensor<<endl;
81 
82  if (wedge <= 0 || wedge > kFstNumWedges) {
83  LOG_WARN << "Wedge ID is out of range (1 - 36)!" << endm;
84  continue;
85  }
86 
87  if (sensor < 0 || sensor >= kFstNumSensorsPerWedge) {
88  LOG_WARN << "Sensor ID is out of range (0 - 2)!" << endm;
89  continue;
90  }
91 
92  //setting rotation/translation for sensor geometry matrix
93  mGeoHMatrixSensorOnWedge[wedge - 1][sensor].SetName(Form("sensorOnWedge%4i%4i", wedge, sensor));
94  mGeoHMatrixSensorOnWedge[wedge - 1][sensor].SetRotation(&sensorsOnWedges->r00);
95  mGeoHMatrixSensorOnWedge[wedge - 1][sensor].SetTranslation(&sensorsOnWedges->t0);
96 
97  TGeoHMatrix *sensorLocal = (TGeoHMatrix *) mgRotList->FindObject(Form("sensorLocal%04i", id));
98 
99  if (!sensorLocal) {
100  sensorLocal = new TGeoHMatrix(Form("sensorLocal%04i", id));
101  sensorLocal->SetRotation(mGeoHMatrixSensorOnWedge[wedge - 1][sensor].GetRotationMatrix());
102  sensorLocal->SetTranslation(mGeoHMatrixSensorOnWedge[wedge - 1][sensor].GetTranslation());
103  mgRotList->Add(sensorLocal);
104  }
105 
106  //calculate sensor global position
107  TGeoHMatrix sensorGlobal = (*mGeoHMatrixTpcOnGlobal) * mGeoHMatrixFstOnTpc * mGeoHMatrixHssOnFst * mGeoHMatrixWedgeOnHss * mGeoHMatrixSensorOnWedge[wedge - 1][sensor];
108 
109  comb->SetRotation(sensorGlobal.GetRotationMatrix());
110  comb->SetTranslation(sensorGlobal.GetTranslation());
111  mgRotList->Add(comb);
112  }
113 
114  return kStOk;
115 }
116 
117 
123 const TGeoHMatrix *StFstDb::getHMatrixSensorOnGlobal(int wedge, int sensor)
124 {
125  if (wedge < 1 || wedge > kFstNumWedges || sensor < 0 || sensor >= kFstNumSensorsPerWedge)
126  return 0;
127 
128  int id = 1000 + (wedge - 1) * kFstNumSensorsPerWedge + sensor;
129  return mgRotList ? (const TGeoHMatrix *) mgRotList->FindObject(Form("R%04i", id)) : 0;
130 }
131 
132 
133 void StFstDb::Print(Option_t *opt) const
134 {
135  mGeoHMatrixTpcOnGlobal->Print();
136  mGeoHMatrixFstOnTpc.Print();
137  mGeoHMatrixHssOnFst.Print();
138  mGeoHMatrixWedgeOnHss.Print();
139 
140  for (Int_t iL = 0; iL < kFstNumWedges; iL++) {
141  for (Int_t iS = 0; iS < kFstNumSensorsPerWedge; iS++) {
142  mGeoHMatrixSensorOnWedge[iL][iS].Print();
143  }
144  }
145 
146  for (Int_t iS = 0; iS < kFstNumSensors; iS++) {
147  TGeoHMatrix *sensorOnGlobal = (TGeoHMatrix *) mgRotList->FindObject(Form("R%04i", iS + 1000));
148  sensorOnGlobal->Print();
149  }
150 }
static const TGeoHMatrix * getHMatrixSensorOnGlobal(int wedge, int sensor)
Definition: StFstDb.cxx:123
Definition: Stypes.h:41