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