scripts/Wafer.C

Go to the documentation of this file.
00001 //____________________________________________________________________
00002 //
00003 // $Id: Wafer.C,v 1.3 2006/03/17 11:42:24 cholm Exp $
00004 //
00005 // Small script that I used to make some intial testing of the wafer
00006 // layout and geometry. 
00007 //
00008 // Christian 
00009 // 
00015 TObjArray*
00016 WaferParameters(const char c)
00017 {      
00018   double dl;
00019   double dh;
00020   double r     = 134 / 2;
00021   double theta;
00022   switch (c) {
00023   case 'i': 
00024     dl     = 43;
00025     dh     = 172;
00026     theta  = 18;
00027     break;
00028   case 'o':
00029     dl     = 156;
00030     dh     = 280;
00031     theta  = 9;
00032     break;
00033   default:
00034     cerr << "Unknown wafer type: " << c << endl;
00035     return;
00036   }
00037   
00038 
00039   double tan_theta  = tan(theta * TMath::Pi() / 180.);
00040   double tan_theta2 = pow(tan_theta,2);
00041   double r2         = pow(r,2);
00042   double y_A        = tan_theta * dl;
00043   double x_D        = dl + sqrt(r2 - tan_theta2 * pow(dl,2));
00044   double x_D_2      = dl - sqrt(r2 - tan_theta2 * pow(dl,2));
00045   
00046   double y_B       = sqrt(r2 - pow(dh,2) + 2 * dh * x_D - pow(x_D,2));
00047   double x_C       = (x_D + sqrt(-tan_theta2 * pow(x_D,2) + r2 
00048                                  + r2 * tan_theta2)) / (1 + tan_theta2);
00049   double y_C       = tan_theta * x_C;
00050 
00051   cout << "A: (" << dl << "," << y_A << ")" << endl;
00052   cout << "B: (" << dh << "," << y_B << ")" << endl;
00053   cout << "C: (" << x_C << "," << y_C << ")" << endl;
00054   cout << "D: (" << x_D << ",0)" << endl;
00055   
00056   cout << "Recentred at D:"  << endl;
00057   cout << "A: (" << dl - x_D  << "," << y_A << ")" << endl;
00058   cout << "B: (" << dh - x_D  << "," << y_B << ")" << endl;
00059   cout << "C: (" << x_C - x_D << "," << y_C << ")" << endl;
00060 
00061   TObjArray* verticies = new TObjArray(6);
00062   verticies->AddAt(new TVector2(dl,   y_A), 0);
00063   verticies->AddAt(new TVector2(x_C,  y_C), 1);
00064   verticies->AddAt(new TVector2(dh,   y_B), 2);
00065   verticies->AddAt(new TVector2(dh,  -y_B), 3);
00066   verticies->AddAt(new TVector2(x_C, -y_C), 4);
00067   verticies->AddAt(new TVector2(dl,  -y_A), 5);
00068   
00069   return verticies;
00070 }
00071 
00075 void
00076 Wafer()
00077 {
00078   TCanvas* can = new TCanvas("can", "c", 400, 600);
00079   can->SetBorderMode(0);
00080   can->SetFillColor(0);
00081   
00082   TGeometry* g = new TGeometry("g", "G");
00083   TShape* topShape  = new TBRIK("top", "top", "", 100, 100, 100);
00084   TNode*  topNode = new TNode("top", "top", "top", 0, 0, 0);
00085   topNode->SetLineWidth(0);
00086   topNode->SetVisibility(0);
00087 
00088   TShape* virtualShape = new TTUBS("virtual", "Virtual", "", 
00089                                    43, 172, 1, -18, 18);
00090   
00091   TObjArray* v = WaferParameters('i');
00092   TXTRU* moduleShape = new TXTRU("module", "module", "", 6, 2);
00093   for (Int_t i = 0; i  < 6; i++) {
00094     TVector2* vv = static_cast<TVector2*>(v->At(i));
00095     moduleShape->DefineVertex(i, vv->X(), vv->Y());
00096   }
00097   moduleShape->DefineSection(0, -1, 1, 0, 0);
00098   moduleShape->DefineSection(1,  1, 1, 0, 0);
00099 
00100   for (Int_t i = 0; i < 10; i++) {
00101     topNode->cd();
00102     Double_t theta   = 36 * i;
00103     Double_t z = (i % 2 ? +5 : -5);
00104     TRotMatrix* rot = new TRotMatrix(Form("rotation%02d", i), "Rotation", 
00105                                      90, theta, 90, 
00106                                      fmod(90 + theta, 360), 0, 0);
00107     TNode* moduleNode = new TNode(Form("module%02d", i), 
00108                                   "Module", moduleShape, 0, 0, z,
00109                                   rot);
00110     if (i == 0) {
00111       moduleNode->SetFillColor(2);
00112       moduleNode->SetLineColor(2);
00113       moduleNode->SetLineWidth(2);
00114     }
00115   }
00116   g->Draw();
00117   TView* view = can->GetView();
00118   view->SetPerspective();
00119   Int_t a;
00120   view->SetView(1.81208, 66.6725, 90, a);
00121   view->Zoom();
00122   view->Zoom();  
00123   view->Zoom();  
00124   can->Modified();
00125   can->cd();
00126 
00127   can->Print("fmd_module1.gif");
00128   // std::cout << "Waiting ..." << std::flush;
00129   // Char_t c = std::cin.get();
00130   
00131   topNode->cd();
00132   TNode* virtualNode = new TNode("virtual", "Virtual", 
00133                                  virtualShape, 0, 0, -5);
00134   virtualNode->SetLineColor(3);
00135   virtualNode->SetLineWidth(2);
00136   virtualNode->SetLineStyle(2);
00137   g->Draw();
00138   view->SetPerspective();
00139   view->SetView(1.81208, 66.6725, 90, a);
00140   view->Zoom();
00141   view->Zoom();  
00142   view->Zoom();  
00143   can->Modified();
00144   can->cd();
00145   can->Print("fmd_module2.gif");
00146   
00147 }
00148 //____________________________________________________________________
00149 //
00150 // EOF
00151 //
00152 
00153 
00154 
00155 
00156 
00157   

Generated on Fri Mar 24 17:11:21 2006 for ALICE FMD Off-line by  doxygen 1.4.6