]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSv11GeometrySPD.cxx
Code cleanup: elimination of hard coded numbers
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySPD.cxx
index 663e10927fa7f76a0b9a76b42b31236eaa4020ad..01c5aad47e70277558ee4044bbc36b0b8293fc8a 100644 (file)
 // and cable trays on both the RB26 (muon dump) and RB24 sides, and all of
 // the cabling from the ladders/stave ends out past the TPC. 
 
-/* $Id$ */
 // General Root includes
 #include <Riostream.h>
 #include <TMath.h>
 #include <TLatex.h>
 #include <TCanvas.h>
-#include <TView.h>
 #include <TPolyLine.h>
 // Root Geometry includes
-#include <TGeoManager.h>
 #include <TGeoVolume.h>
 #include <TGeoPcon.h>
 #include <TGeoCone.h>
 #include <TGeoXtru.h>
 #include <TGeoCompositeShape.h>
 #include <TGeoMatrix.h>
+#include <TGeoMaterial.h>
+#include <TGeoMedium.h>
+#include "AliMagF.h"
+#include "AliRun.h"
+//#include <TGeoRotation.h>
+//#include <TGeoCombiTrans.h>
+//#include <TGeoTranslation.h>
 #include "AliITSv11GeometrySPD.h"
 
 ClassImp(AliITSv11GeometrySPD)
@@ -47,104 +51,309 @@ ClassImp(AliITSv11GeometrySPD)
 #define SQ(A) (A)*(A)
 
 //______________________________________________________________________
