]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSv11GeomCableFlat.cxx
add getter to cut on n cells
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeomCableFlat.cxx
index c5fa23dbc69d99555bba8432f408592a75d84bf3..8053822372d570d0b4cde22bb41753f391ccec47 100644 (file)
@@ -13,6 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+// $Id$
 
 //*************************************************************************
 //   Class for flat cables
@@ -54,6 +55,7 @@ AliITSv11GeomCableFlat::AliITSv11GeomCableFlat():
     fLayColor[i]     = 0;
     fLayMedia[i]     = 0;  
  };
+  for(Int_t i=0;i<3;i++)fPreviousX[i]=0.;
 }
 
 //________________________________________________________________________
@@ -71,8 +73,9 @@ AliITSv11GeomCableFlat(const char* name, Double_t width, Double_t thick) :
     fLayColor[i]     = 0;
     fLayMedia[i]     = 0;  
   }; 
+  for(Int_t i=0;i<3;i++)fPreviousX[i]=0.;
 }
-
+/*
 //________________________________________________________________________
 AliITSv11GeomCableFlat::AliITSv11GeomCableFlat(const AliITSv11GeomCableFlat &s) :
   AliITSv11GeomCable(s),fWidth(s.fWidth),fThick(s.fThick),fNlayer(s.fNlayer)
@@ -84,6 +87,8 @@ AliITSv11GeomCableFlat::AliITSv11GeomCableFlat(const AliITSv11GeomCableFlat &s)
     fLayMedia[i] = s.fLayMedia[i];
     fLayColor[i] = s.fLayColor[i];
   }
+  for(Int_t i=0;i<3;i++)fPreviousX[i]=s.fPreviousX[i];
+
 }
 
 //________________________________________________________________________
@@ -105,7 +110,7 @@ operator=(const AliITSv11GeomCableFlat &s) {
   };
   return *this;
 }
-
+*/
 //________________________________________________________________________
 Int_t AliITSv11GeomCableFlat::GetPoint( Int_t iCheckPt, Double_t *coord)
   const {
@@ -123,7 +128,6 @@ Int_t AliITSv11GeomCableFlat::GetPoint( Int_t iCheckPt, Double_t *coord)
   };
 }
 
-
 //________________________________________________________________________
 Int_t AliITSv11GeomCableFlat::GetVect( Int_t iCheckPt, Double_t *coord)
   const {
@@ -142,7 +146,6 @@ Int_t AliITSv11GeomCableFlat::GetVect( Int_t iCheckPt, Double_t *coord)
   };
 }
 
-
 //________________________________________________________________________
 void AliITSv11GeomCableFlat::AddCheckPoint( TGeoVolume *vol, Int_t iCheckPt,
                                            Double_t *coord, Double_t *orthVect)
