7 if (gClassTable->GetID(
"StDbManager") < 0) {
9 gSystem->Load(
"St_base");
10 gSystem->Load(
"StChain");
11 gSystem->Load(
"StUtilities");
16 gSystem->Load(
"St_Tables.so");
17 gSystem->Load(
"StDbLib.so");
18 gSystem->Load(
"StDbBroker.so");
19 gSystem->Load(
"St_db_Maker.so");
21 dbMk =
new St_db_Maker(
"db",
"$STAR/StarDb",
"$PWD/StarDb");
25 dbMk->SetFlavor(
"simu",
"svtWafersPosition");
32 void MakeSvtWaferOnGlobal(Int_t date = 20050101, Int_t time = 65 ){
33 TGeoHMatrix GL, WL,LSU,LSH,SHG,WG;
34 if (dbMk == 0) Load();
36 dbMk->SetDateTime(date,time);
40 TDataSet *set = dbMk->GetDataBase(
"Geometry/ssd");
42 St_Survey *SsdOnGlobal = (St_Survey *) set->
Find(
"SsdOnGlobal");
43 if (! SsdOnGlobal) {cout <<
"SsdOnGlobal has not been found" << endl;
return;}
44 Survey_st *OnGlobal = SsdOnGlobal->GetTable();
45 GL.SetRotation(&OnGlobal->r00);
46 GL.SetTranslation(&OnGlobal->t0);
47 set = dbMk->GetDataBase(
"Geometry/svt");
48 St_Survey *WaferOnLadder = (St_Survey *) set->
Find(
"WaferOnLadder");
49 St_Survey *LadderOnSurvey = (St_Survey *) set->
Find(
"LadderOnSurvey");
50 St_Survey *LadderOnShell = (St_Survey *) set->
Find(
"LadderOnShell");
51 St_Survey *ShellOnGlobal = (St_Survey *) set->
Find(
"ShellOnGlobal");
52 Int_t NW = WaferOnLadder->GetNRows();
53 Int_t NL = LadderOnSurvey->GetNRows();
54 Survey_st *waferOnLadder = WaferOnLadder->GetTable();
55 Survey_st *ladderOnSurvey = LadderOnSurvey->GetTable();
56 Survey_st *ladderOnShell = LadderOnShell->GetTable();
57 Survey_st *shellOnGlobal0 = ShellOnGlobal->GetTable(0);
58 Survey_st *shellOnGlobal1 = ShellOnGlobal->GetTable(1);
59 St_svtWafersPosition *svtwafer =
new St_svtWafersPosition(
"svtWafersPosition",216);
60 svtWafersPosition_st row;
61 for (Int_t i = 0; i < NW; i++, waferOnLadder++)
63 Int_t Idw = waferOnLadder->Id;
64 WL.SetRotation(&waferOnLadder->r00);
65 WL.SetTranslation(&waferOnLadder->t0);
68 Int_t wbarrel = Idw/1000;
69 Int_t wwafer = (Idw - 1000*wbarrel)/100;
70 Int_t wladder = Idw%100;
71 Int_t wlayer = 2*wbarrel + wladder%2 - 1;
73 for ( Int_t j = 0; j < NL; j++, ladderOnSurvey++, ladderOnShell++)
75 Int_t Idl = ladderOnSurvey->Id;
76 Int_t lbarrel = Idl/1000;
77 Int_t lladder = Idl%100;
78 if( wladder == lladder )
80 LSU.SetRotation(&ladderOnSurvey->r00);
81 LSU.SetTranslation(&ladderOnSurvey->t0);
82 LSH.SetRotation(&ladderOnShell->r00);
83 LSH.SetTranslation(&ladderOnShell->t0);
84 if( (wbarrel == 1 && wladder <= 4) || (wbarrel == 2 && wladder <= 6) || (wbarrel == 3 && wladder <= 8) )
86 SHG.SetRotation(&shellOnGlobal0->r00);
87 SHG.SetTranslation(&shellOnGlobal0->t0);
90 SHG.SetRotation(&shellOnGlobal1->r00);
91 SHG.SetTranslation(&shellOnGlobal1->t0);
94 WG = GL * SHG * LSH * LSU * WL;
96 Double_t *r = WG.GetRotationMatrix();
98 for (
int l = 0; l < 9; l++) {
99 if (TMath::Abs(r[l]) >= 1.000001) fail++;
102 cout <<
"===============" << waferOnLadder->Id <<
" "<< Idw <<
" " << 100*wwafer + wladder + 1000*wlayer <<endl;
103 cout <<
"WG\t"; WG.Print();
109 row.driftDirection[0] = r[0]; row.normalDirection[0] = r[1]; row.transverseDirection[0] = r[2];
110 row.driftDirection[1] = r[3]; row.normalDirection[1] = r[4]; row.transverseDirection[1] = r[5];
111 row.driftDirection[2] = r[6]; row.normalDirection[2] = r[7]; row.transverseDirection[2] = r[8];
113 TVector3 d(row.driftDirection); norm = 1/d.Mag(); d *= norm;
114 TVector3 t(row.transverseDirection); norm = 1/t.Mag(); t *= norm;
115 TVector3 n(row.normalDirection);
116 TVector3 c = d.Cross(t);
117 if (c.Dot(n) < 0) c *= -1;
118 d.GetXYZ(row.driftDirection);
119 t.GetXYZ(row.transverseDirection);
120 c.GetXYZ(row.normalDirection);
122 row.ID = 100*wwafer + wladder + 1000*wlayer;
123 Double_t *wgtr = WG.GetTranslation();
124 memcpy(row.centerPosition,wgtr, 3*
sizeof(Double_t));
125 svtwafer->AddAt(&row);
132 out.open(Form(
"svtWafersPosition.%8i.%06i.C",date,time));
133 svtwafer->SavePrimitive(out,
"");
virtual TDataSet * Find(const char *path) const