7 if (gClassTable->GetID(
"StDbManager") < 0) {
10 gSystem->Load(
"St_base");
11 gSystem->Load(
"StChain");
12 gSystem->Load(
"StUtilities");
17 gSystem->Load(
"libmysqlclient");
18 gSystem->Load(
"St_Tables.so");
19 gSystem->Load(
"StDbLib.so");
20 gSystem->Load(
"StDbBroker.so");
21 gSystem->Load(
"St_db_Maker.so");
23 dbMk =
new St_db_Maker(
"db",
"$STAR/StarDb",
"$PWD/StarDb");
34 void MakeSsdWaferOnGlobal(Int_t date = 20050316, Int_t time = 195612){
35 if (dbMk == 0) Load();
37 dbMk->SetDateTime(date,time);
41 TDataSet *set = dbMk->GetDataBase(
"Geometry/ssd");
43 St_Survey *SsdOnGlobal = (St_Survey *) set->
Find(
"SsdOnGlobal");
44 if (! SsdOnGlobal) {cout <<
"SsdOnGlobal has not been found" << endl;
return;}
45 St_Survey *SsdSectorsOnGlobal = (St_Survey *) set->
Find(
"SsdSectorsOnGlobal");
46 if (! SsdSectorsOnGlobal) {cout <<
"SsdSectorsOnGlobal has not been found" << endl;
return;}
47 St_Survey *SsdLaddersOnSectors = (St_Survey *) set->
Find(
"SsdLaddersOnSectors");
48 if (! SsdLaddersOnSectors) {cout <<
"SsdLaddersOnSectors has not been found" << endl;
return;}
49 St_Survey *SsdWafersOnLadders = (St_Survey *) set->
Find(
"SsdWafersOnLadders");
51 if (! SsdWafersOnLadders) {cout <<
"SsdWafersOnLadders has not been found" << endl;
return;}
52 St_ssdWafersPosition *ssdWafersPosition = (St_ssdWafersPosition *) set->
Find(
"ssdWafersPosition");
53 if (! ssdWafersPosition) {cout <<
"ssdWafersPosition has not been found" << endl;
return;}
54 Survey_st *OnGlobal = SsdOnGlobal->GetTable();
55 Survey_st *SectorsOnGlobal = SsdSectorsOnGlobal->GetTable();
56 Survey_st *LaddersOnSectors = SsdLaddersOnSectors->GetTable();
57 Survey_st *WafersOnLadders = SsdWafersOnLadders->GetTable();
58 ssdWafersPosition_st *WafersPosition = ssdWafersPosition->GetTable();
59 Int_t NoSectors = SsdSectorsOnGlobal->GetNRows();
60 Int_t NoLadders = SsdLaddersOnSectors->GetNRows();
61 Int_t NoWafers = ssdWafersPosition->GetNRows();
62 St_ssdWafersPosition *ssdwafer =
new St_ssdWafersPosition(
"ssdWafersPosition",NoWafers);
63 TGeoHMatrix GL, WL,LS,SG,LA,WG;
64 GL.SetRotation(&OnGlobal->r00);
65 GL.SetTranslation(&OnGlobal->t0);
68 for (Int_t w = 0; w < NoWafers; w++, WafersPosition++) {
69 ssdWafersPosition_st row = *WafersPosition;
70 WafersOnLadders = SsdWafersOnLadders->GetTable();
72 for (Int_t i = 0; i < NoWafers; i++,WafersOnLadders++) {
73 if (WafersOnLadders->Id != row.id)
continue;
77 if (! Id ) {cout <<
"Wafer Id\t" << Id <<
" has not been found" << endl;}
78 Int_t layer = Id/1000;
79 if (layer > 7) layer = 7;
80 Int_t wafer = (Id - 1000*layer)/100;
81 Int_t ladder = Id%100;
83 WL.SetRotation(&WafersOnLadders->r00);
84 WL.SetTranslation(&WafersOnLadders->t0);
85 LaddersOnSectors = SsdLaddersOnSectors->GetTable();
88 for (Int_t l = 0; l < NoLadders; l++, LaddersOnSectors++) {
90 Ladder = LaddersOnSectors->Id%100;
91 if (Ladder == ladder) {
92 Sector = LaddersOnSectors->Id/100;
93 LS.SetRotation(&LaddersOnSectors->r00);
94 LS.SetTranslation(&LaddersOnSectors->t0);
99 if (Sector <= 0 || Sector > 4) {cout <<
"Sector has not been defined" << endl;
continue;}
100 SectorsOnGlobal = SsdSectorsOnGlobal->GetTable();
102 for (Int_t s = 0; s <NoSectors; s++, SectorsOnGlobal++) {
104 if (SectorsOnGlobal->Id != Sector)
continue;
106 SG.SetRotation(&SectorsOnGlobal->r00);
107 SG.SetTranslation(&SectorsOnGlobal->t0);
110 if (! sector) {cout <<
"Sector\t" << Sector <<
" has not been found" << endl;
continue;}
113 WG = GL * SG * LS * WL;
114 ssdWafersPosition_st row;
120 row.num_chip = (num-1)%16 + 1;
123 Double_t *r = WG.GetRotationMatrix();
124 row.driftDirection[0] = r[0]; row.normalDirection[0] = r[1]; row.transverseDirection[0] = r[2];
125 row.driftDirection[1] = r[3]; row.normalDirection[1] = r[4]; row.transverseDirection[1] = r[5];
126 row.driftDirection[2] = r[6]; row.normalDirection[2] = r[7]; row.transverseDirection[2] = r[8];
128 TVector3 d(row.driftDirection); norm = 1/d.Mag(); d *= norm;
129 TVector3 t(row.transverseDirection); norm = 1/t.Mag(); t *= norm;
130 TVector3 n(row.normalDirection);
131 TVector3 c = d.Cross(t);
132 if (c.Dot(n) < 0) c *= -1;
133 d.GetXYZ(row.driftDirection);
134 t.GetXYZ(row.transverseDirection);
135 c.GetXYZ(row.normalDirection);
137 Double_t *wgtr = WG.GetTranslation();
139 memcpy(row.centerPosition,wgtr, 3*
sizeof(Double_t));
140 ssdwafer->AddAt(&row);
142 cout <<
"Create " << Form(
"ssdWafersPosition.%8i.%06i.C",date,time) << endl;
144 out.open(Form(
"ssdWafersPosition.%8i.%06i.C",date,time));
145 ssdwafer->SavePrimitive(out,
"");
virtual TDataSet * Find(const char *path) const