-AliITSv11GeometrySPD::AliITSv11GeometrySPD() : 
-AliITSv11Geometry(),
-fSPDSensitiveVolumeName("ITSSPDDetectorSensitiveVolume"),
-fThickDetector(0.0),
-fThickChip(0.0){
-    // Default Constructor for the AliITSv11GeometrySPD
-    // Inputs:
-    //   none.
+Int_t AliITSv11GeometrySPD::CreateSPDCenteralMaterials(Int_t &medOffset,
+                                                      Int_t &matOffset){
+    // Define the specific materials used for the ITS SPD centeral
+    // detectors. Note, These are the same old names. By the ALICE
+    // naming convension, these should start out at ITS SPD ....
+    // This data has been taken from AliITSvPPRasymmFMD::CreateMaterials().
+    // Intputs:
+    //    Int_t  &medOffset   The starting number of the list of media
+    //    Int_t  &matOffset   The starting number of the list of Materials
     // Outputs:
-    //   none.
+    //    Int_t  &medOffset   The ending number of the list of media
+    //    Int_t  &matOffset   The ending number of the list of Materials
     // Return:
-    //   One Default Constructed AliITSv11GeometrySPD class
+    //    the last material number used +1 (the next avaiable material number).
+    //Begin_Html
+    /*
+      <img src="http://alice.pd.infn.it/latestdr/all-sections-module.ps"
+       title="SPD Sector drawing with all cross sections defined">
+       <p>The SPD Sector definition.
+      <img src="http://alice.pd.infn.it/latestdr/assembly-10-modules.ps"
+      titile="SPD All Sectors end view with thermal sheald">
+      <p>The SPD all sector end view with thermal sheald.
+      <img src="http://alice.pd.infn.it/latestdr/assembly.ps"
+      title="SPD side view cross section">
+      <p>SPD side view cross section with condes and thermal shealds.
+      <img src="http://alice.pd.infn.it/latestdr/SECTION-A_A.jpg"
+      title="Cross setion A-A"><p>Cross section A-A
+      <img src="http://alice.pd.infn.it/latestdr/SECTION-B_B.jpg"
+      title="Cross section B-B"><p>Cross section B-B
+      <img src="http://alice.pd.infn.it/latestdr/SECTION-C_C.jpg"
+      title-"Cross section C-C"><p>Cross section C-C
+      <img src="http://alice.pd.infn.it/latestdr/SECTION-D_D.jpg"
+      title="Cross section D-D"><p>Cross section D-D
+      <img src="http://alice.pd.infn.it/latestdr/SECTION-F_F.jpg"
+      title="Cross section F-F"><p>Cross section F-F
+      <img src="http://alice.pd.infn.it/latestdr/SECTION-G_G.jpg"
+      title="Cross section G-G"><p>Cross section G-G
+     */
+    //End_Html
+    const Double_t ktmaxfd = 0.1*fgkDegree; // Degree
+    const Double_t kstemax = 1.0*fgkcm; // cm
+    const Double_t kdeemax = 0.1; // Fraction of particle's energy 0<deemax<=1
+    const Double_t kepsil  = 1.0E-4; //
+    const Double_t kstmin  = 0.0*fgkcm; // cm "Default value used"
+    const Double_t ktmaxfdAir = 0.1*fgkDegree; // Degree
+    const Double_t kstemaxAir = 1.0000E+00*fgkcm; // cm
+    const Double_t kdeemaxAir = 0.1; // Fraction of particle's energy 0<deemax<=1
+    const Double_t kepsilAir  = 1.0E-4;//
+    const Double_t kstminAir  = 0.0*fgkcm; // cm "Default value used"
+    const Double_t ktmaxfdSi = 0.1*fgkDegree; // .10000E+01; // Degree
+    const Double_t kstemaxSi = 0.0075*fgkcm; //  .10000E+01; // cm
+    const Double_t kdeemaxSi = 0.1; // Fraction of particle's energy 0<deemax<=1
+    const Double_t kepsilSi  = 1.0E-4;//
+    const Double_t kstminSi  = 0.0*fgkcm; // cm "Default value used"
+    //
+    Int_t matindex=matOffset;
+    Int_t medindex=medOffset;
+    Double_t params[8]={8*0.0};
+    TGeoMaterial *mat;
+    TGeoMixture  *mix;
+    TGeoMedium   *med;
+    //
+    Int_t    ifield = (gAlice->Field()->Integ());
+    Double_t fieldm = (gAlice->Field()->Max());
+    params[1] = (Double_t) ifield;
+    params[2] = fieldm;
+    params[3] = ktmaxfdSi;
+    params[4] = kstemaxSi;
+    params[5] = kdeemaxSi;
+    params[6] = kepsilSi;
+    params[7] = kstminSi;
 
-    fThickDetector = fkLadDetectorThick;
-    fThickChip     = fkLadChipHight;
+    mat = new TGeoMaterial("SI",28.086,14.0,2.33*fgkgcm3,
+                          TGeoMaterial::kMatStateSolid,25.0*fgkCelsius,
+                          0.0*fgkPascal);
+    mat->SetIndex(matindex);
+    med = new TGeoMedium("SI",medindex++,mat,params);
+    //med = new TGeoMedium("SI",medindex++,matindex++,0,ifield,
+    //          fieldm,ktmaxfdSi,kstemaxSi,kdeemaxSi,kepsilSi,kstminSi);
+    //
+    mat = new TGeoMaterial("SPD SI CHIP",28.086,14.0,2.33*fgkgcm3,
+                          TGeoMaterial::kMatStateSolid,25.0*fgkCelsius,
+                          0.0*fgkPascal);
+    mat->SetIndex(matindex);
+    med = new TGeoMedium("SPD SI CHIP",medindex++,mat,params);
+    //med = new TGeoMedium("SPD SI CHIP",medindex++,matindex++,0,ifield,
+    //          fieldm,ktmaxfdSi,kstemaxSi,kdeemaxSi,kepsilSi,kstminSi);
+    //
+    mat = new TGeoMaterial("SPD SI BUS",28.086,14.0,2.33*fgkgcm3,
+                          TGeoMaterial::kMatStateSolid,25.0*fgkCelsius,
+                          0.0*fgkPascal);
+    mat->SetIndex(matindex);
+    med = new TGeoMedium("SPD SI BUS",medindex++,mat,params);
+    //med = new TGeoMedium("SPD SI BUS",medindex++,matindex++,0,ifield,
+    //          fieldm,ktmaxfdSi,kstemaxSi,kdeemaxSi,kepsilSi,kstminSi);
+    //
+    mix = new TGeoMixture("C (M55J)",4,1.9866*fgkgcm3);// Carbon fiber by fractional weight "C (M55J)"
+    mix->SetIndex(matindex);
+    mix->DefineElement(0,12.0107,6.0,0.908508078); // Carbon by fractional weight
+    mix->DefineElement(1,14.0067,7.0,0.010387573); // Nitrogen by fractional weight
+    mix->DefineElement(2,15.9994,8.0,0.055957585); // Oxigen by fractional weight
+    mix->DefineElement(3,1.00794,1.0,0.025146765); // Hydrogen by fractional weight
+    mix->SetPressure(0.0*fgkPascal);
+    mix->SetTemperature(25.0*fgkCelsius);
+    mix->SetState(TGeoMaterial::kMatStateSolid);
+    params[3] = ktmaxfd;
+    params[4] = kstemax;
+    params[5] = kdeemax;
+    params[6] = kepsil;
+    params[7] = kstmin;
+    med = new TGeoMedium("ITSspdCarbonFiber",medindex++,mix,params);
+    //med = new TGeoMedium("ITSspdCarbonFiber",medindex++,matindex++,0,ifield,
+    //          fieldm,ktmaxfd,kstemax,kdeemax,kepsil,kstmin);
+    //
+    mix = new TGeoMixture("Air",4,1.20479E-3*fgkgcm3);// Carbon fiber by fractional weight
+    mix->SetIndex(matindex);
+    mix->DefineElement(0,12.0107,6.0,0.000124); // Carbon by fractional weight
+    mix->DefineElement(1,14.0067,7.0,0.755267); // Nitrogen by fractional weight
+    mix->DefineElement(2,15.9994,8.0,0.231781); // Oxigen by fractional weight
+    mix->DefineElement(3,39.948,18.0,0.012827); // Argon by fractional weight
+    mix->SetPressure(101325.0*fgkPascal); // 1 atmosphere
+    mix->SetTemperature(25.0*fgkCelsius);
+    mix->SetState(TGeoMaterial::kMatStateGas);
+    params[3] = ktmaxfdAir;
+    params[4] = kstemaxAir;
+    params[5] = kdeemaxAir;
+    params[6] = kepsilAir;
+    params[7] = kstminAir;
+    med = new TGeoMedium("ITSspdAir",medindex++,mix,params);
+    //med = new TGeoMedium("ITSspdAir",medindex++,matindex++,0,ifield,
+    //        fieldm,ktmaxfdAir,kstemaxAir,kdeemaxAir,kepsilAir,kstminAir);
+    //
+    mix = new TGeoMixture("INOX",9,8.03*fgkgcm3);// Carbon fiber by fractional weight
+    mix->SetIndex(matindex);
+    mix->DefineElement(0,12.0107, 6.0,0.0003); // Carbon by fractional weight
+    mix->DefineElement(1,54.9380,25.0,0.02); // Iron by fractional weight
+    mix->DefineElement(2,28.0855,14.0,0.01); // Sodium by fractional weight
+    mix->DefineElement(3,30.9738,15.0,0.00045); //  by fractional weight
+    mix->DefineElement(4,32.066 ,16.0,0.0003); // by fractional weight
+    mix->DefineElement(5,58.6928,28.0,0.12); // Nickel by fractional weight
+    mix->DefineElement(6,55.9961,24.0,0.17); // by fractional weight
+    mix->DefineElement(7,95.84  ,42.0,0.025); // by fractional weight
+    mix->DefineElement(8,55.845 ,26.0,0.654); // by fractional weight
+    mix->SetPressure(0.0*fgkPascal); //
+    mix->SetTemperature(25.0*fgkCelsius);
+    mix->SetState(TGeoMaterial::kMatStateSolid);
+    params[3] = ktmaxfdAir;
+    params[4] = kstemaxAir;
+    params[5] = kdeemaxAir;
+    params[6] = kepsilAir;
+    params[7] = kstminAir;
+    med = new TGeoMedium("ITSspdStainlessSteel",medindex++,mix,params);
+    //med = new TGeoMedium("ITSspdStainlessSteel",medindex++,matindex++,0,ifield,
+    //        fieldm,ktmaxfdAir,kstemaxAir,kdeemaxAir,kepsilAir,kstminAir);
+    //
+    mix = new TGeoMixture("Freon",2,1.63*fgkgcm3);// Carbon fiber by fractional weight
+    mix->SetIndex(matindex);
+    mix->DefineElement(0,12.0107,6.0,4); // Carbon by fractional weight
+    mix->DefineElement(1,18.9984032,9.0,10); // Florine by fractional weight
+    mix->SetPressure(101325.0*fgkPascal); // 1 atmosphere
+    mix->SetTemperature(25.0*fgkCelsius);
+    mix->SetState(TGeoMaterial::kMatStateLiquid);
+    params[3] = ktmaxfdAir;
+    params[4] = kstemaxAir;
+    params[5] = kdeemaxAir;
+    params[6] = kepsilAir;
+    params[7] = kstminAir;
+    med = new TGeoMedium("ITSspdCoolingFluid",medindex++,mix,params);
+    //med = new TGeoMedium("ITSspdCoolingFluid",medindex++,matindex++,0,ifield,
+    //        fieldm,ktmaxfdAir,kstemaxAir,kdeemaxAir,kepsilAir,kstminAir);
+    //
+    medOffset = medindex;
+    matOffset = matindex;
+    return matOffset;
 }
 //______________________________________________________________________
-AliITSv11GeometrySPD::AliITSv11GeometrySPD(Int_t debug) : 
-AliITSv11Geometry(debug),
-fSPDSensitiveVolumeName("ITSSPDDetectorSensitiveVolume"),
-fThickDetector(0.0),
-fThickChip(0.0),
-fkGrdFoilThick(0.05*fgkmm),
-fkGrdFoilWidthA(15.95*fgkmm),
-fkGrdFoilWidthC(4.4*fgkmm),
-fkGrdFoilLngA(139.89*fgkmm),
-fkGrdFoilLngB(11.55*fgkmm),
-fkGrdFoilLngC(82.0*fgkmm),
-fkGrdFoilNholesAB(5),
-fkGrdFoilHoleCenterAB(7.8*fgkmm),
-fkGrdFoilHoleLengthAB(12.0*fgkmm),
-fkGrdFoilHoleWidthAB(7.5*fgkmm),
-fkGrdFoilHoleSpacingAB(14.0*fgkmm),
-fkGrdFoilHoleStartA(1.36*fgkmm),
-fkGrdFoilHoleStartB(73.08*fgkmm),
- // Ladder
-fkLadNChips(5),
-fkLadChipWidth(15950.0*fgkmicron),
-fkLadChipHight(150.0*fgkmicron),
-fkLadChipLength(13490.0*fgkmicron),
-fkLadGlue0Thick(0.100*fgkmm),
-fkLadBumpBondThick(30.0*fgkmicron),
-fkLadDetectorWidth(13700.0*fgkmicron),
-fkLadDetectorThick(200.0*fgkmicron),
-fkLadDetectorLength(70710.0*fgkmicron),
-fkLadSensDetWidth(12800.0*fgkmicron),
-fkLadSensDetThick(200.0*fgkmicron),
-fkLadSensDetLength(69490.0*fgkmicron),
-fkLadChipSpacing0(610.0*fgkmicron),
-fkLadChipSpacing1((fkLadDetectorLength-(2.*fkLadChipSpacing0+
-        ((Double_t)fkLadNChips)*fkLadChipLength))/((Double_t)(fkLadNChips-1)))
-{
-    // Default Constructor for the AliITSv11GeometrySPD
-    // Inputs:
-    //   none.
+void AliITSv11GeometrySPD::InitSPDCenteral(Int_t offset,TVirtualMC *vmc){
+    // Do any SPD Centeral detector related initilizations, setting
+    // transport cuts for example.
+    // Some GEANT3 Physics switches
+    // "MULTS"
+    // Multiple scattering. The variable IMULS controls this process. For 
+    // more information see [PHYS320 or 325 or 328].
+    // 0 - No multiple scattering.
+    // 1 - Multiple scattering according to Molière theory. Default setting.
+    // 2 - Same as 1. Kept for backward compatibility.
+    // 3 - Pure Gaussian scattering according to the Rossi formula.
+    // "DRAY"
+    // delta ray production. The variable IDRAY controls this process. See [PHYS430]
+    // 0 - No delta rays production.
+    // 1 - delta rays production with generation of . Default setting.
+    // 2 - delta rays production without generation of .
+    // "LOSS"
+    // Continuous energy loss. The variable ILOSS controls this process.
+    // 0 - No continuous energy loss, IDRAY is set to 0.
+    // 1 - Continuous energy loss with generation of delta rays above 
+    //     DCUTE (common/GCUTS/) and restricted Landau fluctuations below  DCUTE.
+    // 2 - Continuous energy loss without generation of delta rays and full 
+    //     Landau-Vavilov-Gauss fluctuations. In this case the variable IDRAY 
+    //     is forced to 0 to avoid double counting of fluctuations. Default setting.
+    // 3 - Same as 1, kept for backward compatibility.
+    // 4 - Energy loss without fluctuation. The value obtained from the tables is 
+    //     used directly.
+    // Intputs:
+    //    Int_t       offset The material/medium index offset.
+    //    TVirturalMC *vmc The pointer to the virtual Monte Carlo default gMC.
     // Outputs:
-    //   none.
+    //    none.
     // Return:
-    //   One Default Constructed AliITSv11GeometrySPD class
+    //    none.
+    Int_t i,n=4;
 
-    fThickDetector = fkLadDetectorThick;
-    fThickChip     = fkLadChipHight;
+    for(i=0;i<n;i++){
+      vmc->Gstpar(i+offset,"CUTGAM",30.0*fgkKeV);
+      vmc->Gstpar(i+offset,"CUTELE",30.0*fgkKeV);
+      vmc->Gstpar(i+offset,"CUTNEU",30.0*fgkKeV);
+      vmc->Gstpar(i+offset,"CUTHAD",30.0*fgkKeV);
+      vmc->Gstpar(i+offset,"CUTMUO",30.0*fgkKeV);
+      vmc->Gstpar(i+offset,"BCUTE",30.0*fgkKeV);
+      vmc->Gstpar(i+offset,"BCUTM",30.0*fgkKeV);
+      vmc->Gstpar(i+offset,"DCUTE",30.0*fgkKeV);
+      vmc->Gstpar(i+offset,"DCUTM",30.0*fgkKeV);
+      //vmc->Gstpar(i+offset,"PPCUTM",);
+      //vmc->Gstpar(i+offset,"PAIR",);
+      //vmc->Gstpar(i+offset,"COMPT",);
+      //vmc->Gstpar(i+offset,"PHOT",);
+      //vmc->Gstpar(i+offset,"PFIS",);
+      vmc->Gstpar(i+offset,"DRAY",1);
+      //vmc->Gstpar(i+offset,"ANNI",);
+      //vmc->Gstpar(i+offset,"BREM",);
+      //vmc->Gstpar(i+offset,"HADR",);
+      //vmc->Gstpar(i+offset,"MUNU",);
+      //vmc->Gstpar(i+offset,"DCAY",);
+      vmc->Gstpar(i+offset,"LOSS",1);
+      //vmc->Gstpar(i+offset,"MULS",);
+      //vmc->Gstpar(i+offset,"GHCOR1",);
+      //vmc->Gstpar(i+offset,"BIRK1",);
+      //vmc->Gstpar(i+offset,"BRIK2",);
+      //vmc->Gstpar(i+offset,"BRIK3",);
+      //vmc->Gstpar(i+offset,"LABS",);
+      //vmc->Gstpar(i+offset,"SYNC",);
+      //vmc->Gstpar(i+offset,"STRA",);
+    } // end for i
 }
 //______________________________________________________________________
-TGeoVolume* AliITSv11GeometrySPD::CenteralSPD(TGeoVolume *moth){
-    // Define The Centeral part of the SPD detector.
+void AliITSv11GeometrySPD::SPDSector(TGeoVolume *moth,TGeoManager *mgr){
+    // Position of the Carbon Fiber Assembly based on distance
+    // of closest point of SPD stave to beam pipe figures
+    // all-sections-modules.ps of 7.22mm at section A-A.
     // Inputs:
-    //   TGeoVolume* moth
+    //   TGeoVolume *moth   the mother volume which this
+    //                      object/volume is to be placed in.
     // Outputs:
-    //  none.
+    //   none.
     // Return:
-    //  TGeoVolume * moth
-    Int_t i=2;
-    TGeoVolume *vHSGF,*vLad,*vMoth;
-    TGeoTube *tube;
-
-    tube = new TGeoTube("ITSSPD Temp SPD Mother voluem",0.0,7.0,17.0);
-    vMoth = new TGeoVolume("ITSSPDTempSPDMotherVolume",tube,0);
-
-    moth->AddNode(vMoth,1,0);
-    switch(i){
-    case 0:
-        CarbonFiberSector(vMoth);
-        break;
-    case 1:
-        vHSGF = CreateHalfStaveGroundFoil();
-        vMoth->AddNode(vHSGF,1,0);
-        break;
-    case 2:
-        vLad  = CreateSPDLadder();
-        vMoth->AddNode(vLad,1,0);
-        break;
-    } // end sithch
+    //   none.
+    const Double_t kSPDclossesStaveAA    = 7.22*fgkmm;
+    const Double_t kSectorStartingAngle  = -72.0*fgkDegree;
+    const Double_t kNSectorsTotal        = 10.; // number
+    const Double_t kSectorRelativeAngle  = 360./kNSectorsTotal*fgkDegree;
+    const Double_t kBeamPipeRadius       = 0.5*60.0*fgkmm;
+    //
+    Int_t i;
+    Double_t angle,radiusSector,xAAtubeCenter0,yAAtubeCenter0;
+    Double_t staveThicknessAA=1.03*fgkmm; // get from stave geometry.
+    TGeoCombiTrans *secRot=new TGeoCombiTrans();
+    TGeoVolume *vCarbonFiberSector;
+    TGeoMedium *medSPDcf;
 
-    return moth;
+    medSPDcf = mgr->GetMedium("ITSspdCarbonFiber");
+    vCarbonFiberSector = new TGeoVolumeAssembly("ITSSPDCarbonFiberSectorV");
+    vCarbonFiberSector->SetMedium(medSPDcf);
+    CarbonFiberSector(vCarbonFiberSector,xAAtubeCenter0,yAAtubeCenter0);
+    vCarbonFiberSector->SetVisibility(kFALSE); // logical volume
+    // Compute the radial shift out of the sectors.
+    radiusSector = kBeamPipeRadius+kSPDclossesStaveAA+staveThicknessAA;
+    radiusSector *= radiusSector; // squaring;
+    radiusSector -= xAAtubeCenter0*xAAtubeCenter0;
+    radiusSector = -yAAtubeCenter0+TMath::Sqrt(radiusSector);
+    angle = kSectorStartingAngle;
+    secRot->RotateZ(angle);
+    for(i=0;i<(Int_t)kNSectorsTotal;i++){
+        secRot->SetDx(-radiusSector*TMath::Sin(angle/fgkRadian));
+        secRot->SetDy(radiusSector*TMath::Cos(angle/fgkRadian));
+        //secRot->RegisterYourself();
+        moth->AddNode(vCarbonFiberSector,i+1,new TGeoCombiTrans(*secRot));
+        printf("i=%d angle=%g angle[rad]=%g radiusSector=%g x=%g y=%g \n",
+               i,angle,angle/fgkRadian,radiusSector,
+               -radiusSector*TMath::Sin(angle/fgkRadian),
+               radiusSector*TMath::Cos(angle/fgkRadian));
+        angle += kSectorRelativeAngle;
+        secRot->RotateZ(kSectorRelativeAngle);
+    } // end for i
+    if(GetDebug()){
+        moth->PrintNodes();
+    } // end if GetDebug().
+    delete secRot;
 }
 //______________________________________________________________________
-TGeoVolume* AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth){
+void AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth,
+                                            Double_t &xAAtubeCenter0,
+                                            Double_t &yAAtubeCenter0,
+                                            TGeoManager *mgr){
     // Define the detail SPD Carbon fiber support Sector geometry.
     // Based on the drawings ALICE-Pixel "Construzione Profilo Modulo"
     // March 25 2004 and ALICE-SUPPORTO "construzione Profilo Modulo"
@@ -152,13 +361,28 @@ TGeoVolume* AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth){
     // center of the arc is outside of the object.
     // February 16 2004.
     // Inputs:
-    //   TGeoVolume* moth   The mother volume which this object is to be
-    //                      placed in
+    //   TGeoVolume *moth  The mother volume to put this object
     // Outputs:
-    //  none.
+    //  Double_t &xAAtubeCenter0  The x location of the outer surface
+    //                            of the cooling tube center for tube 0.
+    //                            This location helps determine where 
+    //                            this sector is to be located (information
+    //                            used for this is the distance the
+    //                            center of the #0 detector is from the
+    //                            beam pipe. Measurements taken at 
+    //                            cross section A-A.
+    //  Double_t &yAAtubeCenter0  The y location of the outer surface
+    //                            of the cooling tube center for tube 0
+    //                            This location helps determine where
+    //                            this sector is to be located (information
+    //                            used for this is the distance the 
+    //                            center of the #0 detector is from the
+    //                            beam pipe. Measurements taken at 
+    //                            cross section A-A.
+    //   TGeoManager *mgr         The TGeoManager as needed, default is
+    //                            gGeoManager.
     // Return:
-    //  TGeoVolume*
-    TGeoManager *mgr = gGeoManager;
+    //  none.
     TGeoMedium *medSPDcf  = 0; // SPD support cone Carbon Fiber materal number.
     //TGeoMedium *medSPDfs  = 0; // SPD support cone inserto stesalite 4411w.
     //TGeoMedium *medSPDfo  = 0; // SPD support cone foam, Rohacell 50A.
@@ -169,7 +393,7 @@ TGeoVolume* AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth){
     medSPDcf = mgr->GetMedium("ITSspdCarbonFiber");
     //medSPDfs = mgr->GetMedium("ITSspdStaselite4411w");
     //medSPDfo = mgr->GetMedium("ITSspdRohacell50A");
-    medSPDss = mgr->GetMedium("ITSspdStainlessSteal");
+    medSPDss = mgr->GetMedium("ITSspdStainlessSteel");
     medSPDair= mgr->GetMedium("ITSspdAir");
     medSPDcoolfl= mgr->GetMedium("ITSspdCoolingFluid");
     //
@@ -179,7 +403,15 @@ TGeoVolume* AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth){
     const Double_t ksecDipLength = 3.2*fgkmm;
     const Double_t ksecDipRadii  = 0.4*fgkmm;
     //const Double_t ksecCoolingTubeExtraDepth = 0.86*fgkmm;
-    //
+    // These positions, ksecX*,ksecY* are the center of curvatures
+    // for the different point around the SPD sector. The radii,
+    // inner and outer, are the radous of curvature about the centers
+    // ksecX* and ksecY*. To draw this SPD sector, first plot all of
+    // the ksecX and ksecY points and draw circles of the specified
+    // radius about these points. Connect the circles, such that the
+    // lines are tangent to the circles, in accordance with the
+    // radii being "Inside" or "Outside". These lines and the 
+    // corresponding arc's are the surface of this SPD sector.
     const Double_t ksecX0   = -10.725*fgkmm;
     const Double_t ksecY0   = -14.853*fgkmm;
     const Double_t ksecR0   = -0.8*fgkmm; // Outside
@@ -269,32 +501,32 @@ TGeoVolume* AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth){
     //
     const Int_t ksecNPoints = (ksecNPointsPerRadii+1)*ksecNRadii + 8;
     Double_t secX[ksecNRadii] = {ksecX0,ksecX1,-1000.0,ksecX2 ,ksecX3 ,-1000.0,
-                                 ksecX4,ksecX5,-1000.0,ksecX6 ,ksecX7 ,-1000.0,
-                                 ksecX8,ksecX9,-1000.0,ksecX10,ksecX11,-1000.0,
-                                 ksecX12,-1000.0};
+                                ksecX4,ksecX5,-1000.0,ksecX6 ,ksecX7 ,-1000.0,
+                                ksecX8,ksecX9,-1000.0,ksecX10,ksecX11,-1000.0,
+                                ksecX12,-1000.0};
     Double_t secY[ksecNRadii] = {ksecY0,ksecY1,-1000.0,ksecY2 ,ksecY3 ,-1000.0,
-                                 ksecY4,ksecY5,-1000.0,ksecY6 ,ksecY7 ,-1000.0,
-                                 ksecY8,ksecY9,-1000.0,ksecY10,ksecY11,-1000.0,
-                                 ksecY12,-1000.0};
+                                ksecY4,ksecY5,-1000.0,ksecY6 ,ksecY7 ,-1000.0,
+                                ksecY8,ksecY9,-1000.0,ksecY10,ksecY11,-1000.0,
+                                ksecY12,-1000.0};
     Double_t secR[ksecNRadii] ={ksecR0 ,ksecR1 ,-.5*ksecDipLength-ksecDipRadii,
-                                ksecR2 ,ksecR3 ,-.5*ksecDipLength-ksecDipRadii,
-                                ksecR4 ,ksecR5 ,-.5*ksecDipLength-ksecDipRadii,
-                                ksecR6 ,ksecR7 ,-.5*ksecDipLength-ksecDipRadii,
-                                ksecR8 ,ksecR9 ,-.5*ksecDipLength-ksecDipRadii,
-                                ksecR10,ksecR11,-.5*ksecDipLength-ksecDipRadii,
-                                ksecR12,ksecR13};/*
+                               ksecR2 ,ksecR3 ,-.5*ksecDipLength-ksecDipRadii,
+                               ksecR4 ,ksecR5 ,-.5*ksecDipLength-ksecDipRadii,
+                               ksecR6 ,ksecR7 ,-.5*ksecDipLength-ksecDipRadii,
+                               ksecR8 ,ksecR9 ,-.5*ksecDipLength-ksecDipRadii,
+                               ksecR10,ksecR11,-.5*ksecDipLength-ksecDipRadii,
+                               ksecR12,ksecR13};/*
     Double_t secDip[ksecNRadii]={0.0,0.0,ksecDip0,0.0,0.0,ksecDip1,
-                                 0.0,0.0,ksecDip2,0.0,0.0,ksecDip3,
-                                 0.0,0.0,ksecDip4,0.0,0.0,ksecDip5,
-                                 0.0,0.0};*/
+                                0.0,0.0,ksecDip2,0.0,0.0,ksecDip3,
+                                0.0,0.0,ksecDip4,0.0,0.0,ksecDip5,
+                                0.0,0.0};*/
     Double_t secX2[ksecNRadii];
     Double_t secY2[ksecNRadii];
     Double_t secR2[ksecNRadii] = {
-        ksecR0,ksecR1,ksecRCoolOut,ksecR2,ksecR3,ksecRCoolOut,ksecR4,ksecR5,
-        ksecRCoolOut,ksecR6,ksecR7,ksecRCoolOut,ksecR8,ksecR9,ksecRCoolOut,
-        ksecR10,ksecR11,ksecRCoolOut,ksecR12,ksecR13};
+       ksecR0,ksecR1,ksecRCoolOut,ksecR2,ksecR3,ksecRCoolOut,ksecR4,ksecR5,
+       ksecRCoolOut,ksecR6,ksecR7,ksecRCoolOut,ksecR8,ksecR9,ksecRCoolOut,
+       ksecR10,ksecR11,ksecRCoolOut,ksecR12,ksecR13};
     Double_t secDip2[ksecNCoolingTubeDips]={ksecDl1,ksecDl2,ksecDl3,
-                                            ksecDl4,ksecDl5,ksecDl6};
+                                           ksecDl4,ksecDl5,ksecDl6};
     Double_t secX3[ksecNRadii];
     Double_t secY3[ksecNRadii];
     const Int_t ksecDipIndex[ksecNCoolingTubeDips] = {2,5,8,11,14,17};
