1 //____________________________________________________________________
5 // Small script that I used to make some intial testing of the wafer
6 // layout and geometry.
10 /** Calculate wafer parameters
13 @ingroup simple_script
16 WaferParameters(const char c)
34 cerr << "Unknown wafer type: " << c << endl;
39 double tan_theta = tan(theta * TMath::Pi() / 180.);
40 double tan_theta2 = pow(tan_theta,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));
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;
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;
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;
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);
73 @ingroup simple_script
78 TCanvas* can = new TCanvas("can", "c", 400, 600);
79 can->SetBorderMode(0);
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);
88 TShape* virtualShape = new TTUBS("virtual", "Virtual", "",
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());
97 moduleShape->DefineSection(0, -1, 1, 0, 0);
98 moduleShape->DefineSection(1, 1, 1, 0, 0);
100 for (Int_t i = 0; i < 10; i++) {
102 Double_t theta = 36 * i;
103 Double_t z = (i % 2 ? +5 : -5);
104 TRotMatrix* rot = new TRotMatrix(Form("rotation%02d", i), "Rotation",
106 fmod(90 + theta, 360), 0, 0);
107 TNode* moduleNode = new TNode(Form("module%02d", i),
108 "Module", moduleShape, 0, 0, z,
111 moduleNode->SetFillColor(2);
112 moduleNode->SetLineColor(2);
113 moduleNode->SetLineWidth(2);
117 TView* view = can->GetView();
118 view->SetPerspective();
120 view->SetView(1.81208, 66.6725, 90, a);
127 can->Print("fmd_module1.gif");
128 // std::cout << "Waiting ..." << std::flush;
129 // Char_t c = std::cin.get();
132 TNode* virtualNode = new TNode("virtual", "Virtual",
133 virtualShape, 0, 0, -5);
134 virtualNode->SetLineColor(3);
135 virtualNode->SetLineWidth(2);
136 virtualNode->SetLineStyle(2);
138 view->SetPerspective();
139 view->SetView(1.81208, 66.6725, 90, a);
145 can->Print("fmd_module2.gif");
148 //____________________________________________________________________