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