]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New methods added: GetSectorMountingPoints and Make2DcrossSections. (B. Nilsen)
authormasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 3 Sep 2007 14:29:28 +0000 (14:29 +0000)
committermasera <masera@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 3 Sep 2007 14:29:28 +0000 (14:29 +0000)
ITS/AliITSv11GeometrySPD.cxx
ITS/AliITSv11GeometrySPD.h
ITS/Displayv11.C

index 03b3fdb277ee93a740acc6b5274fc7bf34aba024..7ec045049e097d6e68efcbe0136dc42f5bd5ae36 100644 (file)
 #include <TLatex.h>
 #include <TCanvas.h>
 #include <TPolyLine.h>
+#include <TPolyMarker.h>
 // Root Geometry includes
 #include <TGeoVolume.h>
-//#include <TGeoPcon.h>
-//#include <TGeoCone.h>
 #include <TGeoTube.h> // contains TGeoTubeSeg
 #include <TGeoArb8.h>
 #include <TGeoEltu.h>
 #include <TGeoXtru.h>
 #include <TGeoMatrix.h>
-//#include <TGeoRotation.h>
-//#include <TGeoCombiTrans.h>
-//#include <TGeoTranslation.h>
 #include <TGeoMaterial.h>
 #include <TGeoMedium.h>
 #include <TGeoCompositeShape.h>