@@ -320,43 +552,43 @@ TGeoVolume* AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth){
     Bool_t tst;
 
     if(moth==0){
-        Error("CarbonFiberSector","moth=%p",moth);
-        return moth;
+       Error("CarbonFiberSector","moth=%p",moth);
+       return;
     } // end if moth==0
     //SetDebug(3);
     for(i=0;i<ksecNRadii;i++){
-        xp[i]  = &(xpp[i*(ksecNPointsPerRadii+1)]);
-        yp[i]  = &(ypp[i*(ksecNPointsPerRadii+1)]);
-        xp2[i] = &(xpp2[i*(ksecNPointsPerRadii+1)]);
-        yp2[i] = &(ypp2[i*(ksecNPointsPerRadii+1)]);
-        secX2[i] = secX[i];
-        secY2[i] = secY[i];
-        secX3[i] = secX[i];
-        secY3[i] = secY[i];
+       xp[i]  = &(xpp[i*(ksecNPointsPerRadii+1)]);
+       yp[i]  = &(ypp[i*(ksecNPointsPerRadii+1)]);
+       xp2[i] = &(xpp2[i*(ksecNPointsPerRadii+1)]);
+       yp2[i] = &(ypp2[i*(ksecNPointsPerRadii+1)]);
+       secX2[i] = secX[i];
+       secY2[i] = secY[i];
+       secX3[i] = secX[i];
+       secY3[i] = secY[i];
     } // end for i
 
     // Find starting and ending angles for all but cooling tube sections
     secAngleStart[0] = 0.5*ksecAngleSide13;
     for(i=0;i<ksecNRadii-2;i++){
-        tst = kFALSE;
-        for(j=0;j<ksecNCoolingTubeDips;j++) tst = tst||i==ksecDipIndex[j];
-        if(tst) continue;
-        tst = kFALSE;
-        for(j=0;j<ksecNCoolingTubeDips;j++) tst = tst||(i+1)==ksecDipIndex[j];
-        if(tst) j = i+2;
-        else j = i+1;
-        AnglesForRoundedCorners(secX[i],secY[i],secR[i],
-                                secX[j],secY[j],secR[j],t0,t1);
-        secAngleEnd[i]   = t0;
-        secAngleStart[j] = t1;
-        if(secR[i]>0.0&&secR[j]>0.0)if(secAngleStart[i]>secAngleEnd[i])
-            secAngleEnd[i] += 360.0;
-        secAngleStart2[i] = secAngleStart[i];
-        secAngleEnd2[i]   = secAngleEnd[i];
+       tst = kFALSE;
+       for(j=0;j<ksecNCoolingTubeDips;j++) tst = tst||i==ksecDipIndex[j];
+       if(tst) continue;
+       tst = kFALSE;
+       for(j=0;j<ksecNCoolingTubeDips;j++) tst = tst||(i+1)==ksecDipIndex[j];
+       if(tst) j = i+2;
+       else j = i+1;
+       AnglesForRoundedCorners(secX[i],secY[i],secR[i],
+                               secX[j],secY[j],secR[j],t0,t1);
+       secAngleEnd[i]   = t0;
+       secAngleStart[j] = t1;
+       if(secR[i]>0.0&&secR[j]>0.0)if(secAngleStart[i]>secAngleEnd[i])
+           secAngleEnd[i] += 360.0;
+       secAngleStart2[i] = secAngleStart[i];
+       secAngleEnd2[i]   = secAngleEnd[i];
     } // end for i
     secAngleEnd[ksecNRadii-2]   = secAngleStart[ksecNRadii-2] + 
-                                     (secAngleEnd[ksecNRadii-5]-
-                                      secAngleStart[ksecNRadii-5]);
+                                    (secAngleEnd[ksecNRadii-5]-
+                                     secAngleStart[ksecNRadii-5]);
     if(secAngleEnd[ksecNRadii-2]<0.0) secAngleEnd[ksecNRadii-2] += 360.0;
     secAngleStart[ksecNRadii-1] = secAngleEnd[ksecNRadii-2] - 180.0;
     secAngleEnd[ksecNRadii-1]   = secAngleStart[0];
@@ -378,40 +610,46 @@ TGeoVolume* AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth){
     t -= t0*(-secR[i]+secR[j+1])*CosD(secAngleStart[i]);
     secX[ksecNRadii-1] = t/(t1-t0);
     secY[ksecNRadii-1] = TanD(90.+0.5*ksecAngleSide13)*
-                          (secX[ksecNRadii-1]-secX[0]) + secY[0];
+                         (secX[ksecNRadii-1]-secX[0]) + secY[0];
     secX2[ksecNRadii-1] = secX[ksecNRadii-1];
     secY2[ksecNRadii-1] = secY[ksecNRadii-1];
     secX3[ksecNRadii-1] = secX[ksecNRadii-1];
     secY3[ksecNRadii-1] = secY[ksecNRadii-1];
     // find location of cooling tube centers
     for(i=0;i<ksecNCoolingTubeDips;i++){
-        j = ksecDipIndex[i];
-        x0 = secX[j-1] + TMath::Abs(secR[j-1])*CosD(secAngleEnd[j-1]);
-        y0 = secY[j-1] + TMath::Abs(secR[j-1])*SinD(secAngleEnd[j-1]);
-        x1 = secX[j+1] + TMath::Abs(secR[j+1])*CosD(secAngleStart[j+1]);
-        y1 = secY[j+1] + TMath::Abs(secR[j+1])*SinD(secAngleStart[j+1]);
-        t0 = TMath::Sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1));
-        t  = secDip2[i]/t0;
-        a  = x0+(x1-x0)*t;
-        b  = y0+(y1-y0)*t;
-        if(a+b*(a-x0)/(b-y0)>0.0){
-            secX[j] = a + TMath::Abs(y1-y0)*2.0*ksecDipRadii/t0;
-            secY[j] = b - TMath::Sign(2.0*ksecDipRadii,y1-y0)*(x1-x0)/t0;
-            secX2[j] = a + TMath::Abs(y1-y0)*ksecTl/t0;
-            secY2[j] = b - TMath::Sign(ksecTl,y1-y0)*(x1-x0)/t0;
-            secX3[j] = a + TMath::Abs(y1-y0)*(2.0*ksecDipRadii-
-                                              0.5*ksecCoolTubeFlatY)/t0;
-            secY3[j] = b - TMath::Sign(2.0*ksecDipRadii-0.5*ksecCoolTubeFlatY,
-                                       y1-y0)*(x1-x0)/t0;
-        }else{
-            secX[j] = a - TMath::Abs(y1-y0)*2.0*ksecDipRadii/t0;
-            secY[j] = b + TMath::Sign(2.0*ksecDipRadii,y1-y0)*(x1-x0)/t0;
-            secX2[j] = a - TMath::Abs(y1-y0)*ksecTl/t0;
-            secY2[j] = b + TMath::Sign(ksecTl,y1-y0)*(x1-x0)/t0;
-            secX3[j] = a - TMath::Abs(y1-y0)*(2.0*ksecDipRadii-
-                                              0.5*ksecCoolTubeFlatY)/t0;
-            secY3[j] = b + TMath::Sign(2.0*ksecDipRadii-0.5*ksecCoolTubeFlatY,
-                                       y1-y0)*(x1-x0)/t0;
+       j = ksecDipIndex[i];
+       x0 = secX[j-1] + TMath::Abs(secR[j-1])*CosD(secAngleEnd[j-1]);
+       y0 = secY[j-1] + TMath::Abs(secR[j-1])*SinD(secAngleEnd[j-1]);
+       x1 = secX[j+1] + TMath::Abs(secR[j+1])*CosD(secAngleStart[j+1]);
+       y1 = secY[j+1] + TMath::Abs(secR[j+1])*SinD(secAngleStart[j+1]);
+       t0 = TMath::Sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1));
+       t  = secDip2[i]/t0;
+       a  = x0+(x1-x0)*t;
+       b  = y0+(y1-y0)*t;
+       if(i==0){ // get location of tube center->Surface for locating
+                 // this sector around the beam pipe. This needs to be
+                 // double checked, but I need my notes for that, Bjorn Nilsen
+           xAAtubeCenter0 = x0+(x1-x0)*t*0.5;
+           yAAtubeCenter0 = y0+(y1-y0)*t*0.5;
+       } // end if i==0
+       if(a+b*(a-x0)/(b-y0)>0.0){
+           secX[j] = a + TMath::Abs(y1-y0)*2.0*ksecDipRadii/t0;
+           secY[j] = b - TMath::Sign(2.0*ksecDipRadii,y1-y0)*(x1-x0)/t0;
+           secX2[j] = a + TMath::Abs(y1-y0)*ksecTl/t0;
+           secY2[j] = b - TMath::Sign(ksecTl,y1-y0)*(x1-x0)/t0;
+           secX3[j] = a + TMath::Abs(y1-y0)*(2.0*ksecDipRadii-
+                                         0.5*ksecCoolTubeFlatY)/t0;
+           secY3[j] = b - TMath::Sign(2.0*ksecDipRadii-0.5*ksecCoolTubeFlatY,
+                                  y1-y0)*(x1-x0)/t0;
+       }else{
+           secX[j] = a - TMath::Abs(y1-y0)*2.0*ksecDipRadii/t0;
+           secY[j] = b + TMath::Sign(2.0*ksecDipRadii,y1-y0)*(x1-x0)/t0;
+           secX2[j] = a - TMath::Abs(y1-y0)*ksecTl/t0;
+           secY2[j] = b + TMath::Sign(ksecTl,y1-y0)*(x1-x0)/t0;
+           secX3[j] = a - TMath::Abs(y1-y0)*(2.0*ksecDipRadii-
+                                         0.5*ksecCoolTubeFlatY)/t0;
+           secY3[j] = b + TMath::Sign(2.0*ksecDipRadii-0.5*ksecCoolTubeFlatY,
+                                     y1-y0)*(x1-x0)/t0;
         } // end if
         // Set up Start and End angles to correspond to start/end of dips.
         t1 = (secDip2[i]-TMath::Abs(secR[j]))/t0;
