1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 // General Root includes
19 //#include <Riostream.h>
23 // Root Geometry includes
24 #include <TGeoManager.h>
25 #include <TGeoVolume.h>
27 #include <TGeoTorus.h>
28 #include <TGeoMatrix.h>
30 #include "AliITSv11GeomCableRound.h"
32 //*************************************************************************
33 // Class for round cables
35 // Ludovic Gaudichet gaudichet@to.infn.it
36 //*************************************************************************
39 // ************************************************************************
40 // Here is a example on how to use this class
41 // ************************************************************************
44 TGeoMedium *air = gGeoManager->GetMedium("ITSair");
45 TGeoMedium *water = gGeoManager->GetMedium("WATER");
46 TGeoMedium *alu = gGeoManager->GetMedium("ITSal");
48 // Creating a small box inside a bigger one (containers)
49 TGeoBBox *box1 = new TGeoBBox("box1", 6,10,10);
50 TGeoBBox *bigBox = new TGeoBBox("bigBox", 20,10,10);
51 TGeoVolume *vbox1 = new TGeoVolume("vbox1", box1, air);
52 TGeoVolume *vBigBox = new TGeoVolume("vBigBox", bigBox, air);
53 vbox1->SetVisibility(kFALSE);
54 vBigBox->SetVisibility(kFALSE);
56 TGeoTranslation *tr1 = new TGeoTranslation("negTr",-14,0,0);
57 vBigBox->AddNode(vbox1, 1, tr1);
58 moth->AddNode(vBigBox, 1, 0);
60 // **************************************************
61 // Inserting a round cable (or here a water pipe...)
62 // **************************************************
66 AliITSv11GeomCableRound roundCable("waterPipe", 0.9); //radius of 0.9cm
67 roundCable.SetNLayers(2);
68 roundCable.SetLayer(0, 0.7, water, waterColor); // radius of 0.7cm
69 roundCable.SetLayer(1, 0.2, alu, aluColor); // thickness of 0.2cm
71 // ****** Set check points and their containers ******
72 // The 2 first points are in the small box (vbox1)
73 // The second point is at the boundary
75 Double_t coord0[3] = {0,-2,-2};
76 Double_t coord1[3] = {6,2,1};
77 Double_t vect0[3] = {1,1,0};
78 Double_t vect1[3] = {1,0,0};
79 // coordinates have to be given in the specified container
80 // reference system (here it's going to be vbox1).
81 // vect1 and vect2 are vectors perpendicular to the segment ends
82 // (These vectors don't need to be normalized)
83 roundCable.AddCheckPoint( vbox1, 0, coord0, vect0);
84 roundCable.AddCheckPoint( vbox1, 1, coord1, vect1);
86 // Then, let's cross the boundary ! You just need
87 // to put the next point in the other volume, vBigBox.
88 // At the moment of creating the second segment, it will
89 // be inserted in this volume. That is why the point 1 had to
90 // be at the boundary, because otherwise the second segment
91 // between de points 1 and 2 would have been inserted in the
92 // vBigBox but in the same time would have cross its
94 Double_t coord2[3] = {-2,6,4}; // coord. syst. of vBigBox !
95 Double_t vect2[3]= {1,1,0.5};
96 roundCable.AddCheckPoint( vBigBox, 2, coord2, vect2);
98 Double_t coord3[3] = {4,6,4};
99 Double_t vect3[3]= {-1,0,0};
100 roundCable.AddCheckPoint( vBigBox, 3, coord3, vect3);
102 Double_t coord4[3] = {4,0,-4};
103 Double_t vect4[3]= {1,0,0};
104 roundCable.AddCheckPoint( vBigBox, 4, coord4, vect4);
106 Double_t coord5[3] = {4,-6,4};
107 Double_t vect5[3]= {1,0,0};
108 roundCable.AddCheckPoint( vBigBox, 5, coord5, vect5);
110 Double_t coord6[3] = {7,-6,4};
111 Double_t vect6[3]= {1,0,0};
112 roundCable.AddCheckPoint( vBigBox, 6, coord6, vect6);
115 Double_t angle = 70*TMath::DegToRad();
116 Double_t coord7[3] = {coord6[0] +r*sin(angle), coord6[1],
117 coord6[2] -r*(1-cos(angle)) };
118 Double_t vect7[3]= {r*cos(angle),0,-r*sin(angle)};
119 roundCable.AddCheckPoint( vBigBox, 7, coord7, vect7);
121 Double_t coord8[3] = { coord7[0]+vect7[0], coord7[1]+vect7[1],-10};
122 Double_t vect8[3]= {0,0,1};
123 roundCable.AddCheckPoint( vBigBox, 8, coord8, vect8);
125 // ****** Creating the corresponding volume ******
126 // Since the container volumes of the check points have
127 // been recorded, this can be done at any moments, providing
128 // that the container volumes are found in the sub-nodes
129 // of the initial node (the top volume of the TGeoManager or
130 // the volume set in SetInitialNode(TGeoVolume*) function)
132 roundCable.SetInitialNode(vBigBox); //Set the root node
133 roundCable.CreateAndInsertCableSegment( 1);
134 // This command means : create the segment between point 0
135 // and point 1. The segment is automatically inserted in the
136 // container volume of point 1.
138 roundCable.CreateAndInsertCableSegment( 2);
139 roundCable.CreateAndInsertCableSegment( 3);
141 // The following segment is going to be a torus segment.
142 // The radius and position of the torus is defined by the
143 // orthogonal vector of point 4 (the orientation of this vector
144 // and the position of the 2 check points are enough to define
145 // completely the torus)
146 roundCable.CreateAndInsertTorusSegment( 4, 180);
147 // The second argument is an additionnal rotation of the
148 // segment around the axis defined by the 2 check points.
150 roundCable.CreateAndInsertTorusSegment( 5);
151 roundCable.CreateAndInsertCableSegment( 6);
152 roundCable.CreateAndInsertTorusSegment( 7,180);
153 roundCable.CreateAndInsertCableSegment( 8);
159 ClassImp(AliITSv11GeomCableRound)
161 //________________________________________________________________________
162 AliITSv11GeomCableRound::
163 AliITSv11GeomCableRound(const char* name, Double_t radius) :
164 AliITSv11GeomCable(name) {
168 for (Int_t i=0; i<fgkCableMaxLayer ; i++) {
169 fLayThickness[i] = 0;
177 //________________________________________________________________________
178 AliITSv11GeomCableRound::AliITSv11GeomCableRound(const AliITSv11GeomCableRound &s) :
179 AliITSv11GeomCable(s),fRadius(s.fRadius),fNlayer(s.fNlayer),fPhiMin(s.fPhiMin),
183 for (Int_t i=0; i<s.fNlayer; i++) {
184 fLayThickness[i] = s.fLayThickness[i];
185 fLayMedia[i] = s.fLayMedia[i];
186 fLayColor[i] = s.fLayColor[i];
190 //________________________________________________________________________
191 AliITSv11GeomCableRound& AliITSv11GeomCableRound::
192 operator=(const AliITSv11GeomCableRound &s) {
193 // Assignment operator
194 // Not fully inplemented yet !!!
196 if(&s == this) return *this;
202 for (Int_t i=0; i<s.fNlayer; i++) {
203 fLayThickness[i] = s.fLayThickness[i];
204 fLayMedia[i] = s.fLayMedia[i];
205 fLayColor[i] = s.fLayColor[i];
210 //________________________________________________________________________
211 Int_t AliITSv11GeomCableRound::GetPoint( Int_t iCheckPt, Double_t *coord)
213 // Get check point #iCheckPt
214 TVectorD *coordVector =(TVectorD *)fPointArray.UncheckedAt(2*iCheckPt);
215 #if ROOT_VERSION_CODE < ROOT_VERSION(4,0,0)
216 CopyFrom(coord, coordVector->GetElements());
218 CopyFrom(coord, coordVector->GetMatrixArray());
223 //________________________________________________________________________
224 Int_t AliITSv11GeomCableRound::GetVect( Int_t iCheckPt, Double_t *coord)
227 // Get vector transverse to the section at point #iCheckPt
230 TVectorD *coordVector =(TVectorD *)fPointArray.UncheckedAt(2*iCheckPt+1);
231 #if ROOT_VERSION_CODE < ROOT_VERSION(4,0,0)
232 CopyFrom(coord, coordVector->GetElements());
234 CopyFrom(coord, coordVector->GetMatrixArray());
239 //________________________________________________________________________
240 void AliITSv11GeomCableRound::AddCheckPoint( TGeoVolume *vol, Int_t iCheckPt,
241 Double_t *coord, Double_t *orthVect)
244 // Add point #iCheckPt and its transverse vector. Point is added at (i) in
245 // fPointArray and the vector is added at (i+1)
249 if (iCheckPt>=fVolumeArray.GetEntriesFast()) {
250 fVolumeArray.AddLast(vol);
251 TVectorD *point = new TVectorD(3,coord);
252 TVectorD *vect = new TVectorD(3,orthVect);
253 fPointArray.AddLast(point);
254 fPointArray.AddLast(vect);
256 } else if ((iCheckPt >= 0)&&(iCheckPt < fVolumeArray.GetEntriesFast())) {
257 fVolumeArray.AddAt(vol, iCheckPt);
258 TVectorD *point = new TVectorD(3,coord);
259 TVectorD *vect = new TVectorD(3,orthVect);
260 fPointArray.AddAt(point, iCheckPt*2 );
261 fPointArray.AddAt(vect, iCheckPt*2+1);
265 //________________________________________________________________________
266 void AliITSv11GeomCableRound::PrintCheckPoints() const {
267 // Print all check points
269 printf(" ---\n Printing all check points of the round cable\n");
270 for (Int_t i = 0; i<fVolumeArray.GetEntriesFast(); i++) {
271 TVectorD *coordVector = (TVectorD *)fPointArray.UncheckedAt(i*2);
272 //TVectorD *vectVector = (TVectorD *)fPointArray.UncheckedAt(i*2+1);
274 #if ROOT_VERSION_CODE < ROOT_VERSION(4,0,0)
275 CopyFrom(coord, coordVector->GetElements());
277 CopyFrom(coord, coordVector->GetMatrixArray());
279 printf(" ( %.2f, %.2f, %.2f )\n", coord[0], coord[1], coord[2]);
284 //________________________________________________________________________
285 Int_t AliITSv11GeomCableRound::CreateAndInsertCableSegment(Int_t p2)
287 // Creates a cable segment between points p1 and p2.
289 // The segment volume is created inside the volume containing point2
290 // Therefore this segment should be defined in this volume only.
291 // I mean here that, if the previous point is in another volume,
292 // it should be just at the border between the 2 volumes. Also the
293 // orientation vector of the previous point should be othogonal to
294 // the surface between the 2 volumes.
297 if (fInitialNode==0) {
298 TObjArray *nodes = gGeoManager->GetListOfNodes();
299 if (nodes->GetEntriesFast()==0) return kFALSE;
300 mainNode = (TGeoNode *) nodes->UncheckedAt(0);
302 mainNode = fInitialNode;
306 TGeoVolume *p1Vol = GetVolume(p1);
307 TGeoVolume *p2Vol = GetVolume(p2);
309 ResetCheckDaughter();
311 if (! CheckDaughter(mainNode)) {
312 printf("Error::volume containing point is not visible in node tree!\n");
316 Double_t coord1[3], coord2[3], vect1[3], vect2[3];
317 //=================================================
318 // Get p1 position in the systeme of p2
321 Int_t p1nodeInd[fgkCableMaxNodeLevel];
322 for (Int_t i=0; i<fgkCableMaxNodeLevel; i++) p1nodeInd[i]=fNodeInd[i];
323 Int_t p1volLevel = 0;
324 while (p1nodeInd[p1volLevel]!=-1) p1volLevel++;
327 ResetCheckDaughter();
329 if (! CheckDaughter(mainNode)) {
330 printf("Error::volume containing point is not visible in node tree!\n");
333 Int_t p2nodeInd[fgkCableMaxNodeLevel];
334 for (Int_t i=0; i<fgkCableMaxNodeLevel; i++) p2nodeInd[i]=fNodeInd[i];
335 Int_t commonMotherLevel = 0;
336 while (p1nodeInd[commonMotherLevel]==fNodeInd[commonMotherLevel])
339 Int_t p2volLevel = 0;
340 while (fNodeInd[p2volLevel]!=-1) p2volLevel++;
343 // Get coord and vect of p1 in the common mother reference system
344 GetCheckPoint(p1, 0, p1volLevel-commonMotherLevel, coord1);
345 GetCheckVect( p1, 0, p1volLevel-commonMotherLevel, vect1);
346 // Translate them in the reference system of the volume containing p2
347 TGeoNode *pathNode[fgkCableMaxNodeLevel];
348 pathNode[0] = mainNode;
349 for (Int_t i=0; i<=p2volLevel; i++) {
350 pathNode[i+1] = pathNode[i]->GetDaughter(p2nodeInd[i]);
352 Double_t globalCoord1[3] = {coord1[0], coord1[1], coord1[2]};
353 Double_t globalVect1[3] = {vect1[0], vect1[1], vect1[2]};
355 for (Int_t i = commonMotherLevel+1; i<=p2volLevel; i++) {
356 pathNode[i+1]->GetMatrix()->MasterToLocal(globalCoord1, coord1);
357 pathNode[i+1]->GetMatrix()->MasterToLocalVect(globalVect1, vect1);
358 CopyFrom(globalCoord1, coord1);
359 CopyFrom(globalVect1, vect1);
362 GetCheckPoint(p1, 0, 0, coord1);
363 GetCheckVect(p1, 0, 0, vect1);
366 //=================================================
367 // Get p2 position in the systeme of p2
368 GetCheckPoint(p2, 0, 0, coord2);
369 GetCheckVect(p2, 0, 0, vect2);
371 Double_t cx = (coord1[0]+coord2[0])/2;
372 Double_t cy = (coord1[1]+coord2[1])/2;
373 Double_t cz = (coord1[2]+coord2[2])/2;
374 Double_t dx = coord2[0]-coord1[0];
375 Double_t dy = coord2[1]-coord1[1];
376 Double_t dz = coord2[2]-coord1[2];
378 //=================================================
379 // Positionning of the segment between the 2 points
380 if ((dy<1e-31)&&(dy>0)) dy = 1e-31;
381 if ((dz<1e-31)&&(dz>0)) dz = 1e-31;
382 if ((dy>-1e-31)&&(dy<0)) dy = -1e-31;
383 if ((dz>-1e-31)&&(dz<0)) dz = -1e-31;
385 Double_t angleRot1 = -TMath::ATan2(dx,dy);
386 Double_t planDiagL = TMath::Sqrt(dy*dy+dx*dx);
387 Double_t angleRotDiag = -TMath::ATan2(planDiagL,dz);
388 TGeoRotation *rot = new TGeoRotation("",angleRot1*TMath::RadToDeg(),
389 angleRotDiag*TMath::RadToDeg(),
391 Double_t localVect1[3], localVect2[3];
392 rot->MasterToLocalVect(vect1, localVect1);
393 rot->MasterToLocalVect(vect2, localVect2);
394 TGeoTranslation *trans = new TGeoTranslation("",cx, cy, cz);
396 //=================================================
397 // Create the segment and add it to the mother volume
398 TGeoVolume *vCableSeg = CreateSegment(coord1, coord2,
399 localVect1, localVect2);
401 TGeoCombiTrans *combi = new TGeoCombiTrans(*trans, *rot);
402 p2Vol->AddNode(vCableSeg, p2, combi);
403 //=================================================
408 printf("---\n Cable segment points : ");
409 printf("%f, %f, %f\n",coord1[0], coord1[1], coord1[2]);
410 printf("%f, %f, %f\n",coord2[0], coord2[1], coord2[2]);
412 // #include <TGeoSphere.h>
413 // TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
414 // TGeoSphere *sphere = new TGeoSphere(0, 0.15);
415 // TGeoVolume *vSphere = new TGeoVolume("", sphere, airSDD);
416 // TGeoTranslation *trC = new TGeoTranslation("", cx, cy, cz);
417 // TGeoTranslation *tr1 = new TGeoTranslation("",coord1[0],
418 // coord1[1],coord1[2]);
419 // TGeoTranslation *tr2 = new TGeoTranslation("",coord2[0],
420 // coord2[1],coord2[2]);
421 // p2Vol->AddNode(vSphere, p2*3-2, trC);
422 // p2Vol->AddNode(vSphere, p2*3-1, tr1);
423 // p2Vol->AddNode(vSphere, p2*3 , tr2);
429 //________________________________________________________________________
430 Int_t AliITSv11GeomCableRound::CreateAndInsertTorusSegment(Int_t p2, Double_t rotation)
432 // Create a torus cable segment between points p1 and p2.
433 // The radius and position of the torus is defined by the
434 // perpendicular vector of point p2 (the orientation of this vector
435 // and the position of the 2 check points are enough to completely
439 if (fInitialNode==0) {
440 TObjArray *nodes = gGeoManager->GetListOfNodes();
441 if (nodes->GetEntriesFast()==0) return kFALSE;
442 mainNode = (TGeoNode *) nodes->UncheckedAt(0);
444 mainNode = fInitialNode;
448 TGeoVolume *p1Vol = GetVolume(p1);
449 TGeoVolume *p2Vol = GetVolume(p2);
451 ResetCheckDaughter();
453 if (! CheckDaughter(mainNode)) {
454 printf("Error::volume containing point is not visible in node tree!\n");
458 Double_t coord1[3], coord2[3], vect1[3], vect2[3];
459 //=================================================
460 // Get p1 position in the systeme of p2
463 Int_t p1nodeInd[fgkCableMaxNodeLevel];
464 for (Int_t i=0; i<fgkCableMaxNodeLevel; i++) p1nodeInd[i]=fNodeInd[i];
465 Int_t p1volLevel = 0;
466 while (p1nodeInd[p1volLevel]!=-1) p1volLevel++;
469 ResetCheckDaughter();
471 if (! CheckDaughter(mainNode)) {
472 printf("Error::volume containing point is not visible in node tree!\n");
475 Int_t p2nodeInd[fgkCableMaxNodeLevel];
476 for (Int_t i=0; i<fgkCableMaxNodeLevel; i++) p2nodeInd[i]=fNodeInd[i];
477 Int_t commonMotherLevel = 0;
478 while (p1nodeInd[commonMotherLevel]==fNodeInd[commonMotherLevel])
481 Int_t p2volLevel = 0;
482 while (fNodeInd[p2volLevel]!=-1) p2volLevel++;
485 // Get coord and vect of p1 in the common mother reference system
486 GetCheckPoint(p1, 0, p1volLevel-commonMotherLevel, coord1);
487 GetCheckVect( p1, 0, p1volLevel-commonMotherLevel, vect1);
488 // Translate them in the reference system of the volume containing p2
489 TGeoNode *pathNode[fgkCableMaxNodeLevel];
490 pathNode[0] = mainNode;
491 for (Int_t i=0; i<=p2volLevel; i++) {
492 pathNode[i+1] = pathNode[i]->GetDaughter(p2nodeInd[i]);
494 Double_t globalCoord1[3] = {coord1[0], coord1[1], coord1[2]};
495 Double_t globalVect1[3] = {vect1[0], vect1[1], vect1[2]};
497 for (Int_t i = commonMotherLevel+1; i<=p2volLevel; i++) {
498 pathNode[i+1]->GetMatrix()->MasterToLocal(globalCoord1, coord1);
499 pathNode[i+1]->GetMatrix()->MasterToLocalVect(globalVect1, vect1);
500 CopyFrom(globalCoord1, coord1);
501 CopyFrom(globalVect1, vect1);
504 GetCheckPoint(p1, 0, 0, coord1);
505 GetCheckVect(p1, 0, 0, vect1);
508 //=================================================
509 // Get p2 position in the systeme of p2
510 GetCheckPoint(p2, 0, 0, coord2);
511 GetCheckVect(p2, 0, 0, vect2);
513 Double_t cx = (coord1[0]+coord2[0])/2;
514 Double_t cy = (coord1[1]+coord2[1])/2;
515 Double_t cz = (coord1[2]+coord2[2])/2;
516 Double_t dx = coord2[0]-coord1[0];
517 Double_t dy = coord2[1]-coord1[1];
518 Double_t dz = coord2[2]-coord1[2];
519 Double_t length = TMath::Sqrt(dx*dx+dy*dy+dz*dz);
521 //=================================================
522 // Positionning of the segment between the 2 points
523 if ((dy<1e-31)&&(dy>0)) dy = 1e-31;
524 if ((dz<1e-31)&&(dz>0)) dz = 1e-31;
525 if ((dy>-1e-31)&&(dy<0)) dy = -1e-31;
526 if ((dz>-1e-31)&&(dz<0)) dz = -1e-31;
528 Double_t angleRot1 = -TMath::ATan2(dx,dy);
529 Double_t planDiagL = TMath::Sqrt(dy*dy+dx*dx);
530 Double_t angleRotDiag = -TMath::ATan2(planDiagL,dz);
532 TGeoRotation rotTorusTemp("",angleRot1*TMath::RadToDeg(),
533 angleRotDiag*TMath::RadToDeg(),0);
534 TGeoRotation rotTorusToZ("",0,90,0);
535 rotTorusTemp.MultiplyBy(&rotTorusToZ, kTRUE);
536 Double_t localVect2[3];
537 rotTorusTemp.MasterToLocalVect(vect2, localVect2);
538 if (localVect2[1]<0) {
539 localVect2[0] = -localVect2[0];
540 localVect2[1] = -localVect2[1];
541 localVect2[2] = -localVect2[2];
543 Double_t normVect2 = TMath::Sqrt(localVect2[0]*localVect2[0]+
544 localVect2[1]*localVect2[1]+
545 localVect2[2]*localVect2[2]);
546 Double_t axisX[3] = {1,0,0};
547 Double_t cosangleTorusSeg = (localVect2[0]*axisX[0]+
548 localVect2[1]*axisX[1]+
549 localVect2[2]*axisX[2])/normVect2;
550 Double_t angleTorusSeg = TMath::ACos(cosangleTorusSeg)*TMath::RadToDeg();
551 TGeoRotation rotTorus("",angleRot1*TMath::RadToDeg(),
552 angleRotDiag*TMath::RadToDeg(),
553 180-angleTorusSeg+rotation);
554 rotTorus.MultiplyBy(&rotTorusToZ, kTRUE);
555 rotTorus.MasterToLocalVect(vect2, localVect2);
556 if (localVect2[1]<0) {
557 localVect2[0] = -localVect2[0];
558 localVect2[1] = -localVect2[1];
559 localVect2[2] = -localVect2[2];
561 normVect2 = TMath::Sqrt(localVect2[0]*localVect2[0]+
562 localVect2[1]*localVect2[1]+
563 localVect2[2]*localVect2[2]);
564 Double_t axisY[3] = {0,1,0};
565 Double_t cosPhi = (localVect2[0]*axisY[0]+localVect2[1]*axisY[1]+
566 localVect2[2]*axisY[2])/normVect2;
567 Double_t torusPhi1 = TMath::ACos(cosPhi);
568 Double_t torusR = (length/2)/TMath::Sin(torusPhi1);
569 torusPhi1 = torusPhi1*TMath::RadToDeg();
570 Double_t perpLength = TMath::Sqrt(torusR*torusR-length*length/4);
571 Double_t localTransT[3] = {-perpLength,0,0};
572 Double_t globalTransT[3];
573 rotTorus.LocalToMasterVect(localTransT, globalTransT);
574 TGeoTranslation transTorus("",cx+globalTransT[0],cy+globalTransT[1],
577 TGeoCombiTrans *combiTorus = new TGeoCombiTrans(transTorus, rotTorus);
579 //=================================================
580 // Create the segment and add it to the mother volume
581 TGeoVolume *vCableSegT = CreateTorus(torusPhi1, torusR);
582 p2Vol->AddNode(vCableSegT, p2, combiTorus);
585 printf("---\n Cable segment points : ");
586 printf("%f, %f, %f\n",coord1[0], coord1[1], coord1[2]);
587 printf("%f, %f, %f\n",coord2[0], coord2[1], coord2[2]);
593 //________________________________________________________________________
594 TGeoVolume *AliITSv11GeomCableRound::CreateSegment( Double_t *coord1,
596 Double_t *localVect1,
597 Double_t *localVect2 )
599 // Create one cylindrical segment and its layers
601 //=================================================
602 // Calculate segment "deformation"
603 Double_t dx = coord2[0]-coord1[0];
604 Double_t dy = coord2[1]-coord1[1];
605 Double_t dz = coord2[2]-coord1[2];
606 Double_t length = TMath::Sqrt(dx*dx+dy*dy+dz*dz);
608 // normal vectors have to point outside the TGeoCtub :
609 if (-localVect1[2]<0) {
610 localVect1[0] = -localVect1[0];
611 localVect1[1] = -localVect1[1];
612 localVect1[2] = -localVect1[2];
614 if (localVect2[2]<0) {
615 localVect2[0] = -localVect2[0];
616 localVect2[1] = -localVect2[1];
617 localVect2[2] = -localVect2[2];
619 //=================================================
620 // Create the segment
621 TGeoCtub *cableSeg = new TGeoCtub(0, fRadius, length/2, fPhiMin, fPhiMax,
622 localVect1[0],localVect1[1],localVect1[2],
623 localVect2[0],localVect2[1],localVect2[2]);
625 TGeoMedium *airSDD = gGeoManager->GetMedium("ITSair");
626 TGeoVolume *vCableSeg = new TGeoVolume(GetName(), cableSeg, airSDD);
628 // add all cable layers
629 Double_t layThickness[100+1]; // 100 layers max !!!
631 for (Int_t iLay=0; iLay<fNlayer; iLay++) {
633 layThickness[iLay+1] = fLayThickness[iLay]+layThickness[iLay];
634 TGeoCtub *lay = new TGeoCtub(layThickness[iLay], layThickness[iLay+1],
635 length/2, fPhiMin, fPhiMax,
636 localVect1[0],localVect1[1],localVect1[2],
637 localVect2[0],localVect2[1],localVect2[2]);
639 TGeoVolume *vLay = new TGeoVolume("vCableSegLay", lay, fLayMedia[iLay]);
640 vLay->SetLineColor(fLayColor[iLay]);
641 vCableSeg->AddNode(vLay, iLay+1, 0);
644 vCableSeg->SetVisibility(kFALSE);
649 //________________________________________________________________________
650 TGeoVolume *AliITSv11GeomCableRound::CreateTorus( Double_t &phi,
653 // Create one torus segment and its layers
656 Double_t torusPhi1 = phi;
657 Double_t torusDPhi = -2*torusPhi1;
659 //=================================================
660 // Create the segment
661 TGeoTorus *cableSeg = new TGeoTorus(torusR, 0,fRadius,torusPhi1,torusDPhi);
662 TGeoMedium *airSDD = gGeoManager->GetMedium("ITSair");
663 TGeoVolume *vCableSeg = new TGeoVolume(GetName(), cableSeg, airSDD);
665 // add all cable layers
666 Double_t layThickness[100+1]; // 100 layers max !!!
668 for (Int_t iLay=0; iLay<fNlayer; iLay++) {
670 layThickness[iLay+1] = fLayThickness[iLay]+layThickness[iLay];
671 TGeoTorus *lay = new TGeoTorus(torusR, layThickness[iLay],
672 layThickness[iLay+1],
673 torusPhi1,torusDPhi);
675 TGeoVolume *vLay = new TGeoVolume("vCableSegLay",lay,fLayMedia[iLay]);
676 vLay->SetLineColor(fLayColor[iLay]);
677 vCableSeg->AddNode(vLay, iLay+1, 0);
680 vCableSeg->SetVisibility(kFALSE);
685 //________________________________________________________________________
686 void AliITSv11GeomCableRound::SetNLayers(Int_t nLayers) {
687 // Set the total number of layers
688 if((nLayers>0) &&(nLayers<=fgkCableMaxLayer)) {
690 for (Int_t i = 0; i<fNlayer; i++) {
691 fLayThickness[i] = 0;
697 //________________________________________________________________________
698 Int_t AliITSv11GeomCableRound::SetLayer(Int_t nLayer, Double_t thick,
699 TGeoMedium *medium, Int_t color) {
701 if ((nLayer<0)||(nLayer>=fNlayer)) {
702 printf("Set wrong layer number of the cable\n");
706 if (fLayThickness[nLayer-1]<=0) {
707 printf("You must define cable layer %i first !",nLayer-1);
711 Double_t thickTot = 0;
712 for (Int_t i=0; i<nLayer; i++) thickTot += fLayThickness[i];
714 if (thickTot-1e-10>fRadius) {
715 printf("Can't add this layer, cable thickness would be higher than total\n");
719 fLayThickness[nLayer] = thick;
720 fLayMedia[nLayer] = medium;
721 fLayColor[nLayer] = color;