@@ -102,7 +98,7 @@ Int_t AliITSv11GeometrySPD::CreateSPDCentralMaterials(Int_t &medOffset, Int_t &m
     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 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
@@ -152,12 +148,17 @@ Int_t AliITSv11GeometrySPD::CreateSPDCentralMaterials(Int_t &medOffset, Int_t &m
     //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)"
+    // Carbon fiber by fractional weight "C (M55J)"
+    mix = new TGeoMixture("C (M55J)",4,1.9866*fgkgcm3);
     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
+     // Carbon by fractional weight
+    mix->DefineElement(0,12.0107,6.0,0.908508078);
+    // Nitrogen by fractional weight
+    mix->DefineElement(1,14.0067,7.0,0.010387573); 
+    // Oxigen by fractional weight
+    mix->DefineElement(2,15.9994,8.0,0.055957585); 
+    // Hydrogen by fractional weight
+    mix->DefineElement(3,1.00794,1.0,0.025146765); 
     mix->SetPressure(0.0*fgkPascal);
     mix->SetTemperature(25.0*fgkCelsius);
     mix->SetState(TGeoMaterial::kMatStateSolid);
@@ -170,7 +171,8 @@ Int_t AliITSv11GeometrySPD::CreateSPDCentralMaterials(Int_t &medOffset, Int_t &m
     //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
+    // Carbon fiber by fractional weight
+    mix = new TGeoMixture("Air",4,1.20479E-3*fgkgcm3);
     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
@@ -188,7 +190,8 @@ Int_t AliITSv11GeometrySPD::CreateSPDCentralMaterials(Int_t &medOffset, Int_t &m
     //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
+    // Carbon fiber by fractional weight
+    mix = new TGeoMixture("INOX",9,8.03*fgkgcm3);
     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
@@ -208,11 +211,12 @@ Int_t AliITSv11GeometrySPD::CreateSPDCentralMaterials(Int_t &medOffset, Int_t &m
     params[6] = kepsilAir;
     params[7] = kstminAir;
     med = new TGeoMedium("ITSspdStainlessSteel",medindex++,mix,params);
-    //med = new TGeoMedium("ITSspdStainlessSteel",medindex++,matindex++,0,ifield,
+    //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
+    // Carbon fiber by fractional weight
     mix->SetIndex(matindex);
+    mix = new TGeoMixture("Freon",2,1.63*fgkgcm3);
     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
@@ -244,7 +248,8 @@ void AliITSv11GeometrySPD::InitSPDCentral(Int_t offset,TVirtualMC *vmc) const {
     // 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]
+    // 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 .
@@ -252,13 +257,14 @@ void AliITSv11GeometrySPD::InitSPDCentral(Int_t offset,TVirtualMC *vmc) const {
     // 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.
+    //     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.
+    //     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.
+    // 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.
@@ -674,10 +680,26 @@ void AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth,
         if(secAngleEnd[j]>secAngleStart[j]) secAngleEnd[j] -= 360.0;
         secR[j] = TMath::Sqrt(secR[j]*secR[j]+4.0*ksecDipRadii*ksecDipRadii);
     } // end for i
-    // Spcial cases
+    // Special cases
     secAngleStart2[8] -= 360.;
     secAngleStart2[11] -= 360.;
     //
+    fSPDsectorPoints0.Set(ksecNCoolingTubeDips);
+    fSPDsectorPoints1.Set(ksecNCoolingTubeDips);
+    //
+    for(i=0;i<ksecNCoolingTubeDips;i++){
+        // Find index in xpp[] and ypp[] corresponding to where the
+        // SPD ladders are to be attached. Order them according to
+        // the ALICE numbering schema. Using array of indexes (+-1 for
+        // cooling tubes. For any "bend/dip/edge, there are 
+        // ksecNPointsPerRadii+1 points involved.
+        if(i==0) j=1;
+        else if(i==1) j=0;
+       else j=i;
+       fSPDsectorPoints0[i] = (ksecDipIndex[j]-1)*(ksecNPointsPerRadii+1)+
+                               (ksecNPointsPerRadii);
+       fSPDsectorPoints1[i] = (ksecDipIndex[j]+1)*(ksecNPointsPerRadii+1);
+    } // end for i
     SPDsectorShape(ksecNRadii,secX,secY,secR,secAngleStart,secAngleEnd,
                    ksecNPointsPerRadii,m,xp,yp);
     //  Fix up dips to be square.
@@ -704,6 +726,9 @@ void AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth,
         } // end if
     } // end for i
     sA0 = new TGeoXtru(2);
+    // This shape needs to be access later to mount the SPD sector to.
+    //fSPDsectorShapeName = "ITS SPD Carbon fiber support Sector A0";
+    //sA0->SetName(fSPDsectorShapeName.Data());
     sA0->SetName("ITS SPD Carbon fiber support Sector A0");
     sA0->DefinePolygon(m,xpp,ypp);
     sA0->DefineSection(0,-ksecDz);
@@ -816,8 +841,9 @@ void AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth,
     //vM0->SetFillColor(vM0->GetLineColor());
     //vM0->SetFillStyle(4090); // 90% transparent
     // ALBERTO
-    StavesInSector(vM0);
-    vA0 = new TGeoVolume("ITSSPDCarbonFiberSupportSectorA0",sA0,medSPDcf);
+    fSPDsectorShapeName = "ITSSPDCarbonFiberSupportSectorA0";
+    vA0 = new TGeoVolume(fSPDsectorShapeName,sA0,medSPDcf);
+    //vA0 = new TGeoVolume("ITSSPDCarbonFiberSupportSectorA0",sA0,medSPDcf);
     vA0->SetVisibility(kTRUE);
     vA0->SetLineColor(4); // Blue
     vA0->SetLineWidth(1);
@@ -867,6 +893,7 @@ void AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth,
     vTB1->SetFillColor(vTB1->GetLineColor());
     vTB1->SetFillStyle(4000); // 0% transparent
     //
+    StavesInSector(vM0);
     moth->AddNode(vM0,1,0); // Add virtual volume to mother
     vA0->AddNode(vA1,1,0); // Put air inside carbon fiber.
     vB0->AddNode(vB1,1,0); // Put air inside carbon fiber.
@@ -901,6 +928,59 @@ void AliITSv11GeometrySPD::CarbonFiberSector(TGeoVolume *moth,
     //
 }
 //----------------------------------------------------------------------
+Bool_t AliITSv11GeometrySPD::GetSectorMountingPoints(Int_t index,
+                            Double_t &x0,Double_t &y0,
+                            Double_t &x1,Double_t &y1,TGeoManager *mgr)const{
+    // Return's the mounting locations needed to mount the SPD ladders 
+    // on the SPD Carbon fiber Sectors (A cross section). Coordinate
+    // system is that of the carbon fiber sector TVolume 
+    // "ITSSPDCarbonFiberSupportSectorA0". Index numbering is as follows
+    //                         /5
+    //                        /\/4
+    //                      1\   \/3
+    //                      0|___\/2
+    // Inputs:
+    //    Int_t index   the index for which location on the SPD sector [0-5]
+    // Outputs:
+    //    Double_t &x0     The x0 location or the ladder sector [cm]
+    //    Double_t &y0     The y0 location of the ladder sector [cm]
+    //    Double_t &x1     The x1 location or the ladder sector [cm]
+    //    Double_t &y1     The y1 location of the ladder sector [cm]
+    //    TGeoManager *mgr The Geometry manager to use [gGeoManager]
+    // Return:
+    //     Returns kTRUE if no problems incountered. Returns kFALSE
+    //     if a problem was incountered (for example the shape has 
+    //     not been found.
+    TGeoVolume *spdSectorV=0;
+    TGeoXtru *spdSector=0;
+    Int_t ixy0,ixy1;
+
+    x0 = x1 = y0 = y1 = 0.0;
+    if(index<0 || index>fSPDsectorPoints0.GetSize()){
+      Error("GetSectorMountingPoints","index=%d size=%d",index,
+           fSPDsectorPoints0.GetSize());
+      return kFALSE;
+    }// end if
+    spdSectorV = mgr->GetVolume(fSPDsectorShapeName.Data());
+    if(spdSectorV==0){
+      Error("GetSectorMountingPoints","spdSectorV==0 name=%s",
+           fSPDsectorShapeName.Data());
+      return kFALSE;
+    } // end if
+    spdSector = dynamic_cast<TGeoXtru*>(spdSectorV->GetShape());
+    if(spdSector==0){
+      Error("GetSectorMountingPoints","spdSector==0");
+      return kFALSE;
+    } // end if
+    ixy0 = fSPDsectorPoints0.At(index);
+    ixy1 = fSPDsectorPoints1.At(index);
+    x0 = spdSector->GetX(ixy0);
+    y0 = spdSector->GetY(ixy0);
+    x1 = spdSector->GetX(ixy1);
+    y1 = spdSector->GetY(ixy1);
+    return kTRUE;
+}
+//----------------------------------------------------------------------
 void AliITSv11GeometrySPD::SPDsectorShape(Int_t n,const Double_t *xc,
 const Double_t *yc,const Double_t *r,const Double_t *ths,const Double_t *the,
                                Int_t npr,Int_t &m,Double_t **xp,Double_t **yp){
@@ -1064,18 +1144,17 @@ void AliITSv11GeometrySPD::CreateFigure0(const Char_t *filepath,
     //
 }
 
-//___________________________________________________________________________________________________________________
-TGeoVolume* AliITSv11GeometrySPD::CreateLadder
-(Int_t layer, Double_t &length, Double_t &width, Double_t &thickness, TGeoManager *mgr)
-{
-       //
+//______________________________________________________________________
+TGeoVolume* AliITSv11GeometrySPD::CreateLadder(Int_t layer,Double_t &length,
+                    Double_t &width,Double_t &thickness, TGeoManager *mgr){
        // Creates the "ladder" = silicon sensor + 5 chips.
        // All parts are implemented as TGeoBBox and inserted 
        // into a container which is the return value of this method.
        // The sizes of the components come from drawings 
        // of the Technical office of INFN Padova.
-       // Due to the requirement to specify the sensitive volume separately from the rest,
-       // the sensor is implemented as the sum of a central sensitive part + a guard ring.
+       // Due to the requirement to specify the sensitive volume 
+        // separately from the rest, the sensor is implemented as the 
+        // sum of a central sensitive part + a guard ring.
        // Also the bump-bondings are added in form of small cylinders.
        // ---
        // Arguments:
@@ -1087,18 +1166,23 @@ TGeoVolume* AliITSv11GeometrySPD::CreateLadder
        //  - the size of the container box (arguments passed by reference)
        // ---
        // NOTE 1
-       // Here and in the other methods which contribute to the stave definition
-       // a convention is used for the naming of the three dimensions of the volumes:
-       //  - 'length'    refers to the size in the Z direction of the ALICE reference frame
-       //  - 'width'     refers to the "large" dimension orthogonal to Z axis in the local reference 
-       //                frame of the object being implemented (e.g., 15.95 mm for the chips)
-       //  - 'thickness' refers to the "small" dimension orthogonal to Z axis, which is also
-       //                the direction along which the components are superimposed on each other
+       // Here and in the other methods which contribute to the stave 
+        // definition a convention is used for the naming of the three 
+        // dimensions of the volumes:
+       //  - 'length'    refers to the size in the Z direction of the 
+        //                ALICE reference frame
+       //  - 'width'     refers to the "large" dimension orthogonal to 
+        //                Z axis in the local reference frame of the 
+        //                object being implemented (e.g., 15.95 mm for 
+        //                the chips)
+       //  - 'thickness' refers to the "small" dimension orthogonal to 
+        //                Z axis, which is also the direction along which 
+        //                the components are superimposed on each other
        // ---
        // NOTE 2
-       // all sizes taken are expressed in mm in drawings, and this is kept as is, to avoid confusion
-       // the conversion is made multiplying by the conversion factor
-       //
+       // all sizes taken are expressed in mm in drawings, and this is 
+        // kept as is, to avoid confusion the conversion is made 
+        // multiplying by the conversion factor
        
        // ** CRITICAL CHECK **
        // layer number can be ONLY 1 or 2
@@ -1115,7 +1199,7 @@ TGeoVolume* AliITSv11GeometrySPD::CreateLadder
        // 'length'    is in the direction of the detector length (Z axis)
        // 'thickness' is obvious
        // 'width'     is in the direction orthogonal to 'width' and 'thickness'
-       
+
        // for the chip, also the spacing between them is required
        Double_t chipThickness  = fgkmm *  0.150;
        Double_t chipWidth      = fgkmm * 15.950;
@@ -1135,55 +1219,67 @@ TGeoVolume* AliITSv11GeometrySPD::CreateLadder
        Double_t bbLength    = fgkmm * 0.042;
        Double_t bbWidth     = sensWidth;
        Double_t bbThickness = fgkmm * 0.012;
-       Double_t bbPos       = 0.080;           // Z position w.r. to left pixel edge
+       Double_t bbPos       = 0.080;   // Z position w.r. to left pixel edge
                
        // ** Create volumes **
        // the container is the return value, and is built as a box
-       // whose edges exactly enclose the stuff we inserted here, filled with air.
-       // Its name depends on the layer number.
+       // whose edges exactly enclose the stuff we inserted here, 
+       // filled with air. Its name depends on the layer number.
        width = chipWidth;
        length = sensLength + 2.0*guardRingWidth;
        thickness = sensThickness + chipThickness + bbThickness;
-       TGeoVolume *container = mgr->MakeBox(Form("LAY%d_LADDER", layer), medAir, 0.5*thickness, 0.5*width, 0.5*length);
-       
+       TGeoVolume *container = mgr->MakeBox(Form("LAY%d_LADDER", layer),
+                               medAir, 0.5*thickness, 0.5*width, 0.5*length);
        // the chip is a simple box:
-       TGeoVolume *volChip = mgr->MakeBox("CHIP", medSPDSiChip, 0.5*chipThickness, 0.5*chipWidth, 0.5*chipLength);
-       
-       // the sensor is the union of a box and a border, to separate sensitive part from the rest
-       // the sensitive volume (inner part) is named according to the owner layer.
-       // To compute the shape subtraction which is needed for this we create two shapes,
-       // which are two boxes with the same center.
-       // The smaller one is then used to define the sensor, while the subtraction of the two
+       TGeoVolume *volChip = mgr->MakeBox("CHIP", medSPDSiChip,
+                           0.5*chipThickness, 0.5*chipWidth, 0.5*chipLength);
+       
+       // the sensor is the union of a box and a border, to separate 
+        // sensitive part from the rest the sensitive volume (inner part) 
+        // is named according to the owner layer. To compute the shape 
+       // subtraction which is needed for this we create two shapes,
+       // which are two boxes with the same center. The smaller one is 
+       // then used to define the sensor, while the subtraction of the two
        // is used for the guard ring.
-       TGeoBBox  *shSens = new TGeoBBox(0.5*sensThickness, 0.5*sensWidth, 0.5*sensLength);
-       TGeoBBox  *shIn   = new TGeoBBox(sensThickness, 0.5*sensWidth, 0.5*sensLength);
-       TGeoBBox  *shOut  = new TGeoBBox(0.5*sensThickness, 0.5*sensWidth + guardRingWidth, 0.5*sensLength + guardRingWidth);
+       TGeoBBox  *shSens = new TGeoBBox(0.5*sensThickness, 0.5*sensWidth, 
+                                        0.5*sensLength);
+       TGeoBBox  *shIn   = new TGeoBBox(sensThickness, 0.5*sensWidth, 
+                                        0.5*sensLength);
+       TGeoBBox  *shOut  = new TGeoBBox(0.5*sensThickness, 
+                                        0.5*sensWidth + guardRingWidth, 
+                                        0.5*sensLength + guardRingWidth);
        shIn->SetName("innerBox");
        shOut->SetName("outerBox");
-       TGeoCompositeShape *shBorder = new TGeoCompositeShape("", "outerBox-innerBox");
-       TGeoVolume *volSens = new TGeoVolume(Form("LAY%d_SENSOR", layer), shSens, medSi);
+       TGeoCompositeShape *shBorder = new TGeoCompositeShape("",
+                                                        "outerBox-innerBox");
+       TGeoVolume *volSens = new TGeoVolume(Form("LAY%d_SENSOR", layer),
+                                            shSens, medSi);
        TGeoVolume *volBorder = new TGeoVolume("GUARD_RING", shBorder, medSi);
-       
+
        // one line of bumpbonds
-       TGeoVolume *volBB = mgr->MakeBox("BB", medBumpBond, 0.5*bbThickness, 0.5*bbWidth, 0.5*bbLength);
-                       
+       TGeoVolume *volBB = mgr->MakeBox("BB", medBumpBond, 0.5*bbThickness,
+                                        0.5*bbWidth, 0.5*bbLength);
+               
        // set colors of all objects for visualization  
        volSens->SetLineColor(kYellow + 1);
        volChip->SetLineColor(kGreen);
        volBorder->SetLineColor(kYellow + 3);
 
-       // translations for the chip box: direction of length and thickness (moved down)
+       // translations for the chip box: direction of length and 
+       // thickness (moved down)
        TGeoTranslation *trChip[5] = {0, 0, 0, 0, 0};
        Double_t x = 0.5 * (chipThickness - thickness);
        Double_t y = 0.0;
        Double_t z = 0.0;
        Int_t i;
        for (i = 0; i < 5; i++) {
-               z = -0.5*length + guardRingWidth + (Double_t)i*chipSpacing + ((Double_t)(i) + 0.5)*chipLength;
+               z = -0.5*length + guardRingWidth + (Double_t)i*chipSpacing + 
+                 ((Double_t)(i) + 0.5)*chipLength;
                trChip[i] = new TGeoTranslation(x, y, z);
-       }
+       } // end for i
        
-       // translation for the sensor parts: direction of width (moved to edge of container) and thickness (moved up)
+       // translation for the sensor parts: direction of width (moved 
+       // to edge of container) and thickness (moved up)
        x = 0.5 * (thickness - sensThickness);
        y = 0.5 * (width - sensWidth - 2.0*guardRingWidth);
        z = 0.0;
@@ -1206,31 +1302,33 @@ TGeoVolume* AliITSv11GeometrySPD::CreateLadder
                                break;
                        default:
                                z += fgkmm * 0.425;
-               }
-       }
+               } // end switch
+       } // end for i
                
        // add nodes to container
        container->AddNode(volSens, 1, trSens);
        container->AddNode(volBorder, 1, trSens);
        for (i = 0; i < 160; i++) container->AddNode(volBB, i, trBB[i]);
-       for (i = 0; i < 5; i++) container->AddNode(volChip, i + 2, trChip[i]);
+       for (i = 0; i < 5; i++){
+           container->AddNode(volChip, i + 2, trChip[i]);
+       } // end for i
        
        // return the container
        return container;
 }
-
 /*
-//___________________________________________________________________________________________________________________
-TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
-(Bool_t kaptonLayer, Double_t &length, Double_t &width, Double_t &thickness, TGeoManager *mgr)
-{
+//______________________________________________________________________
+TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle(Bool_t kaptonLayer,
+    Double_t &length, Double_t &width, Double_t &thickness, TGeoManager *mgr){
        //
        // Creates the grounding foil layer made in Kapton.
-       // Both layers of the grounding foil have the same shape, but with small
-       // differences in the size of some parts (holes, overall size).
-       // The Kapton layer is a little bit wider and has smaller holes.
+       // Both layers of the grounding foil have the same shape, but 
+       // with small differences in the size of some parts (holes, 
+       // overall size). The Kapton layer is a little bit wider and 
+       // has smaller holes.
        // ---
-       // The complete object is created as the superimposition of an XTRU with some holes
+       // The complete object is created as the superimposition of 
+       // an XTRU with some holes
        // ---
        // Whenever possible, the size of the parts is parameterized with 
        // variable names, even if their value is fixed according 
@@ -1239,28 +1337,31 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
        // Returns: a TGeoVolume object which contains all parts of this layer
        //
        
-       // The shape of the grounding foil is an irregular polygon, which can easily be implemented as 
-       // a TGeoXtru using the corners as reference points:
+       // The shape of the grounding foil is an irregular polygon, which 
+       // can easily be implemented as a TGeoXtru using the corners as 
+       // reference points:
        // 
-       // 0                                                                                                     1
-       //  +---------------------------------------------------------------------------------------------------+
-       //  |                                                            7              6      3                |
-       //  |                                                            +--------------+      +----------------+ 2
-       //  |                                                O           |              |      |
-       //  |                                                    9 /-----+ 8            +------+ 4
-       //  |                                                     /                    5
-       //  |                                  11 /--------------/ 10
-       //  +------------------------------------
-       // 13                                    12
+       // 0                                                                             1
+       //  +-----------------------------------------------------------------------------+
+       //  |                                    7              6      3                |
+       //  |                                     +--------------+      +----------------+ 2
+       //  |                         O           |              |      |
+       //  |                             9 /-----+ 8            +------+ 4
+       //  |                              /                    5
+       //  |           11 /--------------/ 10
+       //  +-------------/ 
+       // 13           12
        //
-       // in total: 14 points (X is just a referencem but is unused in the implementation.
-       // The whole shape can be subdivided into sectors delimited by vertical lines passing
-       // througth the points in the lower part of the shape. This convention is used to names
-       // their length which is different for each one (the widths, instead, are common for some)      
-
+       // in total: 14 points (X is just a referencem but is unused in 
+       // the implementation. The whole shape can be subdivided into 
+       // sectors delimited by vertical lines passing througth the 
+       // points in the lower part of the shape. This convention is 
+       // used to names their length which is different for each one 
+       // (the widths, instead, are common for some)   
        // instantiate the media:
        // - kapton/aluminum for the pysical volumes
-       TGeoMedium *material = kaptonLayer ? mgr->GetMedium("KAPTON") : mgr->GetMedium("AL");
+       TGeoMedium *material = kaptonLayer ? mgr->GetMedium("KAPTON") : 
+                                                    mgr->GetMedium("AL");
        
        // label
        char type[3];
@@ -1275,7 +1376,7 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
        
        // define the length of all sectors (from leftmost to rightmost)
        Int_t i;
-       Double_t sectorLength[] = { 140.71,  2.48,  26.78,  4.00,  10.00,  24.40,  10.00,  24.81 };
+       Double_t sectorLength[] = {140.71,2.48,26.78,4.0,10.0,24.4,10.0,24.81};
        if (!kaptonLayer) {
                sectorLength[0] -= 0.2;
                sectorLength[4] -= 0.2;
@@ -1288,7 +1389,8 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
                length += sectorLength[i];
        }
                
-       // as shown in the drawing, we have three different widths in this shape:
+       // as shown in the drawing, we have three different widths in 
+       // this shape:
        Double_t widthMax  = fgkmm * 15.95;
        Double_t widthMed1 = fgkmm * 15.00;
        Double_t widthMed2 = fgkmm * 11.00;
@@ -1301,8 +1403,9 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
        }
        width = widthMax;
        
-       // the vertices of the polygon are arrays correctly ordered in the counterclockwise direction:
-       // initially we place the point 0 in the origin, and all others will be defined accordingly
+       // the vertices of the polygon are arrays correctly ordered in 
+       // the counterclockwise direction: initially we place the point 
+       // 0 in the origin, and all others will be defined accordingly
        Double_t x[14], y[14];
        x[ 0] = 0.0;
        y[ 0] = 0.0;
@@ -1346,7 +1449,8 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
        x[13] = x[0];
        y[13] = -widthMax;
        
-       // then, we shift all points in such a way that the origin will be at the centers
+       // then, we shift all points in such a way that the origin will 
+       // be at the centers
        for (i = 0; i < 14; i++) {
                x[i] -= 0.5*length;
                y[i] += 0.5*width;
@@ -1361,16 +1465,21 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
        shGroundFull->DefineSection(0, -0.5*thickness, 0., 0., 1.0);
        shGroundFull->DefineSection(1,  0.5*thickness, 0., 0., 1.0);
        
-       // this volume contains some holes which are here implemented as simple boxes
-       // of fixed size, which are displaced along the shape itself and then composed
-       // using the facilities of the TGeo package
-       
+       // this volume contains some holes which are here implemented 
+       // as simple boxes of fixed size, which are displaced along the 
+       // shape itself and then composed using the facilities of the 
+       // TGeo package
+
        Double_t holeLength = fgkmm * 10.00;
        Double_t holeWidth  = fgkmm *  7.50;
-       Double_t holeSepX0  = fgkmm *  7.05;  // separation between center of first hole and left border
-       Double_t holeSepXC  = fgkmm * 14.00;  // separation between the centers of two consecutive holes
-       Double_t holeSepX1  = fgkmm * 15.42;  // separation between centers of 5th and 6th hole
-       Double_t holeSepX2  = fgkmm * 22.00;  // separation between centers of 10th and 11th hole
+       Double_t holeSepX0  = fgkmm *  7.05;//separation between center 
+                                           //of first hole and left border
+       Double_t holeSepXC  = fgkmm * 14.00;//separation between the 
+                                            // centers of two consecutive holes
+       Double_t holeSepX1  = fgkmm * 15.42;//separation between centers 
+                                            // of 5th and 6th hole
+       Double_t holeSepX2  = fgkmm * 22.00;//separation between centers 
+                                            // of 10th and 11th hole
        if (!kaptonLayer) {
                holeSepX0  -= fgkmm * 0.2;
                holeLength += fgkmm * 0.4;
@@ -1387,10 +1496,11 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
        char holeName[200];
        sprintf(holeName, "%sHOLE", type);
        TGeoBBox *shHole = 0;
-       shHole = new TGeoBBox(holeName, 0.5*holeLength, 0.5*holeWidth, thickness);
+       shHole = new TGeoBBox(holeName,0.5*holeLength,0.5*holeWidth,thickness);
        
        // insert the holes in the XTRU shape:
-       // starting from the first value of X, they are simply shifted along this axis
+       // starting from the first value of X, they are simply shifted 
+       // along this axis
        char trName[200];
        TGeoTranslation *transHole[11];
        TString strComposite(shName);
@@ -1425,19 +1535,19 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
        //MM    cout << strComposite.Data() << endl;
        
        // create composite shape (with holes)
-       TGeoCompositeShape *shGround = new TGeoCompositeShape(Form("SH_%sGFOIL", type), strComposite.Data());
+       TGeoCompositeShape *shGround = new TGeoCompositeShape(
+                                 Form("SH_%sGFOIL", type), strComposite.Data());
        
        // create the volume
-       TGeoVolume *vol = new TGeoVolume(Form("%sGFOIL", type), shGround, material);
+       TGeoVolume *vol = new TGeoVolume(Form("%sGFOIL",type),shGround,
+                                                              material);
        return vol;
 }
 */
-
-//___________________________________________________________________________________________________________________
-TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
-(Bool_t kaptonLayer, Double_t &length, Double_t &width, Double_t &thickness, TGeoManager *mgr)
-{
-       //
+//______________________________________________________________________
+TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle(
+      Bool_t kaptonLayer, Double_t &length, Double_t &width, 
+      Double_t &thickness, TGeoManager *mgr){
        // Creates the grounding foil layer made in Kapton.
        // Both layers of the grounding foil have the same shape, but with small
        // differences in the size of some parts (holes, overall size).
@@ -1450,7 +1560,8 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
        // 3) another box with a unique hole of the same shape and size as above
        // 4) another trapezoidal connection where the Y size changes
        // 5) a final part which is built as a sequence of 4 BOX volumes
-       //    where the first and the third are equal and the others have same size in Y.
+       //    where the first and the third are equal and the others have 
+        //    same size in Y.
        // ---
        // Whenever possible, the size of the parts is parameterized with 
        // variable names, even if their value is fixed according 
@@ -1484,12 +1595,18 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
        
        Double_t holeX      = fgkmm *  10.00;
        Double_t holeY      = fgkmm *   7.50;
-       Double_t holeSepX   = fgkmm *  14.00;  // separation between the centers of two consecutive holes
-       Double_t holeSepX1  = fgkmm *   1.42;  // to be added after 4th hole in volume 1
-       Double_t holeFirstX = fgkmm *   7.05;  // position of center of first hole
-       Double_t holeSepY   = fgkmm *   4.40;  // dist between hole's and volume's upper border
-       Double_t holeAloneX = fgkmm *  13.28;  // position of hole center in box "part 3"
-       
+       Double_t holeSepX   = fgkmm *  14.00;  // separation between the 
+                                              // centers of two consecutive 
+                                              // holes
+       Double_t holeSepX1  = fgkmm *   1.42;  // to be added after 4th hole 
+                                              // in volume 1
+       Double_t holeFirstX = fgkmm *   7.05;  // position of center of first 
+                                              // hole
+       Double_t holeSepY   = fgkmm *   4.40;  // dist between hole's and 
+                                              // volume's upper border
+       Double_t holeAloneX = fgkmm *  13.28;  // position of hole center 
+                                              // in box "part 3"
+
        // correct data in case we are on Aluminum foil
        if (!kaptonLayer) {
                material = mgr->GetMedium("AL");
@@ -1515,19 +1632,24 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
        if (kaptonLayer) strcpy(type, "KAP"); else strcpy(type, "ALU");
        
        // compute full length and width
-       length = part1X + part2X + part3X + part4X + part5X + part6X + part7X + part8X;
+       length = part1X + part2X + part3X + part4X + part5X + part6X + 
+                part7X + part8X;
        width = sizeYMax;
        thickness = sizeZ;
                
-       // grounding foil world, bounded exactly around the limits of the structure
-       TGeoVolume *container = mgr->MakeBox(Form("GFOIL_%s", type), vacuum, 0.5*length, 0.5*sizeYMax, 0.5*sizeZ);
-       
+       // grounding foil world, bounded exactly around the limits 
+       // of the structure
+       TGeoVolume *container = mgr->MakeBox(Form("GFOIL_%s", type), 
+                             vacuum, 0.5*length, 0.5*sizeYMax, 0.5*sizeZ);
+
        // === PART 1: box with holes ===
-       
+
        TGeoBBox *shBox1 = 0, *shHole = 0;
-       shBox1 = new TGeoBBox(Form("GF%s_BOX1", type), 0.5*part1X, 0.5*sizeYMax, 0.5*sizeZ);
-       shHole = new TGeoBBox(Form("GF%s_HOLE", type), 0.5*holeX, 0.5*holeY, 0.5*sizeZ + 0.01);
-       
+       shBox1 = new TGeoBBox(Form("GF%s_BOX1", type), 0.5*part1X, 
+                             0.5*sizeYMax, 0.5*sizeZ);
+       shHole = new TGeoBBox(Form("GF%s_HOLE", type), 0.5*holeX, 0.5*holeY, 
+                             0.5*sizeZ + 0.01);
+
        // define the position of all holes and compose the expression
        // to define the composite shape (box - holes)
        Double_t firstX = -0.5*part1X + holeFirstX;
@@ -1538,16 +1660,21 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
        for (Int_t i = 0; i < 10; i++) {
                transX = firstX + (Double_t)i * holeSepX;
                if (i > 4) transX += holeSepX1;
-               transHole[i] = new TGeoTranslation(Form("TGF%s_HOLE%d", type, i), transX, transY, 0.0);
+               transHole[i] = new TGeoTranslation(Form("TGF%s_HOLE%d",type,i),
+                                                  transX, transY, 0.0);
                transHole[i]->RegisterYourself();
-               strComposite.Append(Form("%s:%s", shHole->GetName(), transHole[i]->GetName()));
-               if (i < 9) strComposite.Append("+"); else strComposite.Append(")");
-}
+               strComposite.Append(Form("%s:%s", shHole->GetName(),
+                                        transHole[i]->GetName()));
+               if (i < 9) strComposite.Append("+"); 
+               else strComposite.Append(")");
+       } // end for i
        // create composite shape
-       TGeoCompositeShape *shPart1 = new TGeoCompositeShape(Form("GF%s_PART1_SHAPE", type), strComposite.Data());
+       TGeoCompositeShape *shPart1 = new TGeoCompositeShape(
+                          Form("GF%s_PART1_SHAPE", type), strComposite.Data());
        // create the volume
-       TGeoVolume *volPart1 = new TGeoVolume(Form("GF%s_PART1", type), shPart1, material);
-       
+       TGeoVolume *volPart1 = new TGeoVolume(Form("GF%s_PART1", type),
+                                             shPart1, material);
+
        // === PART 2: first trapezoidal connection
        
        TGeoArb8 *shTrap1 = new TGeoArb8(0.5*sizeZ);
@@ -1559,21 +1686,28 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
        shTrap1->SetVertex(5,  0.5*part2X,  0.5*sizeYMax);
        shTrap1->SetVertex(6,  0.5*part2X,  0.5*sizeYMax - sizeYMed1);
        shTrap1->SetVertex(7, -0.5*part2X, -0.5*sizeYMax);
-       TGeoVolume *volPart2 = new TGeoVolume(Form("GF%s_PART2", type), shTrap1, material);
+       TGeoVolume *volPart2 = new TGeoVolume(Form("GF%s_PART2", type),
+                                             shTrap1, material);
        
        // === PART 3: other box with one hole
        
        TGeoBBox *shBox2 = 0;
-       shBox2 = new TGeoBBox(Form("GF%s_BOX2", type), 0.5*part3X, 0.5*sizeYMed1, 0.5*sizeZ);
+       shBox2 = new TGeoBBox(Form("GF%s_BOX2", type), 0.5*part3X,
+                             0.5*sizeYMed1, 0.5*sizeZ);
                
        // define the position of the hole
        transX = holeAloneX - 0.5*part3X;
-       TGeoTranslation *transHoleAlone = new TGeoTranslation(Form("TGF%s_HOLE_ALONE", type), transX, transY, 0.0);
+       TGeoTranslation *transHoleAlone = new TGeoTranslation(
+                        Form("TGF%s_HOLE_ALONE", type), transX, transY, 0.0);
        transHoleAlone->RegisterYourself();
        // create composite shape
-       TGeoCompositeShape *shPart3 = new TGeoCompositeShape(Form("GF%sPART3_SHAPE", type), Form("%s - %s:%s", shBox2->GetName(), shHole->GetName(), transHoleAlone->GetName()));
+       TGeoCompositeShape *shPart3 = new TGeoCompositeShape(
+                        Form("GF%sPART3_SHAPE", type),
+                        Form("%s - %s:%s", shBox2->GetName(),
+                            shHole->GetName(), transHoleAlone->GetName()));
        // create the volume
-       TGeoVolume *volPart3 = new TGeoVolume(Form("GF%s_PART3", type), shPart3, material);
+       TGeoVolume *volPart3 = new TGeoVolume(Form("GF%s_PART3", type),
+                                             shPart3, material);
                
        // === PART 4: second trapezoidal connection
        
@@ -1586,14 +1720,19 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
        shTrap2->SetVertex(5,  0.5*part4X,  0.5*sizeYMed1);
        shTrap2->SetVertex(6,  0.5*part4X,  0.5*sizeYMed1 - sizeYMed2);
        shTrap2->SetVertex(7, -0.5*part4X, -0.5*sizeYMed1);
-       TGeoVolume *volPart4 = new TGeoVolume(Form("GF%s_PART4", type), shTrap2, material);
+       TGeoVolume *volPart4 = new TGeoVolume(Form("GF%s_PART4", type),
+                                             shTrap2, material);
                
        // === PART 5 --> 8: sequence of boxes ===
        
-       TGeoVolume *volPart5 = mgr->MakeBox(Form("GF%s_BOX3", type), material, 0.5*part5X, 0.5*sizeYMed2, 0.5*sizeZ);
-       TGeoVolume *volPart6 = mgr->MakeBox(Form("GF%s_BOX4", type), material, 0.5*part6X, 0.5*sizeYMin , 0.5*sizeZ);
-       TGeoVolume *volPart7 = mgr->MakeBox(Form("GF%s_BOX5", type), material, 0.5*part7X, 0.5*sizeYMed2, 0.5*sizeZ);
-       TGeoVolume *volPart8 = mgr->MakeBox(Form("GF%s_BOX6", type), material, 0.5*part8X, 0.5*sizeYMin , 0.5*sizeZ);
+       TGeoVolume *volPart5 = mgr->MakeBox(Form("GF%s_BOX3", type),
+                            material, 0.5*part5X, 0.5*sizeYMed2, 0.5*sizeZ);
+       TGeoVolume *volPart6 = mgr->MakeBox(Form("GF%s_BOX4", type),
+                            material, 0.5*part6X, 0.5*sizeYMin , 0.5*sizeZ);
+       TGeoVolume *volPart7 = mgr->MakeBox(Form("GF%s_BOX5", type),
+                            material, 0.5*part7X, 0.5*sizeYMed2, 0.5*sizeZ);
+       TGeoVolume *volPart8 = mgr->MakeBox(Form("GF%s_BOX6", type), 
+                             material, 0.5*part8X, 0.5*sizeYMin , 0.5*sizeZ);
        
        // === SET COLOR ===
        if (kaptonLayer) {
@@ -1605,8 +1744,7 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
                volPart6->SetLineColor(kRed + 3);
                volPart7->SetLineColor(kRed + 3);
                volPart8->SetLineColor(kRed + 3);
-       }
-       else {
+       }else{
                volPart1->SetLineColor(kGreen);
                volPart2->SetLineColor(kGreen);
                volPart3->SetLineColor(kGreen);
@@ -1615,7 +1753,7 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
                volPart6->SetLineColor(kGreen);
                volPart7->SetLineColor(kGreen);
                volPart8->SetLineColor(kGreen);
-       }
+       } // end if (kaptonLayer)
                
        // === TRANSLATION OF ALL PARTS ===
        
@@ -1654,42 +1792,49 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoilSingle
        return container;
 }
 
-//___________________________________________________________________________________________________________________
-TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoil(Double_t &thickness, TGeoManager *mgr)
-{
-       //
+//______________________________________________________________________
+TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoil(Double_t &thickness,
+                                                      TGeoManager *mgr){
        // Joins two Kapton and two Aluminum layers of the grounding foil
        // in order to create the complete grounding foil for a whole stave.
        // into a unique container volume, which is returned as output.
-       // The use of the TGeoXtru shape requires that in the separate foils, the Z axis
-       // lies perpendicularly to the polygonal basis of this shape; this caused the components
-       // to have their Z axis corresponding to the X axis of the ALICE reference frame and 
-       // vieceversa; to correct this, a rotation is necessary around their middle axis, 
-       // to exchange X and Z axes and displace the object correctly in the ALICE frame.
+       // The use of the TGeoXtru shape requires that in the separate 
+        // foils, the Z axis lies perpendicularly to the polygonal basis 
+        // of this shape;  this caused the components to have their Z 
+        // axis corresponding to the X axis of the ALICE reference frame 
+        // and vieceversa; to correct this, a rotation is necessary 
+        // around their middle axis, to exchange X and Z axes and displace 
+        // the object correctly in the ALICE frame.
        // ---
        // Arguments:
-       //  - the sizes of the container box (passed by reference and filled here)
+       //  - the sizes of the container box (passed by reference and 
+        //    filled here)
        //  - the TGeoManager
        // ---
        // Returns: 
        //  - the container TGeoBBox (return value)
        //  - the size of the container (reference variables)
        //
-       
+
        // sizes of the added volumes, which are filled by passing them 
        // to the volume creation methods
        Double_t kpLength, kpWidth, kpThick;
        Double_t alLength, alWidth, alThick;
-       Double_t separation = fgkmm * 1.42;  // separation between left and right volumes
-       
-       // create the two component volumes (each one will be replicated twice)
-       // this gives also the size of their virtual container boxes (just a reference, not a volume)
-       TGeoVolume *kVol = CreateGroundingFoilSingle(kTRUE, kpLength, kpWidth, kpThick, mgr);
-       TGeoVolume *aVol = CreateGroundingFoilSingle(kFALSE, alLength, alWidth, alThick, mgr);
+       // separation between left and right volumes
+       Double_t separation = fgkmm * 1.42;
+       
+       // create the two component volumes (each one will be replicated 
+       // twice) this gives also the size of their virtual container 
+       // boxes (just a reference, not a volume)
+       TGeoVolume *kVol = CreateGroundingFoilSingle(kTRUE, kpLength, 
+                                                    kpWidth, kpThick, mgr);
+       TGeoVolume *aVol = CreateGroundingFoilSingle(kFALSE, alLength, 
+                                                    alWidth, alThick, mgr);
        kVol->SetLineColor(kRed);
        aVol->SetLineColor(kGray);
        
-       // kapton leads the total size of the foil (including spagcing of 1.42 mm between them in the center)
+       // kapton leads the total size of the foil (including spagcing 
+       // of 1.42 mm between them in the center)
        Double_t length, width;
        length    = 2.0 * kpLength + separation;
        width     = kpWidth;
@@ -1697,7 +1842,8 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoil(Double_t &thickness, TGeoM
        
        // create the container
        TGeoMedium *vacuum = mgr->GetMedium("VACUUM");
-       TGeoVolume *container = mgr->MakeBox("GFOIL", vacuum, 0.5*thickness, 0.5*width, 0.5*length);
+       TGeoVolume *container = mgr->MakeBox("GFOIL", vacuum, 0.5*thickness, 
+                                            0.5*width, 0.5*length);
        
        // create the common correction rotations
        TGeoRotation *rotCorr1 = new TGeoRotation(*gGeoIdentity);
@@ -1705,13 +1851,22 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoil(Double_t &thickness, TGeoM
        rotCorr1->RotateY(-90.0);
        rotCorr2->RotateY( 90.0);
                
-       // compute the translations to place the objects at the edges of the volume
-       // the kapton foils are also shifted down, and the aluminum foils are shifted up
-       // with respect to the thickness direction
-       TGeoTranslation *kTrans1 = new TGeoTranslation(0.5*(-thickness + kpThick), 0.0, 0.5*( length - kpLength));
-       TGeoTranslation *kTrans2 = new TGeoTranslation(0.5*(-thickness + kpThick), 0.0, 0.5*(-length + kpLength));
-       TGeoTranslation *aTrans1 = new TGeoTranslation(0.5*( thickness - alThick), 0.0, 0.5*( length - alLength) - 0.02);
-       TGeoTranslation *aTrans2 = new TGeoTranslation(0.5*( thickness - alThick), 0.0, 0.5*(-length + alLength) + 0.02);
+       // compute the translations to place the objects at the edges of 
+       // the volume the kapton foils are also shifted down, and the 
+       // aluminum foils are shifted up with respect to the thickness 
+       // direction
+       TGeoTranslation *kTrans1 = new TGeoTranslation(0.5*(-thickness+kpThick),
+                                                      0.0,
+                                                      0.5*(length-kpLength));
+       TGeoTranslation *kTrans2 = new TGeoTranslation(0.5*(-thickness+kpThick),
+                                                      0.0,
+                                                      0.5*(-length+kpLength));
+       TGeoTranslation *aTrans1 = new TGeoTranslation(0.5*(thickness-alThick),
+                                                      0.0,
+                                                   0.5*(length-alLength)-0.02);
+       TGeoTranslation *aTrans2 = new TGeoTranslation(0.5*(thickness-alThick),
+                                                      0.0,
+                                                  0.5*(-length+alLength)+0.02);
        
        // combine translations and rotations
        TGeoCombiTrans *kCombi1 = new TGeoCombiTrans(*kTrans1, *rotCorr1);
@@ -1729,24 +1884,26 @@ TGeoVolume* AliITSv11GeometrySPD::CreateGroundingFoil(Double_t &thickness, TGeoM
 }
 
 //______________________________________________________________________
-TGeoVolume* AliITSv11GeometrySPD::CreateMCMBase(TGeoManager *geom) const
-{
-       //
+TGeoVolume* AliITSv11GeometrySPD::CreateMCMBase(TGeoManager *geom) const{
        // Creates the MCM basis volume.
        // It is a little bit more complicated because this is a plain base
-       // with a poly shape similar to the one of grounding foil but there are also
-       // some chips glued to its base and covered with a cave cap.
+       // with a poly shape similar to the one of grounding foil but 
+        // there are also some chips glued to its base and covered with 
+        // a cave cap.
        // ---
        // The complete MCM object is created as the sum of the following parts:
        // 1) a planar basis shaped according to the MCM typical shape
-       // 2) some boxes which represent the chips and devices mounted on this base
+       // 2) some boxes which represent the chips and devices mounted on 
+        //    this base
        // 3) a cave cap which covers the portion of MCM containing these chips
        // ---
-       // Due to the different widths of MCM, it is implemented in a more complicated way:
-       // - cap and chips will define a sub-volume of this structure, which can be bounded
-       //   by a complete box
+       // Due to the different widths of MCM, it is implemented in a 
+        // more complicated way:
+       // - cap and chips will define a sub-volume of this structure, 
+        //   which can be bounded by a complete box
        // - base of MCM will be a separate volume
-       // - these two objects will need to be glued together into an upper-level volume
+       // - these two objects will need to be glued together into an 
+        //  upper-level volume
        // ---
        // This metod creates only the thin base (point 1 in the list)
        //
@@ -1755,10 +1912,11 @@ TGeoVolume* AliITSv11GeometrySPD::CreateMCMBase(TGeoManager *geom) const
        TGeoMedium *medBase = geom->GetMedium("MCM BASE");
        
        // parameterize the interesting sizes of MCM
-       // it is divided into 3 sectors which have different size in X and Y and 
-       // are connected by trapezoidal-based shapes, where the oblique angle
-       // makes a 45 degrees angle with the vertical, so that the X size and Y size
-       // of these "intermezzo"'s is the same
+       // it is divided into 3 sectors which have different size in 
+       // X and Y and are connected by trapezoidal-based shapes, 
+       // where the oblique angle makes a 45 degrees angle with the 
+       // vertical, so that the X size and Y size of these "intermezzo"'s 
+       // is the same
        // +--------------------------------+
        // |                   sect 2       |
        // | sect 1     --------------------+
@@ -1801,12 +1959,15 @@ TGeoVolume* AliITSv11GeometrySPD::CreateMCMBase(TGeoManager *geom) const
        
        // create small hole
        TGeoBBox *shHole = 0;
-       shHole = new TGeoBBox("SH_MCMBASE_HOLE", 0.5*sizeHole, 0.5*sizeHole, 0.5*sizeZ+0.01);
-       TGeoTranslation *transHole = new TGeoTranslation("TR_MCMBASE_HOLE", posHoleX, posHoleY, 0.0);
+       shHole = new TGeoBBox("SH_MCMBASE_HOLE", 0.5*sizeHole, 0.5*sizeHole, 
+                             0.5*sizeZ+0.01);
+       TGeoTranslation *transHole = new TGeoTranslation("TR_MCMBASE_HOLE", 
+                                                   posHoleX, posHoleY, 0.0);
        transHole->RegisterYourself(); 
        
        // create shape intersection
-       TGeoCompositeShape *shBase = new TGeoCompositeShape("SH_MCMBASE", "SH_MCMBASE_POLY - SH_MCMBASE_HOLE:TR_MCMBASE_HOLE");
+       TGeoCompositeShape *shBase = new TGeoCompositeShape("SH_MCMBASE",
+                          "SH_MCMBASE_POLY - SH_MCMBASE_HOLE:TR_MCMBASE_HOLE");
        
        // create volume
        TGeoVolume *volBase = new TGeoVolume("VOL_MCMBASE", shBase, medBase);
@@ -1814,31 +1975,32 @@ TGeoVolume* AliITSv11GeometrySPD::CreateMCMBase(TGeoManager *geom) const
        
        return volBase;
 }
-
-
 //______________________________________________________________________
-TGeoVolume* AliITSv11GeometrySPD::CreateMCMCoverBorder(TGeoManager *geom)
-{
-       //
+TGeoVolume* AliITSv11GeometrySPD::CreateMCMCoverBorder(TGeoManager *geom){
        // Creates the MCM basis volume.
        // It is a little bit more complicated because this is a plain base
-       // with a poly shape similar to the one of grounding foil but there are also
-       // some chips glued to its base and covered with a cave cap.
+       // with a poly shape similar to the one of grounding foil but there 
+        // are also some chips glued to its base and covered with a cave cap.
        // ---
        // The complete MCM object is created as the sum of the following parts:
        // 1) a planar basis shaped according to the MCM typical shape
-       // 2) some boxes which represent the chips and devices mounted on this base
+       // 2) some boxes which represent the chips and devices mounted on 
+        //  this base
        // 3) a cave cap which covers the portion of MCM containing these chips
        // ---
-       // Due to the different widths of MCM, it is implemented in a more complicated way:
-       // - cap and chips will define a sub-volume of this structure, which can be bounded
-       //   by a complete box
+       // Due to the different widths of MCM, it is implemented in a more 
+        // complicated way:
+       // - cap and chips will define a sub-volume of this structure, 
+        //   which can be bounded by a complete box
        // - base of MCM will be a separate volume
-       // - these two objects will need to be glued together into an upper-level volume
+       // - these two objects will need to be glued together into an 
+        //   upper-level volume
        // ---
-       // This metod creates the thicker cap and its contents (points 2-3 in the list).
-       // Since it covers only two of the three sectors of the MCM base with different width
-       // the computations and variables related to the largest sector are removed, while
+       // This metod creates the thicker cap and its contents (points 2-3 
+        // in the list). Since it covers only two of the three sectors of 
+        // the MCM base with different width
+       // the computations and variables related to the largest sector 
+        // are removed, while
        // the other are the same as the other part of the MCM.
        //
        
@@ -1846,10 +2008,11 @@ TGeoVolume* AliITSv11GeometrySPD::CreateMCMCoverBorder(TGeoManager *geom)
        TGeoMedium *medCap  = geom->GetMedium("MCM COVER");
        
        // parameterize the interesting sizes of MCM
-       // it is divided into 3 sectors which have different size in X and Y and 
-       // are connected by trapezoidal-based shapes, where the oblique angle
-       // makes a 45 degrees angle with the vertical, so that the X size and Y size
-       // of these "intermezzo"'s is the same
+       // it is divided into 3 sectors which have different size in 
+       // X and Y and  are connected by trapezoidal-based shapes, 
+       // where the oblique angle makes a 45 degrees angle with the 
+       // vertical, so that the X size and Y size of these "intermezzo"'s 
+       // is the same
        // +--------------------------------+
        // |                   sect 2       |
        // | sect 1     --------------------+
@@ -1911,49 +2074,54 @@ TGeoVolume* AliITSv11GeometrySPD::CreateMCMCoverBorder(TGeoManager *geom)
        capIn->DefineSection(1,  0.5*capHeight+0.01, 0., 0., 1.0);
        
        // compose shape
-       TGeoCompositeShape *shBorder = new TGeoCompositeShape("SH_MCMCAPBORDER", "SH_MCMCAPOUT-SH_MCMCAPIN");
+       TGeoCompositeShape *shBorder = new TGeoCompositeShape("SH_MCMCAPBORDER",
+                                "SH_MCMCAPOUT-SH_MCMCAPIN");
        
        // create volume
-       TGeoVolume *volBorder = new TGeoVolume("VOL_MCMCAPBORDER", shBorder, medCap);
+       TGeoVolume *volBorder = new TGeoVolume("VOL_MCMCAPBORDER", shBorder,
+                                              medCap);
        volBorder->SetLineColor(kGreen);
        
        return volBorder;
 }
-
 //______________________________________________________________________
-TGeoVolume* AliITSv11GeometrySPD::CreateMCMCoverTop(TGeoManager *geom)
-{
-       //
+TGeoVolume* AliITSv11GeometrySPD::CreateMCMCoverTop(TGeoManager *geom){
        // Creates the MCM basis volume.
        // It is a little bit more complicated because this is a plain base
-       // with a poly shape similar to the one of grounding foil but there are also
+       // with a poly shape similar to the one of grounding foil but 
+        // there are also
        // some chips glued to its base and covered with a cave cap.
        // ---
        // The complete MCM object is created as the sum of the following parts:
        // 1) a planar basis shaped according to the MCM typical shape
-       // 2) some boxes which represent the chips and devices mounted on this base
+       // 2) some boxes which represent the chips and devices mounted on 
+        //    this base
        // 3) a cave cap which covers the portion of MCM containing these chips
        // ---
-       // Due to the different widths of MCM, it is implemented in a more complicated way:
-       // - cap and chips will define a sub-volume of this structure, which can be bounded
-       //   by a complete box
+       // Due to the different widths of MCM, it is implemented in a 
+        // more complicated way:
+       // - cap and chips will define a sub-volume of this structure, 
+        //   which can be bounded by a complete box
        // - base of MCM will be a separate volume
-       // - these two objects will need to be glued together into an upper-level volume
+       // - these two objects will need to be glued together into an 
+        //   upper-level volume
        // ---
-       // This metod creates the thicker cap and its contents (points 2-3 in the list).
-       // Since it covers only two of the three sectors of the MCM base with different width
-       // the computations and variables related to the largest sector are removed, while
-       // the other are the same as the other part of the MCM.
+       // This metod creates the thicker cap and its contents (points 
+        // 2-3 in the list). Since it covers only two of the three 
+        // sectors of the MCM base with different width
+       // the computations and variables related to the largest sector 
+        // are removed, while the other are the same as the other part 
+        // of the MCM.
        //
-       
+
        // media
        TGeoMedium *medCap  = geom->GetMedium("MCM COVER");
        
        // parameterize the interesting sizes of MCM
-       // it is divided into 3 sectors which have different size in X and Y and 
-       // are connected by trapezoidal-based shapes, where the oblique angle
-       // makes a 45 degrees angle with the vertical, so that the X size and Y size
-       // of these "intermezzo"'s is the same
+       // it is divided into 3 sectors which have different size in X 
+       // and Y and  are connected by trapezoidal-based shapes, where 
+       // the oblique angle makes a 45 degrees angle with the vertical, 
+       // so that the X size and Y size of these "intermezzo"'s is the same
        // +--------------------------------+
        // |                   sect 2       |
        // | sect 1     --------------------+
@@ -2014,23 +2182,22 @@ TGeoVolume* AliITSv11GeometrySPD::CreateMCMCoverTop(TGeoManager *geom)
        shCover->DefineSection(1,  0.5*sizeZ, 0., 0., 1.0);
        
        // create volume
-       TGeoVolume *volCover  = new TGeoVolume("VOL_MCMCAPCOVER", shCover, medCap);
+       TGeoVolume *volCover  = new TGeoVolume("VOL_MCMCAPCOVER", shCover, 
+                                              medCap);
        volCover->SetLineColor(kBlue);
        
        return volCover;
 }
-
 //______________________________________________________________________
-TGeoVolumeAssembly* AliITSv11GeometrySPD::CreateStave
-(Int_t layer, Double_t &fullThickness, TGeoManager *mgr)
-{
-       //
-       // Creates the complete stave as an assembly which contains all the stuff defined
-       // in the "CreateStaveBase" method (which are the thin part of the structure)
-       // and adds to this the thick cover of the MCM and the Pixel bus.
-       // This is done as an assembly to avoid the problem of a "ghost" overlap which occurs
-       // when putting the stave on the carbon fiber sector, in the case that we define it
-       // as a volume container.
+TGeoVolumeAssembly* AliITSv11GeometrySPD::CreateStave(Int_t layer, 
+                             Double_t &fullThickness, TGeoManager *mgr){
+       // Creates the complete stave as an assembly which contains all 
+        // the stuff defined in the "CreateStaveBase" method (which are 
+        // the thin part of the structure) and adds to this the thick 
+        // cover of the MCM and the Pixel bus. This is done as an 
+        // assembly to avoid the problem of a "ghost" overlap which occurs
+       // when putting the stave on the carbon fiber sector, in the case 
+        // that we define it as a volume container.
        // ---
        // Arguments:
        //     - the layer where the stave has to be put (hard check on this)
@@ -2039,7 +2206,8 @@ TGeoVolumeAssembly* AliITSv11GeometrySPD::CreateStave
        
        // ** CRITICAL CHECK **
        // layer number can be ONLY 1 or 2
-       if (layer != 1 && layer != 2) AliFatal("Required that layer number be 1 or 2");
+       if (layer != 1 && layer != 2) 
+         AliFatal("Required that layer number be 1 or 2");
        
        // sizes regarding the components
        Double_t baseWidth, baseHeight, baseThickness;
@@ -2049,18 +2217,23 @@ TGeoVolumeAssembly* AliITSv11GeometrySPD::CreateStave
        Double_t mcmCapWidth           = fgkmm * 73.2;
        
        // create container
-       TGeoVolumeAssembly *container = new TGeoVolumeAssembly(Form("LAY%d_FULLSTAVE", layer));
+       TGeoVolumeAssembly *container = new TGeoVolumeAssembly(
+                                         Form("LAY%d_FULLSTAVE", layer));
        
        // create subvolumes
-       TGeoVolume *staveBase = CreateStaveBase(layer, baseWidth, baseHeight, baseThickness, mgr);
+       TGeoVolume *staveBase = CreateStaveBase(layer, baseWidth, baseHeight, 
+                                               baseThickness, mgr);
        TGeoVolume *mcmCapBorder = CreateMCMCoverBorder(mgr);
        TGeoVolume *mcmCapTop = CreateMCMCoverTop(mgr);
-       TGeoVolumeAssembly *bus0 = CreatePixelBusAndExtensions(kTRUE, mgr);   // bus in z > 0
-       TGeoVolumeAssembly *bus1 = CreatePixelBusAndExtensions(kFALSE, mgr);  // bus in z < 0
-       
-       // the full width and height of the area which contains all components
-       // corresponds to the one of the stave base built with the "CreateStaveBase" method
-       // while the thickness must be computed as the sum of this base + the cover
+       // bus in z > 0
+       TGeoVolumeAssembly *bus0 = CreatePixelBusAndExtensions(kTRUE, mgr);
+       // bus in z < 0
+       TGeoVolumeAssembly *bus1 = CreatePixelBusAndExtensions(kFALSE, mgr);
+       
+       // the full width and height of the area which contains all 
+       // components corresponds to the one of the stave base built with 
+       // the "CreateStaveBase" method while the thickness must be 
+       // computed as the sum of this base + the cover
        fullThickness = baseThickness + mcmCapThickness + mcmCapBorderThickness;
        
        // 1 - MCM cover        
@@ -2069,7 +2242,8 @@ TGeoVolumeAssembly* AliITSv11GeometrySPD::CreateStave
        Double_t xBase = -0.5*fullThickness + 0.5*baseThickness;
        TGeoTranslation *trBase = new TGeoTranslation(xBase, 0.0, 0.0);
        Double_t xMCMCapB = xBase + 0.5*baseThickness + 0.5*mcmCapThickness;
-       Double_t xMCMCapT = xMCMCapB + 0.5*mcmCapThickness + 0.5*mcmCapBorderThickness;
+       Double_t xMCMCapT = xMCMCapB + 0.5*mcmCapThickness + 
+                                                 0.5*mcmCapBorderThickness;
        Double_t yMCMCap  = 0.5*(baseHeight - mcmCapHeight);
        Double_t zMCMCap1 = 0.5*baseWidth - 0.5*mcmCapWidth;
        Double_t zMCMCap0 = -zMCMCap1;
@@ -2078,10 +2252,14 @@ TGeoVolumeAssembly* AliITSv11GeometrySPD::CreateStave
        TGeoRotation *rotCorr1 = new TGeoRotation(*gGeoIdentity);
        rotCorr0->RotateY( 90.0);
        rotCorr1->RotateY(-90.0);
-       TGeoCombiTrans  *trMCMCapBorder0 = new TGeoCombiTrans(xMCMCapB, yMCMCap, zMCMCap0, rotCorr0);
-       TGeoCombiTrans  *trMCMCapBorder1 = new TGeoCombiTrans(xMCMCapB, yMCMCap, zMCMCap1, rotCorr1);
-       TGeoCombiTrans  *trMCMCapTop0 = new TGeoCombiTrans(xMCMCapT, yMCMCap, zMCMCap0, rotCorr0);
-       TGeoCombiTrans  *trMCMCapTop1 = new TGeoCombiTrans(xMCMCapT, yMCMCap, zMCMCap1, rotCorr1);
+       TGeoCombiTrans  *trMCMCapBorder0 = new TGeoCombiTrans(xMCMCapB, 
+                                             yMCMCap, zMCMCap0, rotCorr0);
+       TGeoCombiTrans  *trMCMCapBorder1 = new TGeoCombiTrans(xMCMCapB, 
+                                             yMCMCap, zMCMCap1, rotCorr1);
+       TGeoCombiTrans  *trMCMCapTop0 = new TGeoCombiTrans(xMCMCapT, 
+                                             yMCMCap, zMCMCap0, rotCorr0);
+       TGeoCombiTrans  *trMCMCapTop1 = new TGeoCombiTrans(xMCMCapT, 
+                                             yMCMCap, zMCMCap1, rotCorr1);
        // add to container
        container->AddNode(staveBase, 0, trBase);
        container->AddNode(mcmCapBorder, 0, trMCMCapBorder0);
@@ -2092,21 +2270,27 @@ TGeoVolumeAssembly* AliITSv11GeometrySPD::CreateStave
        // 2 - Pixel Bus
        
        // translations
-       // for the moment, a correction amount of 0.04 is required to place correctly the object in X
-       // and another correction of 0.015 in Z
+       // for the moment, a correction amount of 0.04 is required to 
+       // place correctly the object in X and another correction of 
+       // 0.015 in Z
        Double_t busHeight  = fgkmm * 13.8;
        Double_t xPixelBus  = xBase + baseThickness + 0.04;
-       Double_t yPixelBus1 = 0.5*baseHeight - 0.5*busHeight + 0.5*(baseHeight - busHeight);
+       Double_t yPixelBus1 = 0.5*baseHeight - 0.5*busHeight + 
+                                      0.5*(baseHeight - busHeight);
        Double_t zPixelBus0 = -0.25*baseWidth + 0.015 - 0.03;
        //Double_t zPixelBus0 = -0.5*(0.5*baseWidth - 0.04);
        Double_t zPixelBus1 = -zPixelBus0;
        // correction rotations
        TGeoRotation *rotCorrBus1 = new TGeoRotation(*gGeoIdentity);
        rotCorrBus1->RotateX(180.0);
-       //TGeoCombiTrans *trBus0 = new TGeoCombiTrans(xPixelBus, 0.0, zPixelBus0, rotCorrBus);
-       TGeoTranslation *trBus0 = new TGeoTranslation(xPixelBus, 0.0, zPixelBus0);
-       //TGeoTranslation *trBus1 = new TGeoTranslation(xPixelBus, 0.0, zPixelBus1);
-       TGeoCombiTrans *trBus1 = new TGeoCombiTrans(xPixelBus, yPixelBus1, zPixelBus1, rotCorrBus1);
+       //TGeoCombiTrans *trBus0 = new TGeoCombiTrans(xPixelBus, 0.0, 
+       //                                     zPixelBus0, rotCorrBus);
+       TGeoTranslation *trBus0 = new TGeoTranslation(xPixelBus, 0.0, 
+                                                           zPixelBus0);
+       //TGeoTranslation *trBus1 = new TGeoTranslation(xPixelBus, 0.0, 
+       //                                                 zPixelBus1);
+       TGeoCombiTrans *trBus1 = new TGeoCombiTrans(xPixelBus, yPixelBus1, 
+                                                   zPixelBus1, rotCorrBus1);
 
        // add to container
        container->AddNode(bus0, 0, trBus0);
@@ -2114,11 +2298,9 @@ TGeoVolumeAssembly* AliITSv11GeometrySPD::CreateStave
        
        return container;
 }
-
 //______________________________________________________________________
-TGeoVolumeAssembly* AliITSv11GeometrySPD::CreatePixelBusAndExtensions(Bool_t zpos, TGeoManager *mgr)
-{
-  //
+TGeoVolumeAssembly* AliITSv11GeometrySPD::CreatePixelBusAndExtensions(
+                                     Bool_t zpos, TGeoManager *mgr){
   // Creates an assembly which contains the pixel bus and its extension
   // and the extension of the MCM.
   // By: Renaud Vernet
@@ -2139,8 +2321,10 @@ TGeoVolumeAssembly* AliITSv11GeometrySPD::CreatePixelBusAndExtensions(Bool_t zpo
   const Double_t kGroundingWidthX       = 170.501 * fgkmm ;
   const Double_t kPixelBusContactDx     =   1.099 * fgkmm ;
   const Double_t kPixelBusWidthY        =  13.8   * fgkmm ;
-  const Double_t kPixelBusContactPhi    =  20.0   * TMath::Pi()/180. ; //design=20 deg.
-  const Double_t kPbExtenderPsi         =  70.0   * TMath::Pi()/180. ; //design=?? 70 deg. seems OK
+  //design=20 deg.
+  const Double_t kPixelBusContactPhi    =  20.0   * TMath::DegToRad();
+  //design=?? 70 deg. seems OK
+  const Double_t kPbExtenderPsi         =  70.0   * TMath::DegToRad(); 
   const Double_t kPbExtenderWidthY      =  11.0   * fgkmm ;
   const Double_t kPbExtenderTopZ        =   2.72  * fgkmm ;
   const Double_t kMcmThickness          =   0.35  * fgkmm ;
@@ -2151,13 +2335,19 @@ TGeoVolumeAssembly* AliITSv11GeometrySPD::CreatePixelBusAndExtensions(Bool_t zpo
   const Double_t kDeltaXOrigin          =   1.1    * fgkmm ;
   const Double_t kDeltaZOrigin          = kHalfStaveTotalLength / 2. ;
 
-  const Double_t kGrounding2pixelBusDz2 = kGrounding2pixelBusDz+kGroundingThickness/2. + kPixelBusThickness/2. ;
+  const Double_t kGrounding2pixelBusDz2 = kGrounding2pixelBusDz+
+                            kGroundingThickness/2. + kPixelBusThickness/2. ;
   const Double_t kPixelBusWidthX        = kGroundingWidthX ;
-  const Double_t kPixelBusRaiseLength   = (kPixelBusContactDx-kPixelBusThickness*TMath::Sin(kPixelBusContactPhi))/TMath::Cos(kPixelBusContactPhi) ;
-  const Double_t kPbExtenderBaseZ       = kGrounding2pixelBusDz2 + kPixelBusRaiseLength*TMath::Sin(kPixelBusContactPhi) + 2*kPixelBusThickness*TMath::Sin(kPixelBusContactPhi)*TMath::Tan(kPixelBusContactPhi) ;
+  const Double_t kPixelBusRaiseLength   = (kPixelBusContactDx-
+             kPixelBusThickness*TMath::Sin(kPixelBusContactPhi))/
+                                      TMath::Cos(kPixelBusContactPhi) ;
+  const Double_t kPbExtenderBaseZ       = kGrounding2pixelBusDz2 + 
+              kPixelBusRaiseLength*TMath::Sin(kPixelBusContactPhi) + 
+              2*kPixelBusThickness*TMath::Sin(kPixelBusContactPhi)*
+              TMath::Tan(kPixelBusContactPhi) ;
   const Double_t kPbExtenderDeltaZ      = kPbExtenderTopZ-kPbExtenderBaseZ ;
-
-  const Double_t kPbExtenderEndPointX   = 2*kDeltaZOrigin - kGroundingWidthX - 2*kPixelBusThickness*TMath::Sin(kPixelBusContactPhi) ;
+  const Double_t kPbExtenderEndPointX   = 2*kDeltaZOrigin - kGroundingWidthX - 
+                        2*kPixelBusThickness*TMath::Sin(kPixelBusContactPhi) ;
   const Double_t kMcmextenderEndPointX  = kDeltaZOrigin - 48.2 * fgkmm ;
   const Double_t kMcmExtenderWidthY     = kPbExtenderWidthY ;
 
@@ -2190,58 +2380,64 @@ TGeoVolumeAssembly* AliITSv11GeometrySPD::CreatePixelBusAndExtensions(Bool_t zpo
     -kPixelBusWidthX/2. ,
     kPixelBusWidthX/2. ,
     kPixelBusWidthX/2. + kPixelBusThickness * TMath::Sin(kPixelBusContactPhi) ,
-    kPixelBusWidthX/2. + kPixelBusThickness * TMath::Sin(kPixelBusContactPhi) + kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi) ,
-    kPixelBusWidthX/2. + kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi) ,
+    kPixelBusWidthX/2. + kPixelBusThickness * TMath::Sin(kPixelBusContactPhi) +
+                       kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi) ,
+    kPixelBusWidthX/2. + kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi),
     kPixelBusWidthX/2. ,
     -kPixelBusWidthX/2.
   } ;
   Double_t pixelBusXtruY[7] = {
     -kPixelBusThickness/2. ,
     -kPixelBusThickness/2. ,
-    -kPixelBusThickness/2. + kPixelBusThickness * (1 - TMath::Cos(kPixelBusContactPhi)) ,
-    -kPixelBusThickness/2. + kPixelBusThickness * (1 - TMath::Cos(kPixelBusContactPhi)) + kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) ,
-    kPixelBusThickness/2.  + kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) ,
+    -kPixelBusThickness/2. + kPixelBusThickness *
+                                 (1 - TMath::Cos(kPixelBusContactPhi)) ,
+    -kPixelBusThickness/2. + kPixelBusThickness *
+                                 (1 - TMath::Cos(kPixelBusContactPhi)) +
+                  kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) ,
+    kPixelBusThickness/2.  + kPixelBusRaiseLength * 
+                                  TMath::Sin(kPixelBusContactPhi) ,
     kPixelBusThickness/2. ,
     kPixelBusThickness/2.
   } ;
 
   // creation of the volume
   TGeoXtru   *pixelBusXtru    = new TGeoXtru(2);
-  TGeoVolume* pixelBusXtruVol = new TGeoVolume("pixelBusXtru",pixelBusXtru,medPixelBus) ;
+  TGeoVolume* pixelBusXtruVol = new TGeoVolume("pixelBusXtru",
+                                                pixelBusXtru,medPixelBus) ;
   pixelBusXtru->DefinePolygon(7,pixelBusXtruX,pixelBusXtruY);
   pixelBusXtru->DefineSection(0,-kPixelBusWidthY/2.);
   pixelBusXtru->DefineSection(1, kPixelBusWidthY/2.);
-  // --------------- END PIXEL BUS ----------------------------------------------------
+  // --------------- END PIXEL BUS -------------------------------------
 
 
-  // ------------------------- CREATE THE PIXEL BUS EXTENDER --------------------------
+  // ------------------------- CREATE THE PIXEL BUS EXTENDER -----------
   // The geometry of the extender is a bit complicated sinceit is constrained
   // to be in contact with the pixel bus.
   // It consists of an extrusion using 13 points as shows the scheme below :
-  //                                                                                     
-  //                             8     7                       6                         
-  //                               +---+---------------------+                           
-  //                              /                          |                           
-  //                             /                           |                           
-  //                            /      +---------------------+                           
-  //                           /      / 4                     5                          
-  //                          /      /                                                   
-  //       11  10          9 /      /                                                    
-  //        +---+-----------+      /                                                     
-  //       /                      /                                                      
-  //      /                      /                                                       
-  //     /      +-----------+---+                                                        
-  // 12 +      / 1         2     3                                                       
-  //     \    /                                                                          
-  //      \  /                                                                           
-  //        +                                                                            
-  //        0                                                                            
-  //                                                                                     
-
+  //
+  //                             8     7                       6
+  //                               +---+---------------------+
+  //                              /                          |
+  //                             /                           |
+  //                            /      +---------------------+
+  //                           /      / 4                     5
+  //                          /      /
+  //       11  10          9 /      /
+  //        +---+-----------+      /
+  //       /                      /
+  //      /                      /
+  //     /      +-----------+---+
+  // 12 +      / 1         2     3
+  //     \    /
+  //      \  /
+  //        +
+  //        0
 
   // ====   constants   =====
   const Double_t kPbExtenderXtru3L   = 1.5 * fgkmm ; //arbitrary ?
-  const Double_t kPbExtenderXtru4L   = (kPbExtenderDeltaZ + kPixelBusThickness*(TMath::Cos(kPbExtenderPsi)-2))/TMath::Sin(kPbExtenderPsi) ;
+  const Double_t kPbExtenderXtru4L   = (kPbExtenderDeltaZ + 
+                 kPixelBusThickness*(TMath::Cos(kPbExtenderPsi)-2))/
+                     TMath::Sin(kPbExtenderPsi) ;
   //=====  end constants  =====
 
   TGeoVolumeAssembly *pbExtender = new TGeoVolumeAssembly("PIXEL BUS EXTENDER");
@@ -2250,63 +2446,85 @@ TGeoVolumeAssembly* AliITSv11GeometrySPD::CreatePixelBusAndExtensions(Bool_t zpo
     0, 
     kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi) , 
     kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi) + kPbExtenderXtru3L ,
-    kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi) + kPbExtenderXtru3L + kPixelBusThickness * TMath::Sin(kPbExtenderPsi) , 
-    kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi) + kPbExtenderXtru3L + kPixelBusThickness * TMath::Sin(kPbExtenderPsi) + kPbExtenderXtru4L * TMath::Cos(kPbExtenderPsi) ,
+    kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi) + 
+           kPbExtenderXtru3L + kPixelBusThickness * TMath::Sin(kPbExtenderPsi) ,
+    kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi) + 
+           kPbExtenderXtru3L + kPixelBusThickness * 
+           TMath::Sin(kPbExtenderPsi) + kPbExtenderXtru4L * 
+           TMath::Cos(kPbExtenderPsi) ,
     kPbExtenderEndPointX ,
     kPbExtenderEndPointX ,
-    kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi) + kPbExtenderXtru3L + kPixelBusThickness * TMath::Sin(kPbExtenderPsi) + kPbExtenderXtru4L * TMath::Cos(kPbExtenderPsi) ,
-    kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi)  + kPbExtenderXtru3L + kPixelBusThickness * TMath::Sin(kPbExtenderPsi) + kPbExtenderXtru4L * TMath::Cos(kPbExtenderPsi) - kPixelBusThickness * TMath::Sin(kPbExtenderPsi),
+    kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi) + 
+           kPbExtenderXtru3L + kPixelBusThickness * TMath::Sin(kPbExtenderPsi)+
+           kPbExtenderXtru4L * TMath::Cos(kPbExtenderPsi) ,
+    kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi)  + 
+           kPbExtenderXtru3L + kPixelBusThickness * TMath::Sin(kPbExtenderPsi)+
+           kPbExtenderXtru4L * TMath::Cos(kPbExtenderPsi) - kPixelBusThickness*
+           TMath::Sin(kPbExtenderPsi),
     kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi) + kPbExtenderXtru3L ,
     kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi) , 