@@ -426,7 +664,7 @@ TGeoVolume* AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth){
         secAngleEnd2[j]   = secAngleEnd[j];
         if(secAngleEnd[j]>secAngleStart[j]) secAngleEnd[j] -= 360.0;
         secR[j] = TMath::Sqrt(secR[j]*secR[j]+4.0*ksecDipRadii*ksecDipRadii);
-    } // end if
+    } // end for i
     // Spcial cases
     secAngleStart2[8] -= 360.;
     secAngleStart2[11] -= 360.;
@@ -452,8 +690,8 @@ TGeoVolume* AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth){
         } // end for k
         secAngleTurbo[i] = -TMath::RadToDeg()*TMath::ATan2(y1-y0,x1-x0);
         if(GetDebug(3)){ 
-            Info("CarbonFiberSector","i=%d angle=%f x0,y0{%f,%f} "
-                 "x1y1={%f,%f,}",i,secAngleTurbo[i],x0,0,x1,y1);
+           cout <<"i="<<i<<" angle="<<secAngleTurbo[i]<<" x0,y0{"
+                <<x0<<","<<y0<<"} x1y1={"<<x1<<","<<y1<<"}"<<endl;
         } // end if
     } // end for i
     sA0 = new TGeoXtru(2);
@@ -538,6 +776,18 @@ TGeoVolume* AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth){
                        sA0->GetZ(1)+sB0->GetZ(1));
     //
     if(GetDebug()){
+        cout<<"medSPDcf= "<<medSPDcf<<endl;
+       //        printf("medSPDcf=%x\n",medSPDcf);
+        if(medSPDcf) medSPDcf->Dump();
+        cout<<"medSPDss= "<<medSPDss<<endl;
+       //       printf("medSPDss=%x\n",medSPDss);
+        if(medSPDss) medSPDss->Dump();
+       cout<<"medSPDair= "<<medSPDair<<endl;
+       //       printf("medSPDair=%x\n",medSPDair);
+        if(medSPDair) medSPDair->Dump();
+       cout<<"medSPDcoolfl= "<<medSPDcoolfl<<endl;
+       //       printf("medSPDcoolfl=%x\n",medSPDcoolfl);
+        if(medSPDcoolfl) medSPDcoolfl->Dump();
         sM0->InspectShape();
         sA0->InspectShape();
         sA1->InspectShape();
@@ -616,7 +866,7 @@ TGeoVolume* AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth){
         rot = new TGeoRotation("",0.0,0.0,t);
         rotrans = new TGeoCombiTrans("",x0,y0,0.0,rot);
         vM0->AddNode(vTA0,i+1,rotrans);
-        delete rot; // rot owned by AliITSv11GeometerySPD::CarbonFiberSector
+        //delete rot; // rot owned by AliITSv11GeometerySPD::CarbonFiberSector
     } // end for i
     vM0->AddNode(vA0,1,0);
     vM0->AddNode(vB0,1,0);
