scripts/SimpleGeometry.C

Go to the documentation of this file.
00001 //____________________________________________________________________
00002 //
00003 //
00004 // $Id: SimpleGeometry.C,v 1.2 2005/12/06 20:56:06 cholm Exp $
00005 //
00006 // Script I used for rapid prototyping of the FMD3 geometry - in
00007 // particular the support cone 
00008 //
00021 //____________________________________________________________________
00022 TObjArray*
00023 waferParameters(double dl, double dh, double theta, double r, 
00024                 Bool_t verbose=kFALSE)
00025 {      
00026   double tan_theta  = tan(theta * TMath::Pi() / 180.);
00027   double tan_theta2 = pow(tan_theta,2);
00028   double r2         = pow(r,2);
00029   double y_A        = tan_theta * dl;
00030   double x_D        = dl + sqrt(r2 - tan_theta2 * pow(dl,2));
00031   double x_D_2      = dl - sqrt(r2 - tan_theta2 * pow(dl,2));
00032   
00033   double y_B       = sqrt(r2 - pow(dh,2) + 2 * dh * x_D - pow(x_D,2));
00034   double x_C       = (x_D + sqrt(-tan_theta2 * pow(x_D,2) + r2 
00035                                  + r2 * tan_theta2)) / (1 + tan_theta2);
00036   double y_C       = tan_theta * x_C;
00037 
00038   if (verbose) {
00039     cout << "A: (" << dl << "," << y_A << ")" << endl;
00040     cout << "B: (" << dh << "," << y_B << ")" << endl;
00041     cout << "C: (" << x_C << "," << y_C << ")" << endl;
00042     cout << "D: (" << x_D << ",0)" << endl;
00043     
00044     cout << "Recentred at D:"  << endl;
00045     cout << "A: (" << dl - x_D  << "," << y_A << ")" << endl;
00046     cout << "B: (" << dh - x_D  << "," << y_B << ")" << endl;
00047     cout << "C: (" << x_C - x_D << "," << y_C << ")" << endl;
00048   }
00049   
00050   TObjArray* verticies = new TObjArray(6);
00051   verticies->AddAt(new TVector2(dl,   y_A), 0);
00052   verticies->AddAt(new TVector2(x_C,  y_C), 1);
00053   verticies->AddAt(new TVector2(dh,   y_B), 2);
00054   verticies->AddAt(new TVector2(dh,  -y_B), 3);
00055   verticies->AddAt(new TVector2(x_C, -y_C), 4);
00056   verticies->AddAt(new TVector2(dl,  -y_A), 5);
00057   
00058   return verticies;
00059 }
00060 
00070 //____________________________________________________________________
00071 TShape* 
00072 createModuleShape(const Char_t* name, double rl, double rh, double th, 
00073                   double r, double dz) 
00074 {
00075   std::cout << "Creating Module shape for " << name << std::flush;
00076   // TShape* virtualShape = new TTUBS(Form("%sVirtual", name), 
00077   //                                  Form("Virtual %s", name), 
00078   //                                  "", rl, rh, 1, -th, th);
00079   
00080   TObjArray* v = waferParameters(rl, rh, th, r);
00081   TXTRU* moduleShape = new TXTRU(Form("%sModule", name),
00082                                  Form("Module %s", name), 
00083                                  "", 6, 2);
00084   for (Int_t i = 0; i  < 6; i++) {
00085     std::cout << "." << std::flush;
00086     TVector2* vv = static_cast<TVector2*>(v->At(i));
00087     moduleShape->DefineVertex(i, vv->X(), vv->Y());
00088   }
00089   moduleShape->DefineSection(0, -dz, 1, 0, 0);
00090   moduleShape->DefineSection(1,  dz, 1, 0, 0);
00091   std::cout << std::endl;
00092 
00093   return (TShape*)moduleShape;
00094 }
00095 
00108 //____________________________________________________________________
00109 TNode* 
00110 createRing(const char* name, double rl, double rh, double th, 
00111            double siThick, double waferR, double staggering, double z) 
00112 {
00113   std::cout << "Creating Ring node for " << name << std::flush;
00114   TShape* ringShape   = new TTUBE(Form("%sShape", name), "Ring Shape", 
00115                                   "", rl, rh, staggering + siThick);
00116   TNode*  ringNode    = new TNode(Form("%sNode", name), "Ring Node", 
00117                                   ringShape, 0, 0, z, 0);
00118   TShape* moduleShape = createModuleShape(name, rl, rh, th, waferR, siThick);
00119   Int_t n = 360 / 2 / th;
00120   for (Int_t i = 0; i < n; i++) {
00121     std::cout << "." << std::flush;
00122     ringNode->cd();
00123     Double_t theta = 2  * th * i;
00124     Double_t z     = (i % 2 ? 0 : staggering);
00125     TRotMatrix* rot = new TRotMatrix(Form("%sRotation%02d", name, i), 
00126                                      "Rotation", 90, theta, 90, 
00127                                      fmod(90 + theta, 360), 0, 0);
00128     TNode* moduleNode = new TNode(Form("%sModule%02d", name, i), 
00129                                   "Module", moduleShape, 0, 0, z,
00130                                   rot);
00131     moduleNode->SetFillColor(5);
00132     moduleNode->SetLineColor(5);
00133     moduleNode->SetLineWidth(2);
00134   }
00135   std::cout << std::endl;
00136   ringNode->SetVisibility(0);
00137   return ringNode;
00138 }
00139 
00140 //____________________________________________________________________
00156 TNode*
00157 createSupport(double noseRl, double noseRh, double noseDz, double noseZ, 
00158               double backRl, double backRh, double backDz, double coneL, 
00159               double beamW, double beamDz,  double flangeR) 
00160 {
00161   TShape* noseShape = new TTUBE("noseShape", "Nose Shape", "", 
00162                                 noseRl, noseRh, noseDz);
00163   TNode*  noseNode  = new TNode("noseNode", "noseNode", noseShape, 
00164                                 0, 0, noseZ - noseDz, 0);
00165   noseNode->SetLineColor(0);
00166   
00167   Double_t zdist = coneL - 2 * backDz - 2 * noseDz;
00168   Double_t tdist = backRh - noseRh;
00169   Double_t beamL = TMath::Sqrt(zdist * zdist + tdist * tdist);
00170   Double_t theta = -TMath::ATan2(tdist, zdist);
00171   
00172 
00173   TShape* backShape = new TTUBE("backShape", "Back Shape", "", 
00174                                  backRl, backRh, backDz);
00175   TNode*  backNode  = new TNode("backNode", "backNode", backShape, 
00176                                 0, 0, noseZ - 2 * noseDz - zdist - backDz, 0);
00177   backNode->SetLineColor(0);
00178 
00179 
00180   TShape* beamShape = new TBRIK("beamShape", "beamShape", "", 
00181                                 beamDz, beamW / 2 , beamL / 2);
00182   Int_t    n = 8;
00183   Double_t r = noseRl + tdist / 2;
00184   for (Int_t i = 0; i < n; i++) {
00185     Double_t phi   = 360. / n * i;
00186     Double_t t     = 180. * theta / TMath::Pi();
00187     TRotMatrix* beamRotation = new TRotMatrix(Form("beamRotation%d", i), 
00188                                                 Form("beamRotation%d", i),
00189                                                 180-t, phi, 90, 90+phi, 
00190                                                 t, phi);
00191     TNode* beamNode = new TNode(Form("beamNode%d", i), 
00192                                 Form("beamNode%d", i), beamShape, 
00193                                 r * TMath::Cos(phi / 180 * TMath::Pi()), 
00194                                 r * TMath::Sin(phi / 180 * TMath::Pi()), 
00195                                 noseZ - 2 * noseDz - zdist / 2,  beamRotation);
00196     beamNode->SetLineColor(0);
00197   }
00198   
00199   Double_t flangel = (flangeR - backRh) / 2;
00200   TShape* flangeShape = new TBRIK("flangeShape", "FlangeShape", "", 
00201                                   flangel, beamW / 2, backDz);
00202   n = 4;
00203   r = backRh + flangel;
00204   for (Int_t i = 0; i < n; i++) {
00205     Double_t phi = 360. / n * i + 180. / n;
00206     TRotMatrix* flangeRotation = new TRotMatrix(Form("flangeRotation%d", i),
00207                                                 Form("Flange Rotation %d", i),
00208                                                 90, phi, 90, 90+phi, 0, 0);
00209     TNode* flangeNode = new TNode(Form("flangeNode%d", i), 
00210                                   Form("flangeNode%d", i), 
00211                                   flangeShape,
00212                                   r * TMath::Cos(phi / 180 * TMath::Pi()), 
00213                                   r * TMath::Sin(phi / 180 * TMath::Pi()),
00214                                   noseZ - 2 * noseDz - zdist - backDz, 
00215                                   flangeRotation);
00216     flangeNode->SetLineColor(0);
00217                                   
00218   }
00219   return 0;
00220 }
00221 
00222                                  
00223 
00224 
00225 //____________________________________________________________________
00229 void
00230 SimpleGeometry() 
00231 {
00232   TGeometry* geometry = new TGeometry("geometry","geometry");
00233   TShape* topShape = new TBRIK("topShape", "topShape", "", 40, 40, 150);
00234   TNode* topNode = new TNode("topNode", "topNode", topShape, 0, 0, 0, 0);
00235   topNode->SetVisibility(0);
00236   topNode->cd();
00237   
00238   Double_t waferR     = 13.4 / 2;
00239   Double_t siThick    = .03;
00240   Double_t staggering = 1;
00241   Double_t innerRh    = 17.2;
00242   Double_t innerRl    = 4.3;
00243   Double_t innerTh    = 18;
00244   Double_t innerZ     = -62.8;
00245   Double_t outerRh    = 28;
00246   Double_t outerRl    = 15.6;
00247   Double_t outerTh    = 9;
00248   Double_t outerZ     = -75.2;
00249   Double_t noseRl     = 5.5;
00250   Double_t noseRh     = 6.7;
00251   Double_t noseDz     = 2.8 / 2;
00252   Double_t noseZ      = -46;
00253   Double_t coneL      = 30.9;
00254   Double_t backRl     = 61 / 2;
00255   Double_t backRh     = 66.8 /2;
00256   Double_t backDz     = 1.4 / 2;
00257   Double_t beamDz     = .5 / 2;
00258   Double_t beamW      = 6;
00259   Double_t flangeR    = 49.25;
00260 
00261   Double_t zdist      = coneL - 2 * backDz - 2 * noseDz;
00262   Double_t tdist      = backRh - noseRh;
00263   Double_t alpha      = tdist / zdist;
00264 
00265   Double_t x, rl, rh, z;
00266   z  = noseZ - coneL / 2;
00267   TPCON* fmd3Shape = new TPCON("fmd3Shape", "FMD 3 Shape", "", 0, 360, 7);
00268   
00269   x  = noseZ;
00270   rl = noseRl;
00271   rh = noseRh;
00272   fmd3Shape->DefineSection(0, x - z, rl, rh);
00273 
00274   x  = noseZ-2*noseDz;
00275   fmd3Shape->DefineSection(1, x - z, rl, rh);
00276 
00277   x  = innerZ - staggering - siThick; 
00278   rl = innerRl;
00279   rh = noseRh + alpha * TMath::Abs(x-noseZ + 2 * noseDz);
00280   fmd3Shape->DefineSection(2, x - z, rl, rh);
00281 
00282   x  = outerZ;
00283   rl = outerRl;
00284   rh = backRh;
00285   fmd3Shape->DefineSection(3, x - z, rl, rh);
00286 
00287   x  = noseZ - zdist - 2 * noseDz;
00288   rl = outerRl;
00289   rh = backRh;
00290   fmd3Shape->DefineSection(4, x - z, rl, rh);
00291 
00292   x  = noseZ - zdist - 2 * noseDz;
00293   rl = outerRl;
00294   rh = flangeR;
00295   fmd3Shape->DefineSection(5, x - z, rl, rh);
00296 
00297   x  = noseZ - coneL;
00298   rl = outerRl;
00299   rh = flangeR;
00300   fmd3Shape->DefineSection(6, x - z, rl, rh);
00301 
00302   TNode* fmd3Node = new TNode("fmd3Node", "FMD3 Node", fmd3Shape, 
00303                               0, 0, z, 0);
00304   fmd3Node->SetLineColor(3);
00305   fmd3Node->SetVisibility(1);
00306 
00307   fmd3Node->cd();
00308   TNode* innerNode = createRing("inner", innerRl, innerRh, innerTh, 
00309                                 siThick, waferR, staggering, innerZ-z);
00310 
00311 
00312   fmd3Node->cd();
00313   TNode* outerNode = createRing("outer", outerRl, outerRh, outerTh, 
00314                                 siThick, waferR, staggering, outerZ-z);
00315   
00316 
00317   fmd3Node->cd();
00318   TNode* supportNode = createSupport(noseRl, noseRh, noseDz, noseZ-z, 
00319                                      backRl, backRh, backDz, coneL,
00320                                      beamW, beamDz, flangeR);
00321   
00322   TCanvas* c = new TCanvas("c", "c", 800, 800);
00323   c->SetFillColor(1);
00324   geometry->Draw();
00325   // c->x3d("ogl");
00326 }
00327 //____________________________________________________________________
00328 //
00329 // EOF
00330 //

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