X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ITS%2FAliITSv11GeomCableFlat.cxx;h=8053822372d570d0b4cde22bb41753f391ccec47;hb=1afa951f28e5a1d66cb0b78bb90e895caebe1579;hp=ee85a959e1be7c609fa98fb773e20f2437a3210f;hpb=99d29480535fb10a918fe157d1a4bac3e62fadd4;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/AliITSv11GeomCableFlat.cxx b/ITS/AliITSv11GeomCableFlat.cxx index ee85a959e1b..8053822372d 100644 --- a/ITS/AliITSv11GeomCableFlat.cxx +++ b/ITS/AliITSv11GeomCableFlat.cxx @@ -13,6 +13,7 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ +// $Id$ //************************************************************************* // Class for flat cables @@ -31,6 +32,7 @@ #include #include #include +#include #include #include @@ -40,36 +42,40 @@ ClassImp(AliITSv11GeomCableFlat) //________________________________________________________________________ -AliITSv11GeomCableFlat::AliITSv11GeomCableFlat() : AliITSv11GeomCable() +AliITSv11GeomCableFlat::AliITSv11GeomCableFlat(): + AliITSv11GeomCable(), + fWidth(0), + fThick(0), + fNlayer(0) { // constructor - fWidth = 0; - fThick = 0; - fNlayer = 0; for (Int_t i=0; iGetElements()); #else CopyFrom(coord, coordVector->GetMatrixArray()); -#endif +#endif return kTRUE; } else { return kFALSE; }; -}; - +} //________________________________________________________________________ Int_t AliITSv11GeomCableFlat::GetVect( Int_t iCheckPt, Double_t *coord) @@ -132,13 +139,12 @@ Int_t AliITSv11GeomCableFlat::GetVect( Int_t iCheckPt, Double_t *coord) CopyFrom(coord, coordVector->GetElements()); #else CopyFrom(coord, coordVector->GetMatrixArray()); -#endif +#endif return kTRUE; } else { return kFALSE; }; -}; - +} //________________________________________________________________________ void AliITSv11GeomCableFlat::AddCheckPoint( TGeoVolume *vol, Int_t iCheckPt, @@ -168,7 +174,7 @@ void AliITSv11GeomCableFlat::AddCheckPoint( TGeoVolume *vol, Int_t iCheckPt, TVectorD *vect = new TVectorD(3,orthVect); fPointArray.AddAtAndExpand(point, iCheckPt*2 ); fPointArray.AddAtAndExpand(vect, iCheckPt*2+1); -}; +} //________________________________________________________________________ void AliITSv11GeomCableFlat::PrintCheckPoints() const { @@ -179,11 +185,12 @@ void AliITSv11GeomCableFlat::PrintCheckPoints() const { if (GetPoint( i, coord)) printf(" ( %.2f, %.2f, %.2f )\n", coord[0], coord[1], coord[2]); }; -}; +} //________________________________________________________________________ -Int_t AliITSv11GeomCableFlat::CreateAndInsertCableSegment(Int_t p2, - Double_t rotation) +TGeoVolume* AliITSv11GeomCableFlat::CreateAndInsertCableSegment(Int_t p2, + Double_t rotation, + TGeoCombiTrans** ct) { // Creates a cable segment between points p1 and p2. // Rotation is the eventual rotation of the flat cable @@ -199,7 +206,7 @@ Int_t AliITSv11GeomCableFlat::CreateAndInsertCableSegment(Int_t p2, TGeoNode *mainNode; if (fInitialNode==0) { TObjArray *nodes = gGeoManager->GetListOfNodes(); - if (nodes->GetEntriesFast()==0) return kFALSE; + if (nodes->GetEntriesFast()==0) return 0; mainNode = (TGeoNode *) nodes->UncheckedAt(0); } else { mainNode = fInitialNode; @@ -213,7 +220,7 @@ Int_t AliITSv11GeomCableFlat::CreateAndInsertCableSegment(Int_t p2, fCurrentVol = p1Vol; if (! CheckDaughter(mainNode)) { printf("Error::volume containing point is not visible in node tree!\n"); - return kFALSE; + return 0; }; Double_t coord1[3], coord2[3], vect1[3], vect2[3]; @@ -231,7 +238,7 @@ Int_t AliITSv11GeomCableFlat::CreateAndInsertCableSegment(Int_t p2, fCurrentVol = p2Vol; if (! CheckDaughter(mainNode)) { printf("Error::volume containing point is not visible in node tree!\n"); - return kFALSE; + return 0; }; Int_t p2nodeInd[fgkCableMaxNodeLevel]; for (Int_t i=0; i1) { - Double_t orthVectNorm2 = ScalProd(orthVect,orthVect); - Double_t alpha1 = ScalProd(fPreviousX,orthVect)/orthVectNorm2; - Double_t alpha2 = ScalProd(globalX,orthVect)/orthVectNorm2; - Double_t globalX1p[3], globalX2p[3]; - globalX1p[0] = fPreviousX[0] - alpha1*orthVect[0]; - globalX1p[1] = fPreviousX[1] - alpha1*orthVect[1]; - globalX1p[2] = fPreviousX[2] - alpha1*orthVect[2]; - globalX2p[0] = globalX[0] - alpha2*orthVect[0]; - globalX2p[1] = globalX[1] - alpha2*orthVect[1]; - globalX2p[2] = globalX[2] - alpha2*orthVect[2]; - //-- now I'm searching the 3th vect which makes an orthogonal base - //-- with orthVect and globalX1p ... - Double_t nulVect[3] = {0,0,0}; - Double_t axis3[3]; - TMath::Normal2Plane(nulVect, orthVect, globalX1p, axis3); - Double_t globalX1pNorm2 = ScalProd(globalX1p, globalX1p); - Double_t beta = ScalProd(globalX2p, globalX1p)/globalX1pNorm2; - Double_t gamma = ScalProd(globalX2p, axis3); - angleRotZ = (TMath::ATan2(1,0) - TMath::ATan2(beta, gamma)) - *TMath::RadToDeg(); - }; +// Double_t angleRotZ = 0; +// if (p2>1) { +// Double_t orthVectNorm2 = ScalProd(orthVect,orthVect); +// Double_t alpha1 = ScalProd(fPreviousX,orthVect)/orthVectNorm2; +// Double_t alpha2 = ScalProd(globalX,orthVect)/orthVectNorm2; +// Double_t globalX1p[3], globalX2p[3]; +// globalX1p[0] = fPreviousX[0] - alpha1*orthVect[0]; +// globalX1p[1] = fPreviousX[1] - alpha1*orthVect[1]; +// globalX1p[2] = fPreviousX[2] - alpha1*orthVect[2]; +// globalX2p[0] = globalX[0] - alpha2*orthVect[0]; +// globalX2p[1] = globalX[1] - alpha2*orthVect[1]; +// globalX2p[2] = globalX[2] - alpha2*orthVect[2]; +// //-- now I'm searching the 3th vect which makes an orthogonal base +// //-- with orthVect and globalX1p ... +// Double_t nulVect[3] = {0,0,0}; +// Double_t axis3[3]; +// TMath::Normal2Plane(nulVect, orthVect, globalX1p, axis3); +// Double_t globalX1pNorm2 = ScalProd(globalX1p, globalX1p); +// Double_t beta = ScalProd(globalX2p, globalX1p)/globalX1pNorm2; +// Double_t gamma = ScalProd(globalX2p, axis3); +// angleRotZ = (TMath::ATan2(1,0) - TMath::ATan2(beta, gamma)) +// *TMath::RadToDeg(); +// }; // cout << "!!!!!!!!!!!!!!!!!!! angle = " < -// TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir"); +// TGeoMedium *airSDD = gGeoManager->GetMedium("ITS_AIR$"); // TGeoSphere *sphere = new TGeoSphere(0, 0.05); // TGeoVolume *vSphere = new TGeoVolume("", sphere, airSDD); // TGeoTranslation *trC = new TGeoTranslation("", cx, cy, cz); @@ -373,17 +379,374 @@ Int_t AliITSv11GeomCableFlat::CreateAndInsertCableSegment(Int_t p2, // p2Vol->AddNode(vSphere, p2*3-2, trC); // p2Vol->AddNode(vSphere, p2*3-1, tr1); // p2Vol->AddNode(vSphere, p2*3 , tr2); + if (ct) *ct = combiB; + return vCableSegB; +} - return kTRUE; -}; +//________________________________________________________________________ +TGeoVolume* AliITSv11GeomCableFlat::CreateAndInsertBoxCableSegment(Int_t p2, + Double_t rotation, + TGeoCombiTrans** ct) +{ + // This function is to be use only when the segment has the shape + // of a simple box, i.e. the normal vector to its end is perpendicular + // to the segment own axis +// Creates a cable segment between points p1 and p2. +// Rotation is the eventual rotation of the flat cable +// along its length axis +// +// The segment volume is created inside the volume containing point2 +// Therefore this segment should be defined in this volume only. +// I mean here that, if the previous point is in another volume, +// it should be just at the border between the 2 volumes. Also the +// orientation vector of the previous point should be orthogonal to +// the surface between the 2 volumes. + + TGeoNode *mainNode; + if (fInitialNode==0) { + TObjArray *nodes = gGeoManager->GetListOfNodes(); + if (nodes->GetEntriesFast()==0) return 0; + mainNode = (TGeoNode *) nodes->UncheckedAt(0); + } else { + mainNode = fInitialNode; + }; + + Int_t p1 = p2 - 1; + TGeoVolume *p2Vol = GetVolume(p2); + TGeoVolume *p1Vol = GetVolume(p1); + + ResetCheckDaughter(); + fCurrentVol = p1Vol; + if (! CheckDaughter(mainNode)) { + printf("Error::volume containing point is not visible in node tree!\n"); + return 0; + }; + + Double_t coord1[3], coord2[3], vect1[3], vect2[3]; + //================================================= + // Get p1 position in the systeme of p2 + if (p1Vol!=p2Vol) { + + Int_t p1nodeInd[fgkCableMaxNodeLevel]; + for (Int_t i=0; iGetDaughter(p2nodeInd[i]); + }; + Double_t globalCoord1[3] = {coord1[0], coord1[1], coord1[2]}; + Double_t globalVect1[3] = {vect1[0], vect1[1], vect1[2]}; + + for (Int_t i = commonMotherLevel+1; i <= p2volLevel; i++) { + pathNode[i+1]->GetMatrix()->MasterToLocal(globalCoord1, coord1); + pathNode[i+1]->GetMatrix()->MasterToLocalVect(globalVect1, vect1); + CopyFrom(globalCoord1, coord1); + CopyFrom(globalVect1, vect1); + }; + } else { + if (! GetCheckPoint(p1, 0, 0, coord1) ) return 0; + if (! GetCheckVect(p1, 0, 0, vect1) ) return 0; + }; + + //================================================= + // Get p2 position in the systeme of p2 + if (! GetCheckPoint(p2, 0, 0, coord2) ) return 0; + if (! GetCheckVect(p2, 0, 0, vect2) ) return 0; + + Double_t cx = (coord1[0]+coord2[0])/2; + Double_t cy = (coord1[1]+coord2[1])/2; + Double_t cz = (coord1[2]+coord2[2])/2; + Double_t dx = coord2[0]-coord1[0]; + Double_t dy = coord2[1]-coord1[1]; + Double_t dz = coord2[2]-coord1[2]; + + //================================================= + // Positionning of the segment between the 2 points + if (TMath::Abs(dy)<1e-231) dy = 1e-231; + if (TMath::Abs(dz)<1e-231) dz = 1e-231; + //Double_t angleRot1 = -TMath::ATan(dx/dy); + //Double_t planDiagL = -TMath::Sqrt(dy*dy+dx*dx); + //if (dy<0) planDiagL = -planDiagL; + //Double_t angleRotDiag = TMath::ATan(planDiagL/dz); + + Double_t angleRot1 = -TMath::ATan2(dx,dy); + Double_t planDiagL = TMath::Sqrt(dy*dy+dx*dx); + Double_t angleRotDiag = -TMath::ATan2(planDiagL,dz); + //--- (Calculate rotation of segment on the Z axis) + //-- Here I'm trying to calculate the rotation to be applied in + //-- order to match as closer as possible this segment and the + //-- previous one. + //-- It seems that some times it doesn't work ... + TGeoRotation rotTemp("",angleRot1*TMath::RadToDeg(), + angleRotDiag*TMath::RadToDeg(), rotation); + Double_t localX[3] = {0,1,0}; + Double_t globalX[3]; + rotTemp.LocalToMasterVect(localX, globalX); + CopyFrom(localX, globalX); + GetCheckVect(localX, p2Vol, 0, fgkCableMaxNodeLevel+1, globalX); + Double_t orthVect[3]; + GetCheckVect(vect1, p2Vol, 0, fgkCableMaxNodeLevel+1, orthVect); +// Double_t angleRotZ = 0; +// if (p2>1) { +// Double_t orthVectNorm2 = ScalProd(orthVect,orthVect); +// Double_t alpha1 = ScalProd(fPreviousX,orthVect)/orthVectNorm2; +// Double_t alpha2 = ScalProd(globalX,orthVect)/orthVectNorm2; +// Double_t globalX1p[3], globalX2p[3]; +// globalX1p[0] = fPreviousX[0] - alpha1*orthVect[0]; +// globalX1p[1] = fPreviousX[1] - alpha1*orthVect[1]; +// globalX1p[2] = fPreviousX[2] - alpha1*orthVect[2]; +// globalX2p[0] = globalX[0] - alpha2*orthVect[0]; +// globalX2p[1] = globalX[1] - alpha2*orthVect[1]; +// globalX2p[2] = globalX[2] - alpha2*orthVect[2]; +// //-- now I'm searching the 3th vect which makes an orthogonal base +// //-- with orthVect and globalX1p ... +// Double_t nulVect[3] = {0,0,0}; +// Double_t axis3[3]; +// TMath::Normal2Plane(nulVect, orthVect, globalX1p, axis3); +// Double_t globalX1pNorm2 = ScalProd(globalX1p, globalX1p); +// Double_t beta = ScalProd(globalX2p, globalX1p)/globalX1pNorm2; +// Double_t gamma = ScalProd(globalX2p, axis3); +// angleRotZ = (TMath::ATan2(1,0) - TMath::ATan2(beta, gamma)) +// *TMath::RadToDeg(); +// }; + CopyFrom(fPreviousX, globalX); + //--- + Double_t localVect1[3], localVect2[3]; + TGeoRotation rot("",angleRot1*TMath::RadToDeg(), + angleRotDiag*TMath::RadToDeg(), + rotation); +// rotation-angleRotZ); +// since angleRotZ doesn't always work, I won't use it ... + + rot.MasterToLocalVect(vect1, localVect1); + rot.MasterToLocalVect(vect2, localVect2); + + //================================================= + // Create the segment and add it to the mother volume + TGeoVolume *vCableSegB = CreateBoxSegment(coord1, coord2); + + TGeoRotation rotArbSeg("", 0, 90, 0); + rotArbSeg.MultiplyBy(&rot, kFALSE); + TGeoTranslation trans("",cx, cy, cz); + TGeoCombiTrans *combiB = new TGeoCombiTrans(trans, rotArbSeg); + p2Vol->AddNode(vCableSegB, p2, combiB); + //=================================================; + + if (fDebug) { + printf("---\n Cable segment points : "); + printf("%f, %f, %f\n",coord1[0], coord1[1], coord1[2]); + printf("%f, %f, %f\n",coord2[0], coord2[1], coord2[2]); + }; + + if (ct) *ct = combiB; + return vCableSegB; +} //________________________________________________________________________ -TGeoVolume *AliITSv11GeomCableFlat::CreateSegment( Double_t *coord1, - Double_t *coord2, - Double_t *localVect1, - Double_t *localVect2 ) +TGeoVolume* AliITSv11GeomCableFlat::CreateAndInsertCableCylSegment(Int_t p2, + Double_t rotation, + TGeoCombiTrans** ct) { + // Create a flat cable segment with a curvature between points p1 and p2. + // The radius and position of the curve is defined by the + // perpendicular vector of point p2 (the orientation of this vector + // and the position of the 2 check points are enough to completely + // define the curve) + // Rotation is the eventual rotation of the flat cable + // along its length axis + // + + TGeoNode *mainNode; + if (fInitialNode==0) { + TObjArray *nodes = gGeoManager->GetListOfNodes(); + if (nodes->GetEntriesFast()==0) return 0; + mainNode = (TGeoNode *) nodes->UncheckedAt(0); + } else { + mainNode = fInitialNode; + }; + + Int_t p1 = p2 - 1; + TGeoVolume *p1Vol = GetVolume(p1); + TGeoVolume *p2Vol = GetVolume(p2); + + ResetCheckDaughter(); + fCurrentVol = p1Vol; + if (! CheckDaughter(mainNode)) { + printf("Error::volume containing point is not visible in node tree!\n"); + return 0; + }; + + Double_t coord1[3], coord2[3], vect1[3], vect2[3]; + //================================================= + // Get p1 position in the systeme of p2 + if (p1Vol!=p2Vol) { + + Int_t p1nodeInd[fgkCableMaxNodeLevel]; + for (Int_t i=0; iGetDaughter(p2nodeInd[i]); + }; + Double_t globalCoord1[3] = {coord1[0], coord1[1], coord1[2]}; + Double_t globalVect1[3] = {vect1[0], vect1[1], vect1[2]}; + + for (Int_t i = commonMotherLevel+1; i<=p2volLevel; i++) { + pathNode[i+1]->GetMatrix()->MasterToLocal(globalCoord1, coord1); + pathNode[i+1]->GetMatrix()->MasterToLocalVect(globalVect1, vect1); + CopyFrom(globalCoord1, coord1); + CopyFrom(globalVect1, vect1); + }; + } else { + GetCheckPoint(p1, 0, 0, coord1); + GetCheckVect(p1, 0, 0, vect1); + }; + + //================================================= + // Get p2 position in the systeme of p2 + GetCheckPoint(p2, 0, 0, coord2); + GetCheckVect(p2, 0, 0, vect2); + + Double_t cx = (coord1[0]+coord2[0])/2; + Double_t cy = (coord1[1]+coord2[1])/2; + Double_t cz = (coord1[2]+coord2[2])/2; + Double_t dx = coord2[0]-coord1[0]; + Double_t dy = coord2[1]-coord1[1]; + Double_t dz = coord2[2]-coord1[2]; + Double_t length = TMath::Sqrt(dx*dx+dy*dy+dz*dz); + + //================================================= + // Positionning of the segment between the 2 points + if ((dy<1e-31)&&(dy>0)) dy = 1e-31; + if ((dz<1e-31)&&(dz>0)) dz = 1e-31; + if ((dy>-1e-31)&&(dy<0)) dy = -1e-31; + if ((dz>-1e-31)&&(dz<0)) dz = -1e-31; + + Double_t angleRot1 = -TMath::ATan2(dx,dy); + Double_t planDiagL = TMath::Sqrt(dy*dy+dx*dx); + Double_t angleRotDiag = -TMath::ATan2(planDiagL,dz); + + TGeoRotation rotTorusTemp("",angleRot1*TMath::RadToDeg(), + angleRotDiag*TMath::RadToDeg(),0); + TGeoRotation rotTorusToZ("",0,90,0); + rotTorusTemp.MultiplyBy(&rotTorusToZ, kTRUE); + Double_t localVect2[3]; + rotTorusTemp.MasterToLocalVect(vect2, localVect2); + if (localVect2[1]<0) { + localVect2[0] = -localVect2[0]; + localVect2[1] = -localVect2[1]; + localVect2[2] = -localVect2[2]; + }; + Double_t normVect2 = TMath::Sqrt(localVect2[0]*localVect2[0]+ + localVect2[1]*localVect2[1]+ + localVect2[2]*localVect2[2]); + Double_t axisX[3] = {1,0,0}; + Double_t cosangleTorusSeg = (localVect2[0]*axisX[0]+ + localVect2[1]*axisX[1]+ + localVect2[2]*axisX[2])/normVect2; + Double_t angleTorusSeg = TMath::ACos(cosangleTorusSeg)*TMath::RadToDeg(); + TGeoRotation rotTorus("",angleRot1*TMath::RadToDeg(), + angleRotDiag*TMath::RadToDeg(), + 45-angleTorusSeg+rotation); + //180-angleTorusSeg+rotation); + rotTorus.MultiplyBy(&rotTorusToZ, kTRUE); + rotTorus.MasterToLocalVect(vect2, localVect2); + if (localVect2[1]<0) { + localVect2[0] = -localVect2[0]; + localVect2[1] = -localVect2[1]; + localVect2[2] = -localVect2[2]; + }; + normVect2 = TMath::Sqrt(localVect2[0]*localVect2[0]+ + localVect2[1]*localVect2[1]+ + localVect2[2]*localVect2[2]); + Double_t axisY[3] = {0,1,0}; + Double_t cosPhi = (localVect2[0]*axisY[0]+localVect2[1]*axisY[1]+ + localVect2[2]*axisY[2])/normVect2; + Double_t torusPhi1 = TMath::ACos(cosPhi); + Double_t torusR = (length/2)/TMath::Sin(torusPhi1); + torusPhi1 = torusPhi1*TMath::RadToDeg(); + Double_t perpLength = TMath::Sqrt((torusR-0.5*length)*(torusR+0.5*length)); + Double_t localTransT[3] = {-perpLength,0,0}; + Double_t globalTransT[3]; + rotTorus.LocalToMasterVect(localTransT, globalTransT); + TGeoTranslation transTorus("",cx+globalTransT[0],cy+globalTransT[1], + cz+globalTransT[2]); + + TGeoCombiTrans *combiTorus = new TGeoCombiTrans(transTorus, rotTorus); + + //================================================= + // Create the segment and add it to the mother volume + TGeoVolume *vCableSegT = CreateCylSegment(torusPhi1, torusR); + p2Vol->AddNode(vCableSegT, p2, combiTorus); + + if (fDebug) { + printf("---\n Cable segment points : "); + printf("%f, %f, %f\n",coord1[0], coord1[1], coord1[2]); + printf("%f, %f, %f\n",coord2[0], coord2[1], coord2[2]); + }; + + if (ct) *ct = combiTorus; + return vCableSegT; +} + +//________________________________________________________________________ +TGeoVolume *AliITSv11GeomCableFlat::CreateSegment( const Double_t *coord1, + const Double_t *coord2, + const Double_t *localVect1, + const Double_t *localVect2 ) +{ + // Create a segment with arbitrary vertices (general case) //================================================= // Calculate segment "deformation" Double_t dx = coord2[0]-coord1[0]; @@ -415,26 +778,26 @@ TGeoVolume *AliITSv11GeomCableFlat::CreateSegment( Double_t *coord1, if (localVect1[1]<0) tanACosCosPhi1 = -tanACosCosPhi1; if (localVect2[1]<0) tanACosCosPhi2 = -tanACosCosPhi2; - Double_t dl1 = 0.5*fThick*tanACosCosPhi1; - Double_t dl2 = 0.5*fThick*tanACosCosPhi2; - + Double_t dl1 = 0.5*fThick*tanACosCosPhi1*0.99999999999999; + Double_t dl2 = 0.5*fThick*tanACosCosPhi2*0.99999999999999; + // 0.9999999999999 is for correcting problems in TGeo... //================================================= // Create the segment TGeoArb8 *cableSeg = new TGeoArb8(fThick/2); cableSeg->SetVertex( 0, -fWidth/2, -length/2 - dL1 + dl1); - cableSeg->SetVertex( 1, fWidth/2, -length/2 + dL1 + dl1); + cableSeg->SetVertex( 1, -fWidth/2, length/2 + dL2 - dl2); cableSeg->SetVertex( 2, fWidth/2, length/2 - dL2 - dl2); - cableSeg->SetVertex( 3, -fWidth/2, length/2 + dL2 - dl2); + cableSeg->SetVertex( 3, fWidth/2, -length/2 + dL1 + dl1); cableSeg->SetVertex( 4, -fWidth/2, -length/2 - dL1 - dl1); - cableSeg->SetVertex( 5, fWidth/2, -length/2 + dL1 - dl1); + cableSeg->SetVertex( 5, -fWidth/2, length/2 + dL2 + dl2); cableSeg->SetVertex( 6, fWidth/2, length/2 - dL2 + dl2); - cableSeg->SetVertex( 7, -fWidth/2, length/2 + dL2 + dl2); + cableSeg->SetVertex( 7, fWidth/2, -length/2 + dL1 - dl1); - TGeoMedium *airSDD = gGeoManager->GetMedium("ITSair"); - TGeoVolume *vCableSeg = new TGeoVolume(GetName(), cableSeg, airSDD); + TGeoVolume *vCableSeg = new TGeoVolume(GetName(), cableSeg, fLayMedia[fNlayer-1]); + vCableSeg->SetLineColor(fLayColor[fNlayer-1]); - // add all cable layers - for (Int_t iLay=0; iLaySetVertex( 0, -fWidth/2, -length/2 - dL1 + dl1Lay - dl1LayS); - lay->SetVertex( 1, fWidth/2, -length/2 + dL1 + dl1Lay - dl1LayS); + lay->SetVertex( 1, -fWidth/2, length/2 + dL2 - dl2Lay + dl2LayS); lay->SetVertex( 2, fWidth/2, length/2 - dL2 - dl2Lay + dl2LayS); - lay->SetVertex( 3, -fWidth/2, length/2 + dL2 - dl2Lay + dl2LayS); + lay->SetVertex( 3, fWidth/2, -length/2 + dL1 + dl1Lay - dl1LayS); lay->SetVertex( 4, -fWidth/2, -length/2 - dL1 - dl1Lay - dl1LayS); - lay->SetVertex( 5, fWidth/2, -length/2 + dL1 - dl1Lay - dl1LayS); + lay->SetVertex( 5, -fWidth/2, length/2 + dL2 + dl2Lay + dl2LayS); lay->SetVertex( 6, fWidth/2, length/2 - dL2 + dl2Lay + dl2LayS); - lay->SetVertex( 7, -fWidth/2, length/2 + dL2 + dl2Lay + dl2LayS); + lay->SetVertex( 7, fWidth/2, -length/2 + dL1 - dl1Lay - dl1LayS); TGeoVolume *vLay = new TGeoVolume("vCableSegLay", lay, fLayMedia[iLay]); vLay->SetLineColor(fLayColor[iLay]); @@ -463,10 +826,88 @@ TGeoVolume *AliITSv11GeomCableFlat::CreateSegment( Double_t *coord1, vCableSeg->AddNode(vLay, iLay+1, fTranslation[iLay]); }; - vCableSeg->SetVisibility(kFALSE); + //vCableSeg->SetVisibility(kFALSE); return vCableSeg; -}; +} +//________________________________________________________________________ +TGeoVolume *AliITSv11GeomCableFlat::CreateCylSegment(const Double_t &phi, + const Double_t &r) +{ + // Create a segment in shape of a cylinder, allows to represent + // a folded flat cable + + Double_t phi1 = 360-phi; + Double_t phi2 = 360+phi; + + Double_t rMin = r-fThick/2; + Double_t rMax = r+fThick/2; + //================================================= + // Create the segment + + TGeoTubeSeg *cableSeg = new TGeoTubeSeg(rMin, rMax, fWidth/2, + phi1, phi2); + TGeoVolume *vCableSeg = new TGeoVolume(GetName(), cableSeg, fLayMedia[fNlayer-1]); + vCableSeg->SetLineColor(fLayColor[fNlayer-1]); + + // add all cable layers but the last + for (Int_t iLay=0; iLaySetLineColor(fLayColor[iLay]); + + vCableSeg->AddNode(vLay, iLay+1, 0); + }; + + //vCableSeg->SetVisibility(kFALSE); + return vCableSeg; +} + +//________________________________________________________________________ +TGeoVolume *AliITSv11GeomCableFlat::CreateBoxSegment( const Double_t *coord1, + const Double_t *coord2) +{ + // Create a segment for the case it is a simple box + //================================================= + Double_t dx = coord2[0]-coord1[0]; + Double_t dy = coord2[1]-coord1[1]; + Double_t dz = coord2[2]-coord1[2]; + Double_t length = TMath::Sqrt(dx*dx+dy*dy+dz*dz); + + TGeoBBox *cableSeg = new TGeoBBox(fWidth/2, length/2, fThick/2); + TGeoVolume *vCableSeg = new TGeoVolume(GetName(), cableSeg, fLayMedia[fNlayer-1]); + vCableSeg->SetLineColor(fLayColor[fNlayer-1]); + // This volume is the cable container. It codes also the material for the + // last layer + + // add all cable layers but the last one + for (Int_t iLay=0; iLaySetLineColor(fLayColor[iLay]); + + if (fTranslation[iLay]==0) + fTranslation[iLay] = new TGeoTranslation(0, 0, ztr); + vCableSeg->AddNode(vLay, iLay+1, fTranslation[iLay]); + }; + + //vCableSeg->SetVisibility(kFALSE); + return vCableSeg; +} //________________________________________________________________________ void AliITSv11GeomCableFlat::SetNLayers(Int_t nLayers) { @@ -481,7 +922,7 @@ void AliITSv11GeomCableFlat::SetNLayers(Int_t nLayers) { fLayMedia[i] = 0; }; }; -}; +} //________________________________________________________________________ Int_t AliITSv11GeomCableFlat::SetLayer(Int_t nLayer, Double_t thick, @@ -511,4 +952,4 @@ Int_t AliITSv11GeomCableFlat::SetLayer(Int_t nLayer, Double_t thick, fLayColor[nLayer] = color; fTranslation[nLayer] = 0; return kTRUE; -}; +}