-    kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi) - kPixelBusThickness*TMath::Sin(kPixelBusContactPhi) , 
+    kPixelBusRaiseLength * TMath::Cos(kPixelBusContactPhi) - 
+          kPixelBusThickness*TMath::Sin(kPixelBusContactPhi) , 
     -kPixelBusThickness * TMath::Sin(kPixelBusContactPhi)
   } ;
   Double_t pbExtenderXtruY[13] = {
     0, 
     kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) , 
     kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) ,
-    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) + kPixelBusThickness * (1-TMath::Cos(kPbExtenderPsi)) ,
-    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) + kPixelBusThickness * (1-TMath::Cos(kPbExtenderPsi)) + kPbExtenderXtru4L * TMath::Sin(kPbExtenderPsi) ,
-    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) + kPixelBusThickness * (1-TMath::Cos(kPbExtenderPsi)) + kPbExtenderXtru4L * TMath::Sin(kPbExtenderPsi) ,
-    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) + kPixelBusThickness * (1-TMath::Cos(kPbExtenderPsi)) + kPbExtenderXtru4L * TMath::Sin(kPbExtenderPsi) + kPixelBusThickness ,
-    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) + kPixelBusThickness * (1-TMath::Cos(kPbExtenderPsi)) + kPbExtenderXtru4L * TMath::Sin(kPbExtenderPsi) + kPixelBusThickness ,
-    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) + kPixelBusThickness + kPbExtenderXtru4L * TMath::Sin(kPbExtenderPsi)
-    ,
-    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) + kPixelBusThickness ,
-    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) + kPixelBusThickness ,
-    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) + kPixelBusThickness*TMath::Cos(kPixelBusContactPhi) ,
+    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) + 
+                  kPixelBusThickness * (1-TMath::Cos(kPbExtenderPsi)) ,
+    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) + 
+                  kPixelBusThickness * (1-TMath::Cos(kPbExtenderPsi)) + 
+                  kPbExtenderXtru4L * TMath::Sin(kPbExtenderPsi) ,
+    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) + 
+                  kPixelBusThickness * (1-TMath::Cos(kPbExtenderPsi)) + 
+                  kPbExtenderXtru4L * TMath::Sin(kPbExtenderPsi) ,
+    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) + 
+                  kPixelBusThickness * (1-TMath::Cos(kPbExtenderPsi)) + 
+                  kPbExtenderXtru4L * TMath::Sin(kPbExtenderPsi) + 
+                  kPixelBusThickness ,
+    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) + 
+                  kPixelBusThickness * (1-TMath::Cos(kPbExtenderPsi)) + 
+                  kPbExtenderXtru4L * TMath::Sin(kPbExtenderPsi) + 
+                  kPixelBusThickness ,
+    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi) + 
+                  kPixelBusThickness + kPbExtenderXtru4L * 
+                  TMath::Sin(kPbExtenderPsi),
+    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi)+kPixelBusThickness ,
+    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi)+kPixelBusThickness ,
+    kPixelBusRaiseLength * TMath::Sin(kPixelBusContactPhi)+kPixelBusThickness*
+                           TMath::Cos(kPixelBusContactPhi) ,
     kPixelBusThickness * TMath::Cos(kPixelBusContactPhi)
   } ;
   
   // creation of the volume
   TGeoXtru   *pbExtenderXtru    = new TGeoXtru(2);