@@ -186,7 +189,8 @@ void AliITSv11GeomCableFlat::PrintCheckPoints() const {
 
 //________________________________________________________________________
 TGeoVolume* AliITSv11GeomCableFlat::CreateAndInsertCableSegment(Int_t p2,
-                                                         Double_t rotation)
+                                                               Double_t rotation,
+                                                               TGeoCombiTrans** ct)
 {
 //    Creates a cable segment between points p1 and p2.
 //    Rotation is the eventual rotation of the flat cable
@@ -301,7 +305,6 @@ TGeoVolume* AliITSv11GeomCableFlat::CreateAndInsertCableSegment(Int_t p2,
   //-- order to match as closer as possible this segment and the 
   //-- previous one. 
   //-- It seems that some times it doesn't work ...
-  Double_t angleRotZ = 0;
   TGeoRotation rotTemp("",angleRot1*TMath::RadToDeg(),
                       angleRotDiag*TMath::RadToDeg(), rotation);
   Double_t localX[3] = {0,1,0};
@@ -311,28 +314,29 @@ TGeoVolume* AliITSv11GeomCableFlat::CreateAndInsertCableSegment(Int_t p2,
   GetCheckVect(localX, p2Vol, 0, fgkCableMaxNodeLevel+1, globalX);
   Double_t orthVect[3];
   GetCheckVect(vect1, p2Vol, 0, fgkCableMaxNodeLevel+1, orthVect);
-  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();
-  };
+//   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 = " <<angleRotZ << endl;
   CopyFrom(fPreviousX, globalX);
   //---
@@ -350,8 +354,6 @@ TGeoVolume* AliITSv11GeomCableFlat::CreateAndInsertCableSegment(Int_t p2,
   // Create the segment and add it to the mother volume
   TGeoVolume *vCableSegB = CreateSegment(coord1, coord2,
                                         localVect1, localVect2);
-//   TGeoVolume *vCableSegB = CreateBoxSegment(coord1, coord2);
-
   TGeoRotation rotArbSeg("", 0, 90, 0);
   rotArbSeg.MultiplyBy(&rot, kFALSE);
   TGeoTranslation trans("",cx, cy, cz);
@@ -366,7 +368,7 @@ TGeoVolume* AliITSv11GeomCableFlat::CreateAndInsertCableSegment(Int_t p2,
   };
 
 //   #include <TGeoSphere.h>
-//   TGeoMedium *airSDD = gGeoManager->GetMedium("ITS_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);
@@ -377,13 +379,14 @@ TGeoVolume* 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;
 }
 
 //________________________________________________________________________
 TGeoVolume* AliITSv11GeomCableFlat::CreateAndInsertBoxCableSegment(Int_t p2,
-                                                         Double_t rotation)
+                                                                  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
@@ -501,7 +504,6 @@ TGeoVolume* AliITSv11GeomCableFlat::CreateAndInsertBoxCableSegment(Int_t p2,
   //-- order to match as closer as possible this segment and the 
   //-- previous one. 
   //-- It seems that some times it doesn't work ...
-  Double_t angleRotZ = 0;
   TGeoRotation rotTemp("",angleRot1*TMath::RadToDeg(),
                       angleRotDiag*TMath::RadToDeg(), rotation);
   Double_t localX[3] = {0,1,0};
@@ -511,29 +513,29 @@ TGeoVolume* AliITSv11GeomCableFlat::CreateAndInsertBoxCableSegment(Int_t p2,
   GetCheckVect(localX, p2Vol, 0, fgkCableMaxNodeLevel+1, globalX);
   Double_t orthVect[3];
   GetCheckVect(vect1, p2Vol, 0, fgkCableMaxNodeLevel+1, orthVect);
-  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 = " <<angleRotZ << endl;
+//   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];
@@ -563,12 +565,14 @@ TGeoVolume* AliITSv11GeomCableFlat::CreateAndInsertBoxCableSegment(Int_t p2,
     printf("%f, %f, %f\n",coord2[0], coord2[1], coord2[2]);
   };
 
+  if (ct) *ct = combiB;
   return vCableSegB;
 }
 
 //________________________________________________________________________
 TGeoVolume* AliITSv11GeomCableFlat::CreateAndInsertCableCylSegment(Int_t p2,
-                                                         Double_t rotation)
+                                                                  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
@@ -712,7 +716,7 @@ TGeoVolume* AliITSv11GeomCableFlat::CreateAndInsertCableCylSegment(Int_t p2,
   Double_t torusPhi1 = TMath::ACos(cosPhi);
   Double_t torusR = (length/2)/TMath::Sin(torusPhi1);
   torusPhi1 = torusPhi1*TMath::RadToDeg();
-  Double_t perpLength = TMath::Sqrt(torusR*torusR-length*length/4);
+  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);
@@ -732,17 +736,17 @@ TGeoVolume* AliITSv11GeomCableFlat::CreateAndInsertCableCylSegment(Int_t p2,
     printf("%f, %f, %f\n",coord2[0], coord2[1], coord2[2]);
   };
 
+  if (ct) *ct = combiTorus;
   return vCableSegT;
 }
 
-
 //________________________________________________________________________
-TGeoVolume *AliITSv11GeomCableFlat::CreateSegment( Double_t *coord1,
-                                                  Double_t *coord2,
-                                                  Double_t *localVect1,
-                                                  Double_t *localVect2 )
+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];
@@ -774,9 +778,9 @@ 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);
@@ -789,11 +793,11 @@ TGeoVolume *AliITSv11GeomCableFlat::CreateSegment( Double_t *coord1,
   cableSeg->SetVertex( 6,  fWidth/2,  length/2 - dL2 + dl2);
   cableSeg->SetVertex( 7,  fWidth/2, -length/2 + dL1 - dl1);
 
-  TGeoMedium *airSDD = gGeoManager->GetMedium("ITS_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; iLay<fNlayer; iLay++) {
+  // add all cable layers but the last
+  for (Int_t iLay=0; iLay<fNlayer-1; iLay++) {
 
     Double_t dl1Lay = 0.5*fLayThickness[iLay]*tanACosCosPhi1;
     Double_t dl2Lay = 0.5*fLayThickness[iLay]*tanACosCosPhi2;
@@ -822,15 +826,16 @@ TGeoVolume *AliITSv11GeomCableFlat::CreateSegment( Double_t *coord1,
     vCableSeg->AddNode(vLay, iLay+1, fTranslation[iLay]);
   };
 
-  vCableSeg->SetVisibility(kFALSE);
+  //vCableSeg->SetVisibility(kFALSE);
   return vCableSeg;
 }
 
-
 //________________________________________________________________________
-TGeoVolume *AliITSv11GeomCableFlat::CreateCylSegment(Double_t &phi,
-                                                    Double_t &r)
+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;
@@ -842,11 +847,11 @@ TGeoVolume *AliITSv11GeomCableFlat::CreateCylSegment(Double_t &phi,
 
   TGeoTubeSeg *cableSeg = new TGeoTubeSeg(rMin, rMax, fWidth/2,
                                          phi1, phi2);
-  TGeoMedium *airSDD = gGeoManager->GetMedium("ITS_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; iLay<fNlayer; iLay++) {
+  // add all cable layers but the last
+  for (Int_t iLay=0; iLay<fNlayer-1; iLay++) {
  
     Double_t ztr = -fThick/2;
     for (Int_t i=0;i<iLay; i++) ztr+= fLayThickness[i];
@@ -862,30 +867,29 @@ TGeoVolume *AliITSv11GeomCableFlat::CreateCylSegment(Double_t &phi,
     vCableSeg->AddNode(vLay, iLay+1, 0);
   };
 
-  vCableSeg->SetVisibility(kFALSE);
+  //vCableSeg->SetVisibility(kFALSE);
   return vCableSeg;
 }
 
-
 //________________________________________________________________________
-TGeoVolume *AliITSv11GeomCableFlat::CreateBoxSegment( Double_t *coord1,
-                                                     Double_t *coord2)
+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
 
-  TGeoMedium *airSDD = gGeoManager->GetMedium("ITS_ITSair");
-  TGeoVolume *vCableSeg = new TGeoVolume(GetName(), cableSeg, airSDD);
-
-  // add all cable layers
-  for (Int_t iLay=0; iLay<fNlayer; iLay++) {
+  // add all cable layers but the last one
+  for (Int_t iLay=0; iLay<fNlayer-1; iLay++) {
  
     Double_t ztr = -fThick/2;
     for (Int_t i=0;i<iLay; i++) ztr+= fLayThickness[i];
@@ -893,7 +897,6 @@ TGeoVolume *AliITSv11GeomCableFlat::CreateBoxSegment( Double_t *coord1,
 
     TGeoBBox *lay = new  TGeoBBox(fWidth/2, length/2, fLayThickness[iLay]/2);
 
-
     TGeoVolume *vLay = new TGeoVolume("vCableSegLay", lay, fLayMedia[iLay]);
     vLay->SetLineColor(fLayColor[iLay]);
     
@@ -902,7 +905,7 @@ TGeoVolume *AliITSv11GeomCableFlat::CreateBoxSegment( Double_t *coord1,
     vCableSeg->AddNode(vLay, iLay+1, fTranslation[iLay]);
   };
 
-  vCableSeg->SetVisibility(kFALSE);
+  //vCableSeg->SetVisibility(kFALSE);
   return vCableSeg;
 }