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