@@ -628,9 +878,12 @@ TGeoVolume* AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth){
         vA1->PrintNodes();
         vB0->PrintNodes();
         vB1->PrintNodes();
+        vTA0->PrintNodes();
+        vTA1->PrintNodes();
+        vTB0->PrintNodes();
+        vTB1->PrintNodes();
     } // end if GetDebug
     //
-    return moth;
 }
 //----------------------------------------------------------------------
 void AliITSv11GeometrySPD::SPDsectorShape(Int_t n,const Double_t *xc,
@@ -660,10 +913,13 @@ const Double_t *yc,const Double_t *r,const Double_t *ths,const Double_t *the,
 
     m = n*(npr+1);
     if(GetDebug(2)){
-        Info("SPDsectorShape","    X    \t  Y  \t  R  \t  S  \t  E%d", m);
+        cout <<"    X    \t  Y  \t  R  \t  S  \t  E"<< m <<endl;
         for(i=0;i<n;i++){
-            Info("SPDsectorShape","{%f,%f,%f,%f,%f}",
-                 xc[i],yc[i],r[i],ths[i],the[i]);
+            cout <<"{"<< xc[i] <<",";
+            cout << yc[i] <<",";
+            cout << r[i] <<",";
+            cout << ths[i] <<",";
+            cout << the[i] <<"},"<< endl;
         } // end for i
     } // end if GetDebug
     //
@@ -693,265 +949,28 @@ const Double_t *yc,const Double_t *r,const Double_t *ths,const Double_t *the,
     return;
 }
 //______________________________________________________________________
