]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/scripts/Wafer.C
Added AliMpStringObjMap, AliMpDEIterator, AliMpDEManager, AliMpSegFactory
[u/mrichter/AliRoot.git] / FMD / scripts / Wafer.C
CommitLineData
d389af40 1//
a1f80595 2// $Id$
3//
d389af40 4// Small script that I used to make some intial testing of the wafer
5// layout and geometry.
6//
7// Christian
8//
9TObjArray*
10WaferParameters(const char c)
11{
12 double dl;
13 double dh;
14 double r = 134 / 2;
15 double theta;
16 switch (c) {
17 case 'i':
18 dl = 43;
19 dh = 172;
20 theta = 18;
21 break;
22 case 'o':
23 dl = 156;
24 dh = 280;
25 theta = 9;
26 break;
27 default:
28 cerr << "Unknown wafer type: " << c << endl;
29 return;
30 }
31
32
33 double tan_theta = tan(theta * TMath::Pi() / 180.);
34 double tan_theta2 = pow(tan_theta,2);
35 double r2 = pow(r,2);
36 double y_A = tan_theta * dl;
37 double x_D = dl + sqrt(r2 - tan_theta2 * pow(dl,2));
38 double x_D_2 = dl - sqrt(r2 - tan_theta2 * pow(dl,2));
39
40 double y_B = sqrt(r2 - pow(dh,2) + 2 * dh * x_D - pow(x_D,2));
41 double x_C = (x_D + sqrt(-tan_theta2 * pow(x_D,2) + r2
42 + r2 * tan_theta2)) / (1 + tan_theta2);
43 double y_C = tan_theta * x_C;
44
45 cout << "A: (" << dl << "," << y_A << ")" << endl;
46 cout << "B: (" << dh << "," << y_B << ")" << endl;
47 cout << "C: (" << x_C << "," << y_C << ")" << endl;
48 cout << "D: (" << x_D << ",0)" << endl;
49
50 cout << "Recentred at D:" << endl;
51 cout << "A: (" << dl - x_D << "," << y_A << ")" << endl;
52 cout << "B: (" << dh - x_D << "," << y_B << ")" << endl;
53 cout << "C: (" << x_C - x_D << "," << y_C << ")" << endl;
54
55 TObjArray* verticies = new TObjArray(6);
56 verticies->AddAt(new TVector2(dl, y_A), 0);
57 verticies->AddAt(new TVector2(x_C, y_C), 1);
58 verticies->AddAt(new TVector2(dh, y_B), 2);
59 verticies->AddAt(new TVector2(dh, -y_B), 3);
60 verticies->AddAt(new TVector2(x_C, -y_C), 4);
61 verticies->AddAt(new TVector2(dl, -y_A), 5);
62
63 return verticies;
64}
65
66void
67Wafer()
68{
69 TCanvas* can = new TCanvas("can", "c", 400, 600);
70 can->SetBorderMode(0);
71 can->SetFillColor(0);
72
73 TGeometry* g = new TGeometry("g", "G");
74 TShape* topShape = new TBRIK("top", "top", "", 100, 100, 100);
75 TNode* topNode = new TNode("top", "top", "top", 0, 0, 0);
76 topNode->SetLineWidth(0);
77 topNode->SetVisibility(0);
78
79 TShape* virtualShape = new TTUBS("virtual", "Virtual", "",
80 43, 172, 1, -18, 18);
81
82 TObjArray* v = WaferParameters('i');
83 TXTRU* moduleShape = new TXTRU("module", "module", "", 6, 2);
84 for (Int_t i = 0; i < 6; i++) {
85 TVector2* vv = static_cast<TVector2*>(v->At(i));
86 moduleShape->DefineVertex(i, vv->X(), vv->Y());
87 }
88 moduleShape->DefineSection(0, -1, 1, 0, 0);
89 moduleShape->DefineSection(1, 1, 1, 0, 0);
90
91 for (Int_t i = 0; i < 10; i++) {
92 topNode->cd();
93 Double_t theta = 36 * i;
94 Double_t z = (i % 2 ? +5 : -5);
95 TRotMatrix* rot = new TRotMatrix(Form("rotation%02d", i), "Rotation",
96 90, theta, 90,
97 fmod(90 + theta, 360), 0, 0);
98 TNode* moduleNode = new TNode(Form("module%02d", i),
99 "Module", moduleShape, 0, 0, z,
100 rot);
101 if (i == 0) {
102 moduleNode->SetFillColor(2);
103 moduleNode->SetLineColor(2);
104 moduleNode->SetLineWidth(2);
105 }
106 }
107 g->Draw();
108 TView* view = can->GetView();
109 view->SetPerspective();
110 Int_t a;
111 view->SetView(1.81208, 66.6725, 90, a);
112 view->Zoom();
113 view->Zoom();
114 view->Zoom();
115 can->Modified();
116 can->cd();
117
118 can->Print("fmd_module1.gif");
119 // std::cout << "Waiting ..." << std::flush;
120 // Char_t c = std::cin.get();
121
122 topNode->cd();
123 TNode* virtualNode = new TNode("virtual", "Virtual",
124 virtualShape, 0, 0, -5);
125 virtualNode->SetLineColor(3);
126 virtualNode->SetLineWidth(2);
127 virtualNode->SetLineStyle(2);
128 g->Draw();
129 view->SetPerspective();
130 view->SetView(1.81208, 66.6725, 90, a);
131 view->Zoom();
132 view->Zoom();
133 view->Zoom();
134 can->Modified();
135 can->cd();
136 can->Print("fmd_module2.gif");
137
138}
a1f80595 139//____________________________________________________________________
140//
141// EOF
142//
d389af40 143
144
145
146
147
148