-  TGeoVolume *pbExtenderXtruVol = new TGeoVolume("pbExtenderXtru",pbExtenderXtru,medPBExtender) ;
+  TGeoVolume *pbExtenderXtruVol = new TGeoVolume("pbExtenderXtru",
+                                         pbExtenderXtru,medPBExtender) ;
   pbExtenderXtru->DefinePolygon(13,pbExtenderXtruX,pbExtenderXtruY);
   pbExtenderXtru->DefineSection(0,-kPbExtenderWidthY/2.);
   pbExtenderXtru->DefineSection(1, kPbExtenderWidthY/2.);
-  // -------------- END PIXEL BUS EXTENDER -------------------------------------------------
+  // -------------- END PIXEL BUS EXTENDER -----------------------------
 
 
-  // ------------------   CREATE THE MCM EXTENDER    ------------------------------------
+  // ------------------   CREATE THE MCM EXTENDER    -------------------
   // 
   // The MCM extender is located betwen the MCM and the Pixel Bus Extender
   // It consists of an extrusion using 10 points as shows the scheme below :
-  //                                                                                     
-  //                             7     6                       5                         
-  //                               +---+---------------------+                           
-  //                              /                          |                           
-  //                             /                           |                           
-  //                            /      +---------------------+                           
-  //                           /      / 3                     4                          
-  //                          /      /                                                   
-  //            9          8 /      /                                                    
-  //            +-----------+      /                                                     
-  //            |                 /                                                      
-  //            |                /                                                       
-  //            +-----------+---+                                                        
-  //            0          1     2                                                       
-  //                                                                                     
-
+  //
+  //                             7     6                       5
+  //                               +---+---------------------+
+  //                              /                          |
+  //                             /                           |
+  //                            /      +---------------------+
+  //                           /      / 3                     4
+  //                          /      /
+  //            9          8 /      /
+  //            +-----------+      /
+  //            |                 /
+  //            |                /
+  //            +-----------+---+
+  //            0          1     2
 
   //constants
   const Double_t kMcmExtenderXtru3L  = 1.5  * fgkmm ;