-TGeoVolume* AliITSv11GeometrySPD::CreateHalfStaveGroundFoil(){
+void AliITSv11GeometrySPD::HalfStave(TGeoVolume *moth,Double_t &thicknessAA,
+                                    TGeoManager *mgr){
     // Define the detail SPD Half Stave geometry.
     // Inputs:
-    //   none.
+    //   TGeoVolume  *moth  The mother volume to place this object.
+    //   Int_t      &thicknessAA Thickness of stave at section A-A
+    //   TGeoManager *mgr   TGeoManager default gGeoManager
     // Outputs:
     //  none.
     // Return:
-    //  TGeoVolume* The volume containing the half stave grounding foil.
-
-    TGeoManager *mgr = gGeoManager;
-    TGeoMedium *medSPDair = 0; // SPD Air
-    TGeoMedium *medSPDCu  = 0; // SPD Copper conductor
-    TGeoMedium *medSPDSiNs  = 0; // SPD Silicon non-sensitive material
-    TGeoMedium *medSPDSiSv  = 0; // SPD Silicon Sensitive material
-    TGeoMedium *medSPDStaveGlue = 0; // SPD Glue used on Half Staves
-
-    medSPDair       = mgr->GetMedium("ITSspdAir");
-    medSPDCu        = mgr->GetMedium("ITSspdCopper");
-    medSPDSiNs      = mgr->GetMedium("ITSspdSiliconNonSensitive");
-    medSPDSiSv      = mgr->GetMedium("ITSspdSiliconSensitive");
-    medSPDStaveGlue = mgr->GetMedium("ITSspdStaveGlue");
-    //
-    Double_t origin[3] = {0.0,0.0,0.0};
-    TGeoBBox *sA0,*sA1,*sA3,*sB2;
-    TGeoArb8 *sA2;
-    TGeoTubeSeg *sB1;
-
-    sA0 = new TGeoBBox("ITS SPD Half Stave Grounding Foil A0",
-                       0.5*fkGrdFoilWidthA,0.5*fkGrdFoilThick,0.5*(
-                fkGrdFoilLngA+fkGrdFoilLngB+fkGrdFoilLngC),origin);
-    origin[2] = 0.5*fkGrdFoilLngA;
-    sA1 = new TGeoBBox("ITS SPD Half Stave Gounding Foil Copper A1",
-            0.5*fkGrdFoilWidthA,0.5*fkGrdFoilThick,0.5*fkGrdFoilLngA,origin);
-    origin[0] = 0.5*(fkGrdFoilWidthA-fkGrdFoilWidthC);
-    origin[2] = -(fkGrdFoilLngA+fkGrdFoilLngB+0.5*fkGrdFoilLngC);
-    sA3 = new TGeoBBox("ITS SPD Half Stave Gounding Foil copper A3",
-            0.5*fkGrdFoilWidthC,0.5*fkGrdFoilThick,0.5*fkGrdFoilLngC,origin);
-    sA2 = new TGeoArb8("ITS SPD Half Stave Gounding Foil Copper A2",
-                       0.5*fkGrdFoilLngB);
-    sA2->SetVertex(0,-sA1->GetDX(),+sA1->GetDY());
-    sA2->SetVertex(1,+sA1->GetDX(),+sA1->GetDY());
-    sA2->SetVertex(2,+sA1->GetDX(),-sA1->GetDY());
-    sA2->SetVertex(3,-sA1->GetDX(),-sA1->GetDY());
-    sA2->SetVertex(4,origin[0]-sA3->GetDX(),+sA3->GetDY());
-    sA2->SetVertex(5,origin[0]+sA3->GetDX(),+sA3->GetDY());
-    sA2->SetVertex(6,origin[0]+sA3->GetDX(),-sA3->GetDY());
-    sA2->SetVertex(7,origin[0]-sA3->GetDX(),-sA3->GetDY());
-    sB1 = new TGeoTubeSeg("ITS SPD Half Stave Ground Foil Hole B1",
-                          0.0,0.5*fkGrdFoilHoleWidthAB,sA1->GetDY(),0.,180.);
-    sB2 = new TGeoBBox("ITS SPD Half Stave Ground Foil Hole B2",
-                       0.5*fkGrdFoilHoleWidthAB,sA1->GetDY(),
-                       0.5*(fkGrdFoilHoleLengthAB-fkGrdFoilHoleWidthAB),0);
-    //
-    TGeoVolume *vA0,*vA1,*vA2,*vA3,*vB1,*vB2;
-    vA0 = new TGeoVolume("ITSSPDHalfStaveGroundFoilA0",sA0,medSPDair);
-    vA0->SetVisibility(kTRUE);
-    vA0->SetLineColor(7); // light Blue
-    vA0->SetLineWidth(1);
-    vA0->SetFillColor(vA0->GetLineColor());
-    vA0->SetFillStyle(4090); // 90% transparent
-    vB1 = new TGeoVolume("ITSSPDHalfStaveGoundFoilHoleB1",sB1,medSPDair);
-    vB1->SetVisibility(kTRUE);
-    vB1->SetLineColor(7); // light Blue
-    vB1->SetLineWidth(1);
-    vB1->SetFillColor(vB1->GetLineColor());
-    vB1->SetFillStyle(4090); // 90% transparent
-    vB2 = new TGeoVolume("ITSSPDHalfStaveGoundFoilHoleB2",sB2,medSPDair);
-    vB2->SetVisibility(kTRUE);
-    vB2->SetLineColor(7); // light Blue
-    vB2->SetLineWidth(1);
-    vB2->SetFillColor(vB2->GetLineColor());
-    vB2->SetFillStyle(4090); // 90% transparent
-    vA1 = new TGeoVolume("ITSSPDHalfStaveGoundFoilCopperA1",sA1,medSPDCu);
-    vA1->SetVisibility(kTRUE);
-    vA1->SetLineColor(2); // red
-    vA1->SetLineWidth(1);
-    vA1->SetFillColor(vA1->GetLineColor());
-    vA1->SetFillStyle(4000); // 00% transparent
-    vA2 = new TGeoVolume("ITSSPDHalfStaveGoundFoilCopperA2",sA2,medSPDCu);
-    vA2->SetVisibility(kTRUE);
-    vA2->SetLineColor(2); // red
-    vA2->SetLineWidth(1);
-    vA2->SetFillColor(vA2->GetLineColor());
-    vA2->SetFillStyle(4000); // 00% transparent
-    vA3 = new TGeoVolume("ITSSPDHalfStaveGoundFoilCopperA3",sA3,medSPDCu);
-    vA3->SetVisibility(kTRUE);
-    vA3->SetLineColor(2); // red
-    vA3->SetLineWidth(1);
-    vA3->SetFillColor(vA3->GetLineColor());
-    vA3->SetFillStyle(4000); // 00% transparent
-    //
-    vA0->AddNode(vA1,1,0);
-    vA0->AddNode(vA2,1,new TGeoTranslation(0.0,0.0,
-                                           2.0*sA1->GetDZ()+sA2->GetDz()));
-    vA0->AddNode(vA3,1,0);
-    TGeoRotation left("",-90.0,0.0,0.0), right("",90.0,0.0,0.0);
-    Int_t i,ncopyB1=1,ncopyB2=1;
-    for(i=0;i<fkGrdFoilNholesAB;i++){
-        origin[0] = 0.0;
-        origin[1] = 0.0;
-        origin[2] = fkGrdFoilHoleStartA+((Double_t)i)*fkGrdFoilHoleSpacingAB;
-        vA1->AddNode(vB1,ncopyB1,0); // double check
-        vA1->AddNode(vB2,ncopyB2,new TGeoTranslation(0.0,0.0,
-                                        origin[2]+0.5*fkGrdFoilHoleLengthAB));
-        vA1->AddNode(vB1,ncopyB1,0); // double check
-    } // end for i
-    for(i=0;i<fkGrdFoilNholesAB;i++){
-        origin[0] = 0.0;
-        origin[1] = 0.0;
-        origin[2] = fkGrdFoilHoleStartB+((Double_t)i)*fkGrdFoilHoleSpacingAB;
-        new TGeoTranslation(0.0,0.0,origin[2]+sB1->GetRmax());
-        vA1->AddNode(vB1,ncopyB1,0); // double check
-        vA1->AddNode(vB2,ncopyB2,new TGeoTranslation(0.0,0.0,
-                                      origin[2]+0.5*fkGrdFoilHoleLengthAB));
-        new TGeoTranslation(0.0,0.0,origin[2]+sB1->GetRmax()+2.0*sB2->GetDZ());
-        vA1->AddNode(vB1,ncopyB1,0); // double check
-    } // end for i
-    return vA0;
-}
-//______________________________________________________________________
-TGeoVolume* AliITSv11GeometrySPD::CreateSPDLadder(){
-    // Define the detail SPD Half Stave geometry.
-    // Inputs:
-    //   none.
-    // Outputs:
     //  none.
-    // Return:
-    //  TGeoVolume* of the volume containing the SPD Ladder.
-    TGeoMedium *medSPDair       = 0; // SPD Air
-    TGeoMedium *medSPDCu        = 0; // SPD Copper conductor
-    TGeoMedium *medSPDSiNs      = 0; // SPD Silicon non-sensitive material
-    TGeoMedium *medSPDSiSv      = 0; // SPD Silicon Sensitive material
-    TGeoMedium *medSPDStaveGlue = 0; // SPD Glue used on Half Staves
-    TGeoMedium *medSPDLadGlue   = 0; // SPD Glue used on Half Staves
-    TGeoMedium *medSPDBumpBonds = 0; // SPD Bump bond material
-    TGeoBBox *sM0,*sGlue0,*sChip,*sBB,*sDet,*sSenDet,*sGlue1;
-    Double_t x,y,z;
 
-    TGeoManager *mgr = gGeoManager;
-    medSPDair       = mgr->GetMedium("ITSspdAir");
-    medSPDCu        = mgr->GetMedium("ITSspdCopper");
-    medSPDSiNs      = mgr->GetMedium("ITSspdSiliconNonSensitive");
-    medSPDSiSv      = mgr->GetMedium("ITSspdSiliconSensitive");
-    medSPDStaveGlue = mgr->GetMedium("ITSspdStaveGlue");
-    medSPDLadGlue   = mgr->GetMedium("ITSspdLadderGlue");
-    medSPDBumpBonds = mgr->GetMedium("ITSspdBumpBond");
-    //
-    sChip   = new TGeoBBox("ITS SPD Chip",0.5*fkLadChipWidth,0.5*fThickChip,
-                           0.5*fkLadChipLength);
-    sGlue0  = new TGeoBBox("ITS SPD Ladder bottom Glue0",sChip->GetDX(),
-                           0.5*fkLadGlue0Thick,sChip->GetDZ());
-    sDet    = new TGeoBBox("ITS SPD Detector Det",0.5*fkLadDetectorWidth,
-                           0.5*fThickDetector,0.5*fkLadDetectorLength);
-    sBB     = new TGeoBBox("ITS SPD BumpBond BB",sDet->GetDX(),
-                           0.5*fkLadBumpBondThick,sChip->GetDZ());
-    sSenDet = new TGeoBBox(CreateSensitivevolumeName("_shape"),
-                  0.5*fkLadSensDetWidth,sDet->GetDY(),0.5*fkLadSensDetLength);
-    sGlue1  = new TGeoBBox("ITS SPD Ladder Top Glue1",
-                           sDet->GetDX(),0.5*fkLadGlue0Thick,sDet->GetDZ());
-    x = TMath::Max(sChip->GetDX(),sDet->GetDX());
-    y = sGlue0->GetDY()+sChip->GetDY()+sBB->GetDY()+sDet->GetDY()+
-        sGlue1->GetDY();
-    z = ((Double_t) fkLadNChips)*sChip->GetDZ()+2.*0.5*fkLadChipSpacing0 +
-        ((Double_t) fkLadNChips-1)*0.5*fkLadChipSpacing1;
-    z = TMath::Max(z,sDet->GetDZ());
-    sM0 = new TGeoBBox("ITS SPD Ladder M0",x,y,z);
-    if(GetDebug()){
-        sGlue0->InspectShape();
-        sChip->InspectShape();
-        sBB->InspectShape();
-        sDet->InspectShape();
-        sSenDet->InspectShape();
-        sGlue1->InspectShape();
-        sM0->InspectShape();
-    } // end if GetDebug
-    //
-    TGeoVolume *vM0,*vGlue0,*vChip,*vBB,*vDet,*vSenDet,*vGlue1;
-    vM0 = new TGeoVolume("ITSSPDLadderM0",sM0,medSPDair);
-    vM0->SetVisibility(kFALSE);
-    vM0->SetLineColor(8); // White
-    vM0->SetLineWidth(1);
-    vM0->SetFillColor(vM0->GetLineColor());
-    vM0->SetFillStyle(4000); // 100% transparent
-    vGlue0 = new TGeoVolume("ITSSPDLadderGlue0",sGlue0,medSPDLadGlue);
-    vGlue0->SetVisibility(kTRUE);
-    vGlue0->SetLineColor(5); // Yellow
-    vGlue0->SetLineWidth(1);
-    vGlue0->SetFillColor(vGlue0->GetLineColor());
-    vGlue0->SetFillStyle(4050); // 50% transparent
-    vGlue1 = new TGeoVolume("ITSSPDLadderGlue1",sGlue1,medSPDLadGlue);
-    vGlue1->SetVisibility(kTRUE);
-    vGlue1->SetLineColor(5); // Yellow
-    vGlue1->SetLineWidth(1);
-    vGlue1->SetFillColor(vGlue1->GetLineColor());
-    vGlue1->SetFillStyle(4050); // 50% transparent
-    vChip = new TGeoVolume("ITSSPDLadderChip",sChip,medSPDSiNs);
-    vChip->SetVisibility(kTRUE);
-    vChip->SetLineColor(4); // blue
-    vChip->SetLineWidth(1);
-    vChip->SetFillColor(vChip->GetLineColor());
-    vChip->SetFillStyle(4100); // 0% transparent
-    vBB = new TGeoVolume("ITSSPDLadderBumpBond",sBB,medSPDBumpBonds);
-    vBB->SetVisibility(kTRUE);
-    vBB->SetLineColor(1); // black
-    vBB->SetLineWidth(1);
-    vBB->SetFillColor(vBB->GetLineColor());
-    vBB->SetFillStyle(4100); // 0% transparent
-    vDet = new TGeoVolume("ITSSPDLadderDet",sDet,medSPDSiNs);
-    vDet->SetVisibility(kTRUE);
-    vDet->SetLineColor(4); // blue
-    vDet->SetLineWidth(1);
-    vDet->SetFillColor(vDet->GetLineColor());
-    vDet->SetFillStyle(4100); // 0% transparent
-    vSenDet =new TGeoVolume(GetSensitivevolumeName(),sSenDet,medSPDSiSv);
-    vSenDet->SetVisibility(kTRUE);
-    vSenDet->SetLineColor(4); // blue
-    vSenDet->SetLineWidth(1);
-    vSenDet->SetFillColor(vSenDet->GetLineColor());
-    vSenDet->SetFillStyle(4100); // 0% transparent
-    //
-    vDet->AddNode(vSenDet,1,0); // Put sensitive volume inside detector
-    TGeoTranslation *tran;
-    Int_t i,nCopyGlue0=1,nCopyChip=1,nCopyBB=1;
-    Double_t xb,yg0,yc,yb,yd,yg1;
-    x   = 0.0;
-    xb  = -sM0->GetDX() + sDet->GetDX();
-    yg0 = -sM0->GetDY()+sGlue0->GetDY();
-    yc  = yg0 + sGlue0->GetDY() + sChip->GetDY();
-    yb  = yc  + sChip->GetDY()  + sBB->GetDY();
-    yd  = yb  + sBB->GetDY()    + sDet->GetDY();
-    yg1 = yd  + sDet->GetDY()   + sGlue1->GetDY();
-    z   = -sM0->GetDZ() + fkLadChipSpacing0 + sChip->GetDZ();
-    for(i=0;i<fkLadNChips;i++){
-        tran = new TGeoTranslation(x,yg0,z);
-        vM0->AddNode(vGlue0,nCopyGlue0++,tran);
-        tran = new TGeoTranslation(x,yc,z);
-        vM0->AddNode(vChip,nCopyChip++,tran);
-        tran = new TGeoTranslation(xb,yb,z);
-        vM0->AddNode(vBB,nCopyBB++,tran);
-        z += fkLadChipSpacing1 + 2.0*sChip->GetDZ();
-    } // end for i
-    tran = new TGeoTranslation(xb,yd,0.0);
-    vM0->AddNode(vDet,1,tran);
-    tran = new TGeoTranslation(xb,yg1,0.0);
-    vM0->AddNode(vGlue1,1,tran);
-    if(GetDebug()){
-        vGlue0->PrintNodes();
-        vChip->PrintNodes();
-        vBB->PrintNodes();
-        vDet->PrintNodes();
-        vSenDet->PrintNodes();
-        vGlue1->PrintNodes();
-        vM0->PrintNodes();
-    } // end if GetDebug
-    return vM0;
+    thicknessAA = 1.03*fgkmm; // Default value
+    if(moth==0){
+      Error("HalfStave","moth=%p mgr=%p",moth,mgr);
+        return;
+    } // end if moth==0
 }
 //----------------------------------------------------------------------
 void AliITSv11GeometrySPD::CreateFigure0(const Char_t *filepath,
-                                         const Char_t *type){
+                                         const Char_t *type,
+                                        TGeoManager *mgr){
     // Creates Figure 0 for the documentation of this class. In this
     // specific case, it creates the X,Y cross section of the SPD suport
     // section, center and ends. The output is written to a standard
@@ -959,6 +978,7 @@ void AliITSv11GeometrySPD::CreateFigure0(const Char_t *filepath,
     // Inputs:
     //   const Char_t *filepath  Path where the figure is to be drawn
     //   const Char_t *type      The type of file, default is gif.
+    //   TGeoManager  *mgr       The TGeoManager default gGeoManager
     // Output:
     //   none.
     // Return:
@@ -975,13 +995,13 @@ void AliITSv11GeometrySPD::CreateFigure0(const Char_t *filepath,
         Error("CreateFigure0","filepath=%s type=%s",filepath,type);
     } // end if
     //
-    sA0 = (TGeoXtru*) gGeoManager->GetVolume(
+    sA0 = (TGeoXtru*) mgr->GetVolume(
         "ITSSPDCarbonFiberSupportSectorA0_1")->GetShape();
-    sA1 = (TGeoXtru*) gGeoManager->GetVolume(
+    sA1 = (TGeoXtru*) mgr->GetVolume(
         "ITSSPDCarbonFiberSupportSectorAirA1_1")->GetShape();
-    sB0 = (TGeoXtru*) gGeoManager->GetVolume(
+    sB0 = (TGeoXtru*) mgr->GetVolume(
         "ITSSPDCarbonFiberSupportSectorEndB0_1")->GetShape();
-    sB1 = (TGeoXtru*) gGeoManager->GetVolume(
+    sB1 = (TGeoXtru*) mgr->GetVolume(
         "ITSSPDCarbonFiberSupportSectorEndAirB1_1")->GetShape();
     //pmA = new TPolyMarker();
     //pmA.SetMarkerStyle(2); // +
@@ -1031,11 +1051,11 @@ void AliITSv11GeometrySPD::CreateFigure0(const Char_t *filepath,
     Char_t chr[3];
     for(i=0;i<kNRadii;i++){
         sprintf(chr,"%2d",i);txt.DrawLatex(x-0.1,y,chr);
-        sprintf(chr,"%8.4",5.000);txt.DrawLatex(x,y,chr);
-        sprintf(chr,"%8.4",5.000);txt.DrawLatex(x+0.5,y,chr);
-        sprintf(chr,"%8.4",5.000);txt.DrawLatex(x+1.0,y,chr);
-        sprintf(chr,"%8.4",5.000);txt.DrawLatex(x+1.5,y,chr);
-        sprintf(chr,"%8.4",5.000);txt.DrawLatex(x+2.0,y,chr);
+        sprintf(chr,"%8.4f",5.000);txt.DrawLatex(x,y,chr);
+        sprintf(chr,"%8.4f",5.000);txt.DrawLatex(x+0.5,y,chr);
+        sprintf(chr,"%8.4f",5.000);txt.DrawLatex(x+1.0,y,chr);
+        sprintf(chr,"%8.4f",5.000);txt.DrawLatex(x+1.5,y,chr);
+        sprintf(chr,"%8.4f",5.000);txt.DrawLatex(x+2.0,y,chr);
         if(kTRUE) txt.DrawLatex(x+2.5,y,"A-A/E-E");
         else txt.DrawLatex(x+2.5,y,"E-E");
     } // end for i
@@ -1047,48 +1067,3 @@ void AliITSv11GeometrySPD::CreateFigure0(const Char_t *filepath,
     txt.DrawLatex(x+2.5,y,"Section");
     //
 }
-//----------------------------------------------------------------------
-void AliITSv11GeometrySPD::CreateFigureLadder(const Char_t *filepath,
-                                         const Char_t *type){
-    // Creates Figure 0 for the documentation of this class. In this
-    // specific case, it creates the X,Y cross section of the SPD suport
-    // section, center and ends. The output is written to a standard
-    // file name to the path specificed.
-    // Inputs:
-    //   const Char_t *filepath  Path where the figure is to be drawn
-    //   const Char_t *type      The type of file, default is gif.
-    // Output:
-    //   none.
-    // Return:
-    //   none.
-    TGeoVolume *vLad;
-    TCanvas *canvas;
-    TLatex txt;
-    TGeoManager *mgr = gGeoManager;
-
-    if((vLad = mgr->GetVolume("ITSSPDLadderM0"))==0){
-        printf("file=%s type=%s\n",filepath,type);
-        vLad = CreateSPDLadder();
-    } // end if
-    //
-    canvas = new TCanvas("canvas","ITS SPD Ladder",900,450);
-    //canvas->Divide(2,1);
-    //canvas->cd(1);
-    //TVirtualPad *pad1 = canvas->GetPad(1);
-    //TView *view1 = pad1->GetView();
-    //if(view1){
-    //    view1->FrontView(pad1);
-    //}
-    vLad->Draw();
-    //pad1->Update();
-    //
-/*    canvas->cd(2);
-    TVirtualPad *pad2 = canvas->GetPad(2);
-    TView *view2 = pad2->GetView();
-    if(view2){
-        view2->TopView(pad2);
-    }
-    vLad->Draw();
-*/    //pad2->Update();
-    canvas->Update();
-}