@@ -2317,10 +2535,12 @@ TGeoVolumeAssembly* AliITSv11GeometrySPD::CreatePixelBusAndExtensions(Bool_t zpo
     0 ,
     kMcmExtenderXtru3L ,
     kMcmExtenderXtru3L + kMcmExtenderThickness * TMath::Sin(kPbExtenderPsi) , 
-    kMcmExtenderXtru3L + kMcmExtenderThickness * TMath::Sin(kPbExtenderPsi) + kDeltaMcmMcmextender / TMath::Tan(kPbExtenderPsi) ,
+    kMcmExtenderXtru3L + kMcmExtenderThickness * TMath::Sin(kPbExtenderPsi) + 
+                           kDeltaMcmMcmextender / TMath::Tan(kPbExtenderPsi) ,
     kMcmextenderEndPointX ,
     kMcmextenderEndPointX ,
-    kMcmExtenderXtru3L + kMcmExtenderThickness * TMath::Sin(kPbExtenderPsi) + kDeltaMcmMcmextender / TMath::Tan(kPbExtenderPsi) ,
+    kMcmExtenderXtru3L + kMcmExtenderThickness * TMath::Sin(kPbExtenderPsi) + 
+                           kDeltaMcmMcmextender / TMath::Tan(kPbExtenderPsi) ,
     kMcmExtenderXtru3L + kDeltaMcmMcmextender / TMath::Tan(kPbExtenderPsi) ,
     kMcmExtenderXtru3L ,
     0
@@ -2329,11 +2549,11 @@ TGeoVolumeAssembly* AliITSv11GeometrySPD::CreatePixelBusAndExtensions(Bool_t zpo
   Double_t mcmExtenderXtruY[10] = {
     0 ,
     0 ,
-    kMcmExtenderThickness * (1-TMath::Cos(kPbExtenderPsi)) ,
-    kMcmExtenderThickness * (1-TMath::Cos(kPbExtenderPsi)) + kDeltaMcmMcmextender ,
-    kMcmExtenderThickness * (1-TMath::Cos(kPbExtenderPsi)) + kDeltaMcmMcmextender ,
-    kMcmExtenderThickness * (2-TMath::Cos(kPbExtenderPsi)) + kDeltaMcmMcmextender ,
-    kMcmExtenderThickness * (2-TMath::Cos(kPbExtenderPsi)) + kDeltaMcmMcmextender ,
+    kMcmExtenderThickness*(1.-TMath::Cos(kPbExtenderPsi)),
+    kMcmExtenderThickness*(1.-TMath::Cos(kPbExtenderPsi))+kDeltaMcmMcmextender,
+    kMcmExtenderThickness*(1.-TMath::Cos(kPbExtenderPsi))+kDeltaMcmMcmextender,
+    kMcmExtenderThickness*(2.-TMath::Cos(kPbExtenderPsi))+kDeltaMcmMcmextender,
+    kMcmExtenderThickness*(2.-TMath::Cos(kPbExtenderPsi))+kDeltaMcmMcmextender,
     kMcmExtenderThickness + kDeltaMcmMcmextender ,
     kMcmExtenderThickness ,
     kMcmExtenderThickness ,
@@ -2341,34 +2561,41 @@ TGeoVolumeAssembly* AliITSv11GeometrySPD::CreatePixelBusAndExtensions(Bool_t zpo
 
   // creation of the volume
   TGeoXtru   *mcmExtenderXtru    = new TGeoXtru(2);
-  TGeoVolume *mcmExtenderXtruVol = new TGeoVolume("mcmExtenderXtru",mcmExtenderXtru,medMCMExtender) ;
+  TGeoVolume *mcmExtenderXtruVol = new TGeoVolume("mcmExtenderXtru",
+                                            mcmExtenderXtru,medMCMExtender) ;
   mcmExtenderXtru->DefinePolygon(10,mcmExtenderXtruX,mcmExtenderXtruY);
   mcmExtenderXtru->DefineSection(0,-kMcmExtenderWidthY/2.);
   mcmExtenderXtru->DefineSection(1, kMcmExtenderWidthY/2.);
 
 
-  //--------------   DEFINITION OF GEOMETRICAL TRANSFORMATIONS -------------------
+  //--------------   DEFINITION OF GEOMETRICAL TRANSFORMATIONS ---------
   TGeoRotation    * commonRot       = new TGeoRotation("commonRot",0,90,0);
   commonRot->MultiplyBy(new TGeoRotation("rot",-90,0,0)) ;
-  TGeoTranslation * pixelBusTrans   = new TGeoTranslation(kPixelBusThickness/2. - kDeltaXOrigin + 0.52*fgkmm ,
-                                                         -kPixelBusWidthY/2.     + kDeltaYOrigin , 
-                                                         -kGroundingWidthX/2.    + kDeltaZOrigin) ;
+  TGeoTranslation * pixelBusTrans   = new TGeoTranslation(kPixelBusThickness/2.
+                                                - kDeltaXOrigin + 0.52*fgkmm ,
+                                         -kPixelBusWidthY/2.+ kDeltaYOrigin , 
+                                         -kGroundingWidthX/2.+ kDeltaZOrigin) ;
   TGeoRotation    * pixelBusRot     = new TGeoRotation(*commonRot);
   TGeoTranslation * pbExtenderTrans = new TGeoTranslation(*pixelBusTrans) ;
   TGeoRotation    * pbExtenderRot   = new TGeoRotation(*pixelBusRot) ;
-  pbExtenderTrans->SetDz(*(pbExtenderTrans->GetTranslation()+2) - kPixelBusWidthX/2. - 2*kPixelBusThickness*TMath::Sin(kPixelBusContactPhi)) ;  
+  pbExtenderTrans->SetDz(*(pbExtenderTrans->GetTranslation()+2)-
+                  kPixelBusWidthX/2.-2.*kPixelBusThickness*
+                        TMath::Sin(kPixelBusContactPhi)) ;  
   if (!zpos) {
-    pbExtenderTrans->SetDy(*(pbExtenderTrans->GetTranslation()+1) - (kPixelBusWidthY - kPbExtenderWidthY)/2.);
-  }
-  else {
-    pbExtenderTrans->SetDy(*(pbExtenderTrans->GetTranslation()+1) + (kPixelBusWidthY - kPbExtenderWidthY)/2.);
-  }
-  pbExtenderTrans->SetDx(*(pbExtenderTrans->GetTranslation()) + kPixelBusThickness/2 + 2*kPixelBusThickness*TMath::Sin(kPixelBusContactPhi)*TMath::Tan(kPixelBusContactPhi)) ;
-  TGeoTranslation * mcmExtenderTrans = new TGeoTranslation(0.12*fgkmm + kMcmThickness - kDeltaXOrigin,
-                                                          pbExtenderTrans->GetTranslation()[1],
-                                                          -4.82);
+    pbExtenderTrans->SetDy(*(pbExtenderTrans->GetTranslation()+1) - 
+                          (kPixelBusWidthY - kPbExtenderWidthY)/2.);
+  }else {
+    pbExtenderTrans->SetDy(*(pbExtenderTrans->GetTranslation()+1) + 
+                          (kPixelBusWidthY - kPbExtenderWidthY)/2.);
+  } // end if !zpos
+  pbExtenderTrans->SetDx(*(pbExtenderTrans->GetTranslation()) +
+                        kPixelBusThickness/2 + 2*kPixelBusThickness*
+                        TMath::Sin(kPixelBusContactPhi)*
+                        TMath::Tan(kPixelBusContactPhi)) ;
+  TGeoTranslation * mcmExtenderTrans = new TGeoTranslation(0.12*fgkmm + 
+                                       kMcmThickness - kDeltaXOrigin,
+                                  pbExtenderTrans->GetTranslation()[1],-4.82);
   TGeoRotation    * mcmExtenderRot   = new TGeoRotation(*pbExtenderRot);
-  
 
   //ADD NODES TO ASSEMBLIES
   pixelBus    ->AddNode((TGeoVolume*)pixelBusXtruVol,0);
@@ -2383,18 +2610,19 @@ TGeoVolumeAssembly* AliITSv11GeometrySPD::CreatePixelBusAndExtensions(Bool_t zpo
 
   //CREATE FINAL VOLUME ASSEMBLY AND ROTATE IT
   TGeoVolumeAssembly *assembly = new TGeoVolumeAssembly("EXTENDERS");
-  assembly->AddNode((TGeoVolume*)pixelBus    ,0, new TGeoCombiTrans(*pixelBusTrans,*pixelBusRot));
-  assembly->AddNode((TGeoVolume*)pbExtender  ,0, new TGeoCombiTrans(*pbExtenderTrans,*pbExtenderRot));
-  assembly->AddNode((TGeoVolume*)mcmExtender ,0, new TGeoCombiTrans(*mcmExtenderTrans,*mcmExtenderRot));
-assembly->SetTransparency(50);
+  assembly->AddNode((TGeoVolume*)pixelBus    ,0, 
+                   new TGeoCombiTrans(*pixelBusTrans,*pixelBusRot));
+  assembly->AddNode((TGeoVolume*)pbExtender  ,0, 
+                   new TGeoCombiTrans(*pbExtenderTrans,*pbExtenderRot));
+  assembly->AddNode((TGeoVolume*)mcmExtender ,0, 
+                   new TGeoCombiTrans(*mcmExtenderTrans,*mcmExtenderRot));
+  assembly->SetTransparency(50);
   return assembly ;
 }
-
 //______________________________________________________________________
-TGeoVolume* AliITSv11GeometrySPD::CreateStaveBase
-(Int_t layer, Double_t &fullWidth, Double_t &fullHeight, Double_t &fullThickness, TGeoManager *mgr)
-{
-       //
+TGeoVolume* AliITSv11GeometrySPD::CreateStaveBase(Int_t layer,
+          Double_t &fullWidth, Double_t &fullHeight, Double_t &fullThickness,
+          TGeoManager *mgr){
        // Creates a box which contains the followin parts of the whole stave:
        // - the two layers of grounding foil
        // - the ladders
@@ -2412,13 +2640,14 @@ TGeoVolume* AliITSv11GeometrySPD::CreateStaveBase
        // ---
        // Returns:
        //    - a TGeoBBox volume containing all this stuff
-       //    - the size of the container box are stored in the reference-passed variables
+       //    - the size of the container box are stored in the 
+        //      reference-passed variables
        //
-       
        // sizes of all objects to be inserted
        // these values are used to compute the total volume of the container
        // and to compute parametrically the position of each piece, instead
-       // of putting hard-coded number (this helps in eventually modifying everything)
+       // of putting hard-coded number (this helps in eventually modifying 
+        // everything)
        Double_t mcmThickness    = fgkmm * 0.35;
        Double_t grndThickness   = fgkmm * 0.07; // = 0.05 + 0.02
        Double_t sepThickness    = fgkmm * 0.05;
@@ -2427,17 +2656,21 @@ TGeoVolume* AliITSv11GeometrySPD::CreateStaveBase
        Double_t mcmWidth        = fgkmm * 105.60;
        Double_t sepLaddersWidth = fgkmm *   0.20;
        Double_t sepMCMWidth     = fgkmm *   0.30;
-       Double_t sepLaddersCtr   = fgkmm *   0.40; // separations between central ladders in the two half-staves 
+       // separations between central ladders in the two half-staves 
+       Double_t sepLaddersCtr   = fgkmm *   0.40; 
 
        Double_t mcmHeight       = fgkmm *  15.00;
        
        // compute the size of the container
-       fullWidth     = 2.0*sepLaddersCtr + 4.0*ladderWidth + 2.0*sepMCMWidth + 2.0*sepLaddersWidth + 2.0*mcmWidth;
+       fullWidth     = 2.0*sepLaddersCtr + 4.0*ladderWidth + 
+                   2.0*sepMCMWidth + 2.0*sepLaddersWidth + 2.0*mcmWidth;
        fullHeight    = fgkmm * 15.95;
        fullThickness = grndThickness + sepThickness + mcmThickness;
        
        // create the container
-       TGeoVolume *container = mgr->MakeBox(Form("LAY%d_STAVE", layer), mgr->GetMedium("VACUUM"), 0.5*fullThickness, 0.5*fullHeight, 0.5*fullWidth);
+       TGeoVolume *container = mgr->MakeBox(Form("LAY%d_STAVE", layer),
+                         mgr->GetMedium("VACUUM"), 0.5*fullThickness,
+                         0.5*fullHeight, 0.5*fullWidth);
                
        // fill the container going from bottom to top 
        // with respect to the thickness direction
@@ -2454,18 +2687,23 @@ TGeoVolume* AliITSv11GeometrySPD::CreateStaveBase
        // 2 - Ladders
        // volume (will be replicated 4 times)
        Double_t ladderLength, ladderThickness;
-       TGeoVolume *ladder = CreateLadder(layer, ladderLength, ladderWidth, ladderThickness, mgr);
+       TGeoVolume *ladder = CreateLadder(layer, ladderLength, ladderWidth, 
+                                         ladderThickness, mgr);
        // translations (in thickness direction, the MCM thickness is used)
-       // layers are sorted going from the one at largest Z to the one at smallest Z:
+       // layers are sorted going from the one at largest Z to the one 
+       // at smallest Z:
        // -|Zmax| ------> |Zmax|
        //      0   1   2   3
-       // but it is more comfortable to start defining their Z position from center
-       Double_t xLad  = xGrnd + 0.5*grndThickness + 0.5*mcmThickness + sepThickness;
+       // but it is more comfortable to start defining their Z position 
+       // from center
+       Double_t xLad  = xGrnd + 0.5*grndThickness + 0.5*mcmThickness + 
+                        sepThickness;
        Double_t zLad1 = -0.5*ladderWidth - sepLaddersCtr;
        Double_t zLad0 = zLad1 - ladderWidth - sepLaddersWidth;
        Double_t zLad2 = -zLad1;
        Double_t zLad3 = -zLad0;
-       TGeoRotation   *rotLad = new TGeoRotation(*gGeoIdentity);// rotLad->RotateZ(180.0);
+       // rotLad->RotateZ(180.0);
+       TGeoRotation   *rotLad = new TGeoRotation(*gGeoIdentity);
        TGeoCombiTrans *trLad0 = new TGeoCombiTrans(xLad, 0.0, zLad0, rotLad);
        TGeoCombiTrans *trLad1 = new TGeoCombiTrans(xLad, 0.0, zLad1, rotLad);
        TGeoCombiTrans *trLad2 = new TGeoCombiTrans(xLad, 0.0, zLad2, rotLad);
@@ -2476,12 +2714,15 @@ TGeoVolume* AliITSv11GeometrySPD::CreateStaveBase
        container->AddNode(ladder, 2, trLad2);
        container->AddNode(ladder, 3, trLad3);
        
-       // 3 - MCM (only the base, the cover is added as a separate volume in a more global 'stave' assembly
-       // volume (will be replicated twice)
+       // 3 - MCM (only the base, the cover is added as a separate 
+       // volume in a more global 'stave' assembly volume (will be 
+       // replicated twice)
        TGeoVolume *mcm = CreateMCMBase(mgr);
-       // translations (in the X direction, MCM is at the same level as ladder)
-       // the two copies of the MCM are placed at the same distance from the center, on both sides
-       // and their sorting is the same as ladders' one (MCM0 is at Z < 0, MCM1 at Z > 0);
+       // translations (in the X direction, MCM is at the same 
+       // level as ladder) the two copies of the MCM are placed at 
+       // the same distance from the center, on both sides and their 
+       // sorting is the same as ladders' one (MCM0 is at Z < 0, 
+       // MCM1 at Z > 0);
        Double_t xMCM  = xLad;
        Double_t yMCM  = 0.5*(fullHeight - mcmHeight);
        Double_t zMCM1 = zLad3 + 0.5*ladderWidth + 0.5*mcmWidth + sepMCMWidth;
@@ -2491,19 +2732,16 @@ TGeoVolume* AliITSv11GeometrySPD::CreateStaveBase
        TGeoRotation *rotCorr1 = new TGeoRotation(*gGeoIdentity);
        rotCorr0->RotateY( 90.0);
        rotCorr1->RotateY(-90.0);
-       TGeoCombiTrans *trMCM0 = new TGeoCombiTrans(xMCM, yMCM, zMCM0, rotCorr0);
-       TGeoCombiTrans *trMCM1 = new TGeoCombiTrans(xMCM, yMCM, zMCM1, rotCorr1);
+       TGeoCombiTrans *trMCM0 = new TGeoCombiTrans(xMCM,yMCM,zMCM0,rotCorr0);
+       TGeoCombiTrans *trMCM1 = new TGeoCombiTrans(xMCM,yMCM,zMCM1,rotCorr1);
        // add to container
        container->AddNode(mcm, 0, trMCM0);
        container->AddNode(mcm, 1, trMCM1);
                
        return container;
 }
-
 //______________________________________________________________________
-void AliITSv11GeometrySPD::StavesInSector(TGeoVolume *moth, TGeoManager *mgr)
-{
-       //
+void AliITSv11GeometrySPD::StavesInSector(TGeoVolume *moth, TGeoManager *mgr){
        // Unification of essentially two methods:
        // - the one which creates the sector structure
        // - the one which returns the complete stave
@@ -2527,18 +2765,23 @@ void AliITSv11GeometrySPD::StavesInSector(TGeoVolume *moth, TGeoManager *mgr)
        // must be found for the two circles which describe the rounded angles.
        class clsSupportPlane {
        public:
-               Double_t xL, yL, rL, sL;  // curvature center and radius (with sign) of left corner
-               Double_t xR, yR, rR, sR;  // curvature center and radius (with sign) of right corner
-               Double_t shift;           // shift from the innermost position (where the stave edge is
-                                         // in the point where the rounded corner begins
+                // curvature center and radius (with sign) of left corner
+               Double_t xL, yL, rL, sL;
+                // curvature center and radius (with sign) of right corner
+               Double_t xR, yR, rR, sR;
+                // shift from the innermost position (where the stave edge is
+               // in the point where the rounded corner begins
+               Double_t shift;
                
-               // Constructor with arguments which allow to set directly everything
-               // since the values are given in millimiters from drawings, they must be converted to cm
+               // Constructor with arguments which allow to set 
+               // directly everything since the values are given in 
+               // millimiters from drawings, they must be converted to cm
                clsSupportPlane
                (Double_t xLin, Double_t yLin, Double_t rLin, Double_t sLin, 
-                Double_t xRin, Double_t yRin, Double_t rRin, Double_t sRin, Double_t shiftin) :
-                xL(xLin), yL(yLin), rL(rLin), sL(sLin), xR(xRin), yR(yRin), rR(rRin), sR(sRin), shift(shiftin) 
-               {
+                Double_t xRin, Double_t yRin, Double_t rRin, Double_t sRin,
+                 Double_t shiftin) :
+                xL(xLin), yL(yLin), rL(rLin), sL(sLin), xR(xRin), yR(yRin), 
+                 rR(rRin), sR(sRin), shift(shiftin) {
                        xL *= fgkmm;
                        yL *= fgkmm;
                        rL *= fgkmm;
@@ -2546,25 +2789,28 @@ void AliITSv11GeometrySPD::StavesInSector(TGeoVolume *moth, TGeoManager *mgr)
                        yR *= fgkmm;
                        rR *= fgkmm;
                        shift *= fgkmm;
-               }
+               } // end group.
                
-               // Computation of the line tangent to both circles defined here
-               // which is taken above or below the center according to the radius sign.
-               // This method returns:
-               //   - the mid-popint of the segment between the two points where the tangent touches the two circles, 
+               // Computation of the line tangent to both circles 
+               // defined here which is taken above or below the center 
+               // according to the radius sign. This method returns:
+               //   - the mid-popint of the segment between the two 
+               //     points where the tangent touches the two circles, 
                //   - the inclination of this segment
                //   - the half-length of this segment
-               Double_t TangentSegment(Double_t &midX, Double_t &midY, Double_t &phi)
-               {
-                       // compute the straight line which is tangent to the two circles
-                       // and extract its inclination 'phi' w.r. to X axis
+               Double_t TangentSegment(Double_t &midX, Double_t &midY, 
+                                       Double_t &phi){
+                       // compute the straight line which is tangent to 
+                       // the two circles and extract its inclination 
+                       // 'phi' w.r. to X axis
                        Double_t dx = xL - xR;
                        Double_t dy = yL - yR;
                        Double_t R  = rL*sL + rR*sR;
                        Double_t delta = dy*dy + dx*dx - R*R;
-                       Double_t tan05phi = (-dy + TMath::Sqrt(delta)) / (R - dx);
+                       Double_t tan05phi = (-dy+TMath::Sqrt(delta))/(R - dx);
                        phi = 2.0 * TMath::ATan(tan05phi);
-                       // compute the points where this line touchs the two circles
+                       // compute the points where this line touchs the 
+                       // two circles
                        Double_t leftX  = xL + sL*rL*TMath::Cos(phi);
                        Double_t leftY  = yL + sL*rL*TMath::Sin(phi);
                        Double_t rightX = xR + sR*rR*TMath::Cos(phi);
@@ -2578,35 +2824,48 @@ void AliITSv11GeometrySPD::StavesInSector(TGeoVolume *moth, TGeoManager *mgr)
                        dy = rightY - leftY;
                        phi = TMath::ATan2(dy, dx);
                        // compute the half-length of this segment
-                       Double_t len = 0.5*TMath::Sqrt((rightX-leftX)*(rightX-leftX) + (rightY-leftY)*(rightY-leftY));
+                       Double_t len = 0.5*TMath::Sqrt((rightX-leftX)*
+                                            (rightX-leftX) + (rightY-leftY)*
+                                                             (rightY-leftY));
                        //MM                    cout << 2.0*len << endl;
                        return len;
-               }
-       };
-       
+               } // end function
+       }; // end class 
        // instantiate this class for each layer1 and layer2 corners
        clsSupportPlane *plane[6] = {0, 0, 0, 0, 0, 0};
        
        // layer 2
-       plane[0] = new clsSupportPlane( 10.830,  16.858, 0.60,  1.,  19.544,  10.961, 0.8,  1.,  1.816);
-       plane[1] = new clsSupportPlane(- 0.733,  17.486, 0.60,  1.,  11.581,  13.371, 0.6, -1., -0.610);
-       plane[2] = new clsSupportPlane(-12.252,  16.298, 0.60,  1.,   0.562,  14.107, 0.6, -1., -0.610);
-       plane[3] = new clsSupportPlane(-22.276,  12.948, 0.85,  1., -10.445,  13.162, 0.6, -1., -0.610);
+       plane[0] = new clsSupportPlane( 10.830,  16.858, 0.60,  1.,  19.544,  
+                                       10.961, 0.8,  1.,  1.816);
+       plane[1] = new clsSupportPlane(- 0.733,  17.486, 0.60,  1.,  11.581,  
+                                      13.371, 0.6, -1., -0.610);
+       plane[2] = new clsSupportPlane(-12.252,  16.298, 0.60,  1.,   0.562,  
+                                      14.107, 0.6, -1., -0.610);
+       plane[3] = new clsSupportPlane(-22.276,  12.948, 0.85,  1., -10.445,  
+                                      13.162, 0.6, -1., -0.610);
        // layer 1
-       plane[4] = new clsSupportPlane(- 3.123, -14.618, 0.50,  1.,  11.280, -14.473, 0.9, -1., -0.691);
-       plane[5] = new clsSupportPlane(-13.187, -19.964, 0.50, -1., - 3.833, -17.805, 0.6, -1.,  1.300);
-       
+       plane[4] = new clsSupportPlane(- 3.123, -14.618, 0.50,  1.,  11.280, 
+                                      -14.473, 0.9, -1., -0.691);
+       plane[5] = new clsSupportPlane(-13.187, -19.964, 0.50, -1., - 3.833, 
+                                      -17.805, 0.6, -1.,  1.300);
        // put the sector in the container
        //CarbonFiberSector(moth, xAAtubeCenter0, yAAtubeCenter0, mgr);
        
        // create stave volume
        Double_t staveHeight = 1.595, staveThickness;
-       TGeoVolume *stave1 = CreateStave(1, staveThickness, gGeoManager);
-       TGeoVolume *stave2 = CreateStave(2, staveThickness, gGeoManager);
+       TGeoVolume *stave1 = CreateStave(1, staveThickness,mgr);
+       TGeoVolume *stave2 = CreateStave(2, staveThickness,mgr);
                
        // compute positions and rotation angles
        Double_t xm, ym, halfPlaneHeight, heightDiff, position, phi, xPos, yPos;
        for (Int_t i = 0; i < 6; i++) {
+           //
+           // This functioninserted here for test. Added By Bjorn Nilsen
+           // August 29 2007.
+           Double_t x0,y0,x1,y1; // should be move out of loop
+           Bool_t lreturn;
+           lreturn = GetSectorMountingPoints(i,x0,y0,x1,y1,mgr);
+           //
                // recall the geometry computations defined for the classe
                halfPlaneHeight = plane[i]->TangentSegment(xm, ym, phi);
                // compute the difference between plane and stave heights
@@ -2619,27 +2878,31 @@ void AliITSv11GeometrySPD::StavesInSector(TGeoVolume *moth, TGeoManager *mgr)
                position = heightDiff + plane[i]->shift;
                // taking into account this shift plus another in the direction
                // normal to the support plane, due to the stave thickness,
-               // the final position of the stave is computed in a temporary reference frame
-               // where the mid-point of the support plane is in the origin
+               // the final position of the stave is computed in a temporary 
+               // reference frame where the mid-point of the support plane 
+               // is in the origin
                if (i < 4) {
-                       ParallelPosition(0.5*staveThickness, position, phi, xPos, yPos);
-               }
-               else if (i == 4) {
-                       ParallelPosition(-0.5*staveThickness, -position, phi, xPos, yPos);
-               }
-               else {
-                       ParallelPosition(-0.5*staveThickness, -position, phi, xPos, yPos);
+                       ParallelPosition(0.5*staveThickness, position, phi, 
+                                        xPos, yPos);
+               }else if (i == 4) {
+                       ParallelPosition(-0.5*staveThickness, -position, phi, 
+                                        xPos, yPos);
+               }else {
+                       ParallelPosition(-0.5*staveThickness, -position, phi, 
+                                        xPos, yPos);
                }
                // then we go into the true reference frame
                xPos += xm;
                yPos += ym;
                /*
                // TEMP
-               TGeoVolume *tubeTemp1 = mgr->MakeTube("tubeTemp1", NULL, 0.0, 0.01, 50.0);
+               TGeoVolume *tubeTemp1 = mgr->MakeTube("tubeTemp1", NULL, 
+                                                         0.0, 0.01, 50.0);
                TGeoTranslation *trTemp1 = new TGeoTranslation(xm, ym, 0.0);
                tubeTemp1->SetLineColor(kRed);
                moth->AddNode(tubeTemp1, i + 1, trTemp1);
-               TGeoVolume *tubeTemp2 = mgr->MakeTube("tubeTemp2", NULL, 0.0, 0.01, 50.0);
+               TGeoVolume *tubeTemp2 = mgr->MakeTube("tubeTemp2", NULL, 
+                                                            0.0, 0.01, 50.0);
                TGeoTranslation *trTemp2 = new TGeoTranslation(xPos, yPos, 0.0);
                tubeTemp2->SetLineColor(kBlue);
                moth->AddNode(tubeTemp2, i + 1, trTemp2);
@@ -2650,31 +2913,31 @@ void AliITSv11GeometrySPD::StavesInSector(TGeoVolume *moth, TGeoManager *mgr)
                TGeoRotation *rot = new TGeoRotation(*gGeoIdentity);
                if (i >= 4) rot->RotateY(180.0);
                rot->RotateZ(90.0 + phi * TMath::RadToDeg());
-               TGeoCombiTrans *trans = new TGeoCombiTrans(xPos, yPos, 0.0, rot);
+               TGeoCombiTrans *trans = new TGeoCombiTrans(xPos,yPos,0.0,rot);
                if (i < 4) {
                        moth->AddNode(stave2, i, trans);
-               }
-               else {
+               }else {
                        moth->AddNode(stave1, i - 4, trans);
-               }
-       }
+               } // end if i<4
+       } // for i
 }
-
 //______________________________________________________________________
-void AliITSv11GeometrySPD::ParallelPosition(Double_t dist1, Double_t dist2, Double_t phi, Double_t &x, Double_t &y)
-{
-       //
+void AliITSv11GeometrySPD::ParallelPosition(Double_t dist1, Double_t dist2, 
+                                    Double_t phi, Double_t &x, Double_t &y){
        // Performs the following steps:
-       // 1 - finds a straight line parallel to the one passing through the origin and with angle 'phi' with X axis
-       //     (phi in RADIANS);
-       // 2 - finds another line parallel to the previous one, with a distance 'dist1' from it
-       // 3 - takes a reference point in the second line in the intersection between the normal to both lines 
-       //     passing through the origin
-       // 4 - finds a point whith has distance 'dist2' from this reference, in the second line (point 2)
+       // 1 - finds a straight line parallel to the one passing through 
+        //     the origin and with angle 'phi' with X axis (phi in RADIANS);
+       // 2 - finds another line parallel to the previous one, with a 
+        //     distance 'dist1' from it
+       // 3 - takes a reference point in the second line in the 
+        //     intersection between the normal to both lines passing 
+        //     through the origin
+       // 4 - finds a point whith has distance 'dist2' from this 
+        //     reference, in the second line (point 2)
        // ----
-       // According to the signs given to dist1 and dist2, the point is found in different position w.r. to the origin
-       //
-       
+       // According to the signs given to dist1 and dist2, the point 
+        // is found in different position w.r. to the origin
+
        // compute the point
        Double_t cs = TMath::Cos(phi);
        Double_t sn = TMath::Sin(phi);
@@ -2682,4 +2945,87 @@ void AliITSv11GeometrySPD::ParallelPosition(Double_t dist1, Double_t dist2, Doub
        x = dist2*cs - dist1*sn;
        y = dist1*cs + dist2*sn;
 }
+//----------------------------------------------------------------------
+Bool_t AliITSv11GeometrySPD::Make2DcrossSections(TPolyLine &a0,TPolyLine &a1,
+                          TPolyLine &b0,TPolyLine &b1,TPolyMarker &p)const{
+    // Fill the objects with the points representing
+    // a0 the outer carbon fiber SPD sector shape Cross Section A
+    // a1 the inner carbon fiber SPD sector shape Cross Section A
+    // b0 the outer carbon fiber SPD sector shape Cross Section B
+    // b1 the inner carbon fiber SPD sector shape Cross Section B
+    //
+    // Inputs:
+    //   TPolyLine &a0   The outer carbon fiber SPD sector shape
+    //   TPolyLine &a1   The Inner carbon fiber SPD sector shape
+    //   TPolyLine &b0   The outer carbon fiber SPD sector shape
+    //   TPolyLine &b1   The Inner carbon fiber SPD sector shape
+    //   TPolyMarker &p  The points where the ladders are to be placed
+    // Outputs:
+    //   TPolyLine &a0   The shape filled with the points
+    //   TPolyLine &a1   The shape filled with the points
+    //   TPolyLine &b0   The shape filled with the points
+    //   TPolyLine &b1   The shape filled with the points
+    //   TPolyMarker &p  The filled array of points
+    // Return:
+    //     An error flag.
+    Int_t n0,n1,i;
+    Double_t x,y;
+    TGeoVolume *a0V,*a1V,*b0V,*b1V;
+    TGeoXtru *a0S,*a1S,*b0S,*b1S;
+    TGeoManager *mgr = gGeoManager;
+
+    a0V = mgr->GetVolume(fSPDsectorShapeName.Data());
+    a0S = dynamic_cast<TGeoXtru*>(a0V->GetShape());
+    n0 = a0S->GetNvert();
+    a0.SetPolyLine(n0+1);
+    //for(i=0;i<fSPDsectorPoints0.GetSize();i++) 
+    //  printf("%d %d %d\n",i,fSPDsectorPoints0[i],fSPDsectorPoints1[i]);
+    for(i=0;i<n0;i++){
+        x = a0S->GetX(i);
+       y = a0S->GetY(i);
+       //printf("%d %g %g\n",i,x,y);
+        a0.SetPoint(i,x,y);
+       if(i==0) a0.SetPoint(n0,x,y);
+    } // end for i
+    a1V = mgr->GetVolume("ITSSPDCarbonFiberSupportSectorAirA1");
+    a1S = dynamic_cast<TGeoXtru*>(a1V->GetShape());
+    n1 = a1S->GetNvert();
+    a1.SetPolyLine(n1+1);
+    for(i=0;i<n1;i++){
+        x = a1S->GetX(i);
+       y = a1S->GetY(i);
+        a1.SetPoint(i,x,y);
+       if(i==0) a1.SetPoint(n1,x,y);
+    } // end for i
+    // Cross Section B
+    b0V = mgr->GetVolume("ITSSPDCarbonFiberSupportSectorEndB0");
+    b0S = dynamic_cast<TGeoXtru*>(b0V->GetShape());
+    n0 = b0S->GetNvert();
+    b0.SetPolyLine(n0+1);
+    for(i=0;i<n0;i++){
+        x = b0S->GetX(i);
+       y = b0S->GetY(i);
+        b0.SetPoint(i,x,y);
+       if(i==0) b0.SetPoint(n0,x,y);
+    } // end for i
+    b1V = mgr->GetVolume("ITSSPDCarbonFiberSupportSectorEndAirB1");
+    b1S = dynamic_cast<TGeoXtru*>(b1V->GetShape());
+    n1 = b1S->GetNvert();
+    b1.SetPolyLine(n1+1);
+    for(i=0;i<n1;i++){
+        x = b1S->GetX(i);
+       y = b1S->GetY(i);
+        b1.SetPoint(i,x,y);
+       if(i==0) b1.SetPoint(n1,x,y);
+    } // end for i
+    //
+    Double_t x0,y0,x1,y1;
+    p.SetPolyMarker(2*fSPDsectorPoints0.GetSize());
+    for(i=0;i<fSPDsectorPoints0.GetSize();i++){
+      GetSectorMountingPoints(i,x0,y0,x1,y1);
+      p.SetPoint(2*i,x0,y0);
+      p.SetPoint(2*i+1,x1,y1);
+    } // end for i
+    return kTRUE;
+}
 
index 7ed4589b9d1632d74d66ce9a55c403ce533ab887..d817015d6afca51ae55888c889b9124eb6800c7e 100644 (file)
 //
 #include <TGeoManager.h>
 #include <TVirtualMC.h>
+#include <TString.h>
+#include <TArrayI.h>
 #include <AliITSv11Geometry.h>
 
 class TGeoVolume;
+class TPolyLine;
+class TPolyMarker;
+
 
 class AliITSv11GeometrySPD : public AliITSv11Geometry
 {
 public:
-       AliITSv11GeometrySPD() : AliITSv11Geometry() {};
-       AliITSv11GeometrySPD(Int_t debug) : AliITSv11Geometry(debug) {}; // set explicitly debug level
-       virtual ~AliITSv11GeometrySPD() {};
-       
+        // Default Constructor, should not be used by default
+        AliITSv11GeometrySPD() : AliITSv11Geometry(),fSPDsectorShapeName(),
+                                 fSPDsectorPoints0(),fSPDsectorPoints1() {};
+        // Standard Constructor, set explicitly debug level
+        AliITSv11GeometrySPD(Int_t debug) : AliITSv11Geometry(debug),
+              fSPDsectorShapeName("ITS SPD Carbon fiber support Sector A0"),
+              fSPDsectorPoints0(6),fSPDsectorPoints1() {}; 
+        virtual ~AliITSv11GeometrySPD() {}; // Destructor
+
        /* Settings */
-       
+
        // define/create materials
-       virtual Int_t CreateSPDCentralMaterials(Int_t &medOffset, Int_t &matOffset) const;
+       virtual Int_t CreateSPDCentralMaterials(Int_t &medOffset,
+                                               Int_t &matOffset) const;
        // set SPD Central, GEANT3 type, tracking parameters
        virtual void InitSPDCentral(Int_t offset,TVirtualMC *mc=gMC) const;
        
        /* Monitoring */
        
        // creates standard figures for the documentation of this class
-       virtual void CreateFigure0(const Char_t *filepath = "", const Char_t *type = "gif", TGeoManager *mgr=gGeoManager);
+       virtual void CreateFigure0(const Char_t *filepath = "",
+                                  const Char_t *type = "gif",
+                                  TGeoManager *mgr=gGeoManager);
        
        /* Member functions which create pieces of the geometry */
        
        // a single ladder (= 1 detector + 5 chips)
-       TGeoVolume* CreateLadder(Int_t layer, Double_t &width, Double_t &height, Double_t &thickness, TGeoManager *mgr = gGeoManager);
+       TGeoVolume* CreateLadder(Int_t layer, Double_t &width,
+                                Double_t &height, Double_t &thickness,
+                                TGeoManager *mgr = gGeoManager);
        // the grounding foil (splitted in two components)
-       TGeoVolume* CreateGroundingFoilSingle(Bool_t kapLayer, Double_t &len, Double_t &wid, Double_t &thick, TGeoManager *mgr = gGeoManager);
-       TGeoVolume* CreateGroundingFoil(Double_t &thickness, TGeoManager *mgr = gGeoManager);
+       TGeoVolume* CreateGroundingFoilSingle(Bool_t kapLayer,Double_t &len, 
+                                             Double_t &wid, Double_t &thick,
+                                             TGeoManager *mgr = gGeoManager);
+       TGeoVolume* CreateGroundingFoil(Double_t &thickness,
+                                       TGeoManager *mgr = gGeoManager);
        // the MCM (incomplete: missing the internal chips)
        TGeoVolume* CreateMCMBase(TGeoManager *mgr = gGeoManager) const;
        TGeoVolume* CreateMCMCoverBorder(TGeoManager *mgr = gGeoManager);
        TGeoVolume* CreateMCMCoverTop(TGeoManager *mgr = gGeoManager);
        // the Pixel Bus & extenders
-       TGeoVolumeAssembly* CreatePixelBusAndExtensions(Bool_t zpos = kTRUE, TGeoManager *mgr = gGeoManager);
+       TGeoVolumeAssembly* CreatePixelBusAndExtensions(Bool_t zpos = kTRUE,
+                                             TGeoManager *mgr = gGeoManager);
        // the thin part of a stave (grounding + ladders)
-       TGeoVolume *CreateStaveBase(Int_t layer, Double_t &width, Double_t &height, Double_t &thickness, TGeoManager *mgr=gGeoManager);
-       // the whole stave, including the thick parts (MCM cover, pixel bus & extensions)
-       TGeoVolumeAssembly* CreateStave(Int_t layer, Double_t &thickness, TGeoManager *mgr);
+       TGeoVolume *CreateStaveBase(Int_t layer, Double_t &width,
+                                   Double_t &height, Double_t &thickness,
+                                   TGeoManager *mgr=gGeoManager);
+       // the whole stave, including the thick parts (MCM cover, 
+       // pixel bus & extensions)
+       TGeoVolumeAssembly* CreateStave(Int_t layer, Double_t &thickness,
+                                       TGeoManager *mgr);
        // displacement of staves on the carbon fiber sector
-       virtual void StavesInSector(TGeoVolume *moth, TGeoManager *mgr=gGeoManager);
+       virtual void StavesInSector(TGeoVolume *moth,
+                                   TGeoManager *mgr=gGeoManager);
        // the complete Carbon Fiber sector (support + staves)
-       virtual void CarbonFiberSector(TGeoVolume *moth, Double_t &xAAtubeCenter0, Double_t &yAAtubeCenter0, TGeoManager *mgr=gGeoManager);
+       virtual void CarbonFiberSector(TGeoVolume *moth,
+                                      Double_t &xAAtubeCenter0,
+                                      Double_t &yAAtubeCenter0,
+                                      TGeoManager *mgr=gGeoManager);
        // the whole SPD barrel
        virtual void SPDSector(TGeoVolume *moth, TGeoManager *mgr=gGeoManager);
+       // Returns the mounting location and rotation needed to mount
+        // and SPD ladder.
+       virtual Bool_t AliITSv11GeometrySPD::GetSectorMountingPoints(
+                             Int_t index,Double_t &x0,Double_t &y0,
+                             Double_t &x1,Double_t &y1,
+                            TGeoManager *mgr=gGeoManager)const;
+       // Functions to test aspects of this geometry.
+        // Fill TPolylines with crossections of the SPD Carbon
+       // fiber sectors.
+       Bool_t Make2DcrossSections(TPolyLine &a0,TPolyLine &a1,
+                                  TPolyLine &b0,TPolyLine &b1,
+                                  TPolyMarker &p)const;
 
 private:
        
        // NOTE:
-       // all of the member functions which define a component of the final SPD
-       // will need to be defined as private once the design is fixed and does not
+       // all of the member functions which define a component of the 
+       // final SPD will need to be defined as private once the design 
+       // is fixed and does not
        // need any longer to be checked and debugged.
        
-       // Computes shape of the SPD Sector given specific inputs (internal use only)
-       void SPDsectorShape(Int_t n, const Double_t *xc, const Double_t *yc, const Double_t *r,
+       // Computes shape of the SPD Sector given specific inputs 
+       // (internal use only)
+       void SPDsectorShape(Int_t n, const Double_t *xc, const Double_t *yc,
+                           const Double_t *r,
                            const Double_t *ths, const Double_t *the, Int_t npr,
                            Int_t &m, Double_t **xp, Double_t **yp);
        
-       // computes a point o a line parallel to a given direction
+       // computes a point to a line parallel to a given direction
        // and with a fixed distance from it (internal use only)
-       void ParallelPosition(Double_t dist1, Double_t dist2, Double_t phi, Double_t &x, Double_t &y);
+       void ParallelPosition(Double_t dist1, Double_t dist2,
+                             Double_t phi, Double_t &x, Double_t &y);
+
+       // Some internal data
+       TString fSPDsectorShapeName; // SPD Sector Shape name
+       TArrayI fSPDsectorPoints0;    // Array of sector points index
+                                     // used to mount SPD ladder to.
+       TArrayI fSPDsectorPoints1;    // Array of sector points index
+                                     // used to mount SPD ladder to.
        
        ClassDef(AliITSv11GeometrySPD,1) // ITS v11 Centeral SPD geometry
 };
 
 #endif
+
index b3c8928d45fedf72d7f655ac3169c791d5bf04ba..a1070a895d3975d1ab579189a4c6b7c28e3b3c3b 100644 (file)
@@ -1,4 +1,11 @@
 //----------------------------------------------------------------------
+
+AliITSv11GeometrySPD *gspd;
+AliITSv11GeometrySDD *gsdd;
+AliITSv11GeometrySupport *gsupp;
+AliITSv11GeometrySSD *gssd;
+//
+//----------------------------------------------------------------------
 void Displayv11(const char* filename=""){
     // Display AliITSv11 Geometry
     // Inputs:
@@ -31,13 +38,13 @@ void Displayv11(const char* filename=""){
     its->CreateMaterials();
     its->CreateGeometry();
     */
-    AliITSv11GeometrySPD *gspd = new AliITSv11GeometrySPD(0);
-    //AliITSv11GeometrySDD *gsdd = new AliITSv11GeometrySDD();
-    AliITSv11GeometrySupport *gsupp = new AliITSv11GeometrySupport(0);
-    //AliITSv11GeometrySSD *gssd = new AliITSv11GeometrySSD();
+    gspd = new AliITSv11GeometrySPD(0);
+    //gsdd = new AliITSv11GeometrySDD();
+    gsupp = new AliITSv11GeometrySupport(0);
+    //gssd = new AliITSv11GeometrySSD();
     //
-    Int_t imat=1,imed=1;
-    gspd->CreateSPDCenteralMaterials(imed,imat);
+    Int_t imat=1,imed=1,ireturn=0;
+    ireturn = gspd->CreateSPDCentralMaterials(imed,imat);
     gspd->SPDSector(ITSspd,mgr2);
     gsupp->SPDCone(ITS,mgr2);
     gsupp->SetDebug(0);
@@ -66,6 +73,8 @@ void Displayv11(const char* filename=""){
                    "Run EngineeringSPDCenter");
     bar->AddButton("Display SPD Thermal Sheald","EngineeringSPDThS()",
                    "Run EngineeringSPDThS");
+    bar->AddButton("Display SPD Sector Cross Sections","EngineeringSPDSCS()",
+                   "Run EngineeringSPDSCS");
     bar->AddButton("Display SDD Layer 3","EngineeringSDDLayer3()",
                    "Run EngineeringSDDLayer3");
     bar->AddButton("Display SDD Layer 4","EngineeringSDDLayer4()",
@@ -254,6 +263,67 @@ void Displayit(){
     //
 }
 //----------------------------------------------------------------------
+void EngineeringSPDSCS(){
+    // Display SPD Carbon Fiber Sector Cross sections A and B
+    // Inputs:
+    //    none.
+    // Outputs:
+    //    none.
+    // Return:
+    //    none.
+    TPolyLine *a0,*a1,*b0,*b1;
+    TPolyMarker *p;
+    TCanvas *cSPDSCS=0;
+    Int_t i;
+    Double_t max=0.0;
+
+    a0 = new TPolyLine();
+    a1 = new TPolyLine();
+    b0 = new TPolyLine();
+    b1 = new TPolyLine();
+    p = new TPolyMarker();
+    a0->SetLineColor(1);
+    a1->SetLineColor(4);
+    b0->SetLineColor(3);
+    b0->SetLineStyle(2); // dashed
+    b1->SetLineColor(6);
+    b1->SetLineStyle(2); // dashed
+    p->SetMarkerColor(2);
+    p->SetMarkerStyle(5);
+    if(gspd->Make2DcrossSections(*a0,*a1,*b0,*b1,*p)==kFALSE) return;
+    for(i=0;i<a0->GetN();i++) {
+      if(TMath::Abs(a0->GetX()[i])>max) max = TMath::Abs(a0->GetX()[i]);
+      if(TMath::Abs(a0->GetY()[i])>max) max = TMath::Abs(a0->GetY()[i]);
+    } // end for i
+    for(i=0;i<a1->GetN();i++) {
+      if(TMath::Abs(a1->GetX()[i])>max) max = TMath::Abs(a0->GetX()[i]);
+      if(TMath::Abs(a1->GetY()[i])>max) max = TMath::Abs(a1->GetY()[i]);
+    } // end for i
+    for(i=0;i<b0->GetN();i++) {
+      if(TMath::Abs(b0->GetX()[i])>max) max = TMath::Abs(b0->GetX()[i]);
+      if(TMath::Abs(b0->GetY()[i])>max) max = TMath::Abs(b0->GetY()[i]);
+    } // end for i
+    for(i=0;i<b1->GetN();i++) {
+      if(TMath::Abs(b1->GetX()[i])>max) max = TMath::Abs(b1->GetX()[i]);
+      if(TMath::Abs(b1->GetY()[i])>max) max = TMath::Abs(b1->GetY()[i]);
+    } // end for i
+    max *= 1.05;
+    cSPDSCS = gROOT->FindObject("cSPDSCS");
+    if(cSPDSCS==0) delete cSPDSCS;
+    cSPDSCS = new TCanvas("cSPDSCS","SPD Carbon Fiber Sector Cross sections",2);
+    cSPDSCS->Range(-max,-max,max,max);
+    //cSPDSCS->RangeAxis();
+    cSPDSCS->SetFixedAspectRatio(kTRUE);
+    //
+    a0->Draw("");
+    a1->Draw("same");
+    p->Draw("same");
+    b0->Draw("same");
+    b1->Draw("same");
+    cSPDSCS->Update();
+    return;
+}
+//----------------------------------------------------------------------
 void EngineeringSPDSector(){
     // Display SPD Sector Geometry
     // Inputs:
@@ -1075,4 +1145,4 @@ void EngineeringSupRB26(){
     } // end if view2
     if(ISetits(5,-1)==1) SUPRB26->Raytrace();
     //
-}
+}
\ No newline at end of file