LCOV - code coverage report
Current view: top level - ITS/ITSsim - AliITSv11GeometrySSD.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 5652 5931 95.3 %
Date: 2016-06-14 17:26:59 Functions: 271 273 99.3 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id$ */
      17             : 
      18             : //*************************************************************************
      19             : // SSD geometry, based on ROOT geometrical modeler
      20             : //
      21             : // Enrico Cattaruzza                                    ecattar@ts.infn.it
      22             : //*************************************************************************
      23             : #include "TMath.h"
      24             : #include "TGeoVolume.h"
      25             : #include "TGeoMatrix.h"
      26             : #include <TGeoManager.h>
      27             : #include "TVector3.h"
      28             : #include "TGeoArb8.h"
      29             : #include "TList.h"
      30             : #include "TGeoMatrix.h"
      31             : #include "TGeoCompositeShape.h"
      32             : #include "TGeoBoolNode.h"
      33             : #include "TGeoTube.h"
      34             : #include "TGeoBBox.h"
      35             : #include "TGeoXtru.h"
      36             : #include "TGeoTorus.h"
      37             : #include "TGeoPgon.h"
      38             : #include "TGeoPcon.h"
      39             : #include "TRotation.h"
      40             : #include "AliITSv11GeometrySSD.h"
      41             : 
      42             : /////////////////////////////////////////////////////////////////////////////////
      43             : // Names of the Sensitive Volumes of Layer 5 and Layer 6
      44             : /////////////////////////////////////////////////////////////////////////////////
      45             : const char* AliITSv11GeometrySSD::fgkSSDsensitiveVolName5 = "ITSssdSensitivL5";
      46             : const char* AliITSv11GeometrySSD::fgkSSDsensitiveVolName6 = "ITSssdSensitivL6";
      47             : /////////////////////////////////////////////////////////////////////////////////
      48             : //Parameters for SSD Geometry
      49             : /////////////////////////////////////////////////////////////////////////////////
      50             : // Variable for Vertical Disalignement of Modules
      51             : /////////////////////////////////////////////////////////////////////////////////
      52         116 : const Double_t AliITSv11GeometrySSD::fgkSSDTolerance = 0.0001*fgkmm;
      53         116 : const Double_t AliITSv11GeometrySSD::fgkSSDModuleVerticalDisalignment = 0.2*fgkmm;
      54         116 : const Double_t AliITSv11GeometrySSD::fgkSSDModuleSideDisalignment     = 0.2*fgkmm;
      55             : // For ladders:
      56         116 : const Double_t AliITSv11GeometrySSD::fgkSSDLadderVerticalDisalignment = 0.520*fgkmm;
      57             : /////////////////////////////////////////////////////////////////////////////////
      58             : // Layer5 (lengths are in mm and angles in degrees)
      59             : /////////////////////////////////////////////////////////////////////////////////
      60         116 : const Double_t AliITSv11GeometrySSD::fgkSSDLay5LadderLength      = 950.7*fgkmm;
      61             : const Int_t AliITSv11GeometrySSD::fgkSSDLay5SensorsNumber        =  22;
      62             : const Int_t AliITSv11GeometrySSD::fgkSSDLay5LadderNumber         =  34;
      63         116 : const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMin         = 378.0*fgkmm;
      64         116 : const Double_t AliITSv11GeometrySSD::fgkSSDLay5RadiusMax         = 384.0*fgkmm;
      65         116 : const Double_t AliITSv11GeometrySSD::fgkLay5CenterITSPosition    = 467.85*fgkmm;
      66             : /////////////////////////////////////////////////////////////////////////////////
      67             : // Layer6 (lengths are in mm and angles in degrees)
      68             : /////////////////////////////////////////////////////////////////////////////////
      69         116 : const Double_t AliITSv11GeometrySSD::fgkSSDLay6LadderLength      = 1068.0*fgkmm;
      70             : const Int_t AliITSv11GeometrySSD::fgkSSDLay6SensorsNumber        =   25;
      71             : const Int_t AliITSv11GeometrySSD::fgkSSDLay6LadderNumber         =   38;
      72         116 : const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMin         =  428.0*fgkmm;
      73         116 : const Double_t AliITSv11GeometrySSD::fgkSSDLay6RadiusMax         =  434.0*fgkmm;
      74         116 : const Double_t AliITSv11GeometrySSD::fgkLay6CenterITSPosition    = 526.50*fgkmm;
      75             : /////////////////////////////////////////////////////////////////////////////////
      76             : // SSD Chips and Hybrid (lengths are in mm and angles in degrees)
      77             : /////////////////////////////////////////////////////////////////////////////////
      78             : const Int_t AliITSv11GeometrySSD::fgkSSDChipNumber               =   6;
      79         116 : const Double_t AliITSv11GeometrySSD::fgkSSDChipLength            =  11.100*fgkmm; 
      80         116 : const Double_t AliITSv11GeometrySSD::fgkSSDChipWidth             =   3.850*fgkmm;
      81         116 : const Double_t AliITSv11GeometrySSD::fgkSSDChipHeight            =   0.180*fgkmm;
      82         116 : const Double_t AliITSv11GeometrySSD::fgkSSDChipSeparationLength  =   1.000*fgkmm;
      83         116 : const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueLength     = fgkSSDChipLength;
      84         116 : const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueWidth      =  fgkSSDChipWidth;
      85         116 : const Double_t AliITSv11GeometrySSD::fgkSSDChipGlueHeight        =   0.030*fgkmm;
      86             : /////////////////////////////////////////////////////////////////////////////////
      87             : // Stiffener (lengths are in mm and angles in degrees)
      88             : /////////////////////////////////////////////////////////////////////////////////
      89         116 : const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerLength       =  73.000*fgkmm;
      90         116 : const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerWidth        =   6.500*fgkmm;
      91         116 : const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerHeight       =   0.295*fgkmm;
      92         116 : const Double_t AliITSv11GeometrySSD::fgkSSDStiffenerToChipDist   =   2.500*fgkmm;
      93         116 : const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603CapLength  =  0.900*fgkmm;  // Includes solder
      94         116 : const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Length   = 1.600*fgkmm; 
      95         116 : const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Width    =   0.870*fgkmm;
      96         116 : const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor0603Height   =   0.800*fgkmm;
      97         116 : const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812CapLength  =  0.215*fgkmm;
      98         116 : const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Length   =   4.600*fgkmm;
      99         116 : const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Width    =   3.400*fgkmm;
     100         116 : const Double_t AliITSv11GeometrySSD::fgkSSDCapacitor1812Height   =   1.400*fgkmm;   
     101         116 : const Double_t AliITSv11GeometrySSD::fgkSSDWireLength            =  30.000*fgkmm;
     102         116 : const Double_t AliITSv11GeometrySSD::fgkSSDWireRadius            =   0.185*fgkmm;
     103         116 : const Double_t AliITSv11GeometrySSD::fgkSSDConnectorPosition[2]  = {44.32*fgkmm, 0.33*fgkmm};
     104         116 : const Double_t AliITSv11GeometrySSD::fgkSSDConnectorSeparation   =        0.44*fgkmm;
     105         116 : const Double_t AliITSv11GeometrySSD::fgkSSDConnectorLength       =        2.16*fgkmm;
     106         116 : const Double_t AliITSv11GeometrySSD::fgkSSDConnectorWidth        =        3.60*fgkmm;
     107         116 : const Double_t AliITSv11GeometrySSD::fgkSSDConnectorHeight       =   0.25*fgkSSDStiffenerHeight;
     108         116 : const Double_t AliITSv11GeometrySSD::fgkSSDConnectorAlHeight     =       0.030*fgkmm;
     109         116 : const Double_t AliITSv11GeometrySSD::fgkSSDConnectorNiHeight     =   0.002*fgkmm;
     110         116 : const Double_t AliITSv11GeometrySSD::fgkSSDConnectorSnHeight     =   0.15*fgkmm;
     111             : /////////////////////////////////////////////////////////////////////////////////
     112             : // Cooling Block (lengths are in mm and angles in degrees)
     113             : /////////////////////////////////////////////////////////////////////////////////
     114         116 : const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockLength    =   3.000*fgkmm;
     115         116 : const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockWidth     =   4.000*fgkmm;
     116             : const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHeight[3] =  
     117         116 :                                                                                  {1.950*fgkmm, 0.240*fgkmm, 0.300*fgkmm};
     118             : const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleRadius[2] = 
     119         116 :   {1.025*fgkmm, 0.120*fgkmm};  // Added 50 micron tolerance for thicker wall cooling pipe (March 2010)
     120             : const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleLength[2] = 
     121         116 :                                                                                                           {1.900*fgkmm, 0.400*fgkmm};
     122             : const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleCenter    =  
     123         116 :                                                                                                                                          1.500*fgkmm;
     124             : const Double_t AliITSv11GeometrySSD::fgkSSDCoolingBlockHoleHeight    =  
     125         116 :                                                                                                                                          0.300*fgkmm;
     126             : /////////////////////////////////////////////////////////////////////////////////
     127             : // SSD Sensor (lengths are in mm and angles in degrees)
     128             : /////////////////////////////////////////////////////////////////////////////////
     129             : const char*  AliITSv11GeometrySSD::fgkSSDSensitiveVolName       = 
     130             :                                                                                                                  "SSDSensorSensitiveVol";
     131         116 : const Double_t AliITSv11GeometrySSD::fgkSSDSensorLength          =  42.000*fgkmm;
     132         116 : const Double_t AliITSv11GeometrySSD::fgkSSDSensorHeight          =   0.300*fgkmm;
     133         116 : const Double_t AliITSv11GeometrySSD::fgkSSDSensorWidth           =  75.000*fgkmm;
     134             : const Double_t AliITSv11GeometrySSD::fgkSSDSensorOverlap         = 
     135         116 :                                                                                                    fgkSSDSensorLength-39.1*fgkmm;
     136         116 : const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveLength    = 1.*fgkmm; 
     137         116 : const Double_t AliITSv11GeometrySSD::fgkSSDSensorInsensitiveWidth     = 1.*fgkmm;
     138             : /////////////////////////////////////////////////////////////////////////////////
     139             : // Flex (lengths are in mm and angles in degrees)
     140             : /////////////////////////////////////////////////////////////////////////////////
     141         116 : const Double_t AliITSv11GeometrySSD::fgkSSDFlexFullLength       =  106.000*fgkmm; 
     142             : const Double_t AliITSv11GeometrySSD::fgkSSDFlexLength[4]        = 
     143         348 :                         {0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
     144          58 :                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
     145         116 :                          0.5 * (fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
     146          58 :                                  + (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength)
     147         232 :                                                                            - 4.000*fgkmm, 9.500*fgkmm, 10.000*fgkmm};
     148             : const Double_t AliITSv11GeometrySSD::fgkSSDFlexWidth[2]         = 
     149         116 :                                                                                                    {  9.340*fgkmm,  5.380*fgkmm};
     150             : const Double_t AliITSv11GeometrySSD::fgkSSDFlexHeight[2]        =
     151         116 :                                                                                                    {  0.030*fgkmm,  0.020*fgkmm};      
     152             : const Double_t AliITSv11GeometrySSD::fgkSSDFlexAngle            =   30.000;
     153         116 : const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleLength       =    1.430*fgkmm;
     154         116 : const Double_t AliITSv11GeometrySSD::fgkSSDFlexHoleWidth        =    3.000*fgkmm;
     155             : const Double_t AliITSv11GeometrySSD::fgkSSDEndFlexCompLength[6] = 
     156         116 :                          {3.30*fgkmm,4.12*fgkmm,4.22*fgkmm,1.70*fgkmm,0.75*fgkmm,7.18*fgkmm};
     157             : const Double_t AliITSv11GeometrySSD:: fgkSSDEndFlexCompWidth[3] =
     158         116 :                                                                                    {15.03*fgkmm,23.48*fgkmm,12.28*fgkmm};
     159             : /////////////////////////////////////////////////////////////////////////////////
     160             : // SSD Ladder Cable (lengths are in mm and angles in degrees)
     161             : /////////////////////////////////////////////////////////////////////////////////
     162         116 : const Double_t AliITSv11GeometrySSD::fgkSSDLadderCableWidth     =     23.5*fgkmm;
     163         116 : const Double_t AliITSv11GeometrySSD::fgkSSDLadderCableHeight[2] = {  0.030*fgkmm*17.5/23.5,  1.25 * 0.030*fgkmm};   // Al covers ~ 17.5/23.5 of surface, Kapton includes glue+foam   
     164             : /////////////////////////////////////////////////////////////////////////////////
     165             : // SSD Module (lengths are in mm and angles in degrees)
     166             : /////////////////////////////////////////////////////////////////////////////////
     167             : const Double_t AliITSv11GeometrySSD::fgkSSDModuleStiffenerPosition[2]  = 
     168         116 :                                                                                                          { 1.000*fgkmm, 3.900*fgkmm};
     169             : const Double_t AliITSv11GeometrySSD::fgkSSDModuleSensorSupportDistance =  
     170         116 :                                                                                                                                         45.600*fgkmm;
     171             : const Double_t AliITSv11GeometrySSD::fgkSSDModuleCoolingBlockToSensor  =  
     172         116 :                                                                                                                                          5.075*fgkmm;
     173             : /////////////////////////////////////////////////////////////////////////////////
     174             : // Sensor Support (lengths are in mm and angles in degrees)
     175             : /////////////////////////////////////////////////////////////////////////////////
     176             : const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportLength                     = 
     177         116 :                                                                                                                                          5.800*fgkmm;
     178             : const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportWidth          =  
     179         116 :                                                                                                                                          2.000*fgkmm;
     180             : const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
     181         174 :                                                                                                      { 4.620*fgkmm-fgkSSDModuleVerticalDisalignment, 
     182         116 :                                                                                                        5.220*fgkmm-fgkSSDModuleVerticalDisalignment};
     183             : //const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportHeight[2]      =
     184             : //                                                                                                   { 4.520*fgkmm, 5.130*fgkmm};
     185             : const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportThickness[2]   = 
     186         116 :                                                                                                          { 0.450*fgkmm, 0.450*fgkmm};
     187             : const Double_t AliITSv11GeometrySSD::fgkSSDSensorSideSupportPosition       
     188         174 :                                                                 = 0.5 * (fgkSSDModuleSensorSupportDistance
     189          58 :                                                             +  fgkSSDSensorSideSupportThickness[0])
     190          58 :                                                                 -  fgkSSDSensorSideSupportLength;
     191             : const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportLength       =  
     192         116 :                                                                                                                                     5.250*fgkmm;
     193             : const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportWidth        =
     194         116 :                                                                                                                                         1.680*fgkmm;
     195             : const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportHeight[2]    
     196         232 :                                                                   = {fgkSSDSensorSideSupportHeight[0]
     197          58 :                                                                   +  fgkSSDSensorSideSupportThickness[0],
     198          58 :                                                                          fgkSSDSensorSideSupportHeight[1]
     199         116 :                                                                   +  fgkSSDSensorSideSupportThickness[1]};
     200             : const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportThickness[2] 
     201         174 :                                                                   =  {fgkSSDSensorSideSupportThickness[0],
     202         116 :                                                                           fgkSSDSensorSideSupportThickness[1]};
     203             : const Double_t AliITSv11GeometrySSD::fgkSSDSensorCenterSupportPosition     = 
     204         116 :                                                                                                                                    19.000*fgkmm;
     205             : /////////////////////////////////////////////////////////////////////////////////
     206             : // Chip Cables (lengths are in mm and angles in degrees)
     207             : /////////////////////////////////////////////////////////////////////////////////
     208             : const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesLength[2]   = 
     209         116 :                                   {73.12/fgkSSDChipNumber*fgkmm,fgkSSDChipLength+2.*0.19*fgkmm};
     210             : const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesHeight[4]   = 
     211         232 :                                   {  0.014*fgkmm,  0.010*fgkmm, fgkSSDModuleCoolingBlockToSensor
     212         116 :                                                                   -  (fgkSSDSensorSideSupportHeight[1]
     213          58 :                                                                   -   fgkSSDSensorSideSupportHeight[0])
     214          58 :                                                                   -   fgkSSDModuleVerticalDisalignment
     215          58 :                                                                   -   fgkSSDCoolingBlockHoleCenter
     216          58 :                                                                   -   fgkSSDStiffenerHeight
     217          58 :                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight,
     218          58 :                                                                           fgkSSDModuleCoolingBlockToSensor
     219          58 :                                                                   -   fgkSSDModuleVerticalDisalignment  
     220          58 :                                                                   -   fgkSSDCoolingBlockHoleCenter
     221          58 :                                                                   -       fgkSSDStiffenerHeight
     222         116 :                                                                   -   fgkSSDChipHeight-fgkSSDSensorHeight};
     223             : const Double_t AliITSv11GeometrySSD::fgkSSDChipCablesWidth[3]    = 
     224         116 :                                             { 11.000*fgkmm,  0.800*fgkmm,  0.600*fgkmm};
     225             : /////////////////////////////////////////////////////////////////////////////////
     226             : // Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
     227             : /////////////////////////////////////////////////////////////////////////////////
     228             : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
     229         116 :                                                                                                                                         3.820*fgkmm;
     230             : //const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionLength          = 
     231             : //                                                                                                                                         3.780;
     232             : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionWidth           = 
     233         116 :                                                                                  fgkSSDSensorLength-fgkSSDSensorOverlap;
     234             : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionEdge[2]         = 
     235         116 :                                                                                                         {  0.86*fgkmm,  0.30*fgkmm};
     236             : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionAngle[2]        = 
     237             :                                                                                                                                 { 30.00, 90.00};
     238             : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberJunctionToSensorSupport = 
     239         116 :                                                                                                                                          1.78*fgkmm;
     240             : /////////////////////////////////////////////////////////////////////////////////
     241             : //Carbon Fiber Parameters (lengths are in mm and angles in degrees)
     242             : /////////////////////////////////////////////////////////////////////////////////
     243             : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleLength          
     244         116 :                                                                    = fgkSSDModuleSensorSupportDistance
     245          58 :                                                                    - 2. * fgkCarbonFiberJunctionToSensorSupport;  
     246             : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberTriangleAngle = 60.00;
     247             : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportTopEdgeDist[2]   = 
     248         116 :                                                                                                   {  0.751*fgkmm,  0.482*fgkmm};
     249             : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportEdgeLength  = 
     250         116 :                                                                                                                                         1.630*fgkmm;
     251         116 : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportWidth =   0.950*fgkmm;
     252             : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportXAxisLength      
     253         116 :                                                                         = fgkCarbonFiberTriangleLength
     254         116 :                                                                         - 0.5*fgkCarbonFiberSupportTopEdgeDist[1]
     255          58 :                                                                         / TMath::Cos(fgkCarbonFiberTriangleAngle
     256         116 :                                                                         * TMath::DegToRad());
     257             : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberSupportYAxisLength      
     258         174 :                                                                         = 0.5*(fgkCarbonFiberJunctionWidth
     259          58 :                                                                         - fgkCarbonFiberSupportWidth)
     260          58 :                                                                         - fgkCarbonFiberSupportTopEdgeDist[0]
     261          58 :                                                                         - fgkCarbonFiberSupportWidth;
     262             : /////////////////////////////////////////////////////////////////////////////////
     263             : // Carbon Fiber Lower Support Parameters (lengths are in mm)
     264             : /////////////////////////////////////////////////////////////////////////////////
     265         116 : const Double_t AliITSv11GeometrySSD::fgkLowerSupportToSensorZ           = 11.575*fgkmm;  
     266             : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportWidth             
     267         116 :                                                                                                                                           =  0.950*fgkmm;
     268             : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportLowerLenght       
     269         116 :                                                                                                                                           =  1.600*fgkmm;
     270             : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportHeight            
     271         116 :                                                                                                                                           =  0.830*fgkmm;
     272             : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumeSeparation  
     273         116 :                                                                                           = 0.5*fgkCarbonFiberSupportWidth;
     274             : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportTransverseWidth   
     275         116 :                                                                         = fgkCarbonFiberJunctionWidth
     276         116 :                                                                         - 2. * (fgkCarbonFiberLowerSupportWidth
     277         116 :                                                                         + fgkCarbonFiberLowerSupportVolumeSeparation);
     278             : const Double_t AliITSv11GeometrySSD::fgkCarbonFiberLowerSupportVolumePosition[2] 
     279         232 :                                                                         = {fgkCarbonFiberLowerSupportWidth
     280          58 :                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation,
     281          58 :                                                                            fgkCarbonFiberLowerSupportWidth
     282          58 :                                                                         +  fgkCarbonFiberLowerSupportVolumeSeparation                                                   
     283         116 :                                                                         +  fgkCarbonFiberLowerSupportTransverseWidth};
     284             : /////////////////////////////////////////////////////////////////////////////////
     285             : // End Ladder Carbon Fiber Junction Parameters (lengths are in mm and angles in degrees)
     286             : /////////////////////////////////////////////////////////////////////////////////
     287             : const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberLowerJunctionLength[2] = 
     288         232 :                                                            {0.5 * (fgkSSDLay5LadderLength
     289          58 :                                                                         -  fgkSSDLay5SensorsNumber
     290          58 :                                                                         *  fgkCarbonFiberJunctionWidth
     291          58 :                                                                         -  fgkCarbonFiberLowerSupportWidth),
     292         116 :                                                                 0.5 * (fgkSSDLay5LadderLength
     293          58 :                                                                         -  fgkSSDLay5SensorsNumber
     294          58 :                                                                         *  fgkCarbonFiberJunctionWidth
     295         116 :                                                                         +  fgkCarbonFiberLowerSupportWidth)};
     296             : const Double_t AliITSv11GeometrySSD::fgkEndLadderCarbonFiberUpperJunctionLength[2] = 
     297         174 :                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-20.4*fgkmm,
     298         116 :                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-20.6*fgkmm};
     299             : const Double_t AliITSv11GeometrySSD::fgkEndLadderMountingBlockPosition[2] = 
     300         174 :                                                 {fgkEndLadderCarbonFiberLowerJunctionLength[0]-16.50*fgkmm,
     301         116 :                                                  fgkEndLadderCarbonFiberLowerJunctionLength[1]-31.50*fgkmm};
     302             : const Double_t AliITSv11GeometrySSD::fgkendladdercoolingsupportdistance[3] = 
     303         116 :                                                                                         {15.0*fgkmm, 13.5*fgkmm, 14.5*fgkmm};
     304             : /////////////////////////////////////////////////////////////////////////////////
     305             : // Cooling Tube Support (lengths are in mm and angles in degrees)
     306             : /////////////////////////////////////////////////////////////////////////////////
     307         116 : const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmax      =  1.45*fgkmm;
     308             : const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportRmin          
     309         116 :                                                                                           = fgkSSDCoolingBlockHoleRadius[0];
     310         116 : const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportLength    =  8.55*fgkmm;
     311         116 : const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportHeight    =  0.85*fgkmm;
     312         116 : const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportWidth     =  2.00*fgkmm;
     313             : const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportSeparation    = 
     314         116 :                                         fgkSSDSensorLength-2.*fgkSSDSensorOverlap;
     315             : const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSupportToCarbonFiber = 
     316         116 :                                                                                                                                           11.70*fgkmm;
     317             : /////////////////////////////////////////////////////////////////////////////////
     318             : // Cooling Tube (lengths are in mm and angles in degrees)
     319             : /////////////////////////////////////////////////////////////////////////////////
     320         116 : const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmax = fgkCoolingTubeSupportRmin;
     321         116 : const Double_t AliITSv11GeometrySSD::fgkCoolingTubeRmin =  1.915*fgkmm/2; // Nominal + 50 micron tolerance; real pipes are closer to 450 micron wall thickness
     322             : const Double_t AliITSv11GeometrySSD::fgkCoolingTubeLength = 
     323         116 :                                                                                                         fgkCarbonFiberJunctionWidth;
     324             : const Double_t AliITSv11GeometrySSD::fgkCoolingTubeSeparation = 
     325         116 :                                                                          fgkSSDModuleSensorSupportDistance
     326          58 :                                                                   +      fgkSSDCoolingBlockLength;
     327         116 : const Double_t AliITSv11GeometrySSD::fgkMountingBlockToSensorSupport = 30.7*fgkmm;
     328             : /////////////////////////////////////////////////////////////////////////////////
     329             : // SSD Mounting Block Parameters (lengths are in mm and angles in degrees)
     330             : /////////////////////////////////////////////////////////////////////////////////
     331             : const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockLength[3]            = 
     332         116 :                                                                                    { 60.0*fgkmm, 42.2*fgkmm, 34.0*fgkmm};
     333             : const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHeight[4]            =
     334         116 :                                                            {  4.0*fgkmm,  8.0*fgkmm,  5.0*fgkmm,  0.2*fgkmm};
     335             : const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockWidth                =   
     336         116 :                                                                                                                                           20.0*fgkmm;
     337             : const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidAngle   =   
     338             :                                                                                                                                                     40.0;
     339             : const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidHeight  = 
     340         116 :                    0.30*(fgkSSDMountingBlockHeight[1]-fgkSSDMountingBlockHeight[2]);
     341             : const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTrapezoidUpBasis =    
     342         116 :                                                                                                                                           2.5*fgkmm;
     343             : const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeLength[2]    = 
     344         116 :                                                                                                           { 56.0*fgkmm, 12.0*fgkmm}; 
     345             : const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleTubeWidth[2]     = 
     346         116 :                                                                                                       {  5.0*fgkmm,  2.9*fgkmm}; 
     347             : const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockHoleRadius           = 
     348         116 :                                                                                                                                           1.0*fgkmm;
     349             : const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleEdge        =   
     350         116 :                                                                                                                                           6.0*fgkmm;
     351             : const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleHeight      =  
     352         116 :                                                                                                                                           4.0*fgkmm;
     353             : const Double_t AliITSv11GeometrySSD::fgkSSDMountingBlockScrewHoleRadius[2]   =
     354         116 :                                                           {  1.5*fgkmm,fgkSSDMountingBlockScrewHoleEdge/6.};
     355             : /////////////////////////////////////////////////////////////////////////////////
     356             : // SSD Mounting Block Clip Parameters (lengths are in mm and angles in degrees)
     357             : /////////////////////////////////////////////////////////////////////////////////
     358         116 : const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipLength        = 15.1*fgkmm;
     359         116 : const Double_t AliITSv11GeometrySSD::fgkMountingBlockClipThickness     = 0.3*fgkmm;
     360         116 : const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewRadius   = 1.6*fgkmm;
     361         116 : const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibScrewPosition = 4.0*fgkmm;
     362         116 : const Double_t AliITSv11GeometrySSD::fgkMountingBlockClibWidth         = 9.0*fgkmm;
     363             : /////////////////////////////////////////////////////////////////////////////////
     364             : // SSD Mounting Block Support Parameters (lengths are in mm and angles in degrees)
     365             : /////////////////////////////////////////////////////////////////////////////////
     366         116 : const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportWidth[2] = {9.5*fgkmm,10.0*fgkmm}; 
     367         116 : const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportDownHeight   = 4.0*fgkmm;
     368         232 : const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportRadius[2] = {fgkSSDLay5RadiusMin
     369          58 :                                                                                                   -  fgkSSDMountingBlockHeight[1]
     370          58 :                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
     371          58 :                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
     372          58 :                                                                                                   -      fgkMountingBlockSupportDownHeight,
     373          58 :                                                                                                          fgkSSDLay6RadiusMin
     374          58 :                                                                                                   -  fgkSSDMountingBlockHeight[1]
     375          58 :                                                                                                   +  0.5*fgkCoolingTubeSupportHeight
     376          58 :                                                                                                   +      fgkSSDModuleCoolingBlockToSensor
     377         116 :                                                                                                   -      fgkMountingBlockSupportDownHeight}; 
     378         232 : const Double_t AliITSv11GeometrySSD::fgkMountingBlockSupportUpHeight[2] = {fgkSSDLay5RadiusMax
     379          58 :                                                                                                     -  fgkSSDMountingBlockHeight[1]
     380          58 :                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
     381          58 :                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
     382          58 :                                                                                                         -  fgkMountingBlockSupportRadius[0],
     383          58 :                                                                                                            fgkSSDLay6RadiusMax
     384          58 :                                                                                                     -  fgkSSDMountingBlockHeight[1]
     385          58 :                                                                                                     +  0.5*fgkCoolingTubeSupportHeight
     386          58 :                                                                                                     +  fgkSSDModuleCoolingBlockToSensor
     387         116 :                                                                                                         -  fgkMountingBlockSupportRadius[1]};
     388         116 : const Double_t AliITSv11GeometrySSD::fgkLadderSupportHeight = 10.0*fgkmm; // To be verified
     389         116 : const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay5Position = 451.35*fgkmm;
     390         116 : const Double_t AliITSv11GeometrySSD::fgkLadderSupportRingLay6Position = 510.00*fgkmm;
     391             : /////////////////////////////////////////////////////////////////////////////////
     392             : // SSD End Cap Cover Plate Parameters (lengths are in mm and angles in degrees)
     393             : /////////////////////////////////////////////////////////////////////////////////
     394         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleRadius = 1.25*fgkmm;
     395         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateBigHoleRadius = 2.45*fgkmm;
     396         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateThickness = 0.5*fgkmm;
     397             : const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateSmallHoleSeparation[3] =
     398         116 :                                                                                                 {16.5*fgkmm,22.0*fgkmm,7.*fgkmm};
     399             : const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateLength[6] = 
     400         116 :                                   {7.*fgkmm,55.*fgkmm,8.0*fgkmm,53.*fgkmm,61.0*fgkmm,25.5*fgkmm};
     401             : const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateWidth[3] = 
     402         116 :                                                                                            {68.5*fgkmm,75.5*fgkmm,6.5*fgkmm};
     403         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMin = 0.750*fgkmm;  
     404         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateScrewRadiusMax = 2.*fgkmm;  
     405         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipLength = 10.4*fgkmm;
     406         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateClipWidth = 6.0*fgkmm;
     407         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipLength = 5.7*fgkmm;
     408         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapCoverPlateDownClipWidth = 5.0*fgkmm;
     409             : /////////////////////////////////////////////////////////////////////////////////
     410             : // SSD End Cap Kapton Foil Parameters (lengths are in mm and angles in degrees)
     411             : /////////////////////////////////////////////////////////////////////////////////
     412         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilThickness = 0.4*fgkmm;
     413         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilLength = 68.0*fgkmm;
     414         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapKaptonFoilWidth = 75.0*fgkmm;
     415             : /////////////////////////////////////////////////////////////////////////////////
     416             : // SSD End Cap Cooling Tube Parameters (lengths are in mm and angles in degrees)
     417             : /////////////////////////////////////////////////////////////////////////////////
     418             : const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAxialRadius[2] =
     419         116 :                                                                                                                 {10.5*fgkmm,9.25*fgkmm}; 
     420         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMin = 1.3*fgkmm; 
     421         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeRadiusMax = 1.5*fgkmm; 
     422             : const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeAngle[5] =
     423             :                                                                                                         {182.3,177.9,84.4,70.0,35.0}; 
     424             : const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeLength[5] = 
     425         232 :                                                                         {49.5*fgkmm,41.7*fgkmm,47.6*fgkmm,5.0*fgkmm};
     426         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapCoolingTubeToCoverSide = 13.0*fgkmm;
     427             : /////////////////////////////////////////////////////////////////////////////////
     428             : // SSD End Cap Cover Side Parameters (lengths are in mm and angles in degrees)
     429             : /////////////////////////////////////////////////////////////////////////////////
     430         348 : const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverLength[5] = {3.5*fgkmm,
     431         290 :                                                                           6.5*fgkmm,75.0*fgkmm,8.0*fgkmm,2.0*fgkmm};
     432         464 : const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverWidth[7] = {30.9*fgkmm,
     433         174 :                                                                           47.5*fgkmm,12.6*fgkmm,5.6*fgkmm,
     434         232 :                                                                           20.0*fgkmm,7.0*fgkmm,5.9*fgkmm};
     435         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapSideCoverThickness = 0.4*fgkmm; 
     436             : /////////////////////////////////////////////////////////////////////////////////
     437             : // SSD End Cap Cards Parameters (lengths are in mm and angles in degrees)
     438             : /////////////////////////////////////////////////////////////////////////////////
     439             : const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackLength[3] = 
     440         232 :                                                                                                            {62.0*fgkmm,21.87*fgkmm};
     441             : const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackWidth[2] = 
     442         116 :                                                                                                             {47.0*fgkmm,0.35*fgkmm};
     443             : const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardBackThickness = 
     444         116 :                                                                                                                                           1.0*fgkmm;
     445         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLength = 61.8*fgkmm;
     446             : const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerWidth[2] =
     447         116 :                                                                                                            {43.5*fgkmm, 0.70*fgkmm};
     448             : const Double_t AliITSv11GeometrySSD::fgkEndCapCardElectBoardLayerThickness = 
     449         116 :                                                                                                                                          0.15*fgkmm;
     450             : const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorThickness = 
     451         116 :                                                                                                                                          19.0*fgkmm;
     452             : const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorLength[2] = 
     453         116 :                                                                                                                  {4.80*fgkmm,1.1*fgkmm};
     454             : const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorWidth[2] =
     455         116 :                                                                                                                  {3.3*fgkmm,1.10*fgkmm};
     456             : const Double_t AliITSv11GeometrySSD::fgkEndCapCardJMDConnectorToLayer = 
     457         116 :                                                                                                                                           2.1*fgkmm;
     458             : const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorLength[3] =
     459         116 :                                                                                                 {5.2*fgkmm,3.5*fgkmm,1.2*fgkmm}; 
     460             : const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorWidth[2] =
     461         116 :                                                                                                                  {1.9*fgkmm,0.15*fgkmm}; 
     462             : const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorThickness = 
     463         116 :                                                                                                                                            19*fgkmm; 
     464             : const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorDistance = 
     465         116 :                                                                                                                                           1.0*fgkmm;
     466             : const Double_t AliITSv11GeometrySSD::fgkEndCapCardCableConnectorToLayer = 
     467         116 :                                                                                                                                           3.6*fgkmm;
     468             : const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionLength = 
     469         116 :                                                                                                                                          61.0*fgkmm; 
     470             : const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionThickness =
     471         116 :                                                                                                                                          5.97*fgkmm; 
     472         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapStripConnectionWidth = 3.0*fgkmm; 
     473             : const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBLength[7] = 
     474         348 :                                                                                                 {3.1*fgkmm,68.0*fgkmm,3.6*fgkmm,
     475         290 :                                                                           1.9*fgkmm,2.5*fgkmm,14.2*fgkmm,1.5*fgkmm};
     476             : const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBWidth[5] = 
     477         116 :                                                   {17.0*fgkmm,10.0*fgkmm,5.9*fgkmm,6.4*fgkmm,3.9*fgkmm};
     478             : const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBThickness = 
     479         116 :                                                                                                                                           1.0*fgkmm; 
     480             : const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceElectBoardCardBThickness 
     481         116 :                                                                                                                                    = 0.15*fgkmm; 
     482             : const Double_t AliITSv11GeometrySSD::fgkEndCapInterfaceCardBJMDConnectorSeparation = 
     483         116 :                                                                                                                                          20.0*fgkmm;
     484         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerLength = 68.0*fgkmm;
     485         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerWidth = 5.0*fgkmm;
     486         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapStiffenerThickness = 5.0*fgkmm;
     487         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMin = 1.25*fgkmm; // To Be Checked
     488         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapEffectiveCableRadiusMax = 1.575*fgkmm; // To Be Checked
     489             : /////////////////////////////////////////////////////////////////////////////////
     490             : // SSD End Cap SupportLayer5/6 Side Parameters (lengths are in mm and angles in degrees)
     491             : /////////////////////////////////////////////////////////////////////////////////
     492         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLength[2] = {70.424*fgkmm,72.919*fgkmm};
     493         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapSupportMiddleRadius[2] = {377.0*fgkmm,437.0*fgkmm};
     494         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowRadius[2] = {375.0*fgkmm,435.0*fgkmm};
     495         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapSupportHighWidth = 20.0*fgkmm;
     496         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapSupportLowWidth[2] = {3.0*fgkmm,3.0*fgkmm};
     497         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5ITSPosition = 624.9*fgkmm;
     498         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay5Position = 2.5*fgkmm;
     499         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6ITSPosition = 635.0*fgkmm;
     500         116 : const Double_t AliITSv11GeometrySSD::fgkEndCapSupportCenterLay6Position = 2.5*fgkmm;
     501             : /////////////////////////////////////////////////////////////////////////////////
     502             : // SSD Cone Parameters (lengths are in mm and angles in degrees)
     503             : /////////////////////////////////////////////////////////////////////////////////
     504         116 : const Double_t AliITSv11GeometrySSD::fgkSSDLowerPConeRadius = 296.5*fgkmm;
     505             : const Double_t AliITSv11GeometrySSD::fgkSSDPConeAngle = 39.0; 
     506         116 : const Double_t AliITSv11GeometrySSD::fgkSSDPConeZLength[2] = {168.0*fgkmm,153.0*fgkmm};
     507         116 : const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleRadius = 317.5*fgkmm;
     508         116 : const Double_t AliITSv11GeometrySSD::fgkSSDPConeLittleHoleLength = 20.*fgkmm;   
     509         116 : const Double_t AliITSv11GeometrySSD::fgkSSDConeMiddleRadius = 350.*fgkmm;
     510         116 : const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleLength = 30.*fgkmm;
     511         116 : const Double_t AliITSv11GeometrySSD::fgkSSDPConeMiddleWidth = 40.*fgkmm;
     512         116 : const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpRadius = 400.*fgkmm;
     513         116 : const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMaxRadius = 459.*fgkmm;
     514         116 : const Double_t AliITSv11GeometrySSD::fgkSSDPConeUpMiddleRadius = 472.5*fgkmm;
     515         116 : const Double_t AliITSv11GeometrySSD::fgkSSDPConeDownRadius = 282.0*fgkmm;
     516             : const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidAngle = 42.0;
     517         116 : const Double_t AliITSv11GeometrySSD::fgkSSDPConeTrapezoidBasis = 200.0*fgkmm;
     518         116 : const Double_t AliITSv11GeometrySSD::fgkSSDPConeExternalRadius = 492.5*fgkmm;
     519         116 : const Double_t AliITSv11GeometrySSD::fgkSSDPConeRadiusWidth = 16.75*fgkmm;
     520         116 : const Double_t AliITSv11GeometrySSD::fgkSSDPConeLength = 168.0*fgkmm;
     521         116 : const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportLength = 1020.*fgkmm;
     522         116 : const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportRadius = 297.5*fgkmm;  
     523         116 : const Double_t AliITSv11GeometrySSD::fgkSSDCentralSupportWidth = 6.28*fgkmm;
     524         116 : const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportLength = 60.0*fgkmm;
     525         116 : const Double_t AliITSv11GeometrySSD::fgkSSDCentralAL3SupportWidth = 2.5*fgkSSDCentralSupportWidth;
     526             : 
     527             : /////////////////////////////////////////////////////////////////////////////////
     528         116 : ClassImp(AliITSv11GeometrySSD)
     529             : /////////////////////////////////////////////////////////////////////////////////
     530             : AliITSv11GeometrySSD::AliITSv11GeometrySSD(): 
     531           1 :   AliITSv11Geometry(),
     532           1 :   fSSDChipMedium(),
     533           1 :   fSSDChipGlueMedium(),
     534           1 :   fSSDStiffenerMedium(),
     535           1 :   fSSDStiffenerConnectorMedium(),
     536           1 :   fSSDStiffener0603CapacitorMedium(),
     537           1 :   fSSDStiffener1812CapacitorMedium(),
     538           1 :   fSSDStiffenerCapacitorCapMedium(),
     539           1 :   fSSDStiffenerHybridWireMedium(),
     540           1 :   fSSDKaptonFlexMedium(),
     541           1 :   fSSDAlTraceFlexMedium(),
     542           1 :   fSSDAlTraceLadderCableMedium(),
     543           1 :   fSSDKaptonLadderCableMedium(),
     544           1 :   fSSDKaptonChipCableMedium(),
     545           1 :   fSSDAlTraceChipCableMedium(),
     546           1 :   fSSDAlCoolBlockMedium(),
     547           1 :   fSSDSensorMedium(),
     548           1 :   fSSDSensorSupportMedium(),
     549           1 :   fSSDCarbonFiberMedium(),
     550           1 :   fSSDTubeHolderMedium(),
     551           1 :   fSSDCoolingTubeWater(),
     552           1 :   fSSDCoolingTubePhynox(),
     553           1 :   fSSDSupportRingAl(),
     554           1 :   fSSDMountingBlockMedium(),
     555           1 :   fSSDRohaCellCone(),
     556           1 :   fSSDAir(),
     557           1 :   fSSDCopper(),
     558           1 :   fSSDSn(),
     559           1 :   fCreateMaterials(kFALSE),
     560           1 :   fTransformationMatrices(kFALSE),
     561           1 :   fBasicObjects(kFALSE),
     562           1 :   fcarbonfiberjunction(),
     563           1 :   fcoolingtubesupport(),
     564           1 :   fhybridmatrix(),
     565           1 :   fssdcoolingblocksystem(),
     566           1 :   fcoolingblocksystematrix(),
     567           1 :   fssdstiffenerflex(),
     568           1 :   fssdendflex(),
     569           1 :   fcoolingtube(0),
     570           1 :   fendladdercoolingtubesupportmatrix(),
     571           1 :   fendladdermountingblock(),
     572           1 :   fendladdermountingblockclip(),
     573           1 :   fSSDSensor5(),
     574           1 :   fSSDSensor6(),
     575           1 :   fSSDLayer5(), 
     576           1 :   fSSDLayer6(),
     577           1 :   fMotherVol(),
     578           1 :   fLay5LadderSupportRing(),
     579           1 :   fLay6LadderSupportRing(),
     580           1 :   fgkEndCapSupportSystem(),
     581           1 :   fSSDCone(),
     582           1 :   fColorCarbonFiber(4),
     583           1 :   fColorRyton(5),
     584           1 :   fColorPhynox(14),
     585           1 :   fColorSilicon(3),
     586           1 :   fColorAl(38),
     587           1 :   fColorNiSn(40),
     588           1 :   fColorKapton(6),
     589           1 :   fColorPolyhamide(5),
     590           1 :   fColorStiffener(9),
     591           1 :   fColorEpoxy(30),
     592           1 :   fColorWater(7),
     593           1 :   fColorG10(41)
     594           5 : {
     595             :   ////////////////////////
     596             :   // Standard constructor
     597             :   ////////////////////////
     598           6 :   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++){
     599           2 :     fendladdermountingblockcombitrans[i] = NULL;
     600             :   }
     601           6 :   for (Int_t i=0; i < fgkcarbonfibersupportnumber; i++) {
     602           2 :     fcarbonfibersupport[i] = 0;
     603           2 :     fcarbonfibersupportmatrix[i] = 0;
     604             :   }
     605           8 :   for (Int_t i=0; i < fgkcarbonfiberjunctionumber; i++) {
     606           3 :     fcarbonfiberjunctionmatrix[i] = 0;
     607             :   }
     608           6 :   for (Int_t i=0; i < fgkcarbonfiberlowersupportnumber; i++) {
     609           2 :     fcarbonfiberlowersupport[i] = 0;
     610           2 :     fcarbonfiberlowersupportrans[0] = 0;
     611             :   }
     612           6 :   for (Int_t i=0; i < fgkvolumekind; i++) {
     613           2 :     fssdsensorsupport[i] = 0;
     614             :   }
     615           8 :   for (Int_t i=0; i < fgkssdsensorsupportnumber; i++) {
     616           3 :     fssdsensorsupportmatrix[i] = 0;
     617             :   }
     618           6 :   for (Int_t i=0; i < fgkcoolingtubesupportnumber; i++) {
     619           2 :     fcoolingtubesupportmatrix[i] = 0;
     620             :   }
     621           8 :   for (Int_t i=0; i < fgkhybridcompnumber; i++) {
     622           3 :     fssdhybridcomponent[i] = 0;
     623             :   }
     624          10 :   for (Int_t i=0; i < fgkcoolingblocknumber; i++) {
     625           4 :     fcoolingblockmatrix[i] = 0;
     626             :   }
     627           6 :   for (Int_t i=0; i < fgkflexnumber; i++) {
     628           2 :     fstiffenerflexmatrix[i] = 0;
     629           2 :     fendflexmatrix[i] = 0;
     630             :   }
     631           6 :   for (Int_t i=0; i < fgkendladdercoolingtubenumber; i++) {
     632           2 :     fendladdercoolingtube[i] = 0;
     633          12 :     for (Int_t j = 0; j < 2; j++) 
     634           4 :       fendladdercoolingtubematrix[i][j] = 0;
     635             :   }
     636           6 :   for (Int_t i=0; i < fgkendlabbercarbonfiberjunctionumber; i++) {
     637           2 :     fendladdercarbonfiberjunction[i] = 0;
     638             :   }
     639           8 :   for (Int_t i=0; i < fgkendladdercarbonfiberjunctionmatrixnumber; i++) {
     640           3 :     fendladdercarbonfiberjunctionmatrix[i] = 0;
     641             :   }
     642           6 :   for (Int_t i=0; i < fgkendladdercarbonfibermatrixnumber; i++) {
     643           2 :     fendladdercarbonfibermatrix[i] = 0;
     644             :   }
     645           6 :   for (Int_t i=0; i < fgkendladdermountingblocknumber; i++) {
     646           2 :     fendladdermountingblockclipmatrix[i] = 0;
     647             :   }
     648           8 :   for (Int_t i = 0; i < fgkendladderlowersuppnumber+1; i++) {
     649           3 :     fendladderlowersupptrans[i] = 0;
     650             :   }
     651           6 :   for (Int_t i = 0; i < fgkladdercablesnumber; i++) {
     652           2 :     fladdercablematrix[i] = 0;
     653             :   }
     654           6 :   for (Int_t i = 0; i < fgkladdersegmentnumber; i++) {
     655           2 :     fladdersegment[i] = 0;
     656             :   }
     657           6 :   for (Int_t i = 0; i < fgkladdernumber; i++) {
     658           2 :     fladder[i] = 0;
     659           2 :     fladdermatrix[i] = 0;
     660           2 :     fssdsensormatrix[i] = 0;
     661           2 :     flayermatrix[i] = 0;
     662             :   }
     663           6 :   for (Int_t i = 0; i < 2; i++) {
     664           2 :     fLay5LadderSupport[i] = 0;
     665           2 :     fLay6LadderSupport[i] = 0;
     666           2 :     fcoolingtubematrix[i] = NULL;
     667           2 :     fendladdersegment[i] = NULL;
     668           2 :     fendladdersegmentmatrix[i] = NULL;
     669             :   }
     670           2 : }
     671             : 
     672             : ///////////////////////////////////////////////////////////////////////////////
     673             : void AliITSv11GeometrySSD::CreateTransformationMatrices(){
     674             :   ///////////////////////////////////////////////////////////////////////  
     675             :   // Method generating the trasformation matrix for the whole SSD Geometry   
     676             :   ///////////////////////////////////////////////////////////////////////  
     677             :   // Setting some variables for Carbon Fiber Supportmatrix creation
     678             :   //////////////////////////////////////////////////////////////////////
     679           2 :   Double_t carbonfibersupportxaxisEdgeproj = fgkCarbonFiberSupportEdgeLength
     680           1 :                                                                                    * CosD(fgkCarbonFiberJunctionAngle[0]);
     681           1 :   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
     682           1 :                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
     683           1 :                                                                  +      fgkCarbonFiberSupportWidth);
     684             :   Double_t carbonfibersupportheight = carbonfibersupportxaxisEdgeproj
     685           1 :                                                                         * TanD(fgkCarbonFiberJunctionAngle[0]);
     686           1 :   TGeoRotation* carbonfiberot[3];
     687          11 :   for(Int_t i=0; i<3; i++) carbonfiberot[i] = new TGeoRotation();
     688           1 :   carbonfiberot[0]->SetAngles(0.0,180.0,0.0);
     689           1 :   carbonfiberot[1]->SetAngles(90.,-fgkCarbonFiberTriangleAngle,-90.);
     690           1 :   carbonfiberot[2]->SetRotation((*carbonfiberot[1])*(*carbonfiberot[0]));
     691           1 :   Double_t transvector[3] = {fgkCarbonFiberTriangleLength
     692           1 :                                                   *  CosD(fgkCarbonFiberTriangleAngle),0.,
     693           1 :                                                   -  fgkCarbonFiberTriangleLength
     694           1 :                                                   *      SinD(fgkCarbonFiberTriangleAngle)};
     695             :   ///////////////////////////////////////////
     696             :   //Setting Local Translations and Rotations: 
     697             :   ///////////////////////////////////////////
     698           1 :   TGeoCombiTrans* localcarbonfibersupportmatrix[3]; 
     699           3 :   localcarbonfibersupportmatrix[0] = new TGeoCombiTrans(0.0,0.0,
     700           1 :                                                                          0.5*carbonfibersupportheight,NULL);    
     701           3 :   localcarbonfibersupportmatrix[1] = new TGeoCombiTrans(transvector[0],
     702           1 :                                                                          2.*symmetryplaneposition+transvector[1],
     703           1 :                                                                          transvector[2], carbonfiberot[2]);
     704           2 :   localcarbonfibersupportmatrix[2] = new TGeoCombiTrans(*carbonfiberot[1]);
     705             :   /////////////////////////////////////////////////////////////
     706             :   // Carbon Fiber Support Transformations
     707             :   /////////////////////////////////////////////////////////////
     708             :   const Int_t kcarbonfibersupportmatrixnumber[2] = {2,3};
     709           6 :   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++){ 
     710           4 :                 fcarbonfibersupportmatrix[i] = new TGeoHMatrix();
     711          14 :                 for(Int_t j=0; j<kcarbonfibersupportmatrixnumber[i]; j++)
     712           5 :                         fcarbonfibersupportmatrix[i]->MultiplyLeft(localcarbonfibersupportmatrix[i==0?2*j:j]);
     713             :   }             
     714             :   /////////////////////////////////////////////////////////////
     715             :   // Carbon Fiber Junction Transformation
     716             :   /////////////////////////////////////////////////////////////
     717             :   const Int_t kcarbonfiberjunctionmatrixnumber = 2;
     718           1 :   TGeoCombiTrans** localcarbonfiberjunctionmatrix[fgkcarbonfiberjunctionumber];
     719           1 :   TGeoRotation** localcarbonfiberjunctionrot[fgkcarbonfiberjunctionumber];
     720           1 :   TGeoTranslation** localcarbonfiberjunctiontrans[fgkcarbonfiberjunctionumber];
     721           8 :   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){ 
     722           3 :         localcarbonfiberjunctionmatrix[i] = 
     723           3 :                                                 new TGeoCombiTrans*[kcarbonfiberjunctionmatrixnumber];
     724           3 :         localcarbonfiberjunctionrot[i] = 
     725           3 :                                                 new TGeoRotation*[kcarbonfiberjunctionmatrixnumber];
     726           3 :         localcarbonfiberjunctiontrans[i] = 
     727           3 :                                                 new TGeoTranslation*[kcarbonfiberjunctionmatrixnumber];
     728             :   }
     729             :   ///////////////////////
     730             :   // Setting Translations
     731             :   ///////////////////////
     732           2 :   localcarbonfiberjunctiontrans[0][0] = new TGeoTranslation(0.,0.,0.);
     733           1 :   localcarbonfiberjunctiontrans[1][0] = 
     734           1 :                                  new TGeoTranslation(fgkCarbonFiberTriangleLength,0.0,0.0);
     735           1 :   localcarbonfiberjunctiontrans[2][0] = 
     736           2 :                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
     737           2 :                                  * TMath::Cos(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),
     738           1 :                                  fgkCarbonFiberTriangleLength
     739           2 :                                  * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad()),0.0);
     740           1 :   localcarbonfiberjunctiontrans[0][1] = 
     741           1 :                                  new TGeoTranslation(0.0,0.5*fgkCarbonFiberJunctionWidth,0.0);
     742           1 :   localcarbonfiberjunctiontrans[1][1] = 
     743           1 :                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
     744           1 :   localcarbonfiberjunctiontrans[2][1] = 
     745           1 :                                  new TGeoTranslation(*localcarbonfiberjunctiontrans[0][1]);
     746             :   ////////////////////
     747             :   // Setting Rotations
     748             :   ////////////////////
     749           8 :   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
     750          18 :                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++)
     751          12 :                         localcarbonfiberjunctionrot[i][j] = new TGeoRotation();
     752           8 :   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++)
     753           3 :         localcarbonfiberjunctionrot[i][0]->SetAngles(120.*i,0.0,0.0);
     754           1 :   localcarbonfiberjunctionrot[0][1]->SetAngles(0.0,90.0,0.0);
     755           1 :   localcarbonfiberjunctionrot[1][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
     756           1 :   localcarbonfiberjunctionrot[2][1]->SetRotation(*localcarbonfiberjunctionrot[0][1]);
     757             :   ////////////////////////////////////////
     758             :   // Setting Carbon Fiber Junction matrix 
     759             :   ////////////////////////////////////////
     760           8 :   for(Int_t i=0; i<fgkcarbonfiberjunctionumber; i++){
     761           6 :                 fcarbonfiberjunctionmatrix[i] = new TGeoHMatrix();
     762          18 :                 for(Int_t j=0; j<kcarbonfiberjunctionmatrixnumber; j++){
     763           6 :                         localcarbonfiberjunctionmatrix[i][j] = 
     764          12 :                         new TGeoCombiTrans(*localcarbonfiberjunctiontrans[i][j],
     765           6 :                                                            *localcarbonfiberjunctionrot[i][j]);
     766           6 :                     fcarbonfiberjunctionmatrix[i]->MultiplyLeft(localcarbonfiberjunctionmatrix[i][j]);
     767             :          }
     768             :   }
     769             :   /////////////////////////////////////////////////////////////
     770             :   // Carbon Fiber Lower Support Transformations
     771             :   /////////////////////////////////////////////////////////////
     772           1 :   TGeoTranslation* localcarbonfiberlowersupportrans[2];
     773           3 :   localcarbonfiberlowersupportrans[0] = new TGeoTranslation(0.0,
     774           1 :                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
     775           1 :                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
     776             :                                                                          0.0);
     777           3 :   localcarbonfiberlowersupportrans[1] = new TGeoTranslation(0.0,
     778           1 :                                                                          fgkCarbonFiberJunctionWidth
     779           1 :                                                                 -    fgkCarbonFiberLowerSupportWidth
     780           1 :                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[0]
     781           1 :                                                                 -    fgkCarbonFiberLowerSupportVolumePosition[1],
     782           1 :                                                                 -    0.5*fgkCarbonFiberLowerSupportHeight);
     783           1 :    localcarbonfiberlowersupportrans[0]->Add(localcarbonfiberlowersupportrans[1]);
     784           1 :    fcarbonfiberlowersupportrans[0] = 
     785           1 :                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[0]);
     786           1 :    fcarbonfiberlowersupportrans[1] = 
     787           1 :                                                 new TGeoTranslation(*localcarbonfiberlowersupportrans[1]);
     788             :   /////////////////////////////////////////////////////////////
     789             :   // SSD Sensor Support Transformations
     790             :   /////////////////////////////////////////////////////////////
     791             :   const Int_t kssdsensorsupportmatrixnumber = 3;
     792           1 :   TGeoCombiTrans** localssdsensorsupportmatrix[fgkssdsensorsupportnumber];
     793           1 :   TGeoRotation** localssdsensorsupportrot[fgkssdsensorsupportnumber];
     794           1 :   TGeoTranslation** localssdsensorsupportrans[fgkssdsensorsupportnumber];
     795           8 :   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){ 
     796           3 :         localssdsensorsupportmatrix[i] = 
     797           3 :                                                 new TGeoCombiTrans*[kssdsensorsupportmatrixnumber];
     798           3 :         localssdsensorsupportrot[i] = 
     799           3 :                                                 new TGeoRotation*[kssdsensorsupportmatrixnumber];
     800           3 :         localssdsensorsupportrans[i] = 
     801           3 :                                                 new TGeoTranslation*[kssdsensorsupportmatrixnumber];
     802             :   }
     803             :   ///////////////////////
     804             :   // Setting Translations
     805             :   ///////////////////////
     806           3 :   localssdsensorsupportrans[0][0] = new TGeoTranslation(0.0,
     807           1 :                                                                           0.5*fgkSSDSensorSideSupportWidth,
     808             :                                                                           0.0);
     809           1 :   localssdsensorsupportrans[1][0] = 
     810           1 :                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
     811           1 :   localssdsensorsupportrans[2][0] = 
     812           1 :                                                  new TGeoTranslation(*localssdsensorsupportrans[0][0]);
     813           1 :   localssdsensorsupportrans[0][1] = 
     814           2 :                                                  new TGeoTranslation(-0.5*fgkSSDSensorSideSupportWidth,
     815           1 :                                                                                 0.5*fgkSSDSensorSideSupportThickness[0],
     816             :                                                                                 0.0);
     817           1 :   localssdsensorsupportrans[1][1] = 
     818           2 :                                                  new TGeoTranslation(0.5*fgkSSDSensorSideSupportWidth,
     819           1 :                                                                         -   0.5*fgkSSDSensorSideSupportThickness[0]
     820           1 :                                                                     -   fgkSSDModuleSensorSupportDistance,
     821             :                                                                                 0.0);
     822           1 :   localssdsensorsupportrans[2][1] = 
     823           2 :                                                  new TGeoTranslation(0.5*fgkSSDSensorCenterSupportThickness[0]
     824           1 :                                                                         -    fgkSSDSensorCenterSupportPosition,
     825           1 :                                                                                  0.5*fgkSSDSensorCenterSupportWidth
     826           1 :                                                                         -    0.5*fgkSSDModuleSensorSupportDistance,
     827             :                                                                                  fgkSSDSensorCenterSupportThickness[0]);
     828           1 :   localssdsensorsupportrans[0][2] = 
     829           2 :                                                  new TGeoTranslation(fgkCarbonFiberTriangleLength
     830           1 :                                                                         +    fgkCarbonFiberJunctionToSensorSupport,
     831           1 :                                                                                  fgkCarbonFiberJunctionWidth
     832           2 :                                                                     -    0.5*(fgkCarbonFiberLowerSupportWidth
     833           1 :                                                                         +    fgkSSDSensorCenterSupportLength
     834           1 :                                                                         -    fgkSSDSensorCenterSupportThickness[0])
     835           1 :                                                                         -    fgkSSDSensorCenterSupportPosition,
     836             :                                                                              0.0);
     837           1 :   localssdsensorsupportrans[1][2] = 
     838           1 :                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
     839           1 :   localssdsensorsupportrans[2][2] = 
     840           1 :                                                 new TGeoTranslation(*localssdsensorsupportrans[0][2]);
     841             :   ////////////////////
     842             :   // Setting Rotations
     843             :   ////////////////////
     844           8 :   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++)
     845          24 :                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++)
     846          18 :                         localssdsensorsupportrot[i][j] = new TGeoRotation();
     847           8 :   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
     848           3 :         localssdsensorsupportrot[i][0]->SetAngles(0.0,90.0,0.0);
     849           3 :         localssdsensorsupportrot[i][2]->SetAngles(-90.0,0.0,0.0);
     850             :   }
     851           1 :   localssdsensorsupportrot[0][1]->SetAngles(0.0,90.0,-90.0);
     852           1 :   localssdsensorsupportrot[1][1]->SetAngles(180.0,90.0,-90.0);
     853           1 :   localssdsensorsupportrot[2][1]->SetAngles(270.0,90.0,-90.0);
     854             :   ////////////////////////////////////////
     855             :   // SSD Sensor Support matrix 
     856             :   ////////////////////////////////////////
     857           8 :   for(Int_t i=0; i<fgkssdsensorsupportnumber; i++){
     858           6 :                 fssdsensorsupportmatrix[i] = new TGeoHMatrix();
     859          24 :                 for(Int_t j=0; j<kssdsensorsupportmatrixnumber; j++){
     860           9 :                         localssdsensorsupportmatrix[i][j] = 
     861          18 :                         new TGeoCombiTrans(*localssdsensorsupportrans[i][j],
     862           9 :                                                            *localssdsensorsupportrot[i][j]);
     863           9 :                     fssdsensorsupportmatrix[i]->MultiplyLeft(localssdsensorsupportmatrix[i][j]);
     864             :          }
     865             :   }
     866             :   /////////////////////////////////////////////////////////////
     867             :   // SSD Cooling Tube Support Transformations
     868             :   /////////////////////////////////////////////////////////////
     869             :   const Int_t kcoolingtubesupportmatrixnumber = 2;
     870           1 :   TGeoCombiTrans* localcoolingtubesupportmatrix[kcoolingtubesupportmatrixnumber];
     871           1 :   TGeoTranslation* localcoolingtubesupportrans[kcoolingtubesupportmatrixnumber];
     872           1 :   TGeoRotation* localcoolingtubesupportrot[kcoolingtubesupportmatrixnumber];
     873           2 :   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
     874           1 :                                                                                                         /fgkCoolingTubeSupportRmax);
     875           1 :   localcoolingtubesupportrans[0] = 
     876           2 :                         new TGeoTranslation(2.*fgkCoolingTubeSupportRmax*TMath::Cos(phi)
     877           2 :                                                 +  2.*(fgkCoolingTubeSupportLength
     878           1 :                                                 -  fgkCoolingTubeSupportRmax*(1.+TMath::Cos(phi)))
     879           1 :                                                 +  fgkCarbonFiberTriangleLength
     880           1 :                                                 -  2.0*fgkCarbonFiberJunctionLength,0.0,0.0);
     881           1 :   localcoolingtubesupportrans[1] = 
     882           2 :                         new TGeoTranslation(fgkCarbonFiberJunctionLength
     883           1 :                                         - (fgkCoolingTubeSupportLength-fgkCoolingTubeSupportRmax),
     884           2 :                                         - (2.0*fgkSSDSensorLength-fgkSSDSensorOverlap)+
     885           2 :                                                    fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
     886           1 :                     +  0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
     887           2 :                     -  0.5*(fgkCarbonFiberLowerSupportWidth
     888           1 :                                         +          fgkSSDSensorCenterSupportLength
     889           1 :                     -      fgkSSDSensorCenterSupportThickness[0])
     890           1 :                                         +  0.5*fgkSSDSensorLength,
     891           1 :                                         -  0.5*fgkCoolingTubeSupportHeight);  
     892           6 :   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)     
     893           4 :   localcoolingtubesupportrot[i] = new TGeoRotation();
     894           1 :   localcoolingtubesupportrot[0]->SetAngles(180.0,0.0,0.0);
     895           1 :   localcoolingtubesupportrot[1]->SetAngles(0.0,90.0,0.0);
     896           6 :   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++)
     897           2 :         localcoolingtubesupportmatrix[i] = 
     898           4 :                 new TGeoCombiTrans(*localcoolingtubesupportrans[i],
     899           2 :                                                    *localcoolingtubesupportrot[i]);
     900           2 :   fcoolingtubesupportmatrix[0] = new TGeoHMatrix(*localcoolingtubesupportmatrix[1]);
     901           4 :   fcoolingtubesupportmatrix[1] = new TGeoHMatrix((*localcoolingtubesupportmatrix[1])*
     902           1 :                                                                 (*localcoolingtubesupportmatrix[0]));
     903             :   /////////////////////////////////////////////////////////////
     904             :   // End Ladder SSD Cooling Tube Support Transformations
     905             :   /////////////////////////////////////////////////////////////
     906           1 :   TGeoTranslation** localendladdercooltubetrans[2];
     907           1 :   localendladdercooltubetrans[0] = new TGeoTranslation*[4];
     908           1 :   localendladdercooltubetrans[1] = new TGeoTranslation*[2];
     909          14 :   for(Int_t i=0; i<4; i++) localendladdercooltubetrans[0][i] = new TGeoTranslation();
     910           2 :   localendladdercooltubetrans[0][0]->SetTranslation(fgkCarbonFiberJunctionLength
     911           2 :                                                                                         -          (fgkCoolingTubeSupportLength
     912           1 :                                                                                         -               fgkCoolingTubeSupportRmax),
     913           1 :                                                                                                         fgkEndLadderMountingBlockPosition[0]
     914           1 :                                                                                         -               fgkendladdercoolingsupportdistance[0]
     915           1 :                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
     916           1 :                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
     917           2 :   localendladdercooltubetrans[0][1]->SetTranslation(fgkCarbonFiberJunctionLength
     918           2 :                                                                                         -          (fgkCoolingTubeSupportLength
     919           1 :                                                                                         -               fgkCoolingTubeSupportRmax),
     920           1 :                                                                                                         fgkEndLadderMountingBlockPosition[0]
     921           1 :                                                                                         +               fgkendladdercoolingsupportdistance[1]
     922           1 :                                                                                         +   0.5*fgkCoolingTubeSupportWidth,
     923           1 :                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
     924           3 :   localendladdercooltubetrans[0][2]->SetTranslation(2*(fgkCoolingTubeSupportLength
     925           1 :                                                                                         -       fgkCoolingTubeSupportRmax)
     926           1 :                                                                                         +               fgkCarbonFiberTriangleLength
     927           1 :                                                                                         -   2.0*fgkCarbonFiberJunctionLength,
     928             :                                                                                                 0.0,
     929             :                                                                                                 0.0);
     930           2 :   localendladdercooltubetrans[0][3]->SetTranslation(0.0,
     931           1 :                                                                                                         fgkendladdercoolingsupportdistance[0]
     932           1 :                                                                                         +               fgkendladdercoolingsupportdistance[1],
     933             :                                                                                                         0.0);
     934           8 :   for(Int_t i=0; i<2; i++) localendladdercooltubetrans[1][i] = new TGeoTranslation();
     935           2 :   localendladdercooltubetrans[1][0]->SetTranslation(fgkCoolingTubeSupportRmax
     936           1 :                                                                                         +               fgkCarbonFiberJunctionLength
     937           1 :                                                                                         -               fgkCoolingTubeSupportLength,
     938           1 :                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
     939           1 :                                                                                         -       0.5*fgkCoolingTubeSupportWidth
     940           1 :                                                                                                    -fgkendladdercoolingsupportdistance[2],
     941           1 :                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
     942           2 :   localendladdercooltubetrans[1][1]->SetTranslation(fgkCarbonFiberTriangleLength
     943           1 :                                                                                         +               fgkCoolingTubeSupportLength
     944           1 :                                                                                         -               fgkCoolingTubeSupportRmax
     945           1 :                                                                                         -               fgkCarbonFiberJunctionLength,
     946           1 :                                                                                                         fgkEndLadderCarbonFiberLowerJunctionLength[1]
     947           1 :                                                                                         -       0.5*fgkCoolingTubeSupportWidth
     948           1 :                                                                                         -               fgkendladdercoolingsupportdistance[2],
     949           1 :                                                                                         -   0.5*fgkCoolingTubeSupportHeight);
     950           1 :   fendladdercoolingtubesupportmatrix = new TGeoHMatrix**[kcoolingtubesupportmatrixnumber];
     951           1 :   fendladdercoolingtubesupportmatrix[0] = new TGeoHMatrix*[4];
     952           1 :   fendladdercoolingtubesupportmatrix[1] = new TGeoHMatrix*[2];
     953           4 :   fendladdercoolingtubesupportmatrix[0][0] = new TGeoHMatrix((*localendladdercooltubetrans[0][0])*
     954           1 :   (*localcoolingtubesupportrot[1]));
     955           4 :   fendladdercoolingtubesupportmatrix[0][1] = new TGeoHMatrix((*localendladdercooltubetrans[0][1])*
     956           1 :   (*localcoolingtubesupportrot[1]));
     957           2 :   fendladdercoolingtubesupportmatrix[0][2] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][0]);
     958           1 :   fendladdercoolingtubesupportmatrix[0][2]->Multiply(localcoolingtubesupportrot[0]);
     959           1 :   fendladdercoolingtubesupportmatrix[0][2]->MultiplyLeft(localendladdercooltubetrans[0][2]);
     960           2 :   fendladdercoolingtubesupportmatrix[0][3] = new TGeoHMatrix(*fendladdercoolingtubesupportmatrix[0][2]);
     961           1 :   fendladdercoolingtubesupportmatrix[0][3]->MultiplyLeft(localendladdercooltubetrans[0][3]);
     962             : 
     963           1 :   fendladdercoolingtubesupportmatrix[1][0] =    
     964           2 :                                                         new TGeoHMatrix((*localendladdercooltubetrans[1][0])
     965           1 :                                                                                    *(*localcoolingtubesupportrot[1]));
     966           2 :   fendladdercoolingtubesupportmatrix[1][1] = new TGeoHMatrix(*localcoolingtubesupportrot[1]);
     967           1 :   fendladdercoolingtubesupportmatrix[1][1]->Multiply(localcoolingtubesupportrot[0]);
     968           1 :   fendladdercoolingtubesupportmatrix[1][1]->MultiplyLeft(localendladdercooltubetrans[1][1]);
     969             :   /////////////////////////////////////////////////////////////
     970             :   // SSD Cooling Tube Transformations
     971             :   /////////////////////////////////////////////////////////////
     972           1 :   TGeoRotation* localcoolingtuberot = new TGeoRotation();       
     973           1 :   localcoolingtuberot->SetAngles(0.,90.,0.);
     974           1 :   TGeoTranslation* localcoolingtubetrans[2];
     975           1 :   TVector3* localcoolingtubevect[2];
     976             : 
     977           4 :   localcoolingtubevect[0] = new TVector3(-0.5*(fgkCoolingTubeSeparation
     978           1 :                                                   -fgkCarbonFiberTriangleLength),
     979           1 :                                             fgkCarbonFiberJunctionWidth         // Y-coord is local Z, from sensor translation 
     980           1 :                                             - fgkCarbonFiberLowerSupportWidth 
     981           1 :                                             - fgkLowerSupportToSensorZ ,
     982           1 :                                                   -  0.5*fgkCoolingTubeSupportHeight);  
     983           3 :   localcoolingtubevect[1] = new TVector3( -localcoolingtubevect[0]->X()+fgkCarbonFiberTriangleLength,
     984           1 :                                               localcoolingtubevect[0]->Y(),
     985           1 :                                               localcoolingtubevect[0]->Z());
     986           6 :   for(Int_t j=0; j<2; j++){
     987           2 :     localcoolingtubetrans[j] = 
     988           4 :         new TGeoTranslation(localcoolingtubevect[j]->X(),
     989           2 :                             localcoolingtubevect[j]->Y(),
     990           2 :                             localcoolingtubevect[j]->Z());
     991           6 :      fcoolingtubematrix[j] = new TGeoHMatrix((*localcoolingtubetrans[j])
     992           2 :                                              *(*localcoolingtuberot));
     993             :   }
     994             :   /////////////////////////////////////////////////////////////
     995             :   // SSD End Ladder Cooling Tube Transformations
     996             :   /////////////////////////////////////////////////////////////
     997           1 :   TGeoRotation* localendlladdercoolingtuberot = new TGeoRotation();     
     998           1 :   localendlladdercoolingtuberot->SetAngles(0.,90.,0.);
     999           1 :   TGeoTranslation** localendlladdercoolingtubetrans[2];
    1000           1 :   localendlladdercoolingtubetrans[0] = new TGeoTranslation*[2];
    1001           1 :   localendlladdercoolingtubetrans[1] = new TGeoTranslation*[2];
    1002           6 :   for(Int_t i=0; i<2; i++)   
    1003          12 :         for(Int_t j=0; j<2; j++)     
    1004           8 :                 localendlladdercoolingtubetrans[i][j] = new TGeoTranslation();
    1005             : 
    1006           1 :   Double_t sensZshift = 0.5*fgkCarbonFiberJunctionWidth - fgkCarbonFiberLowerSupportWidth - fgkLowerSupportToSensorZ;
    1007           3 :   localendlladdercoolingtubetrans[0][0]->SetTranslation(-(fgkCoolingTubeSupportLength
    1008           1 :                                                                         -        fgkCoolingTubeSupportRmax)
    1009           1 :                                                                         +        fgkCarbonFiberJunctionLength,
    1010           1 :                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0]+sensZshift),
    1011           1 :                                                                         - 0.5*fgkCoolingTubeSupportHeight);
    1012           2 :   localendlladdercoolingtubetrans[0][1]->SetTranslation((fgkCoolingTubeSupportLength
    1013           1 :                                                                         -        fgkCoolingTubeSupportRmax)
    1014           1 :                                                                         -        fgkCarbonFiberJunctionLength
    1015           1 :                                                                         +    fgkCarbonFiberTriangleLength,
    1016           1 :                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0]+sensZshift),
    1017           1 :                                                                         - 0.5*fgkCoolingTubeSupportHeight);
    1018             : 
    1019           3 :   localendlladdercoolingtubetrans[1][0]->SetTranslation(-(fgkCoolingTubeSupportLength
    1020           1 :                                                           -   fgkCoolingTubeSupportRmax)
    1021           1 :                                                         +       fgkCarbonFiberJunctionLength,
    1022           1 :                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1]-sensZshift),
    1023           1 :                                                   -             0.5*fgkCoolingTubeSupportHeight);        
    1024           2 :   localendlladdercoolingtubetrans[1][1]->SetTranslation((fgkCoolingTubeSupportLength
    1025           1 :                                                   -      fgkCoolingTubeSupportRmax)
    1026           1 :                                                   -      fgkCarbonFiberJunctionLength
    1027           1 :                                                   +    fgkCarbonFiberTriangleLength,
    1028           1 :                                                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1]-sensZshift),
    1029           1 :                                                   -             0.5*fgkCoolingTubeSupportHeight);        
    1030           6 :   for(Int_t i=0; i<2; i++)
    1031          12 :         for(Int_t j=0; j<2; j++){
    1032           8 :                 fendladdercoolingtubematrix[i][j] = new TGeoHMatrix(*localendlladdercoolingtuberot);
    1033           4 :                 fendladdercoolingtubematrix[i][j]->MultiplyLeft(localendlladdercoolingtubetrans[i][j]);      
    1034             :         }
    1035             :   /////////////////////////////////////////////////////////////
    1036             :   // SSD Hybrid Components Transformations
    1037             :   /////////////////////////////////////////////////////////////
    1038             :   const Int_t khybridmatrixnumber = 3;
    1039           1 :   TGeoTranslation* localhybridtrans[khybridmatrixnumber];
    1040           3 :   localhybridtrans[0] = new TGeoTranslation(0.5*fgkSSDStiffenerLength,
    1041           1 :                                             0.5*fgkSSDStiffenerWidth,
    1042           1 :                                             0.5*fgkSSDStiffenerHeight);
    1043           3 :   localhybridtrans[1] = new TGeoTranslation(fgkSSDModuleStiffenerPosition[0],
    1044           1 :                                             fgkSSDModuleStiffenerPosition[1],0.0);
    1045             : 
    1046           3 :   localhybridtrans[2] = new TGeoTranslation(
    1047           1 :                       -  0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
    1048           2 :                       -      (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
    1049           2 :                               fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
    1050           1 :                       +         0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
    1051           2 :                       -         0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
    1052           1 :                       -       fgkSSDSensorCenterSupportThickness[0]),
    1053           2 :                       -      (fgkSSDModuleCoolingBlockToSensor+0.5*fgkCoolingTubeSupportHeight
    1054           1 :                       -       fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight
    1055           1 :                                           -       fgkSSDModuleVerticalDisalignment)); 
    1056           2 :   fhybridmatrix = new TGeoHMatrix();
    1057           8 :   for(Int_t i=0; i<khybridmatrixnumber; i++) fhybridmatrix->MultiplyLeft(localhybridtrans[i]);
    1058             :   /////////////////////////////////////////////////////////////
    1059             :   // SSD Cooling Block Transformations
    1060             :   /////////////////////////////////////////////////////////////
    1061           2 :   TGeoTranslation localcoolingblocktrans (fcoolingtubematrix[0]->GetTranslation()[0] 
    1062           1 :                                           - 0.5*fgkSSDCoolingBlockLength,
    1063           1 :                                           fhybridmatrix->GetTranslation()[1]-0.5*fgkSSDStiffenerWidth,
    1064           2 :                                           fhybridmatrix->GetTranslation()[2]+0.5*fgkSSDStiffenerHeight+
    1065           1 :                                           0.5*(fgkSSDCoolingBlockHoleCenter+fgkCoolingTubeRmax));
    1066           3 :   fcoolingblocksystematrix = new TGeoHMatrix(localcoolingblocktrans);
    1067             :   /////////////////////////////////////////////////////////////
    1068             :   // SSD Stiffener Flex Transformations
    1069             :   /////////////////////////////////////////////////////////////
    1070             :   const Int_t klocalflexmatrixnumber = 4;
    1071           1 :   TGeoCombiTrans** localflexmatrix[fgkflexnumber];
    1072           6 :   for(Int_t i=0; i<fgkflexnumber; i++)    
    1073           4 :       localflexmatrix[i] = new TGeoCombiTrans*[klocalflexmatrixnumber];
    1074           6 :   for(Int_t i=0; i<fgkflexnumber; i++)
    1075          20 :       for(Int_t j =0; j<klocalflexmatrixnumber; j++) 
    1076          24 :             localflexmatrix[i][j] = new TGeoCombiTrans();
    1077           1 :   Double_t ssdstiffenerseparation = fgkSSDSensorLength
    1078           1 :                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
    1079           1 :                                                                   -    fgkSSDStiffenerWidth;
    1080           2 :   localflexmatrix[0][0]->SetTranslation(-fgkSSDFlexLength[0]
    1081           1 :                                         +0.5*fgkSSDStiffenerLength,
    1082           1 :                                          0.5*fgkSSDStiffenerWidth,
    1083           1 :                                         -0.5*fgkSSDStiffenerHeight
    1084           1 :                                         -0.5*fgkSSDFlexHeight[0]);
    1085           2 :   localflexmatrix[1][0]->SetTranslation(-(fgkSSDStiffenerLength-fgkSSDFlexLength[0])
    1086           1 :                                         +0.5*fgkSSDStiffenerLength,ssdstiffenerseparation
    1087           1 :                                         -0.5*fgkSSDStiffenerWidth,
    1088           1 :                                         -0.5*fgkSSDStiffenerHeight
    1089           1 :                                         -0.5*fgkSSDFlexHeight[0]);
    1090           2 :   TGeoRotation* localflexrot = new TGeoRotation();
    1091           1 :   localflexrot->SetAngles(180.,0.,0.);    
    1092           1 :   localflexmatrix[1][0]->SetRotation(localflexrot);
    1093           6 :   for(Int_t i=0; i<fgkflexnumber; i++)
    1094          16 :       for(Int_t j =1; j<klocalflexmatrixnumber; j++) 
    1095           6 :             localflexmatrix[i][j]->SetTranslation(*localhybridtrans[j-1]);
    1096           6 :   for(Int_t i=0; i<fgkflexnumber; i++){
    1097           6 :       fstiffenerflexmatrix[i] = new TGeoHMatrix();
    1098          20 :       for(Int_t j =0; j<klocalflexmatrixnumber; j++)   
    1099           8 :             fstiffenerflexmatrix[i]->MultiplyLeft(localflexmatrix[i][j]);
    1100             :   }
    1101             :   /////////////////////////////////////////////////////////////
    1102             :   // SSD End Flex Transformations
    1103             :   /////////////////////////////////////////////////////////////
    1104           2 :   TGeoRotation* localendflexrot = new TGeoRotation();
    1105           1 :   localendflexrot->SetAngles(0.0,90.0,0.0);
    1106           2 :   TGeoCombiTrans* localendflexmatrix = new TGeoCombiTrans();
    1107           1 :   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
    1108           2 :                             /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
    1109           2 :   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
    1110           2 :                             * TMath::DegToRad()*ssdflexradiusmax
    1111           2 :                                                                - fgkSSDFlexLength[2]-TMath::Pi()
    1112           2 :                                                                * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
    1113           1 :                                                                                    - 0.1*fgkSSDFlexFullLength;
    1114           2 :   Double_t trans = ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
    1115           2 :                             + (ssdflexradiusmax-fgkSSDStiffenerHeight)*SinD(2.*fgkSSDFlexAngle)
    1116           1 :                             +      fgkSSDFlexLength[2];
    1117           2 :   localendflexmatrix->SetTranslation(fgkSSDFlexLength[0]-trans,
    1118           1 :                               0.5*fgkSSDFlexWidth[0],
    1119           1 :                               2.*fgkSSDStiffenerHeight
    1120           1 :                             + 0.5*fgkSSDFlexHeight[0]);      
    1121           1 :   localendflexmatrix->SetRotation(localendflexrot);
    1122           6 :   for(Int_t i=0; i<fgkflexnumber; i++) 
    1123           8 :       fendflexmatrix[i] = new TGeoHMatrix((*fstiffenerflexmatrix[i])*(*localendflexmatrix));
    1124             :   /////////////////////////////////////////////////////////////
    1125             :   // End Ladder Carbon Fiber Junction
    1126             :   /////////////////////////////////////////////////////////////
    1127           1 :   TGeoCombiTrans** localendladdercarbonfiberjunctionmatrix[fgkendlabbercarbonfiberjunctionumber];
    1128           1 :   TGeoRotation** localendladdercarbonfiberjunctionrot[fgkendlabbercarbonfiberjunctionumber];    
    1129           1 :   TGeoTranslation** localendladdercarbonfiberjunctiontrans[fgkendlabbercarbonfiberjunctionumber];    
    1130           6 :   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
    1131           2 :       localendladdercarbonfiberjunctionmatrix[i] 
    1132           6 :             = new TGeoCombiTrans*[fgkendladdercarbonfiberjunctionmatrixnumber];
    1133           2 :       localendladdercarbonfiberjunctionrot[i] 
    1134           6 :             = new TGeoRotation*[fgkendladdercarbonfiberjunctionmatrixnumber];
    1135           2 :       localendladdercarbonfiberjunctiontrans[i] 
    1136           6 :             = new TGeoTranslation*[fgkendladdercarbonfiberjunctionmatrixnumber];
    1137           2 :       fendladdercarbonfiberjunctionmatrix[i]
    1138           6 :             = new TGeoHMatrix*[fgkendladdercarbonfiberjunctionmatrixnumber];
    1139             :   }
    1140           6 :   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
    1141          16 :       for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++){
    1142          18 :             localendladdercarbonfiberjunctionrot[i][j] = new TGeoRotation();
    1143          18 :             localendladdercarbonfiberjunctiontrans[i][j] = new TGeoTranslation();
    1144             :       }
    1145           6 :   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)     
    1146          16 :       for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++)
    1147           6 :           localendladdercarbonfiberjunctionrot[i][j]->SetAngles(120.*j,0.,0.);
    1148           6 :   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
    1149           2 :       localendladdercarbonfiberjunctiontrans[i][1]->SetTranslation(fgkCarbonFiberTriangleLength,
    1150             :                               0.0,0.0);
    1151           4 :       localendladdercarbonfiberjunctiontrans[i][2]->SetTranslation(fgkCarbonFiberTriangleLength
    1152           4 :                 *                     CosD(fgkCarbonFiberTriangleAngle),fgkCarbonFiberTriangleLength
    1153           4 :                 *                     SinD(fgkCarbonFiberTriangleAngle),
    1154           4 :                         0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[i]
    1155           2 :   -                          fgkEndLadderCarbonFiberUpperJunctionLength[i]));
    1156             :   }
    1157           1 :   TGeoCombiTrans* localendladdercarbonfiberjunctionglobalmatrix[fgkendlabbercarbonfiberjunctionumber];
    1158           1 :   TGeoRotation* localendladdercarbonfiberjunctionglobalrot[fgkendlabbercarbonfiberjunctionumber];
    1159           1 :   TGeoTranslation* localendladdercarbonfiberjunctionglobaltrans[fgkendlabbercarbonfiberjunctionumber];
    1160           6 :   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
    1161           6 :       localendladdercarbonfiberjunctionglobalrot[i] = new TGeoRotation();
    1162           6 :       localendladdercarbonfiberjunctionglobaltrans[i] = new TGeoTranslation();
    1163           2 :       localendladdercarbonfiberjunctionglobalrot[i]->SetAngles(0.0,90.0,0.0);
    1164           4 :       localendladdercarbonfiberjunctionglobaltrans[i]->SetTranslation(0.0,
    1165           2 :             0.5*fgkEndLadderCarbonFiberLowerJunctionLength[i],0.0);
    1166           2 :       localendladdercarbonfiberjunctionglobalmatrix[i] = 
    1167           6 :             new TGeoCombiTrans(*localendladdercarbonfiberjunctionglobaltrans[i],
    1168           2 :                                *localendladdercarbonfiberjunctionglobalrot[i]);
    1169             :   }
    1170           6 :   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++)    
    1171          16 :       for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++){
    1172           6 :             localendladdercarbonfiberjunctionmatrix[i][j] = 
    1173          18 :                   new TGeoCombiTrans(*localendladdercarbonfiberjunctiontrans[i][j],
    1174           6 :                                      *localendladdercarbonfiberjunctionrot[i][j]);
    1175           6 :            fendladdercarbonfiberjunctionmatrix[i][j] =
    1176          18 :             new TGeoHMatrix((*localendladdercarbonfiberjunctionglobalmatrix[i])
    1177           6 :             *               (*localendladdercarbonfiberjunctionmatrix[i][j])); 
    1178             :       }  
    1179             :   /////////////////////////////////////////////////////////////
    1180             :   // End Ladder Carbon Fiber Support
    1181             :   /////////////////////////////////////////////////////////////
    1182           1 :   TGeoTranslation* localendladdercarbonfibertrans[fgkendladdercarbonfibermatrixnumber];
    1183           6 :   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++){
    1184           6 :       localendladdercarbonfibertrans[i] = new TGeoTranslation();
    1185           2 :       localendladdercarbonfibertrans[i]->SetTranslation(0.0,
    1186           2 :             i==0 ? 0.0 :fgkCarbonFiberLowerSupportWidth,0.0);
    1187           4 :       fendladdercarbonfibermatrix[i] = new TGeoHMatrix*[fgkcarbonfibersupportnumber];
    1188             :   }
    1189           6 :   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
    1190          12 :       for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++)
    1191           4 :             fendladdercarbonfibermatrix[i][j] = 
    1192          12 :             new TGeoHMatrix((*localendladdercarbonfibertrans[i])
    1193           4 :             *(*fcarbonfibersupportmatrix[j]));
    1194             :   /////////////////////////////////////////////////////////////
    1195             :   // End Ladder SSD Mounting Block
    1196             :   /////////////////////////////////////////////////////////////
    1197           6 :   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
    1198           6 :       fendladdermountingblockcombitrans[i] = new TGeoCombiTrans();
    1199           6 :   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
    1200           6 :       fendladdermountingblockcombitrans[i]->SetTranslation(-  0.25*(fgkSSDMountingBlockLength[0]
    1201           2 :                                 +        fgkSSDMountingBlockLength[1])
    1202           2 :                                 +  0.5*fgkCarbonFiberTriangleLength,
    1203           2 :                                 fgkEndLadderMountingBlockPosition[i],
    1204           2 :                                 -  fgkSSDMountingBlockHeight[1]
    1205           2 :                                 +  0.5*fgkSSDMountingBlockHeight[0]);
    1206           2 :   TGeoRotation* endladdermountingblockrot = new TGeoRotation();
    1207           1 :   endladdermountingblockrot->SetAngles(0.,90.,0.);
    1208           6 :   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
    1209           2 :         fendladdermountingblockcombitrans[i]->SetRotation(*endladdermountingblockrot);
    1210             :   /////////////////////////////////////////////////////////////
    1211             :   // End Ladder SSD Mounting Block Clip Matrix 
    1212             :   /////////////////////////////////////////////////////////////
    1213           6 :   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++) 
    1214           4 :         fendladdermountingblockclipmatrix[i] = new TGeoHMatrix*[2];
    1215             :   
    1216           2 :   TGeoRotation* localendladdercliprot = new TGeoRotation();
    1217           2 :   TGeoTranslation* localendladdercliptrans = new TGeoTranslation();
    1218           3 :   localendladdercliptrans->SetTranslation(-0.5*(fgkSSDMountingBlockLength[0]
    1219           1 :                                                                                   -     fgkSSDMountingBlockLength[1])
    1220           1 :                                                                                   + fgkSSDMountingBlockLength[0],0.,0.);
    1221           1 :   localendladdercliprot->SetAngles(90.,180.,-90.);
    1222             :   TGeoCombiTrans* localendladderclipcombitrans = 
    1223           2 :                         new TGeoCombiTrans(*localendladdercliptrans,*localendladdercliprot);
    1224           6 :   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
    1225          12 :         for(Int_t j=0; j<2; j++){
    1226           4 :                 fendladdermountingblockclipmatrix[i][j] = 
    1227           8 :                                                 new TGeoHMatrix(*fendladdermountingblockcombitrans[i]);
    1228           6 :                 if(j!=0) fendladdermountingblockclipmatrix[i][j]->Multiply(localendladderclipcombitrans);
    1229             :         }
    1230             :   /////////////////////////////////////////////////////////////
    1231             :   // End Ladder Carbon Fiber Lower Support
    1232             :   /////////////////////////////////////////////////////////////
    1233           6 :   for(Int_t i=0; i<fgkendladderlowersuppnumber; i++)
    1234           2 :       fendladderlowersupptrans[i] = 
    1235           8 :             new TGeoTranslation(0.0,(1-i)*(fgkEndLadderMountingBlockPosition[i]
    1236           2 :                         +  0.5*fgkSSDMountingBlockWidth),
    1237           2 :                         -  0.5*fgkCarbonFiberLowerSupportHeight);
    1238           1 :   fendladderlowersupptrans[0]->SetDz(-0.5*fgkCarbonFiberLowerSupportHeight-fgkSSDTolerance);
    1239           4 :   fendladderlowersupptrans[2] = new TGeoTranslation(0.0,
    1240           1 :                                                                          fgkCarbonFiberLowerSupportVolumePosition[1]
    1241           1 :                                                                 +    fgkCarbonFiberLowerSupportVolumePosition[0],
    1242             :                                                                          0.0);
    1243           1 :   fendladderlowersupptrans[2]->Add(fendladderlowersupptrans[1]);
    1244             :  /////////////////////////////////////////////////////////////
    1245             :   // Matrix for positioning Ladder into mother volume
    1246             :   /////////////////////////////////////////////////////////////
    1247           1 :   TGeoHMatrix** ladderglobalmatrix[fgkladdernumber];
    1248           6 :   for(Int_t i=0; i<fgkladdernumber; i++) 
    1249           4 :         ladderglobalmatrix[i] = new TGeoHMatrix*[fgkladdernumber];
    1250           2 :   TGeoRotation* localladdermotherrot = new TGeoRotation();
    1251           1 :   localladdermotherrot->SetAngles(0.,90.,0.);  
    1252           1 :   TGeoTranslation* localladdermothertrans[fgkladdernumber];
    1253           1 :   TGeoCombiTrans* localladdermothercombitrans[fgkladdernumber];
    1254           6 :   for(Int_t i=0; i<fgkladdernumber; i++){
    1255           8 :         localladdermothertrans[i] = new TGeoTranslation(0.,
    1256           2 :                                                           - fgkEndLadderCarbonFiberLowerJunctionLength[1]
    1257           2 :                                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]
    1258           4 :                                                           + (i==0?fgkSSDLay5SensorsNumber:fgkSSDLay6SensorsNumber)
    1259           2 :                                                           * fgkCarbonFiberJunctionWidth,0.);
    1260           6 :         localladdermothercombitrans[i] = new TGeoCombiTrans(*localladdermothertrans[i],
    1261             :                                                                                                                 *localladdermotherrot);
    1262           6 :         ladderglobalmatrix[0][i] = new TGeoHMatrix(*localladdermothercombitrans[i]);
    1263           8 :         ladderglobalmatrix[1][i] = new TGeoHMatrix(ladderglobalmatrix[0][i]->Inverse());
    1264             :   }
    1265             :   /////////////////////////////////////////////////////////////
    1266             :   // Ladder Cables Matrices
    1267             :   /////////////////////////////////////////////////////////////
    1268           1 :   Double_t ssdflexradius = fgkSSDStiffenerHeight+2*fgkSSDFlexHeight[0]
    1269           1 :                                              + fgkSSDFlexHeight[1];  
    1270             :   Double_t ssdladdercabletransx[3];
    1271           1 :   ssdladdercabletransx[0] = (ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
    1272           2 :                                                   *   SinD(2.*fgkSSDFlexAngle)
    1273           2 :                                                   *       CosD(2.*fgkSSDFlexAngle);
    1274           1 :   ssdladdercabletransx[1] = ((ssdflexradiusmax-fgkSSDFlexHeight[1]-ssdflexradius)
    1275           1 :                                                   -     ssdladdercabletransx[0]
    1276           2 :                                                   /     SinD(2.*fgkSSDFlexAngle))
    1277           2 :                                                   *     CosD(fgkSSDFlexAngle);                                          
    1278           2 :   ssdladdercabletransx[2] = (fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
    1279           2 :                                                   *       TMath::DegToRad()*ssdflexradiusmax
    1280           2 :                                                   -     fgkSSDFlexLength[2]-TMath::Pi()
    1281           2 :                                                   *       fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
    1282           1 :                                                   -       fgkSSDLadderCableWidth)
    1283           2 :                                                   *       CosD(2.*fgkSSDFlexAngle);
    1284             :   Double_t ssdladdercabletransz[3] = {ssdladdercabletransx[0]
    1285           2 :                                                   *     TanD(2.*fgkSSDFlexAngle),
    1286             :                                                         ssdladdercabletransx[1]
    1287           2 :                                                   *     TanD(fgkSSDFlexAngle),
    1288             :                                                         ssdladdercabletransx[2]
    1289           2 :                                                   *     TanD(2.*fgkSSDFlexAngle)};      
    1290           1 :   TGeoRotation* localladdercablerot[3]; 
    1291          14 :   for(Int_t i=0; i<3; i++) localladdercablerot[i] = new TGeoRotation();
    1292           1 :   localladdercablerot[0]->SetAngles(90.,0.,0.);
    1293           1 :   localladdercablerot[1]->SetAngles(90.,60.,-90.);
    1294           2 :   localladdercablerot[2]->SetRotation((*localladdercablerot[1])
    1295           1 :                                                  *                        (*localladdercablerot[0]));
    1296             :   //TGeoRotation* localladdercablerot = new TGeoRotation();     
    1297             :   //localladdercablerot->SetAngles(90.,0.,0.);
    1298             :   ////////////////////////////////////////////
    1299             :   // LocalLadderCableCombiTransMatrix
    1300             :   ////////////////////////////////////////////
    1301             :   const Int_t klocalladdersidecablesnumber = 2;
    1302             :   const Int_t klocalladdercombitransnumber = 5;
    1303           1 :   TGeoCombiTrans** localladdercablecombitransmatrix[klocalladdersidecablesnumber];
    1304           6 :   for(Int_t i=0; i<klocalladdersidecablesnumber; i++) 
    1305           2 :          localladdercablecombitransmatrix[i] = 
    1306           4 :                                                            new TGeoCombiTrans*[klocalladdercombitransnumber];
    1307             :   ///////////////////////////////////////////
    1308             :   // Left Side Ladder Cables Transformations
    1309             :   ///////////////////////////////////////////
    1310           1 :   localladdercablecombitransmatrix[0][0]  =
    1311           2 :                                                 new TGeoCombiTrans(-0.5*fgkCarbonFiberTriangleLength,
    1312             :                                                 0.,0.,NULL);
    1313           1 :   localladdercablecombitransmatrix[0][1] = 
    1314           3 :         new TGeoCombiTrans(-0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength),
    1315           2 :                                            - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
    1316           2 :                                                  fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
    1317           1 :                                            + 0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
    1318           2 :                                            - 0.5*(fgkCarbonFiberLowerSupportWidth
    1319           1 :                                            + fgkSSDSensorCenterSupportLength
    1320           1 :                                            - fgkSSDSensorCenterSupportThickness[0]),
    1321           2 :                                            - (fgkSSDModuleCoolingBlockToSensor
    1322           1 :                                            + 0.5*fgkCoolingTubeSupportHeight
    1323           1 :                                            - fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]
    1324           1 :                                            - fgkSSDChipHeight),NULL);
    1325           1 :   localladdercablecombitransmatrix[0][2] = 
    1326           3 :                                                 new TGeoCombiTrans(fgkSSDModuleStiffenerPosition[0],
    1327           1 :                                                                                    fgkSSDModuleStiffenerPosition[1],0.,0);
    1328           4 :   localladdercablecombitransmatrix[0][3] = new TGeoCombiTrans(
    1329           2 :                                         0.5*(fgkSSDStiffenerLength+fgkSSDChipNumber*fgkSSDChipLength
    1330           1 :                                    +(fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
    1331           1 :                                    fgkSSDSensorLength-2.*fgkSSDModuleStiffenerPosition[1]
    1332           1 :                                          - fgkSSDStiffenerWidth,- 0.5*fgkSSDChipHeight,
    1333           2 :                                                                                                 new TGeoRotation("",180.,0.,0.));
    1334           1 :   localladdercablecombitransmatrix[0][4] = 
    1335           3 :                                                 new TGeoCombiTrans(-ssdladdercabletransx[0]
    1336           1 :                                                 -     ssdladdercabletransx[1]-ssdladdercabletransx[2]
    1337           1 :                                                 +     fgkSSDFlexLength[0]-fgkSSDFlexLength[2],
    1338             :                                                           0.,
    1339           2 :                                                           0.5*fgkSSDFlexHeight[0]+2.*(fgkSSDFlexHeight[0]
    1340           2 :                                                 +         fgkSSDFlexHeight[1])+2.*fgkSSDStiffenerHeight
    1341           1 :                                                 +     ssdladdercabletransz[0]-ssdladdercabletransz[1]
    1342           1 :                                                 +         ssdladdercabletransz[2],localladdercablerot[2]);
    1343             :   ///////////////////////////////////////////
    1344             :   // Rigth Side Ladder Cables Transformations
    1345             :   ///////////////////////////////////////////
    1346             :   TGeoCombiTrans* localladdercablessdmodulematrix = 
    1347           4 :         new TGeoCombiTrans(0.5*(fgkSSDStiffenerLength-fgkSSDChipNumber*fgkSSDChipLength
    1348           1 :                                                                   - (fgkSSDChipNumber-1)*fgkSSDChipSeparationLength),
    1349           1 :                                                                          fgkSSDStiffenerWidth,
    1350           1 :                                                                   - 0.5*fgkSSDFlexHeight[0],NULL);
    1351          12 :   for(Int_t i=0; i<klocalladdercombitransnumber; i++)
    1352           5 :    localladdercablecombitransmatrix[1][i] = 
    1353          18 :                         (i!=3 ? new TGeoCombiTrans(*localladdercablecombitransmatrix[0][i]):
    1354           2 :                                         new TGeoCombiTrans(*localladdercablessdmodulematrix));  
    1355             :   ///////////////////////////////////////////
    1356             :   // Setting LadderCableHMatrix
    1357             :   ///////////////////////////////////////////
    1358           1 :   Int_t beamaxistrans[2][3];
    1359           1 :   beamaxistrans[0][0] = fgkSSDLay5SensorsNumber/2; 
    1360           1 :   beamaxistrans[0][1] = beamaxistrans[0][0]+1;
    1361           1 :   beamaxistrans[0][2] = beamaxistrans[0][0]-1;
    1362           1 :   beamaxistrans[1][0] = (fgkSSDLay6SensorsNumber-1)/2;
    1363           1 :   beamaxistrans[1][1] = beamaxistrans[1][0]+1;
    1364           1 :   beamaxistrans[1][2] = beamaxistrans[1][0];
    1365           1 :   TGeoHMatrix** localladdercablehmatrix[fgkladdercablesnumber];
    1366           2 :   TGeoRotation* laddercablerot = new TGeoRotation();
    1367           2 :   TGeoTranslation* laddercabletrans = new TGeoTranslation();
    1368           2 :   TGeoCombiTrans* laddercablecombitrans = new TGeoCombiTrans();
    1369             :   Double_t* laddercabletransvector;     
    1370           6 :   for(Int_t i=0; i<fgkladdercablesnumber; i++){ 
    1371           4 :         localladdercablehmatrix[i] = new TGeoHMatrix*[klocalladdersidecablesnumber];
    1372           4 :         fladdercablematrix[i] = new TGeoHMatrix*[fgkladdercablematrixnumber];
    1373             :   }
    1374           6 :   for(Int_t i=0; i<fgkladdercablesnumber; i++){
    1375          12 :         for(Int_t j=0; j<klocalladdersidecablesnumber; j++){
    1376          12 :                 localladdercablehmatrix[i][j] = new TGeoHMatrix();
    1377          48 :                 for(Int_t k=0; k<klocalladdercombitransnumber; k++){
    1378          40 :                         localladdercablehmatrix[i][j]->MultiplyLeft(
    1379          20 :                         localladdercablecombitransmatrix[j][klocalladdercombitransnumber-k-1]);
    1380             :         }
    1381           8 :                 laddercablerot->SetMatrix(localladdercablehmatrix[i][j]->GetRotationMatrix());
    1382           4 :                 laddercabletransvector = localladdercablehmatrix[i][j]->GetTranslation();
    1383           8 :                 laddercabletrans->SetTranslation(laddercabletransvector[0],
    1384           4 :                                                                          laddercabletransvector[1]
    1385          14 :                                         +                (j==0 ? beamaxistrans[i][0] : 0.)
    1386           4 :                                         *                                fgkCarbonFiberJunctionWidth,
    1387           4 :                                                                          laddercabletransvector[2]);
    1388           4 :                 laddercablecombitrans->SetRotation(*laddercablerot);
    1389           4 :                 laddercablecombitrans->SetTranslation(*laddercabletrans);    
    1390          12 :                 fladdercablematrix[i][j] = new TGeoHMatrix(*laddercablecombitrans);
    1391             :         }
    1392           2 :     fladdercablematrix[i][2] = 
    1393           4 :                                         AddTranslationToHMatrix(fladdercablematrix[i][1],0.,
    1394           2 :                                         beamaxistrans[i][1]*fgkCarbonFiberJunctionWidth,0.);
    1395           2 :         fladdercablematrix[i][3] = 
    1396           4 :                                         AddTranslationToHMatrix(fladdercablematrix[i][0],0.,
    1397           2 :                                         beamaxistrans[i][2]*fgkCarbonFiberJunctionWidth,0.);
    1398             :   }
    1399           6 :   for(Int_t i=0; i<fgkladdercablesnumber; i++)
    1400          20 :     for(Int_t j=0; j<klocalladdercombitransnumber-1; j++) 
    1401           8 :       fladdercablematrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
    1402             :   
    1403             :   ///////////////////////////////////////////
    1404             :   // Setting Ladder HMatrix
    1405             :   ///////////////////////////////////////////
    1406           1 :   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
    1407             :                                                                                                 fgkSSDLay6SensorsNumber};
    1408           6 :   for(Int_t i=0; i<fgkladdernumber; i++){
    1409           4 :         fladdermatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
    1410          98 :         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
    1411         141 :                 fladdermatrix[i][j] = new TGeoHMatrix();
    1412          47 :                 fladdermatrix[i][j]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
    1413          47 :                 fladdermatrix[i][j]->SetDy(fgkCarbonFiberJunctionWidth*j);
    1414          47 :                 fladdermatrix[i][j]->MultiplyLeft(ladderglobalmatrix[1][i]);
    1415             :         }
    1416             :   }
    1417             :   ///////////////////////////////////////////
    1418             :   // Setting SSD Sensor Matrix 
    1419             :   ///////////////////////////////////////////
    1420           1 :   TGeoCombiTrans* localssdsensorcombitrans[2];
    1421           2 :   TGeoRotation* localssdsensorrot = new TGeoRotation(); 
    1422           1 :   localssdsensorrot->SetAngles(0.,90.,0.);   
    1423           1 :   TGeoTranslation* localssdsensortrans[2];
    1424          10 :   for(Int_t i=0; i<2; i++) localssdsensortrans[i] = new TGeoTranslation();
    1425           2 :   localssdsensortrans[0]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
    1426           1 :                                          fgkCarbonFiberJunctionWidth 
    1427           1 :                                          - fgkCarbonFiberLowerSupportWidth 
    1428           1 :                                          - fgkLowerSupportToSensorZ,
    1429           1 :                                                         0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
    1430           1 :                                           -             fgkSSDModuleCoolingBlockToSensor
    1431           2 :                                           +    (fgkSSDSensorSideSupportHeight[1]
    1432           1 :                                           -             fgkSSDSensorSideSupportHeight[0]));
    1433           2 :   localssdsensortrans[1]->SetTranslation(0.5*fgkCarbonFiberTriangleLength,
    1434           1 :                                          fgkCarbonFiberJunctionWidth 
    1435           1 :                                          - fgkCarbonFiberLowerSupportWidth 
    1436           1 :                                          - fgkLowerSupportToSensorZ,
    1437           1 :                                                     0.5*fgkSSDSensorHeight-0.5*fgkCoolingTubeSupportHeight
    1438           1 :                                                         -fgkSSDModuleCoolingBlockToSensor);
    1439             : 
    1440           6 :   for(Int_t i=0; i<2; i++) 
    1441           6 :         localssdsensorcombitrans[i] = new TGeoCombiTrans(*localssdsensortrans[i],
    1442             :                                                                                                          *localssdsensorrot);   
    1443           6 :     for(Int_t i=0; i<fgkladdernumber; i++){
    1444           4 :         fssdsensormatrix[i] = new TGeoHMatrix*[ssdlaysensorsnumber[i]];
    1445          98 :         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
    1446          47 :                 switch(i){
    1447             :                         case 0: //Ladder of Layer5  
    1448          88 :                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
    1449          44 :                                                                    * ((j%2==0 ? *localssdsensorcombitrans[0] :
    1450          22 :                                                                                                 *localssdsensorcombitrans[1])));
    1451          22 :                         break;
    1452             :                         case 1: //Ladder of Layer6 
    1453         100 :                         fssdsensormatrix[i][j] = new TGeoHMatrix((*fladdermatrix[i][j])
    1454          50 :                                                                    * ((j%2==0 ? *localssdsensorcombitrans[1] :
    1455          25 :                                                                                                 *localssdsensorcombitrans[0])));
    1456          25 :                 break;
    1457             :                 }
    1458             :           }
    1459             :   }     
    1460             :   //////////////////////////
    1461             :   // Setting SSD End Ladder  
    1462             :   //////////////////////////
    1463           8 :   for(Int_t i=0; i<2; i++) fendladdersegmentmatrix[i] = new TGeoHMatrix*[2];
    1464           6 :   for(Int_t i=0; i<2; i++){
    1465           6 :         fendladdersegmentmatrix[0][i] = new TGeoHMatrix();
    1466           2 :         fendladdersegmentmatrix[0][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
    1467           2 :         fendladdersegmentmatrix[0][i]->SetDy(fgkCarbonFiberJunctionWidth*ssdlaysensorsnumber[i]);
    1468           2 :         fendladdersegmentmatrix[0][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
    1469           6 :         fendladdersegmentmatrix[1][i] = new TGeoHMatrix();
    1470           2 :         fendladdersegmentmatrix[1][i]->SetDx(-0.5*fgkCarbonFiberTriangleLength);
    1471           2 :         fendladdersegmentmatrix[1][i]->RotateZ(180.0);
    1472           2 :         fendladdersegmentmatrix[1][i]->MultiplyLeft(ladderglobalmatrix[1][i]);
    1473             :    }
    1474             :   /////////////////////////////////////////////////////
    1475             :   // Setting the CombiTransformation to pass ITS center 
    1476             :   /////////////////////////////////////////////////////
    1477           1 :   Double_t itscentertransz[fgklayernumber];
    1478           2 :   itscentertransz[0] = fgkSSDLay5LadderLength
    1479           1 :                                          - fgkLay5CenterITSPosition;
    1480           2 :   itscentertransz[1] = fgkSSDLay6LadderLength
    1481           1 :                                          - fgkLay6CenterITSPosition;
    1482           1 :   Double_t itssensortransy = fgkSSDModuleCoolingBlockToSensor
    1483           1 :                                                    + 0.5*fgkCoolingTubeSupportHeight;
    1484           1 :   TGeoRotation* itscenterrot[3];
    1485          10 :   for(Int_t i=0; i<fgklayernumber; i++) itscenterrot[i] = new TGeoRotation();
    1486           1 :   itscenterrot[0]->SetAngles(90.,180.,-90.);
    1487           1 :   itscenterrot[1]->SetAngles(0.,90.,0.);
    1488           4 :   itscenterrot[2] = new TGeoRotation((*itscenterrot[1])*(*itscenterrot[0]));
    1489           1 :   TGeoCombiTrans* itscentercombitrans[fgklayernumber];
    1490           6 :   for(Int_t i=0; i<fgklayernumber; i++) 
    1491           8 :         itscentercombitrans[i] = new TGeoCombiTrans(0.,
    1492             :                                                          itssensortransy,
    1493           2 :                                                          fgkEndLadderCarbonFiberLowerJunctionLength[1]
    1494           2 :                                                    - itscentertransz[i],itscenterrot[2]);
    1495           1 :   TGeoRotation** locallayerrot[fgklayernumber];
    1496           1 :   TGeoTranslation** locallayertrans[fgklayernumber];    
    1497           1 :   TGeoCombiTrans** locallayercombitrans[fgklayernumber];
    1498           1 :   TGeoTranslation* localbeamaxistrans[fgklayernumber];
    1499           4 :   localbeamaxistrans[0] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay5LadderLength
    1500           1 :                                          - fgkLay5CenterITSPosition);
    1501           4 :   localbeamaxistrans[1] = new TGeoTranslation(0.,0.,0.5*fgkSSDLay6LadderLength
    1502           1 :                                          - fgkLay6CenterITSPosition);
    1503             :   const Int_t kssdlayladdernumber[fgklayernumber] = 
    1504             :                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
    1505           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    1506           4 :     locallayerrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
    1507           4 :     locallayertrans[i] = new TGeoTranslation*[kssdlayladdernumber[i]];
    1508           4 :         locallayercombitrans[i] = new TGeoCombiTrans*[kssdlayladdernumber[i]];
    1509           4 :         flayermatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
    1510             :   }
    1511           1 :   Double_t layerladderangleposition[fgklayernumber] = 
    1512             :                 {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
    1513             :   Double_t layerradius = 0.;
    1514           6 :   for(Int_t i=0; i<fgklayernumber; i++){     
    1515         148 :         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
    1516         144 :                 switch(i){
    1517             :                         case 0: //Ladder of Layer5  
    1518          34 :                         layerradius = (j%2==0 ? fgkSSDLay5RadiusMin: fgkSSDLay5RadiusMax);
    1519          34 :                         break;
    1520             :                         case 1: //Ladder of Layer6 
    1521          38 :                         layerradius = (j%2==0 ? fgkSSDLay6RadiusMin: fgkSSDLay6RadiusMax);
    1522          38 :                 break;
    1523             :                 }
    1524         216 :                 locallayerrot[i][j] = new TGeoRotation();
    1525         216 :                 locallayertrans[i][j] = new TGeoTranslation();
    1526          72 :                 locallayerrot[i][j]->SetAngles(j*layerladderangleposition[i],0.,0.);
    1527         144 :                 locallayertrans[i][j]->SetTranslation(layerradius 
    1528         144 :                                                           *     CosD(90.0+j*layerladderangleposition[i]),
    1529             :                                                             layerradius 
    1530         144 :                                                           * SinD(90.0+j*layerladderangleposition[i]),0.);
    1531         288 :                 locallayercombitrans[i][j] = new TGeoCombiTrans(*locallayertrans[i][j],
    1532          72 :                                                                          *locallayerrot[i][j]);
    1533         288 :                 flayermatrix[i][j] = new TGeoHMatrix((*locallayercombitrans[i][j])*(*itscentercombitrans[i]));
    1534          72 :                 flayermatrix[i][j]->Multiply(ladderglobalmatrix[0][i]);
    1535          72 :                 flayermatrix[i][j]->MultiplyLeft(localbeamaxistrans[i]);
    1536             :         }
    1537             :   }
    1538             :   /////////////////////////////////////////////////////////////
    1539             :   // Deallocating memory
    1540             :   /////////////////////////////////////////////////////////////
    1541           8 :   for(Int_t i=0; i< kcarbonfibersupportmatrixnumber[1]; i++){
    1542           6 :         delete carbonfiberot[i];
    1543           6 :         delete localcarbonfibersupportmatrix[i];
    1544             :   }
    1545           8 :   for(Int_t i=0; i< fgkcarbonfiberjunctionumber; i++){
    1546          18 :      for(Int_t j=0; j< kcarbonfiberjunctionmatrixnumber; j++){
    1547          12 :        delete localcarbonfiberjunctionmatrix[i][j];
    1548          12 :            delete localcarbonfiberjunctionrot[i][j];
    1549          12 :            delete localcarbonfiberjunctiontrans[i][j];
    1550             :            }
    1551           6 :        delete [] localcarbonfiberjunctionmatrix[i];
    1552           6 :        delete [] localcarbonfiberjunctionrot[i];
    1553           6 :        delete [] localcarbonfiberjunctiontrans[i];
    1554             :   }
    1555           6 :   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++) 
    1556           4 :            delete localcarbonfiberlowersupportrans[i];
    1557           8 :   for(Int_t i=0; i< fgkssdsensorsupportnumber; i++){
    1558          24 :      for(Int_t j=0; j< kssdsensorsupportmatrixnumber; j++){
    1559          18 :        delete localssdsensorsupportmatrix[i][j];
    1560          18 :            delete localssdsensorsupportrot[i][j];
    1561          18 :            delete localssdsensorsupportrans[i][j];
    1562             :            }
    1563           6 :        delete [] localssdsensorsupportmatrix[i];
    1564           6 :        delete [] localssdsensorsupportrot[i];
    1565           6 :        delete [] localssdsensorsupportrans[i];
    1566             :   }
    1567           6 :   for(Int_t i=0; i<kcoolingtubesupportmatrixnumber; i++){
    1568           4 :         delete localcoolingtubesupportmatrix[i];
    1569           4 :         delete localcoolingtubesupportrot[i];
    1570           4 :         delete localcoolingtubesupportrans[i];
    1571             :   }
    1572           6 :   for(Int_t j=0; j<2; j++){
    1573           4 :     delete localcoolingtubevect[j];
    1574           4 :     delete localcoolingtubetrans[j];
    1575             :   }
    1576           2 :  delete endladdermountingblockrot;
    1577          14 :  for(Int_t i=0; i<khybridmatrixnumber; i++) delete localhybridtrans[i];
    1578           6 :  for(Int_t i=0; i<fgkflexnumber; i++){
    1579          16 :       for(Int_t j=1; j<klocalflexmatrixnumber; j++) 
    1580          12 :             delete localflexmatrix[i][j];
    1581           4 :       delete [] localflexmatrix[i];
    1582             :  }
    1583           2 :  delete localendlladdercoolingtuberot;
    1584           6 :  for(Int_t i=0; i<2; i++){
    1585          12 :         for(Int_t j=0; j<2; j++)
    1586           8 :           delete localendlladdercoolingtubetrans[i][j];
    1587           4 :         delete [] localendlladdercoolingtubetrans[i];
    1588             :   }
    1589             : 
    1590           2 :  delete localflexrot;
    1591           2 :  delete localendflexrot;
    1592           2 :  delete localendflexmatrix;
    1593           6 :  for(Int_t i=0; i<fgkladdernumber; i++){ 
    1594           4 :         delete localladdermothertrans[i];
    1595           4 :         delete localladdermothercombitrans[i];
    1596             :   }
    1597           2 :  delete localladdermotherrot;
    1598           6 :  for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){    
    1599          16 :       for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++){
    1600          12 :             delete localendladdercarbonfiberjunctionmatrix[i][j];
    1601          12 :             delete localendladdercarbonfiberjunctionrot[i][j];
    1602          12 :             delete localendladdercarbonfiberjunctiontrans[i][j];
    1603             :       }
    1604           4 :       delete [] localendladdercarbonfiberjunctionmatrix[i];
    1605           4 :       delete [] localendladdercarbonfiberjunctionrot[i];
    1606           4 :       delete [] localendladdercarbonfiberjunctiontrans[i];
    1607           4 :       delete localendladdercarbonfiberjunctionglobalrot[i];
    1608           4 :       delete localendladdercarbonfiberjunctionglobaltrans[i];
    1609           4 :       delete localendladdercarbonfiberjunctionglobalmatrix[i];
    1610             :  }
    1611           6 :   for(Int_t i=0; i<2; i++){
    1612          28 :         for(Int_t j=0; j<(i==0?4:2); j++) delete localendladdercooltubetrans[i][j];
    1613           4 :         delete [] localendladdercooltubetrans[i];
    1614             :   }
    1615           6 :   for(Int_t i=0; i<fgkendladdercarbonfibermatrixnumber; i++)
    1616           4 :       delete localendladdercarbonfibertrans[i];
    1617          14 :   for(Int_t i=0; i<3; i++) delete localladdercablerot[i];
    1618           6 :   for(Int_t i=0; i<klocalladdersidecablesnumber; i++){
    1619          44 :     for(Int_t j=0; j<klocalladdercombitransnumber; j++)delete localladdercablecombitransmatrix[i][j];
    1620           4 :     delete []localladdercablecombitransmatrix[i];
    1621             :   }
    1622           2 :   delete localendladdercliprot;
    1623           2 :   delete localendladdercliptrans;
    1624           6 :   for(Int_t i=0; i<fgkladdercablesnumber; i++){
    1625          12 :         for(Int_t j=0; j<klocalladdersidecablesnumber; j++)
    1626           8 :                 delete localladdercablehmatrix[i][j];
    1627           4 :         delete []localladdercablehmatrix[i];
    1628             :   }
    1629           2 :   delete laddercablerot;
    1630           2 :   delete laddercabletrans;
    1631           2 :   delete laddercablecombitrans;
    1632           2 :   delete localladdercablessdmodulematrix;
    1633           2 :   delete localssdsensorrot;     
    1634           6 :   for(Int_t i=0; i<2; i++){
    1635           4 :         delete localssdsensortrans[i];
    1636           4 :         delete localssdsensorcombitrans[i];
    1637             :   }
    1638           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    1639         148 :         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
    1640         144 :                 delete locallayerrot[i][j];
    1641         144 :                 delete locallayertrans[i][j];
    1642         144 :                 delete locallayercombitrans[i][j];
    1643             :     }
    1644           4 :         delete [] locallayerrot[i];
    1645           4 :         delete [] locallayertrans[i];
    1646           4 :         delete [] locallayercombitrans[i];
    1647           4 :         delete localbeamaxistrans[i];
    1648             :   }
    1649          14 :   for(Int_t i=0; i<3; i++) delete itscenterrot[i];
    1650           6 :   for(Int_t i=0; i<fgkladdernumber; i++){
    1651          12 :         for(Int_t j=0; j<fgkladdernumber; j++)
    1652           8 :                 delete ladderglobalmatrix[i][j];
    1653           4 :         delete [] ladderglobalmatrix[i];
    1654             :   }
    1655             :   /////////////////////////////////////////////////////////////
    1656           1 :   fTransformationMatrices = kTRUE;      
    1657           1 : }
    1658             : ///////////////////////////////////////////////////////////////////////////////
    1659             : void AliITSv11GeometrySSD::CreateBasicObjects(){
    1660             :   /////////////////////////////////////////////////////////////  
    1661             :   // Method generating the Objects of SSD Geometry    
    1662             :   /////////////////////////////////////////////////////////////
    1663             :   // SSD Sensor
    1664             :   ///////////////////////////////////
    1665           2 :   SetSSDSensor();
    1666             :   /////////////////////////////////////////////////////////////  
    1667             :   // Carbon Fiber Support    
    1668             :   /////////////////////////////////////////////////////////////  
    1669           1 :   TList* carbonfibersupportlist = GetCarbonFiberSupportList();  
    1670           6 :   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++) 
    1671           2 :       fcarbonfibersupport[i] = (TGeoVolume*)carbonfibersupportlist->At(i);
    1672             :   /////////////////////////////////////////////////////////////
    1673             :   // Carbon Fiber Junction 
    1674             :   /////////////////////////////////////////////////////////////
    1675           1 :   fcarbonfiberjunction = GetCarbonFiberJunction(fgkCarbonFiberJunctionWidth-fgkSSDTolerance);
    1676             :   /////////////////////////////////////////////////////////////
    1677             :   // Carbon Fiber Lower Support
    1678             :   /////////////////////////////////////////////////////////////
    1679           1 :   TList* carbonfiberlowersupportlist = GetCarbonFiberLowerSupportList();
    1680           6 :   for(Int_t i=0; i<fgkcarbonfiberlowersupportnumber; i++)
    1681           2 :         fcarbonfiberlowersupport[i] = (TGeoVolume*)carbonfiberlowersupportlist->At(i);
    1682             :   /////////////////////////////
    1683             :   // SSD Sensor Support
    1684             :   /////////////////////////////
    1685           6 :   for(Int_t i=0; i<fgkvolumekind; i++) fssdsensorsupport[i] = 
    1686           2 :                                                                                 new TGeoVolume*[fgkssdsensorsupportnumber]; 
    1687           2 :   Double_t sidesupporthickness[2] = {fgkSSDSensorSideSupportThickness[0],
    1688           1 :                                                                          fgkSSDSensorSideSupportThickness[1]};
    1689           6 :   for(Int_t i=0; i<fgkssdsensorsupportnumber-1; i++){
    1690           4 :         fssdsensorsupport[0][i] = GetSSDSensorSupport(fgkSSDSensorSideSupportLength,
    1691           2 :                                                                                            fgkSSDSensorSideSupportHeight[i],
    1692           2 :                                                                                            fgkSSDSensorSideSupportWidth,
    1693           2 :                                                                                            sidesupporthickness);  
    1694           4 :         fssdsensorsupport[1][i] = GetSSDSensorSupport(fgkSSDSensorCenterSupportLength,
    1695           2 :                                                                                            fgkSSDSensorCenterSupportHeight[i],
    1696           2 :                                                                                            fgkSSDSensorCenterSupportWidth,
    1697             :                                                                                            sidesupporthickness);
    1698             :   }
    1699             :   /////////////////////////////////////////////////////////////
    1700             :   // SSD Cooling Tube Support
    1701             :   /////////////////////////////////////////////////////////////
    1702             :   Int_t edgesnumber = 3;
    1703           1 :   fcoolingtubesupport = GetCoolingTubeSupport(edgesnumber);       
    1704             :   /////////////////////////////////////////////////////////////
    1705             :   // SSD Hybrid
    1706             :   /////////////////////////////////////////////////////////////
    1707           1 :   TList* ssdhybridcomponentslist = GetSSDHybridParts();
    1708           8 :   for(Int_t i=0; i<fgkhybridcompnumber; i++) 
    1709           3 :         fssdhybridcomponent[i] = (TGeoVolume*)ssdhybridcomponentslist->At(i);
    1710             :   /////////////////////////////////////////////////////////////
    1711             :   // SSD Cooling Block System
    1712             :   /////////////////////////////////////////////////////////////
    1713           1 :   fssdcoolingblocksystem = GetCoolingBlockSystem();
    1714             :    /////////////////////////////////////////////////////////////
    1715             :   // SSD Cooling Tube
    1716             :   /////////////////////////////////////////////////////////////
    1717           1 :   CreateCoolingTubes();
    1718             :   /////////////////////////////////////////////////////////////
    1719             :   // SSD Flex  
    1720             :   /////////////////////////////////////////////////////////////
    1721           1 :   fssdstiffenerflex = GetSSDStiffenerFlex();
    1722           1 :   fssdendflex = GetSSDEndFlex();
    1723             :   ///////////////////////////////////
    1724             :   // End Ladder Carbon Fiber Junction
    1725             :   ///////////////////////////////////
    1726           6 :   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++) 
    1727           2 :                                                    fendladdercarbonfiberjunction[i] = 
    1728           2 :                                                    new TGeoVolume*[fgkendlabbercarbonfiberjunctionumber];
    1729           6 :   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
    1730           2 :     fendladdercarbonfiberjunction[i][0] = 
    1731           2 :                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberLowerJunctionLength[i]-fgkSSDTolerance);
    1732           2 :     fendladdercarbonfiberjunction[i][1] = 
    1733           2 :                   GetCarbonFiberJunction(fgkEndLadderCarbonFiberUpperJunctionLength[i]-fgkSSDTolerance);
    1734             :   }
    1735             :   ///////////////////////////////////
    1736             :   // End Ladder Mounting Block
    1737             :   ///////////////////////////////////
    1738           1 :   fendladdermountingblock = GetSSDMountingBlock();
    1739             :   ///////////////////////////////////
    1740             :   // End Ladder Mounting Block
    1741             :   ///////////////////////////////////
    1742           1 :   fendladdermountingblockclip = GetMountingBlockClip();
    1743             :   ///////////////////////////////////
    1744             :   // Ladder Support 
    1745             :   ///////////////////////////////////
    1746           1 :   TList* laddersupportlist = GetMountingBlockSupport(20);
    1747           1 :   fLay5LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(0);
    1748           1 :   fLay5LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(1);
    1749           1 :   fLay6LadderSupport[0] = (TGeoVolume*)laddersupportlist->At(2);
    1750           1 :   fLay6LadderSupport[1] = (TGeoVolume*)laddersupportlist->At(3);
    1751             :   /////////////////////////////////////////////////////////////
    1752             :   // Deallocating memory
    1753             :   /////////////////////////////////////////////////////////////
    1754           2 :   delete carbonfibersupportlist;
    1755           2 :   delete carbonfiberlowersupportlist;
    1756           2 :   delete ssdhybridcomponentslist;
    1757           2 :   delete laddersupportlist;
    1758             :   /////////////////////////////////////////////////////////////
    1759           1 :   fBasicObjects = kTRUE;
    1760           1 : }
    1761             : /////////////////////////////////////////////////////////////////////////////////
    1762             : void AliITSv11GeometrySSD::SetSSDSensor(){
    1763             :   ////////////////////////////////////////////////////////////////
    1764             :   // Method generating SSD Sensors: it sets the private variables
    1765             :   // fSSDSensor5, fSSDSensor6  
    1766             :   ////////////////////////////////////////////////////////////////
    1767           2 :   Double_t ssdsensitivelength = fgkSSDSensorLength-2.*fgkSSDSensorInsensitiveLength;
    1768           1 :   Double_t ssdsensitivewidth  = fgkSSDSensorWidth-2.*fgkSSDSensorInsensitiveWidth;
    1769           2 :   TGeoBBox* ssdsensorsensitiveshape = new TGeoBBox("SSDSensorSensitiveShape",
    1770           1 :                                                 0.5*ssdsensitivewidth,
    1771           1 :                                                 0.5*fgkSSDSensorHeight,
    1772           1 :                                                 0.5*ssdsensitivelength);
    1773             :   TGeoVolume* ssdsensorsensitiveLay5 = 
    1774           1 :         new TGeoVolume(fgkSSDsensitiveVolName5,ssdsensorsensitiveshape,fSSDSensorMedium);
    1775             :   TGeoVolume* ssdsensorsensitiveLay6 = 
    1776           1 :         new TGeoVolume(fgkSSDsensitiveVolName6,ssdsensorsensitiveshape,fSSDSensorMedium);
    1777           1 :   ssdsensorsensitiveLay5->SetLineColor(fColorSilicon);
    1778           1 :   ssdsensorsensitiveLay6->SetLineColor(fColorSilicon);
    1779           1 :   TGeoBBox* ssdsensorinsensitiveshape[2];
    1780           3 :   ssdsensorinsensitiveshape[0] = new TGeoBBox("SSDSensorInsensitiveShape1",
    1781           1 :                                                 0.5*fgkSSDSensorInsensitiveWidth,
    1782           1 :                                                 0.5*fgkSSDSensorHeight,
    1783           1 :                                                 0.5*fgkSSDSensorLength);
    1784           3 :   ssdsensorinsensitiveshape[1] = new TGeoBBox("SSDSensorInsensitiveShape2",
    1785             :                                                 0.5*ssdsensitivewidth,
    1786           1 :                                                 0.5*fgkSSDSensorHeight,
    1787           1 :                                                 0.5*fgkSSDSensorInsensitiveWidth);
    1788           1 :   const char* ssdsensorinsensitivename[2] = {"SSDSensorInsensitive1",
    1789             :                                              "SSDSensorInsensitive2"};
    1790           1 :   TGeoVolume* ssdsensorinsensitive[2];
    1791           8 :   for(Int_t i=0; i<2; i++){ ssdsensorinsensitive[i] = 
    1792           4 :       new TGeoVolume(ssdsensorinsensitivename[i],ssdsensorinsensitiveshape[i],
    1793           2 :                      fSSDSensorMedium);
    1794           2 :       ssdsensorinsensitive[i]->SetLineColor(fColorCarbonFiber);
    1795             :   }
    1796             :   /////////////////////////////////////////////////////////////
    1797             :   // Virtual Volume containing SSD Sensor  
    1798             :   /////////////////////////////////////////////////////////////
    1799           2 :   TGeoBBox* virtualSSDSensorShape = new TGeoBBox("SSDSensorShape",
    1800           1 :                                                                                              0.5*fgkSSDSensorWidth,
    1801           1 :                                                                                              0.5*fgkSSDSensorHeight,
    1802           1 :                                                                                              0.5*fgkSSDSensorLength);
    1803           3 :   fSSDSensor5 = new TGeoVolume("ITSssdSensor5",virtualSSDSensorShape,
    1804           1 :                                                                                  fSSDAir);      
    1805           3 :   fSSDSensor6 = new TGeoVolume("ITSssdSensor6",virtualSSDSensorShape,
    1806           1 :                                                                                  fSSDAir);      
    1807             :   /////////////////////////////////////////////////////////////
    1808          10 :   for(Int_t i=0; i<4; i++){ 
    1809          12 :             fSSDSensor5->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
    1810           8 :             ssdsensorinsensitive[1],i<2?1:2,
    1811          12 :                         new TGeoTranslation(
    1812           4 :                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
    1813          12 :       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                    
    1814           4 :                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
    1815          12 :       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
    1816          12 :             fSSDSensor6->AddNode(i%2==0 ? ssdsensorinsensitive[0]:
    1817           4 :             ssdsensorinsensitive[1],i<2?1:2,
    1818          12 :                         new TGeoTranslation(
    1819           4 :                          0.5*(1.+TMath::Power(-1.,i))*(i==0?-1.: 1.)
    1820          12 :       *   (ssdsensorsensitiveshape->GetDX()+ssdsensorinsensitiveshape[0]->GetDX()),0.,                    
    1821           4 :                         0.5*(1.-TMath::Power(-1.,i))*(i==1? 1.:-1.)
    1822          12 :       *   (ssdsensorsensitiveshape->GetDZ()+ssdsensorinsensitiveshape[1]->GetDZ())));    
    1823             :   }
    1824           1 :     fSSDSensor5->AddNode(ssdsensorsensitiveLay5,1);
    1825           1 :     fSSDSensor6->AddNode(ssdsensorsensitiveLay6,1);
    1826           1 : }
    1827             : ///////////////////////////////////////////////////////////////////////////////
    1828             : TList* AliITSv11GeometrySSD::GetCarbonFiberSupportList(){
    1829             :   /////////////////////////////////////////////////////////////  
    1830             :   // Method generating the Carbon Fiber Support   
    1831             :   /////////////////////////////////////////////////////////////  
    1832             :   const Int_t kvertexnumber = 4;
    1833             :   const Int_t kshapesnumber = 2;
    1834           2 :   TVector3** vertexposition[kshapesnumber];
    1835           6 :   for(Int_t i=0; i<kshapesnumber; i++) vertexposition[i] = new TVector3*[kvertexnumber];
    1836             :   Double_t carbonfibersupportxaxisEdgeproj = 
    1837           2 :                 fgkCarbonFiberSupportEdgeLength*TMath::Cos(fgkCarbonFiberJunctionAngle[0]
    1838           1 :         *       TMath::DegToRad());
    1839           2 :   Double_t theta = TMath::ATan(fgkCarbonFiberSupportYAxisLength
    1840           1 :                                  /                         fgkCarbonFiberSupportXAxisLength);
    1841             :   /////////////////////
    1842             :   //Vertex Positioning
    1843             :   ////////////////////
    1844           2 :   vertexposition[0][0] = new TVector3();
    1845           3 :   vertexposition[0][1] = new TVector3(fgkCarbonFiberSupportXAxisLength,
    1846           1 :                                       fgkCarbonFiberSupportYAxisLength, 0);
    1847           3 :   vertexposition[0][2] = new TVector3(carbonfibersupportxaxisEdgeproj,
    1848             :                                                                           carbonfibersupportxaxisEdgeproj
    1849           1 :                                       *                   TMath::Tan(theta), 0);
    1850           3 :   vertexposition[0][3] = new TVector3(fgkCarbonFiberSupportXAxisLength
    1851           1 :                                            -                      carbonfibersupportxaxisEdgeproj,
    1852           1 :                                                                           fgkCarbonFiberSupportYAxisLength
    1853           1 :                                       - vertexposition[0][2]->Y(), 0);
    1854             :   ////////////////////////////////////////////////////
    1855             :   //Setting the parameters for Isometry Transformation
    1856             :   ////////////////////////////////////////////////////
    1857           1 :   Double_t symmetryplaneposition = (fgkCarbonFiberSupportYAxisLength
    1858           1 :                                                                  +      fgkCarbonFiberSupportTopEdgeDist[0]
    1859           1 :                                                                  +      fgkCarbonFiberSupportWidth);
    1860           1 :   Double_t* param = new Double_t[4]; 
    1861           1 :   param[0] = 0., param[1] = 1., param[2] = 0., param[3] = -symmetryplaneposition;
    1862          10 :   for(Int_t j=0; j<kvertexnumber; j++) vertexposition[1][j] = 
    1863          12 :     new TVector3((GetReflection(vertexposition[0][j],param))->X(),
    1864           8 :                  (GetReflection(vertexposition[0][j],param))->Y(), 0);
    1865           1 :   const char* carbonfibersupportshapename[kshapesnumber] = 
    1866             :                                                 {"CarbonFiberSupportShape1","CarbonFiberSupportShape2"};
    1867           1 :   const char* carbonfibersupportname[kshapesnumber] = 
    1868             :                                                 {"CarbonFiberSupport1","CarbonFiberSupport2"};
    1869           1 :   TGeoArb8* carbonfibersupportshape[kshapesnumber]; 
    1870           1 :   TGeoVolume* carbonfibersupport[kshapesnumber];
    1871           1 :   TList* carbonfibersupportlist = new TList();
    1872           1 :   Double_t width[2] = {fgkCarbonFiberSupportWidth,fgkCarbonFiberSupportWidth};
    1873             :   Double_t carbonfibersupportheight = 
    1874           1 :           carbonfibersupportxaxisEdgeproj*TMath::Tan(fgkCarbonFiberJunctionAngle[0]
    1875           1 :           *TMath::DegToRad());
    1876           6 :   for(Int_t i = 0; i< kshapesnumber; i++){
    1877           2 :    carbonfibersupportshape[i] = 
    1878           4 :                                         GetArbShape(vertexposition[i],width,carbonfibersupportheight,
    1879           2 :                                                                 carbonfibersupportshapename[i],i==0 ? 1: -1);
    1880           6 :    carbonfibersupport[i] = new TGeoVolume(carbonfibersupportname[i],
    1881           2 :                                                    carbonfibersupportshape[i],fSSDCarbonFiberMedium);
    1882           2 :    carbonfibersupport[i]->SetLineColor(fColorCarbonFiber);
    1883           2 :    carbonfibersupportlist->Add(carbonfibersupport[i]);       
    1884             :    }
    1885             :   /////////////////////////////////////////////////////////////
    1886             :   // Deallocating memory
    1887             :   /////////////////////////////////////////////////////////////
    1888           6 :   for(Int_t i=0; i< kshapesnumber; i++){
    1889          20 :      for(Int_t j=0; j< kvertexnumber; j++)
    1890          16 :            delete vertexposition[i][j];
    1891           4 :        delete [] vertexposition[i];
    1892             :   }
    1893           2 :   delete [] param;
    1894             :   /////////////////////////////////////////////////////////////
    1895           1 :    return carbonfibersupportlist;
    1896           1 : }
    1897             : /////////////////////////////////////////////////////////////////////////////////
    1898             : TGeoVolume* AliITSv11GeometrySSD::GetCarbonFiberJunction(Double_t width){
    1899             :   /////////////////////////////////////////////////////////////
    1900             :   // Method generating SSD Carbon Fiber Junction
    1901             :   /////////////////////////////////////////////////////////////
    1902             :   const Int_t kvertexnumber = 6;
    1903          10 :   TGeoXtru* carbonfiberjunctionshape = new TGeoXtru(2);
    1904          10 :   Double_t reflectionparam[4] = {TMath::Tan(fgkCarbonFiberJunctionAngle[0]
    1905           5 :                                             *  TMath::DegToRad()),-1.,0.,0.};
    1906           5 :   TVector3* vertex[kvertexnumber];
    1907          10 :   vertex[0] = new TVector3();
    1908          15 :   vertex[3] = new TVector3(fgkCarbonFiberJunctionEdge[0]
    1909           5 :                         *                         TMath::Cos(fgkCarbonFiberJunctionAngle[0]
    1910          10 :                         *                         TMath::DegToRad()),
    1911           5 :                                                   fgkCarbonFiberJunctionEdge[0]
    1912           5 :                         *                         TMath::Sin(fgkCarbonFiberJunctionAngle[0]
    1913          10 :                                         * TMath::DegToRad()), 0);
    1914          15 :   vertex[4] = new TVector3(fgkCarbonFiberJunctionLength-fgkSSDTolerance,
    1915           5 :                            fgkCarbonFiberJunctionEdge[1], 0);
    1916          10 :   vertex[5] = new TVector3(fgkCarbonFiberJunctionLength-fgkSSDTolerance, 0, 0); 
    1917           5 :   vertex[1] = GetReflection(vertex[5],reflectionparam); 
    1918           5 :   vertex[2] = GetReflection(vertex[4],reflectionparam); 
    1919           5 :   Double_t xvertexpoints[6], yvertexpoints[6];
    1920          70 :   for(Int_t i=0; i<kvertexnumber; i++) 
    1921          30 :           xvertexpoints[i] = vertex[i]->X(), yvertexpoints[i] = vertex[i]->Y();
    1922           5 :   carbonfiberjunctionshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
    1923           5 :   carbonfiberjunctionshape->DefineSection(0,-0.5*width);
    1924           5 :   carbonfiberjunctionshape->DefineSection(1,0.5*width);
    1925          10 :   TGeoVolume* carbonfiberjunction = new TGeoVolume("CarbonFiberJunction",
    1926           5 :                                                                 carbonfiberjunctionshape,fSSDCarbonFiberMedium);
    1927           5 :   carbonfiberjunction->SetLineColor(fColorCarbonFiber);
    1928             :   /////////////////////////////////////////////////////////////
    1929             :   // Deallocating memory
    1930             :   /////////////////////////////////////////////////////////////
    1931         130 :   for (Int_t i=0; i<kvertexnumber; i++) delete vertex[i];
    1932             :   ///////////////////////////////////////////////////////////// 
    1933           5 :   return carbonfiberjunction;
    1934           5 : }
    1935             : ////////////////////////////////////////////////////////////////////////////////
    1936             : TList* AliITSv11GeometrySSD::GetCarbonFiberLowerSupportList(){
    1937             :   /////////////////////////////////////////////////////////////
    1938             :   // Method generating the Carbon Fiber Lower Support   
    1939             :   /////////////////////////////////////////////////////////////  
    1940             :   const Int_t kvertexnumber = 4;
    1941             :   const Int_t kshapesnumber = 2;
    1942           3 :   Double_t width[2] = {fgkCarbonFiberLowerSupportWidth,
    1943           1 :                                                                 fgkCarbonFiberLowerSupportWidth};
    1944           1 :   TVector3** vertexposition[kshapesnumber];
    1945           6 :   for(Int_t i = 0; i<kshapesnumber; i++) vertexposition[i] = 
    1946           2 :                                                  new TVector3*[kvertexnumber];
    1947             :   //First Shape Vertex Positioning
    1948           2 :   vertexposition[0][0] = new TVector3(fgkCarbonFiberLowerSupportLowerLenght, 0, 0);
    1949           3 :   vertexposition[0][1] = new TVector3(fgkCarbonFiberTriangleLength
    1950           1 :                                       - fgkCarbonFiberLowerSupportLowerLenght, 0, 0);
    1951           2 :   vertexposition[0][2] = new TVector3();
    1952           2 :   vertexposition[0][3] = new TVector3(fgkCarbonFiberTriangleLength, 0, 0);
    1953             :   //Second Shape Vertex Positioning
    1954           2 :   Double_t theta = TMath::ATan((fgkCarbonFiberLowerSupportVolumePosition[1]
    1955           1 :                                  -                              fgkCarbonFiberLowerSupportVolumePosition[0])
    1956           1 :                                  /                              fgkCarbonFiberTriangleLength);
    1957           3 :   vertexposition[1][0] = new TVector3(vertexposition[0][0]->X(),
    1958           1 :                                                                 vertexposition[0][0]->X()*TMath::Tan(theta)
    1959           1 :                                       + fgkCarbonFiberLowerSupportVolumePosition[0], 0);
    1960           3 :   vertexposition[1][1] = new TVector3(vertexposition[0][1]->X(),
    1961           1 :                                                                 vertexposition[0][1]->X()*TMath::Tan(theta)
    1962           1 :                                       + fgkCarbonFiberLowerSupportVolumePosition[0], 0);
    1963           2 :   vertexposition[1][2] = new TVector3(0.,fgkCarbonFiberLowerSupportVolumePosition[0], 0);
    1964           3 :   vertexposition[1][3] = new TVector3(fgkCarbonFiberTriangleLength,
    1965           1 :                                       fgkCarbonFiberLowerSupportVolumePosition[1], 0);
    1966           1 :   const char* carbonfiberlowersupportshapename[kshapesnumber] = 
    1967             :                           {"CarbonFiberLowerSupportShape1","CarbonFiberLowerSupportShape2"};
    1968           1 :   const char* carbonfiberlowersupportname[kshapesnumber] = 
    1969             :                           {"CarbonFiberLowerSupport1","CarbonFiberLowerSupport2"};
    1970           1 :   TGeoArb8* carbonfiberlowersupportshape[kshapesnumber];
    1971           1 :   TGeoVolume* carbonfiberlowersupport[kshapesnumber];
    1972           1 :   TList* carbonfiberlowersupportlist = new TList();
    1973           6 :   for(Int_t i = 0; i< kshapesnumber; i++){ 
    1974           2 :         carbonfiberlowersupportshape[i] = 
    1975           4 :                                                                 GetArbShape(vertexposition[i],width,
    1976           2 :                                                                                         fgkCarbonFiberLowerSupportHeight,
    1977           2 :                                                                                         carbonfiberlowersupportshapename[i]);
    1978           6 :     carbonfiberlowersupport[i] = new TGeoVolume(carbonfiberlowersupportname[i],
    1979           2 :                                                 carbonfiberlowersupportshape[i],fSSDCarbonFiberMedium);
    1980           2 :         carbonfiberlowersupport[i]->SetLineColor(fColorCarbonFiber);
    1981           2 :     carbonfiberlowersupportlist->Add(carbonfiberlowersupport[i]);
    1982             :   }
    1983             :   /////////////////////////////////////////////////////////////
    1984             :   // Deallocating memory
    1985             :   /////////////////////////////////////////////////////////////
    1986           6 :   for(Int_t i=0; i< kshapesnumber; i++){
    1987          20 :      for(Int_t j=0; j< kvertexnumber; j++)
    1988          16 :            delete vertexposition[i][j];
    1989           4 :        delete [] vertexposition[i];
    1990             :   }
    1991             :   /////////////////////////////////////////////////////////////
    1992           1 :   return carbonfiberlowersupportlist;
    1993           1 : }
    1994             : ///////////////////////////////////////////////////////////////////////////////
    1995             : TGeoVolume* AliITSv11GeometrySSD::GetSSDSensorSupport(Double_t length, Double_t height, 
    1996             :                                                                  Double_t width, const Double_t* thickness)const{
    1997             :   /////////////////////////////////////////////////////////////
    1998             :   // Method generating the Sensor Support   
    1999             :   /////////////////////////////////////////////////////////////  
    2000             :         const Int_t kvertexnumber = 6;
    2001           8 :         TGeoXtru* ssdsensorsupportshape = new TGeoXtru(2);      
    2002           4 :     TVector3* vertexposition[kvertexnumber];
    2003           8 :         vertexposition[0] = new TVector3();     
    2004           8 :         vertexposition[1] = new TVector3(0.0,length,0); 
    2005           8 :         vertexposition[2] = new TVector3(thickness[1],vertexposition[1]->Y(),0);     
    2006           8 :         vertexposition[3] = new TVector3(vertexposition[2]->X(),thickness[0],0);     
    2007           8 :         vertexposition[4] = new TVector3(height,vertexposition[3]->Y(),0);   
    2008           8 :         vertexposition[5] = new TVector3(vertexposition[4]->X(),0,0);        
    2009           4 :         Double_t xvertexpoints[6], yvertexpoints[6];
    2010          56 :         for(Int_t i=0; i<kvertexnumber; i++) 
    2011          24 :                 xvertexpoints[i] = vertexposition[i]->X(), 
    2012          24 :                 yvertexpoints[i] = vertexposition[i]->Y();
    2013           4 :     ssdsensorsupportshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
    2014           4 :     ssdsensorsupportshape->DefineSection(0,-0.5*width);
    2015           4 :     ssdsensorsupportshape->DefineSection(1,0.5*width);
    2016           8 :     TGeoVolume* ssdsensorsupport = new TGeoVolume("SSDSensorSupport",
    2017           4 :                                                                  ssdsensorsupportshape,fSSDSensorSupportMedium);
    2018             :   /////////////////////////////////////////////////////////////
    2019             :   // Deallocating memory
    2020             :   /////////////////////////////////////////////////////////////
    2021          56 :         for (Int_t i=0; i<kvertexnumber; i++)
    2022          48 :                 delete vertexposition[i];
    2023             :   /////////////////////////////////////////////////////////////
    2024           4 :     return ssdsensorsupport;
    2025           4 : }
    2026             : ////////////////////////////////////////////////////////////////////////////////
    2027             : TGeoVolume* AliITSv11GeometrySSD::GetCoolingTubeSupport(Int_t nedges){
    2028             :   /////////////////////////////////////////////////////////////
    2029             :   // Method generating the Cooling Tube Support
    2030             :   /////////////////////////////////////////////////////////////
    2031           3 :   if(nedges%2!=0) nedges--;     
    2032           1 :   const Int_t kvertexnumber = nedges+5;
    2033           2 :   Double_t phi = TMath::ASin(0.5*fgkCoolingTubeSupportHeight
    2034           2 :                            /                     fgkCoolingTubeSupportRmax)*TMath::RadToDeg();
    2035           1 :   Double_t angle = 90.+phi;
    2036           1 :   Double_t psi = 90.-phi;
    2037             :   ///////////////////////////////////////
    2038             :   // Vertex Positioning for TGeoXTru
    2039             :   ///////////////////////////////////////
    2040           1 :   TVector3** vertexposition = new TVector3*[kvertexnumber];
    2041             : 
    2042           1 :   Double_t router = fgkCoolingTubeSupportRmin/CosD(phi/nedges);  //  Recalc inner radius so that tube fits inside  
    2043           4 :   vertexposition[0] = new TVector3(router*CosD(angle),
    2044           2 :                                    router*SinD(angle), 0);
    2045           4 :   vertexposition[1] = new TVector3(fgkCoolingTubeSupportRmax*CosD(angle),
    2046           2 :                                    fgkCoolingTubeSupportRmax*SinD(angle),0);
    2047           3 :   vertexposition[2] = new TVector3(vertexposition[1]->X(),
    2048           1 :                                    fgkCoolingTubeSupportRmax, 0);
    2049           3 :   vertexposition[3] = new TVector3(-vertexposition[1]->X(),
    2050           1 :                                    fgkCoolingTubeSupportRmax, 0);
    2051           3 :   vertexposition[4] = new TVector3(-vertexposition[1]->X(),
    2052           1 :                                    vertexposition[1]->Y(), 0);
    2053             : 
    2054           6 :   for(Int_t i=0; i<nedges; i++)
    2055           2 :         vertexposition[i+5] = 
    2056           6 :                 new TVector3(router*CosD(psi+i*(2.*phi/nedges)),
    2057           4 :                              router*SinD(psi+i*(2.*phi/nedges)), 0);
    2058             :   ///////////////////////////////////////////////////////////////////////
    2059             :   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
    2060             :   ///////////////////////////////////////////////////////////////////////
    2061           1 :   TGeoXtru* coolingtubesupportarcshape = new TGeoXtru(2);       
    2062           1 :   Double_t* xvertexpoints = new Double_t[kvertexnumber];        
    2063           1 :   Double_t* yvertexpoints = new Double_t[kvertexnumber];        
    2064          16 :   for(Int_t i=0; i<kvertexnumber; i++){
    2065           7 :         xvertexpoints[i] = vertexposition[i]->X();
    2066           7 :         yvertexpoints[i] = vertexposition[i]->Y();
    2067             :   } 
    2068           1 :   coolingtubesupportarcshape->DefinePolygon(kvertexnumber,xvertexpoints,
    2069             :                                                                                         yvertexpoints);
    2070           1 :   coolingtubesupportarcshape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
    2071           1 :   coolingtubesupportarcshape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
    2072           2 :   TGeoVolume* coolingtubesupportarc = new TGeoVolume("CoolingTubeSupportArc",
    2073           1 :                                                                           coolingtubesupportarcshape,
    2074           1 :                                                                                   fSSDTubeHolderMedium);
    2075           1 :   coolingtubesupportarc->SetLineColor(fColorG10);
    2076             :   //////////////////////////////////////////////////////////////////////////
    2077             :   // TGeoTubeSeg Volume definition for Cooling Tube Support TGeoTubeSeg Part
    2078             :   //////////////////////////////////////////////////////////////////////////
    2079             :   TGeoTubeSeg* coolingtubesupportsegshape = 
    2080           2 :                                                         new TGeoTubeSeg(fgkCoolingTubeSupportRmin,
    2081           1 :                                                                                         fgkCoolingTubeSupportRmax,
    2082           1 :                                                                                         0.5*fgkCoolingTubeSupportWidth,
    2083           1 :                                                                                         phi,360-phi);
    2084           2 :   TGeoVolume* coolingtubesupportseg = new TGeoVolume("CoolingTubeSupportSeg",
    2085           1 :                                                                                         coolingtubesupportsegshape,
    2086           1 :                                                                                         fSSDTubeHolderMedium);
    2087           1 :   coolingtubesupportseg->SetLineColor(fColorG10);
    2088             :   //////////////////////////////////////////////////////////////////////////
    2089             :   // TGeoBBox Volume definition for Cooling Tube Support Box Part
    2090             :   //////////////////////////////////////////////////////////////////////////
    2091           1 :   Double_t* boxorigin = new Double_t[3];
    2092           1 :   Double_t boxlength = fgkCoolingTubeSupportLength-2.*fgkCoolingTubeSupportRmax;
    2093           1 :   boxorigin[0] = fgkCoolingTubeSupportRmax+0.5*boxlength, boxorigin[1] = boxorigin[2] = 0.;
    2094           2 :   TGeoBBox* coolingtubesupportboxshape = new TGeoBBox(0.5*boxlength,
    2095           1 :                                                                                  0.5*fgkCoolingTubeSupportHeight,
    2096           1 :                                                                                  0.5*fgkCoolingTubeSupportWidth,boxorigin);
    2097           2 :   TGeoVolume* coolingtubesupportbox = new TGeoVolume("CoolingTubeSupportBox",
    2098           1 :                                coolingtubesupportboxshape,fSSDTubeHolderMedium);
    2099           1 :   coolingtubesupportbox->SetLineColor(fColorG10);
    2100             :   //////////////////////////////////////////////////////////////////////////
    2101             :   // Cooling Tube for Cooling Tube Support 
    2102             :   //////////////////////////////////////////////////////////////////////////
    2103             :   TGeoXtru* coolingtubearcshape[2];
    2104           1 :   coolingtubearcshape[0] = new TGeoXtru(2);     
    2105           1 :   Double_t* xvert = new Double_t[nedges+2];
    2106           1 :   Double_t* yvert = new Double_t[nedges+2];
    2107           1 :   Double_t ratio = fgkCoolingTubeRmin/fgkCoolingTubeSupportRmin;
    2108             :   ////////////////////////////////////////
    2109             :   // Positioning the vertices for TGeoXTru
    2110             :   ////////////////////////////////////////
    2111           1 :   xvert[0] = 0., yvert[0] = 0.;
    2112           1 :   xvert[1] = vertexposition[0]->X()*ratio,  yvert[1] = vertexposition[0]->Y()*ratio;
    2113           6 :   for(Int_t i=0; i< nedges; i++)
    2114           2 :                 xvert[i+2] = vertexposition[kvertexnumber-i-1]->X()*ratio,
    2115           2 :                 yvert[i+2] = vertexposition[kvertexnumber-i-1]->Y()*ratio;
    2116             :   ////////////////////////////////////////
    2117             :   // Defining TGeoXTru PolyGone
    2118             :   ////////////////////////////////////////
    2119           1 :   coolingtubearcshape[0]->DefinePolygon(nedges+2,xvert,yvert);
    2120           1 :   coolingtubearcshape[0]->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
    2121           1 :   coolingtubearcshape[0]->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
    2122           2 :   coolingtubearcshape[1] = GetArcShape(2.*phi,fgkCoolingTubeRmin,
    2123           1 :                 fgkCoolingTubeRmax,nedges,fgkCoolingTubeSupportWidth);
    2124             :   TGeoVolume* coolingtubearc[2];
    2125           2 :   coolingtubearc[0] = new TGeoVolume("CoolingTubeWaterArcPart",
    2126           1 :                                                                   coolingtubearcshape[0],fSSDCoolingTubeWater);
    2127           2 :   coolingtubearc[1] = new TGeoVolume("CoolingTubePhynoxArcPart",
    2128           1 :                                                                   coolingtubearcshape[1],fSSDCoolingTubePhynox);
    2129           1 :   coolingtubearc[0]->SetLineColor(fColorWater);
    2130           1 :   coolingtubearc[1]->SetLineColor(fColorPhynox);
    2131             :   ////////////////////////////////////////////
    2132             :   // Defining TGeoTubeSeg Part of Cooling Tube
    2133             :   ////////////////////////////////////////////
    2134             :   TGeoTubeSeg* coolingtubesegshape[2];
    2135           2 :   coolingtubesegshape[0] = new TGeoTubeSeg(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
    2136           1 :                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
    2137           2 :   coolingtubesegshape[1] = new TGeoTubeSeg(0.,fgkCoolingTubeRmin,
    2138           1 :                                                         0.5*fgkCoolingTubeSupportWidth,phi,360-phi);
    2139             :   TGeoVolume* coolingtubeseg[2];
    2140           2 :   coolingtubeseg[0] = new TGeoVolume("CoolingTubePhynoxPart",
    2141           1 :                                                                  coolingtubesegshape[0],fSSDCoolingTubePhynox);
    2142           2 :   coolingtubeseg[1] = new TGeoVolume("CoolingTubeWaterPart",
    2143           1 :                                                                  coolingtubesegshape[1],fSSDCoolingTubeWater);
    2144           1 :   coolingtubeseg[0]->SetLineColor(fColorPhynox);
    2145           1 :   coolingtubeseg[1]->SetLineColor(fColorWater);
    2146             :   /////////////////////////////////////////////////////////////
    2147             :   // Virtual Volume containing Cooling Tube Support  
    2148             :   /////////////////////////////////////////////////////////////
    2149           1 :   TGeoXtru* virtualCoolingTubeSupportShape = new TGeoXtru(2);
    2150             :   const Int_t kvirtualvertexnumber = 8;
    2151           1 :   TVector3* virtualvertex[kvirtualvertexnumber];
    2152             :    ////////////////////////////////////////
    2153             :   // Positioning the vertices for TGeoXTru
    2154             :   ////////////////////////////////////////
    2155           2 :   virtualvertex[0] = new TVector3(-fgkCoolingTubeSupportRmax,-fgkCoolingTubeSupportRmax, 0); 
    2156           2 :   virtualvertex[1] = new TVector3(virtualvertex[0]->X(),-virtualvertex[0]->Y(),0);
    2157           2 :   virtualvertex[2] = new TVector3(-virtualvertex[0]->X(),virtualvertex[1]->Y(),0);
    2158           2 :   virtualvertex[3] = new TVector3(virtualvertex[2]->X(),0.5*fgkCoolingTubeSupportHeight,0);
    2159           2 :   virtualvertex[4] = new TVector3(virtualvertex[3]->X()+boxlength,virtualvertex[3]->Y(),0);
    2160           2 :   virtualvertex[5] = new TVector3(virtualvertex[4]->X(),-virtualvertex[4]->Y(),0);
    2161           2 :   virtualvertex[6] = new TVector3(virtualvertex[3]->X(),-virtualvertex[3]->Y(),0);
    2162           2 :   virtualvertex[7] = new TVector3(virtualvertex[2]->X(),-virtualvertex[2]->Y(),0);
    2163           1 :   Double_t xmothervertex[kvirtualvertexnumber], ymothervertex[kvirtualvertexnumber];
    2164          18 :   for(Int_t i=0; i< kvirtualvertexnumber; i++)
    2165           8 :         xmothervertex[i] = virtualvertex[i]->X(),
    2166           8 :         ymothervertex[i] = virtualvertex[i]->Y();
    2167             :   ////////////////////////////////////////
    2168             :   // Defining TGeoXTru PolyGone
    2169             :   ////////////////////////////////////////
    2170           2 :   virtualCoolingTubeSupportShape->DefinePolygon(kvirtualvertexnumber,xmothervertex,
    2171           1 :                                                                                                                                          ymothervertex);
    2172           1 :   virtualCoolingTubeSupportShape->DefineSection(0,-0.5*fgkCoolingTubeSupportWidth);
    2173           1 :   virtualCoolingTubeSupportShape->DefineSection(1,0.5*fgkCoolingTubeSupportWidth);
    2174             :   /*TGeoVolume* virtualcoolingtubesupport = new TGeoVolume("CoolingTubeSupport",
    2175             :     virtualCoolingTubeSupportShape,fSSDAir); */
    2176           2 :   TGeoVolume* virtualcoolingtubesupport = new TGeoVolumeAssembly("CoolingTubeSupport");
    2177             : 
    2178             :   ////////////////////////////////////////
    2179             :   // Positioning Volumes in Virtual Volume
    2180             :   ////////////////////////////////////////
    2181           1 :   TGeoRotation* coolingtubesupportrot = new TGeoRotation(); 
    2182           1 :   coolingtubesupportrot->SetAngles(-90.0,0.0,0.0);
    2183           1 :   virtualcoolingtubesupport->AddNode(coolingtubesupportarc,1,coolingtubesupportrot);
    2184           1 :   virtualcoolingtubesupport->AddNode(coolingtubesupportbox,1);
    2185           1 :   virtualcoolingtubesupport->AddNode(coolingtubesupportseg,1);
    2186             :   //virtualcoolingtubesupport->AddNode(coolingtubearc[0],1,coolingtubesupportrot);
    2187             :   //virtualcoolingtubesupport->AddNode(coolingtubearc[1],1,coolingtubesupportrot);
    2188             :   //virtualcoolingtubesupport->AddNode(coolingtubeseg[0],1);
    2189             :   //virtualcoolingtubesupport->AddNode(coolingtubeseg[1],1);
    2190             :   /////////////////////////////////////////////////////////////
    2191             :   // Deallocating memory
    2192             :   /////////////////////////////////////////////////////////////
    2193           2 :   delete [] vertexposition;
    2194           2 :   delete [] xvertexpoints;
    2195           2 :   delete [] yvertexpoints;
    2196           2 :   delete [] xvert;
    2197           2 :   delete [] yvert;
    2198          18 :   for(Int_t i=0; i< kvirtualvertexnumber; i++)
    2199          16 :         delete virtualvertex[i];
    2200             :   /////////////////////////////////////////////////////////////
    2201             : 
    2202           1 :   virtualcoolingtubesupport->GetShape()->ComputeBBox(); //RS: enforce recompting of BBox
    2203           1 :   return virtualcoolingtubesupport;
    2204           1 : }
    2205             : /////////////////////////////////////////////////////////////////////////////////
    2206             : TList* AliITSv11GeometrySSD::GetSSDHybridParts(){
    2207             :   /////////////////////////////////////////////////////////////
    2208             :   // Method generating List containing SSD Hybrid Components   
    2209             :   /////////////////////////////////////////////////////////////
    2210           2 :   TList* ssdhybridlist = new TList();
    2211             :   const Int_t kssdstiffenernumber = 2;
    2212           1 :   Double_t ssdstiffenerseparation = fgkSSDSensorLength
    2213           1 :                                                                   - 2.*fgkSSDModuleStiffenerPosition[1]
    2214           1 :                                                                   -    fgkSSDStiffenerWidth;
    2215           1 :   Double_t ssdchipcablesradius[kssdstiffenernumber];
    2216           6 :   for(Int_t i=0; i<kssdstiffenernumber; i++)
    2217           4 :           ssdchipcablesradius[i] = 0.25*(fgkSSDChipCablesHeight[i+2]
    2218           2 :                                -  fgkSSDChipCablesHeight[0]
    2219           2 :                                -  fgkSSDChipCablesHeight[1]);
    2220             :   /////////////////////////////////////////////////////////////
    2221             :   // Mother Volumes Containers 
    2222             :   /////////////////////////////////////////////////////////////
    2223             :   const Int_t kmothernumber = 2;
    2224             :   const Int_t kmothervertexnumber = 8;
    2225           1 :   Double_t xmothervertex[kmothernumber][kmothervertexnumber]; 
    2226           1 :   Double_t ymothervertex[kmothernumber][kmothervertexnumber]; 
    2227             : 
    2228           1 :   TGeoVolumeAssembly* ssdhybridassembly[kmothernumber];
    2229           1 :   TGeoVolume* ssdhybridmother[kmothernumber][2];
    2230             : 
    2231           6 :   TGeoRotation hybridmotherrotR(TGeoRotation("",-90.0,0.0,0.0)*TGeoRotation("",0.0,90.0,0.0)*TGeoRotation("",90.,180.,-90));
    2232           4 :   TGeoRotation hybridmotherrotL(TGeoRotation("",180.,0.0,0.0)*hybridmotherrotR);
    2233           3 :   TGeoRotation *hybridmotherrotInv = new TGeoRotation(hybridmotherrotR.Inverse());
    2234             : 
    2235           1 :   const char* ssdhybridmothername[kmothernumber] = {"SSDHybridMother1","SSDHybridMother2"};
    2236           6 :   for(Int_t i=0; i<kmothernumber; i++){
    2237           2 :     xmothervertex[i][0] = -0.5*fgkSSDStiffenerWidth;
    2238           2 :     ymothervertex[i][0] = 0.5*fgkSSDStiffenerHeight;
    2239           2 :     xmothervertex[i][1] = -0.5*fgkSSDStiffenerWidth;
    2240           4 :     ymothervertex[i][1] = -0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight      
    2241           2 :       -fgkSSDChipCablesHeight[i+2];
    2242             :     
    2243           2 :     xmothervertex[i][2] = 0.5*(fgkSSDSensorLength-ssdstiffenerseparation); //0.5*fgkSSDStiffenerWidth;
    2244           2 :     ymothervertex[i][2] = -0.5*fgkSSDStiffenerHeight-fgkSSDChipHeight -fgkSSDChipCablesHeight[i+2];
    2245           2 :     xmothervertex[i][3] = xmothervertex[i][2];
    2246           2 :     ymothervertex[i][3] = ymothervertex[i][2]+fgkSSDChipCablesHeight[0]+fgkSSDChipCablesHeight[1]+fgkSSDTolerance;
    2247             : 
    2248           2 :     xmothervertex[i][4] = xmothervertex[i][2]-0.4;  
    2249           2 :     ymothervertex[i][4] = ymothervertex[i][3];
    2250           2 :     xmothervertex[i][5] = xmothervertex[i][4];
    2251           2 :     ymothervertex[i][5] = ymothervertex[i][4]+2*ssdchipcablesradius[i]-fgkSSDTolerance;
    2252             : 
    2253           2 :     xmothervertex[i][6] = 0.5*fgkSSDStiffenerWidth+ssdchipcablesradius[i]+0.3*fgkmm;
    2254           2 :     ymothervertex[i][6] = ymothervertex[i][5];
    2255             :     
    2256           2 :     xmothervertex[i][7] = xmothervertex[i][6];
    2257           2 :     ymothervertex[i][7] = 0.5*fgkSSDStiffenerHeight;
    2258           4 :     TGeoXtru *shape = new TGeoXtru(2);
    2259           2 :     shape->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
    2260           2 :     shape->DefineSection(0,-0.5*fgkSSDStiffenerLength);
    2261           2 :     shape->DefineSection(1,0.5*fgkSSDStiffenerLength);
    2262          12 :     ssdhybridmother[i][0] = new TGeoVolume(TString(ssdhybridmothername[i])+"L",shape,fSSDAir);
    2263          12 :     ssdhybridmother[i][1] = new TGeoVolume(TString(ssdhybridmothername[i])+"R",shape,fSSDAir);
    2264           6 :     ssdhybridassembly[i] = new TGeoVolumeAssembly(ssdhybridmothername[i]);
    2265             :    }   
    2266             :   /////////////////////////////////////////////////////////////
    2267             :   // SSD Stiffener   
    2268             :   /////////////////////////////////////////////////////////////
    2269           3 :   TGeoBBox* ssdstiffenershape = new TGeoBBox("SSDStiffenerShape",
    2270           1 :                                              0.5*fgkSSDStiffenerLength,
    2271           1 :                                              0.5*(fgkSSDStiffenerWidth-fgkSSDTolerance),
    2272           1 :                                              0.5*fgkSSDStiffenerHeight);
    2273           3 :   TGeoVolume* ssdstiffener = new TGeoVolume("SSDStiffener",ssdstiffenershape,
    2274           1 :                                             fSSDStiffenerMedium);  
    2275           1 :   ssdstiffener->SetLineColor(fColorStiffener); 
    2276             : 
    2277             : ////////////////////////////
    2278             : // Capacitor 0603-2200 nF
    2279             : ///////////////////////////
    2280             :   const Int_t knapacitor0603number = 5;
    2281           3 :   TGeoBBox* capacitor0603mothershape =  new TGeoBBox("Capacitor0603MotherShape",
    2282           1 :                                                0.5*fgkSSDCapacitor0603Length + fgkSSDCapacitor0603CapLength,
    2283           1 :                                                0.5*fgkSSDCapacitor0603Width,
    2284           1 :                                                0.5*fgkSSDCapacitor0603Height);
    2285           3 :   TGeoVolume* capacitor0603mother = new TGeoVolume("Capacitor0603Mother",capacitor0603mothershape,
    2286           1 :                                              fSSDAir); 
    2287             : 
    2288           3 :   TGeoBBox* capacitor0603shape =  new TGeoBBox("Capacitor0603Shape",
    2289           1 :                                                0.5*fgkSSDCapacitor0603Length,
    2290           1 :                                                0.5*fgkSSDCapacitor0603Width,
    2291           1 :                                                0.5*fgkSSDCapacitor0603Height);
    2292           3 :   TGeoVolume* capacitor0603 = new TGeoVolume("Capacitor0603",capacitor0603shape,
    2293           1 :                                              fSSDStiffener0603CapacitorMedium); 
    2294           1 :   capacitor0603->SetLineColor(fColorAl);
    2295           2 :   TGeoTranslation *cap0603trans = new TGeoTranslation(0.,0.,0.);
    2296           1 :   capacitor0603mother->AddNode(capacitor0603,1,cap0603trans);
    2297             : 
    2298           3 :   TGeoBBox* capacitor0603capshape =  new TGeoBBox("Capacitor0603CapShape",
    2299           1 :                                                0.5*fgkSSDCapacitor0603CapLength,
    2300           1 :                                                0.5*fgkSSDCapacitor0603Width,
    2301           1 :                                                0.5*fgkSSDCapacitor0603Height);
    2302           3 :   TGeoVolume* capacitor0603cap = new TGeoVolume("Capacitor0603Cap",capacitor0603capshape,
    2303           1 :                                              fSSDStiffenerCapacitorCapMedium); 
    2304           1 :   capacitor0603cap->SetLineColor(fColorNiSn);
    2305           4 :   TGeoTranslation *cap0603captrans1 = new TGeoTranslation(- capacitor0603shape->GetDX() - capacitor0603capshape->GetDX(),0.,0.);
    2306           1 :   capacitor0603mother->AddNode(capacitor0603cap,1,cap0603captrans1);
    2307           4 :   TGeoTranslation *cap0603captrans2 = new TGeoTranslation(capacitor0603shape->GetDX() + capacitor0603capshape->GetDX(),0.,0.);
    2308           1 :   capacitor0603mother->AddNode(capacitor0603cap,2,cap0603captrans2);
    2309             : 
    2310             : 
    2311           1 :   TGeoVolume* ssdchip = GetSSDChip();
    2312             : 
    2313             :   const Int_t knedges = 5;
    2314           1 :   TGeoVolume *ssdchipcables[2];
    2315             : 
    2316           6 :   for(Int_t i=0; i<kmothernumber; i++){
    2317          12 :     for(Int_t j=0; j<kssdstiffenernumber; j++){
    2318           4 :       ssdhybridmother[i][j]->AddNode(ssdstiffener,1,hybridmotherrotInv);
    2319          48 :       for(Int_t k=1; k<knapacitor0603number+1; k++){
    2320          40 :         ssdhybridmother[i][j]->AddNode(capacitor0603mother,k,
    2321          80 :                                        new TGeoCombiTrans("",
    2322          20 :                                                           -0.5*(fgkSSDStiffenerWidth - fgkSSDCapacitor0603Width),
    2323          20 :                                                           -0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor0603Height),
    2324          20 :                                                           (k-3.)/6*fgkSSDStiffenerLength,
    2325             :                                                           hybridmotherrotInv));
    2326             :       }
    2327             :     }
    2328             :     
    2329           2 :     GetSSDChipCables(ssdchipcables[0],ssdchipcables[1],fgkSSDChipCablesHeight[i+2],knedges);
    2330          28 :     for(Int_t k=0; k<fgkSSDChipNumber; k++){
    2331          36 :       TGeoTranslation *chipcabletrans = new TGeoTranslation("",0.5*fgkSSDStiffenerWidth-fgkSSDChipWidth,
    2332          12 :                                                             - 0.5*fgkSSDStiffenerHeight - fgkSSDChipHeight
    2333          12 :                                                             - fgkSSDChipCablesHeight[i+2],
    2334          24 :                                                             (k+0.5-fgkSSDChipNumber/2)*
    2335          12 :                                                             (fgkSSDChipLength + fgkSSDChipSeparationLength));
    2336          36 :       TGeoCombiTrans *chiptrans = new TGeoCombiTrans("",0.5*(fgkSSDStiffenerWidth-fgkSSDChipWidth),
    2337          12 :                                                      - 0.5*(fgkSSDChipHeight+fgkSSDStiffenerHeight),
    2338          12 :                                                      (k+0.5-fgkSSDChipNumber/2)*(fgkSSDChipLength + fgkSSDChipSeparationLength),
    2339             :                                                      hybridmotherrotInv);
    2340          72 :       for(Int_t j=0; j<kssdstiffenernumber; j++){
    2341          24 :         ssdhybridmother[i][j]->AddNode(ssdchipcables[j],k+1,chipcabletrans);
    2342          24 :         ssdhybridmother[i][j]->AddNode(ssdchip,k+1,chiptrans);
    2343             :       }
    2344             :     }  
    2345             :     // Final placement by assembly
    2346          10 :     ssdhybridassembly[i]->AddNode(ssdhybridmother[i][0],1,new TGeoCombiTrans(TGeoTranslation("",0,0,0),hybridmotherrotL));
    2347          10 :     ssdhybridassembly[i]->AddNode(ssdhybridmother[i][1],1,new TGeoCombiTrans(TGeoTranslation("",0,ssdstiffenerseparation,0),hybridmotherrotR));
    2348           2 :     ssdhybridassembly[i]->GetShape()->ComputeBBox(); //RS: enforce recompting of BBox
    2349           2 :     ssdhybridlist->Add(ssdhybridassembly[i]);
    2350             :   }    
    2351             :   /////////////////////////////////////////////////////////////
    2352             :   // Mother Volume Containing Capacitor Part 
    2353             :   /////////////////////////////////////////////////////////////
    2354             :   const Int_t kcapacitormothernumber = 8;
    2355           1 :   Double_t xcapacitorvertex[kcapacitormothernumber];
    2356           1 :   Double_t ycapacitorvertex[kcapacitormothernumber];  
    2357             :   ///////////////////////
    2358             :   // Setting the vertices 
    2359             :   ///////////////////////
    2360           2 :   xcapacitorvertex[0] = -fgkSSDConnectorPosition[0]+ssdstiffenershape->GetDX();    
    2361           1 :   xcapacitorvertex[1] = xcapacitorvertex[0];   
    2362           1 :   xcapacitorvertex[2] = 0.5*fgkSSDFlexHoleWidth;   
    2363           1 :   xcapacitorvertex[3] = xcapacitorvertex[2];   
    2364           1 :   xcapacitorvertex[4] = xcapacitorvertex[0];   
    2365           1 :   xcapacitorvertex[5] = xcapacitorvertex[0];   
    2366           1 :   xcapacitorvertex[6] = -xcapacitorvertex[0];   
    2367           1 :   xcapacitorvertex[7] = xcapacitorvertex[6];   
    2368           1 :   ycapacitorvertex[0] = -0.5*fgkSSDStiffenerWidth;    
    2369           1 :   ycapacitorvertex[1] = ssdstiffenerseparation-0.5*fgkSSDStiffenerWidth-fgkSSDFlexHoleLength;   
    2370           1 :   ycapacitorvertex[2] = ycapacitorvertex[1];   
    2371           1 :   ycapacitorvertex[3] = ycapacitorvertex[2]+fgkSSDFlexHoleLength;   
    2372           1 :   ycapacitorvertex[4] = ycapacitorvertex[3];   
    2373           1 :   ycapacitorvertex[5] = ycapacitorvertex[4]+fgkSSDStiffenerWidth;   
    2374           1 :   ycapacitorvertex[6] = ycapacitorvertex[5];   
    2375           1 :   ycapacitorvertex[7] = ycapacitorvertex[0];   
    2376           2 :   TGeoXtru* ssdhybridcapacitormothershape = new TGeoXtru(2);
    2377           2 :   ssdhybridcapacitormothershape->DefinePolygon(kcapacitormothernumber,xcapacitorvertex,
    2378           1 :                                               ycapacitorvertex);
    2379           1 :   ssdhybridcapacitormothershape->DefineSection(0,0.5*fgkSSDStiffenerHeight);
    2380           1 :   ssdhybridcapacitormothershape->DefineSection(1, 0.5*fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height);
    2381             : //  TGeoVolume* ssdhybridcapacitormother = new TGeoVolume("SSDHybridCapacitorMother",ssdhybridcapacitormothershape,
    2382             : //                                          fSSDAir);
    2383           2 :   TGeoVolumeAssembly* ssdhybridcapacitormother = new TGeoVolumeAssembly("SSDHybridCapacitorMother");
    2384             : ////////////////////////////
    2385             : // Connector 
    2386             : ///////////////////////////
    2387             :   const Int_t kssdconnectorlayernumber = 3;
    2388           1 :   TGeoBBox* ssdconnectorshape[kssdconnectorlayernumber];
    2389           1 :   Double_t ssdConnectorThickness[kssdconnectorlayernumber]={fgkSSDConnectorAlHeight,fgkSSDConnectorNiHeight,fgkSSDConnectorSnHeight};
    2390             :   /*
    2391             :   Double_t ssdAlconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorAlHeight)};    
    2392             :   Double_t ssdNiconnectororigin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDConnectorNiHeight)
    2393             :                                    +  fgkSSDConnectorAlHeight};  
    2394             :   */
    2395           1 :   Double_t ssdconnectororigin[3] = {0,0,0.5*fgkSSDStiffenerHeight};
    2396           1 :   const char* ssdconnectorname[kssdconnectorlayernumber] = {"SSDConnectorAl","SSDConnectorNi","SSDConnectorSn"};
    2397           1 :   TGeoMedium *ssdConnectorMedium[kssdconnectorlayernumber]={fSSDAlTraceFlexMedium,fSSDStiffenerConnectorMedium,fSSDSn};
    2398           1 :   TGeoVolume* ssdconnector[kssdconnectorlayernumber];
    2399           8 :   for(Int_t i=0; i<kssdconnectorlayernumber; i++){
    2400           3 :     ssdconnectororigin[2]+= 0.5*ssdConnectorThickness[i];
    2401          12 :       ssdconnectorshape[i] = new TGeoBBox(0.5*fgkSSDConnectorLength,
    2402           3 :                                           0.5*fgkSSDConnectorWidth,
    2403           3 :                                           0.5*ssdConnectorThickness[i],
    2404           3 :                                           ssdconnectororigin);
    2405           3 :       ssdconnectororigin[2]+= 0.5*ssdConnectorThickness[i];
    2406          12 :       ssdconnector[i] = new TGeoVolume(ssdconnectorname[i],ssdconnectorshape[i],
    2407           3 :                                        ssdConnectorMedium[i]);      
    2408           9 :       ssdconnector[i]->SetLineColor(i==0 ? fColorAl : fColorNiSn);
    2409             :   }
    2410             :   const Int_t kssdconnectornumber = 4;
    2411           1 :   TGeoTranslation* ssdconnectortrans[kssdconnectornumber];
    2412           5 :   ssdconnectortrans[0] = new TGeoTranslation(-ssdstiffenershape->GetDX()
    2413           1 :                        +  fgkSSDConnectorPosition[0]
    2414           1 :                        -  fgkSSDConnectorSeparation
    2415           1 :                        -  1.5*fgkSSDConnectorLength,
    2416           2 :                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
    2417           1 :                        -  fgkSSDConnectorPosition[1]
    2418           2 :                        -  ssdconnectorshape[0]->GetDY(),0.0);        
    2419           4 :   ssdconnectortrans[1] = new TGeoTranslation(
    2420           2 :                        -  ssdstiffenershape->GetDX()
    2421           1 :                        +  fgkSSDConnectorPosition[0]
    2422           1 :                        -  0.5*fgkSSDConnectorLength,
    2423           2 :                           ssdstiffenerseparation+ssdstiffenershape->GetDY()
    2424           1 :                        -  fgkSSDConnectorPosition[1]
    2425           2 :                        -  ssdconnectorshape[0]->GetDY(),0.0);
    2426           4 :   ssdconnectortrans[2] = new TGeoTranslation(+ssdstiffenershape->GetDX()
    2427           1 :                        -  fgkSSDConnectorPosition[0]
    2428           1 :                        +  fgkSSDConnectorSeparation
    2429           1 :                        +  1.5*fgkSSDConnectorLength,
    2430           2 :                           -(ssdstiffenershape->GetDY()
    2431           1 :                        -  fgkSSDConnectorPosition[1]
    2432           2 :                        -  ssdconnectorshape[0]->GetDY()),0.0);       
    2433           4 :   ssdconnectortrans[3] = new TGeoTranslation(+ssdstiffenershape->GetDX()
    2434           1 :                        -  fgkSSDConnectorPosition[0]
    2435           1 :                        +  0.5*fgkSSDConnectorLength,
    2436           2 :                           -(ssdstiffenershape->GetDY()
    2437           1 :                        -  fgkSSDConnectorPosition[1]
    2438           2 :                        -  ssdconnectorshape[0]->GetDY()),0.0);
    2439          10 :   for(Int_t i=0; i<kssdconnectornumber; i++) {
    2440             :     Int_t nlay = kssdconnectorlayernumber - 1;
    2441           4 :     if (i == 1 || i == 2)
    2442           2 :       nlay++;
    2443          28 :     for(Int_t j=0; j<nlay; j++)
    2444          10 :       ssdhybridcapacitormother->AddNode(ssdconnector[j],i+1,ssdconnectortrans[i]);      
    2445             :   }
    2446             : ////////////////////////////
    2447             : // Capacitor 1812-330 nF
    2448             : /////////////////////////// 
    2449             : //  Double_t ssdcapacitor1812origin[3] = {0.0,0.0,0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height)};    
    2450           3 :   TGeoBBox* capacitor1812shape =  new TGeoBBox("Capacitor1812Shape",
    2451           1 :                                                                                          0.5*fgkSSDCapacitor1812Length,
    2452           1 :                                                                                          0.5*fgkSSDCapacitor1812Width,
    2453           1 :                                                0.5*fgkSSDCapacitor1812Height);
    2454             :   //            ssdcapacitor1812origin);
    2455           3 :   TGeoVolume* capacitor1812 = new TGeoVolume("Capacitor1812",capacitor1812shape,
    2456           1 :                                              fSSDStiffener1812CapacitorMedium); 
    2457           1 :   capacitor1812->SetLineColor(fColorAl);
    2458           3 :   TGeoTranslation* capacitor1812trans = new TGeoTranslation(0.0,
    2459           1 :                                         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
    2460           2 :                                       - capacitor1812shape->GetDY()-fgkSSDConnectorPosition[1],0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
    2461           1 :   ssdhybridcapacitormother->AddNode(capacitor1812,1,capacitor1812trans);
    2462             : 
    2463           3 :   TGeoBBox* capacitor1812capshape =  new TGeoBBox("Capacitor1812CapShape",
    2464           1 :     0.5*fgkSSDCapacitor1812CapLength, 0.5*fgkSSDCapacitor1812Width,
    2465           1 :     0.5*fgkSSDCapacitor1812Height);
    2466           3 :   TGeoVolume* capacitor1812cap = new TGeoVolume("Capacitor1812Cap",capacitor1812capshape,
    2467           1 :                                              fSSDStiffenerCapacitorCapMedium);
    2468           1 :   capacitor1812cap->SetLineColor(fColorNiSn);
    2469           3 :   TGeoTranslation* capacitor1812captrans1 = new TGeoTranslation(
    2470           3 :         - capacitor1812shape->GetDX() - capacitor1812capshape->GetDX(),
    2471           1 :         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
    2472           2 :         - capacitor1812shape->GetDY() - fgkSSDConnectorPosition[1],
    2473           1 :         0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
    2474           1 :   ssdhybridcapacitormother->AddNode(capacitor1812cap,1,capacitor1812captrans1);
    2475           3 :   TGeoTranslation* capacitor1812captrans2 = new TGeoTranslation(
    2476           3 :         capacitor1812shape->GetDX() + capacitor1812capshape->GetDX(),
    2477           1 :         0.5*fgkSSDStiffenerWidth+ssdstiffenerseparation
    2478           2 :         - capacitor1812shape->GetDY() - fgkSSDConnectorPosition[1],
    2479           1 :         0.5*(fgkSSDStiffenerHeight+fgkSSDCapacitor1812Height));
    2480           1 :   ssdhybridcapacitormother->AddNode(capacitor1812cap,2,capacitor1812captrans2);
    2481             : 
    2482             : ////////////////////////////
    2483             : //Hybrid Wire
    2484             : ////////////////////////////
    2485           2 :   Double_t wirex = 2.*(fgkSSDConnectorPosition[0]-0.5*fgkSSDStiffenerLength
    2486           2 :                                  - 0.5*fgkSSDConnectorLength)-fgkSSDConnectorLength
    2487           1 :                                  - fgkSSDConnectorSeparation;
    2488           1 :   Double_t wirey = ssdstiffenerseparation+fgkSSDStiffenerWidth
    2489           1 :                                  - 2.*fgkSSDConnectorPosition[1]-fgkSSDConnectorWidth;
    2490           1 :   Double_t ssdwireradius = TMath::Sqrt(wirex*wirex+wirey*wirey);
    2491             : 
    2492           1 :   Double_t wireangle = TMath::ATan(wirex/wirey);
    2493           3 :   TGeoTube *hybridwireshape = new TGeoTube("HybridWireShape", 0., 
    2494           1 :                                                 fgkSSDWireRadius, 0.5*ssdwireradius);
    2495           3 :   TGeoVolume* hybridwire = new TGeoVolume("HybridWire",hybridwireshape,
    2496           1 :                                              fSSDStiffenerHybridWireMedium); 
    2497           1 :   hybridwire->SetLineColor(fColorPhynox);
    2498             :   TGeoCombiTrans* hybridwirecombitrans[2];
    2499           3 :   hybridwirecombitrans[0] = new TGeoCombiTrans("HybridWireCombiTrans1",
    2500           1 :                    0.5*fgkSSDStiffenerLength-fgkSSDConnectorPosition[0]
    2501           1 :                                  + 1.5*fgkSSDConnectorLength+fgkSSDConnectorSeparation,
    2502           1 :                    0.5*ssdwireradius-0.5*fgkSSDStiffenerWidth
    2503           1 :                                  + fgkSSDConnectorPosition[1]+0.5*fgkSSDConnectorWidth,
    2504           1 :                                    ssdstiffenershape->GetDZ()
    2505           1 :                                  + fgkSSDWireRadius+fgkSSDConnectorAlHeight+fgkSSDConnectorNiHeight+fgkSSDConnectorSnHeight,
    2506           2 :                    new TGeoRotation("HybridWireRot1",0.,90.,0.));
    2507           3 :   hybridwirecombitrans[1] = new TGeoCombiTrans("HybridWireCombiTrans2",
    2508             :                             0.0,
    2509           1 :                           - 0.5*fgkSSDConnectorWidth+fgkSSDWireRadius,
    2510             :                             0.0,        
    2511           3 :                             new TGeoRotation("HybridWireRot2",
    2512           1 :                           - wireangle*TMath::RadToDeg(),0.,0.));
    2513           2 :   TGeoHMatrix* hybridwirematrix = new TGeoHMatrix();
    2514           1 :   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[0]);
    2515           1 :   hybridwirematrix->MultiplyLeft(hybridwirecombitrans[1]);
    2516           1 :   ssdhybridcapacitormother->AddNode(hybridwire,1,hybridwirematrix);
    2517           1 :   ssdhybridcapacitormother->GetShape()->ComputeBBox(); //RS: enforce recompting of BBox
    2518             : 
    2519           1 :   ssdhybridlist->Add(ssdhybridcapacitormother);
    2520             :   /////////////////////////////////////////////////////////////
    2521             :   // Deallocating memory
    2522             :   /////////////////////////////////////////////////////////////
    2523           2 :   delete hybridwirecombitrans[0];
    2524           2 :   delete hybridwirecombitrans[1];
    2525             :   return ssdhybridlist;
    2526             :   /////////////////////////////////////////////////////////////
    2527           1 : }
    2528             : ///////////////////////////////////////////////////////////////////////////////
    2529             : TGeoVolume* AliITSv11GeometrySSD::GetCoolingBlockSystem(){
    2530             :   /////////////////////////////////////////////////////////////
    2531             :   // SSD Cooling Block System
    2532             :   /////////////////////////////////////////////////////////////
    2533             :   // SSD Cooling Block and Cooling Tube Transformations
    2534             :   /////////////////////////////////////////////////////////////
    2535           2 :   TGeoRotation* localcoolingblockrot = new TGeoRotation();
    2536           1 :   localcoolingblockrot->SetAngles(0.,90.,0.);
    2537           1 :   TGeoCombiTrans localcoolingblockmatrix(0.,0.5*fgkSSDCoolingBlockWidth,0.,localcoolingblockrot);
    2538             :   TVector3* coolingblocktransvector;
    2539           3 :   coolingblocktransvector = new TVector3(fgkCoolingTubeSeparation,
    2540           1 :                                                                   fgkSSDSensorLength
    2541           1 :                                                                 - 2.*fgkSSDModuleStiffenerPosition[1]
    2542           1 :                                          - fgkSSDCoolingBlockWidth, 0);
    2543             :   const Int_t kcoolingblocktransnumber = 2;
    2544             :   const Int_t kcoolingblocknumber = 4;
    2545           1 :   TGeoHMatrix* coolingblockmatrix[kcoolingblocknumber];
    2546           2 :   TGeoRotation* localcoolingtuberot = new TGeoRotation();
    2547           1 :   localcoolingtuberot->SetAngles(0.0,90.0,0.0);
    2548           6 :   for(Int_t i=0; i<kcoolingblocktransnumber; i++){
    2549          12 :     for(Int_t j=0; j<kcoolingblocktransnumber; j++){
    2550           8 :       TGeoTranslation localcoolingblocktrans(i*coolingblocktransvector->X(),//+2*coolingtubedistance,
    2551           4 :                                              j*coolingblocktransvector->Y(),
    2552           8 :                                              - 0.5*(fgkSSDCoolingBlockHoleCenter
    2553           4 :                                                     + fgkCoolingTubeRmax));
    2554          16 :       coolingblockmatrix[2*i+j] = new TGeoHMatrix(localcoolingblocktrans*localcoolingblockmatrix);
    2555           4 :     }
    2556             :   }
    2557           3 :   TGeoVolume* coolingsystemother = new TGeoVolumeAssembly("CoolingBlockSystem");
    2558           1 :   TGeoVolume* ssdcoolingblock = GetSSDCoolingBlock(30);
    2559             :   /////////////////////////////////////////////////////////////
    2560             :   // Adding Cooling block to mother volume
    2561             :   /////////////////////////////////////////////////////////////
    2562          10 :   for(Int_t i=0; i<kcoolingblocknumber; i++){ 
    2563           4 :     coolingsystemother->AddNode(ssdcoolingblock,i+1,coolingblockmatrix[i]);
    2564             :   }
    2565             :   
    2566           1 :   coolingsystemother->GetShape()->ComputeBBox(); //RS: enforce recompting of BBox
    2567             : 
    2568             :   /////////////////////////////////////////////////////////////
    2569             :   // Deallocating memory
    2570             :   /////////////////////////////////////////////////////////////
    2571           2 :   delete coolingblocktransvector;
    2572           2 :   delete localcoolingblockrot;
    2573             : 
    2574             :   return coolingsystemother;
    2575           1 : }
    2576             : /////////////////////////////////////////////////////////////////////////////////
    2577             : TGeoVolume* AliITSv11GeometrySSD::GetSSDStiffenerFlex()const{
    2578             :   /////////////////////////////////////////////////////////////
    2579             :   // SSD Flex
    2580             :   /////////////////////////////////////////////////////////////
    2581             :   const Int_t kssdflexlayernumber = 2;
    2582           2 :   TGeoXtru* ssdflexshape[kssdflexlayernumber];
    2583           8 :   for(Int_t i=0; i<kssdflexlayernumber; i++) ssdflexshape[i] = new TGeoXtru(2);
    2584             :   const Int_t kmothervertexnumber = 17; 
    2585           1 :   Double_t xmothervertex[kmothervertexnumber];
    2586           1 :   Double_t ymothervertex[kmothervertexnumber];
    2587             :   /////////////////////////////////////////////
    2588             :   // Auxiliary variables for vertex positioning
    2589             :   /////////////////////////////////////////////
    2590             :   const Int_t kssdflexboxnumber = 5;
    2591             :   Double_t ssdflexboxlength[kssdflexboxnumber];
    2592           1 :   ssdflexboxlength[0] = 0.5*(fgkSSDChipNumber
    2593           2 :                                           *     fgkSSDChipLength+(fgkSSDChipNumber-1)
    2594           1 :                                           *     fgkSSDChipSeparationLength
    2595           1 :                                           - fgkSSDModuleSensorSupportDistance-fgkSSDFlexHoleLength)
    2596           1 :                                           - (fgkSSDFlexLength[0]-fgkSSDFlexLength[1]);
    2597           1 :   ssdflexboxlength[1] = fgkSSDModuleSensorSupportDistance+fgkSSDFlexHoleLength;
    2598           1 :   ssdflexboxlength[2] = 0.5*(fgkSSDModuleSensorSupportDistance
    2599           1 :                                           -     fgkSSDFlexHoleLength-fgkSSDFlexHoleWidth);      
    2600             :   ssdflexboxlength[3] = fgkSSDFlexHoleWidth;    
    2601           1 :   ssdflexboxlength[4] = fgkSSDFlexLength[1]-ssdflexboxlength[0]
    2602           1 :                                           -     ssdflexboxlength[1];
    2603             :   Double_t ssdflexboxwidth[kssdflexboxnumber];
    2604             :   ssdflexboxwidth[0] = fgkSSDFlexWidth[0];
    2605           1 :   ssdflexboxwidth[1] = fgkSSDFlexWidth[0]-fgkSSDFlexHoleWidth;
    2606             :   ssdflexboxwidth[2] = fgkSSDFlexHoleWidth;
    2607           1 :   ssdflexboxwidth[3] = ssdflexboxwidth[2]-fgkSSDFlexHoleLength;
    2608             :   ssdflexboxwidth[4] = fgkSSDFlexWidth[0];
    2609             :   ///////////////////////
    2610             :   // Setting the vertices 
    2611             :   ///////////////////////
    2612           1 :   xmothervertex[0]  = 0.0;
    2613           1 :   xmothervertex[1]  = xmothervertex[0];
    2614           1 :   xmothervertex[2]  = fgkSSDFlexLength[0]-fgkSSDFlexLength[1];
    2615           2 :   xmothervertex[3]  = xmothervertex[2]+ssdflexboxlength[0]+ssdflexboxlength[1]
    2616           1 :                                         + ssdflexboxlength[4];
    2617           1 :   xmothervertex[4]  = xmothervertex[3];
    2618           1 :   xmothervertex[5]  = xmothervertex[4]-ssdflexboxlength[4];
    2619           1 :   xmothervertex[6]  = xmothervertex[5];
    2620           1 :   xmothervertex[7]  = xmothervertex[6]-fgkSSDFlexHoleLength;
    2621           1 :   xmothervertex[8]  = xmothervertex[7];
    2622           1 :   xmothervertex[9]  = xmothervertex[8]-ssdflexboxlength[2];
    2623           1 :   xmothervertex[10] = xmothervertex[9]; 
    2624           1 :   xmothervertex[11] = xmothervertex[10]-ssdflexboxlength[3];
    2625           1 :   xmothervertex[12] = xmothervertex[11];
    2626           1 :   xmothervertex[13] = xmothervertex[12]-ssdflexboxlength[2];
    2627           1 :   xmothervertex[14] = xmothervertex[13];
    2628           1 :   xmothervertex[15] = xmothervertex[14]-fgkSSDFlexHoleLength;
    2629           1 :   xmothervertex[16] = xmothervertex[15];
    2630           1 :   ymothervertex[0]  = 0.0;
    2631           1 :   ymothervertex[1]  = fgkSSDFlexWidth[1];
    2632           1 :   ymothervertex[2]  = fgkSSDFlexWidth[0];
    2633           1 :   ymothervertex[3]  = ymothervertex[2];
    2634           1 :   ymothervertex[4]  = ymothervertex[0];
    2635           1 :   ymothervertex[5]  = ymothervertex[4];
    2636           1 :   ymothervertex[6]  = ssdflexboxwidth[2];
    2637           1 :   ymothervertex[7]  = ymothervertex[6];
    2638           1 :   ymothervertex[8]  = ymothervertex[0];
    2639           1 :   ymothervertex[9]  = ymothervertex[8];
    2640           1 :   ymothervertex[10] = ssdflexboxwidth[2]-ssdflexboxwidth[3];
    2641           1 :   ymothervertex[11] = ymothervertex[10];
    2642           1 :   ymothervertex[12] = ymothervertex[0];
    2643           1 :   ymothervertex[13] = ymothervertex[12];
    2644           1 :   ymothervertex[14] = ymothervertex[7];
    2645           1 :   ymothervertex[15] = ymothervertex[14];
    2646           1 :   ymothervertex[16] = ymothervertex[0];
    2647             :   /////////////////////////////////////////////////////////////
    2648             :   // First Mother Volume containing SSDFlex
    2649             :   /////////////////////////////////////////////////////////////
    2650           1 :   TGeoXtru* ssdflexmothershape = new TGeoXtru(2);
    2651           2 :   ssdflexmothershape->DefinePolygon(kmothervertexnumber,xmothervertex,
    2652           1 :                                                                     ymothervertex);
    2653           1 :   ssdflexmothershape->DefineSection(0,-1.5*fgkSSDFlexHeight[0]-2.*fgkSSDFlexHeight[1]);
    2654           1 :   ssdflexmothershape->DefineSection(1, 0.5*fgkSSDFlexHeight[0]);
    2655           1 :   TGeoVolumeAssembly* ssdflexmother = new TGeoVolumeAssembly("SSDFlexMother");
    2656             : //  TGeoVolume* ssdflexmother = new TGeoVolume("SSDFlexMother",ssdflexmothershape,
    2657             : //                                                                                       fSSDAir);
    2658             :   /////////////////////////////////////////////////////////////
    2659             :   // SSDFlex Layer Shapes
    2660             :   /////////////////////////////////////////////////////////////
    2661           6 :   for(Int_t i=0; i<kssdflexlayernumber; i++){
    2662           2 :         ssdflexshape[i]->DefinePolygon(kmothervertexnumber,xmothervertex,
    2663             :                                                                    ymothervertex);
    2664           2 :     ssdflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexHeight[i]);
    2665           2 :         ssdflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexHeight[i]);
    2666             :   }
    2667             :   /////////////////////////////////////
    2668             :   // Setting Layers into Mother Volume
    2669             :   /////////////////////////////////////
    2670           1 :   Int_t ssdflexcolor[kssdflexlayernumber] = {fColorAl,fColorPolyhamide};
    2671           1 :   TGeoMedium* ssdflexmed[kssdflexlayernumber] = {fSSDAlTraceFlexMedium,
    2672           1 :                                                                                                  fSSDKaptonFlexMedium};
    2673           1 :   const char* ssdflexname[2*kssdflexlayernumber] = {"AlFlexLay1","KaptonFlexLay1",
    2674             :                                                                                                         "AlFlexLay2","KaptonFlexLay2"};
    2675           1 :   TGeoVolume* ssdflex[2*kssdflexlayernumber];
    2676           1 :   TGeoTranslation* ssdflextrans[2*kssdflexlayernumber];
    2677          10 :   for(Int_t i=0; i<2*kssdflexlayernumber; i++){
    2678          12 :         ssdflex[i] = new TGeoVolume(ssdflexname[i],
    2679           4 :                                                                 i%2==0 ? ssdflexshape[0] : ssdflexshape[1],
    2680           4 :                                                                 i%2==0 ? ssdflexmed[0]   : ssdflexmed[1]);
    2681           4 :         ssdflex[i]->SetLineColor(i%2==0 ? ssdflexcolor[0] : ssdflexcolor[1]);
    2682          12 :     ssdflextrans[i]  = new TGeoTranslation(0.,0.,-0.5*i*(fgkSSDFlexHeight[0]
    2683           4 :                                          +                                         fgkSSDFlexHeight[1])); 
    2684           4 :     ssdflexmother->AddNode(ssdflex[i],1,ssdflextrans[i]);
    2685             :   }
    2686           1 :   ssdflexmother->GetShape()->ComputeBBox(); //RS: enforce recompting of BBox
    2687             : 
    2688           1 :   return ssdflexmother;
    2689           1 : }
    2690             : 
    2691             : /////////////////////////////////////////////////////////////////////////////////
    2692             : TGeoVolume* AliITSv11GeometrySSD::GetSSDEndFlex(){
    2693             :   /////////////////////////////////////////////////////////////
    2694             :   // Method generating SSD End Flex   
    2695             :   /////////////////////////////////////////
    2696           2 :   Double_t ssdflexradiusmax = (fgkSSDFlexLength[3]-fgkSSDFlexLength[2])
    2697           1 :                                                         /  TMath::Tan(fgkSSDFlexAngle*TMath::DegToRad());
    2698           2 :   Double_t ssdflexboxlength = fgkSSDFlexFullLength-2.*fgkSSDFlexAngle
    2699           1 :                                                 * TMath::DegToRad()*ssdflexradiusmax
    2700           2 :                                                 - fgkSSDFlexLength[2]-TMath::Pi()
    2701           2 :                                                 * fgkSSDStiffenerHeight-fgkSSDFlexLength[0]
    2702           1 :                                                         - 0.1*fgkSSDFlexFullLength;
    2703             :   const Int_t knedges = 20;  
    2704             :   const Int_t karcnumber = 2;
    2705           1 :   TVector3* vertexposition[karcnumber*(knedges+1)];
    2706           1 :   Double_t deltangle[karcnumber] = {2.*fgkSSDFlexAngle/knedges,180.0/knedges}; 
    2707           1 :   Double_t angle[karcnumber] = {90.-2.*fgkSSDFlexAngle,180.0};  
    2708           1 :   Double_t radius[karcnumber] = {ssdflexradiusmax-fgkSSDStiffenerHeight,fgkSSDStiffenerHeight};
    2709           1 :   Double_t referenceangle[karcnumber] = {-180.0*TMath::DegToRad(),
    2710           1 :                                                                                  - 90.0*TMath::DegToRad()};
    2711           1 :   TVector3* referencetrans[karcnumber];
    2712           4 :   referencetrans[0] = new TVector3(ssdflexboxlength*CosD(2.*fgkSSDFlexAngle)
    2713           2 :                                         +                          radius[0]*SinD(2.*fgkSSDFlexAngle),
    2714           1 :                                    radius[0], 0);
    2715           3 :   referencetrans[1] = new TVector3(referencetrans[0]->X()
    2716           1 :                                         +              fgkSSDFlexLength[2],
    2717           1 :                                    -              fgkSSDStiffenerHeight, 0);
    2718           6 : for(Int_t i=0; i<karcnumber; i++){
    2719          88 :         for(Int_t j=0; j<knedges+1; j++){
    2720         168 :                 vertexposition[j+i*(knedges+1)] = new TVector3(radius[i]*CosD(angle[i]),
    2721          84 :                                                          radius[i]*SinD(angle[i]), 0);
    2722          42 :                 angle[i] +=  deltangle[i]*(1.0-2.0*i);
    2723             :         }       
    2724             :   }
    2725             :   ///////////////////////
    2726             :   // Setting the vertices 
    2727             :   ///////////////////////
    2728             :   const Int_t kendflexlayernumber = 4;
    2729             :   const Int_t kendflexvertexnumber = 4*(knedges+1)+2;
    2730           1 :   TVector3** vertex[kendflexlayernumber];
    2731          10 :   for(Int_t i=0; i<kendflexlayernumber; i++) 
    2732           4 :                                         vertex[i] = new TVector3*[kendflexvertexnumber];
    2733           1 :   TVector3* transvector[kendflexlayernumber+1];
    2734           1 :   TVector3* deltatransvector = new TVector3();  
    2735          17 :   for(Int_t i=0; i<kendflexlayernumber+1; i++) transvector[i] = new TVector3();      
    2736           2 :   transvector[0]->SetXYZ(0.0,ssdflexboxlength*SinD(2.*fgkSSDFlexAngle)
    2737           1 :                                 +                radius[0]*(1.0-CosD(2.*fgkSSDFlexAngle)),0.0);
    2738          10 :   for(Int_t i=1; i<kendflexlayernumber+1; i++){      
    2739           8 :         deltatransvector->SetXYZ((i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
    2740           4 :                                         *                 CosD(fgkSSDFlexAngle),
    2741           4 :                                                           (i%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
    2742           4 :                                         *         SinD(fgkSSDFlexAngle),0.0);   
    2743           4 :         *transvector[i] = *transvector[i-1]+*deltatransvector;
    2744             :   }
    2745           1 :   Double_t ratioradius[karcnumber][kendflexlayernumber+1];
    2746           1 :   ratioradius[0][0] = 1., ratioradius[1][0] = 1.;
    2747           6 :   for(Int_t i=0; i<karcnumber; i++){
    2748          20 :         for(Int_t j=1; j<kendflexlayernumber+1; j++){
    2749          16 :                 ratioradius[i][j] = ratioradius[i][j-1]-TMath::Power(-1.0,i)
    2750           8 :                                                   * (j%2!=0?fgkSSDFlexHeight[0]:fgkSSDFlexHeight[1])
    2751           8 :                                               /radius[i];
    2752             :         }
    2753             :   }
    2754          10 :   for(Int_t i=0; i<kendflexlayernumber; i++){
    2755           8 :     vertex[i][0] = new TVector3(transvector[i]->X(),transvector[i]->Y(),0);
    2756           8 :     vertex[i][1] = new TVector3(transvector[i+1]->X(),transvector[i+1]->Y(),0);
    2757         344 :         for(Int_t j=0; j<karcnumber*(knedges+1); j++){
    2758         336 :                 if(j<(knedges+1)){
    2759         420 :                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[0][i+1],
    2760          84 :                                                 vertexposition[j]->Y()*ratioradius[0][i+1], 0);
    2761          84 :                         vertex[i][j+2]->RotateZ(referenceangle[0]);
    2762          84 :                         *vertex[i][j+2] += *referencetrans[0];
    2763          84 :                         vertex[i][4*(knedges+1)-j+1] = 
    2764         168 :                                                          new TVector3(vertexposition[j]->X()*ratioradius[0][i],
    2765          84 :                                  vertexposition[j]->Y()*ratioradius[0][i], 0);
    2766          84 :                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[0]);
    2767          84 :                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[0];
    2768          84 :                 }
    2769             :                 else{
    2770             :                 
    2771         252 :                         vertex[i][j+2] = new TVector3(vertexposition[j]->X()*ratioradius[1][i+1],
    2772          84 :                                                 vertexposition[j]->Y()*ratioradius[1][i+1],0);
    2773          84 :                         vertex[i][j+2]->RotateZ(referenceangle[1]);
    2774          84 :                         *vertex[i][j+2] += *referencetrans[1];
    2775          84 :                         vertex[i][4*(knedges+1)-j+1] = 
    2776         168 :                                                          new TVector3(vertexposition[j]->X()*ratioradius[1][i],
    2777          84 :                                        vertexposition[j]->Y()*ratioradius[1][i],
    2778             :                                        0);
    2779          84 :                         vertex[i][4*(knedges+1)-j+1]->RotateZ(referenceangle[1]);
    2780          84 :                         *vertex[i][4*(knedges+1)-j+1] += *referencetrans[1];
    2781             :            }
    2782             :         }
    2783             :   }
    2784             :   /////////////////////////////////////////////////////////////
    2785             :   // First Mother Volume containing SSDEndFlex
    2786             :   /////////////////////////////////////////////////////////////
    2787           1 :   TGeoXtru* ssdendflexmothershape = new TGeoXtru(2);
    2788           1 :   Double_t xmothervertex[kendflexvertexnumber];
    2789           1 :   Double_t ymothervertex[kendflexvertexnumber];
    2790           1 :   xmothervertex[0] = vertex[0][0]->X();      
    2791           1 :   ymothervertex[0] = vertex[0][0]->Y();
    2792         172 :   for(Int_t i=1; i<kendflexvertexnumber; i++){
    2793         170 :         if(i<2*(knedges+1)+2){
    2794         128 :                 xmothervertex[i] = vertex[3][i]->X();
    2795          43 :                 ymothervertex[i] = vertex[3][i]->Y();
    2796          43 :         }
    2797             :         else{
    2798          42 :                 xmothervertex[i] = vertex[0][i]->X();
    2799          42 :                 ymothervertex[i] = vertex[0][i]->Y();
    2800             :         }
    2801             :   }
    2802           1 :   ssdendflexmothershape->DefinePolygon(kendflexvertexnumber,
    2803           1 :                                                                            xmothervertex,ymothervertex);
    2804           1 :   ssdendflexmothershape->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
    2805           1 :   ssdendflexmothershape->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
    2806             : //  TGeoVolume* ssdendflexmother = new TGeoVolume("SSDEndFlexMother",
    2807             : //                                                               ssdendflexmothershape,fSSDAir);        
    2808           1 :   TGeoVolumeAssembly* ssdendflexmother = new TGeoVolumeAssembly("SSDEndFlexMother");
    2809             :   //////////////////////////////////////
    2810             :   // End Flex TGeoXtru Layer Definition 
    2811             :   //////////////////////////////////////
    2812           1 :   TGeoXtru* ssdendflexshape[kendflexlayernumber];
    2813           1 :   TGeoVolume* ssdendflex[kendflexlayernumber];
    2814          14 :   for(Int_t i=0; i<kendflexlayernumber; i++) ssdendflexshape[i] = new TGeoXtru(2);
    2815           1 :   Double_t xvertex[kendflexlayernumber][kendflexvertexnumber];
    2816           1 :   Double_t yvertex[kendflexlayernumber][kendflexvertexnumber];
    2817           3 :   Int_t ssdendflexcolor[kendflexlayernumber] = {fColorAl,fColorPolyhamide};
    2818           4 :   TGeoMedium* ssdendflexmed[kendflexlayernumber] = {fSSDAlTraceFlexMedium,
    2819           1 :                                                                                                         fSSDKaptonFlexMedium};
    2820           1 :   const char* ssdendflexname[kendflexlayernumber] = {"AlEndFlexLay1","KaptonEndFlexLay1",
    2821             :                                                                                                          "AlEndFlexLay2","KaptonEndFlexLay2"};
    2822          10 :   for(Int_t i=0; i<kendflexlayernumber; i++){
    2823         696 :         for(Int_t j=0; j<4*(knedges+1)+2; j++){
    2824         344 :                 xvertex[i][j] = vertex[i][j]->X();
    2825         344 :                 yvertex[i][j] = vertex[i][j]->Y();
    2826             :         }
    2827           4 :   ssdendflexshape[i]->DefinePolygon(kendflexvertexnumber,xvertex[i],yvertex[i]);
    2828           4 :   ssdendflexshape[i]->DefineSection(0,-0.5*fgkSSDFlexWidth[0]);
    2829           4 :   ssdendflexshape[i]->DefineSection(1, 0.5*fgkSSDFlexWidth[0]);
    2830          12 :   ssdendflex[i] = new TGeoVolume(ssdendflexname[i],ssdendflexshape[i],
    2831           4 :                                                                  i%2==0 ? ssdendflexmed[0] : ssdendflexmed[1]);
    2832           4 :   ssdendflex[i]->SetLineColor(i%2==0 ? ssdendflexcolor[0] : ssdendflexcolor[1]);
    2833           4 :   ssdendflexmother->AddNode(ssdendflex[i],1);
    2834             :   }
    2835             :   /////////////////////////////////////////////////////////////
    2836             :   // Deallocating memory
    2837             :   /////////////////////////////////////////////////////////////
    2838         170 :   for(Int_t i=0; i<karcnumber*(knedges+1); i++) delete vertexposition[i];
    2839          10 :   for(Int_t i=0; i<karcnumber; i++) delete referencetrans[i];
    2840          10 :   for(Int_t i=0; i<kendflexlayernumber; i++){
    2841        1384 :         for(Int_t j=0; j<kendflexvertexnumber; j++) delete vertex[i][j];
    2842           8 :         delete [] vertex[i];
    2843             :   }
    2844          22 :   for(Int_t i=0; i<kendflexlayernumber+1; i++) delete transvector[i];
    2845             : 
    2846           1 :   ssdendflexmother->GetShape()->ComputeBBox(); //RS: enforce recompting of BBox
    2847             :         
    2848           2 :   delete deltatransvector;
    2849             :   /////////////////////////////////////////////////////////////
    2850             :   //ssdendflexmother->CheckOverlaps(0.01);
    2851           1 :   return ssdendflexmother;
    2852           1 : }
    2853             : ///////////////////////////////////////////////////////////////////////////////
    2854             : TGeoVolume* AliITSv11GeometrySSD::GetSSDMountingBlock(){
    2855             :   /////////////////////////////////////////////////////////////
    2856             :   // Method generating the Mounting Block
    2857             :   /////////////////////////////////////////////////////////////  
    2858             :   const Int_t kvertexnumber = 8;
    2859           2 :   Double_t xvertex[kvertexnumber];
    2860           1 :   Double_t yvertex[kvertexnumber];
    2861           1 :   xvertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
    2862           1 :   xvertex[1] = xvertex[0];
    2863           1 :   xvertex[2] = -xvertex[0];
    2864           1 :   xvertex[3] = xvertex[2];
    2865           2 :   xvertex[4] = xvertex[3]+0.5*(fgkSSDMountingBlockLength[1]
    2866           1 :                          -                                 fgkSSDMountingBlockLength[2]);
    2867           1 :   xvertex[5] = xvertex[4];
    2868           2 :   xvertex[6] = 0.5*fgkSSDMountingBlockLength[0]-xvertex[2]
    2869           1 :                          - 0.5*fgkSSDMountingBlockScrewHoleEdge
    2870           1 :                          -     fgkSSDMountingBlockScrewHoleRadius[0];
    2871           1 :   xvertex[7] = xvertex[6];
    2872           2 :   yvertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
    2873           1 :                          +      fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
    2874           1 :   yvertex[1] = 0.5*fgkSSDMountingBlockHeight[0];
    2875           1 :   yvertex[2] = yvertex[1]; 
    2876           1 :   yvertex[3] = fgkSSDMountingBlockHeight[1]-yvertex[1];
    2877           1 :   yvertex[4] = yvertex[3];
    2878           2 :   yvertex[5] = yvertex[2]+fgkSSDMountingBlockHeight[2]
    2879           1 :                          - fgkSSDMountingBlockHeight[0];
    2880           1 :   yvertex[6] = yvertex[5];
    2881           1 :   yvertex[7] = yvertex[0];
    2882             : 
    2883             :   ///////////////////////////////////////////////////////////////////////
    2884             :   // TGeoXTru Volume definition for Mounting Block Part
    2885             :   ///////////////////////////////////////////////////////////////////////
    2886           1 :   TGeoXtru* ssdmountingblockshape = new TGeoXtru(2);
    2887           1 :   ssdmountingblockshape->DefinePolygon(kvertexnumber,xvertex,yvertex);
    2888           1 :   ssdmountingblockshape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
    2889           1 :   ssdmountingblockshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
    2890           2 :   TGeoVolume* ssdmountingblock = new TGeoVolume("SSDMountingBlock",
    2891           1 :                                                                           ssdmountingblockshape,
    2892           1 :                                                                                   fSSDMountingBlockMedium);
    2893           1 :   ssdmountingblock->SetLineColor(fColorG10);
    2894           1 :   TGeoCombiTrans* mountingblockcombitrans = new TGeoCombiTrans();
    2895           1 :   mountingblockcombitrans->SetTranslation(2.*xvertex[2]+fgkSSDMountingBlockLength[1],0.,0.);
    2896           1 :   TGeoRotation* mountingblockrot = new TGeoRotation();
    2897           1 :   mountingblockrot->SetAngles(90.,180.,-90.);
    2898           1 :   mountingblockcombitrans->SetRotation(*mountingblockrot);
    2899             :   /////////////////////////////////////////////////////////////
    2900             :   // Generating the Mounting Block Screw Vertices 
    2901             :   /////////////////////////////////////////////////////////////  
    2902             :   const Int_t kscrewvertexnumber = 15;
    2903           3 :   Double_t alpha = TMath::ACos(0.5*(fgkSSDMountingBlockHeight[1]
    2904           1 :                                  -                                      fgkSSDMountingBlockScrewHoleEdge)
    2905           1 :                                  /                              fgkSSDMountingBlockScrewHoleRadius[0])
    2906           1 :                                  * TMath::RadToDeg();
    2907           1 :   Double_t phi0 = 90.+alpha;
    2908           1 :   Double_t phi = 270.-2*alpha;
    2909           1 :   Double_t deltaphi = phi/kscrewvertexnumber;   
    2910           1 :   TVector3* screwvertex[kscrewvertexnumber+1];
    2911          34 :   for(Int_t i=0; i<kscrewvertexnumber+1; i++)        
    2912          48 :         screwvertex[i] = new TVector3(fgkSSDMountingBlockScrewHoleRadius[0]
    2913          32 :                                    *CosD(phi0+i*deltaphi),
    2914          16 :                                    fgkSSDMountingBlockScrewHoleRadius[0]
    2915          32 :                                       *SinD(phi0+i*deltaphi), 0);
    2916           1 :   Double_t xscrewvertex[kscrewvertexnumber+6];
    2917           1 :   Double_t yscrewvertex[kscrewvertexnumber+6];
    2918           1 :   xscrewvertex[0] = - fgkSSDMountingBlockScrewHoleRadius[0];    
    2919           2 :   yscrewvertex[0] = -0.5*(fgkSSDMountingBlockWidth
    2920           1 :                                   -               fgkSSDMountingBlockScrewHoleEdge);
    2921           1 :   xscrewvertex[1] = xscrewvertex[0];
    2922           1 :   yscrewvertex[1] = 0.5*fgkSSDMountingBlockScrewHoleEdge;
    2923           1 :   xscrewvertex[2] = screwvertex[0]->X();
    2924           1 :   yscrewvertex[2] = yscrewvertex[1];
    2925          34 :   for(Int_t i=0; i<kscrewvertexnumber+1; i++){
    2926          16 :         xscrewvertex[i+3] = screwvertex[i]->X();     
    2927          16 :         yscrewvertex[i+3] = screwvertex[i]->Y();     
    2928             :   } 
    2929           1 :   xscrewvertex[kscrewvertexnumber+4] = 0.5*fgkSSDMountingBlockScrewHoleEdge;    
    2930           1 :   yscrewvertex[kscrewvertexnumber+4] = yscrewvertex[kscrewvertexnumber+3];      
    2931           1 :   xscrewvertex[kscrewvertexnumber+5] = xscrewvertex[kscrewvertexnumber+4];
    2932           1 :   yscrewvertex[kscrewvertexnumber+5] = yscrewvertex[0];
    2933           1 :   TGeoXtru* ssdmountingblockscrewshape = new TGeoXtru(2);
    2934           1 :   ssdmountingblockscrewshape->DefinePolygon(kscrewvertexnumber+6,xscrewvertex,yscrewvertex);
    2935           1 :   ssdmountingblockscrewshape->DefineSection(0,yvertex[0]);
    2936           2 :   ssdmountingblockscrewshape->DefineSection(1,-0.5*fgkSSDMountingBlockHeight[0]
    2937           1 :                                                         +                                  fgkSSDMountingBlockHeight[2]);
    2938           2 :   TGeoVolume* ssdmountingblockscrew = new TGeoVolume("SSDMountingBlockScrew",
    2939           1 :                                                                                 ssdmountingblockscrewshape,
    2940           1 :                                                                                             fSSDMountingBlockMedium);
    2941           1 :   ssdmountingblockscrew->SetLineColor(fColorG10);
    2942           1 :   TGeoCombiTrans* ssdmountingblockscrewcombitrans[4];
    2943          14 :   for(Int_t i=0; i<4; i++) ssdmountingblockscrewcombitrans[i] = new TGeoCombiTrans();
    2944           2 :   ssdmountingblockscrewcombitrans[0]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
    2945           1 :                                                                         -                                yscrewvertex[1],
    2946           1 :                                                                                                          0.5*fgkSSDMountingBlockHeight[0]
    2947           1 :                                                                         -                                fgkSSDMountingBlockHeight[2]
    2948           2 :                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
    2949           1 :                                                                         +                                fgkSSDMountingBlockHeight[2]
    2950           1 :                                                                         -                                yvertex[0]));
    2951           2 :   ssdmountingblockscrewcombitrans[1]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
    2952           1 :                                                                                                         -0.5*fgkSSDMountingBlockScrewHoleEdge,
    2953           1 :                                                                                                                  yscrewvertex[1]
    2954           2 :                                                                                                         -0.5*(-0.5*fgkSSDMountingBlockHeight[0]
    2955           1 :                                                                                                          +fgkSSDMountingBlockHeight[2]
    2956           1 :                                                                                                          -yvertex[0]));
    2957           2 :   ssdmountingblockscrewcombitrans[2]->SetTranslation(-0.5*fgkSSDMountingBlockScrewHoleEdge,
    2958           1 :                                                                                                           yscrewvertex[1],
    2959           1 :                                                                         -                                 0.5*fgkSSDMountingBlockHeight[0]
    2960           1 :                                                                         +                                 fgkSSDMountingBlockHeight[2]
    2961           1 :                                                                         -                                 0.5*(-0.5*fgkSSDMountingBlockHeight[0]
    2962             :                                                                         +                                 fgkSSDMountingBlockHeight[2]
    2963           1 :                                                                         -                                 yvertex[0]));
    2964           2 :   ssdmountingblockscrewcombitrans[3]->SetTranslation(0.5*fgkSSDMountingBlockScrewHoleEdge,
    2965           1 :                                                                                                          yscrewvertex[1],
    2966           1 :                                                                         -                                yscrewvertex[1]
    2967           2 :                                                                         +                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
    2968           1 :                                                                         +                                fgkSSDMountingBlockHeight[2]
    2969           1 :                                                                         -                                yvertex[0]));
    2970           1 :   TGeoRotation* ssdmountingblockscrewrot[4];
    2971          14 :   for(Int_t i=0; i<4; i++) ssdmountingblockscrewrot[i] = new TGeoRotation();
    2972           1 :         ssdmountingblockscrewrot[1]->SetAngles(90.,-180.,-90.);      
    2973           1 :     ssdmountingblockscrewrot[2]->SetAngles(0.,180.,0.);      
    2974           1 :     ssdmountingblockscrewrot[3]->SetAngles(180.,0.,0.);      
    2975           8 :   for(Int_t i=1; i<4; i++) 
    2976           3 :         ssdmountingblockscrewcombitrans[i]->SetRotation(*ssdmountingblockscrewrot[i]);
    2977           1 :   TGeoRotation* ssdmountingblockglobalrot = new TGeoRotation();
    2978           1 :   ssdmountingblockglobalrot->SetAngles(0.,90.,0.);   
    2979           1 :   TGeoTranslation* ssdmountingblockglobaltrans = new TGeoTranslation();
    2980           2 :   ssdmountingblockglobaltrans->SetTranslation(0.5*fgkSSDMountingBlockLength[0]
    2981           1 :                                                          +                                xvertex[0],yscrewvertex[1]
    2982           2 :                                                          -                                0.5*(-0.5*fgkSSDMountingBlockHeight[0]
    2983           1 :                                                          +                                fgkSSDMountingBlockHeight[2]
    2984           1 :                                                          -                                yvertex[0]),0.);      
    2985           1 :   TGeoHMatrix* ssdmountingblockscrewmatrix[4];
    2986          10 :   for(Int_t i=0; i<4; i++){
    2987           4 :         ssdmountingblockscrewmatrix[i] = 
    2988           8 :                 new TGeoHMatrix((*ssdmountingblockglobalrot)*(*ssdmountingblockscrewcombitrans[i])); 
    2989           4 :         ssdmountingblockscrewmatrix[i]->MultiplyLeft(ssdmountingblockglobaltrans);
    2990             :   }
    2991             :   ///////////////////////////////////////////////////////////////////////
    2992             :   // TGeoXtru for Mother Volume 
    2993             :   ///////////////////////////////////////////////////////////////////////
    2994             :   const Int_t kvertexmothernumber = 12;
    2995           1 :   Double_t xmothervertex[kvertexmothernumber];
    2996           1 :   Double_t ymothervertex[kvertexmothernumber];
    2997          14 :   for(Int_t i=0; i<6; i++){
    2998           6 :         xmothervertex[i] = xvertex[i];
    2999           6 :         ymothervertex[i] = yvertex[i];
    3000             :   } 
    3001           1 :   xmothervertex[6]  = xvertex[5]+fgkSSDMountingBlockLength[2];
    3002           1 :   ymothervertex[6]  = ymothervertex[5];
    3003           1 :   xmothervertex[7]  = xmothervertex[6];
    3004           1 :   ymothervertex[7]  = ymothervertex[4] - fgkSSDTolerance;
    3005           2 :   xmothervertex[8]  = xmothervertex[7]
    3006           2 :                                         + 0.5*(fgkSSDMountingBlockLength[1]
    3007           1 :                                         -          fgkSSDMountingBlockLength[2]);
    3008           1 :   ymothervertex[8]  = ymothervertex[7];
    3009           1 :   xmothervertex[9]  = xmothervertex[8];
    3010           1 :   ymothervertex[9]  = ymothervertex[2];
    3011           1 :   xmothervertex[10] = xvertex[0]+fgkSSDMountingBlockLength[0];
    3012           1 :   ymothervertex[10] = ymothervertex[1];
    3013           1 :   xmothervertex[11] = xmothervertex[10];
    3014           1 :   ymothervertex[11] = ymothervertex[0];  
    3015           1 :   TGeoXtru* ssdmountingblockmothershape = new TGeoXtru(2);
    3016           1 :   ssdmountingblockmothershape->DefinePolygon(kvertexmothernumber,xmothervertex,ymothervertex);
    3017           1 :   ssdmountingblockmothershape->DefineSection(0,-0.5*fgkSSDMountingBlockWidth);
    3018           1 :   ssdmountingblockmothershape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
    3019           2 :   TGeoVolume* ssdmountingblockmother = new TGeoVolume("SSDMountingBlockMother",
    3020           1 :                                                                           ssdmountingblockmothershape,
    3021           1 :                                                                                   fSSDAir);
    3022             :   /////////////////////////////////////////////////////////////
    3023             :   // Placing the Volumes into Mother Volume 
    3024             :   /////////////////////////////////////////////////////////////
    3025           1 :   ssdmountingblockmother->AddNode(ssdmountingblock,1);
    3026           1 :   ssdmountingblockmother->AddNode(ssdmountingblock,2,mountingblockcombitrans);
    3027          10 :   for(Int_t i=0; i<4; i++) 
    3028           8 :         ssdmountingblockmother->AddNode(ssdmountingblockscrew,i+1,
    3029           4 :                                                                         ssdmountingblockscrewmatrix[i]);
    3030             :   /////////////////////////////////////////////////////////////
    3031             :   // Deallocating memory
    3032             :   /////////////////////////////////////////////////////////////
    3033           2 :   delete mountingblockrot;
    3034          18 :   for(Int_t i=0; i<4; i++) delete ssdmountingblockscrewrot[i];
    3035           2 :   delete ssdmountingblockglobalrot; 
    3036           2 :   delete ssdmountingblockglobaltrans; 
    3037             :   /////////////////////////////////////////////////////////////
    3038           1 :   return ssdmountingblockmother;
    3039           1 : }
    3040             : ///////////////////////////////////////////////////////////////////////////////
    3041             :  TGeoVolume* AliITSv11GeometrySSD::GetMountingBlockClip() const {
    3042             :   /////////////////////////////////////////////////////////////
    3043             :   // Method generating the Mounting Block Clip 
    3044             :   /////////////////////////////////////////////////////////////  
    3045             :   const Int_t kmothervertexnumber = 10;
    3046           2 :   Double_t xmothervertex[kmothervertexnumber];
    3047           1 :   Double_t ymothervertex[kmothervertexnumber];
    3048           2 :   xmothervertex[0] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1])
    3049           1 :                                    - 0.5*(fgkSSDSensorWidth-fgkSSDMountingBlockLength[0]); 
    3050           1 :   xmothervertex[1] = xmothervertex[0];
    3051           2 :   xmothervertex[2] = xmothervertex[0]+0.5*(fgkMountingBlockClibScrewPosition
    3052           1 :                                    - fgkMountingBlockClibScrewRadius);
    3053           1 :   xmothervertex[3] = xmothervertex[2]; 
    3054           1 :   xmothervertex[4] = xmothervertex[3]+2.*fgkMountingBlockClibScrewRadius; 
    3055           1 :   xmothervertex[5] = xmothervertex[4]; 
    3056           1 :   xmothervertex[6] = xmothervertex[0]+fgkMountingBlockClipLength; 
    3057           1 :   xmothervertex[7] = xmothervertex[6]; 
    3058           1 :   xmothervertex[8] = -0.25*(fgkSSDMountingBlockLength[0]-fgkSSDMountingBlockLength[1]); 
    3059           1 :   xmothervertex[9] = xmothervertex[8]; 
    3060           2 :   ymothervertex[0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor
    3061           1 :                                + fgkSSDMountingBlockHeight[1]-0.5*fgkSSDMountingBlockHeight[0];
    3062           1 :   ymothervertex[1] = 0.5*fgkSSDMountingBlockHeight[0]+fgkMountingBlockClipThickness;
    3063           1 :   ymothervertex[2] = ymothervertex[1];
    3064           2 :   ymothervertex[3] = ymothervertex[2]+(fgkSSDMountingBlockHeight[1]
    3065           1 :                                    - fgkSSDMountingBlockHeight[0]-fgkMountingBlockClipThickness
    3066           1 :                                    - 0.5*fgkCoolingTubeSupportHeight-fgkCoolingTubeSupportRmax);
    3067           1 :   ymothervertex[4] = ymothervertex[3];
    3068           1 :   ymothervertex[5] = ymothervertex[2];
    3069           1 :   ymothervertex[6] = ymothervertex[5];
    3070           1 :   ymothervertex[7] = ymothervertex[6]-fgkMountingBlockClipThickness;
    3071           1 :   ymothervertex[8] = ymothervertex[7];
    3072           1 :   ymothervertex[9] = ymothervertex[0];
    3073             : 
    3074             :   ///////////////////////////////////////////////////////////////////////
    3075             :   // TGeoXTru Volume definition for Mounting Block Clip Part
    3076             :   ///////////////////////////////////////////////////////////////////////
    3077           1 :   TGeoXtru* ssdmountingblockclipshape = new TGeoXtru(2);
    3078           1 :   ssdmountingblockclipshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
    3079           1 :   ssdmountingblockclipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
    3080           1 :   ssdmountingblockclipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
    3081           2 :   TGeoVolume* ssdmountingblockclip = new TGeoVolume("SSDMountingBlockClip",
    3082           1 :                                                                           ssdmountingblockclipshape,fSSDAir);
    3083           1 :   ssdmountingblockclip->SetLineColor(4);
    3084             :   ///////////////////////////////////////////////////////////////////////
    3085             :   // TGeoXTru Volume definition for Clip 
    3086             :   ///////////////////////////////////////////////////////////////////////
    3087             :   const Int_t kclipvertexnumber = 6;
    3088           1 :   Double_t xclipvertex[kclipvertexnumber];
    3089           1 :   Double_t yclipvertex[kclipvertexnumber];
    3090           1 :   xclipvertex[0] = xmothervertex[0];
    3091           1 :   xclipvertex[1] = xclipvertex[0];
    3092           1 :   xclipvertex[2] = xmothervertex[6];
    3093           1 :   xclipvertex[3] = xclipvertex[2];
    3094           1 :   xclipvertex[4] = xclipvertex[0]+fgkMountingBlockClipThickness;
    3095           1 :   xclipvertex[5] = xclipvertex[4];
    3096           1 :   yclipvertex[0] = ymothervertex[0];
    3097           1 :   yclipvertex[1] = ymothervertex[1];
    3098           1 :   yclipvertex[2] = yclipvertex[1];
    3099           1 :   yclipvertex[3] = yclipvertex[1]-fgkMountingBlockClipThickness;
    3100           1 :   yclipvertex[4] = yclipvertex[3];
    3101           1 :   yclipvertex[5] = yclipvertex[0];
    3102           1 :   TGeoXtru* clipshape = new TGeoXtru(2);
    3103           1 :   clipshape->DefinePolygon(kclipvertexnumber,xclipvertex,yclipvertex);
    3104           1 :   clipshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockClibWidth);
    3105           2 :   clipshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]
    3106           1 :                                                          +   fgkMountingBlockClibWidth);
    3107           1 :   TGeoVolume* clip = new TGeoVolume("SSDClip",clipshape,fSSDMountingBlockMedium);
    3108           1 :   clip->SetLineColor(18);
    3109             :   ///////////////////////////////////////////////////////////////////////
    3110             :   // Ladder Support Piece  
    3111             :   ///////////////////////////////////////////////////////////////////////
    3112             :   const Int_t ksupportvertexnumber = 4;
    3113           1 :   Double_t xsupportvertex[ksupportvertexnumber];
    3114           1 :   Double_t ysupportvertex[ksupportvertexnumber];
    3115           1 :   xsupportvertex[0] = xclipvertex[5];
    3116           1 :   xsupportvertex[1] = xsupportvertex[0];
    3117           1 :   xsupportvertex[2] = xmothervertex[9];
    3118           1 :   xsupportvertex[3] = xsupportvertex[2];
    3119           1 :   ysupportvertex[0] = yclipvertex[0];
    3120           1 :   ysupportvertex[1] = yclipvertex[3];
    3121           1 :   ysupportvertex[2] = ysupportvertex[1];
    3122           1 :   ysupportvertex[3] = ysupportvertex[0];
    3123           1 :   TGeoXtru* supportshape = new TGeoXtru(2);
    3124           1 :   supportshape->DefinePolygon(ksupportvertexnumber,xsupportvertex,ysupportvertex);
    3125           1 :   supportshape->DefineSection(0,0.5*fgkSSDMountingBlockWidth-fgkMountingBlockSupportWidth[0]);
    3126           1 :   supportshape->DefineSection(1,0.5*fgkSSDMountingBlockWidth);
    3127           1 :   TGeoVolume* support = new TGeoVolume("RingSupport",supportshape,fSSDMountingBlockMedium);
    3128           1 :   support->SetLineColor(9);
    3129             :   ///////////////////////////////////////////////////////////////////////
    3130             :   // TGeoXTru Volume definition for Screw   
    3131             :   ///////////////////////////////////////////////////////////////////////
    3132           2 :   Double_t radius[2] = {fgkMountingBlockClibScrewRadius,
    3133           1 :                                                 0.5*fgkMountingBlockClibScrewRadius};
    3134           1 :   Int_t edgesnumber[2] = {50,6};
    3135           2 :   Double_t section[2] = {-0.5*(ymothervertex[3]-ymothervertex[2]),
    3136           1 :                                                  +0.5*(ymothervertex[3]-ymothervertex[2])};
    3137           1 :   TGeoShape* clipscrewshape = GetScrewShape(radius,edgesnumber,section);
    3138           1 :   TGeoVolume* clipscrew = new TGeoVolume("ClipScrewShape",clipscrewshape,fSSDSupportRingAl);
    3139           1 :   clipscrew->SetLineColor(12);
    3140           1 :   TGeoRotation* screwrot = new TGeoRotation();
    3141           1 :   screwrot->SetAngles(0.,90.,0.);
    3142           1 :   TGeoTranslation* screwtrans = new TGeoTranslation();
    3143           2 :   screwtrans->SetTranslation(xmothervertex[3]+fgkMountingBlockClibScrewRadius,
    3144           1 :                                                          0.5*(ymothervertex[3]+ymothervertex[2]),
    3145           2 :                                                          0.5*fgkSSDMountingBlockWidth+
    3146           1 :                                                         -0.5*fgkMountingBlockSupportWidth[0]);
    3147           1 :   TGeoCombiTrans* screwcombitrans = new TGeoCombiTrans(*screwtrans,*screwrot);
    3148             :   ///////////////////////////////////////////////////////////////////////
    3149             :   // Placing the Volumes
    3150             :   ///////////////////////////////////////////////////////////////////////
    3151           1 :   ssdmountingblockclip->AddNode(clip,1);
    3152           1 :   ssdmountingblockclip->AddNode(support,1);
    3153           1 :   ssdmountingblockclip->AddNode(clipscrew,1,screwcombitrans);
    3154             :   /////////////////////////////////////////////////////////////
    3155             :   // Deallocating memory
    3156             :   /////////////////////////////////////////////////////////////  
    3157           2 :   delete screwtrans;
    3158           2 :   delete screwrot;
    3159             :   /////////////////////////////////////////////////////////////
    3160           1 :   return ssdmountingblockclip;
    3161           1 : }
    3162             : ///////////////////////////////////////////////////////////////////////////////
    3163             : void AliITSv11GeometrySSD::CreateCoolingTubes() {
    3164             :   /////////////////////////////////////////////////////////////
    3165             :   // Method generating the Cooling Tube 
    3166             :   // sets fcoolingtube and returns list for endladdercoolingtube
    3167             :   /////////////////////////////////////////////////////////////  
    3168             :   TGeoTube *coolingtubeshape[2];
    3169             :   // Ladder Cooling Tubes
    3170             : 
    3171             :   // MvL: Simplified cooling tubes
    3172           2 :   coolingtubeshape[0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,0.5*fgkCoolingTubeLength);
    3173           2 :   coolingtubeshape[1] = new TGeoTube(0.0,fgkCoolingTubeRmin,coolingtubeshape[0]->GetDz());
    3174             : 
    3175             :   // End Ladder Cooling Tubes   
    3176           1 :   TGeoTube** endladdercoolingtubeshape[fgkendladdercoolingtubenumber];
    3177           6 :   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
    3178           2 :     endladdercoolingtubeshape[i] = new  TGeoTube*[2];
    3179             : 
    3180           1 :   Double_t sensZshift = 0.5*fgkCarbonFiberJunctionWidth - fgkCarbonFiberLowerSupportWidth - fgkLowerSupportToSensorZ;
    3181           3 :   endladdercoolingtubeshape[0][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
    3182           1 :                                                  0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[0] - sensZshift));
    3183           3 :   endladdercoolingtubeshape[0][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
    3184           1 :                                                  endladdercoolingtubeshape[0][0]->GetDz());
    3185           3 :   endladdercoolingtubeshape[1][0] = new TGeoTube(fgkCoolingTubeRmin,fgkCoolingTubeRmax,
    3186           1 :                                                  0.5*(fgkEndLadderCarbonFiberLowerJunctionLength[1] + sensZshift));
    3187           3 :   endladdercoolingtubeshape[1][1] = new TGeoTube(0.0,fgkCoolingTubeRmin,
    3188           2 :                                                  endladdercoolingtubeshape[1][0]->GetDz()-0.5*fgkSSDTolerance);
    3189             :   // Ladder Cooling Tubes
    3190             :   TGeoVolume* coolingtube[2];
    3191           1 :   coolingtube[0] = new TGeoVolume("OuterCoolingTube1",coolingtubeshape[0], fSSDCoolingTubePhynox);
    3192           1 :   coolingtube[1] = new TGeoVolume("InnerCoolingTube1",coolingtubeshape[1], fSSDCoolingTubeWater);
    3193           1 :   coolingtube[0]->SetLineColor(fColorPhynox);
    3194           1 :   coolingtube[1]->SetLineColor(fColorWater);
    3195             : 
    3196             :   // End Ladder Cooling Tubes   
    3197           1 :   TGeoVolume** endladdercoolingtube[fgkendladdercoolingtubenumber];
    3198           6 :   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++) 
    3199           2 :     endladdercoolingtube[i] = new TGeoVolume*[2];
    3200           3 :   endladdercoolingtube[0][0] = new TGeoVolume("OuterEndLadderCoolingTube1",
    3201           1 :                                               endladdercoolingtubeshape[0][0],
    3202           1 :                                               fSSDCoolingTubePhynox);
    3203           3 :   endladdercoolingtube[0][1] = new TGeoVolume("InnerEndlLadderCoolingTube1",
    3204           1 :                                               endladdercoolingtubeshape[0][1],
    3205           1 :                                               fSSDCoolingTubeWater);
    3206           3 :   endladdercoolingtube[1][0] = new TGeoVolume("OuterEndLadderCoolingTube2",
    3207           1 :                                               endladdercoolingtubeshape[1][0],
    3208           1 :                                               fSSDCoolingTubePhynox);
    3209           3 :   endladdercoolingtube[1][1] = new TGeoVolume("InnerEndlLadderCoolingTube2",
    3210           1 :                                               endladdercoolingtubeshape[1][1],
    3211           1 :                                               fSSDCoolingTubeWater);
    3212           6 :   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++){
    3213           2 :     endladdercoolingtube[i][0]->SetLineColor(fColorPhynox);
    3214           2 :     endladdercoolingtube[i][1]->SetLineColor(fColorWater);
    3215             :   }
    3216             :   
    3217             :   /////////////////////////////////////////////////////////////
    3218             :   // Virtual Volume containing Cooling Tubes
    3219             :   /////////////////////////////////////////////////////////////
    3220             :   // Ladder Cooling Tubes
    3221           2 :   TGeoTube* virtualcoolingtubeshape = new TGeoTube(coolingtubeshape[1]->GetRmin(),
    3222           1 :                                                    coolingtubeshape[0]->GetRmax(),
    3223           1 :                                                    coolingtubeshape[0]->GetDz());
    3224           2 :   fcoolingtube = new TGeoVolume("CoolingTube1",virtualcoolingtubeshape, fSSDAir);
    3225           1 :   fcoolingtube->AddNode(coolingtube[0],1);
    3226           1 :   fcoolingtube->AddNode(coolingtube[1],1);
    3227             : 
    3228             :   // End Ladder Cooling Tubes
    3229           1 :   TGeoTube* endladdervirtualcoolingtubeshape[fgkendladdercoolingtubenumber];
    3230           6 :   for(Int_t i=0; i<fgkendladdercoolingtubenumber; i++)
    3231           6 :     endladdervirtualcoolingtubeshape[i] = new TGeoTube(endladdercoolingtubeshape[i][1]->GetRmin(),
    3232           2 :                                                        endladdercoolingtubeshape[i][0]->GetRmax(),
    3233           2 :                                                        endladdercoolingtubeshape[i][0]->GetDz());
    3234           3 :   fendladdercoolingtube[0] = new TGeoVolume("EndLadderCoolingTube1",
    3235           1 :                                             endladdervirtualcoolingtubeshape[0],
    3236           1 :                                             fSSDAir);
    3237           3 :   fendladdercoolingtube[1] = new TGeoVolume("EndLadderCoolingTube2",
    3238           1 :                                             endladdervirtualcoolingtubeshape[1],
    3239           1 :                                             fSSDAir);
    3240           1 :   fendladdercoolingtube[0]->AddNode(endladdercoolingtube[0][0],1);
    3241           1 :   fendladdercoolingtube[0]->AddNode(endladdercoolingtube[0][1],1);
    3242           1 :   fendladdercoolingtube[1]->AddNode(endladdercoolingtube[1][0],1);
    3243           1 :   fendladdercoolingtube[1]->AddNode(endladdercoolingtube[1][1],1);  
    3244           1 : }
    3245             : ///////////////////////////////////////////////////////////////////////////////
    3246             : TGeoVolume* AliITSv11GeometrySSD::GetSSDCoolingBlock(Int_t nedges){
    3247             :   /////////////////////////////////////////////////////////////
    3248             :   // Method generating SSD Cooling Block    
    3249             :   /////////////////////////////////////////////////////////////
    3250             :   const Int_t kvertexnumber = 8;
    3251             :   ///////////////////////////////////////
    3252             :   // Vertex Positioning for TGeoXTru
    3253             :   ///////////////////////////////////////
    3254           2 :   TVector3** vertexposition = new TVector3*[2*kvertexnumber+nedges+1];
    3255           2 :   vertexposition[0] = new TVector3(0.0,0.0, 0.);
    3256           2 :   vertexposition[1] = new TVector3(0.0,fgkSSDCoolingBlockHeight[1],0);
    3257           3 :   vertexposition[2] = new TVector3(fgkSSDCoolingBlockHoleLength[1],
    3258           1 :                                    vertexposition[1]->Y(),0);
    3259           3 :   vertexposition[3] = new TVector3(vertexposition[2]->X(),
    3260           1 :                                    vertexposition[2]->Y()+fgkSSDCoolingBlockHeight[2],0);
    3261           2 :   vertexposition[4] = new TVector3(vertexposition[1]->X(),vertexposition[3]->Y(),0);
    3262           3 :   vertexposition[5] = new TVector3(vertexposition[4]->X(),
    3263           1 :                                    + vertexposition[3]->Y()+fgkSSDCoolingBlockHoleRadius[1],0);
    3264           4 :   vertexposition[6] = new TVector3(Xfrom2Points(vertexposition[5]->X(),
    3265           2 :                                           vertexposition[5]->Y(),0.5*(fgkSSDCoolingBlockLength
    3266           1 :                                         - fgkSSDCoolingBlockHoleLength[0]
    3267           1 :                                         - 4.*fgkSSDCoolingBlockHoleRadius[1]),
    3268           1 :                                           fgkSSDCoolingBlockHeight[0]
    3269           1 :                                         - fgkSSDCoolingBlockHoleRadius[1],
    3270           1 :                                                 fgkSSDCoolingBlockHeight[0]),fgkSSDCoolingBlockHeight[0], 0);
    3271           4 :   vertexposition[7] = new TVector3(0.5*(fgkSSDCoolingBlockLength
    3272           1 :                                         - fgkSSDCoolingBlockHoleLength[0]),
    3273           1 :                                    vertexposition[6]->Y(), 0);
    3274           2 :   Double_t alpha = TMath::ACos(0.5*fgkSSDCoolingBlockHoleLength[0]
    3275           2 :                            / fgkSSDCoolingBlockHoleRadius[0])*TMath::RadToDeg();
    3276           1 :   Double_t phi = 180.-alpha;
    3277           1 :   Double_t psi = 180.+2.*alpha;
    3278           1 :   Double_t deltapsi = psi/nedges;
    3279           1 :   Double_t radius = fgkSSDCoolingBlockHoleRadius[0]/CosD(0.5*deltapsi);
    3280           2 :   TVector3* transvector = new TVector3(0.5*fgkSSDCoolingBlockLength,
    3281           1 :                                        fgkSSDCoolingBlockHoleCenter, 0);
    3282          64 :   for(Int_t i=0; i<nedges+1; i++){
    3283         124 :         vertexposition[kvertexnumber+i] = new TVector3(radius*CosD(phi+i*deltapsi),
    3284          62 :                                                    radius*SinD(phi+i*deltapsi),
    3285             :                                                    0);
    3286          31 :    *vertexposition[kvertexnumber+i] += (*transvector);
    3287             :   }
    3288           1 :   Double_t param[4] = {1.0,0.0,0.0,-0.5*fgkSSDCoolingBlockLength};  
    3289          18 :   for(Int_t i=0; i<kvertexnumber; i++)
    3290           8 :     vertexposition[kvertexnumber+nedges+1+i] = 
    3291           8 :                                                 GetReflection(vertexposition[kvertexnumber-1-i],param);
    3292             :   ///////////////////////////////////////////////////////////////////////
    3293             :   // TGeoXTru Volume definition for Cooling Tube Support Arc Part
    3294             :   ///////////////////////////////////////////////////////////////////////
    3295           1 :   TGeoXtru* ssdcoolingblockshape = new TGeoXtru(2);     
    3296           1 :   Double_t* xvertexpoints = new Double_t[2*kvertexnumber+nedges+1]; 
    3297           1 :   Double_t* yvertexpoints = new Double_t[2*kvertexnumber+nedges+1];
    3298          96 :   for(Int_t i=0; i<2*kvertexnumber+nedges+1; i++){
    3299          47 :         xvertexpoints[i] = vertexposition[i]->X();
    3300          47 :         yvertexpoints[i] = vertexposition[i]->Y();
    3301             :   } 
    3302           1 :   ssdcoolingblockshape->DefinePolygon(2*kvertexnumber+nedges+1,xvertexpoints,
    3303             :                                                                                         yvertexpoints);
    3304           1 :   ssdcoolingblockshape->DefineSection(0,-0.5*fgkSSDCoolingBlockWidth);
    3305           1 :   ssdcoolingblockshape->DefineSection(1,0.5*fgkSSDCoolingBlockWidth);
    3306           2 :   TGeoVolume* ssdcoolingblock = new TGeoVolume("SSDCoolingBlock",
    3307           1 :                                                                           ssdcoolingblockshape,
    3308           1 :                                                                                   fSSDAlCoolBlockMedium);
    3309           1 :   ssdcoolingblock->SetLineColor(fColorAl);
    3310             :   /////////////////////////////////////////////////////////////
    3311             :   // Deallocating memory
    3312             :   /////////////////////////////////////////////////////////////
    3313           2 :   delete [] vertexposition;
    3314           2 :   delete [] xvertexpoints;
    3315           2 :   delete [] yvertexpoints;
    3316             :   /////////////////////////////////////////////////////////////
    3317           1 :   return ssdcoolingblock;
    3318           1 : }
    3319             : /////////////////////////////////////////////////////////////////////////////////
    3320             : void AliITSv11GeometrySSD::GetSSDChipCables(TGeoVolume *&cableL, TGeoVolume *&cableR, Double_t SSDChipCablesHeight, Int_t nedges){
    3321             :   ///////////////////////////////////////////////////////
    3322             :   static const Int_t kssdchipcablesnumber    = 2;  // Number of cables: left and right
    3323             :   static const Int_t kssdchipcableslaynumber = 2;  // Number of layers: Al and Kapton
    3324           6 :   static const Int_t kvertexnumber                        = 4*(nedges+1)+4;
    3325           2 :   Int_t ssdchipcablescolor[kssdchipcableslaynumber] = {fColorAl,fColorPolyhamide};
    3326             :   Double_t ssdchipcablesradius[kssdchipcableslaynumber];
    3327           2 :   ssdchipcablesradius[0] = 0.25*(SSDChipCablesHeight
    3328           2 :                                                  -  fgkSSDChipCablesHeight[0]
    3329           2 :                                                  -  fgkSSDChipCablesHeight[1]);
    3330           2 :   ssdchipcablesradius[1] = ssdchipcablesradius[0]-fgkSSDChipCablesHeight[0];
    3331           2 :   Double_t ssdchipcablespiecelength[kssdchipcablesnumber];
    3332           4 :   ssdchipcablespiecelength[0] = 0.5*(fgkSSDChipCablesWidth[0]
    3333           2 :                                                           - 2.*TMath::Pi()*ssdchipcablesradius[0]
    3334           2 :                                                           - ssdchipcablesradius[0]
    3335           2 :                                                           - fgkSSDChipCablesWidth[1]
    3336           2 :                                                           - fgkSSDChipCablesWidth[2]);
    3337           2 :   ssdchipcablespiecelength[1] = ssdchipcablespiecelength[0]
    3338           4 :                                                           - 0.5*(fgkSSDModuleStiffenerPosition[1]                                                         
    3339           2 :                                                           +      fgkSSDChipCablesHeight[1]
    3340           2 :                                                           +      fgkSSDSensorHeight);
    3341             :   ///////////////////////////////////////////////////////
    3342             :   // Vertex Positioning for TGeoXTrue Layer 1 and Layer 2
    3343             :   ///////////////////////////////////////////////////////
    3344           2 :   TVector3** vertexposition[kssdchipcableslaynumber];
    3345          12 :   for(Int_t i=0; i<kssdchipcableslaynumber; i++) vertexposition[i] = 
    3346           4 :                                                                                                   new TVector3*[4*(nedges+1)+4];
    3347           2 :   Double_t ratio[4];
    3348           2 :   ratio[0] = ssdchipcablesradius[1]/ssdchipcablesradius[0]; 
    3349           4 :   ratio[1] = (ssdchipcablesradius[1]-fgkSSDChipCablesHeight[1])
    3350           2 :                    /  ssdchipcablesradius[0]; 
    3351           4 :   ratio[2] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0])
    3352           2 :                    /  ssdchipcablesradius[0];
    3353           4 :   ratio[3] = (ssdchipcablesradius[0]+fgkSSDChipCablesHeight[0]
    3354           2 :                    +  fgkSSDChipCablesHeight[1])
    3355           2 :                    /  ssdchipcablesradius[0];
    3356             :   Double_t phi = 180.;
    3357           2 :   Double_t deltaphi = 180./nedges;
    3358             :   Double_t angle = 0.0;
    3359             : 
    3360           2 :   Double_t xvertexpoints[kssdchipcableslaynumber][kvertexnumber];
    3361           2 :   Double_t yvertexpoints[kssdchipcableslaynumber][kvertexnumber];
    3362             : 
    3363           2 :   TVector3* vertex = new TVector3();
    3364           2 :   TVector3* transvector[kssdchipcableslaynumber];
    3365           6 :   transvector[0] = new TVector3(fgkSSDChipWidth,
    3366           2 :                                 SSDChipCablesHeight-ssdchipcablesradius[0], 0);
    3367           4 :   transvector[1] = new TVector3();
    3368           2 :   TGeoXtru* ssdchipcableshape[kssdchipcableslaynumber*kssdchipcablesnumber];
    3369           2 :   TGeoVolume* ssdchipcable[kssdchipcableslaynumber*kssdchipcablesnumber];
    3370           2 :   const char* ssdchipcablename[kssdchipcableslaynumber*kssdchipcablesnumber] = 
    3371             :                 {"SSDChipcableAllay1Left","SSDChipcableKaptonlay2Left",
    3372             :                  "SSDChipcableAllay1Right","SSDChipcableKaptonlay2Right"};
    3373          12 :   for(Int_t k=0; k<kssdchipcablesnumber; k++){
    3374           4 :         transvector[1]->SetX(fgkSSDChipWidth-ssdchipcablespiecelength[k]);
    3375           8 :         transvector[1]->SetY(ssdchipcablesradius[0]
    3376           4 :                                  +               fgkSSDChipCablesHeight[0]
    3377           4 :                                  +               fgkSSDChipCablesHeight[1]);  
    3378          24 :         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
    3379          24 :                 vertexposition[i][0] = new TVector3(0.,SSDChipCablesHeight
    3380           8 :                                               - fgkSSDChipCablesHeight[0]-i*fgkSSDChipCablesHeight[1], 0);
    3381          24 :                 vertexposition[i][1] = new TVector3(0.,SSDChipCablesHeight
    3382           8 :                                                     - i*fgkSSDChipCablesHeight[0], 0);
    3383           8 :                 vertexposition[i][2*(nedges+1)+2] = 
    3384          16 :                                         new TVector3(fgkSSDChipWidth+ssdchipcablesradius[0]
    3385           8 :                                 +                                fgkSSDChipCablesWidth[1]
    3386           8 :                                 +                                fgkSSDChipCablesWidth[2],
    3387           8 :                                                                 ((1.-i)*fgkSSDChipCablesHeight[i]
    3388           8 :                                 + fgkSSDChipCablesHeight[1]), 0);
    3389           8 :         vertexposition[i][2*(nedges+1)+3] = 
    3390          16 :                                         new TVector3(vertexposition[i][2*(nedges+1)+2]->X(),
    3391           8 :                                                                  vertexposition[i][2*(nedges+1)+2]->Y()
    3392           8 :                        - fgkSSDChipCablesHeight[i], 0);
    3393         112 :             for(Int_t j=0; j<nedges+1; j++){                 
    3394          48 :                     angle = 0.5*phi+TMath::Power(-1,i+1)*j*deltaphi;
    3395          48 :                         vertex->SetX(ssdchipcablesradius[0]*CosD(angle));
    3396          48 :                         vertex->SetY(ssdchipcablesradius[0]*SinD(angle));
    3397          48 :                         vertexposition[0][(nedges+1)*i+j+2] = 
    3398          48 :                                                 new TVector3(*vertex+*transvector[i]);
    3399          48 :                         vertexposition[1][(nedges+1)*i+j+2] = 
    3400          96 :                                                 new TVector3(vertex->X()*ratio[2*i]+transvector[i]->X(),
    3401          48 :                                        vertex->Y()*ratio[2*i]+transvector[i]->Y(), 0);
    3402          48 :                         vertexposition[0][(4-i)*(nedges+1)+4-j-1] = 
    3403          48 :                                                 new TVector3(*vertexposition[1][(nedges+1)*i+j+2]);
    3404          48 :                         vertexposition[1][(4-i)*(nedges+1)+4-j-1] = 
    3405          96 :                                                 new TVector3(vertex->X()*ratio[2*i+1]
    3406          48 :                                                         +                        transvector[i]->X(),
    3407          48 :                                                                                  vertex->Y()*ratio[2*i+1]
    3408          48 :                                        + transvector[i]->Y(), 0);
    3409             :                 }
    3410             :         }
    3411          24 :         for(Int_t i=0; i<kssdchipcableslaynumber; i++){
    3412         464 :                 for(Int_t j=0; j<kvertexnumber; j++){        
    3413         224 :                         xvertexpoints[i][j] = vertexposition[i][j]->X();
    3414         224 :                         yvertexpoints[i][j] = vertexposition[i][j]->Y();
    3415             :                 }
    3416          16 :                 ssdchipcableshape[kssdchipcablesnumber*k+i] = new TGeoXtru(2);
    3417          16 :                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefinePolygon(kvertexnumber,
    3418           8 :                                                                                 xvertexpoints[i],yvertexpoints[i]);
    3419           8 :                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
    3420           8 :                 ssdchipcableshape[kssdchipcablesnumber*k+i]->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
    3421           8 :                 ssdchipcable[kssdchipcablesnumber*k+i] = 
    3422          16 :                                 new TGeoVolume(ssdchipcablename[kssdchipcablesnumber*k+i],
    3423           8 :                                                            ssdchipcableshape[kssdchipcablesnumber*k+i],
    3424          24 :                                                           (kssdchipcablesnumber*k+i)%2==0?
    3425           8 :                                                            fSSDAlTraceChipCableMedium:fSSDKaptonChipCableMedium);
    3426           8 :                 ssdchipcable[kssdchipcablesnumber*k+i]->SetLineColor(ssdchipcablescolor[i]);
    3427             :         }
    3428          24 :         for(Int_t i=0; i<kssdchipcableslaynumber; i++)
    3429         912 :                 for(Int_t j=0; j<kvertexnumber; j++) delete vertexposition[i][j];
    3430             :   }
    3431             :   /////////////////////////////////////////////////////////////
    3432             :   // Mother Volume definition 
    3433             :   /////////////////////////////////////////////////////////////
    3434             :   static const Int_t kmothervertexnumber = 8;
    3435           2 :   Double_t xmothervertex[kmothervertexnumber];
    3436           2 :   Double_t ymothervertex[kmothervertexnumber];
    3437           2 :   xmothervertex[0] = xvertexpoints[0][1];
    3438           2 :   ymothervertex[0] = yvertexpoints[0][1];
    3439           2 :   xmothervertex[1] = xvertexpoints[0][2+nedges/2];
    3440           2 :   ymothervertex[1] = yvertexpoints[0][1];
    3441           2 :   xmothervertex[2] = xvertexpoints[0][2+nedges/2];
    3442           2 :   ymothervertex[2] = yvertexpoints[0][2+nedges];
    3443           2 :   xmothervertex[3] = xvertexpoints[0][3+nedges];
    3444           2 :   ymothervertex[3] = yvertexpoints[0][3+nedges];
    3445           2 :   xmothervertex[4] = xvertexpoints[0][3+2*nedges];
    3446           2 :   ymothervertex[4] = yvertexpoints[0][3+2*nedges]+fgkSSDTolerance;
    3447           2 :   xmothervertex[5] = xvertexpoints[0][4+2*nedges];
    3448           2 :   ymothervertex[5] = yvertexpoints[0][4+2*nedges]+fgkSSDTolerance;
    3449           2 :   xmothervertex[6] = xvertexpoints[1][5+2*nedges];
    3450           2 :   ymothervertex[6] = yvertexpoints[1][5+2*nedges];
    3451           2 :   xmothervertex[7] = xvertexpoints[0][1];
    3452           2 :   ymothervertex[7] = yvertexpoints[1][5+2*nedges];
    3453           2 :   TGeoXtru *ssdchipcablemothershape = new TGeoXtru(2);
    3454           2 :   ssdchipcablemothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);
    3455           2 :   ssdchipcablemothershape->DefineSection(0,-0.5*fgkSSDChipCablesLength[1]);
    3456           2 :   ssdchipcablemothershape->DefineSection(1,+0.5*fgkSSDChipCablesLength[1]);
    3457             : 
    3458           4 :   cableL = new TGeoVolume("SSDChipCableMotherLeft",ssdchipcablemothershape,fSSDAir);
    3459           4 :   cableR = new TGeoVolume("SSDChipCableMotherRight",ssdchipcablemothershape,fSSDAir);
    3460             : 
    3461           2 :   cableL->AddNode(ssdchipcable[0],1);
    3462           2 :   cableL->AddNode(ssdchipcable[1],1);
    3463           2 :   cableR->AddNode(ssdchipcable[2],1);
    3464           2 :   cableR->AddNode(ssdchipcable[3],1);  
    3465             : 
    3466             :   /////////////////////////////////////////////////////////////
    3467             :   // Deallocating memory
    3468             :   /////////////////////////////////////////////////////////////
    3469          20 :   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete [] vertexposition[i];
    3470          20 :   for(Int_t i=0; i<kssdchipcableslaynumber; i++) delete transvector[i];
    3471           4 :   delete vertex; 
    3472             :   /////////////////////////////////////////////////////////////
    3473           2 : }
    3474             : //_____________________________________________________________________________
    3475             : TGeoVolume* AliITSv11GeometrySSD::GetSSDChip() const{
    3476             :   /////////////////////////////////////////////////////////////
    3477             :   // SSD Chip Assembly Generation    
    3478             :   /////////////////////////////////////////////////////////////
    3479             :   TGeoBBox* ssdchipcompshape[2];
    3480           3 :   ssdchipcompshape[0] =  new TGeoBBox("SSDChipCompShape",
    3481           1 :                                                                                 0.5*fgkSSDChipLength,
    3482           1 :                                                                                 0.5*fgkSSDChipWidth,
    3483           1 :                                                                                 0.5*(fgkSSDChipHeight-fgkSSDChipGlueHeight));
    3484           2 :   ssdchipcompshape[1] =  new TGeoBBox("SSDChipGlueCompShape",
    3485           1 :                                                                                 0.5*fgkSSDChipLength,
    3486           1 :                                                                                 0.5*fgkSSDChipWidth,
    3487           1 :                                                                                 0.5*fgkSSDChipGlueHeight);
    3488           1 :   TGeoVolume* ssdchipcomp[2];
    3489           2 :   ssdchipcomp[0] = new TGeoVolume("SSDChipComp",ssdchipcompshape[0],fSSDChipMedium);
    3490           3 :   ssdchipcomp[1] = new TGeoVolume("SSDChipGlueComp",ssdchipcompshape[1],
    3491           1 :                                                                   fSSDChipGlueMedium);
    3492           1 :   ssdchipcomp[0]->SetLineColor(fColorSilicon);  
    3493           1 :   ssdchipcomp[1]->SetLineColor(fColorEpoxy);
    3494           1 :   TGeoTranslation* ssdchipcomptrans[2];
    3495           3 :   ssdchipcomptrans[0] = new TGeoTranslation(0.,0.,-ssdchipcompshape[1]->GetDZ());
    3496           3 :   ssdchipcomptrans[1] = new TGeoTranslation(0.,0.,ssdchipcompshape[0]->GetDZ());
    3497             :   /////////////////////////////////////////////////////////////
    3498             :   // Virtual Volume containing SSDChip   
    3499             :   /////////////////////////////////////////////////////////////
    3500           2 :   TGeoBBox* ssdvirtualchipshape = new TGeoBBox("SSDChipShape",0.5*fgkSSDChipLength,
    3501           1 :                                                                                                                  0.5*fgkSSDChipWidth,
    3502           1 :                                                                                                                  0.5*fgkSSDChipHeight);
    3503           1 :   TGeoVolume* ssdchip = new TGeoVolume("SSDChip",ssdvirtualchipshape,fSSDAir);
    3504             :   /////////////////////////////////////////////////////////////
    3505           6 :   for(Int_t i=0; i<2; i++) ssdchip->AddNode(ssdchipcomp[i],1,ssdchipcomptrans[i]);
    3506           1 :   return ssdchip;
    3507           1 : }
    3508             : /////////////////////////////////////////////////////////////////////////////////
    3509             : TList* AliITSv11GeometrySSD::GetLadderCableSegment(Double_t ssdendladdercablelength){
    3510             :   /////////////////////////////////////////////////////////////
    3511             :   // Method returning a List containing pointers to Ladder Cable Volumes    
    3512             :   //
    3513             :   // Return list contains 3 assemblies: cable box, cable arb shape and the end part of the cable
    3514             :   //                                    each contains 2 volumes, one for polyamide and one for aluminium
    3515             :   /////////////////////////////////////////////////////////////
    3516             :   const Int_t kladdercablesegmentnumber = 2;
    3517             :   /////////////////////////////////////////
    3518             :   // LadderSegmentBBox Volume
    3519             :   /////////////////////////////////////////
    3520             :   static TGeoBBox* laddercablesegmentbboxshape[kladdercablesegmentnumber] = {0,0};
    3521         188 :   const char* laddercablesegmentbboxshapename[kladdercablesegmentnumber] = 
    3522             :                                 {"LadderCableSegmentBBoxShape1","LadderCableSegmentBBoxShape2"};
    3523             : 
    3524             : 
    3525          94 :   const char* laddercablesegmentbboxname[kladdercablesegmentnumber] = 
    3526             :                                                   {"LadderCableSegmentBBox1","LadderCableSegmentBBox2"};
    3527             :   static TGeoVolume* laddercablesegmentbbox[kladdercablesegmentnumber];
    3528             : 
    3529          97 :   static TGeoTranslation* laddercablesegmentbboxtrans[kladdercablesegmentnumber] = {
    3530           3 :                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans1",
    3531           1 :                                                                                            0.5*fgkSSDFlexWidth[0],
    3532           1 :                                                                                            0.5*fgkSSDLadderCableWidth,
    3533           1 :                                                                        0.5*fgkSSDLadderCableHeight[0]),
    3534           3 :                                                    new TGeoTranslation("LadderCableSegmentBBoxTrans2",
    3535           1 :                                                                                            0.5*fgkSSDFlexWidth[0],
    3536           1 :                                                                                            0.5*fgkSSDLadderCableWidth,
    3537           1 :                                                                                            fgkSSDLadderCableHeight[0]
    3538           1 :                                                                                            +0.5*fgkSSDLadderCableHeight[1])
    3539             :                                                                                    };
    3540          98 :   static TGeoVolume* laddercablesegmentbboxassembly = new TGeoVolumeAssembly("LadderCableSegmentBBoxAssembly") ;
    3541          98 :   static TGeoVolume* laddercablesegmentarbassembly = new TGeoVolumeAssembly("LadderCableSegmentArbAssembly"); 
    3542             : 
    3543             :   static TGeoArb8* laddercablesegmentarbshape[kladdercablesegmentnumber];
    3544             :   static TGeoVolume* laddercablesegmentarb[kladdercablesegmentnumber];
    3545             : 
    3546          94 :   if (laddercablesegmentbboxshape[0] == 0) { 
    3547             :     // Initialise static shapes and volumes 
    3548           6 :   for(Int_t i=0; i<kladdercablesegmentnumber; i++) laddercablesegmentbboxshape[i] = 
    3549           4 :                                                      new TGeoBBox(laddercablesegmentbboxshapename[i],
    3550           2 :                                                                   0.5*fgkSSDFlexWidth[0],
    3551           2 :                                                                   0.5*fgkSSDLadderCableWidth,
    3552           2 :                                                                   0.5*fgkSSDLadderCableHeight[i]); 
    3553             :   
    3554           6 :   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
    3555           2 :     laddercablesegmentbbox[i] =
    3556           4 :       new TGeoVolume(laddercablesegmentbboxname[i],
    3557           2 :                      laddercablesegmentbboxshape[i],
    3558           6 :                      (i==0?fSSDAlTraceLadderCableMedium:
    3559           1 :                       fSSDKaptonLadderCableMedium));
    3560           6 :     laddercablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
    3561           1 :                                             fColorPolyhamide);
    3562             :   }
    3563             :   
    3564           6 :   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
    3565           4 :     laddercablesegmentbboxassembly->AddNode(laddercablesegmentbbox[i],1,
    3566           2 :                                             laddercablesegmentbboxtrans[i]);
    3567             : /////////////////////////////////////////
    3568             : // LadderSegmentArb8 Volume
    3569             : /////////////////////////////////////////
    3570             :   const Int_t kvertexnumber = 4;
    3571           1 :   TVector3** laddercablesegmentvertexposition[kladdercablesegmentnumber];
    3572           6 :   for(Int_t i = 0; i<kladdercablesegmentnumber; i++) laddercablesegmentvertexposition[i] = 
    3573           2 :                                                        new TVector3*[kvertexnumber];
    3574             : //Shape Vertex Positioning
    3575           6 :   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
    3576           4 :     laddercablesegmentvertexposition[i][0] = new TVector3(0.,i*fgkSSDFlexHeight[0], 0);
    3577           6 :     laddercablesegmentvertexposition[i][1] = new TVector3(fgkSSDLadderCableWidth,
    3578           2 :                                                           i*fgkSSDFlexHeight[0], 0);
    3579           6 :     laddercablesegmentvertexposition[i][2] = new TVector3(0.,fgkSSDFlexHeight[0]
    3580           2 :                                                           +                          fgkSSDFlexHeight[1]
    3581           2 :                                                           + i*fgkSSDFlexHeight[0], 0);
    3582           2 :     laddercablesegmentvertexposition[i][3] = 
    3583           4 :       new TVector3(laddercablesegmentvertexposition[i][1]->X(),
    3584           2 :                    laddercablesegmentvertexposition[i][2]->Y(), 0);
    3585             :   }
    3586           1 :   Double_t laddercablesegmentwidth[2][2] = {{fgkSSDFlexHeight[0],fgkSSDFlexHeight[0]},
    3587           1 :                                             {fgkSSDFlexHeight[1],fgkSSDFlexHeight[1]}}; 
    3588           1 :   const char* laddercablesegmentarbshapename[kladdercablesegmentnumber] = 
    3589             :     {"LadderCableSegmentArbShape1","LadderCableSegmentArbShape2"};
    3590             :   
    3591           6 :   for(Int_t i = 0; i< kladdercablesegmentnumber; i++) laddercablesegmentarbshape[i] = 
    3592           4 :                                                         GetArbShape(laddercablesegmentvertexposition[i],
    3593           2 :                                                                     laddercablesegmentwidth[i],
    3594           2 :                                                                     fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0],
    3595           2 :                                                                     laddercablesegmentarbshapename[i]);
    3596           1 :   const char* laddercablesegmentarbname[kladdercablesegmentnumber] = 
    3597             :     {"LadderCableSegmentArb1","LadderCableSegmentArb2"};
    3598             :   
    3599           6 :   for(Int_t i=0; i<kladdercablesegmentnumber; i++){
    3600           2 :     laddercablesegmentarb[i] =
    3601           4 :       new TGeoVolume(laddercablesegmentarbname[i],
    3602           2 :                      laddercablesegmentarbshape[i],
    3603           6 :                      (i==0?fSSDAlTraceLadderCableMedium:
    3604           1 :                       fSSDKaptonLadderCableMedium)); 
    3605           6 :     laddercablesegmentarb[i]->SetLineColor(i==0 ? fColorAl : 
    3606           1 :                                            fColorPolyhamide);
    3607             :   }
    3608             :   TGeoRotation* laddercablesegmentarbrot[kladdercablesegmentnumber];
    3609           1 :   laddercablesegmentarbrot[0] = new TGeoRotation("LadderCableSegmentArbRot1",
    3610             :                                                  90.,90,-90.);   
    3611           1 :   laddercablesegmentarbrot[1] = new TGeoRotation("LadderCableSegmentArbRot2",
    3612             :                                                  0.,90.,0.);     
    3613             :   TGeoCombiTrans* laddercablesegmentarbcombitrans =  
    3614           2 :     new TGeoCombiTrans("LadderCableSegmentArbCombiTrans",
    3615           1 :                        0.5*(fgkCarbonFiberJunctionWidth-fgkSSDFlexWidth[0])
    3616           1 :                        + fgkSSDFlexWidth[0],0.,0.,
    3617           3 :                        new TGeoRotation((*laddercablesegmentarbrot[1])
    3618           1 :                                         *(*laddercablesegmentarbrot[0])));
    3619           6 :   for(Int_t i=0; i<kladdercablesegmentnumber; i++)
    3620           4 :     laddercablesegmentarbassembly->AddNode(laddercablesegmentarb[i],1,
    3621           2 :                                            laddercablesegmentarbcombitrans);
    3622           1 :   }  // End of static initialisations
    3623             :   /////////////////////////////////////////
    3624             :   // End Ladder Cable Volume
    3625             :   // Note: this part depends explicitly on the length passed as an argument to the function
    3626             :   /////////////////////////////////////////
    3627          94 :   TGeoBBox* ladderendcablesegmentbboxshape[kladdercablesegmentnumber];
    3628          94 :   const char* ladderendcablesegmentbboxshapename[kladdercablesegmentnumber] = 
    3629             :     {"LadderEndCableSegmentBBoxShape1","LadderEndCableSegmentBBoxShape2"};
    3630         564 :   for(Int_t i=0; i<kladdercablesegmentnumber; i++) ladderendcablesegmentbboxshape[i] = 
    3631         376 :                                                      new TGeoBBox(ladderendcablesegmentbboxshapename[i],
    3632         188 :                                                                   0.5*ssdendladdercablelength,
    3633         188 :                                                                   0.5*fgkSSDLadderCableWidth,
    3634         188 :                                                                   0.5*fgkSSDLadderCableHeight[i]);
    3635          94 :   const char* ladderendcablesegmentbboxname[kladdercablesegmentnumber] = 
    3636             :     {"LadderEndCableSegmentBBox1","LadderEndCableSegmentBBox2"};
    3637          94 :   TGeoVolume* ladderendcablesegmentbbox[kladdercablesegmentnumber];
    3638         564 :   for(Int_t i=0; i<kladdercablesegmentnumber; i++){ 
    3639         188 :     ladderendcablesegmentbbox[i] =
    3640         376 :       new TGeoVolume(ladderendcablesegmentbboxname[i],
    3641         188 :                      ladderendcablesegmentbboxshape[i],
    3642         564 :                      (i==0?fSSDAlTraceLadderCableMedium:
    3643          94 :                       fSSDKaptonLadderCableMedium));
    3644         564 :     ladderendcablesegmentbbox[i]->SetLineColor(i==0 ? fColorAl : 
    3645          94 :                                                fColorPolyhamide);
    3646             :   }
    3647          94 :   TGeoTranslation* ladderendcablesegmentbboxtrans[kladdercablesegmentnumber];                                                                             
    3648          94 :   ladderendcablesegmentbboxtrans[0] = 
    3649         188 :     new TGeoTranslation("LadderEndCableSegmentBBoxTrans0",
    3650          94 :                         0.5*ssdendladdercablelength,
    3651          94 :                         0.5*fgkSSDLadderCableWidth,
    3652          94 :                         0.5*fgkSSDLadderCableHeight[0]);
    3653          94 :   ladderendcablesegmentbboxtrans[1] = 
    3654         188 :     new TGeoTranslation("LadderEndCableSegmentBBoxTrans1",
    3655             :                         0.5*ssdendladdercablelength,
    3656          94 :                         0.5*fgkSSDLadderCableWidth,
    3657          94 :                         fgkSSDLadderCableHeight[0]
    3658          94 :                         +0.5*fgkSSDLadderCableHeight[1]);
    3659             :   TGeoVolume* ladderendcablesegmentbboxassembly = 
    3660         188 :     new TGeoVolumeAssembly("LadderEndCableSegmentBBoxAssembly"); 
    3661         564 :   for(Int_t i=0; i<kladdercablesegmentnumber; i++)  
    3662         376 :     ladderendcablesegmentbboxassembly->AddNode(ladderendcablesegmentbbox[i],1,
    3663         188 :                                                ladderendcablesegmentbboxtrans[i]);
    3664             :   /////////////////////////////////////////
    3665          94 :   TList* laddercablesegmentlist = new TList();
    3666          94 :   laddercablesegmentlist->Add(laddercablesegmentbboxassembly);
    3667          94 :   laddercablesegmentlist->Add(laddercablesegmentarbassembly);
    3668          94 :   laddercablesegmentlist->Add(ladderendcablesegmentbboxassembly);
    3669             : 
    3670          94 :   laddercablesegmentbboxassembly->GetShape()->ComputeBBox(); //RS: enforce recompting of BBox
    3671          94 :   laddercablesegmentarbassembly->GetShape()->ComputeBBox();
    3672          94 :   return laddercablesegmentlist;
    3673          94 : }
    3674             : 
    3675             : /////////////////////////////////////////////////////////////////////////////////
    3676             : TGeoVolume* AliITSv11GeometrySSD::GetLadderCable(Int_t n, Double_t ssdendladdercablelength){
    3677             :   /////////////////////////////////////////////////////////////
    3678             :   // Method generating Ladder Cable of given length (n modules + end)
    3679             :   // Called by GetLadderCableAssembly
    3680             :   /////////////////////////////////////////////////////////////
    3681         188 :   TList* laddercablesegmentlist = GetLadderCableSegment(ssdendladdercablelength);
    3682         188 :   TGeoVolume* laddercable = new TGeoVolumeAssembly("LadderCable"); 
    3683        1396 :   for(Int_t i=0; i<n; i++){
    3684        1208 :          TGeoTranslation* laddercabletrans = new TGeoTranslation(
    3685         604 :                                                         i*(fgkCarbonFiberJunctionWidth),
    3686         604 :                                                         fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
    3687         604 :                                                         i*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]));
    3688         604 :     laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(0),i+1,laddercabletrans);  
    3689        1114 :     if(i!=n-1) laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(1),i+1,laddercabletrans);  
    3690             :  
    3691             :   }
    3692         188 :   TGeoTranslation* endladdercabletrans = new TGeoTranslation("EndLadderCableTrans",
    3693          94 :                                           (n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
    3694          94 :                                                              fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],
    3695          94 :                                                              (n-1)*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]));
    3696          94 :   laddercable->AddNode((TGeoVolume*)laddercablesegmentlist->At(2),1,endladdercabletrans);
    3697             : 
    3698          94 :   laddercable->GetShape()->ComputeBBox(); //RS: enforce recompting of BBox
    3699          94 :   return laddercable;
    3700           0 : }
    3701             : /////////////////////////////////////////////////////////////////////////////////
    3702             : TGeoVolume* AliITSv11GeometrySSD::GetLadderCableAssembly(Int_t n, Double_t ssdendladdercablelength){
    3703             :   ///////////////////////////////////////////////////////////////////
    3704             :   // Main method generating Ladder Cable bundles containing n cables
    3705             :   ///////////////////////////////////////////////////////////////////
    3706          16 :   Double_t totalLength = ssdendladdercablelength+(n-1)*fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0];
    3707           8 :   Double_t cableOrig[3] = {0.5*totalLength,1.5*fgkSSDLadderCableWidth-fgkSSDFlexWidth[0],0.5*n*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1])};
    3708           8 :   TGeoBBox *laddercableshape = new TGeoBBox(0.5*totalLength,0.5*fgkSSDLadderCableWidth,0.5*n*(fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]),cableOrig);
    3709           8 :   TGeoVolume* laddercable = new TGeoVolume("LadderCableMother", laddercableshape, fSSDAir);
    3710           8 :   char laddercabletransname[100];
    3711         204 :   for(Int_t i=0; i<n; i++){ 
    3712          94 :     snprintf(laddercabletransname,100,"LadderCableTrans%i",i+1);
    3713         188 :     laddercable->AddNode(GetLadderCable(n-i,ssdendladdercablelength),i+1,
    3714         188 :                          new TGeoTranslation(laddercabletransname,i*fgkCarbonFiberJunctionWidth,0,0));
    3715             :   }
    3716           8 :   return laddercable;
    3717           8 : }
    3718             : /////////////////////////////////////////////////////////////////////////////////
    3719             : TList* AliITSv11GeometrySSD::GetLadderCableAssemblyList(Int_t n, Double_t ssdendladdercablelength){
    3720             :   /////////////////////////////////////////////////////////////
    3721             :   // Method generating Ladder Cable List Assemblies  
    3722             :   // containing two cables bundles, i.e. P+N readout for one endcap
    3723             :   /////////////////////////////////////////////////////////////  
    3724             :   const Int_t kladdercableassemblynumber = 2; 
    3725          16 :   TGeoVolume* laddercableassembly = GetLadderCableAssembly(n,ssdendladdercablelength);
    3726           8 :   TGeoVolume* ladderCable[kladdercableassemblynumber];
    3727           8 :   char laddercableassemblyname[100];
    3728           8 :   TList* laddercableassemblylist = new TList();
    3729          48 :   for(Int_t i=0; i<kladdercableassemblynumber; i++){ 
    3730          16 :     snprintf(laddercableassemblyname,100,"LadderCableAssembly%i",i+1);
    3731          32 :     ladderCable[i] = new TGeoVolumeAssembly(laddercableassemblyname);
    3732          32 :     ladderCable[i]->AddNode(laddercableassembly,i+1,i==0 ? NULL :
    3733          16 :                             new TGeoCombiTrans((n-1)
    3734           8 :                                                *         fgkCarbonFiberJunctionWidth+fgkSSDFlexWidth[0],
    3735           8 :                                                2.*fgkSSDLadderCableWidth+0.5*fgkSSDFlexWidth[0],
    3736          16 :                                                0.,new TGeoRotation("",180,0.,0.)));
    3737          16 :     ladderCable[i]->GetShape()->ComputeBBox(); //RS: enforce recompting of BBox
    3738          16 :     laddercableassemblylist->Add(ladderCable[i]);
    3739             : }
    3740           8 :   return laddercableassemblylist;
    3741           8 : }
    3742             : ///////////////////////////////////////////////////////////////////////////////
    3743             : void AliITSv11GeometrySSD::SetLadderSegment(){
    3744             :   /////////////////////////////////////////////////////////////
    3745             :   // Method Generating Ladder Segment Array
    3746             :   /////////////////////////////////////////////////////////////
    3747           3 :   fladdersegment[0] = new TGeoVolumeAssembly("LadderSegment1");       
    3748           2 :   fladdersegment[1] = new TGeoVolumeAssembly("LadderSegment2");       
    3749             : 
    3750             :   /* MvL: tried to create mother volume. Requires changes in all rotations, bc xtru is always along z-axis
    3751             :   TGeoXtru *laddersegmentshape = new TGeoXtru(2);
    3752             :   static const Int_t ntrianglevtx = 3;
    3753             :   Double_t xtrianglevtx[ntrianglevtx]={-0.5*fgkCarbonFiberTriangleLength,fgkCarbonFiberTriangleLength, 0};
    3754             :   Double_t ytrianglevtx[ntrianglevtx]={0, 0, fgkCarbonFiberTriangleLength * TMath::Sin(fgkCarbonFiberTriangleAngle*TMath::DegToRad())};
    3755             :   laddersegmentshape->DefinePolygon(ntrianglevtx,xtrianglevtx,ytrianglevtx);
    3756             :   laddersegmentshape->DefineSection(0,0);
    3757             :   laddersegmentshape->DefineSection(1,fgkCarbonFiberJunctionWidth);  // MVL
    3758             :   fladdersegment[0] = new TGeoVolume("LadderSegment1",laddersegmentshape,fSSDAir);    
    3759             :   fladdersegment[1] = new TGeoVolume("LadderSegment2",laddersegmentshape,fSSDAir);    
    3760             :   */
    3761             : 
    3762           1 :   if(!fCreateMaterials) CreateMaterials();
    3763           1 :   if(!fTransformationMatrices) CreateTransformationMatrices();
    3764           1 :   if(!fBasicObjects) CreateBasicObjects();
    3765           6 :   for(Int_t i=0; i<fgkladdersegmentnumber; i++){
    3766             :   // Placing Carbon Fiber Support       
    3767          12 :         for(Int_t j=0; j<fgkcarbonfibersupportnumber; j++){ 
    3768           8 :                 fladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
    3769           4 :                                                                                         fcarbonfibersupportmatrix[j]);  
    3770           8 :                 fladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
    3771           4 :                                                                                         fcarbonfibersupportmatrix[j]);
    3772             :   }
    3773             :   // Placing Carbon Fiber Junction
    3774          16 :         for(Int_t j=0; j<fgkcarbonfiberjunctionumber; j++) {
    3775          12 :         fladdersegment[i]->AddNode(fcarbonfiberjunction,j+1,
    3776           6 :                                                                    fcarbonfiberjunctionmatrix[j]);
    3777             :   }
    3778             :   // Placing Carbon Fiber Lower Support
    3779          12 :     for(Int_t j=0; j<fgkcarbonfiberlowersupportnumber; j++) {
    3780           8 :                 fladdersegment[i]->AddNode(fcarbonfiberlowersupport[j],j+1,
    3781           4 :                                                            fcarbonfiberlowersupportrans[j]);    
    3782             :     }
    3783             :   // Placing SSD Sensor Support
    3784          16 :     for(Int_t j=0; j<fgkssdsensorsupportnumber; j++) 
    3785          24 :         fladdersegment[i]->AddNode(j<2 ? fssdsensorsupport[0][i] :
    3786           2 :                                                                      fssdsensorsupport[1][i],
    3787           6 :                                                            j+1,fssdsensorsupportmatrix[j]);
    3788             :   // Placing SSD Cooling Tube Support 
    3789          12 :         for(Int_t j=0; j<fgkcoolingtubesupportnumber; j++)
    3790           8 :                 fladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
    3791           4 :                                                                    fcoolingtubesupportmatrix[j]);
    3792             :   // Placing SSD Cooling Tube  
    3793           4 :         fladdersegment[i]->AddNode(fcoolingtube,1,fcoolingtubematrix[0]);
    3794           4 :         fladdersegment[i]->AddNode(fcoolingtube,2,fcoolingtubematrix[1]);
    3795             :   // Placing SSD Hybrid
    3796           4 :     switch(i){
    3797             :         case 0: 
    3798           1 :                 fladdersegment[i]->AddNode(fssdhybridcomponent[0],1,fhybridmatrix);
    3799           1 :                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
    3800           1 :                 break;
    3801             :     case 1:
    3802           1 :                 fladdersegment[i]->AddNode(fssdhybridcomponent[1],1,fhybridmatrix);
    3803           1 :                 fladdersegment[i]->AddNode(fssdhybridcomponent[2],1,fhybridmatrix);
    3804           1 :                 break;
    3805             :         }
    3806             :         // Placing Cooling Block System
    3807           2 :       fladdersegment[i]->AddNode(fssdcoolingblocksystem,1,fcoolingblocksystematrix);
    3808             :         // Placing SSD Flex
    3809          12 :       for(Int_t j=0; j<fgkflexnumber; j++){
    3810           4 :         fladdersegment[i]->AddNode(fssdstiffenerflex,j+1,fstiffenerflexmatrix[j]);
    3811           4 :         fladdersegment[i]->AddNode(fssdendflex,j+1,fendflexmatrix[j]);
    3812             :       }
    3813             :    }
    3814           1 :   fladdersegment[0]->GetShape()->ComputeBBox(); //RS: enforce recompting of BBox
    3815           1 :   fladdersegment[1]->GetShape()->ComputeBBox();
    3816             :  
    3817           1 : }
    3818             : ///////////////////////////////////////////////////////////////////////////////
    3819             : void AliITSv11GeometrySSD::SetEndLadderSegment(){
    3820             :   /////////////////////////////////////////////////////////////
    3821             :   // Method Generating End Ladder
    3822             :   /////////////////////////////////////////////////////////////
    3823             :   // End Ladder Carbon Fiber Junction 
    3824             :   /////////////////////////////////////////////////////////////
    3825           3 :   fendladdersegment[0] = new TGeoVolumeAssembly("EndLadder1");
    3826           2 :   fendladdersegment[1] = new TGeoVolumeAssembly("EndLadder2");
    3827           1 :   if(!fCreateMaterials) CreateMaterials();
    3828           1 :   if(!fTransformationMatrices) CreateTransformationMatrices();
    3829           1 :   if(!fBasicObjects) CreateBasicObjects();
    3830           6 :   for(Int_t i=0; i<fgkendlabbercarbonfiberjunctionumber; i++){
    3831          16 :         for(Int_t j=0; j<fgkendladdercarbonfiberjunctionmatrixnumber; j++)
    3832          30 :                 fendladdersegment[i]->AddNode(j==2 ? 
    3833           8 :                                                         fendladdercarbonfiberjunction[i][1] : 
    3834           4 :                                                         fendladdercarbonfiberjunction[i][0],
    3835           6 :                                                         j+1,fendladdercarbonfiberjunctionmatrix[i][j]);
    3836             :   }
    3837             :   /////////////////////////////////////////////////////////////
    3838             :   // End Ladder Carbon Fiber Support 
    3839             :   /////////////////////////////////////////////////////////////
    3840           6 :   for(Int_t i=0; i<fgkcarbonfibersupportnumber; i++)
    3841          12 :       for(Int_t j=0; j<fgkendladdercarbonfibermatrixnumber; j++){
    3842           8 :                   fendladdersegment[i]->AddNode(fcarbonfibersupport[0],j+1,
    3843           4 :                   fendladdercarbonfibermatrix[i][j]);   
    3844           8 :           fendladdersegment[i]->AddNode(fcarbonfibersupport[1],j+1,
    3845           4 :                   fendladdercarbonfibermatrix[i][j]);   
    3846             :       }
    3847             :   /////////////////////////////////////////////////////////////
    3848             :   // End Ladder Mounting Block
    3849             :   /////////////////////////////////////////////////////////////
    3850           6 :   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
    3851           4 :        fendladdersegment[i]->AddNode(fendladdermountingblock,i+1,
    3852           2 :                                      fendladdermountingblockcombitrans[i]);
    3853             :   /////////////////////////////////////////////////////////////
    3854             :   // End Ladder Mounting Block Clip
    3855             :   /////////////////////////////////////////////////////////////
    3856           6 :   for(Int_t i=0; i<fgkendladdermountingblocknumber; i++)
    3857          12 :         for(Int_t j=0; j<2; j++)
    3858           8 :                 fendladdersegment[i]->AddNode(fendladdermountingblockclip,j+1,
    3859           4 :                                               fendladdermountingblockclipmatrix[i][j]);
    3860             :   /////////////////////////////////////////////////////////////
    3861             :   // End Ladder Lower Supports
    3862             :   /////////////////////////////////////////////////////////////
    3863           2 :   fendladdersegment[0]->AddNode(fcarbonfiberlowersupport[0],1,
    3864           1 :                                 fendladderlowersupptrans[0]);
    3865           2 :   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],2,
    3866           1 :                                 fendladderlowersupptrans[1]);
    3867           2 :   fendladdersegment[1]->AddNode(fcarbonfiberlowersupport[0],3,
    3868           1 :                                 fendladderlowersupptrans[2]);
    3869             :   /////////////////////////////////////////////////////////////
    3870             :   // End Ladder Cooling Tube Support
    3871             :   /////////////////////////////////////////////////////////////
    3872           6 :   for(Int_t i=0; i<2; i++) 
    3873          16 :         for(Int_t j=0; j<(i==0?4:2); j++)   
    3874          12 :                 fendladdersegment[i]->AddNode(fcoolingtubesupport,j+1,
    3875           6 :                                               fendladdercoolingtubesupportmatrix[i][j]);
    3876             :   /////////////////////////////////////////////////////////////
    3877             :   // End Ladder Cooling Tube Support
    3878             :   /////////////////////////////////////////////////////////////
    3879           1 :   fendladdersegment[0]->AddNode(fendladdercoolingtube[0],1,fendladdercoolingtubematrix[0][0]); 
    3880           1 :   fendladdersegment[0]->AddNode(fendladdercoolingtube[0],2,fendladdercoolingtubematrix[0][1]);
    3881           1 :   fendladdersegment[1]->AddNode(fendladdercoolingtube[1],1,fendladdercoolingtubematrix[1][0]);
    3882           1 :   fendladdersegment[1]->AddNode(fendladdercoolingtube[1],2,fendladdercoolingtubematrix[1][1]); 
    3883             : 
    3884           1 :   fendladdersegment[0]->GetShape()->ComputeBBox(); //RS: enforce recompting of BBox
    3885           1 :   fendladdersegment[1]->GetShape()->ComputeBBox();
    3886             : 
    3887           1 : }
    3888             : ///////////////////////////////////////////////////////////////////////////////
    3889             : void AliITSv11GeometrySSD::SetLadder(){
    3890             :   /////////////////////////////////////////////////////////////
    3891             :   // Method Generating Ladder of Layer 5 and 6
    3892             :   /////////////////////////////////////////////////////////////  
    3893           2 :   Int_t ssdlaysensorsnumber[fgkladdernumber] = {fgkSSDLay5SensorsNumber,
    3894             :                                                                                                 fgkSSDLay6SensorsNumber};
    3895             :   /////////////////////////////////////////////////////////////////////////////                                         
    3896             :   /// Generating Ladder Mother Volume Containing Ladder 
    3897             :   /////////////////////////////////////////////////////////////////////////////          
    3898             :   /*  TGeoXtru* laddershape[fgkladdernumber];   
    3899             :   for(Int_t i=0; i<fgkladdernumber; i++) laddershape[i] = new TGeoXtru(2);
    3900             :   */
    3901             :   const Int_t kmothervertexnumber = 8;  
    3902           1 :   Double_t xmothervertex[fgkladdernumber][kmothervertexnumber];
    3903           1 :   Double_t ymothervertex[fgkladdernumber][kmothervertexnumber];
    3904             :   ///////////////////////
    3905             :   // Setting the vertices 
    3906             :   ///////////////////////
    3907             :   Double_t laddercablethickness = (fgkSSDLay6SensorsNumber+2)
    3908           1 :                                                                 * (fgkSSDLadderCableHeight[0]+fgkSSDLadderCableHeight[1]);
    3909           1 :   xmothervertex[0][0] = -0.5*fgkSSDSensorWidth;
    3910           1 :   ymothervertex[0][0] = -0.5*fgkCoolingTubeSupportHeight-fgkSSDModuleCoolingBlockToSensor;
    3911           1 :   xmothervertex[0][1] = xmothervertex[0][0];
    3912           1 :   ymothervertex[0][1] = -0.5*fgkCoolingTubeSupportHeight; // 0.0; MvL 20-apr-2010
    3913           2 :   xmothervertex[0][2] = - 0.5*fgkSSDModuleSensorSupportDistance-2.*fgkCoolingTubeSupportRmax
    3914           1 :                                                 - laddercablethickness/SinD(2.*fgkSSDFlexAngle);
    3915           1 :   ymothervertex[0][2] = ymothervertex[0][1];
    3916           1 :   ymothervertex[0][3] = 0.5*fgkCarbonFiberTriangleLength*TanD(2.*fgkSSDFlexAngle);
    3917           1 :   xmothervertex[0][3] = xmothervertex[0][2]+ymothervertex[0][3]/TanD(2.*fgkSSDFlexAngle);               
    3918           1 :   xmothervertex[0][4] = -xmothervertex[0][3];
    3919           1 :   ymothervertex[0][4] = ymothervertex[0][3];
    3920           1 :   xmothervertex[0][5] = -xmothervertex[0][2];
    3921           1 :   ymothervertex[0][5] = ymothervertex[0][2];
    3922           1 :   xmothervertex[0][6] = -xmothervertex[0][1];
    3923           1 :   ymothervertex[0][6] = ymothervertex[0][1];
    3924           1 :   xmothervertex[0][7] = -xmothervertex[0][0];
    3925           1 :   ymothervertex[0][7] = ymothervertex[0][0];
    3926          18 :   for(Int_t i=0; i<kmothervertexnumber; i++){
    3927           8 :         xmothervertex[1][i] = xmothervertex[0][i];
    3928           8 :         ymothervertex[1][i] = ymothervertex[0][i];
    3929             :   }
    3930             : ///////////////////////////////////////////////////////////////////////////
    3931             : // Disalignement Mother Volume corrections 25/08/08
    3932             : ///////////////////////////////////////////////////////////////////////////
    3933           1 :   TGeoXtru* leftladdershape1[fgkladdernumber];  
    3934           1 :   TGeoXtru* leftladdershape2[fgkladdernumber];  
    3935           1 :   TGeoXtru* centersensorladdershape[fgkladdernumber];   
    3936           1 :   TGeoXtru* rightladdershape1[fgkladdernumber]; 
    3937           1 :   TGeoXtru* rightladdershape2[fgkladdernumber]; 
    3938           6 :   for(Int_t i=0; i<fgkladdernumber; i++){
    3939           4 :     leftladdershape1[i] = new TGeoXtru(2);
    3940           4 :     leftladdershape2[i] = new TGeoXtru(2);
    3941           4 :     centersensorladdershape[i] = new TGeoXtru(2);
    3942           4 :     rightladdershape1[i] = new TGeoXtru(2);
    3943           4 :     rightladdershape2[i] = new TGeoXtru(2);
    3944             :   }
    3945             :   //////////////////////////////////////
    3946             :   // Setting the names for shapes  
    3947             :   //////////////////////////////////////
    3948           1 :   leftladdershape1[0]->SetName("Lay5Left1LadderSegmentContainer");
    3949           1 :   leftladdershape2[0]->SetName("Lay5Left2LadderSegmentContainer");
    3950           1 :   leftladdershape1[1]->SetName("Lay6Left1LadderSegmentContainer");
    3951           1 :   leftladdershape2[1]->SetName("Lay6Left2LadderSegmentContainer");
    3952           1 :   centersensorladdershape[0]->SetName("Lay5CenterSensorContainer");
    3953           1 :   centersensorladdershape[1]->SetName("Lay6CenterSensorContainer");
    3954           1 :   rightladdershape1[0]->SetName("Lay5Right1LadderSegmentContainer");
    3955           1 :   rightladdershape2[0]->SetName("Lay5Right2LadderSegmentContainer");
    3956           1 :   rightladdershape1[1]->SetName("Lay6Right1LadderSegmentContainer");
    3957           1 :   rightladdershape2[1]->SetName("Lay6Right2LadderSegmentContainer");
    3958             :   //////////////////////////////////////
    3959           1 :   Double_t xend1laddervertex[fgkladdernumber][kmothervertexnumber];
    3960           1 :   Double_t yend1laddervertex[fgkladdernumber][kmothervertexnumber];
    3961           1 :   Double_t xcentersensorvertex[fgkladdernumber][kmothervertexnumber];
    3962           1 :   Double_t ycentersensorvertex[fgkladdernumber][kmothervertexnumber];
    3963           1 :   Double_t xend2laddervertex[fgkladdernumber][kmothervertexnumber];
    3964           1 :   Double_t yend2laddervertex[fgkladdernumber][kmothervertexnumber];
    3965           6 :   for(Int_t i=0; i<fgkladdernumber; i++) {
    3966          36 :     for(Int_t j=0; j<kmothervertexnumber; j++){
    3967          16 :       xcentersensorvertex[i][j] = xmothervertex[i][j];
    3968          16 :       ycentersensorvertex[i][j] = ymothervertex[i][j];
    3969          16 :       xend1laddervertex[i][j] = xmothervertex[i][j];
    3970          16 :       yend1laddervertex[i][j] = ymothervertex[i][j];
    3971          16 :       xend2laddervertex[i][j] = xmothervertex[i][j];
    3972          16 :       yend2laddervertex[i][j] = ymothervertex[i][j];
    3973             :     }
    3974             :     // Add some space around sensors to accommodate misalignments
    3975           2 :     xcentersensorvertex[i][0] -= fgkSSDModuleSideDisalignment;  
    3976           2 :     xcentersensorvertex[i][1] =  xcentersensorvertex[0][0];
    3977           2 :     xcentersensorvertex[i][6] = -xcentersensorvertex[0][1];
    3978           2 :     xcentersensorvertex[i][7] = -xcentersensorvertex[0][0];
    3979             :     
    3980           2 :     ycentersensorvertex[i][0] -= fgkSSDModuleVerticalDisalignment;      
    3981           2 :     ycentersensorvertex[i][7] = ycentersensorvertex[0][0];
    3982             :     
    3983             :     // Center Ladder Piece
    3984           4 :     centersensorladdershape[i]->DefinePolygon(kmothervertexnumber,xcentersensorvertex[i],
    3985           2 :                                               ycentersensorvertex[i]);
    3986           4 :     centersensorladdershape[i]->DefineSection(0, - fgkEndLadderCarbonFiberLowerJunctionLength[1]
    3987           2 :                                                  + 1.45*fgkSSDMountingBlockWidth);
    3988           4 :     centersensorladdershape[i]->DefineSection(1,   ssdlaysensorsnumber[i] * fgkCarbonFiberJunctionWidth
    3989           2 :                                                  + fgkEndLadderCarbonFiberLowerJunctionLength[0]
    3990           2 :                                                  - 2.4*fgkSSDMountingBlockWidth);
    3991             : 
    3992             :     // Left and Right Ladder Pieces: Mother volumes around ladder mounting areas 
    3993             : 
    3994             :     // Cuts off first corner (neg x)
    3995           2 :     xend1laddervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];
    3996           2 :     xend1laddervertex[i][1] = -0.5*fgkSSDMountingBlockLength[0];
    3997             :     // Cuts off last part (pos x)
    3998           2 :     xend2laddervertex[i][6] = 0.5*fgkSSDMountingBlockLength[0];
    3999           2 :     xend2laddervertex[i][7] = 0.5*fgkSSDMountingBlockLength[0];
    4000             : 
    4001           4 :     leftladdershape1[i]->DefinePolygon(kmothervertexnumber,xend1laddervertex[i],  
    4002           2 :                                        yend1laddervertex[i]);
    4003           2 :     leftladdershape1[i]->DefineSection(0,-fgkEndLadderCarbonFiberLowerJunctionLength[1]);
    4004           4 :     leftladdershape1[i]->DefineSection(1,  fendladdersegmentmatrix[0][i]->GetTranslation()[2]    
    4005           2 :                                          - fgkEndLadderMountingBlockPosition[0]);
    4006             :     
    4007           4 :     leftladdershape2[i]->DefinePolygon(kmothervertexnumber,xend2laddervertex[i],  
    4008           2 :                                        yend2laddervertex[i]);
    4009           4 :     leftladdershape2[i]->DefineSection(0,  fendladdersegmentmatrix[0][i]->GetTranslation()[2]    
    4010           2 :                                          - fgkEndLadderMountingBlockPosition[0]); 
    4011           4 :     leftladdershape2[i]->DefineSection(1,- fgkEndLadderCarbonFiberLowerJunctionLength[1] 
    4012           2 :                                        + 1.45*fgkSSDMountingBlockWidth);  // connect to main volume at -1.6725 cm
    4013             : 
    4014           2 :     rightladdershape1[i]->DefinePolygon(kmothervertexnumber,xend1laddervertex[i],
    4015             :                                         yend1laddervertex[i]);
    4016           4 :     rightladdershape1[i]->DefineSection(0,ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
    4017           2 :                                         +fgkEndLadderCarbonFiberLowerJunctionLength[0]
    4018           2 :                                         -2.4*fgkSSDMountingBlockWidth);
    4019           4 :     rightladdershape1[i]->DefineSection(1,fendladdersegmentmatrix[1][i]->GetTranslation()[2]
    4020           2 :                                         + fgkEndLadderMountingBlockPosition[1]);
    4021             : 
    4022           2 :     rightladdershape2[i]->DefinePolygon(kmothervertexnumber,xend2laddervertex[i],
    4023             :                                         yend2laddervertex[i]);
    4024           4 :     rightladdershape2[i]->DefineSection(0, fendladdersegmentmatrix[1][i]->GetTranslation()[2]
    4025           2 :                                            + fgkEndLadderMountingBlockPosition[1]);
    4026           4 :     rightladdershape2[i]->DefineSection(1,  ssdlaysensorsnumber[i]*fgkCarbonFiberJunctionWidth
    4027           2 :                                           + fgkEndLadderCarbonFiberLowerJunctionLength[0]);
    4028             :   }
    4029           1 :   TGeoCompositeShape* laddershapecontainer[2];
    4030           2 :   laddershapecontainer[0] = new TGeoCompositeShape("Lay5LadderCompositeShape",
    4031             :                                                    "Lay5Left1LadderSegmentContainer+Lay5Left2LadderSegmentContainer"
    4032             :                                                    "+Lay5CenterSensorContainer"
    4033             :                                                    "+Lay5Right1LadderSegmentContainer+Lay5Right2LadderSegmentContainer");
    4034           2 :   laddershapecontainer[1] = new TGeoCompositeShape("Lay6LadderCompositeShape",
    4035             :                                                    "Lay6Left1LadderSegmentContainer+Lay6Left2LadderSegmentContainer"
    4036             :                                                    "+Lay6CenterSensorContainer"
    4037             :                                                    "+Lay6Right1LadderSegmentContainer+Lay6Right2LadderSegmentContainer");
    4038           1 :   const char* laddername[fgkladdernumber] = {"ITSssdLay5Ladd","ITSssdLay6Ladd"};
    4039           6 :   for(Int_t i=0; i<fgkladdernumber; i++){
    4040           4 :     fladder[i] = new TGeoVolume(laddername[i],laddershapecontainer[i],fSSDAir);
    4041           2 :     fladder[i]->SetLineColor(4);
    4042             :   }
    4043             : ///////////////////////////////////////////////////////////////////////////
    4044           1 :  if(!fCreateMaterials) CreateMaterials();
    4045           1 :  if(!fTransformationMatrices) CreateTransformationMatrices();
    4046           1 :  if(!fBasicObjects) CreateBasicObjects();
    4047           1 :  SetLadderSegment(); 
    4048           1 :  SetEndLadderSegment();
    4049           6 :   for(Int_t i=0; i<fgkladdernumber; i++){
    4050          98 :         for(Int_t j=0; j<ssdlaysensorsnumber[i]; j++){
    4051             :         //////////////////////////                                              
    4052             :         /// Placing Ladder Segment
    4053             :         //////////////////////////              
    4054         188 :                 fladder[i]->AddNode(j%2==0 ? fladdersegment[i==0 ? 0 : 1] :
    4055          23 :                                                                      fladdersegment[i==0 ? 1 : 0],
    4056          47 :                                                                          ssdlaysensorsnumber[i]-j-1,fladdermatrix[i][j]);
    4057             :         //////////////////////////                                              
    4058             :         /// Placing SSD Sensor
    4059             :         //////////////////////////              
    4060          70 :         if(i==0&&ssdlaysensorsnumber[i]-j-1==13) fSSDSensor5->SetLineColor(kRed);
    4061         188 :                 fladder[i]->AddNode(i==0?fSSDSensor5:fSSDSensor6,ssdlaysensorsnumber[i]-j-1,
    4062          47 :                                                         fssdsensormatrix[i][j]);
    4063             :         }
    4064             :         ///////////////////////////////                                         
    4065             :         /// Placing End Ladder Segment
    4066             :         ///////////////////////////////         
    4067           2 :         fladder[i]->AddNode(fendladdersegment[0],1,fendladdersegmentmatrix[0][i]);
    4068           2 :         fladder[i]->AddNode(fendladdersegment[1],1,fendladdersegmentmatrix[1][i]);
    4069             :    }
    4070             : /////////////////////////////////////////////////////////////////////////////                                           
    4071             : /// Placing Ladder Cables
    4072             : /////////////////////////////////////////////////////////////////////////////           
    4073           1 :   Int_t sidecablenumber[2][2];
    4074           1 :   sidecablenumber[0][0] = fgkSSDLay5SensorsNumber/2+1; 
    4075           1 :   sidecablenumber[0][1] = sidecablenumber[0][0]-2;
    4076           1 :   sidecablenumber[1][0] = (fgkSSDLay6SensorsNumber-1)/2+1;
    4077           1 :   sidecablenumber[1][1] = sidecablenumber[1][0]-1;
    4078             :   Double_t carbonfibertomoduleposition[3];
    4079           1 :   carbonfibertomoduleposition[0] = -0.5*(fgkSSDSensorWidth-fgkCarbonFiberTriangleLength);
    4080           2 :   carbonfibertomoduleposition[1] = - (2.*fgkSSDSensorLength-fgkSSDSensorOverlap)+
    4081           2 :                          fgkSSDModuleStiffenerPosition[1]+fgkSSDStiffenerWidth
    4082           1 :          +               0.5*fgkSSDFlexHoleLength+2.*fgkCarbonFiberJunctionWidth
    4083           2 :          -               0.5*(fgkCarbonFiberLowerSupportWidth+fgkSSDSensorCenterSupportLength
    4084           1 :          -            fgkSSDSensorCenterSupportThickness[0]);
    4085           1 :   carbonfibertomoduleposition[2] = - (fgkSSDModuleCoolingBlockToSensor
    4086           1 :                                                                  +   0.5*fgkCoolingTubeSupportHeight
    4087           1 :          -         fgkSSDSensorHeight-fgkSSDChipCablesHeight[3]-fgkSSDChipHeight);      
    4088           1 :   const Double_t kendladdercablecorrection = 1.72*fgkmm; //this has to be tuned
    4089           1 :   Double_t ssdendladdercablelength[4];
    4090           1 :   ssdendladdercablelength[0] = carbonfibertomoduleposition[1]
    4091           1 :                                                          + fgkSSDSensorLength
    4092           1 :                                                          - fgkSSDModuleStiffenerPosition[1]
    4093           1 :                                                          - fgkSSDStiffenerWidth 
    4094           1 :                                                          - fgkSSDFlexWidth[0]
    4095           1 :                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
    4096           1 :   ssdendladdercablelength[1] = carbonfibertomoduleposition[1]
    4097           1 :                                                          + fgkSSDModuleStiffenerPosition[1]
    4098           1 :                                                          + fgkSSDStiffenerWidth
    4099           1 :                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[1]-0.000001*kendladdercablecorrection;
    4100           1 :   ssdendladdercablelength[2] = ssdendladdercablelength[1]
    4101           1 :                                                          - fgkEndLadderCarbonFiberLowerJunctionLength[1]
    4102           1 :                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]
    4103           1 :                                                          - kendladdercablecorrection;
    4104           3 :   ssdendladdercablelength[3] = fgkCarbonFiberJunctionWidth-(fgkSSDSensorLength
    4105           1 :                                                          + carbonfibertomoduleposition[1]
    4106           1 :                                                          - fgkSSDModuleStiffenerPosition[1]
    4107           1 :                                                          - fgkSSDStiffenerWidth)
    4108           1 :                                                          + fgkEndLadderCarbonFiberLowerJunctionLength[0]-0.000001*kendladdercablecorrection;
    4109             : 
    4110           1 :   TList* laddercableassemblylist[4];
    4111             :   const Int_t kendladdercablesnumber = 4;
    4112           1 :   TGeoRotation *laddercablerot = new TGeoRotation();
    4113           1 :   laddercablerot->SetAngles(90.,60.,-90.);
    4114           6 :   for(Int_t i=0; i<fgkladdercablesnumber; i++)
    4115          20 :         for(Int_t j=0; j<kendladdercablesnumber; j++){
    4116           8 :                 laddercableassemblylist[j] = 
    4117          16 :                 GetLadderCableAssemblyList(sidecablenumber[i][j<2?0:1],
    4118           8 :                                                                    ssdendladdercablelength[j]);
    4119          16 :                         fladder[i]->AddNode((TGeoVolume*)laddercableassemblylist[j]->At(j%2==0?0:1),
    4120           8 :                                                                         j<2?1:2,fladdercablematrix[i][j]);
    4121             :   }
    4122           1 : }
    4123             : 
    4124             : ////////////////////////////////////////////////////////////////////////////////
    4125             : void AliITSv11GeometrySSD::SetLayer(){
    4126             : ////////////////////////////////////////////////////////////////////////////////
    4127             :   // Creating Ladder of Layer 5 and Layer 6
    4128             :   /////////////////////////////////////////////////////////////
    4129           3 :   if(!fCreateMaterials) CreateMaterials();
    4130           2 :   if(!fTransformationMatrices) CreateTransformationMatrices();
    4131           2 :   if(!fBasicObjects) CreateBasicObjects();
    4132           1 :   SetLadder(); // Generating the ladder of Layer5 and Layer6
    4133             :   const Int_t kssdlayladdernumber[fgklayernumber] = 
    4134             :                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
    4135             :   /////////////////////////////////////////////////////////////
    4136             :   // Generating mother volumes for Layer5 and Layer6
    4137             :   /////////////////////////////////////////////////////////////
    4138           2 :   fSSDLayer5 = new TGeoVolumeAssembly("ITSssdLayer5");  
    4139           2 :   fSSDLayer6 = new TGeoVolumeAssembly("ITSssdLayer6");  
    4140           1 :   Int_t *ladderindex[fgklayernumber];
    4141           1 :   Int_t index[fgklayernumber] = {8,9};
    4142           6 :   for(Int_t i=0; i<fgklayernumber; i++) ladderindex[i] = new Int_t[kssdlayladdernumber[i]];
    4143           6 :   for(Int_t i=0; i<fgklayernumber; i++)      
    4144         148 :         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
    4145         288 :                 ladderindex[i][j] = ((j>=0)&&(j<=kssdlayladdernumber[i]-index[i]-1)) ? 
    4146          72 :                                                           j+index[i] : j+index[i]-kssdlayladdernumber[i]; 
    4147         144 :                 i ==0 ? fSSDLayer5->AddNode(fladder[0],ladderindex[i][j],flayermatrix[i][j]) : 
    4148          38 :                         fSSDLayer6->AddNode(fladder[1],ladderindex[i][j],flayermatrix[i][j]);
    4149             :         }
    4150             : 
    4151           1 :   fSSDLayer5->GetShape()->ComputeBBox(); //RS: enforce recompting of BBox
    4152           1 :   fSSDLayer6->GetShape()->ComputeBBox();
    4153             :   /////////////////////////////////////////////////////////////
    4154             :   // Deallocating memory
    4155             :   /////////////////////////////////////////////////////////////
    4156          10 :   for(Int_t i=0; i<fgklayernumber; i++) delete [] ladderindex[i];
    4157           1 : }
    4158             : ////////////////////////////////////////////////////////////////////////////////
    4159             : void AliITSv11GeometrySSD::Layer5(TGeoVolume* moth){
    4160             :   /////////////////////////////////////////////////////////////
    4161             :   // Insert the layer 5 in the mother volume. 
    4162             :   /////////////////////////////////////////////////////////////
    4163           2 :   if (! moth) {
    4164           0 :     AliError("Can't insert layer5, mother is null!\n");
    4165           0 :     return;
    4166             :   };
    4167           2 :   if(!fSSDLayer5) SetLayer();
    4168           1 :   fMotherVol = moth;
    4169           2 :   TGeoTranslation* centerITSlayer5trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay5LadderLength
    4170           1 :                                                                                 + fgkLay5CenterITSPosition);
    4171           1 :   moth->AddNode(fSSDLayer5,1,centerITSlayer5trans);
    4172           2 :  }
    4173             : ////////////////////////////////////////////////////////////////////////////////
    4174             : void AliITSv11GeometrySSD::Layer6(TGeoVolume* moth){
    4175             :   /////////////////////////////////////////////////////////////
    4176             :   // Insert the layer 6 in the mother volume. 
    4177             :   /////////////////////////////////////////////////////////////
    4178           2 :   if (! moth) {
    4179           0 :     AliError("AliITSv11GeometrySSD: Can't insert layer6, mother is null!\n");
    4180           0 :     return;
    4181             :   };
    4182           1 :   if(!fSSDLayer6) SetLayer();
    4183           1 :   fMotherVol = moth;
    4184           2 :   TGeoTranslation* centerITSlayer6trans = new TGeoTranslation(0.,0.,-0.5*fgkSSDLay6LadderLength
    4185           1 :                                                                                 + fgkLay6CenterITSPosition);
    4186           1 :   moth->AddNode(fSSDLayer6,1,centerITSlayer6trans);
    4187           2 :  }
    4188             :  ////////////////////////////////////////////////////////////////////////////////
    4189             :  TList* AliITSv11GeometrySSD::GetMountingBlockSupport(Int_t nedges){
    4190             :   /////////////////////////////////////////////////////////////
    4191             :   // Method generating the Arc structure of Ladder Support 
    4192             :   /////////////////////////////////////////////////////////////
    4193             :   const Int_t kssdlayladdernumber[fgklayernumber] = 
    4194             :                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
    4195           2 :   Double_t mountingsupportedge[fgklayernumber];
    4196           1 :   Double_t mountingblockratio[fgklayernumber];
    4197           1 :   Double_t theta[fgklayernumber];
    4198           1 :   Double_t phi[fgklayernumber];
    4199           1 :   Double_t psi0[fgklayernumber];
    4200           1 :   Double_t deltapsi[fgklayernumber];
    4201           1 :   TVector3* mountingsupportedgevector[fgklayernumber];
    4202           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4203           2 :         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
    4204           4 :     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
    4205           4 :                                                           * (TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
    4206           2 :                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
    4207           4 :                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
    4208           2 :                                                           / kssdlayladdernumber[i])));
    4209           2 :     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]/fgkMountingBlockSupportRadius[i]);
    4210           2 :     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
    4211           4 :         mountingsupportedgevector[i] = new TVector3();
    4212           2 :         mountingsupportedgevector[i]->SetX(-0.5*fgkSSDMountingBlockLength[0]);
    4213           4 :         mountingsupportedgevector[i]->SetY(fgkMountingBlockSupportRadius[i]*TMath::Sqrt(
    4214           4 :                                                         (1.-mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])*
    4215           2 :                                                         (1.+mountingsupportedgevector[i]->X()/fgkMountingBlockSupportRadius[i])));
    4216           2 :     psi0[i] = 0.5*TMath::Pi()-phi[i];   
    4217           2 :     deltapsi[i] = (theta[i]+phi[i])/nedges;
    4218             :   }
    4219           1 :   TVector3** vertex[fgklayernumber];
    4220           1 :   TList* vertexlist[fgklayernumber];
    4221           1 :   Int_t indexedge[fgklayernumber] = {0,0};
    4222           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4223           2 :         vertex[i] = new TVector3*[nedges+1];
    4224           4 :         vertexlist[i] = new TList();
    4225             :   } 
    4226           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4227          88 :         for(Int_t j=0; j<nedges+1; j++){
    4228         126 :                 vertex[i][j] = new TVector3(fgkMountingBlockSupportRadius[i]*TMath::Cos(psi0[i]+j*deltapsi[i]),
    4229          42 :                                             fgkMountingBlockSupportRadius[i]*TMath::Sin(psi0[i]+j*deltapsi[i]), 0);
    4230          78 :                 if(vertex[i][j]->X()>mountingsupportedgevector[i]->X()) indexedge[i]++;
    4231          42 :                 vertexlist[i]->Add(vertex[i][j]);
    4232             :         }
    4233           2 :         vertexlist[i]->AddAt(mountingsupportedgevector[i],indexedge[i]);
    4234             :   }
    4235           1 :   Double_t** xsidevertex = new Double_t*[fgklayernumber]; 
    4236           1 :   Double_t** ysidevertex = new Double_t*[fgklayernumber]; 
    4237           1 :   Double_t** xcentervertex = new Double_t*[fgklayernumber]; 
    4238           1 :   Double_t** ycentervertex = new Double_t*[fgklayernumber]; 
    4239           1 :   Double_t** xsidelowervertex = new Double_t*[fgklayernumber];
    4240           1 :   Double_t** ysidelowervertex = new Double_t*[fgklayernumber];  
    4241           1 :   Double_t** xcenterlowervertex = new Double_t*[fgklayernumber];
    4242           1 :   Double_t** ycenterlowervertex = new Double_t*[fgklayernumber];  
    4243           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4244           2 :     xsidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
    4245           2 :     ysidevertex[i] = new Double_t[vertexlist[i]->GetSize()+2];
    4246           2 :     xcentervertex[i] = new Double_t[indexedge[i]+3];
    4247           2 :     ycentervertex[i] = new Double_t[indexedge[i]+3];
    4248           2 :         xsidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
    4249           2 :         ysidelowervertex[i] = new Double_t[vertexlist[i]->GetSize()+1];
    4250           2 :         xcenterlowervertex[i] = new Double_t[indexedge[i]+3];
    4251           2 :         ycenterlowervertex[i] = new Double_t[indexedge[i]+3];
    4252          92 :         for(Int_t j=0; j<vertexlist[i]->GetSize(); j++){
    4253          44 :                 xsidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
    4254          44 :                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
    4255          44 :                 ysidevertex[i][j!=vertexlist[i]->GetSize()-1?j+3:0] = 
    4256          44 :                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
    4257          44 :                 xsidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->X();
    4258          44 :                 ysidelowervertex[i][j] = ((TVector3*)vertexlist[i]->At(vertexlist[i]->GetSize()-1-j))->Y();
    4259          44 :                 if(j<indexedge[i]+1){
    4260          38 :                         xcentervertex[i][j!=indexedge[i]?j+3:0] = 
    4261          38 :                                                                                 ((TVector3*)vertexlist[i]->At(j))->X();
    4262          38 :                         ycentervertex[i][j!=indexedge[i]?j+3:0] = 
    4263          38 :                                                                                 ((TVector3*)vertexlist[i]->At(j))->Y();
    4264          38 :                         xcenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->X();
    4265          38 :                         ycenterlowervertex[i][j+1] = ((TVector3*)vertexlist[i]->At(indexedge[i]-j))->Y();
    4266          38 :                 }
    4267             :         }
    4268           2 :         xsidevertex[i][1] = xsidevertex[i][0]; 
    4269           2 :         ysidevertex[i][1] = fgkMountingBlockSupportRadius[i]; 
    4270           2 :         xsidevertex[i][2] = xsidevertex[i][3]; 
    4271           2 :         ysidevertex[i][2] = fgkMountingBlockSupportRadius[i]; 
    4272           2 :         xcentervertex[i][1] = xcentervertex[i][0]; 
    4273           2 :         ycentervertex[i][1] = fgkMountingBlockSupportRadius[i]; 
    4274           2 :         xcentervertex[i][2] = xcentervertex[i][3]; 
    4275           2 :         ycentervertex[i][2] = fgkMountingBlockSupportRadius[i]; 
    4276           2 :         xsidelowervertex[i][vertexlist[i]->GetSize()] = xsidelowervertex[i][vertexlist[i]->GetSize()-1];
    4277           2 :         ysidelowervertex[i][vertexlist[i]->GetSize()] = ysidelowervertex[i][0];
    4278           2 :         xcenterlowervertex[i][0] = xcenterlowervertex[i][1];
    4279           2 :         ycenterlowervertex[i][0] = ysidevertex[i][0];
    4280           2 :         xcenterlowervertex[i][indexedge[i]+2] = xsidelowervertex[i][vertexlist[i]->GetSize()];
    4281           2 :         ycenterlowervertex[i][indexedge[i]+2] = ycenterlowervertex[i][0];
    4282             :   }
    4283             :   /////////////////////////////////////////////////////////////
    4284             :   // Building the Arc Structure of Ladder Supports 
    4285             :   /////////////////////////////////////////////////////////////
    4286           1 :   TGeoXtru* sidemountingblocksupportshape[fgklayernumber];
    4287           1 :   TGeoXtru* centermountingsupportshape[fgklayernumber];
    4288           1 :   TGeoXtru* sideladdersupportpieceshape[fgklayernumber];
    4289           1 :   TGeoXtru* centerladdersupportpieceshape[fgklayernumber];
    4290           1 :   TGeoVolume* sidemountingblocksupport[fgklayernumber];
    4291           1 :   TGeoVolume* centermountingblocksupport[fgklayernumber];
    4292           1 :   TGeoVolume* sideladdersupportpiece[fgklayernumber];
    4293           1 :   TGeoVolume* centerladdersupportpiece[fgklayernumber];
    4294           1 :   char sidemountingblockname[100];
    4295           1 :   char centermountingblockname[100];
    4296           1 :   char sideladdersupportpiecename[100];
    4297           1 :   char centerladdersupportpiecename[100];
    4298           6 :   for(Int_t i=0; i<fgklayernumber; i++){ 
    4299           2 :     snprintf(sidemountingblockname,100,"MountingBlockSupportSideLay%dArc",i+5);
    4300           2 :     snprintf(centermountingblockname,100,"MountingBlockSupportCenterLay%dArc",i+5);
    4301           2 :     snprintf(sideladdersupportpiecename,100,"SideLadderSupportPieceLay%d",i+5);
    4302           2 :     snprintf(centerladdersupportpiecename,100,"CenterLadderSupportPieceLay%d",i+5);
    4303           4 :     sidemountingblocksupportshape[i] = new TGeoXtru(2);
    4304           4 :     sidemountingblocksupportshape[i]->DefinePolygon(vertexlist[i]->GetSize()+2,
    4305           2 :                                                                                                 xsidevertex[i],ysidevertex[i]);
    4306           4 :     sidemountingblocksupportshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
    4307           2 :                                                                                                          -fgkMountingBlockSupportWidth[0]);
    4308           2 :     sidemountingblocksupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
    4309           6 :     sidemountingblocksupport[i] = new TGeoVolume(sidemountingblockname,
    4310           2 :                                                                           sidemountingblocksupportshape[i],
    4311           2 :                                                                                   fSSDAlCoolBlockMedium);
    4312           2 :         sidemountingblocksupport[i]->SetLineColor(9);
    4313           4 :         centermountingsupportshape[i] = new TGeoXtru(2);
    4314           4 :     centermountingsupportshape[i]->DefinePolygon(indexedge[i]+3,
    4315           2 :                                                                                                 xcentervertex[i],ycentervertex[i]);
    4316           2 :         centermountingsupportshape[i]->DefineSection(0,0.);
    4317           4 :     centermountingsupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
    4318           2 :                                                                                                   -fgkMountingBlockSupportWidth[0]);
    4319             : 
    4320           6 :     centermountingblocksupport[i] = new TGeoVolume(centermountingblockname,
    4321           2 :                                                                           centermountingsupportshape[i],
    4322           2 :                                                                                   fSSDAlCoolBlockMedium);
    4323           2 :         centermountingblocksupport[i]->SetLineColor(9);
    4324           4 :         sideladdersupportpieceshape[i] = new TGeoXtru(2);
    4325           4 :     sideladdersupportpieceshape[i]->DefinePolygon(vertexlist[i]->GetSize()+1,
    4326           2 :                                                                                                 xsidelowervertex[i],ysidelowervertex[i]);
    4327           4 :         sideladdersupportpieceshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
    4328           2 :                                                                                                          -fgkMountingBlockSupportWidth[0]);
    4329           2 :     sideladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
    4330           6 :     sideladdersupportpiece[i] = new TGeoVolume(sideladdersupportpiecename,
    4331           2 :                                                                           sideladdersupportpieceshape[i],
    4332           2 :                                                                                   fSSDCarbonFiberMedium);
    4333           2 :         sideladdersupportpiece[i]->SetLineColor(fColorAl);
    4334           4 :         centerladdersupportpieceshape[i] = new TGeoXtru(2);
    4335           4 :     centerladdersupportpieceshape[i]->DefinePolygon(indexedge[i]+3,
    4336           2 :                                                                                                 xcenterlowervertex[i],ycenterlowervertex[i]);
    4337           2 :         centerladdersupportpieceshape[i]->DefineSection(0,0.0);
    4338           4 :     centerladdersupportpieceshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]
    4339           2 :                                                                                                   -fgkMountingBlockSupportWidth[0]);
    4340           6 :     centerladdersupportpiece[i] = new TGeoVolume(centerladdersupportpiecename,
    4341           2 :                                                                           centerladdersupportpieceshape[i],
    4342           2 :                                                                                   fSSDCarbonFiberMedium);
    4343           2 :         centerladdersupportpiece[i]->SetLineColor(fColorAl);
    4344             :   }
    4345             :   /////////////////////////////////////////////////////////////
    4346             :   // Building the Up Structure of Ladder Supports 
    4347             :   /////////////////////////////////////////////////////////////
    4348           1 :   TGeoBBox** mountingblocksupportboxupshape[fgklayernumber];    
    4349           6 :   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxupshape[i] = new TGeoBBox*[2];
    4350           1 :   TGeoBBox** mountingblocksupportboxdownshape[fgklayernumber];  
    4351           6 :   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdownshape[i] = new TGeoBBox*[2];
    4352           1 :   TGeoVolume** mountingblocksupportboxdown[fgklayernumber];
    4353             :   //////////////////////////////////////////////////////////
    4354             :   // Setting the volume for TGeoXtru Mounting Block Piece  
    4355             :   //////////////////////////////////////////////////////////
    4356           1 :   TGeoVolume** mountingblocksupportboxup[fgklayernumber];
    4357           1 :   TGeoXtru* mountingblockpiecedownshape[fgklayernumber];
    4358           1 :   TGeoVolume* mountingblockpiecedown[fgklayernumber];
    4359           1 :   TGeoXtru* mountingblockpieceupshape[fgklayernumber];
    4360           1 :   TGeoVolume* mountingblockpieceup[fgklayernumber];
    4361           1 :   Double_t mountingblockpieceupxvertex[fgklayernumber][8];
    4362           1 :   Double_t mountingblockpieceupyvertex[fgklayernumber][8];
    4363           1 :   Double_t mountingblockpiecedownxvertex[fgklayernumber][8];
    4364           1 :   Double_t mountingblockpiecedownyvertex[fgklayernumber][8];
    4365           1 :   char mountingblockpiecedownname[100];
    4366           1 :   char mountingblockpieceupname[100];
    4367           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4368             :     ///////////////////////////
    4369             :     // Mounting Block Down Vertex
    4370             :     ///////////////////////////
    4371           4 :         mountingblockpiecedownshape[i] = new TGeoXtru(2);
    4372           2 :         snprintf(mountingblockpiecedownname,100,"MountingBlockPieceDownLay%d",i+5);
    4373           2 :         mountingblockpiecedownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];        
    4374           4 :         mountingblockpiecedownyvertex[i][0] = fgkMountingBlockSupportRadius[i]
    4375           2 :                                               + fgkMountingBlockSupportDownHeight 
    4376           2 :                                               - fgkSSDLadderVerticalDisalignment;
    4377           2 :         mountingblockpiecedownxvertex[i][1] = mountingblockpiecedownxvertex[i][0];      
    4378           4 :         mountingblockpiecedownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
    4379           2 :                                                                                 + fgkSSDMountingBlockHeight[1]
    4380           2 :                                                                                 - 0.5*fgkCoolingTubeSupportHeight
    4381           2 :                                                                                 - fgkSSDModuleCoolingBlockToSensor;
    4382           2 :         mountingblockpiecedownxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0]; 
    4383           2 :         mountingblockpiecedownyvertex[i][2] = mountingblockpiecedownyvertex[i][1];
    4384           2 :         mountingblockpiecedownxvertex[i][3] = mountingblockpiecedownxvertex[i][2];      
    4385           2 :         mountingblockpiecedownyvertex[i][3] = mountingblockpiecedownyvertex[i][0];
    4386           2 :         mountingblockpiecedownxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
    4387           2 :         mountingblockpiecedownyvertex[i][4] = mountingblockpiecedownyvertex[i][0];
    4388           2 :         mountingblockpiecedownxvertex[i][5] = mountingblockpiecedownxvertex[i][4];
    4389           4 :         mountingblockpiecedownyvertex[i][5] = mountingblockpiecedownyvertex[i][4]
    4390           2 :                                                                                 + fgkSSDMountingBlockHeight[2]
    4391           2 :                                                                                 - fgkSSDMountingBlockHeight[0];
    4392           2 :         mountingblockpiecedownxvertex[i][6] = -mountingblockpiecedownxvertex[i][4];
    4393           2 :         mountingblockpiecedownyvertex[i][6] = mountingblockpiecedownyvertex[i][5];
    4394           2 :         mountingblockpiecedownxvertex[i][7] = mountingblockpiecedownxvertex[i][6];      
    4395           2 :         mountingblockpiecedownyvertex[i][7] = mountingblockpiecedownyvertex[i][0];
    4396           4 :         mountingblockpiecedownshape[i]->DefinePolygon(8,mountingblockpiecedownxvertex[i],
    4397           2 :                                                                                                          mountingblockpiecedownyvertex[i]);
    4398           2 :         mountingblockpiecedownshape[i]->DefineSection(0,0.0);
    4399           2 :         mountingblockpiecedownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
    4400           6 :         mountingblockpiecedown[i] = new TGeoVolume(mountingblockpiecedownname,
    4401           2 :                                                                  mountingblockpiecedownshape[i],fSSDMountingBlockMedium);
    4402           2 :         mountingblockpiecedown[i]->SetLineColor(fColorG10);
    4403             : 
    4404             :     ///////////////////////////
    4405             :     // Mounting Block Up Vertex
    4406             :     ///////////////////////////
    4407           4 :         mountingblockpieceupshape[i] = new TGeoXtru(2);
    4408           2 :         snprintf(mountingblockpieceupname,100,"MountingBlockPieceUpLay%d",i+5);
    4409           2 :         mountingblockpieceupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0];  
    4410           4 :         mountingblockpieceupyvertex[i][0] = fgkMountingBlockSupportRadius[i]
    4411           2 :                                                                                 + fgkMountingBlockSupportUpHeight[i]
    4412           2 :                                               - fgkSSDLadderVerticalDisalignment;
    4413           2 :         mountingblockpieceupxvertex[i][1] = mountingblockpieceupxvertex[i][0];  
    4414           4 :         mountingblockpieceupyvertex[i][1] = mountingblockpieceupyvertex[i][0]
    4415           2 :                                                                                 + fgkSSDMountingBlockHeight[1]
    4416           2 :                                                                                 - 0.5*fgkCoolingTubeSupportHeight
    4417           2 :                                                                                 - fgkSSDModuleCoolingBlockToSensor;
    4418           2 :         mountingblockpieceupxvertex[i][2] = 0.5*fgkSSDMountingBlockLength[0];   
    4419           2 :         mountingblockpieceupyvertex[i][2] = mountingblockpieceupyvertex[i][1];
    4420           2 :         mountingblockpieceupxvertex[i][3] = mountingblockpieceupxvertex[i][2];  
    4421           2 :         mountingblockpieceupyvertex[i][3] = mountingblockpieceupyvertex[i][0];
    4422           2 :         mountingblockpieceupxvertex[i][4] = 0.5*fgkSSDMountingBlockLength[1];
    4423           2 :         mountingblockpieceupyvertex[i][4] = mountingblockpieceupyvertex[i][0];
    4424           2 :         mountingblockpieceupxvertex[i][5] = mountingblockpieceupxvertex[i][4];
    4425           4 :         mountingblockpieceupyvertex[i][5] = mountingblockpieceupyvertex[i][4]
    4426           2 :                                                                                 + fgkSSDMountingBlockHeight[2]
    4427           2 :                                                                                 - fgkSSDMountingBlockHeight[0];
    4428           2 :         mountingblockpieceupxvertex[i][6] = -mountingblockpieceupxvertex[i][4];
    4429           2 :         mountingblockpieceupyvertex[i][6] = mountingblockpieceupyvertex[i][5];
    4430           2 :         mountingblockpieceupxvertex[i][7] = mountingblockpieceupxvertex[i][6];  
    4431           2 :         mountingblockpieceupyvertex[i][7] = mountingblockpieceupyvertex[i][0];
    4432             : 
    4433           4 :         mountingblockpieceupshape[i]->DefinePolygon(8,mountingblockpieceupxvertex[i],
    4434           2 :                                                                                                          mountingblockpieceupyvertex[i]);
    4435           2 :         mountingblockpieceupshape[i]->DefineSection(0,0.0);
    4436           2 :         mountingblockpieceupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
    4437           6 :         mountingblockpieceup[i] = new TGeoVolume(mountingblockpieceupname,
    4438           2 :                                                                 mountingblockpieceupshape[i],fSSDMountingBlockMedium);
    4439           2 :         mountingblockpieceup[i]->SetLineColor(fColorG10);
    4440             :  }
    4441             :   ///////////////////////////////////////////////////////////////////
    4442             :   // Setting the volume for TGeoXtru Mounting Block Support Trapezoid  
    4443             :   ///////////////////////////////////////////////////////////////////
    4444           1 :   TGeoXtru* mountingblocksupportrapezoidownshape[fgklayernumber];
    4445           1 :   TGeoXtru* mountingblocksupportrapezoidupshape[fgklayernumber];
    4446           1 :   TGeoVolume* mountingblocksupportrapezoidown[fgklayernumber];
    4447           1 :   TGeoVolume* mountingblocksupportrapezoidup[fgklayernumber];
    4448           1 :   Double_t mountingblocksupportrapezoidownxvertex[fgklayernumber][5];
    4449           1 :   Double_t mountingblocksupportrapezoidownyvertex[fgklayernumber][5];
    4450           1 :   Double_t mountingblocksupportrapezoidupxvertex[fgklayernumber][5];
    4451           1 :   Double_t mountingblocksupportrapezoidupyvertex[fgklayernumber][5];
    4452           1 :   char mountingblocksupportrapezoidowname[100];
    4453           1 :   char mountingblocksupportrapezoidupname[100];
    4454             :   Double_t scalefactor = 3./4.;
    4455           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4456             :   ////////////////////////////////////////////
    4457             :   // Mounting Block Support Down Trapezoid Vertex 
    4458             :   ////////////////////////////////////////////
    4459           4 :         mountingblocksupportrapezoidownshape[i] = new TGeoXtru(2);
    4460           4 :         mountingblocksupportrapezoidownxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
    4461           2 :                                                                                                  - mountingsupportedge[i];
    4462           2 :         mountingblocksupportrapezoidownyvertex[i][0] = mountingblockpiecedownyvertex[i][0];
    4463           2 :         mountingblocksupportrapezoidownxvertex[i][1] = 
    4464           2 :                                                                                 mountingblocksupportrapezoidownxvertex[i][0];
    4465           4 :         mountingblocksupportrapezoidownyvertex[i][1] = mountingblockpiecedownyvertex[i][0]
    4466           4 :                                                                                                  + scalefactor*(mountingblockpiecedownyvertex[i][1]
    4467           2 :                                                                                              - mountingblockpiecedownyvertex[i][0]);
    4468           2 :         mountingblocksupportrapezoidownxvertex[i][2] = -0.5*fgkSSDSensorWidth;
    4469           2 :         mountingblocksupportrapezoidownyvertex[i][2] = mountingblockpiecedownyvertex[i][1]; 
    4470           2 :         mountingblocksupportrapezoidownxvertex[i][3] = mountingblockpiecedownxvertex[i][0];
    4471           2 :         mountingblocksupportrapezoidownyvertex[i][3] = mountingblocksupportrapezoidownyvertex[i][2];
    4472           2 :         mountingblocksupportrapezoidownxvertex[i][4] = mountingblocksupportrapezoidownxvertex[i][3];
    4473           2 :         mountingblocksupportrapezoidownyvertex[i][4] = mountingblocksupportrapezoidownyvertex[i][0];
    4474             : 
    4475           4 :         mountingblocksupportrapezoidownshape[i]->DefinePolygon(5,mountingblocksupportrapezoidownxvertex[i],
    4476           2 :                                                                                                                mountingblocksupportrapezoidownyvertex[i]);
    4477           4 :         mountingblocksupportrapezoidownshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
    4478           2 :                                                                                                                         -fgkMountingBlockSupportWidth[0]);
    4479           2 :         mountingblocksupportrapezoidownshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
    4480           2 :         snprintf(mountingblocksupportrapezoidowname,100,"MountingBlockSuppTrapezoidDownLay%d",i+5);
    4481           6 :         mountingblocksupportrapezoidown[i] = new TGeoVolume(mountingblocksupportrapezoidowname,
    4482           2 :                                                                 mountingblocksupportrapezoidownshape[i],fSSDCarbonFiberMedium);
    4483           2 :         mountingblocksupportrapezoidown[i]->SetLineColor(9);
    4484             :   ////////////////////////////////////////////
    4485             :   // Mounting Block Support Up Trapezoid Vertex 
    4486             :   ////////////////////////////////////////////
    4487           4 :         mountingblocksupportrapezoidupshape[i] = new TGeoXtru(2);
    4488           4 :         mountingblocksupportrapezoidupxvertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
    4489           2 :                                                                                                  - mountingsupportedge[i];
    4490           2 :         mountingblocksupportrapezoidupyvertex[i][0] = mountingblockpieceupyvertex[i][0];
    4491           2 :         mountingblocksupportrapezoidupxvertex[i][1] = 
    4492           2 :                                                                                 mountingblocksupportrapezoidupxvertex[i][0];
    4493           2 :         mountingblocksupportrapezoidupyvertex[i][1] = 
    4494           2 :                                                                                                mountingblockpieceupyvertex[i][0]
    4495           4 :                                                                                                  + scalefactor*(mountingblockpieceupyvertex[i][1]
    4496           2 :                                                                                              - mountingblockpieceupyvertex[i][0]);
    4497           2 :         mountingblocksupportrapezoidupxvertex[i][2] = -0.5*fgkSSDSensorWidth;
    4498           2 :         mountingblocksupportrapezoidupyvertex[i][2] = mountingblockpieceupyvertex[i][1]; 
    4499           2 :         mountingblocksupportrapezoidupxvertex[i][3] = mountingblockpieceupxvertex[i][0];
    4500           2 :         mountingblocksupportrapezoidupyvertex[i][3] = mountingblocksupportrapezoidupyvertex[i][2];
    4501           2 :         mountingblocksupportrapezoidupxvertex[i][4] = mountingblocksupportrapezoidupxvertex[i][3];
    4502           2 :         mountingblocksupportrapezoidupyvertex[i][4] = mountingblocksupportrapezoidupyvertex[i][0];
    4503             : 
    4504           4 :         mountingblocksupportrapezoidupshape[i]->DefinePolygon(5,mountingblocksupportrapezoidupxvertex[i],
    4505           2 :                                                                                                                mountingblocksupportrapezoidupyvertex[i]);
    4506           4 :         mountingblocksupportrapezoidupshape[i]->DefineSection(0,fgkMountingBlockSupportWidth[1]
    4507           2 :                                                                                                                         -fgkMountingBlockSupportWidth[0]);
    4508           2 :         mountingblocksupportrapezoidupshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
    4509           2 :         snprintf(mountingblocksupportrapezoidupname,100,"MountingBlockSuppTrapezoidUpLay%d",i+5);
    4510           6 :         mountingblocksupportrapezoidup[i] = new TGeoVolume(mountingblocksupportrapezoidupname,
    4511           2 :                                                                 mountingblocksupportrapezoidupshape[i],fSSDCarbonFiberMedium);
    4512           2 :         mountingblocksupportrapezoidup[i]->SetLineColor(9);
    4513             :   }
    4514             :   ///////////////////////////////////////////////////////////////////
    4515           6 :   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxdown[i] = new TGeoVolume*[3];
    4516           6 :   for(Int_t i=0; i<fgklayernumber; i++) mountingblocksupportboxup[i] = new TGeoVolume*[3];
    4517           1 :   Double_t boxoriginup[fgklayernumber][2][3];
    4518           1 :   Double_t boxorigindown[fgklayernumber][2][3];
    4519           1 :   char mountingblocksupportboxdownname[100];
    4520           1 :   char mountingblocksupportboxupname[100];
    4521           1 :   TGeoRotation* mountingblocksupportrot = new TGeoRotation();
    4522           1 :   mountingblocksupportrot->SetAngles(90.,180.,-90);
    4523           1 :   TGeoRotation* globalrefladdersupportrot = new TGeoRotation();
    4524           1 :   globalrefladdersupportrot->SetAngles(0.,90.,0.);
    4525           1 :   TGeoHMatrix* laddersupportmatrix[2];
    4526           2 :   laddersupportmatrix[0] = new TGeoHMatrix(*globalrefladdersupportrot);
    4527           3 :   laddersupportmatrix[1] = new TGeoHMatrix((*globalrefladdersupportrot)*(*mountingblocksupportrot));
    4528             :   /////////////////////////////////////////////////////////////
    4529             :   // Creating Mother Volume for Containment
    4530             :   /////////////////////////////////////////////////////////////
    4531           1 :   Double_t *xmothervertex[fgklayernumber];
    4532           1 :   Double_t *ymothervertex[fgklayernumber];
    4533           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4534           2 :         xmothervertex[i] = new Double_t[8];
    4535           2 :         ymothervertex[i] = new Double_t[8];
    4536             :   }  
    4537           1 :   TGeoXtru* downmotherladdersupportshape[fgklayernumber];
    4538           1 :   TGeoVolume* downmotherladdersupport[fgklayernumber]; 
    4539           1 :   TGeoXtru* upmotherladdersupportshape[fgklayernumber];
    4540           1 :   TGeoVolume* upmotherladdersupport[fgklayernumber]; 
    4541           1 :   char upmotheladdersupportname[100];
    4542           1 :   char downmotheladdersupportname[100];
    4543           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4544           4 :         xmothervertex[i][0] = -0.5*fgkSSDMountingBlockLength[0]
    4545           2 :                                                     -  mountingsupportedge[i];
    4546           2 :         ymothervertex[i][0] = -fgkMountingBlockSupportWidth[1];
    4547           2 :         xmothervertex[i][1] = xmothervertex[i][0];
    4548           4 :         ymothervertex[i][1] = -fgkMountingBlockSupportWidth[1]
    4549           2 :                                                         + fgkMountingBlockSupportWidth[0];
    4550           2 :         xmothervertex[i][2] = -0.5*fgkSSDMountingBlockLength[0];
    4551           2 :         ymothervertex[i][2] = ymothervertex[i][1];
    4552           2 :         xmothervertex[i][3] = xmothervertex[i][2];
    4553           2 :         ymothervertex[i][3] = -ymothervertex[i][0];
    4554           2 :         xmothervertex[i][4] = -xmothervertex[i][0];
    4555           2 :         ymothervertex[i][4] = ymothervertex[i][3];
    4556           2 :         xmothervertex[i][5] = xmothervertex[i][4];
    4557           2 :         ymothervertex[i][5] = -ymothervertex[i][1];
    4558           2 :         xmothervertex[i][6] = -xmothervertex[i][2];
    4559           2 :         ymothervertex[i][6] = ymothervertex[i][5];
    4560           2 :         xmothervertex[i][7] = xmothervertex[i][6];
    4561           2 :         ymothervertex[i][7] = ymothervertex[i][0];
    4562             : 
    4563           2 :         snprintf(downmotheladdersupportname,100,"LadderSupportDownLay%d",i+5);
    4564           2 :         snprintf(upmotheladdersupportname,100,"LadderSupportUpLay%d",i+5);
    4565             : 
    4566           4 :         downmotherladdersupportshape[i] = new TGeoXtru(2);
    4567           2 :         downmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
    4568           2 :         downmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
    4569           4 :         downmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
    4570           2 :                                                                    +                       fgkMountingBlockSupportDownHeight
    4571           2 :                                                                    +                       fgkSSDMountingBlockHeight[1]
    4572           2 :                                                                    -                       0.5*fgkCoolingTubeSupportHeight
    4573           2 :                                                                    -                       fgkSSDModuleCoolingBlockToSensor
    4574           2 :                                                        - fgkSSDLadderVerticalDisalignment);
    4575             :         
    4576             : //                                                 - fgkSSDModuleVerticalDisalignment);
    4577             :         //downmotherladdersupport[i] = new TGeoVolumeAssembly(downmotheladdersupportname);
    4578             : 
    4579           6 :         downmotherladdersupport[i] = new TGeoVolume(downmotheladdersupportname,
    4580           2 :                                                                           downmotherladdersupportshape[i],fSSDAir);
    4581           4 :     upmotherladdersupportshape[i] = new TGeoXtru(2);
    4582           2 :         upmotherladdersupportshape[i]->DefinePolygon(8,xmothervertex[i],ymothervertex[i]);
    4583           2 :         upmotherladdersupportshape[i]->DefineSection(0,ysidevertex[i][0]);
    4584           4 :     upmotherladdersupportshape[i]->DefineSection(1,ysidevertex[i][1]
    4585           2 :                                                                    +                       fgkMountingBlockSupportUpHeight[i]
    4586           2 :                                                                    +                       fgkSSDMountingBlockHeight[1]
    4587           2 :                                                                    -                       0.5*fgkCoolingTubeSupportHeight
    4588           2 :                                                                    -                       fgkSSDModuleCoolingBlockToSensor
    4589           2 :                                                  - fgkSSDLadderVerticalDisalignment);
    4590             : 
    4591           6 :      upmotherladdersupport[i] = new TGeoVolume(upmotheladdersupportname,
    4592           2 :                                                                                           upmotherladdersupportshape[i],fSSDAir);
    4593             :   }
    4594           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4595             :         /////////////////////////
    4596             :         // Setting the box origin
    4597             :         /////////////////////////
    4598           2 :         boxorigindown[i][0][0] = -0.5*mountingsupportedge[i];
    4599           4 :         boxorigindown[i][0][1] =  fgkMountingBlockSupportRadius[i]
    4600           2 :                                                    +  0.5*fgkMountingBlockSupportDownHeight
    4601           2 :                                   - 0.5*fgkSSDLadderVerticalDisalignment;
    4602           4 :         boxorigindown[i][0][2] =  fgkMountingBlockSupportWidth[1]
    4603           2 :                                                    -  0.5*fgkMountingBlockSupportWidth[0];
    4604             :   
    4605           2 :         boxorigindown[i][1][0] = 0.0;
    4606           2 :         boxorigindown[i][1][1] = boxorigindown[i][0][1];
    4607           4 :         boxorigindown[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
    4608           2 :                                                    -      fgkMountingBlockSupportWidth[0]);
    4609             :                                                    
    4610           2 :         boxoriginup[i][0][0] = -0.5*mountingsupportedge[i];
    4611           4 :         boxoriginup[i][0][1] = fgkMountingBlockSupportRadius[i]
    4612           2 :                                + 0.5*fgkMountingBlockSupportUpHeight[i]
    4613           2 :                                - 0.5*fgkSSDLadderVerticalDisalignment;
    4614           4 :         boxoriginup[i][0][2] = fgkMountingBlockSupportWidth[1]
    4615           2 :                                                  - 0.5*fgkMountingBlockSupportWidth[0];
    4616             :   
    4617           2 :         boxoriginup[i][1][0] = 0.0;
    4618           2 :         boxoriginup[i][1][1] = boxoriginup[i][0][1];
    4619           4 :         boxoriginup[i][1][2] = 0.5*(fgkMountingBlockSupportWidth[1]
    4620           2 :                                                  - fgkMountingBlockSupportWidth[0]);
    4621             :   
    4622             :         /////////////////////////
    4623             :     // Setting the boxes    
    4624             :         /////////////////////////
    4625           8 :         mountingblocksupportboxdownshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
    4626           2 :                                                                                  +  fgkSSDMountingBlockLength[0]),
    4627           2 :                                                                                         0.5*fgkMountingBlockSupportDownHeight - 0.5*fgkSSDLadderVerticalDisalignment,
    4628           2 :                                                                                         0.5*fgkMountingBlockSupportWidth[0],
    4629           2 :                                                                                         boxorigindown[i][0]);
    4630           6 :         mountingblocksupportboxdownshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
    4631           2 :                                                                                         0.5*fgkMountingBlockSupportDownHeight - 0.5*fgkSSDLadderVerticalDisalignment,
    4632           4 :                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
    4633           2 :                                                                                  -  fgkMountingBlockSupportWidth[0]),
    4634           2 :                                                                                         boxorigindown[i][1]);
    4635             :                                                                                         
    4636           8 :         mountingblocksupportboxupshape[i][0] = new TGeoBBox(0.5*(mountingsupportedge[i]
    4637           2 :                                                                                  +  fgkSSDMountingBlockLength[0]),
    4638           2 :                                                                                         0.5*fgkMountingBlockSupportUpHeight[i] - 0.5*fgkSSDLadderVerticalDisalignment,
    4639           2 :                                                                                         0.5*fgkMountingBlockSupportWidth[0],
    4640           2 :                                                                                         boxoriginup[i][0]);
    4641             : 
    4642           6 :         mountingblocksupportboxupshape[i][1] = new TGeoBBox(0.5*fgkSSDMountingBlockLength[0],
    4643           2 :                                                                                         0.5*fgkMountingBlockSupportUpHeight[i] - 0.5*fgkSSDLadderVerticalDisalignment,
    4644           4 :                                                                                         0.5*(fgkMountingBlockSupportWidth[1]
    4645           2 :                                                                      -  fgkMountingBlockSupportWidth[0]),
    4646           2 :                                                                                         boxoriginup[i][1]);
    4647             :         ///////////////////////////////////////
    4648             :         // Adding the Volumes to Mother Volume    
    4649             :         ///////////////////////////////////////
    4650          12 :         for(Int_t j=0; j<2; j++){
    4651           4 :           snprintf(mountingblocksupportboxdownname,100,"MountingBlockSuppDownLay%dBox%d",i+5,j+1);
    4652           4 :           snprintf(mountingblocksupportboxupname,100,"MountingBlockSuppUpLay%dBox%d",i+5,j+1);
    4653          12 :           mountingblocksupportboxdown[i][j] = new TGeoVolume(mountingblocksupportboxdownname,
    4654           4 :                                                              mountingblocksupportboxdownshape[i][j],
    4655           4 :                                                              fSSDCarbonFiberMedium);
    4656          12 :           mountingblocksupportboxup[i][j] = new TGeoVolume(mountingblocksupportboxupname,
    4657           4 :                                                            mountingblocksupportboxupshape[i][j],
    4658           4 :                                                            fSSDCarbonFiberMedium);
    4659           4 :                 mountingblocksupportboxdown[i][j]->SetLineColor(9);
    4660           4 :                 mountingblocksupportboxup[i][j]->SetLineColor(9);
    4661          24 :                 for(Int_t k=0; k<2; k++){
    4662           8 :                         downmotherladdersupport[i]->AddNode(mountingblocksupportboxdown[i][j],k+1,laddersupportmatrix[k]);
    4663           8 :                         upmotherladdersupport[i]->AddNode(mountingblocksupportboxup[i][j],k+1,laddersupportmatrix[k]);
    4664             :                 }
    4665             :         }
    4666          12 :         for(Int_t k=0; k<2; k++){
    4667           4 :                 downmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
    4668           4 :                 downmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
    4669           4 :                 downmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
    4670           4 :                 downmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
    4671           4 :                 downmotherladdersupport[i]->AddNode(mountingblockpiecedown[i],k+1,laddersupportmatrix[k]);
    4672           4 :                 downmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidown[i],k+1,laddersupportmatrix[k]);
    4673           4 :                 upmotherladdersupport[i]->AddNode(centermountingblocksupport[i],k+1,laddersupportmatrix[k]);
    4674           4 :                 upmotherladdersupport[i]->AddNode(sidemountingblocksupport[i],k+1,laddersupportmatrix[k]);
    4675           4 :                 upmotherladdersupport[i]->AddNode(sideladdersupportpiece[i],k+1,laddersupportmatrix[k]);
    4676           4 :                 upmotherladdersupport[i]->AddNode(centerladdersupportpiece[i],k+1,laddersupportmatrix[k]);
    4677           4 :                 upmotherladdersupport[i]->AddNode(mountingblockpieceup[i],k+1,laddersupportmatrix[k]);
    4678           4 :                 upmotherladdersupport[i]->AddNode(mountingblocksupportrapezoidup[i],k+1,laddersupportmatrix[k]);
    4679             :         }
    4680             :   }
    4681           1 :   TList* laddersupportlist = new TList();
    4682           1 :   laddersupportlist->Add(downmotherladdersupport[0]); 
    4683           1 :   laddersupportlist->Add(upmotherladdersupport[0]); 
    4684           1 :   laddersupportlist->Add(downmotherladdersupport[1]); 
    4685           1 :   laddersupportlist->Add(upmotherladdersupport[1]); 
    4686             :   /////////////////////////////////////////////////////////////
    4687             :   // Deallocating memory
    4688             :   /////////////////////////////////////////////////////////////
    4689           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4690          88 :         for(Int_t j=0; j<nedges+1; j++)
    4691          84 :                 delete vertex[i][j];
    4692           4 :         delete mountingsupportedgevector[i];
    4693           4 :         delete [] vertex[i];
    4694           4 :         delete vertexlist[i];
    4695           4 :         delete [] xsidevertex[i];
    4696           4 :         delete [] ysidevertex[i];
    4697           4 :         delete [] xcentervertex[i];
    4698           4 :         delete [] ycentervertex[i];
    4699           4 :         delete [] xsidelowervertex[i];
    4700           4 :         delete [] ysidelowervertex[i];
    4701           4 :         delete [] xcenterlowervertex[i];
    4702           4 :         delete [] ycenterlowervertex[i];
    4703           4 :         delete [] xmothervertex[i];
    4704           4 :         delete [] ymothervertex[i];
    4705             :   }
    4706           2 :   delete [] xsidevertex;
    4707           2 :   delete [] ysidevertex;
    4708           2 :   delete [] xcentervertex;
    4709           2 :   delete [] ycentervertex;
    4710           2 :   delete [] xsidelowervertex;
    4711           2 :   delete [] ysidelowervertex;
    4712           2 :   delete [] xcenterlowervertex;
    4713           2 :   delete [] ycenterlowervertex;
    4714           2 :   delete globalrefladdersupportrot;
    4715           2 :   delete mountingblocksupportrot;
    4716             :   /////////////////////
    4717           1 :   return laddersupportlist;     
    4718           1 : }
    4719             :  ////////////////////////////////////////////////////////////////////////////////
    4720             : void AliITSv11GeometrySSD::SetLadderSupport(Int_t nedges){ 
    4721             : //////////////////////////////////////////
    4722             : // Method Generating Ladder Support Ring
    4723             : //////////////////////////////////////////
    4724           2 :   if(!fCreateMaterials) CreateMaterials();
    4725           1 :   if(!fTransformationMatrices) CreateTransformationMatrices();
    4726           1 :   if(!fBasicObjects) CreateBasicObjects();
    4727           2 :   fLay5LadderSupportRing = new TGeoVolumeAssembly("Lay5LadderSupportRing");
    4728           2 :   fLay6LadderSupportRing = new TGeoVolumeAssembly("Lay6LadderSupportRing");
    4729             :     const Int_t kssdlayladdernumber[fgklayernumber] = 
    4730             :                         {fgkSSDLay5LadderNumber,fgkSSDLay6LadderNumber};
    4731           1 :   Double_t mountingsupportedge[fgklayernumber];
    4732           1 :   Double_t mountingblockratio[fgklayernumber];
    4733           1 :   Double_t theta[fgklayernumber];
    4734           1 :   Double_t phi[fgklayernumber];
    4735           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4736           2 :         mountingblockratio[i] = fgkSSDMountingBlockLength[0]/fgkMountingBlockSupportRadius[i];
    4737           4 :     mountingsupportedge[i]    = 0.5*fgkMountingBlockSupportRadius[i]
    4738           4 :                                                           *(TMath::Sqrt((2.-mountingblockratio[i])*(2.+mountingblockratio[i]))
    4739           2 :                                                           * TMath::Sin(2.0*TMath::Pi()/kssdlayladdernumber[i])
    4740           4 :                                                           - mountingblockratio[i]*(1.0+TMath::Cos(2.0*TMath::Pi()
    4741           2 :                                                           / kssdlayladdernumber[i])));
    4742           4 :     theta[i] = TMath::ASin(0.5*mountingblockratio[i]+mountingsupportedge[i]
    4743           2 :                          / fgkMountingBlockSupportRadius[i]);
    4744           2 :     phi[i]   = TMath::ASin(0.5*mountingblockratio[i]);
    4745             :   }
    4746           1 :   TGeoRotation* globalrot = new TGeoRotation();
    4747           1 :   globalrot->SetAngles(0.,-90.,0.); 
    4748           1 :   TGeoRotation** laddersupportrot[fgklayernumber];
    4749           1 :   TGeoHMatrix**  laddersupportmatrix[fgklayernumber];
    4750           6 :   for(Int_t i=0; i<fgklayernumber; i++){             
    4751           2 :         laddersupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];
    4752           2 :         laddersupportmatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]];
    4753         148 :         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
    4754         144 :                 laddersupportrot[i][j] = new TGeoRotation();
    4755          72 :                 laddersupportrot[i][j]->SetAngles(j*(phi[i]+theta[i])*TMath::RadToDeg(),0.,0.);
    4756          72 :                 switch(i){
    4757             :                         case 0: //Ladder of Layer5  
    4758         102 :                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
    4759         136 :                                 fLay5LadderSupportRing->AddNode(j%2==0?fLay5LadderSupport[0]:fLay5LadderSupport[1],j+1,
    4760          34 :                                                                             laddersupportmatrix[i][j]); 
    4761          34 :                         break;
    4762             :                         case 1: //Ladder of Layer6 
    4763         114 :                                 laddersupportmatrix[i][j] = new TGeoHMatrix((*laddersupportrot[i][j])*(*globalrot));
    4764         152 :                                 fLay6LadderSupportRing->AddNode(j%2==0?fLay6LadderSupport[0]:fLay6LadderSupport[1],j+1,
    4765          38 :                                                                               laddersupportmatrix[i][j]); 
    4766          38 :                         break;
    4767             :                 }
    4768             :     }
    4769             :   }
    4770             :   /////////////////////////////////////////////////////////////
    4771             :   // Creating Lower Ladder Support 
    4772             :   /////////////////////////////////////////////////////////////
    4773           1 :   TVector3** ringsupportvertex[fgklayernumber];         
    4774           1 :   Double_t angle = 360./nedges;
    4775           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4776           2 :     ringsupportvertex[i] = new TVector3*[2*kssdlayladdernumber[i]+3+nedges];    
    4777           6 :         ringsupportvertex[i][0] = new TVector3(0.,fgkMountingBlockSupportRadius[i]
    4778           2 :                                            * TMath::Cos(theta[i]), 0);
    4779           6 :         ringsupportvertex[i][1] = new TVector3(-0.5*fgkSSDMountingBlockLength[0]
    4780           2 :                                                         -                          mountingsupportedge[i],
    4781           2 :                                                ringsupportvertex[i][0]->Y(), 0);
    4782           6 :         ringsupportvertex[i][2] = new TVector3(0.5*fgkSSDMountingBlockLength[0],
    4783           2 :                                                ringsupportvertex[i][1]->Y(),0);                                                                              
    4784           2 :     ringsupportvertex[i][2]->RotateZ(theta[i]+phi[i]);
    4785         144 :         for(Int_t j=1; j<kssdlayladdernumber[i]; j++){
    4786         140 :            ringsupportvertex[i][2*j+1] = new TVector3(*ringsupportvertex[i][1]);        
    4787          70 :            ringsupportvertex[i][2*j+1]->RotateZ(j*(theta[i]+phi[i]));        
    4788         140 :            ringsupportvertex[i][2*j+2] = new TVector3(*ringsupportvertex[i][2]);        
    4789          70 :            ringsupportvertex[i][2*j+2]->RotateZ(j*(theta[i]+phi[i]));        
    4790             :         }
    4791           4 :         ringsupportvertex[i][2*kssdlayladdernumber[i]+1] = new TVector3(*ringsupportvertex[i][0]);
    4792         408 :     for(Int_t j=0; j<nedges+1; j++){
    4793         202 :                 ringsupportvertex[i][2*kssdlayladdernumber[i]+2+j] = 
    4794         606 :                         new TVector3((ringsupportvertex[i][0]->Y()-fgkLadderSupportHeight)*CosD(90.0-j*angle),
    4795         404 :                                (ringsupportvertex[i][0]->Y()-fgkLadderSupportHeight)*SinD(90.0-j*angle), 0);
    4796             :         }
    4797             :   }
    4798           1 :   Double_t **xmothervertex = new Double_t*[fgklayernumber];
    4799           1 :   Double_t **ymothervertex = new Double_t*[fgklayernumber];
    4800           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4801           2 :         xmothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
    4802           2 :         ymothervertex[i] = new Double_t[2*kssdlayladdernumber[i]+3+nedges];
    4803         704 :         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++){
    4804         350 :                 xmothervertex[i][j] = ringsupportvertex[i][j]->X();
    4805         350 :                 ymothervertex[i][j] = ringsupportvertex[i][j]->Y();
    4806             :         }
    4807             :   }
    4808             : ////////////////////////////////////////////////////////////////////////////////
    4809             : // Start Corrections 13/06/08
    4810             : ////////////////////////////////////////////////////////////////////////////////
    4811           1 :   char lowerladderpconsupportname[100];
    4812           1 :   TGeoPcon* lowerladderpconsupportshape[fgklayernumber];
    4813           1 :   TGeoVolume* lowerladderpconsupport[fgklayernumber]; 
    4814           1 :   Double_t lowerladderpconezsection[2] = {0.,fgkMountingBlockSupportWidth[1]};
    4815           1 :   Double_t lowerladderpconradiusmax[fgklayernumber];
    4816           1 :   Double_t lowerladderpconradiusmin[fgklayernumber];
    4817           1 :   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
    4818           1 :   lowerladdersupportrot->SetAngles(90.,180.,-90);
    4819           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4820           4 :         lowerladderpconradiusmax[i] = fgkMountingBlockSupportRadius[i]
    4821           2 :                                                                 *                          TMath::Cos(theta[i]);
    4822           2 :     lowerladderpconradiusmin[i] = lowerladderpconradiusmax[i]-fgkLadderSupportHeight;
    4823             :   } 
    4824           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4825             : ///////////////////////////  Modified Version ?///////////////////
    4826           4 :     lowerladderpconsupportshape[i] = new TGeoPcon(0.,360.,2);
    4827          16 :         for(Int_t j=0; j<2; j++) lowerladderpconsupportshape[i]->DefineSection(j,
    4828           4 :                                                          lowerladderpconezsection[j],lowerladderpconradiusmin[i],
    4829           4 :                                                          lowerladderpconradiusmax[i]);
    4830           2 :         snprintf(lowerladderpconsupportname,100,"LowerLadderPConSupportNameLay%d",i+5);
    4831           4 :         lowerladderpconsupport[i] = new TGeoVolume(lowerladderpconsupportname,lowerladderpconsupportshape[i],fSSDSupportRingAl);
    4832           2 :     lowerladderpconsupport[i]->SetLineColor(fColorAl);
    4833           6 :         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],1);
    4834           6 :         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladderpconsupport[i],2,lowerladdersupportrot);
    4835             :  }
    4836             : ////////////////////////////////////////////////////////////////////////////////
    4837             : // End Corrections 13/06/08
    4838             : ////////////////////////////////////////////////////////////////////////////////
    4839             :   /*char lowerladdersupportname[30];
    4840             :   TGeoXtru* lowerladdersupportshape[fgklayernumber];
    4841             :   TGeoVolume* lowerladdersupport[fgklayernumber];
    4842             :   TGeoRotation* lowerladdersupportrot = new TGeoRotation();
    4843             :   lowerladdersupportrot->SetAngles(90.,180.,-90);
    4844             :   for(Int_t i=0; i<fgklayernumber; i++){
    4845             :         lowerladdersupportshape[i] = new TGeoXtru(2);
    4846             :         lowerladdersupportshape[i]->DefinePolygon(2*kssdlayladdernumber[i]+3+nedges,
    4847             :                                                                                           xmothervertex[i],ymothervertex[i]);
    4848             :         lowerladdersupportshape[i]->DefineSection(0,0.);
    4849             :     lowerladdersupportshape[i]->DefineSection(1,fgkMountingBlockSupportWidth[1]);
    4850             :         sprintf(lowerladdersupportname,"LowerLadderSupportNameLay%d",i+5);
    4851             :     lowerladdersupport[i] = new TGeoVolume(lowerladdersupportname,
    4852             :                                                         lowerladdersupportshape[i],fSSDSupportRingAl);
    4853             :         lowerladdersupport[i]->SetLineColor(fColorAl);
    4854             :         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],1);
    4855             :         (i==0 ? fLay5LadderSupportRing: fLay6LadderSupportRing)->AddNode(lowerladdersupport[i],2,lowerladdersupportrot);
    4856             :   }*/
    4857             :   /////////////////////////////////////////////////////////////
    4858             :   // Deallocating memory
    4859             :   /////////////////////////////////////////////////////////////
    4860           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4861         704 :         for(Int_t j=0; j<2*kssdlayladdernumber[i]+3+nedges; j++)
    4862         700 :                 delete ringsupportvertex[i][j];
    4863           4 :         delete [] ringsupportvertex[i];
    4864             :   }
    4865           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4866           4 :         delete [] xmothervertex[i];
    4867           4 :         delete [] ymothervertex[i];
    4868             :   }
    4869           2 :   delete [] xmothervertex;
    4870           2 :   delete [] ymothervertex; 
    4871           2 :   delete globalrot;
    4872           6 :   for(Int_t i=0; i<fgklayernumber; i++){
    4873         148 :         for(Int_t j=0; j<kssdlayladdernumber[i]; j++)
    4874         144 :                 delete laddersupportrot[i][j];
    4875           4 :         delete [] laddersupportrot[i];
    4876             :   }
    4877             :   
    4878           1 :   fLay5LadderSupportRing->GetShape()->ComputeBBox(); //RS: enforce recompting of BBox
    4879           1 :   fLay6LadderSupportRing->GetShape()->ComputeBBox();
    4880             :   //
    4881             : 
    4882           1 :  }  
    4883             :  ////////////////////////////////////////////////////////////////////////////////
    4884             :  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoverPlate(){
    4885             :   /////////////////////////////////////////////////////////////
    4886             :   // Method generating Endcap CoverPlate
    4887             :   /////////////////////////////////////////////////////////////
    4888             :   // Holes Definition 
    4889             :   ///////////////////
    4890             :   Int_t nendcapcoverplateholedges = 30;
    4891             :   const Int_t kendcapcoverplatesmallholenumber[2] = {4,9}; 
    4892           3 :   Double_t holesection[2] = {-0.5*fgkEndCapCoverPlateThickness,
    4893           1 :                                                           0.5*fgkEndCapCoverPlateThickness};
    4894           2 :   TGeoShape* endcapcoverplatesmallholeshape = GetHoleShape(fgkEndCapCoverPlateSmallHoleRadius,
    4895           1 :                                                                                                               nendcapcoverplateholedges,holesection);
    4896           2 :   TGeoVolume* endcapcoverplatesmallhole = new TGeoVolume("EndCapCoverPlateSmallHole",
    4897           1 :                                                                                   endcapcoverplatesmallholeshape,fSSDAlCoolBlockMedium);
    4898           1 :   endcapcoverplatesmallhole->SetLineColor(6);
    4899           1 :   TGeoShape* endcapcoverplatebigholeshape = GetHoleShape(fgkEndCapCoverPlateBigHoleRadius,
    4900             :                                                                                                               nendcapcoverplateholedges,holesection);
    4901           2 :   TGeoVolume* endcapcoverplatebighole = new TGeoVolume("EndCapCoverPlateBigHole",
    4902           1 :                                                                                   endcapcoverplatebigholeshape,fSSDAlCoolBlockMedium);
    4903           1 :   endcapcoverplatebighole->SetLineColor(6);
    4904             :   //////////////////////////
    4905             :   // Screw Piece Definition 
    4906             :   //////////////////////////
    4907           1 :   Double_t smallscrewangle = 360.0/nendcapcoverplateholedges;
    4908           3 :   TGeoTube* endcapsmallscrewpieceshape = new TGeoTube(0.0,fgkEndCapCoverPlateSmallHoleRadius*
    4909           1 :                                                                                                       CosD(0.5*smallscrewangle),
    4910           1 :                                                                                                       0.5*fgkEndCapCoverPlateThickness);
    4911           2 :   TGeoVolume* endcapsmallscrewpiece = new TGeoVolume("EndCapCoverPlateSmallScrewPiece",
    4912           1 :                                                                                                 endcapsmallscrewpieceshape,
    4913           1 :                                                                                                 fSSDCoolingTubePhynox);
    4914           1 :   endcapsmallscrewpiece->SetLineColor(fColorPhynox);
    4915             :   ///////////////////
    4916             :   // Box Definition 
    4917             :   ///////////////////
    4918             :   TGeoBBox* endcapcoverplateboxshape[4];
    4919             :   TGeoVolume* endcapcoverplatebox[4];
    4920           1 :   Double_t boxorigin[5][3];
    4921           1 :   boxorigin[0][0] = 0.;
    4922           1 :   boxorigin[0][1] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[2];
    4923           1 :   boxorigin[0][2] = 0.;
    4924             : 
    4925           1 :   boxorigin[1][0] = 0.5*fgkEndCapCoverPlateSmallHoleSeparation[0];
    4926           1 :   boxorigin[1][1] = 4.*fgkEndCapCoverPlateSmallHoleSeparation[2];
    4927           1 :   boxorigin[1][2] = 0.;
    4928             : 
    4929           2 :   boxorigin[2][0] = 1.5*fgkEndCapCoverPlateSmallHoleSeparation[0]
    4930           1 :                                   + fgkEndCapCoverPlateSmallHoleSeparation[1];
    4931           1 :   boxorigin[2][1] = boxorigin[1][1];
    4932           1 :   boxorigin[2][2] = 0.;
    4933             : 
    4934           2 :   boxorigin[3][0] = fgkEndCapCoverPlateSmallHoleSeparation[0]
    4935           1 :                                   + 0.5*fgkEndCapCoverPlateSmallHoleSeparation[1];
    4936           1 :   boxorigin[3][1] = boxorigin[1][1];
    4937           1 :   boxorigin[3][2] = 0.;
    4938             : 
    4939           2 :   endcapcoverplateboxshape[0] = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
    4940           2 :                                                                                 0.5*(fgkEndCapCoverPlateSmallHoleSeparation[2]
    4941           1 :                                                  -              2.*fgkEndCapCoverPlateSmallHoleRadius),
    4942           1 :                                                                             0.5*fgkEndCapCoverPlateThickness,boxorigin[0]);
    4943             : 
    4944           3 :   endcapcoverplateboxshape[1] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
    4945           1 :                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
    4946           1 :                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
    4947           1 :                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
    4948           1 :                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[1]);
    4949             : 
    4950           3 :   endcapcoverplateboxshape[2] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[0]
    4951           1 :                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
    4952           1 :                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
    4953           1 :                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
    4954           1 :                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[2]);
    4955             : 
    4956           3 :   endcapcoverplateboxshape[3] = new TGeoBBox(0.5*(fgkEndCapCoverPlateSmallHoleSeparation[1]
    4957           1 :                                                                         -2.*fgkEndCapCoverPlateSmallHoleRadius),
    4958           1 :                                                                                      4.*fgkEndCapCoverPlateSmallHoleSeparation[2]
    4959           1 :                                                           +                              fgkEndCapCoverPlateSmallHoleRadius,
    4960           1 :                                                                                  0.5*fgkEndCapCoverPlateThickness,boxorigin[3]);
    4961             :   
    4962           2 :   endcapcoverplatebox[0] = new TGeoVolume("EndCapCoverPlateBox1",endcapcoverplateboxshape[0],
    4963           1 :                                                                            fSSDAlCoolBlockMedium);
    4964           2 :   endcapcoverplatebox[1] = new TGeoVolume("EndCapCoverPlateBox2",endcapcoverplateboxshape[1],
    4965           1 :                                                                            fSSDAlCoolBlockMedium);
    4966           2 :   endcapcoverplatebox[2] = new TGeoVolume("EndCapCoverPlateBox3",endcapcoverplateboxshape[2],
    4967           1 :                                                                            fSSDAlCoolBlockMedium);
    4968           2 :   endcapcoverplatebox[3] = new TGeoVolume("EndCapCoverPlateBox4",endcapcoverplateboxshape[3],
    4969           1 :                                                                            fSSDAlCoolBlockMedium);
    4970           1 :   endcapcoverplatebox[0]->SetLineColor(6);
    4971           1 :   endcapcoverplatebox[1]->SetLineColor(6);
    4972           1 :   endcapcoverplatebox[2]->SetLineColor(6);
    4973           1 :   endcapcoverplatebox[3]->SetLineColor(6);
    4974           1 :   Double_t endcapfillingboxorigin[3] = {fgkEndCapCoverPlateSmallHoleSeparation[0],0.,0.};
    4975           2 :   TGeoBBox* endcapfillingboxshape = new TGeoBBox(fgkEndCapCoverPlateSmallHoleRadius,
    4976             :                                                                                         fgkEndCapCoverPlateSmallHoleRadius,
    4977           1 :                                                                                         0.5*fgkEndCapCoverPlateThickness,
    4978           1 :                                                                                         endcapfillingboxorigin);
    4979           2 :   TGeoVolume* endcapfillingbox = new TGeoVolume("EndCapFillingBox",endcapfillingboxshape,
    4980           1 :                                                                            fSSDAlCoolBlockMedium);
    4981           1 :   endcapfillingbox->SetLineColor(6);
    4982             :   ////////////////////////////
    4983             :   // Contour shape Definition 
    4984             :   ////////////////////////////
    4985             :   const Int_t kcontourvertexnumber = 10;
    4986             :   Double_t xcontourvertex[kcontourvertexnumber];
    4987             :   Double_t ycontourvertex[kcontourvertexnumber];
    4988           1 :   xcontourvertex[0] = -fgkEndCapCoverPlateLength[0];
    4989             :   xcontourvertex[1] = xcontourvertex[0];
    4990           1 :   xcontourvertex[2] = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
    4991             :   xcontourvertex[3] = xcontourvertex[2];
    4992           1 :   xcontourvertex[4] = -fgkEndCapCoverPlateSmallHoleRadius;
    4993             :   xcontourvertex[5] = xcontourvertex[4];
    4994             :   xcontourvertex[6] = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
    4995             :   xcontourvertex[7] = xcontourvertex[6];
    4996             :   xcontourvertex[8] = xcontourvertex[4];
    4997             :   xcontourvertex[9] = xcontourvertex[8];
    4998           2 :   ycontourvertex[0] = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
    4999           1 :                                         - (kendcapcoverplatesmallholenumber[1]-1)
    5000           1 :                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
    5001             :   ycontourvertex[1] = (kendcapcoverplatesmallholenumber[1]-1)
    5002           1 :                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
    5003             :   ycontourvertex[2] = ycontourvertex[1];
    5004             :   ycontourvertex[3] = ycontourvertex[0];
    5005             :   ycontourvertex[4] = ycontourvertex[3];
    5006             :   ycontourvertex[5] = -fgkEndCapCoverPlateSmallHoleRadius;
    5007             :   ycontourvertex[6] = ycontourvertex[5];
    5008             :   ycontourvertex[7] = (kendcapcoverplatesmallholenumber[1]-1)
    5009             :                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
    5010             :                                         + fgkEndCapCoverPlateSmallHoleRadius;
    5011             :   ycontourvertex[8] = ycontourvertex[7];
    5012             :   ycontourvertex[9] = ycontourvertex[0];
    5013             : 
    5014             :   Double_t xboxin, dxboxin, yboxin, dyboxin;
    5015             :   Double_t xboxout, dxboxout, yboxout, dyboxout;
    5016             :   Double_t coordmin, coordmax;
    5017             :   coordmin = -fgkEndCapCoverPlateLength[0];
    5018           1 :   coordmax = fgkEndCapCoverPlateLength[1]-xcontourvertex[0];
    5019           1 :   xboxout = 0.5*(coordmin+coordmax);
    5020           1 :   dxboxout = 0.5*(coordmax-coordmin);
    5021             :   coordmin = -0.5*(fgkEndCapCoverPlateWidth[0]-fgkEndCapCoverPlateWidth[2]
    5022             :                                         - (kendcapcoverplatesmallholenumber[1]-1)
    5023             :                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]);
    5024             :   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
    5025             :                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]-ycontourvertex[0];
    5026           1 :   yboxout = 0.5*(coordmin+coordmax);
    5027           1 :   dyboxout = 0.5*(coordmax-coordmin);
    5028           1 :   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
    5029           1 :   coordmax = fgkEndCapCoverPlateLength[1]+fgkEndCapCoverPlateSmallHoleRadius;
    5030           1 :   xboxin = 0.5*(coordmin+coordmax);
    5031           1 :   dxboxin = 0.5*(coordmax-coordmin);
    5032             :   coordmin = -fgkEndCapCoverPlateSmallHoleRadius;
    5033             :   coordmax = (kendcapcoverplatesmallholenumber[1]-1)
    5034             :                                         * fgkEndCapCoverPlateSmallHoleSeparation[2]
    5035           1 :                                         + fgkEndCapCoverPlateSmallHoleRadius;
    5036           1 :   yboxin = 0.5*(coordmin+coordmax);
    5037           1 :   dyboxin = 0.5*(coordmax-coordmin);
    5038           1 :   new TGeoBBox("EndCapCoverPlateContourBoxOut", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
    5039           1 :   TGeoTranslation *trendCapCoverPlateContourboxout = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut",
    5040             :                                                          xboxout, yboxout, 0.);
    5041           1 :   trendCapCoverPlateContourboxout->RegisterYourself();
    5042           1 :   new TGeoBBox("EndCapCoverPlateContourBoxIn",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
    5043           1 :   TGeoTranslation *trendCapCoverPlateContourboxin = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn",
    5044             :                                                          xboxin, yboxin, 0.);
    5045           1 :   trendCapCoverPlateContourboxin->RegisterYourself();
    5046           1 :   TGeoCompositeShape *contourshape = new TGeoCompositeShape("contourShape", 
    5047             :         "EndCapCoverPlateContourBoxOut:SSD_trEndCapCoverPlateContourBoxOut-EndCapCoverPlateContourBoxIn:SSD_trEndCapCoverPlateContourBoxIn");
    5048             : 
    5049           2 :   TGeoVolume* contour = new TGeoVolume("EndCapCoverPlateContour",contourshape,
    5050           1 :                                                                            fSSDAlCoolBlockMedium);
    5051           1 :   contour->SetLineColor(6);
    5052             :   /////////////////////////////
    5053             :   // Hole Contour Shape Definition 
    5054             :   ////////////////////////////
    5055             :   coordmin = xcontourvertex[0];
    5056           1 :   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
    5057           1 :   xboxout = 0.5*(coordmin+coordmax);
    5058           1 :   dxboxout = 0.5*(coordmax-coordmin);
    5059             :   coordmin = ycontourvertex[1];
    5060           1 :   coordmax = ycontourvertex[1]+fgkEndCapCoverPlateWidth[2];
    5061           1 :   yboxout = 0.5*(coordmin+coordmax);
    5062           1 :   dyboxout = 0.5*(coordmax-coordmin);
    5063           1 :   coordmin = xcontourvertex[0]+ 0.5*(fgkEndCapCoverPlateLength[2]
    5064           1 :                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
    5065           1 :   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
    5066           1 :   xboxin = 0.5*(coordmin+coordmax);
    5067           1 :   dxboxin = 0.5*(coordmax-coordmin);
    5068           1 :   coordmin = ycontourvertex[1]+0.5*(fgkEndCapCoverPlateWidth[2]
    5069           1 :                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);;
    5070           1 :   coordmax = coordmin +2.*fgkEndCapCoverPlateBigHoleRadius;
    5071           1 :   yboxin = 0.5*(coordmin+coordmax);
    5072           1 :   dyboxin = 0.5*(coordmax-coordmin);
    5073           1 :   new TGeoBBox("EndCapCoverPlateContourBoxOut1", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
    5074           1 :   TGeoTranslation *trendCapCoverPlateContourboxout1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut1",
    5075             :                                                          xboxout, yboxout, 0.);
    5076           1 :   trendCapCoverPlateContourboxout1->RegisterYourself();
    5077           1 :   new TGeoBBox("EndCapCoverPlateContourBoxIn1",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
    5078           1 :   TGeoTranslation *trendCapCoverPlateContourboxin1 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn1",
    5079             :                                                          xboxin, yboxin, 0.);
    5080           1 :   trendCapCoverPlateContourboxin1->RegisterYourself();
    5081           1 :   TGeoCompositeShape *contourshape1 = new TGeoCompositeShape("contourShape1", 
    5082             :         "EndCapCoverPlateContourBoxOut1:SSD_trEndCapCoverPlateContourBoxOut1-EndCapCoverPlateContourBoxIn1:SSD_trEndCapCoverPlateContourBoxIn1");
    5083             : 
    5084             : 
    5085           1 :   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
    5086           1 :   coordmax = coordmin+fgkEndCapCoverPlateLength[2];
    5087           1 :   xboxout = 0.5*(coordmin+coordmax);
    5088           1 :   dxboxout = 0.5*(coordmax-coordmin);
    5089           2 :   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
    5090           1 :                                                    - fgkEndCapCoverPlateWidth[0]);
    5091             :   coordmax = ycontourvertex[0];
    5092           1 :   yboxout = 0.5*(coordmin+coordmax);
    5093           1 :   dyboxout = 0.5*(coordmax-coordmin);
    5094           1 :   coordmin = xcontourvertex[0]+fgkEndCapCoverPlateLength[5]+ 0.5*(fgkEndCapCoverPlateLength[2]
    5095           1 :                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
    5096           1 :   coordmax = coordmin + 2.*fgkEndCapCoverPlateBigHoleRadius;
    5097           1 :   xboxin = 0.5*(coordmin+coordmax);
    5098           1 :   dxboxin = 0.5*(coordmax-coordmin);
    5099             :   coordmin = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
    5100           1 :                                                    - fgkEndCapCoverPlateWidth[0])+0.5*(fgkEndCapCoverPlateWidth[1]
    5101             :                                                    - fgkEndCapCoverPlateWidth[0]
    5102           1 :                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
    5103           1 :   coordmax = coordmin+2.*fgkEndCapCoverPlateBigHoleRadius;
    5104           1 :   yboxin = 0.5*(coordmin+coordmax);
    5105           1 :   dyboxin = 0.5*(coordmax-coordmin);
    5106           1 :   new TGeoBBox("EndCapCoverPlateContourBoxOut2", dxboxout, dyboxout, 0.5*fgkEndCapCoverPlateThickness);
    5107           1 :   TGeoTranslation *trendCapCoverPlateContourboxout2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxOut2",
    5108             :                                                          xboxout, yboxout, 0.);
    5109           1 :   trendCapCoverPlateContourboxout2->RegisterYourself();
    5110           1 :   new TGeoBBox("EndCapCoverPlateContourBoxIn2",  dxboxin, dyboxin, 0.5*fgkEndCapCoverPlateThickness+0.01);
    5111           1 :   TGeoTranslation *trendCapCoverPlateContourboxin2 = new TGeoTranslation("SSD_trEndCapCoverPlateContourBoxIn2",
    5112             :                                                          xboxin, yboxin, 0.);
    5113           1 :   trendCapCoverPlateContourboxin2->RegisterYourself();
    5114           1 :   TGeoCompositeShape *contourshape2 = new TGeoCompositeShape("contourShape2", 
    5115             :         "EndCapCoverPlateContourBoxOut2:SSD_trEndCapCoverPlateContourBoxOut2-EndCapCoverPlateContourBoxIn2:SSD_trEndCapCoverPlateContourBoxIn2");
    5116             :   
    5117             : //  const Int_t kholecontourvertexnumber = 10;
    5118             : 
    5119             :   Double_t xholecontourvertex[2][kcontourvertexnumber];
    5120             :   Double_t yholecontourvertex[2][kcontourvertexnumber];
    5121             :   xholecontourvertex[0][0] = xcontourvertex[0];
    5122             :   xholecontourvertex[0][1] = xholecontourvertex[0][0];
    5123           1 :   xholecontourvertex[0][2] = xholecontourvertex[0][1]+fgkEndCapCoverPlateLength[2];
    5124             :   xholecontourvertex[0][3] = xholecontourvertex[0][2];
    5125             :   xholecontourvertex[0][4] = xholecontourvertex[0][0]
    5126           1 :                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
    5127           1 :                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
    5128             :   xholecontourvertex[0][5] = xholecontourvertex[0][4];
    5129             :   xholecontourvertex[0][6] = xholecontourvertex[0][5]
    5130             :                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
    5131             :   xholecontourvertex[0][7] = xholecontourvertex[0][6];
    5132             :   xholecontourvertex[0][8] = xholecontourvertex[0][4];
    5133             :   xholecontourvertex[0][9] = xholecontourvertex[0][8];
    5134             :   
    5135             :   yholecontourvertex[0][0] = ycontourvertex[1];
    5136           1 :   yholecontourvertex[0][1] = yholecontourvertex[0][0]+fgkEndCapCoverPlateWidth[2];
    5137             :   yholecontourvertex[0][2] = yholecontourvertex[0][1];
    5138             :   yholecontourvertex[0][3] = yholecontourvertex[0][0];
    5139             :   yholecontourvertex[0][4] = yholecontourvertex[0][3];
    5140           1 :   yholecontourvertex[0][5] = yholecontourvertex[0][4]+0.5*(fgkEndCapCoverPlateWidth[2]
    5141           1 :                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
    5142             :   yholecontourvertex[0][6] = yholecontourvertex[0][5];
    5143           1 :   yholecontourvertex[0][7] = yholecontourvertex[0][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
    5144             :   yholecontourvertex[0][8] = yholecontourvertex[0][7];
    5145             :   yholecontourvertex[0][9] = yholecontourvertex[0][0];
    5146             : 
    5147           1 :   xholecontourvertex[1][0] = xcontourvertex[0]+fgkEndCapCoverPlateLength[5];
    5148             :   xholecontourvertex[1][1] = xholecontourvertex[1][0];
    5149             :   xholecontourvertex[1][2] = xholecontourvertex[1][1]+fgkEndCapCoverPlateLength[2];
    5150             :   xholecontourvertex[1][3] = xholecontourvertex[1][2];
    5151             :   xholecontourvertex[1][4] = xholecontourvertex[1][0]
    5152           1 :                                                    + 0.5*(fgkEndCapCoverPlateLength[2]
    5153             :                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
    5154             :   xholecontourvertex[1][5] = xholecontourvertex[1][4];
    5155             :   xholecontourvertex[1][6] = xholecontourvertex[1][5]
    5156             :                                                    + 2.*fgkEndCapCoverPlateBigHoleRadius;
    5157             :   xholecontourvertex[1][7] = xholecontourvertex[1][6];
    5158             :   xholecontourvertex[1][8] = xholecontourvertex[1][4];
    5159             :   xholecontourvertex[1][9] = xholecontourvertex[1][8];
    5160             :   
    5161           2 :   yholecontourvertex[1][0] = ycontourvertex[0]-(fgkEndCapCoverPlateWidth[1]
    5162           1 :                                                    - fgkEndCapCoverPlateWidth[0]);
    5163             :   yholecontourvertex[1][1] = ycontourvertex[0];
    5164             :   yholecontourvertex[1][2] = yholecontourvertex[1][1];
    5165             :   yholecontourvertex[1][3] = yholecontourvertex[1][0];
    5166             :   yholecontourvertex[1][4] = yholecontourvertex[1][3];
    5167           1 :   yholecontourvertex[1][5] = yholecontourvertex[1][4]+0.5*(fgkEndCapCoverPlateWidth[1]
    5168             :                                                    - fgkEndCapCoverPlateWidth[0]
    5169           1 :                                                    - 2.*fgkEndCapCoverPlateBigHoleRadius);
    5170             :   yholecontourvertex[1][6] = yholecontourvertex[1][5];
    5171             :   yholecontourvertex[1][7] = yholecontourvertex[1][6]+2.*fgkEndCapCoverPlateBigHoleRadius;
    5172             :   yholecontourvertex[1][8] = yholecontourvertex[1][7];
    5173             :   yholecontourvertex[1][9] = yholecontourvertex[1][0];
    5174             : 
    5175             :   TGeoVolume* holecontour[2];
    5176           2 :   holecontour[0] = new TGeoVolume("EndCapCoverPlateContour1",contourshape1,
    5177           1 :                                                                   fSSDAlCoolBlockMedium);
    5178           1 :   holecontour[0]->SetLineColor(6);
    5179           2 :   holecontour[1] = new TGeoVolume("EndCapCoverPlateContour2",contourshape2,
    5180           1 :                                                                   fSSDAlCoolBlockMedium);
    5181           1 :   holecontour[1]->SetLineColor(6);
    5182           2 :   TGeoTranslation* holecontourtrans = new TGeoTranslation(fgkEndCapCoverPlateLength[3]
    5183           1 :                                                                         +     fgkEndCapCoverPlateLength[2],0.,0.);
    5184             :   TGeoTranslation*  bigholetrans[3];
    5185           2 :   bigholetrans[0] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius,
    5186           1 :                                                                                 yholecontourvertex[0][7]-fgkEndCapCoverPlateBigHoleRadius,0.0);
    5187           2 :   bigholetrans[1] = new TGeoTranslation(xholecontourvertex[0][4]+fgkEndCapCoverPlateBigHoleRadius
    5188           1 :                                   +                     fgkEndCapCoverPlateLength[4],yholecontourvertex[0][7]
    5189           1 :                                   -                                             fgkEndCapCoverPlateBigHoleRadius,0.0);
    5190           2 :   bigholetrans[2] = new TGeoTranslation(xholecontourvertex[1][4]+fgkEndCapCoverPlateBigHoleRadius,
    5191           1 :                                                                                 yholecontourvertex[1][5]+fgkEndCapCoverPlateBigHoleRadius,0.0);
    5192             :   /////////////////////////////////
    5193             :   // Mother Volume Xtru Definition 
    5194             :   /////////////////////////////////
    5195             :   const Int_t kmothervertexnumber = 12;
    5196           1 :   Double_t xmothervertex[kmothervertexnumber];  
    5197           1 :   Double_t ymothervertex[kmothervertexnumber];  
    5198           1 :   xmothervertex[0]  = xcontourvertex[0];
    5199           1 :   xmothervertex[1]  = xmothervertex[0];
    5200           1 :   xmothervertex[2]  = xmothervertex[1]+fgkEndCapCoverPlateLength[2];
    5201           1 :   xmothervertex[3]  = xmothervertex[2];
    5202           1 :   xmothervertex[4]  = xmothervertex[3]+fgkEndCapCoverPlateLength[3];
    5203           1 :   xmothervertex[5]  = xmothervertex[4];
    5204           1 :   xmothervertex[6]  = xmothervertex[5]+fgkEndCapCoverPlateLength[2];
    5205           1 :   xmothervertex[7]  = xmothervertex[6];
    5206           2 :   xmothervertex[8]  = xmothervertex[0]+fgkEndCapCoverPlateLength[5]
    5207           1 :                                         + fgkEndCapCoverPlateLength[2]; 
    5208           1 :   xmothervertex[9]  = xmothervertex[8];
    5209           1 :   xmothervertex[10] = xmothervertex[9]-fgkEndCapCoverPlateLength[2];
    5210           1 :   xmothervertex[11] = xmothervertex[10];
    5211             :   
    5212           1 :   ymothervertex[0]  = ycontourvertex[0];
    5213           1 :   ymothervertex[1]  = ymothervertex[0]+fgkEndCapCoverPlateWidth[0];
    5214           1 :   ymothervertex[2]  = ymothervertex[1];
    5215           1 :   ymothervertex[3]  = ycontourvertex[1];
    5216           1 :   ymothervertex[4]  = ymothervertex[3];
    5217           1 :   ymothervertex[5]  = ymothervertex[1];
    5218           1 :   ymothervertex[6]  = ymothervertex[5];
    5219           1 :   ymothervertex[7]  = ymothervertex[0];
    5220           1 :   ymothervertex[8]  = ymothervertex[7];
    5221           1 :   ymothervertex[9]  = ymothervertex[8]
    5222           1 :                                    - (fgkEndCapCoverPlateWidth[1]-fgkEndCapCoverPlateWidth[0]);
    5223           1 :   ymothervertex[10] = ymothervertex[9];
    5224           1 :   ymothervertex[11] = ymothervertex[8];
    5225           1 :   TGeoXtru* mothercoverplateshape = new TGeoXtru(2);
    5226           1 :   mothercoverplateshape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex);  
    5227           1 :   mothercoverplateshape->DefineSection(0,-0.5*fgkEndCapCoverPlateThickness);
    5228           1 :   mothercoverplateshape->DefineSection(1,+0.5*fgkEndCapCoverPlateThickness);
    5229           1 :   TGeoVolume* mothercoverplate = new TGeoVolume("EndCapCoverPlateMother",mothercoverplateshape,fSSDAir);
    5230             :   ////////////////////////////////////////
    5231             :   // Adding Nodes
    5232             :   ////////////////////////////////////////
    5233             : //  TGeoTranslation** endcapcoverplatesmallholetrans[kendcapcoverplatesmallholenumber[0]]; 
    5234             :   TGeoTranslation*** endcapcoverplatesmallholetrans;
    5235           1 :   endcapcoverplatesmallholetrans = new TGeoTranslation**[kendcapcoverplatesmallholenumber[0]]; 
    5236           4 :   Double_t transx[4] = {0,
    5237           1 :                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
    5238           1 :                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
    5239           1 :                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
    5240           1 :                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
    5241           1 :                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
    5242             :   Int_t index = 0;
    5243          10 :   for(Int_t i=0; i<kendcapcoverplatesmallholenumber[0]; i++){
    5244           4 :         endcapcoverplatesmallholetrans[i] = 
    5245           4 :                                         new TGeoTranslation*[kendcapcoverplatesmallholenumber[1]];
    5246          80 :     for(Int_t j=0; j<kendcapcoverplatesmallholenumber[1]; j++){
    5247          36 :                 index = kendcapcoverplatesmallholenumber[1]*i+j+1;
    5248          36 :             endcapcoverplatesmallholetrans[i][j] = 
    5249          72 :                 new TGeoTranslation(transx[i],
    5250          36 :                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],0.);
    5251          36 :             if(index!=10){ 
    5252          70 :                         mothercoverplate->AddNode(endcapcoverplatesmallhole,
    5253          35 :                                                                           index,endcapcoverplatesmallholetrans[i][j]);
    5254          70 :                         mothercoverplate->AddNode(endcapsmallscrewpiece,
    5255          35 :                                                                           index,endcapcoverplatesmallholetrans[i][j]);
    5256          35 :                 }
    5257          36 :                 if(j<kendcapcoverplatesmallholenumber[1]-1) 
    5258          64 :                         mothercoverplate->AddNode(endcapcoverplatebox[0],
    5259          32 :                                                                           index,endcapcoverplatesmallholetrans[i][j]);
    5260             :     }
    5261             :   }
    5262           1 :   mothercoverplate->AddNode(endcapcoverplatebox[1],1);
    5263           1 :   mothercoverplate->AddNode(endcapcoverplatebox[2],1);
    5264           1 :   mothercoverplate->AddNode(endcapcoverplatebox[3],1);
    5265           1 :   mothercoverplate->AddNode(endcapfillingbox,1);
    5266           1 :   mothercoverplate->AddNode(endcapcoverplatebighole,1,bigholetrans[0]);
    5267           1 :   mothercoverplate->AddNode(endcapcoverplatebighole,2,bigholetrans[1]);
    5268           1 :   mothercoverplate->AddNode(endcapcoverplatebighole,3,bigholetrans[2]);
    5269           1 :   mothercoverplate->AddNode(holecontour[0],1);
    5270           1 :   mothercoverplate->AddNode(holecontour[0],2,holecontourtrans);
    5271           1 :   mothercoverplate->AddNode(holecontour[1],1);  
    5272           1 :   mothercoverplate->AddNode(contour,1);
    5273             :   
    5274          10 :   for (Int_t i = 0; i < kendcapcoverplatesmallholenumber[0]; i++) 
    5275           8 :     delete [] endcapcoverplatesmallholetrans[i];
    5276           2 :   delete [] endcapcoverplatesmallholetrans;
    5277             :   /////////////////////////////////
    5278           1 :   return mothercoverplate;      
    5279           1 :  }
    5280             :  ////////////////////////////////////////////////////////////////////////////////
    5281             :  TGeoVolume* AliITSv11GeometrySSD::GetEndCapCoolingTube(){
    5282             :   /////////////////////////////////////////////////////////////
    5283             :   // Getting EndCap Cooling Tube 
    5284             :   /////////////////////////////////////////////////////////////
    5285           2 :   TGeoTorus* endcapcoolingtubetorushape[5];
    5286           1 :   TGeoVolume* endcapcoolingtubetorus[5];
    5287           1 :   TGeoTube* endcapcoolingtubeshape[4];
    5288           1 :   TGeoVolume* endcapcoolingtube[4];
    5289           1 :   char endcapcoolingtubetorusname[100];
    5290           1 :   char endcapcoolingtubename[100];
    5291           1 :   TGeoTorus* endcapcoolingwatertubetorushape[5];
    5292           1 :   TGeoVolume* endcapcoolingwatertubetorus[5];
    5293           1 :   TGeoTube* endcapcoolingwatertubeshape[4];
    5294           1 :   TGeoVolume* endcapcoolingwatertube[4];
    5295           1 :   char endcapcoolingwatertubetorusname[100];
    5296           1 :   char endcapcoolingwatertubename[100];
    5297          12 :   for(Int_t i=0; i<5; i++){
    5298           5 :     snprintf(endcapcoolingtubetorusname,100,"EndCapCoolingTubeTorus%d",i+1);
    5299           5 :     snprintf(endcapcoolingtubename,100,"EndCapCoolingTube%d",i+1);
    5300           5 :     snprintf(endcapcoolingwatertubetorusname,100,"EndCapCoolingWaterTubeTorus%d",i+1);
    5301           5 :     snprintf(endcapcoolingwatertubename,100,"EndCapCoolingWaterTube%d",i+1);
    5302          10 :     if(i==3){
    5303           8 :       endcapcoolingtubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
    5304           1 :                                                     fgkEndCapCoolingTubeRadiusMin,
    5305           1 :                                                     fgkEndCapCoolingTubeRadiusMax,
    5306             :                                                     90.0,fgkEndCapCoolingTubeAngle[3]);
    5307           3 :       endcapcoolingwatertubetorushape[i] = new TGeoTorus(fgkEndCapCoolingTubeAxialRadius[0],
    5308           1 :                                                          0.,fgkEndCapCoolingTubeRadiusMin,
    5309             :                                                          90.0,fgkEndCapCoolingTubeAngle[3]);
    5310           1 :     }
    5311             :     else{
    5312          16 :       endcapcoolingtubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
    5313           4 :                                                     :fgkEndCapCoolingTubeAxialRadius[1],
    5314           4 :                                                     fgkEndCapCoolingTubeRadiusMin,
    5315           4 :                                                     fgkEndCapCoolingTubeRadiusMax,
    5316           4 :                                                     0.,fgkEndCapCoolingTubeAngle[i]);
    5317          16 :       endcapcoolingwatertubetorushape[i] = new TGeoTorus(i!=4?fgkEndCapCoolingTubeAxialRadius[0]
    5318           4 :                                                          :fgkEndCapCoolingTubeAxialRadius[1],
    5319           4 :                                                          0.,fgkEndCapCoolingTubeRadiusMin,
    5320           4 :                                                          0.,fgkEndCapCoolingTubeAngle[i]);
    5321             :     }
    5322          15 :         endcapcoolingtubetorus[i] = new TGeoVolume(endcapcoolingtubetorusname,
    5323           5 :                                                                                            endcapcoolingtubetorushape[i],
    5324           5 :                                                                                            fSSDCoolingTubePhynox);
    5325          15 :         endcapcoolingwatertubetorus[i] = new TGeoVolume(endcapcoolingwatertubetorusname,
    5326           5 :                                                                                                         endcapcoolingwatertubetorushape[i],
    5327           5 :                                                                                                         fSSDCoolingTubeWater);
    5328           5 :     endcapcoolingtubetorus[i]->SetLineColor(fColorPhynox);
    5329           5 :     endcapcoolingwatertubetorus[i]->SetLineColor(fColorWater);
    5330           5 :     if(i<4){
    5331          12 :                 endcapcoolingtubeshape[i] = new TGeoTube(fgkEndCapCoolingTubeRadiusMin,
    5332           4 :                                                                   fgkEndCapCoolingTubeRadiusMax,
    5333           4 :                                                           0.5*fgkEndCapCoolingTubeLength[i]);
    5334          12 :                 endcapcoolingwatertubeshape[i] = new TGeoTube(0.,fgkEndCapCoolingTubeRadiusMin,
    5335           4 :                                                           0.5*fgkEndCapCoolingTubeLength[i]);
    5336          12 :         endcapcoolingtube[i] = new TGeoVolume(endcapcoolingtubename,
    5337           4 :                                                          endcapcoolingtubeshape[i],fSSDCoolingTubePhynox);
    5338          12 :         endcapcoolingwatertube[i] = new TGeoVolume(endcapcoolingwatertubename,
    5339           4 :                                                          endcapcoolingwatertubeshape[i],fSSDCoolingTubeWater);
    5340           4 :                 endcapcoolingtube[i]->SetLineColor(fColorPhynox);
    5341           4 :                 endcapcoolingwatertube[i]->SetLineColor(fColorWater);
    5342           4 :         }
    5343             :   }
    5344           1 :   TGeoVolumeAssembly* endcapcoolingtubemother = new TGeoVolumeAssembly("MotherEndCapCoolingTube");
    5345             :   /////////////////////////////////////////
    5346             :   // Transformation for Volume Positioning 
    5347             :   /////////////////////////////////////////
    5348           1 :   TGeoCombiTrans* coolingtubecombitrans[6];
    5349           1 :   TGeoRotation* coolingtuberot[8];
    5350           1 :   TGeoTranslation* coolingtubetrans[6];
    5351             :   TGeoHMatrix* coolingtubematrix[4];
    5352           1 :   TGeoCombiTrans* torustubecombitrans[4];
    5353           1 :   TGeoRotation* torustuberot[7];
    5354           1 :   TGeoTranslation* torustubetrans[4];
    5355             :   TGeoHMatrix* torustubematrix[5];
    5356           1 :   TGeoCombiTrans* coolingwatertubecombitrans[6];
    5357           1 :   TGeoRotation* coolingwatertuberot[8];
    5358           1 :   TGeoTranslation* coolingwatertubetrans[6];
    5359             :   TGeoHMatrix* coolingwatertubematrix[4];
    5360           1 :   TGeoCombiTrans* toruswatertubecombitrans[4];
    5361           1 :   TGeoRotation* toruswatertuberot[7];
    5362           1 :   TGeoTranslation* toruswatertubetrans[4];
    5363             :   TGeoHMatrix* toruswatertubematrix[5];
    5364          18 :   for(Int_t i=0; i<8; i++){
    5365           8 :     if(i<6){
    5366          12 :          coolingtubetrans[i] = new TGeoTranslation();
    5367          12 :          coolingwatertubetrans[i] = new TGeoTranslation();
    5368           6 :     }
    5369           8 :     if(i<8){
    5370          16 :          coolingtuberot[i] = new TGeoRotation();
    5371          16 :          coolingwatertuberot[i] = new TGeoRotation();
    5372           8 :     }
    5373           8 :     if(i<4){
    5374           8 :          torustubetrans[i] = new TGeoTranslation();
    5375           8 :          toruswatertubetrans[i] = new TGeoTranslation();
    5376           4 :     }
    5377           8 :     if(i<7){
    5378          14 :          torustuberot[i] = new TGeoRotation();
    5379          14 :          toruswatertuberot[i] = new TGeoRotation();
    5380           7 :         }
    5381             :   }
    5382             :   /////////////////////////////////////////
    5383             :   // Transformation for Inox Volume Positioning 
    5384             :   /////////////////////////////////////////
    5385           2 :   coolingtubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
    5386           1 :                                                                           -endcapcoolingtubeshape[0]->GetDz(),0.);
    5387           1 :   coolingtuberot[0]->SetAngles(0.,90.,0.);
    5388           3 :   coolingtubecombitrans[0] = new TGeoCombiTrans(*coolingtubetrans[0],
    5389           1 :                                                                                                 *coolingtuberot[0]);
    5390             :                                                                                                 
    5391           1 :   coolingtubetrans[1]->SetTranslation(0.,-endcapcoolingtubeshape[1]->GetDz(),0.);
    5392           1 :   coolingtuberot[1]->SetAngles(0.,90.,0.);
    5393           3 :   coolingtubecombitrans[1] = new TGeoCombiTrans(*coolingtubetrans[1],
    5394           1 :                                                                                                 *coolingtuberot[1]);
    5395             : 
    5396           2 :   coolingtubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
    5397           1 :                                                                          *CosD(fgkEndCapCoolingTubeAngle[0]),
    5398           1 :                                                                           fgkEndCapCoolingTubeAxialRadius[0]
    5399           1 :                                                                          *SinD(fgkEndCapCoolingTubeAngle[0]),
    5400             :                                                                           0.);
    5401           1 :   coolingtuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
    5402           3 :   coolingtubecombitrans[2] = new TGeoCombiTrans(*coolingtubetrans[2],
    5403           1 :                                                                                                 *coolingtuberot[2]);
    5404             : 
    5405           2 :   coolingtubematrix[0] = new TGeoHMatrix((*coolingtubecombitrans[2])
    5406           1 :                                            *                             (*coolingtubecombitrans[1]));
    5407             : 
    5408           2 :   torustubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
    5409           1 :                                                                          endcapcoolingtubeshape[1]->GetDz());
    5410           1 :   torustuberot[0]->SetAngles(0.,90.,0.); 
    5411           2 :   torustubecombitrans[0] = new TGeoCombiTrans(*torustubetrans[0],*torustuberot[0]);
    5412             : 
    5413           2 :   torustubematrix[0] = new TGeoHMatrix((*coolingtubematrix[0])*(*torustubecombitrans[0]));
    5414             : 
    5415           2 :   coolingtubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
    5416           1 :                                                                           -endcapcoolingtubeshape[2]->GetDz(),0.);
    5417           1 :   coolingtuberot[3]->SetAngles(0.,90.,0.);
    5418           3 :   coolingtubecombitrans[3] = new TGeoCombiTrans(*coolingtubetrans[3],
    5419           1 :                                                                                                 *coolingtuberot[3]);
    5420           1 :   coolingtuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
    5421           2 :   coolingtubematrix[1] = new TGeoHMatrix((*coolingtuberot[4])*(*coolingtubecombitrans[3]));
    5422           1 :   coolingtubematrix[1]->MultiplyLeft(torustubematrix[0]);
    5423             :   
    5424           2 :   torustubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
    5425           1 :                                                                         endcapcoolingtubeshape[2]->GetDz());
    5426           1 :   torustuberot[1]->SetAngles(0.,90.,0.); 
    5427           2 :   torustubecombitrans[1] = new TGeoCombiTrans(*torustubetrans[1],*torustuberot[1]);
    5428           1 :   torustuberot[2]->SetAngles(180.,0.,0.); 
    5429           2 :   torustubematrix[2] = new TGeoHMatrix((*torustuberot[2])*(*torustubecombitrans[1]));
    5430           1 :   torustubematrix[2]->MultiplyLeft(coolingtubematrix[1]);
    5431             : 
    5432           2 :   torustubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
    5433           1 :                                                                         -fgkEndCapCoolingTubeAxialRadius[0]);
    5434           1 :   torustuberot[3]->SetAngles(0.,90.,0.); 
    5435           2 :   torustubecombitrans[2] = new TGeoCombiTrans(*torustubetrans[2],*torustuberot[3]);
    5436           1 :   torustuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
    5437           2 :   torustubematrix[3] = new TGeoHMatrix((*torustuberot[4])*(*torustubecombitrans[2]));
    5438           1 :   torustubematrix[3]->MultiplyLeft(torustubematrix[2]);
    5439             : 
    5440           2 :   coolingtubetrans[4]->SetTranslation(-endcapcoolingtubeshape[3]->GetDz(),
    5441           1 :                                                                           fgkEndCapCoolingTubeAxialRadius[0],0.);
    5442           1 :   coolingtuberot[5]->SetAngles(90.,90.,-90.);
    5443           3 :   coolingtubecombitrans[4] = new TGeoCombiTrans(*coolingtubetrans[4],
    5444           1 :                                                                                                 *coolingtuberot[5]);
    5445           1 :   coolingtuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
    5446           2 :   coolingtubematrix[2] = new TGeoHMatrix((*coolingtuberot[6])*(*coolingtubecombitrans[4]));
    5447           1 :   coolingtubematrix[2]->MultiplyLeft(torustubematrix[3]);
    5448             :   
    5449           2 :   torustubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
    5450           1 :                                                                         endcapcoolingtubeshape[0]->GetDz());
    5451           1 :   torustuberot[5]->SetAngles(0.,90.,0.); 
    5452           2 :   torustubecombitrans[3] = new TGeoCombiTrans(*torustubetrans[3],*torustuberot[5]);
    5453           1 :   torustuberot[6]->SetAngles(-90.,0.,0.); 
    5454           2 :   torustubematrix[4] = new TGeoHMatrix((*torustuberot[6])*(*torustubecombitrans[3]));
    5455           1 :   torustubematrix[4]->MultiplyLeft(coolingtubecombitrans[0]);
    5456             :   
    5457           2 :   coolingtubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
    5458           1 :                                                                           endcapcoolingtubeshape[3]->GetDz(),0.);
    5459           1 :   coolingtuberot[6]->SetAngles(0.,90.,0.);
    5460           3 :   coolingtubecombitrans[5] = new TGeoCombiTrans(*coolingtubetrans[5],
    5461           1 :                                                                                                 *coolingtuberot[6]);
    5462           1 :   coolingtuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
    5463           2 :   coolingtubematrix[3] = new TGeoHMatrix((*coolingtuberot[7])*(*coolingtubecombitrans[5]));
    5464           1 :   coolingtubematrix[3]->MultiplyLeft(torustubematrix[4]);
    5465             :     /////////////////////////////////////////
    5466             :   // Transformation for Water Volume Positioning 
    5467             :   /////////////////////////////////////////
    5468           2 :   coolingwatertubetrans[0]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0],
    5469           1 :                                                                           -endcapcoolingwatertubeshape[0]->GetDz(),0.);
    5470           1 :   coolingwatertuberot[0]->SetAngles(0.,90.,0.);
    5471           3 :   coolingwatertubecombitrans[0] = new TGeoCombiTrans(*coolingwatertubetrans[0],
    5472           1 :                                                                                                      *coolingwatertuberot[0]);
    5473             : 
    5474           1 :   coolingwatertubetrans[1]->SetTranslation(0.,-endcapcoolingwatertubeshape[1]->GetDz(),0.);
    5475           1 :   coolingwatertuberot[1]->SetAngles(0.,90.,0.);
    5476           3 :   coolingwatertubecombitrans[1] = new TGeoCombiTrans(*coolingwatertubetrans[1],
    5477           1 :                                                                                                      *coolingwatertuberot[1]);
    5478             : 
    5479           2 :   coolingwatertubetrans[2]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[0]
    5480           1 :                                                                                   *CosD(fgkEndCapCoolingTubeAngle[0]),
    5481           1 :                                                                                   fgkEndCapCoolingTubeAxialRadius[0]
    5482           1 :                                                                                   *SinD(fgkEndCapCoolingTubeAngle[0]),
    5483             :                                                                               0.);
    5484           1 :   coolingwatertuberot[2]->SetAngles(fgkEndCapCoolingTubeAngle[0]-180.,0.,0.);
    5485           3 :   coolingwatertubecombitrans[2] = new TGeoCombiTrans(*coolingwatertubetrans[2],
    5486           1 :                                                                                                     *coolingwatertuberot[2]);
    5487             : 
    5488           2 :   coolingwatertubematrix[0] = new TGeoHMatrix((*coolingwatertubecombitrans[2])
    5489           1 :                                            *                                 (*coolingwatertubecombitrans[1]));
    5490             :                                            
    5491           2 :   toruswatertubetrans[0]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
    5492           1 :                                                                          endcapcoolingwatertubeshape[1]->GetDz());
    5493           1 :   toruswatertuberot[0]->SetAngles(0.,90.,0.); 
    5494           3 :   toruswatertubecombitrans[0] = new TGeoCombiTrans(*toruswatertubetrans[0],
    5495           1 :                                                                                                    *toruswatertuberot[0]);
    5496             : 
    5497           2 :   toruswatertubematrix[0] = new TGeoHMatrix((*coolingwatertubematrix[0])
    5498           1 :                                                   *                                     (*toruswatertubecombitrans[0]));
    5499             : 
    5500           2 :   coolingwatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],
    5501           1 :                                                                           -endcapcoolingwatertubeshape[2]->GetDz(),0.);
    5502           1 :   coolingwatertuberot[3]->SetAngles(0.,90.,0.);
    5503           3 :   coolingwatertubecombitrans[3] = new TGeoCombiTrans(*coolingwatertubetrans[3],
    5504           1 :                                                                                                      *coolingwatertuberot[3]);
    5505           1 :   coolingwatertuberot[4]->SetAngles(-180.+fgkEndCapCoolingTubeAngle[1],0.,0.);
    5506           2 :   coolingwatertubematrix[1] = new TGeoHMatrix((*coolingwatertuberot[4])
    5507           1 :                                                         *                                 (*coolingwatertubecombitrans[3]));
    5508           1 :   coolingwatertubematrix[1]->MultiplyLeft(toruswatertubematrix[0]);
    5509             : 
    5510           2 :   toruswatertubetrans[1]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[0],0.,
    5511           1 :                                                                         endcapcoolingwatertubeshape[2]->GetDz());
    5512           1 :   toruswatertuberot[1]->SetAngles(0.,90.,0.); 
    5513           3 :   toruswatertubecombitrans[1] = new TGeoCombiTrans(*toruswatertubetrans[1],
    5514           1 :                                                                                                    *toruswatertuberot[1]);
    5515           1 :   toruswatertuberot[2]->SetAngles(180.,0.,0.); 
    5516           2 :   toruswatertubematrix[2] = new TGeoHMatrix((*toruswatertuberot[2])
    5517           1 :                                                   *                 (*toruswatertubecombitrans[1]));
    5518           1 :   toruswatertubematrix[2]->MultiplyLeft(coolingwatertubematrix[1]);
    5519             :   
    5520           2 :   toruswatertubetrans[2]->SetTranslation(0.,fgkEndCapCoolingTubeAxialRadius[0],
    5521           1 :                                                                                    -fgkEndCapCoolingTubeAxialRadius[0]);
    5522           1 :   toruswatertuberot[3]->SetAngles(0.,90.,0.); 
    5523           3 :   toruswatertubecombitrans[2] = new TGeoCombiTrans(*toruswatertubetrans[2],
    5524           1 :                                                                                                    *toruswatertuberot[3]);
    5525           1 :   toruswatertuberot[4]->SetAngles(fgkEndCapCoolingTubeAngle[2]-90.,0.,0.); 
    5526           2 :   toruswatertubematrix[3] = new TGeoHMatrix((*toruswatertuberot[4])
    5527           1 :                                                   *                                     (*toruswatertubecombitrans[2]));
    5528           1 :   toruswatertubematrix[3]->MultiplyLeft(toruswatertubematrix[2]);
    5529             : 
    5530           2 :   coolingwatertubetrans[4]->SetTranslation(-endcapcoolingwatertubeshape[3]->GetDz(),
    5531           1 :                                                                                 fgkEndCapCoolingTubeAxialRadius[0],0.);
    5532           1 :   coolingwatertuberot[5]->SetAngles(90.,90.,-90.);
    5533           3 :   coolingwatertubecombitrans[4] = new TGeoCombiTrans(*coolingwatertubetrans[4],
    5534           1 :                                                                                                      *coolingwatertuberot[5]);
    5535           1 :   coolingwatertuberot[6]->SetAngles(fgkEndCapCoolingTubeAngle[3],0.,0.);
    5536           2 :   coolingwatertubematrix[2] = new TGeoHMatrix((*coolingwatertuberot[6])
    5537           1 :                                                         *                                 (*coolingwatertubecombitrans[4]));
    5538           1 :   coolingwatertubematrix[2]->MultiplyLeft(toruswatertubematrix[3]);
    5539             :   
    5540           2 :   toruswatertubetrans[3]->SetTranslation(-fgkEndCapCoolingTubeAxialRadius[1],0.,
    5541           1 :                                                                               endcapcoolingwatertubeshape[0]->GetDz());
    5542           1 :   toruswatertuberot[5]->SetAngles(0.,90.,0.); 
    5543           3 :   toruswatertubecombitrans[3] = new TGeoCombiTrans(*toruswatertubetrans[3],
    5544           1 :                                                                                                    *toruswatertuberot[5]);
    5545           1 :   toruswatertuberot[6]->SetAngles(-90.,0.,0.); 
    5546           2 :   toruswatertubematrix[4] = new TGeoHMatrix((*toruswatertuberot[6])
    5547           1 :                                                   *                 (*toruswatertubecombitrans[3]));
    5548           1 :   toruswatertubematrix[4]->MultiplyLeft(coolingwatertubecombitrans[0]);
    5549             :   
    5550           2 :   coolingwatertubetrans[5]->SetTranslation(fgkEndCapCoolingTubeAxialRadius[1],
    5551           1 :                                                                           endcapcoolingwatertubeshape[3]->GetDz(),0.);
    5552           1 :   coolingwatertuberot[6]->SetAngles(0.,90.,0.);
    5553           3 :   coolingwatertubecombitrans[5] = new TGeoCombiTrans(*coolingwatertubetrans[5],
    5554           1 :                                                                                                      *coolingwatertuberot[6]);
    5555           1 :   coolingwatertuberot[7]->SetAngles(fgkEndCapCoolingTubeAngle[4],0.,0.);
    5556           2 :   coolingwatertubematrix[3] = new TGeoHMatrix((*coolingwatertuberot[7])
    5557           1 :                                                         *                                 (*coolingwatertubecombitrans[5]));
    5558           1 :   coolingwatertubematrix[3]->MultiplyLeft(toruswatertubematrix[4]);
    5559             :   /////////////////////////////////////////
    5560             :   // Positioning Volumes
    5561             :   /////////////////////////////////////////
    5562           1 :   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[0],1);
    5563           1 :   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[0],1);
    5564             :   
    5565           1 :   endcapcoolingtubemother->AddNode(endcapcoolingtube[0],1,coolingtubecombitrans[0]);
    5566           1 :   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[0],1,coolingwatertubecombitrans[0]);
    5567             : 
    5568           1 :   endcapcoolingtubemother->AddNode(endcapcoolingtube[1],1,coolingtubematrix[0]);
    5569           1 :   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[1],1,coolingwatertubematrix[0]);
    5570             :  
    5571           1 :   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[1],1,torustubematrix[0]);
    5572           1 :   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[1],1,toruswatertubematrix[0]);
    5573             : 
    5574           1 :   endcapcoolingtubemother->AddNode(endcapcoolingtube[2],1,coolingtubematrix[1]);
    5575           1 :   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[2],1,coolingwatertubematrix[1]);
    5576             : 
    5577           1 :   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[2],1,torustubematrix[2]);
    5578           1 :   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[2],1,toruswatertubematrix[2]);
    5579             : 
    5580           1 :   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[3],1,torustubematrix[3]);
    5581           1 :   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[3],1,toruswatertubematrix[3]);
    5582             : 
    5583           1 :   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],1,coolingtubematrix[2]);
    5584           1 :   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],1,coolingwatertubematrix[2]);
    5585             :   
    5586           1 :   endcapcoolingtubemother->AddNode(endcapcoolingtubetorus[4],1,torustubematrix[4]);
    5587           1 :   endcapcoolingtubemother->AddNode(endcapcoolingwatertubetorus[4],1,toruswatertubematrix[4]);
    5588             :  
    5589           1 :   endcapcoolingtubemother->AddNode(endcapcoolingtube[3],2,coolingtubematrix[3]);
    5590           1 :   endcapcoolingtubemother->AddNode(endcapcoolingwatertube[3],2,coolingwatertubematrix[3]);
    5591             :   /////////////////////////////////////////////////////////////
    5592             :   // Deallocating memory
    5593             :   /////////////////////////////////////////////////////////////
    5594          18 :   for(Int_t i=0; i<8; i++){
    5595           8 :     if(i<6){
    5596          12 :          delete coolingtubetrans[i];
    5597          12 :          delete coolingwatertubetrans[i];
    5598           6 :          if(i!=0){
    5599          10 :           delete coolingtubecombitrans[i];
    5600          10 :           delete coolingwatertubecombitrans[i];
    5601             :          }
    5602             :         }
    5603           8 :     if(i<8){
    5604          16 :           delete coolingtuberot[i];
    5605          16 :           delete coolingwatertuberot[i];
    5606             :     }
    5607           8 :     if(i<4){
    5608           8 :                 delete torustubetrans[i];
    5609           8 :                 delete toruswatertubetrans[i];
    5610           8 :                 delete torustubecombitrans[i];
    5611           8 :                 delete toruswatertubecombitrans[i];
    5612             :         } 
    5613           8 :     if(i<7){
    5614          14 :          delete torustuberot[i];
    5615          14 :          delete toruswatertuberot[i];
    5616             :         }
    5617             :   }
    5618             :   /////////////////////////////////////////////////////////////
    5619           1 :   endcapcoolingtubemother->GetShape()->ComputeBBox(); //RS: enforce recompting of BBox
    5620             : 
    5621           1 :   return endcapcoolingtubemother;
    5622           1 :  }
    5623             :  ////////////////////////////////////////////////////////////////////////////////
    5624             :  TGeoVolume* AliITSv11GeometrySSD::GetEndCapSideCover() const {
    5625             :   /////////////////////////////////////////////////////////////
    5626             :   // Getting EndCap Cover Side 
    5627             :   /////////////////////////////////////////////////////////////
    5628             :   const Int_t kendcapcoverholenumber[2] = {7,5}; 
    5629             :   const Int_t kvertexnumber = 15; 
    5630           2 :   Double_t xvertex[kvertexnumber], yvertex[kvertexnumber];
    5631           1 :   xvertex[0]  = 0.0;
    5632           1 :   xvertex[1]  = xvertex[0];
    5633           1 :   xvertex[2]  = fgkEndCapSideCoverLength[0];
    5634           1 :   xvertex[3]  = fgkEndCapSideCoverLength[1];
    5635           1 :   xvertex[4]  = xvertex[3];
    5636           1 :   xvertex[5]  = fgkEndCapSideCoverLength[2];
    5637           1 :   xvertex[6]  = xvertex[5];
    5638           1 :   xvertex[7]  = xvertex[2];
    5639           1 :   xvertex[8]  = xvertex[7];
    5640           1 :   xvertex[9]  = xvertex[6]-fgkEndCapSideCoverLength[0];
    5641           1 :   xvertex[10] = xvertex[9];
    5642           3 :   xvertex[11] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[1]
    5643           2 :                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[1]-1)
    5644           1 :                           * fgkEndCapSideCoverLength[4];
    5645           1 :   xvertex[12] = xvertex[11];
    5646           3 :   xvertex[13] = xvertex[5]-fgkEndCapSideCoverLength[0]-kendcapcoverholenumber[0]
    5647           2 :                           * fgkEndCapSideCoverLength[3]-(kendcapcoverholenumber[0]-1)
    5648           1 :                           * fgkEndCapSideCoverLength[4];
    5649           1 :   xvertex[14] = xvertex[13];
    5650           1 :   yvertex[0]  = 0.0;
    5651           1 :   yvertex[1]  = fgkEndCapSideCoverWidth[0];
    5652           1 :   yvertex[2]  = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[2];
    5653           1 :   yvertex[3]  = yvertex[2];
    5654           1 :   yvertex[4]  = fgkEndCapSideCoverWidth[1];
    5655           1 :   yvertex[5]  = yvertex[4];
    5656           1 :   yvertex[6]  = yvertex[0];
    5657           1 :   yvertex[7]  = yvertex[6];
    5658           1 :   yvertex[8]  = fgkEndCapSideCoverWidth[6];
    5659           1 :   yvertex[9]  = yvertex[8];
    5660           1 :   yvertex[10] = fgkEndCapSideCoverWidth[1]-fgkEndCapSideCoverWidth[3];
    5661           1 :   yvertex[11] = yvertex[10];
    5662           1 :   yvertex[12] = yvertex[9]+2.*fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]; 
    5663           1 :   yvertex[13] = yvertex[12];
    5664           1 :   yvertex[14] = yvertex[6];
    5665           1 :   TGeoXtru* endcapsidecovershapeout = new TGeoXtru(2);
    5666           1 :   endcapsidecovershapeout->SetName("endcapsidecovershapeout");
    5667           1 :   endcapsidecovershapeout->DefinePolygon(7,xvertex,yvertex); 
    5668           1 :   endcapsidecovershapeout->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
    5669           1 :   endcapsidecovershapeout->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
    5670           1 :   TGeoXtru* endcapsidecovershapein = new TGeoXtru(2);
    5671           1 :   endcapsidecovershapein->SetName("endcapsidecovershapein");
    5672           1 :   endcapsidecovershapein->DefinePolygon(6,&xvertex[8],&yvertex[8]); 
    5673           1 :   endcapsidecovershapein->DefineSection(0,-0.5*fgkEndCapSideCoverThickness-0.01);
    5674           1 :   endcapsidecovershapein->DefineSection(1,0.5*fgkEndCapSideCoverThickness+0.01);
    5675             : 
    5676             : 
    5677           1 :   TGeoCompositeShape* endcapsidecovershape = new TGeoCompositeShape("endcapsidecovershape", "endcapsidecovershapeout-endcapsidecovershapein");
    5678           2 :   TGeoVolume* endcapsidecover = new TGeoVolume("EndCapSideCover",
    5679           1 :                                                                 endcapsidecovershape,fSSDCoolingTubePhynox);
    5680           1 :   endcapsidecover->SetLineColor(fColorPhynox);
    5681             :   ////////////////////////////////////////////
    5682             :   // Defininition of Mother Volume
    5683             :   ////////////////////////////////////////////
    5684             :   const Int_t kmothervertexnumber = 7;
    5685           1 :   Double_t xmothervertex[kmothervertexnumber]; 
    5686           1 :   Double_t ymothervertex[kmothervertexnumber]; 
    5687          16 :   for(Int_t i=0; i<kmothervertexnumber; i++){
    5688           7 :         xmothervertex[i] = xvertex[i];
    5689           7 :         ymothervertex[i] = yvertex[i];
    5690             :   }
    5691           1 :   TGeoXtru* endcapsidecovermothershape = new TGeoXtru(2);
    5692           1 :   endcapsidecovermothershape->DefinePolygon(kmothervertexnumber,xmothervertex,ymothervertex); 
    5693           1 :   endcapsidecovermothershape->DefineSection(0,-0.5*fgkEndCapSideCoverThickness);
    5694           1 :   endcapsidecovermothershape->DefineSection(1,0.5*fgkEndCapSideCoverThickness);
    5695           2 :   TGeoVolume* endcapsidecovermother = new TGeoVolume("EndCapSideCoverMother",
    5696           1 :                                                                 endcapsidecovermothershape,fSSDAir);
    5697             :   ////////////////////////////////////////////
    5698           1 :   endcapsidecovermother->AddNode(endcapsidecover,1);
    5699             :   TGeoBBox* endcapsidecoverboxshape[4];
    5700           3 :   endcapsidecoverboxshape[0] = new TGeoBBox(0.5*(kendcapcoverholenumber[0]*fgkEndCapSideCoverLength[3]
    5701           1 :                                                          +     (kendcapcoverholenumber[0]-1)*fgkEndCapSideCoverLength[4]),
    5702           1 :                                                                0.5*fgkEndCapSideCoverLength[4],
    5703           1 :                                                                    0.5*fgkEndCapSideCoverThickness); 
    5704           3 :   endcapsidecoverboxshape[1] = new TGeoBBox(0.5*(kendcapcoverholenumber[1]*fgkEndCapSideCoverLength[3]
    5705           1 :                                                          +     (kendcapcoverholenumber[1]-1)*fgkEndCapSideCoverLength[4]),
    5706           2 :                                                                0.5*(fgkEndCapSideCoverWidth[4]-2.*fgkEndCapSideCoverWidth[5]
    5707           1 :                                                          -     fgkEndCapSideCoverLength[4]),
    5708           1 :                                                                    0.5*fgkEndCapSideCoverThickness); 
    5709           2 :   endcapsidecoverboxshape[2] = new TGeoBBox(endcapsidecoverboxshape[1]->GetDX(),
    5710           1 :                                                                0.5*fgkEndCapSideCoverLength[4],
    5711           1 :                                                                    0.5*fgkEndCapSideCoverThickness); 
    5712           2 :   endcapsidecoverboxshape[3] = new TGeoBBox(0.5*fgkEndCapSideCoverLength[4],
    5713           1 :                                                                0.5*fgkEndCapSideCoverWidth[5],
    5714           1 :                                                                    0.5*fgkEndCapSideCoverThickness); 
    5715           1 :   TGeoVolume* endcapsidecoverbox[4];
    5716           2 :   endcapsidecoverbox[0] = new TGeoVolume("EndCapSideCoverBox1",endcapsidecoverboxshape[0],fSSDCoolingTubePhynox);
    5717           2 :   endcapsidecoverbox[1] = new TGeoVolume("EndCapSideCoverBox2",endcapsidecoverboxshape[1],fSSDCoolingTubePhynox);
    5718           2 :   endcapsidecoverbox[2] = new TGeoVolume("EndCapSideCoverBox3",endcapsidecoverboxshape[2],fSSDCoolingTubePhynox);
    5719           2 :   endcapsidecoverbox[3] = new TGeoVolume("EndCapSideCoverBox4",endcapsidecoverboxshape[3],fSSDCoolingTubePhynox);
    5720          10 :   for(Int_t i=0; i<4; i++)   endcapsidecoverbox[i]->SetLineColor(fColorPhynox);
    5721             : //  TGeoTranslation* endcapsidecoverboxtrans[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
    5722             :   TGeoTranslation** endcapsidecoverboxtrans;
    5723           1 :   endcapsidecoverboxtrans = new TGeoTranslation*[3+2*(kendcapcoverholenumber[0]-1)+2*(kendcapcoverholenumber[1]-1)];
    5724           3 :   endcapsidecoverboxtrans[0] = new TGeoTranslation(endcapsidecoverboxshape[0]->GetDX()
    5725           1 :                                                          +                                         fgkEndCapSideCoverLength[0],
    5726           1 :                                                                                                    endcapsidecoverboxshape[0]->GetDY()
    5727           1 :                                                          +                     yvertex[9]+fgkEndCapSideCoverWidth[5],0.);
    5728           3 :   endcapsidecoverboxtrans[1] = new TGeoTranslation(endcapsidecoverboxshape[1]->GetDX()
    5729           1 :                                                          +                     xvertex[11],
    5730           1 :                                                                                                    endcapsidecoverboxshape[1]->GetDY()
    5731           1 :                                                          +                     yvertex[12],0.);
    5732           3 :   endcapsidecoverboxtrans[2] = new TGeoTranslation(endcapsidecoverboxshape[2]->GetDX()
    5733           1 :                                                          +                     xvertex[11],
    5734           1 :                                                                                                    endcapsidecoverboxshape[2]->GetDY()
    5735           1 :                                                          +                     yvertex[12]
    5736           2 :                                                          +                                         2.*endcapsidecoverboxshape[1]->GetDY() 
    5737           1 :                                                          +                     fgkEndCapSideCoverWidth[5],0.);
    5738           1 :   endcapsidecovermother->AddNode(endcapsidecoverbox[0],1,endcapsidecoverboxtrans[0]);
    5739           1 :   endcapsidecovermother->AddNode(endcapsidecoverbox[1],1,endcapsidecoverboxtrans[1]);
    5740           1 :   endcapsidecovermother->AddNode(endcapsidecoverbox[2],1,endcapsidecoverboxtrans[2]);
    5741           6 :   for(Int_t i=0; i<2; i++)
    5742          28 :         for(Int_t j=0; j<kendcapcoverholenumber[0]-1; j++){
    5743          12 :                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3] = 
    5744          36 :                         new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+fgkEndCapSideCoverLength[0]
    5745          12 :                                                                 +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
    5746          24 :                                                                 endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
    5747          12 :                                                                 +i*(fgkEndCapSideCoverWidth[5]+fgkEndCapSideCoverLength[4]),0.0);
    5748          24 :                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],i*(kendcapcoverholenumber[0]-1)+j+1,
    5749          12 :                                                                 endcapsidecoverboxtrans[i*(kendcapcoverholenumber[0]-1)+j+3]);
    5750             :         }
    5751           6 :   for(Int_t i=0; i<2; i++)
    5752          20 :         for(Int_t j=0; j<kendcapcoverholenumber[1]-1; j++){
    5753           8 :                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j] = 
    5754          24 :                 new TGeoTranslation(endcapsidecoverboxshape[3]->GetDX()+xvertex[12]
    5755           8 :                                                         +(j+1)*fgkEndCapSideCoverLength[3]+j*fgkEndCapSideCoverLength[4],
    5756          16 :                                                         endcapsidecoverboxshape[3]->GetDY()+fgkEndCapSideCoverWidth[6]
    5757          16 :                                                         +fgkEndCapSideCoverWidth[4]+i*(fgkEndCapSideCoverWidth[5]
    5758           8 :                                                         +fgkEndCapSideCoverLength[4]),0.0);
    5759          16 :                 endcapsidecovermother->AddNode(endcapsidecoverbox[3],
    5760             :                                                                 2*(kendcapcoverholenumber[0]-1)+3+i*(kendcapcoverholenumber[1]-1)+j,
    5761           8 :                                                                 endcapsidecoverboxtrans[2*(kendcapcoverholenumber[0]-1)+3
    5762             :                                                                 +i*(kendcapcoverholenumber[1]-1)+j]);
    5763             :         }
    5764           2 :   delete [] endcapsidecoverboxtrans;
    5765           1 :   return endcapsidecovermother;
    5766           1 :  } 
    5767             :  ////////////////////////////////////////////////////////////////////////////////
    5768             :  TGeoVolume** AliITSv11GeometrySSD::GetEndCapCards() const { 
    5769             :  ////////////////////////////////////////////////////////////////////////////////
    5770             :  // Method returning Interface Card A, Interface Card B, Supply Card 
    5771             :  ////////////////////////////////////////////////////////////////////////////////
    5772             :  /////////////////////
    5773             :  // Supply Card
    5774             :  /////////////////////
    5775             :  // Electronic Board Back Al Plane
    5776             :  const Int_t kelectboardbackvertexnumber = 8;
    5777           2 :  Double_t xelectboardback[kelectboardbackvertexnumber];
    5778           1 :  Double_t yelectboardback[kelectboardbackvertexnumber];
    5779           1 :  xelectboardback[0] = 0.0;
    5780           1 :  xelectboardback[1] = xelectboardback[0];
    5781           1 :  xelectboardback[2] = fgkEndCapCardElectBoardBackLength[0];
    5782           1 :  xelectboardback[3] = xelectboardback[2];
    5783           1 :  xelectboardback[4] = xelectboardback[3]-fgkEndCapCardElectBoardBackLength[1];
    5784           1 :  xelectboardback[5] = xelectboardback[4];
    5785           1 :  xelectboardback[6] = fgkEndCapCardElectBoardBackLength[1];
    5786           1 :  xelectboardback[7] = xelectboardback[6];
    5787             :  
    5788           1 :  yelectboardback[0] = 0.0;
    5789           1 :  yelectboardback[1] = fgkEndCapCardElectBoardBackWidth[0];
    5790           1 :  yelectboardback[2] = yelectboardback[1];
    5791           1 :  yelectboardback[3] = yelectboardback[0];
    5792           1 :  yelectboardback[4] = yelectboardback[3];
    5793           1 :  yelectboardback[5] = yelectboardback[4]+fgkEndCapCardElectBoardBackWidth[1];
    5794           1 :  yelectboardback[6] = yelectboardback[5];
    5795           1 :  yelectboardback[7] = yelectboardback[4];
    5796           1 :  TGeoXtru* electboardbackshape = new TGeoXtru(2);
    5797           1 :  electboardbackshape->DefinePolygon(kelectboardbackvertexnumber,
    5798           1 :                                                                         xelectboardback,yelectboardback); 
    5799           1 :  electboardbackshape->DefineSection(0,0.0);
    5800           1 :  electboardbackshape->DefineSection(1,fgkEndCapCardElectBoardBackThickness);
    5801           2 :  TGeoVolume* electboardback = new TGeoVolume("EndCapCardElectBoardBackPlane",
    5802           1 :                                                                                          electboardbackshape,fSSDSupportRingAl);
    5803           1 :  electboardback->SetLineColor(fColorAl);
    5804             :  // Electronic Board Kapton Layer
    5805             :  const Int_t kelectlayervertexnumber = 8;
    5806           1 :  Double_t xelectlayer[kelectlayervertexnumber];
    5807           1 :  Double_t yelectlayer[kelectlayervertexnumber];
    5808           1 :  xelectlayer[0] = fgkEndCapCardElectBoardBackLength[0]-fgkEndCapCardElectBoardLength;
    5809           1 :  xelectlayer[1] = xelectlayer[0];
    5810           1 :  xelectlayer[2] = fgkEndCapCardElectBoardLength;
    5811           1 :  xelectlayer[3] = xelectlayer[2];
    5812          10 :  for(Int_t i=4; i<kelectlayervertexnumber; i++) xelectlayer[i] = xelectboardback[i]; 
    5813             :      
    5814           1 :  yelectlayer[0] = 0.0;
    5815           1 :  yelectlayer[1] = fgkEndCapCardElectBoardLayerWidth[0];
    5816           1 :  yelectlayer[2] = yelectlayer[1];
    5817           1 :  yelectlayer[3] = yelectlayer[0];
    5818           1 :  yelectlayer[4] = yelectlayer[3];
    5819           1 :  yelectlayer[5] = yelectlayer[4]+fgkEndCapCardElectBoardLayerWidth[1];
    5820           1 :  yelectlayer[6] = yelectlayer[5];
    5821           1 :  yelectlayer[7] = yelectlayer[4];
    5822           1 :  TGeoXtru* electlayershape = new TGeoXtru(2);
    5823           1 :  electlayershape->DefinePolygon(kelectlayervertexnumber,xelectlayer,yelectlayer); 
    5824           1 :  electlayershape->DefineSection(0,0.0);
    5825           1 :  electlayershape->DefineSection(1,fgkEndCapCardElectBoardLayerThickness);
    5826           2 :  TGeoVolume* electlayer = new TGeoVolume("EndCapCardElectBoardLayer",
    5827           1 :                                                                                          electlayershape,fSSDKaptonFlexMedium);
    5828           1 :  electlayer->SetLineColor(fColorKapton);
    5829             :  // JMD Connector Female
    5830             :  const Int_t kjmdconnectorvertexnumber = 6;
    5831           1 :  Double_t xjmdconnectorvertex[kjmdconnectorvertexnumber]; 
    5832           1 :  Double_t yjmdconnectorvertex[kjmdconnectorvertexnumber]; 
    5833           1 :  xjmdconnectorvertex[0] = 0.0; 
    5834           1 :  xjmdconnectorvertex[1] = xjmdconnectorvertex[0]; 
    5835           1 :  xjmdconnectorvertex[2] = fgkEndCapCardJMDConnectorLength[1]; 
    5836           1 :  xjmdconnectorvertex[3] = xjmdconnectorvertex[2];  
    5837           1 :  xjmdconnectorvertex[4] = fgkEndCapCardJMDConnectorLength[0]; 
    5838           1 :  xjmdconnectorvertex[5] = xjmdconnectorvertex[4]; 
    5839             : 
    5840           1 :  yjmdconnectorvertex[0] = 0.0; 
    5841           1 :  yjmdconnectorvertex[1] = fgkEndCapCardJMDConnectorWidth[0]; 
    5842           1 :  yjmdconnectorvertex[2] = yjmdconnectorvertex[1]; 
    5843           1 :  yjmdconnectorvertex[3] = yjmdconnectorvertex[2]+fgkEndCapCardJMDConnectorWidth[1]; 
    5844           1 :  yjmdconnectorvertex[4] = yjmdconnectorvertex[3]; 
    5845           1 :  yjmdconnectorvertex[5] = yjmdconnectorvertex[0]; 
    5846           1 :  TGeoXtru* jmdconnectorshape = new TGeoXtru(2);
    5847           2 :  jmdconnectorshape->DefinePolygon(kjmdconnectorvertexnumber,xjmdconnectorvertex,
    5848           1 :                                                                   yjmdconnectorvertex); 
    5849           1 :  jmdconnectorshape->DefineSection(0,0.0);
    5850           1 :  jmdconnectorshape->DefineSection(1,fgkEndCapCardJMDConnectorThickness);
    5851           2 :  TGeoVolume* jmdconnector = new TGeoVolume("EndCapCardJMDConnector",
    5852           1 :                                                                                    jmdconnectorshape,fSSDMountingBlockMedium);
    5853           1 :  jmdconnector->SetLineColor(fColorG10);
    5854             :  // Top Cable Connector
    5855             :  const Int_t kcableconnectorvertexnumber = 8;
    5856           1 :  Double_t xconnectorvertex[kcableconnectorvertexnumber]; 
    5857           1 :  Double_t yconnectorvertex[kcableconnectorvertexnumber]; 
    5858           1 :  xconnectorvertex[0] = 0.0;
    5859           1 :  xconnectorvertex[1] = xconnectorvertex[0];
    5860           1 :  xconnectorvertex[2] = xconnectorvertex[1]+fgkEndCapCardCableConnectorLength[1];
    5861           1 :  xconnectorvertex[3] = xconnectorvertex[2];
    5862           2 :  xconnectorvertex[4] = fgkEndCapCardCableConnectorLength[0]
    5863           1 :                                          - fgkEndCapCardCableConnectorLength[2];
    5864           1 :  xconnectorvertex[5] = xconnectorvertex[4];
    5865           1 :  xconnectorvertex[6] = fgkEndCapCardCableConnectorLength[0];
    5866           1 :  xconnectorvertex[7] = xconnectorvertex[6];
    5867             : 
    5868           1 :  yconnectorvertex[0] = 0.0;
    5869           1 :  yconnectorvertex[1] = fgkEndCapCardCableConnectorWidth[0];
    5870           1 :  yconnectorvertex[2] = yconnectorvertex[1];
    5871           1 :  yconnectorvertex[3] = fgkEndCapCardCableConnectorWidth[1];
    5872           1 :  yconnectorvertex[4] = yconnectorvertex[3];
    5873           1 :  yconnectorvertex[5] = yconnectorvertex[1];
    5874           1 :  yconnectorvertex[6] = yconnectorvertex[5];
    5875           1 :  yconnectorvertex[7] = yconnectorvertex[0];
    5876           1 :  TGeoXtru* cableconnectorshape = new TGeoXtru(2);
    5877           2 :  cableconnectorshape->DefinePolygon(kcableconnectorvertexnumber,xconnectorvertex,
    5878           1 :                                                                     yconnectorvertex); 
    5879           1 :  cableconnectorshape->DefineSection(0,0.0);
    5880           1 :  cableconnectorshape->DefineSection(1,fgkEndCapCardCableConnectorThickness);
    5881           2 :  TGeoVolume* cableconnector = new TGeoVolume("EndCapCardTopCableConnector",
    5882           1 :                                                                                    cableconnectorshape,fSSDMountingBlockMedium);
    5883           1 :  cableconnector->SetLineColor(fColorG10);
    5884             :  // Strip Connection
    5885             :  TGeoBBox* endcapstripconnectionshape = 
    5886           2 :                                                                 new TGeoBBox(0.5*fgkEndCapStripConnectionLength,
    5887           1 :                                                                                          0.5*fgkEndCapStripConnectionThickness,
    5888           1 :                                                                                          0.5*fgkEndCapStripConnectionWidth);
    5889           2 :  TGeoVolume* endcapstripconnection = new TGeoVolume("EndCapStripConnection",
    5890           1 :                                                                                                         endcapstripconnectionshape,
    5891           1 :                                                                                                         fSSDSupportRingAl);
    5892           1 :  endcapstripconnection->SetLineColor(fColorAl);
    5893             :  // Interface Card B
    5894             :  const Int_t kcardBvertexnumber = 12; 
    5895           1 :  Double_t xcardBvertexnumber[kcardBvertexnumber];
    5896           1 :  Double_t ycardBvertexnumber[kcardBvertexnumber];
    5897             : 
    5898           1 :  xcardBvertexnumber[0]  = 0.0;
    5899           1 :  xcardBvertexnumber[1]  = xcardBvertexnumber[0];
    5900           1 :  xcardBvertexnumber[2]  = xcardBvertexnumber[1]+fgkEndCapInterfaceCardBLength[0];
    5901           1 :  xcardBvertexnumber[3]  = xcardBvertexnumber[2];
    5902           1 :  xcardBvertexnumber[4]  = xcardBvertexnumber[1];
    5903           1 :  xcardBvertexnumber[5]  = xcardBvertexnumber[4];
    5904           1 :  xcardBvertexnumber[6]  = xcardBvertexnumber[5]+fgkEndCapInterfaceCardBLength[1];
    5905           1 :  xcardBvertexnumber[7]  = xcardBvertexnumber[6];
    5906           1 :  xcardBvertexnumber[8]  = xcardBvertexnumber[7]-fgkEndCapInterfaceCardBLength[0];
    5907           1 :  xcardBvertexnumber[9]  = xcardBvertexnumber[8];
    5908           1 :  xcardBvertexnumber[10] = xcardBvertexnumber[7];
    5909           1 :  xcardBvertexnumber[11] = xcardBvertexnumber[10];
    5910             :  
    5911           1 :  ycardBvertexnumber[0]  = 0.0;
    5912           1 :  ycardBvertexnumber[1]  = fgkEndCapInterfaceCardBWidth[0];
    5913           1 :  ycardBvertexnumber[2]  = ycardBvertexnumber[1];
    5914           1 :  ycardBvertexnumber[3]  = ycardBvertexnumber[2]+fgkEndCapInterfaceCardBWidth[1];
    5915           1 :  ycardBvertexnumber[4]  = ycardBvertexnumber[3];
    5916           1 :  ycardBvertexnumber[5]  = ycardBvertexnumber[4]+fgkEndCapInterfaceCardBWidth[2];
    5917           1 :  ycardBvertexnumber[6]  = ycardBvertexnumber[5];
    5918           1 :  ycardBvertexnumber[7]  = ycardBvertexnumber[4];
    5919           1 :  ycardBvertexnumber[8]  = ycardBvertexnumber[7];
    5920           1 :  ycardBvertexnumber[9]  = ycardBvertexnumber[1];
    5921           1 :  ycardBvertexnumber[10] = ycardBvertexnumber[9];
    5922           1 :  ycardBvertexnumber[11] = ycardBvertexnumber[0];
    5923             : 
    5924           1 :  TGeoXtru* interfacecardBshape = new TGeoXtru(2);
    5925           1 :  interfacecardBshape->DefinePolygon(kcardBvertexnumber,xcardBvertexnumber,ycardBvertexnumber);
    5926           1 :  interfacecardBshape->DefineSection(0,0.);
    5927           1 :  interfacecardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness);
    5928           2 :  TGeoVolume* interfacecardB = new TGeoVolume("EndCapInterfaceCardB",interfacecardBshape,
    5929           1 :                                                                                          fSSDMountingBlockMedium);
    5930           1 :  interfacecardB->SetLineColor(46);
    5931             :  // Interface Card B Electronic Board
    5932             :  const Int_t kelectboardcardBvertexnumber = 14; 
    5933           1 :  Double_t xelectboardcardBvertex[kelectboardcardBvertexnumber];
    5934           1 :  Double_t yelectboardcardBvertex[kelectboardcardBvertexnumber];
    5935             : 
    5936           1 :  xelectboardcardBvertex[0]  = xcardBvertexnumber[0]+fgkEndCapInterfaceCardBLength[2];
    5937           1 :  xelectboardcardBvertex[1]  = xelectboardcardBvertex[0]; 
    5938           1 :  xelectboardcardBvertex[2]  = xelectboardcardBvertex[1]+fgkEndCapInterfaceCardBLength[3];
    5939           1 :  xelectboardcardBvertex[3]  = xelectboardcardBvertex[2]; 
    5940           1 :  xelectboardcardBvertex[4]  = xelectboardcardBvertex[3]+fgkEndCapInterfaceCardBLength[4];
    5941           1 :  xelectboardcardBvertex[5]  = xelectboardcardBvertex[4];
    5942           1 :  xelectboardcardBvertex[6]  = xelectboardcardBvertex[5]+fgkEndCapInterfaceCardBLength[5];
    5943           1 :  xelectboardcardBvertex[7]  = xelectboardcardBvertex[6];
    5944           1 :  xelectboardcardBvertex[8]  = xelectboardcardBvertex[7]+8.0*fgkEndCapInterfaceCardBLength[4];
    5945           1 :  xelectboardcardBvertex[9]  = xelectboardcardBvertex[8];
    5946           1 :  xelectboardcardBvertex[10] = xelectboardcardBvertex[9]+fgkEndCapInterfaceCardBLength[6];
    5947           1 :  xelectboardcardBvertex[11] = xelectboardcardBvertex[10];
    5948           1 :  xelectboardcardBvertex[12] = xelectboardcardBvertex[11]-9.0*fgkEndCapInterfaceCardBLength[4];
    5949           1 :  xelectboardcardBvertex[13] = xelectboardcardBvertex[12];
    5950             : 
    5951           1 :  yelectboardcardBvertex[0]  = ycardBvertexnumber[0]+fgkEndCapInterfaceCardBWidth[1];
    5952           1 :  yelectboardcardBvertex[1]  = yelectboardcardBvertex[0]+fgkEndCapInterfaceCardBWidth[3];
    5953           1 :  yelectboardcardBvertex[2]  = yelectboardcardBvertex[1];
    5954           1 :  yelectboardcardBvertex[3]  = yelectboardcardBvertex[2]+fgkEndCapInterfaceCardBWidth[3];
    5955           1 :  yelectboardcardBvertex[4]  = yelectboardcardBvertex[3];
    5956           1 :  yelectboardcardBvertex[5]  = yelectboardcardBvertex[2];
    5957           1 :  yelectboardcardBvertex[6]  = yelectboardcardBvertex[5];
    5958           1 :  yelectboardcardBvertex[7]  = yelectboardcardBvertex[6]+fgkEndCapInterfaceCardBWidth[4];
    5959           1 :  yelectboardcardBvertex[8]  = yelectboardcardBvertex[7];
    5960           1 :  yelectboardcardBvertex[9]  = yelectboardcardBvertex[8]-fgkEndCapInterfaceCardBWidth[3];
    5961           1 :  yelectboardcardBvertex[10] = yelectboardcardBvertex[9];
    5962           1 :  yelectboardcardBvertex[11] = yelectboardcardBvertex[10]-fgkEndCapInterfaceCardBWidth[3];
    5963           1 :  yelectboardcardBvertex[12] = yelectboardcardBvertex[11];
    5964           1 :  yelectboardcardBvertex[13] = yelectboardcardBvertex[0];
    5965             : 
    5966           1 :  TGeoXtru* electboardcardBshape = new TGeoXtru(2);
    5967           1 :  electboardcardBshape->DefinePolygon(kelectboardcardBvertexnumber,
    5968           1 :                                                                          xelectboardcardBvertex,yelectboardcardBvertex);
    5969           1 :  electboardcardBshape->DefineSection(0,fgkEndCapInterfaceCardBThickness);
    5970           2 :  electboardcardBshape->DefineSection(1,fgkEndCapInterfaceCardBThickness
    5971           1 :                                                                          + fgkEndCapInterfaceElectBoardCardBThickness);
    5972           2 :  TGeoVolume* electboardcardB = new TGeoVolume("EndCapInterfaceElectBoardCardB",electboardcardBshape,
    5973           1 :                                                                                           fSSDSupportRingAl);
    5974           1 :  electboardcardB->SetLineColor(fColorAl);
    5975             :  // Generating Stiffener 2
    5976           2 :  TGeoBBox* endcapstiffenershape = new TGeoBBox(0.5*fgkEndCapStiffenerWidth,
    5977           1 :                                                                                            0.5*fgkEndCapStiffenerThickness,
    5978           1 :                                                                                            0.5*fgkEndCapStiffenerLength);
    5979           1 :  TGeoVolume* endcapstiffener = new TGeoVolume("EndCapStiffener",endcapstiffenershape,fSSDSupportRingAl);
    5980           1 :  endcapstiffener->SetLineColor(fColorAl);   
    5981             :  // Generating Mother Interface Card B Container
    5982             :  const Int_t kinterfacecardBmothervertexnumber = 10;
    5983           1 :  Double_t xinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
    5984           1 :  Double_t yinterfacecardBmothervertex[kinterfacecardBmothervertexnumber];
    5985             : 
    5986           1 :  xinterfacecardBmothervertex[0] = 0.0;
    5987           1 :  xinterfacecardBmothervertex[1] = xinterfacecardBmothervertex[0];
    5988           1 :  xinterfacecardBmothervertex[2] = xinterfacecardBmothervertex[1]
    5989           1 :                                                                 + fgkEndCapInterfaceCardBThickness;
    5990           1 :  xinterfacecardBmothervertex[3] = xinterfacecardBmothervertex[2];
    5991           1 :  xinterfacecardBmothervertex[4] = xinterfacecardBmothervertex[3]
    5992           1 :                                                                 + fgkEndCapInterfaceElectBoardCardBThickness;
    5993           1 :  xinterfacecardBmothervertex[5] = xinterfacecardBmothervertex[4];
    5994           1 :  xinterfacecardBmothervertex[6] = xinterfacecardBmothervertex[3];
    5995           1 :  xinterfacecardBmothervertex[7] = xinterfacecardBmothervertex[6];
    5996           1 :  xinterfacecardBmothervertex[8] = xinterfacecardBmothervertex[7]
    5997           1 :                                                                 + fgkEndCapCardJMDConnectorLength[0];
    5998           1 :  xinterfacecardBmothervertex[9] = xinterfacecardBmothervertex[8];
    5999             : 
    6000           1 :  yinterfacecardBmothervertex[0] = 0.0;
    6001           2 :  yinterfacecardBmothervertex[1] = fgkEndCapInterfaceCardBWidth[0]
    6002           1 :                                                                 + fgkEndCapInterfaceCardBWidth[1]
    6003           1 :                                                                 + fgkEndCapInterfaceCardBWidth[2];
    6004           1 :  yinterfacecardBmothervertex[2] = yinterfacecardBmothervertex[1];
    6005           1 :  yinterfacecardBmothervertex[3] = yelectboardcardBvertex[3];
    6006           1 :  yinterfacecardBmothervertex[4] = yinterfacecardBmothervertex[3];
    6007           1 :  yinterfacecardBmothervertex[5] = yelectboardcardBvertex[11];
    6008           1 :  yinterfacecardBmothervertex[6] = yinterfacecardBmothervertex[5];
    6009           2 :  yinterfacecardBmothervertex[7] = fgkEndCapCardElectBoardLayerWidth[1]
    6010           1 :                                                                 + fgkEndCapCardJMDConnectorWidth[0]
    6011           1 :                                                                 + fgkEndCapCardJMDConnectorWidth[1];
    6012           1 :  yinterfacecardBmothervertex[8] = yinterfacecardBmothervertex[7];
    6013           1 :  yinterfacecardBmothervertex[9] = yinterfacecardBmothervertex[0];
    6014           1 :  TGeoXtru* interfacecardBmothershape = new TGeoXtru(2);
    6015           1 :  interfacecardBmothershape->DefinePolygon(kinterfacecardBmothervertexnumber,
    6016           1 :                                                                                   xinterfacecardBmothervertex,
    6017           1 :                                                                                   yinterfacecardBmothervertex);
    6018           1 :  interfacecardBmothershape->DefineSection(0,-1.e-15);
    6019           1 :  interfacecardBmothershape->DefineSection(1,fgkEndCapInterfaceCardBLength[1]);
    6020           2 :  TGeoVolume* interfacecardBmother = new TGeoVolume("EndCapInterfaceCardBMother",
    6021           1 :                                                                                                    interfacecardBmothershape,fSSDAir);
    6022           1 :  electboardcardB->SetLineColor(fColorAl);
    6023             :  // Positioning Volumes Mother Interface Card B Container 
    6024           1 :  TGeoRotation* interfacecardBrot = new TGeoRotation();
    6025           1 :  TGeoTranslation* interfacecardBtrans = new TGeoTranslation(); 
    6026           1 :  interfacecardBrot->SetAngles(90.,-90.,-90.);
    6027           1 :  interfacecardBtrans->SetTranslation(fgkEndCapInterfaceCardBThickness,0.,0.);
    6028           1 :  TGeoCombiTrans* interfacecardBcombitrans = new TGeoCombiTrans(*interfacecardBtrans,*interfacecardBrot);
    6029           1 :  TGeoRotation* electboardcardBrot = new TGeoRotation();
    6030           1 :  TGeoTranslation* electboardcardBtrans = new TGeoTranslation(); 
    6031           1 :  electboardcardBrot->SetAngles(90.,90.,-90.);
    6032           1 :  electboardcardBtrans->SetTranslation(0.,0.,fgkEndCapInterfaceCardBLength[1]);
    6033             :  TGeoCombiTrans* electboardcardBcombitrans = 
    6034           1 :                                   new TGeoCombiTrans(*electboardcardBtrans,*electboardcardBrot);
    6035           1 :  interfacecardBmother->AddNode(interfacecardB,1,interfacecardBcombitrans);
    6036           1 :  interfacecardBmother->AddNode(electboardcardB,1,electboardcardBcombitrans);
    6037           1 :  TGeoRotation* jmdconnectorcardBrot = new TGeoRotation();
    6038           1 :  jmdconnectorcardBrot->SetAngles(90.,180.,-90.);
    6039           1 :  TGeoTranslation* jmdconnectorcardBtrans[3];
    6040           1 :  TGeoCombiTrans* jmdconnectorcardBcombitrans[3];
    6041           8 :  for(Int_t i=0; i<3; i++){
    6042           9 :    jmdconnectorcardBtrans[i] = new TGeoTranslation(fgkEndCapInterfaceCardBThickness
    6043           3 :                                                          + fgkEndCapCardJMDConnectorLength[0], 
    6044           3 :                                                            fgkEndCapCardElectBoardLayerWidth[1],
    6045           3 :                                                            0.5*fgkEndCapCardJMDConnectorThickness
    6046           6 :                                                          + 0.5*(fgkEndCapInterfaceCardBLength[1]
    6047           3 :                                                          - 2.*fgkEndCapInterfaceCardBJMDConnectorSeparation)
    6048           3 :                                                          + i *fgkEndCapInterfaceCardBJMDConnectorSeparation);    
    6049           6 :    jmdconnectorcardBcombitrans[i] = new TGeoCombiTrans(*jmdconnectorcardBtrans[i],
    6050             :                                                                                                            *jmdconnectorcardBrot);
    6051           3 :    interfacecardBmother->AddNode(jmdconnector,i+1,jmdconnectorcardBcombitrans[i]);
    6052             :  }
    6053             :  // Mother Supply Card Container 
    6054           1 :  TGeoVolumeAssembly* mothersupplycard = new TGeoVolumeAssembly("EndCapCardMotherSupply");
    6055             :  // Interface Card Container
    6056           1 :  TGeoVolumeAssembly* motherinterfacecardcontainer = new TGeoVolumeAssembly("EndCapMotherInterfaceCardA");
    6057             :  // Placing Volumes in Mother Supply Card Container
    6058             :  // JMD Connector Positioning
    6059           1 :  TGeoTranslation* jmdconnectortrans[2];
    6060           8 :  for(Int_t i=0; i<2; i++) jmdconnectortrans[i] = new TGeoTranslation();
    6061           2 :  jmdconnectortrans[0]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[1],
    6062           1 :                                                                                         fgkEndCapCardElectBoardBackLength[0]
    6063           1 :                                           -                                             fgkEndCapCardJMDConnectorThickness
    6064           1 :                                           -                                             fgkEndCapCardJMDConnectorToLayer);
    6065           1 :  TGeoRotation* jmdconnectorot = new TGeoRotation();
    6066           2 :  jmdconnectortrans[1]->SetTranslation(fgkEndCapCardElectBoardBackThickness
    6067           1 :                                                                  + 2.*fgkEndCapCardJMDConnectorLength[0]
    6068           1 :                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness,
    6069           1 :                                                                           fgkEndCapCardElectBoardLayerWidth[1],
    6070           1 :                                                                       fgkEndCapCardJMDConnectorThickness
    6071           1 :                                                                  +    fgkEndCapCardJMDConnectorToLayer);
    6072           1 :  jmdconnectorot->SetAngles(90.,180.,-90);
    6073           1 :  TGeoCombiTrans* jmdconnectorcombitrans = new TGeoCombiTrans(*jmdconnectortrans[1],
    6074             :                                                                                 * jmdconnectorot);
    6075           1 :  mothersupplycard->AddNode(jmdconnector,1,jmdconnectortrans[0]);
    6076           1 :  mothersupplycard->AddNode(jmdconnector,2,jmdconnectorcombitrans);
    6077             :  // Top Cable Connector Placing
    6078           1 :  TGeoRotation* cableconnectorot[2];
    6079           8 :  for(Int_t i=0; i<2; i++) cableconnectorot[i] = new TGeoRotation();
    6080           1 :  TGeoTranslation* cableconnectortrans[3];
    6081          11 :  for(Int_t i=0; i<3; i++) cableconnectortrans[i] = new TGeoTranslation();
    6082           1 :  cableconnectorot[0]->SetAngles(90.,0.,0.); 
    6083           1 :  cableconnectorot[1]->SetAngles(0.,-90.,0.); 
    6084           1 :  cableconnectortrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0],0.,0.);
    6085           2 :  TGeoCombiTrans* cableconnectorcombitrans = new TGeoCombiTrans(*cableconnectortrans[0],
    6086           1 :                                                                                                                            *cableconnectorot[0]);
    6087           1 :  TGeoHMatrix* cableconnectormatrix[2];
    6088           6 :  for(Int_t i=0; i<2; i++) cableconnectormatrix[i] =
    6089           4 :                                                         new TGeoHMatrix((*cableconnectorot[1])
    6090           2 :                                                                                    *(*cableconnectorcombitrans));
    6091           2 :  cableconnectortrans[1]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
    6092           1 :                                            -                               fgkEndCapCardCableConnectorThickness,
    6093           1 :                                                                                 fgkEndCapCardCableConnectorLength[0]
    6094           1 :                                            +                            fgkEndCapCardCableConnectorToLayer);
    6095           2 :  cableconnectortrans[2]->SetTranslation(0.,fgkEndCapCardElectBoardLayerWidth[0]
    6096           1 :                                            -                2.*fgkEndCapCardCableConnectorThickness
    6097           1 :                                            -                            fgkEndCapCardCableConnectorDistance,
    6098           1 :                                                                                 fgkEndCapCardCableConnectorLength[0]
    6099           1 :                                            +                            fgkEndCapCardCableConnectorToLayer);
    6100           6 :  for(Int_t i=0; i<2; i++){
    6101           2 :         cableconnectormatrix[i]->MultiplyLeft(cableconnectortrans[i+1]);
    6102           2 :     mothersupplycard->AddNode(cableconnector,i+1,cableconnectormatrix[i]);
    6103             :  }
    6104           1 :  TGeoRotation* electboardbackrot = new TGeoRotation(); 
    6105           1 :  TGeoTranslation* electboardbacktrans = new TGeoTranslation();
    6106           1 :  electboardbackrot->SetAngles(90.,-90.,-90.);
    6107           2 :  electboardbacktrans->SetTranslation(fgkEndCapCardElectBoardBackThickness
    6108           1 :                                                         +                fgkEndCapCardJMDConnectorLength[0]
    6109           1 :                                                         +                fgkEndCapCardElectBoardLayerThickness,0.,0.);
    6110           1 :  TGeoCombiTrans* electboardbackcombitrans = new TGeoCombiTrans(*electboardbacktrans,
    6111             :                                                                                                                            *electboardbackrot);
    6112           1 :  mothersupplycard->AddNode(electboardback,1,electboardbackcombitrans);
    6113             :  // Electronic Board Kapton Layer Positioning
    6114           1 :  TGeoRotation* electlayerrot = new TGeoRotation();
    6115           1 :  TGeoTranslation* electlayertrans[2];
    6116           1 :  TGeoCombiTrans* electlayercombitrans[2];
    6117           8 :  for(Int_t i=0; i<2; i++) electlayertrans[i] = new TGeoTranslation();
    6118           1 :  electlayerrot->SetAngles(90.,-90.,-90.);
    6119           2 :  electlayertrans[0]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
    6120           1 :                                                                  + fgkEndCapCardElectBoardLayerThickness,0.,0.);
    6121           2 :  electlayertrans[1]->SetTranslation(fgkEndCapCardJMDConnectorLength[0]
    6122           1 :                                                                  + 2.*fgkEndCapCardElectBoardLayerThickness
    6123           1 :                                                                  + fgkEndCapCardElectBoardBackThickness,0.,0.);
    6124           6 :  for(Int_t i=0; i<2; i++){
    6125           4 :         electlayercombitrans[i] = new TGeoCombiTrans(*electlayertrans[i],*electlayerrot);
    6126           2 :         mothersupplycard->AddNode(electlayer,i+1,electlayercombitrans[i]);
    6127             :  }
    6128             :  // Placing Volumes in Mother Interface Card Container
    6129           1 :  motherinterfacecardcontainer->AddNode(jmdconnector,1,jmdconnectorcombitrans);
    6130           1 :  motherinterfacecardcontainer->AddNode(electboardback,1,electboardbackcombitrans);
    6131           6 :  for(Int_t i=0; i<2; i++){
    6132           2 :         motherinterfacecardcontainer->AddNode(electlayer,i+1,electlayercombitrans[i]);
    6133             :  }
    6134             :  /////////////////////////////////////////////////////////////
    6135             :  // Generation of Card Interface Container
    6136             :  /////////////////////////////////////////////////////////////
    6137           1 :  Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
    6138           1 :                                                   - fgkEndCapCardJMDConnectorLength[0]
    6139           1 :                                                   - fgkEndCapInterfaceCardBThickness
    6140           1 :                                                   - 9.*fgkEndCapStripConnectionThickness
    6141           1 :                                                   - 8.*fgkEndCapCardElectBoardBackThickness;
    6142             :  const Int_t kcardinterfacecontainervertexnumber = 14;
    6143           1 :  Double_t xcardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
    6144           1 :  Double_t ycardinterfacecontainervertex[kcardinterfacecontainervertexnumber];
    6145           2 :  xcardinterfacecontainervertex[0]  =-6.5*fgkEndCapCardElectBoardBackThickness
    6146           1 :                                                                    - 7.0*fgkEndCapStripConnectionThickness;
    6147           1 :  xcardinterfacecontainervertex[1]  = xcardinterfacecontainervertex[0];
    6148           1 :  xcardinterfacecontainervertex[2]  = xcardinterfacecontainervertex[1]
    6149           1 :                                                                    + fgkEndCapStripConnectionThickness
    6150           1 :                                                                    - fgkEndCapCardElectBoardLayerThickness
    6151           1 :                                                                    - fgkEndCapCardCableConnectorWidth[0];
    6152           1 :  xcardinterfacecontainervertex[3]  = xcardinterfacecontainervertex[2];
    6153           1 :  xcardinterfacecontainervertex[4]  = xcardinterfacecontainervertex[1];
    6154           1 :  xcardinterfacecontainervertex[5]  = xcardinterfacecontainervertex[4];
    6155           2 :  xcardinterfacecontainervertex[6]  = 1.5*fgkEndCapCardElectBoardBackThickness
    6156           1 :                                                                    + 2.0*fgkEndCapStripConnectionThickness;
    6157           1 :  xcardinterfacecontainervertex[7]  = xcardinterfacecontainervertex[6];
    6158           1 :  xcardinterfacecontainervertex[8]  = xcardinterfacecontainervertex[7]
    6159           1 :                                                                    + fgkEndCapInterfaceCardBThickness;
    6160           1 :  xcardinterfacecontainervertex[9]  = xcardinterfacecontainervertex[8];
    6161           1 :  xcardinterfacecontainervertex[10] = xcardinterfacecontainervertex[9]
    6162           1 :                                                                    + fgkEndCapInterfaceElectBoardCardBThickness;
    6163           1 :  xcardinterfacecontainervertex[11] = xcardinterfacecontainervertex[10];
    6164           1 :  xcardinterfacecontainervertex[12] = xcardinterfacecontainervertex[11]
    6165           1 :                                    - fgkEndCapInterfaceElectBoardCardBThickness
    6166           1 :                                                                    + fgkEndCapCardJMDConnectorLength[0]
    6167           1 :                                                                    + stiffenertransx+fgkEndCapStiffenerWidth;
    6168           1 :  xcardinterfacecontainervertex[13] = xcardinterfacecontainervertex[12];                                                            
    6169             : 
    6170           1 :  ycardinterfacecontainervertex[0]  = 0.;
    6171           2 :  ycardinterfacecontainervertex[1]  = fgkEndCapCardElectBoardLayerWidth[1]
    6172           1 :                                                                    + fgkEndCapCardJMDConnectorWidth[0]
    6173           1 :                                                                    + fgkEndCapCardJMDConnectorWidth[1];
    6174           1 :  ycardinterfacecontainervertex[2]  = ycardinterfacecontainervertex[1];
    6175           2 :  ycardinterfacecontainervertex[3]  = fgkEndCapCardElectBoardBackWidth[0]
    6176           1 :                                                                    - fgkEndCapStripConnectionWidth;
    6177           1 :  ycardinterfacecontainervertex[4]  = ycardinterfacecontainervertex[3];
    6178           1 :  ycardinterfacecontainervertex[5]  = fgkEndCapCardElectBoardBackWidth[0];
    6179           1 :  ycardinterfacecontainervertex[6]  = ycardinterfacecontainervertex[5];
    6180           2 :  ycardinterfacecontainervertex[7]  = fgkEndCapInterfaceCardBWidth[0]
    6181           1 :                                                                    + fgkEndCapInterfaceCardBWidth[1]
    6182           1 :                                                                    + fgkEndCapInterfaceCardBWidth[2];
    6183           1 :  ycardinterfacecontainervertex[8]  = ycardinterfacecontainervertex[7];
    6184           1 :  ycardinterfacecontainervertex[9]  = yelectboardcardBvertex[3];
    6185           1 :  ycardinterfacecontainervertex[10] = ycardinterfacecontainervertex[9];
    6186           1 :  ycardinterfacecontainervertex[11] = ycardinterfacecontainervertex[1];
    6187           1 :  ycardinterfacecontainervertex[12] = ycardinterfacecontainervertex[11];
    6188           1 :  ycardinterfacecontainervertex[13] = ycardinterfacecontainervertex[0];
    6189             :  
    6190           1 :  TGeoXtru* interfacecardmothershape = new TGeoXtru(2);
    6191           1 :  interfacecardmothershape->DefinePolygon(kcardinterfacecontainervertexnumber,
    6192           1 :                                                                                   xcardinterfacecontainervertex,
    6193           1 :                                                                                   ycardinterfacecontainervertex);
    6194           2 :  interfacecardmothershape->DefineSection(0,-1.e-15-0.5*(fgkEndCapStiffenerLength
    6195           1 :                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
    6196           2 :  interfacecardmothershape->DefineSection(1,0.5*(fgkEndCapStiffenerLength
    6197           1 :                                                                            +    fgkEndCapCardElectBoardBackLength[0]));
    6198             :  TGeoVolume** cardinterfacecontainer;
    6199           1 :  cardinterfacecontainer = new TGeoVolume*[4];
    6200           3 :  cardinterfacecontainer[0] = new TGeoVolume("EndCapCardsContainerLayer5Sx",
    6201           1 :                                                                                         interfacecardmothershape,fSSDAir); 
    6202           3 :  cardinterfacecontainer[1] = new TGeoVolume("EndCapCardsContainerLayer5Dx",
    6203           1 :                                                                                         interfacecardmothershape,fSSDAir); 
    6204           3 :  cardinterfacecontainer[2] = new TGeoVolume("EndCapCardsContainerLayer6Sx",
    6205           1 :                                                                                         interfacecardmothershape,fSSDAir); 
    6206           3 :  cardinterfacecontainer[3] = new TGeoVolume("EndCapCardsContainerLayer6Dx",
    6207           1 :                                                                                         interfacecardmothershape,fSSDAir); 
    6208             :  /////////////////////////////////
    6209             :  // cardinterfacecontainer[0]: Card Container End Cap Layer 5 Bellegarde Side
    6210             :  // cardinterfacecontainer[1]: Card Container End Cap Layer 5 Gex Side
    6211             :  // cardinterfacecontainer[2]: Card Container End Cap Layer 6 Bellegarde Side
    6212             :  // cardinterfacecontainer[3]: Card Container End Cap Layer 6 Gex Side
    6213             :  /////////////////////////////////
    6214           1 :  TGeoRotation* endcapstripconnectionrot[2];
    6215           8 :  for(Int_t i=0; i<2; i++) endcapstripconnectionrot[i] = new TGeoRotation();
    6216           1 :  endcapstripconnectionrot[0]->SetAngles(0.,90.,0.);
    6217           1 :  endcapstripconnectionrot[1]->SetAngles(90.,90.,-90.);
    6218           2 :  TGeoHMatrix* endcapstripconnectionmatrix = new TGeoHMatrix((*endcapstripconnectionrot[1])
    6219           1 :                                                                         *                                 (*endcapstripconnectionrot[0]));
    6220           1 :  TGeoTranslation* endcapstripconnectiontrans = new TGeoTranslation();
    6221           2 :  endcapstripconnectiontrans->SetTranslation(-endcapstripconnectionshape->GetDY()
    6222           1 :                                                                                         -0.5*fgkEndCapCardElectBoardBackThickness,
    6223           1 :                                                                                          fgkEndCapCardElectBoardBackWidth[0]
    6224           1 :                                                                                         -endcapstripconnectionshape->GetDZ(),
    6225           1 :                                                                                          0.5*fgkEndCapCardElectBoardBackLength[0]);
    6226           1 :  endcapstripconnectionmatrix->MultiplyLeft(endcapstripconnectiontrans);
    6227           1 :  TGeoTranslation* cardinterfacetrans[9];
    6228           1 :  TGeoHMatrix* cardinterfacematrix[9]; 
    6229          16 :  for(Int_t i=0; i<7; i++){ 
    6230          21 :         cardinterfacetrans[i] = new TGeoTranslation(-i*(fgkEndCapStripConnectionThickness
    6231           7 :                                                   +                                                     fgkEndCapCardElectBoardBackThickness),
    6232             :                                                                                                 0.0,0.0);  
    6233          21 :         cardinterfacematrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
    6234           7 :                                                    *                             (*endcapstripconnectionmatrix));
    6235             :  }
    6236           3 :  cardinterfacetrans[7] = new TGeoTranslation((fgkEndCapStripConnectionThickness
    6237           1 :                                                   +                                             fgkEndCapCardElectBoardBackThickness),
    6238             :                                                                                                 0.0,0.0);  
    6239           3 :  cardinterfacematrix[7] = new TGeoHMatrix((*cardinterfacetrans[7])
    6240           1 :                                                 *                                 (*endcapstripconnectionmatrix));
    6241           3 :  cardinterfacetrans[8] = new TGeoTranslation(2.*(fgkEndCapStripConnectionThickness
    6242           1 :                                                   +                                             fgkEndCapCardElectBoardBackThickness),
    6243             :                                                                                                 0.0,0.0);  
    6244           3 :  cardinterfacematrix[8] = new TGeoHMatrix((*cardinterfacetrans[8])
    6245           1 :                                                 *                                 (*endcapstripconnectionmatrix));
    6246             : 
    6247          10 :  for(Int_t i=0; i<4; i++){
    6248           8 :         cardinterfacecontainer[i]->AddNode(endcapstripconnection,1,
    6249           4 :                                                                            cardinterfacematrix[7]);                             
    6250           8 :         cardinterfacecontainer[i]->AddNode(endcapstripconnection,2,
    6251           4 :                                                                            cardinterfacematrix[8]);                             
    6252             :  }
    6253             :  TGeoTranslation* mothersupplycardtrans = 
    6254           2 :                                         new TGeoTranslation(-0.5*(fgkEndCapCardElectBoardBackThickness
    6255           1 :                                                                                 + 2.*fgkEndCapCardJMDConnectorLength[0]
    6256           1 :                                                                                 + 2.*fgkEndCapCardElectBoardLayerThickness),0.0,0.0);
    6257           1 :  TGeoHMatrix* mothersupplycardmatrix[7];
    6258           1 :  Int_t index[4] = {1,1,1,1};
    6259          16 :  for(Int_t i=0; i<7; i++){
    6260          21 :         mothersupplycardmatrix[i] = new TGeoHMatrix((*cardinterfacetrans[i])
    6261           7 :                                                         *                                 (*mothersupplycardtrans));
    6262          70 :         for(Int_t j=0; j<4; j++){
    6263          56 :                 switch(j){
    6264             :                         case 0: //Layer5 EndCap Left Side  
    6265          14 :                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
    6266           7 :                                                                                                    cardinterfacematrix[i]);                             
    6267           7 :                                 if(i!=0){
    6268          12 :                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
    6269           6 :                                                                                                            mothersupplycardmatrix[i]);                  
    6270           6 :                                         index[j]++;
    6271             : 
    6272           6 :                                 }
    6273             :                         break;
    6274             :                         case 1: //Layer5 EndCap Rigth Side  
    6275          14 :                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
    6276           7 :                                                                                                    cardinterfacematrix[i]);                     
    6277           7 :                                 if(i>0&&i<6){
    6278          10 :                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
    6279           5 :                                                                                                            mothersupplycardmatrix[i]);                  
    6280           5 :                                         index[j]++;
    6281           5 :                                 }
    6282             :                         break;
    6283             :                         case 2: //Layer6 EndCap Left Side  
    6284          14 :                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
    6285           7 :                                                                                                    cardinterfacematrix[i]);                             
    6286           7 :                                 if(i!=6){
    6287          12 :                                         cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
    6288           6 :                                                                                                            mothersupplycardmatrix[i]);                  
    6289           6 :                                         index[j]++;
    6290           6 :                                 }
    6291             :                         break;
    6292             :                         case 3: //Layer6 EndCap Right Side  
    6293          14 :                                 cardinterfacecontainer[j]->AddNode(endcapstripconnection,i+3,
    6294           7 :                                                                                                    cardinterfacematrix[i]);                             
    6295          14 :                                 cardinterfacecontainer[j]->AddNode(mothersupplycard,index[j],
    6296           7 :                                                                                                    mothersupplycardmatrix[i]);                  
    6297           7 :                                 index[j]++;
    6298           7 :                         break;
    6299             :                 }
    6300             :         }
    6301             :  }
    6302             :  // Positioning Interface 
    6303             :  TGeoTranslation* motherinterfacecardtrans = 
    6304           2 :                 new TGeoTranslation( -fgkEndCapCardJMDConnectorLength[0]
    6305           1 :                                                          +0.5*fgkEndCapCardElectBoardBackThickness
    6306           1 :                                                          -fgkEndCapCardElectBoardLayerThickness
    6307           1 :                                                          +fgkEndCapStripConnectionThickness,0.,0.);
    6308          14 :  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(
    6309           4 :                                         motherinterfacecardcontainer,i+1,motherinterfacecardtrans);
    6310             :  // Positioning Interface Card B 
    6311             :  TGeoTranslation* interfacecardBmothertrans = 
    6312           2 :                                         new TGeoTranslation(0.5 * fgkEndCapCardElectBoardBackThickness
    6313           1 :                                                                                 + 2.*fgkEndCapStripConnectionThickness
    6314           1 :                                                                                         + fgkEndCapCardElectBoardBackThickness,0.,
    6315           2 :                                                                            -0.5 * (fgkEndCapInterfaceCardBLength[1]
    6316           1 :                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));                              
    6317          14 :  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(interfacecardBmother,1,
    6318           4 :                                                                                                                          interfacecardBmothertrans);
    6319             :  // Positioning Stiffener 
    6320             :  TGeoTranslation* endcapstiffenertrans = 
    6321           2 :                                                 new TGeoTranslation(1.5*fgkEndCapCardElectBoardBackThickness
    6322           1 :                                                                            +    2.0*fgkEndCapStripConnectionThickness
    6323           1 :                                                                            +    fgkEndCapInterfaceCardBThickness
    6324           1 :                                                                            +    fgkEndCapCardJMDConnectorLength[0]
    6325           1 :                                                                            +    stiffenertransx
    6326           2 :                                                                            +    endcapstiffenershape->GetDX(),endcapstiffenershape->GetDY(),
    6327           1 :                                                                                         endcapstiffenershape->GetDZ()
    6328           2 :                                                                            -    0.5*(fgkEndCapStiffenerLength
    6329           1 :                                                                            -    fgkEndCapCardElectBoardBackLength[0]));
    6330          10 :  for(Int_t i=0; i<4; i++) cardinterfacecontainer[i]->AddNode(endcapstiffener,1,endcapstiffenertrans);  
    6331             :  /////////////////////////////////////////////////////////////
    6332             :  // Deallocating memory
    6333             :  /////////////////////////////////////////////////////////////
    6334           2 :  delete interfacecardBrot;
    6335           2 :  delete interfacecardBtrans;
    6336           2 :  delete electboardcardBtrans;
    6337           2 :  delete electboardcardBrot; 
    6338           2 :  delete jmdconnectorcardBrot;
    6339          14 :  for(Int_t i=0; i<3; i++) delete jmdconnectorcardBtrans[i];
    6340           2 :  delete jmdconnectorot;
    6341           2 :  delete jmdconnectortrans[1];
    6342          10 :  for(Int_t i=0; i<2; i++) delete cableconnectorot[i];
    6343           2 :  delete cableconnectorcombitrans;
    6344           2 :  delete electboardbacktrans;
    6345           2 :  delete electboardbackrot;
    6346           2 :  delete electlayerrot;
    6347          10 :  for(Int_t i=0; i<2; i++) delete electlayertrans[i];
    6348          10 :  for(Int_t i=0; i<2; i++) delete endcapstripconnectionrot[i];
    6349           2 :  delete mothersupplycardtrans;
    6350          30 :  for(Int_t i=0; i<7; i++) delete cardinterfacetrans[i];
    6351             :  /////////////////////////////////////////////////////////////
    6352             : 
    6353           1 :  mothersupplycard->GetShape()->ComputeBBox(); //RS: enforce recompting of BBox
    6354           1 :  motherinterfacecardcontainer->GetShape()->ComputeBBox();
    6355             : 
    6356           1 :  return cardinterfacecontainer;
    6357           1 :  }
    6358             :  ////////////////////////////////////////////////////////////////////////////////
    6359             :  TGeoVolume** AliITSv11GeometrySSD::GetEndCapAssembly(){ 
    6360             :   /////////////////////////////////////////////////////////////
    6361             :   // Method returning EndCap Mother Volume
    6362             :   /////////////////////////////////////////////////////////////
    6363             :   const Int_t kendcapcoverplatesmallholenumber = 9;
    6364           2 :   Double_t endcapmotherorigin[3];
    6365           2 :   endcapmotherorigin[0] = -fgkEndCapCoverPlateLength[0]
    6366           2 :                                                 +  0.5 *(fgkEndCapCoverPlateLength[3]
    6367           1 :                                             +  2.0 * fgkEndCapCoverPlateLength[2]);
    6368           3 :   endcapmotherorigin[1] = - 0.5 * (fgkEndCapCoverPlateWidth[0]
    6369           1 :                                           -                      fgkEndCapCoverPlateWidth[2]
    6370           1 :                                           -       (kendcapcoverplatesmallholenumber-1)
    6371           1 :                                           *        fgkEndCapCoverPlateSmallHoleSeparation[2])
    6372           2 :                                           +  0.5*(fgkEndCapSideCoverLength[2]
    6373           1 :                                           +               fgkEndCapCoverPlateWidth[1]
    6374           1 :                                           -       fgkEndCapCoverPlateWidth[0])
    6375           1 :                                           -      (fgkEndCapCoverPlateWidth[1]
    6376           1 :                                           -       fgkEndCapCoverPlateWidth[0]);
    6377           2 :   endcapmotherorigin[2] = 0.5*fgkEndCapCoverPlateThickness
    6378           1 :                                                 + 2.*fgkEndCapCoolingTubeRadiusMax
    6379           1 :                                                 - 0.5*(2.*fgkEndCapCoolingTubeRadiusMax
    6380           1 :                                                 +      fgkEndCapSideCoverWidth[1]
    6381           1 :                                                 +      fgkEndCapSideCoverThickness
    6382           1 :                                                 +      fgkEndCapKaptonFoilThickness);
    6383           3 :   TGeoBBox* endcapmothershape = new TGeoBBox(0.5*(fgkEndCapCoverPlateLength[3]
    6384           1 :                                                           +                              2.0* fgkEndCapCoverPlateLength[2]
    6385           1 :                                                           +              2.0* fgkEndCapSideCoverThickness),
    6386           2 :                                                                          0.5* (fgkEndCapSideCoverLength[2]
    6387           1 :                                                           +                    fgkEndCapCoverPlateWidth[1]
    6388           1 :                                                           -                                        fgkEndCapCoverPlateWidth[0]),
    6389           2 :                                                                                          0.5* (2.*fgkEndCapCoolingTubeRadiusMax
    6390           1 :                                                       +                                    fgkEndCapSideCoverWidth[1]
    6391           1 :                                                           +                                       fgkEndCapSideCoverThickness
    6392           1 :                                                       +                                   fgkEndCapKaptonFoilThickness),
    6393           1 :                                                                                          endcapmotherorigin);
    6394             :   TGeoVolume** endcapassembly;  
    6395           1 :   endcapassembly = new TGeoVolume*[4];
    6396           3 :   endcapassembly[0] = new TGeoVolume("EndCapContainerLayer5Sx",
    6397           1 :                                                                                         endcapmothershape,fSSDAir); 
    6398           3 :   endcapassembly[1] = new TGeoVolume("EndCapContainerLayer5Dx",
    6399           1 :                                                                                         endcapmothershape,fSSDAir); 
    6400           3 :   endcapassembly[2] = new TGeoVolume("EndCapContainerLayer6Sx",
    6401           1 :                                                                                         endcapmothershape,fSSDAir); 
    6402           3 :   endcapassembly[3] = new TGeoVolume("EndCapContainerLayer6Dx",
    6403           1 :                                                                                         endcapmothershape,fSSDAir); 
    6404             :  /////////////////////////////////
    6405             :  // endcapassembly[0]:  Container End Cap Layer 5 Bellegarde Side
    6406             :  // endcapassembly[1]:  Container End Cap Layer 5 Gex Side
    6407             :  // endcapassembly[2]:  Container End Cap Layer 6 Bellegarde Side
    6408             :  // endcapassembly[3]:  Container End Cap Layer 6 Gex Side
    6409             :  /////////////////////////////////
    6410             :   /////////////////////////////////////////////////////
    6411             :   // Placing Endcap Cover Plate
    6412             :   /////////////////////////////////////////////////////
    6413           1 :   TGeoVolume* endcapcoverplate = GetEndCapCoverPlate();
    6414           1 :   TGeoRotation* endcapcoverplaterot = new TGeoRotation();
    6415           1 :   endcapcoverplaterot->SetAngles(90.0,180.0,-90.0);
    6416             :   TGeoCombiTrans* endcapcoverplatecombitrans = 
    6417           1 :                                                   new TGeoCombiTrans(-0.5*fgkEndCapCoverPlateLength[1],0.,0.,
    6418             :                                                                                          endcapcoverplaterot);
    6419             :   TGeoTranslation* endcapcoverplatetrans = 
    6420           1 :                                                   new TGeoTranslation(1.5*fgkEndCapCoverPlateLength[1],0.,0.);
    6421             :   TGeoHMatrix* endcapcoverplatematrix = 
    6422           2 :                                                   new TGeoHMatrix((*endcapcoverplatetrans)
    6423           1 :                                                                           *       (*endcapcoverplatecombitrans));
    6424          10 :   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoverplate,1,endcapcoverplatematrix);
    6425             :   /////////////////////////////////////////////////////
    6426             :   // Placing Endcap Side Cover
    6427             :   /////////////////////////////////////////////////////
    6428           1 :   TGeoVolume* endcapsidecover = GetEndCapSideCover();
    6429           1 :   TGeoRotation* endcapsidecoverot[2];
    6430           1 :   TGeoCombiTrans* endcapsidecovercombitrans[3];
    6431           8 :   for(Int_t i=0; i<2; i++) endcapsidecoverot[i] = new TGeoRotation();
    6432           1 :   endcapsidecoverot[0]->SetAngles(-90.,0.,0.);
    6433           3 :   endcapsidecovercombitrans[0] = new TGeoCombiTrans(0.0,
    6434           2 :                                                                                         - 0.5*(fgkEndCapCoverPlateWidth[0]
    6435           1 :                                                                                         - fgkEndCapCoverPlateWidth[2]
    6436           1 :                                                                                     - (kendcapcoverplatesmallholenumber-1)
    6437           1 :                                                                                         * fgkEndCapCoverPlateSmallHoleSeparation[2])
    6438           1 :                                                                                         + 0.*fgkEndCapCoverPlateWidth[0]
    6439           1 :                                                                                         + fgkEndCapSideCoverLength[2],
    6440           2 :                                                                                           0.5*(fgkEndCapSideCoverThickness
    6441           1 :                                                                                         + fgkEndCapCoverPlateThickness)
    6442           1 :                                                                                         - 0.5*fgkEndCapCoverPlateThickness,
    6443           1 :                                                                                           endcapsidecoverot[0]);
    6444           1 :   endcapsidecoverot[1]->SetAngles(90.,-90.,-90.); 
    6445           3 :   endcapsidecovercombitrans[1] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0],0.0,
    6446           1 :                                                                                                         0.5*fgkEndCapCoverPlateThickness
    6447           1 :                                                                                                         -fgkEndCapSideCoverWidth[1],
    6448           1 :                                                                                                         endcapsidecoverot[1]);
    6449           3 :   endcapsidecovercombitrans[2] = new TGeoCombiTrans(-fgkEndCapCoverPlateLength[0]
    6450           1 :                                                                                                         +fgkEndCapCoverPlateLength[3]
    6451           1 :                                                                                                         +2.*fgkEndCapCoverPlateLength[2]
    6452           1 :                                                                                                         +fgkEndCapSideCoverThickness,0.0,
    6453           1 :                                                                                                         0.5*fgkEndCapCoverPlateThickness
    6454           1 :                                                                                                         -fgkEndCapSideCoverWidth[1],
    6455           1 :                                                                                                         endcapsidecoverot[1]);
    6456           1 :   TGeoHMatrix* endcapsidecovermatrix[2];
    6457           6 :   for(Int_t i=0; i<2; i++){
    6458           6 :    endcapsidecovermatrix[i] = new TGeoHMatrix((*endcapsidecovercombitrans[i+1])
    6459           2 :                                                         *                                 (*endcapsidecovercombitrans[0]));
    6460          28 :         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapsidecover,i+1,
    6461           8 :                                                                                                                 endcapsidecovermatrix[i]);
    6462             :   }
    6463             :   /////////////////////////////////////////////////////
    6464             :   // Placing Endcap Cooling Tube
    6465             :   /////////////////////////////////////////////////////
    6466           1 :   TGeoVolume* endcapcoolingtube = GetEndCapCoolingTube();
    6467           1 :   TGeoRotation* endcapcoolingtuberot = new TGeoRotation();
    6468           1 :   endcapcoolingtuberot->SetAngles(0.,180.,0.); 
    6469             :   TGeoCombiTrans* endcapccolingtubecombitrans 
    6470           3 :                                                 = new TGeoCombiTrans(-0.5*(fgkEndCapCoolingTubeAxialRadius[0]
    6471           1 :                                                 + fgkEndCapCoolingTubeAxialRadius[1])
    6472           1 :                                                 + fgkEndCapCoverPlateLength[0]+fgkEndCapCoverPlateLength[1]
    6473           1 :                                                 - fgkEndCapCoolingTubeToCoverSide,
    6474           1 :                                                   fgkEndCapCoolingTubeAxialRadius[0],fgkEndCapCoolingTubeRadiusMax
    6475           1 :                                                 + 0.5*fgkEndCapCoverPlateThickness,endcapcoolingtuberot);
    6476          14 :   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcoolingtube,1,
    6477           4 :                                                                                                           endcapccolingtubecombitrans);
    6478             :   /////////////////////////////////////////////////////
    6479             :   // Placing Screws 
    6480             :   /////////////////////////////////////////////////////
    6481           2 :   Double_t screwcoverplateradius[2] = {fgkEndCapCoverPlateScrewRadiusMax,
    6482           1 :                                                                            fgkEndCapCoverPlateScrewRadiusMin};
    6483           1 :   Int_t screwcoverplatedgesnumber[2] = {20,20};
    6484           2 :   Double_t screwcoverplatesection[2] = {0.5*fgkEndCapCoverPlateThickness,
    6485           1 :                                                                                 fgkEndCapCoverPlateThickness
    6486           1 :                                                                          +  fgkEndCapCoolingTubeRadiusMax};
    6487           2 :   TGeoShape* screwcoverplateshape = GetScrewShape(screwcoverplateradius,
    6488           1 :                                                                                                  screwcoverplatedgesnumber,
    6489           1 :                                                                                                  screwcoverplatesection);
    6490           2 :   TGeoVolume* screwcoverplate = new TGeoVolume("EndCapScrewCoverPlate",
    6491             :                                                                                            screwcoverplateshape,
    6492           1 :                                                                                            fSSDCoolingTubePhynox); 
    6493           1 :   screwcoverplate->SetLineColor(12);
    6494           4 :   Double_t transx[4] = {0,
    6495           1 :                                                 fgkEndCapCoverPlateSmallHoleSeparation[0],
    6496           1 :                                                 fgkEndCapCoverPlateSmallHoleSeparation[0]
    6497           1 :                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1],
    6498           1 :                                          2.*fgkEndCapCoverPlateSmallHoleSeparation[0]
    6499           1 :                                          +  fgkEndCapCoverPlateSmallHoleSeparation[1]};
    6500             :   const Int_t kendcapcoverplatescrewnumber[2] = {4,9}; 
    6501             : //  TGeoTranslation** endcapcoverplatescrewtrans[kendcapcoverplatescrewnumber[0]]; 
    6502             :   TGeoTranslation*** endcapcoverplatescrewtrans;
    6503           1 :   endcapcoverplatescrewtrans = new TGeoTranslation**[kendcapcoverplatescrewnumber[0]]; 
    6504             :   Int_t index = 0;
    6505          10 :   for(Int_t i=0; i<kendcapcoverplatescrewnumber[0]; i++){
    6506           4 :         endcapcoverplatescrewtrans[i] = 
    6507           4 :                                         new TGeoTranslation*[kendcapcoverplatescrewnumber[1]];
    6508          80 :     for(Int_t j=0; j<kendcapcoverplatescrewnumber[1]; j++){
    6509          36 :                 index = kendcapcoverplatescrewnumber[1]*i+j+1;
    6510          72 :         if(index==1||index==9||index==28||index==36){
    6511           4 :                         endcapcoverplatescrewtrans[i][j] = 
    6512          40 :                                 new TGeoTranslation(transx[i],
    6513          36 :                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
    6514           4 :                                                                         fgkEndCapSideCoverThickness);
    6515           4 :                 }
    6516             :                 else{
    6517          32 :                         endcapcoverplatescrewtrans[i][j] = 
    6518          32 :                                 new TGeoTranslation(transx[i],
    6519             :                                                                         j*fgkEndCapCoverPlateSmallHoleSeparation[2],
    6520             :                                                                         0.);
    6521             :                 }
    6522          36 :             if(index!=19) 
    6523         490 :                 for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(screwcoverplate,index,
    6524         175 :                                                                                           endcapcoverplatescrewtrans[i][j]);
    6525             :         }
    6526             :   }
    6527             :   /////////////////////////////////////////////////////
    6528             :   // Placing Cover Plate Clips 
    6529             :   /////////////////////////////////////////////////////
    6530           2 :   TGeoBBox* endcapcoverplateclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateClipLength,
    6531           1 :                                                                                                          0.5*fgkEndCapCoverPlateClipWidth,
    6532           1 :                                                                                                          0.5*fgkEndCapSideCoverThickness);
    6533           2 :   TGeoVolume* endcapcoverplateclip = new TGeoVolume("EndCapCoverPlateUpClip",
    6534           1 :                                                                                                         endcapcoverplateclipshape,
    6535           1 :                                                                                                         fSSDCoolingTubePhynox);
    6536           2 :   TGeoBBox* endcapcoverplatedownclipshape = new TGeoBBox(0.5*fgkEndCapCoverPlateDownClipLength,
    6537           1 :                                                                                                          0.5*fgkEndCapCoverPlateDownClipWidth,
    6538           1 :                                                                                                          0.5*fgkEndCapSideCoverThickness);
    6539           2 :   TGeoVolume* endcapcoverplatedownclip = new TGeoVolume("EndCapCoverPlateDownClip",
    6540           1 :                                                                                                         endcapcoverplatedownclipshape,
    6541           1 :                                                                                                         fSSDCoolingTubePhynox);
    6542           1 :   TGeoTranslation* endcapcoverplatecliptrans[4];
    6543           3 :   endcapcoverplatecliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
    6544           1 :                                                            -                     fgkEndCapCoverPlateLength[0]
    6545           1 :                                                            -                     fgkEndCapSideCoverThickness,
    6546             :                                                                                                          0.0,
    6547           1 :                                                                                                  0.5*(fgkEndCapSideCoverThickness
    6548           1 :                                                            +                                              fgkEndCapCoverPlateThickness));
    6549           3 :   endcapcoverplatecliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
    6550           1 :                                                            -                     fgkEndCapCoverPlateLength[0]
    6551           1 :                                                            -                     fgkEndCapSideCoverThickness,
    6552             :                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
    6553           1 :                                                            *                                     fgkEndCapSideCoverWidth[5],
    6554           1 :                                                                                                  0.5*(fgkEndCapSideCoverThickness
    6555           1 :                                                            +                                              fgkEndCapCoverPlateThickness));
    6556           3 :   endcapcoverplatecliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
    6557           1 :                                                            -                     fgkEndCapCoverPlateLength[0]
    6558           1 :                                                            +                                     fgkEndCapCoverPlateLength[1]
    6559           1 :                                                            +                              2.*fgkEndCapCoverPlateLength[0]
    6560           1 :                                                            -                                     fgkEndCapCoverPlateClipLength
    6561           1 :                                                            +                                 fgkEndCapSideCoverThickness,
    6562             :                                                                                                          0.0,
    6563           1 :                                                                                                  0.5*(fgkEndCapSideCoverThickness
    6564           1 :                                                            +                                              fgkEndCapCoverPlateThickness));
    6565           3 :   endcapcoverplatecliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateClipLength
    6566           1 :                                                            -                     fgkEndCapCoverPlateLength[0]
    6567           1 :                                                            +                                     fgkEndCapCoverPlateLength[1]
    6568           1 :                                                            +                              2.*fgkEndCapCoverPlateLength[0]
    6569           1 :                                                            -                                     fgkEndCapCoverPlateClipLength
    6570           1 :                                                            +                                 fgkEndCapSideCoverThickness,
    6571             :                                                                                                          (kendcapcoverplatescrewnumber[1]-1)
    6572           1 :                                                            *                                     fgkEndCapSideCoverWidth[5],
    6573           1 :                                                                                                  0.5*(fgkEndCapSideCoverThickness
    6574           1 :                                                            +                                              fgkEndCapCoverPlateThickness));
    6575           1 :   endcapcoverplateclip->SetLineColor(fColorPhynox);
    6576           1 :   endcapcoverplatedownclip->SetLineColor(fColorPhynox);  
    6577          10 :   for(Int_t i=0; i<4; i++) 
    6578          56 :         for(Int_t j=0; j<4; j++) endcapassembly[j]->AddNode(endcapcoverplateclip,i+1,
    6579          16 :                                                                                                    endcapcoverplatecliptrans[i]);  
    6580           1 :   TGeoTranslation* endcapcoverplatedowncliptrans[4];
    6581           3 :   endcapcoverplatedowncliptrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
    6582           1 :                                                                    -                     fgkEndCapCoverPlateLength[0]
    6583           1 :                                                                    -                     fgkEndCapSideCoverThickness,
    6584           2 :                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
    6585           1 :                                                                    -                                 fgkEndCapCoverPlateClipWidth),
    6586           1 :                                                                                                         0.5*(fgkEndCapSideCoverThickness
    6587           1 :                                                                +                                         fgkEndCapCoverPlateThickness)
    6588           1 :                                                                    -                     fgkEndCapSideCoverWidth[1]
    6589           1 :                                                                    -                                     fgkEndCapSideCoverThickness);
    6590           3 :   endcapcoverplatedowncliptrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
    6591           1 :                                                                    -                     fgkEndCapCoverPlateLength[0]
    6592           1 :                                                                    -                     fgkEndCapSideCoverThickness,
    6593           2 :                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
    6594           1 :                                                                    -                                 fgkEndCapCoverPlateClipWidth)
    6595           1 :                                                                    +                            fgkEndCapSideCoverLength[2]
    6596           1 :                                                                    -                            fgkEndCapCoverPlateDownClipWidth,
    6597           1 :                                                                                                         0.5*(fgkEndCapSideCoverThickness
    6598           1 :                                                                +                                         fgkEndCapCoverPlateThickness)
    6599           1 :                                                                    -                     fgkEndCapSideCoverWidth[1]
    6600           1 :                                                                    -                                     fgkEndCapSideCoverThickness);
    6601           3 :   endcapcoverplatedowncliptrans[2] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
    6602           1 :                                                                    -                     fgkEndCapCoverPlateLength[0]
    6603           1 :                                                                    +                     fgkEndCapSideCoverThickness
    6604           1 :                                                                    +                     fgkEndCapCoverPlateLength[1]
    6605           1 :                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
    6606           1 :                                                                    -                     fgkEndCapCoverPlateDownClipLength,
    6607           2 :                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
    6608           1 :                                                                    -                                 fgkEndCapCoverPlateClipWidth),
    6609           1 :                                                                                                         0.5*(fgkEndCapSideCoverThickness
    6610           1 :                                                                +                                         fgkEndCapCoverPlateThickness)
    6611           1 :                                                                    -                     fgkEndCapSideCoverWidth[1]
    6612           1 :                                                                    -                                     fgkEndCapSideCoverThickness);
    6613           3 :   endcapcoverplatedowncliptrans[3] = new TGeoTranslation(0.5*fgkEndCapCoverPlateDownClipLength
    6614           1 :                                                                    -                     fgkEndCapCoverPlateLength[0]
    6615           1 :                                                                    +                     fgkEndCapSideCoverThickness
    6616           1 :                                                                    +                     fgkEndCapCoverPlateLength[1]
    6617           1 :                                                                    +                 2.0*fgkEndCapCoverPlateLength[0]
    6618           1 :                                                                    -                     fgkEndCapCoverPlateDownClipLength,
    6619           2 :                                                                                     0.5*(fgkEndCapCoverPlateDownClipWidth
    6620           1 :                                                                    -                                 fgkEndCapCoverPlateClipWidth)
    6621           1 :                                                                    +                                 fgkEndCapSideCoverLength[2]
    6622           1 :                                                                    -                                 fgkEndCapCoverPlateDownClipWidth,
    6623           1 :                                                                                                         0.5*(fgkEndCapSideCoverThickness
    6624           1 :                                                                +                                         fgkEndCapCoverPlateThickness)
    6625           1 :                                                                    -                     fgkEndCapSideCoverWidth[1]
    6626           1 :                                                                    -                                     fgkEndCapSideCoverThickness);
    6627          10 :   for(Int_t i=0; i<4; i++)
    6628          56 :         for(Int_t k=0; k<4; k++) endcapassembly[k]->AddNode(endcapcoverplatedownclip,i+1,
    6629          16 :                                                                                                    endcapcoverplatedowncliptrans[i]);
    6630             :   /////////////////////////////////////////////////////
    6631             :   // Placing Kapton Foil
    6632             :   /////////////////////////////////////////////////////
    6633           2 :   TGeoBBox* endcapkaptonfoilshape = new TGeoBBox(0.5*fgkEndCapKaptonFoilLength,
    6634           1 :                                                                                                  0.5*fgkEndCapKaptonFoilWidth,
    6635           1 :                                                                                                  0.5*fgkEndCapKaptonFoilThickness); 
    6636           2 :   TGeoVolume* endcapkaptonfoil = new TGeoVolume("EndCapKaptonFoil",
    6637           1 :                                                                                                 endcapkaptonfoilshape,
    6638           1 :                                                                                                 fSSDKaptonFlexMedium);
    6639           1 :   endcapkaptonfoil->SetLineColor(8);
    6640           2 :   TGeoTranslation* endcapkaptonfoiltrans = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
    6641           1 :                                                                                                                            0.5*fgkEndCapKaptonFoilWidth
    6642           1 :                                                                                  -                     0.5*fgkEndCapCoverPlateClipWidth,
    6643           1 :                                                                                                                            0.5*fgkEndCapCoverPlateThickness
    6644           1 :                                                                                  -                     0.5*fgkEndCapKaptonFoilThickness
    6645           1 :                                                                              -                     fgkEndCapSideCoverWidth[1]
    6646           1 :                                                                                  -                     fgkEndCapSideCoverThickness);
    6647          10 :   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapkaptonfoil,1,endcapkaptonfoiltrans);
    6648             :   /////////////////////////////////////////////////////////////
    6649             :   // Placing Electronic Tubes
    6650             :   /////////////////////////////////////////////////////////////
    6651           1 :   Double_t endcapeffectivecableswidth[2] = {fgkEndCapKaptonFoilWidth
    6652           1 :                                                                              - fgkEndCapInterfaceCardBThickness
    6653           1 :                                                                              - 9.*fgkEndCapStripConnectionThickness
    6654           1 :                                                                              - 8.*fgkEndCapCardElectBoardBackThickness,
    6655             :                                                                                fgkEndCapKaptonFoilWidth
    6656             :                                                                              - fgkEndCapInterfaceCardBThickness
    6657             :                                                                              - 9.*fgkEndCapStripConnectionThickness
    6658             :                                                                              - 8.*fgkEndCapCardElectBoardBackThickness
    6659           1 :                                                                                  - fgkEndCapInterfaceElectBoardCardBThickness};
    6660             :   TGeoVolume* endcapeffectivecables[2];
    6661           2 :   endcapeffectivecables[0] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
    6662           1 :                                                                                          fgkEndCapEffectiveCableRadiusMax,
    6663             :                                                                                          endcapeffectivecableswidth[0],
    6664             :                                                                                          10,"EndCapEffectiveCables1"); 
    6665           2 :   endcapeffectivecables[1] = GetEndCapEffectiveCables(fgkEndCapEffectiveCableRadiusMin,
    6666           1 :                                                                                          fgkEndCapEffectiveCableRadiusMax,
    6667             :                                                                                          endcapeffectivecableswidth[1],
    6668             :                                                                                          25,"EndCapEffectiveCables2"); 
    6669           1 :   TGeoRotation* endcapeffectivecablesrot = new TGeoRotation();
    6670             :   TGeoTranslation* endcapeffectivecablestrans[2];
    6671           2 :   endcapeffectivecablestrans[0] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
    6672           1 :                                           -                                                        0.5*endcapeffectivecableswidth[0]
    6673           2 :                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
    6674           1 :                                           -                                                               fgkEndCapCoverPlateWidth[2]
    6675           1 :                                           -                                             (kendcapcoverplatesmallholenumber-1)
    6676           1 :                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
    6677           1 :                                           +                                             fgkEndCapSideCoverLength[2],
    6678           1 :                                           -                     0.5*fgkEndCapCoverPlateThickness
    6679           2 :                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
    6680           1 :                                           -                                              fgkEndCapInterfaceCardBWidth[0]
    6681           1 :                                           -                                              fgkEndCapInterfaceCardBWidth[1]));
    6682           2 :   endcapeffectivecablestrans[1] = new TGeoTranslation(0.5*fgkEndCapCoverPlateLength[1],
    6683           1 :                                           -                                                        0.5*endcapeffectivecableswidth[1]
    6684           2 :                                           -                            0.5*(fgkEndCapCoverPlateWidth[0]
    6685           1 :                                           -                                                               fgkEndCapCoverPlateWidth[2]
    6686           1 :                                           -                                             (kendcapcoverplatesmallholenumber-1)
    6687           1 :                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
    6688           1 :                                           +                                         fgkEndCapSideCoverLength[2],
    6689           1 :                                           -                     0.5*fgkEndCapCoverPlateThickness
    6690           2 :                                           -                                             (fgkEndCapCardElectBoardBackWidth[0]
    6691           1 :                                           -                                              fgkEndCapInterfaceCardBWidth[0])
    6692           1 :                                           -                     0.5*fgkEndCapInterfaceCardBWidth[2]);
    6693           1 :   endcapeffectivecablesrot->SetAngles(0.,90.,0.);
    6694             :   TGeoCombiTrans* endcapeffectivecablescombitrans[2];
    6695           1 :   endcapeffectivecablescombitrans[0]  = new TGeoCombiTrans(*endcapeffectivecablestrans[0],
    6696             :                                                                                                                    *endcapeffectivecablesrot);
    6697           1 :   endcapeffectivecablescombitrans[1]  = new TGeoCombiTrans(*endcapeffectivecablestrans[1],
    6698             :                                                                                                                    *endcapeffectivecablesrot);
    6699             : //  for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[0],1,
    6700             : //                                                                                                        endcapeffectivecablescombitrans[0]);
    6701          14 :   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapeffectivecables[1],1,
    6702           4 :                                                                                                           endcapeffectivecablescombitrans[1]);
    6703             :   /////////////////////////////////////////////////////////////
    6704             :   // Placing End Cap Cards
    6705             :   /////////////////////////////////////////////////////////////
    6706           1 :   TGeoVolume** endcapcards = GetEndCapCards();
    6707           1 :   TGeoRotation* endcapcardsrot[2];
    6708           8 :   for(Int_t i=0; i<2; i++) endcapcardsrot[i] = new TGeoRotation();
    6709           1 :   endcapcardsrot[0]->SetAngles(90.,0.,0.); 
    6710           1 :   TGeoTranslation* endcapcardstrans[2]; 
    6711           3 :   endcapcardstrans[0] = new TGeoTranslation(0.,0.,0.5*(fgkEndCapInterfaceCardBLength[1]
    6712           1 :                                                                                         -  fgkEndCapCardElectBoardBackLength[0]));
    6713           1 :   TGeoCombiTrans* endcapcardscombitrans = new TGeoCombiTrans(*endcapcardstrans[0],*endcapcardsrot[0]);
    6714           1 :   endcapcardsrot[1]->SetAngles(90.,90.,-90.); 
    6715             :   TGeoHMatrix* endcapcardsmatrix[2];
    6716           2 :   endcapcardsmatrix[0] = new TGeoHMatrix((*endcapcardsrot[1])*(*endcapcardscombitrans));
    6717           1 :   Double_t stiffenertransx = fgkEndCapKaptonFoilWidth-fgkEndCapStiffenerWidth
    6718           1 :                                                   - fgkEndCapCardJMDConnectorLength[0]
    6719           1 :                                                   - fgkEndCapInterfaceCardBThickness
    6720           1 :                                                   - 9.*fgkEndCapStripConnectionThickness
    6721           1 :                                                   - 8.*fgkEndCapCardElectBoardBackThickness;  
    6722           3 :   endcapcardstrans[1] = new TGeoTranslation(-0.5*fgkEndCapStiffenerLength
    6723           1 :                                           -                                             fgkEndCapCoverPlateLength[0]
    6724           2 :                                           + 0.5 *              (fgkEndCapCoverPlateLength[3]
    6725           1 :                                           + 2.0 *                               fgkEndCapCoverPlateLength[2]),  
    6726           1 :                                           -                                                     stiffenertransx-fgkEndCapStiffenerWidth
    6727           1 :                                           -                                                               fgkEndCapCardJMDConnectorLength[0]
    6728           1 :                                           -                                                               fgkEndCapInterfaceCardBThickness
    6729           1 :                                           -     2.0 *                                             fgkEndCapStripConnectionThickness
    6730           1 :                                           - 1.5 *                                             fgkEndCapInterfaceCardBThickness
    6731           2 :                                           - 0.5 *                                                (fgkEndCapCoverPlateWidth[0]
    6732           1 :                                           -                                                               fgkEndCapCoverPlateWidth[2]
    6733           1 :                                           -                                             (kendcapcoverplatesmallholenumber-1)
    6734           1 :                                           *                                             fgkEndCapCoverPlateSmallHoleSeparation[2])
    6735           1 :                                           +                     fgkEndCapKaptonFoilWidth,
    6736           1 :                                                                                           0.5*fgkEndCapCoverPlateThickness
    6737           1 :                                           -                                                     fgkEndCapSideCoverWidth[1]);
    6738           2 :   endcapcardsmatrix[1] = new TGeoHMatrix((*endcapcardstrans[1])*(*endcapcardsmatrix[0]));
    6739          10 :   for(Int_t i=0; i<4; i++) endcapassembly[i]->AddNode(endcapcards[i],1,endcapcardsmatrix[1]);
    6740             :    /////////////////////////////////////////////////////////////
    6741             :   // Deallocating memory
    6742             :   /////////////////////////////////////////////////////////////
    6743           2 :   delete endcapcoverplaterot;
    6744           2 :   delete endcapcoverplatecombitrans;
    6745           2 :   delete endcapcoverplatetrans;
    6746           8 :   for(Int_t i=0; i<3; i++){
    6747           6 :    delete endcapsidecovercombitrans[i];
    6748           7 :    if(i<2) delete endcapsidecoverot[i];      
    6749             :   }
    6750          10 :   for(Int_t i=0; i<2; i++) delete endcapcardsrot[i];
    6751          10 :   for(Int_t i=0; i<2; i++) delete endcapcardstrans[i];
    6752           2 :   delete endcapcardsmatrix[0];
    6753             : 
    6754          10 :   for(Int_t i=0; i<4; i++) endcapassembly[i]->GetShape()->ComputeBBox(); //RS: enforce recompting of BBox
    6755             : 
    6756           1 :   return endcapassembly;
    6757           1 :  } 
    6758             :  ////////////////////////////////////////////////////////////////////////////////
    6759             :  TGeoVolume* AliITSv11GeometrySSD::GetEndCapEffectiveCables(Double_t radiusmin, 
    6760             :                                                                                                                         Double_t radiusmax, 
    6761             :                                                                                                                         Double_t width, 
    6762             :                                                                                                                         Int_t ncables,
    6763             :                                                                                                                         const char* volname){
    6764             :   /////////////////////////////////////////////////////////////
    6765             :   // Generating EndCap High Voltage Tubes 
    6766             :   /////////////////////////////////////////////////////////////
    6767           4 :   Double_t effectiveinneradius = TMath::Sqrt(ncables)*radiusmin;
    6768           2 :   Double_t effectiveouteradius = TMath::Sqrt(effectiveinneradius*effectiveinneradius+(radiusmax-radiusmin)*(radiusmax-radiusmin));
    6769             : 
    6770           2 :   TGeoTube* effectiveinnertubeshape = new TGeoTube(0.,effectiveinneradius,0.5*width);
    6771           2 :   TGeoTube* effectiveoutertubeshape = new TGeoTube(effectiveinneradius,
    6772             :                                                                                                    effectiveouteradius,0.5*width);
    6773           4 :   TGeoVolume* effectiveinnertube = new TGeoVolume("EffectiveEndCapInnerTube",
    6774           2 :                                                                                                 effectiveinnertubeshape,
    6775           2 :                                                                                                 fSSDStiffenerConnectorMedium);
    6776           2 :   effectiveinnertube->SetLineColor(41);
    6777           4 :   TGeoVolume* effectiveoutertube = new TGeoVolume("EffectiveEndCapOuterTube",
    6778           2 :                                                                                                 effectiveoutertubeshape,
    6779           2 :                                                                                                 fSSDKaptonChipCableMedium);
    6780           2 :   effectiveoutertube->SetLineColor(39);
    6781           2 :   TGeoTube* effectivemothertubeshape = new TGeoTube(0.,effectiveouteradius,0.5*width);  
    6782           2 :   TGeoVolume* effectivemothertube = new TGeoVolume(volname,effectivemothertubeshape,fSSDAir);
    6783           2 :   effectivemothertube->AddNode(effectiveinnertube,1);
    6784           2 :   effectivemothertube->AddNode(effectiveoutertube,1);
    6785           2 :   return effectivemothertube;
    6786           0 :  } 
    6787             :  ////////////////////////////////////////////////////////////////////////////////
    6788             :  TGeoVolume** AliITSv11GeometrySSD::EndCapSupport(){ 
    6789             :   /////////////////////////////////////////////////////////////
    6790             :   // Generating EndCap Support Layer 5 and Layer 6 
    6791             :   /////////////////////////////////////////////////////////////
    6792             :   const Int_t knedges = 5;
    6793             :   ///////////////////////////////////////////////
    6794             :   // Setting the vertices for TGeoXtru Up Volume
    6795             :   ///////////////////////////////////////////////
    6796             :   const Int_t klayernumber = 2;
    6797           2 :   Double_t xupvertex[klayernumber][knedges+3];
    6798           1 :   Double_t yupvertex[klayernumber][knedges+3];
    6799           1 :   Double_t upedgeangle[klayernumber] = {360./fgkSSDLay5LadderNumber,360./fgkSSDLay6LadderNumber};
    6800           1 :   Double_t middledgeangle[klayernumber] = {0.0,0.0};
    6801           1 :   Double_t middlepsi[klayernumber] = {0.0,0.0};
    6802           6 :   for(Int_t i=0; i<klayernumber; i++){
    6803           2 :         xupvertex[i][0] = -fgkEndCapSupportMiddleRadius[i]*SinD(0.5*upedgeangle[i]);
    6804           2 :         xupvertex[i][1] = -0.5*fgkEndCapSupportLength[i];
    6805           2 :         xupvertex[i][2] = -xupvertex[i][1];
    6806           2 :         xupvertex[i][3] = -xupvertex[i][0];
    6807             : 
    6808           2 :         yupvertex[i][0] =  fgkEndCapSupportMiddleRadius[i]*CosD(0.5*upedgeangle[i]);
    6809           2 :         yupvertex[i][1] =  0.5*fgkEndCapSupportLength[i]/TanD(0.5*upedgeangle[i]);
    6810           2 :         yupvertex[i][2] =  yupvertex[i][1];
    6811           2 :         yupvertex[i][3] =  yupvertex[i][0];
    6812             :         
    6813           2 :     middledgeangle[i] = upedgeangle[i]/knedges;
    6814           2 :     middlepsi[i] = 90.0-0.5*upedgeangle[i];
    6815          20 :     for(Int_t j=1; j<knedges; j++){
    6816           8 :                 xupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*CosD(middlepsi[i]+j*middledgeangle[i]);
    6817           8 :                 yupvertex[i][j+3] = fgkEndCapSupportMiddleRadius[i]*SinD(middlepsi[i]+j*middledgeangle[i]);
    6818             :         }
    6819             :   }
    6820             :   ////////////////////////////////////
    6821             :   // Generating Up TGeoXtru
    6822             :   ////////////////////////////////////
    6823           1 :   TGeoXtru* upendcapsupportshape[klayernumber];
    6824           1 :   TGeoVolume* upendcapsupport[klayernumber]; 
    6825           1 :   char upendcapsupportname[100]; 
    6826           6 :   for(Int_t i=0; i<klayernumber; i++){
    6827           4 :    upendcapsupportshape[i] = new TGeoXtru(2);
    6828           2 :    snprintf(upendcapsupportname,100,"UpEndCapSupportPieceLayer%i",i+5);
    6829           2 :    upendcapsupportshape[i]->DefinePolygon(knedges+3,xupvertex[i],yupvertex[i]); 
    6830           2 :    upendcapsupportshape[i]->DefineSection(0,0.);
    6831           2 :    upendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
    6832           6 :    upendcapsupport[i] = new TGeoVolume(upendcapsupportname,upendcapsupportshape[i],
    6833           2 :                                                                         fSSDSupportRingAl);
    6834           2 :    upendcapsupport[i]->SetLineColor(5);
    6835             :   }
    6836             :   ///////////////////////////////////////////////
    6837             :   // Setting the vertices for TGeoXtru Down Volume
    6838             :   ///////////////////////////////////////////////
    6839           1 :   Double_t xdownvertex[klayernumber][2*(knedges+1)];
    6840           1 :   Double_t ydownvertex[klayernumber][2*(knedges+1)];
    6841           6 :   for(Int_t i=0; i<klayernumber; i++){
    6842           2 :         xdownvertex[i][0] = -fgkEndCapSupportLowRadius[i]*SinD(0.5*upedgeangle[i]);
    6843           2 :         xdownvertex[i][1] =  xupvertex[i][0];
    6844           2 :         ydownvertex[i][0] = fgkEndCapSupportLowRadius[i]*CosD(0.5*upedgeangle[i]);
    6845           2 :         ydownvertex[i][1] =  yupvertex[i][0];
    6846          24 :         for(Int_t j=0; j<knedges; j++){
    6847          10 :                 xdownvertex[i][j+2] = xupvertex[i][knedges+2-j];
    6848          10 :                 ydownvertex[i][j+2] = yupvertex[i][knedges+2-j];
    6849             :         } 
    6850          24 :         for(Int_t j=0; j<knedges; j++){
    6851          20 :                 xdownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
    6852          10 :                                                                         * CosD(middlepsi[i]+j*middledgeangle[i]);
    6853          20 :                 ydownvertex[i][knedges+j+2] = fgkEndCapSupportLowRadius[i]
    6854          10 :                                                                         * SinD(middlepsi[i]+j*middledgeangle[i]);
    6855             :         }
    6856             :   }
    6857             :   ////////////////////////////////////
    6858             :   // Generating Down TGeoXtru
    6859             :   ////////////////////////////////////  
    6860           1 :   TGeoXtru* downendcapsupportshape[klayernumber];
    6861           1 :   TGeoVolume* downendcapsupport[klayernumber]; 
    6862           1 :   char downendcapsupportname[100]; 
    6863           6 :   for(Int_t i=0; i<klayernumber; i++){
    6864           4 :         downendcapsupportshape[i] = new TGeoXtru(2);
    6865           2 :         snprintf(downendcapsupportname,100,"DownEndCapSupportPieceLayer%i",i+5);
    6866           4 :         downendcapsupportshape[i] = new TGeoXtru(2);
    6867           2 :         downendcapsupportshape[i]->DefinePolygon(2*(knedges+1),xdownvertex[i],ydownvertex[i]); 
    6868           4 :     if(i==0){
    6869           3 :                 downendcapsupportshape[i]->DefineSection(0,0.);
    6870           1 :                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportLowWidth[i]);
    6871           1 :     }
    6872             :         else{
    6873           2 :                 downendcapsupportshape[i]->DefineSection(0,fgkEndCapSupportHighWidth
    6874           1 :                                                                  -                 fgkEndCapSupportLowWidth[i]);
    6875           1 :                 downendcapsupportshape[i]->DefineSection(1,fgkEndCapSupportHighWidth);
    6876             :         }
    6877           6 :     downendcapsupport[i] = new TGeoVolume(downendcapsupportname,
    6878           2 :                                                                 downendcapsupportshape[i],fSSDSupportRingAl);
    6879           2 :         downendcapsupport[i]->SetLineColor(5);
    6880             :   }
    6881             :   ///////////////////////////////////////////////
    6882             :   // Setting TGeoPgon Volume
    6883             :   ///////////////////////////////////////////////
    6884             :   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
    6885             :                                                                                                    fgkSSDLay6LadderNumber};
    6886           1 :   TGeoPgon* endcapsupportmothershape[klayernumber];
    6887             :   TGeoVolume** endcapsupportmother;
    6888           1 :   endcapsupportmother = new TGeoVolume*[klayernumber];
    6889           1 :   char endcapsupportmothername[100];
    6890           6 :   for(Int_t i=0; i<klayernumber; i++){
    6891           4 :         endcapsupportmothershape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
    6892           2 :         snprintf(endcapsupportmothername,100,"EndCapSupportMotherLayer%i",i+5);
    6893           2 :         endcapsupportmothershape[i]->DefineSection(0,0.,ydownvertex[i][0],yupvertex[i][1]);  
    6894           4 :     endcapsupportmothershape[i]->DefineSection(1,fgkEndCapSupportHighWidth,
    6895           2 :                                                                                           ydownvertex[i][0],yupvertex[i][1]);
    6896           6 :     endcapsupportmother[i] = new TGeoVolume(endcapsupportmothername,endcapsupportmothershape[i],
    6897           2 :                                                                                         fSSDAir);       
    6898             :   }
    6899             :   ////////////////////////////////////
    6900           1 :   TGeoRotation** endcapsupportrot[klayernumber];
    6901           6 :   for(Int_t i=0; i<2; i++){
    6902           2 :         endcapsupportrot[i] = new TGeoRotation*[kssdlayladdernumber[i]];        
    6903         148 :         for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
    6904         144 :            endcapsupportrot[i][j] = new TGeoRotation();
    6905          72 :            endcapsupportrot[i][j]->SetAngles(j*upedgeangle[i],0.,0.);
    6906          72 :        endcapsupportmother[i]->AddNode(upendcapsupport[i],j+1,endcapsupportrot[i][j]);
    6907          72 :        endcapsupportmother[i]->AddNode(downendcapsupport[i],j+1,endcapsupportrot[i][j]);
    6908             :         }
    6909             :   }
    6910           1 :   return endcapsupportmother;
    6911           1 :  } 
    6912             :  ////////////////////////////////////////////////////////////////////////////////
    6913             :  void AliITSv11GeometrySSD::SetEndCapSupportAssembly(){
    6914             :   /////////////////////////////////////////////////////////////
    6915             :   // Setting End Cap Support Layer 5 and 6. 
    6916             :   /////////////////////////////////////////////////////////////
    6917             :   const Int_t kendcapcoverplatesmallholenumber = 9;
    6918             :   const Int_t klayernumber = 2;
    6919             :   const Int_t kssdlayladdernumber[klayernumber] = {fgkSSDLay5LadderNumber,
    6920             :                                                                                                    fgkSSDLay6LadderNumber};
    6921           3 :   Double_t upedgeangle[klayernumber] = {360.0/kssdlayladdernumber[0],
    6922           1 :                                                                                 360.0/kssdlayladdernumber[1]};
    6923           1 :   TGeoVolume** endcapsupport = EndCapSupport();
    6924           1 :   TGeoVolume** endcapassembly = GetEndCapAssembly();
    6925           1 :   TGeoPgon* endcapsupportshape[klayernumber];
    6926           1 :   Double_t* radiusmin[klayernumber];
    6927           1 :   Double_t* radiusmax[klayernumber];
    6928           6 :   for(Int_t i=0; i<klayernumber; i++){
    6929           2 :     endcapsupportshape[i] = (TGeoPgon*)endcapsupport[i]->GetShape();
    6930           2 :         radiusmin[i] = endcapsupportshape[i]->GetRmin();
    6931           2 :         radiusmax[i] = endcapsupportshape[i]->GetRmax();
    6932             :   }  
    6933           1 :   TGeoBBox* endcapassemblyshape = (TGeoBBox*)endcapassembly[0]->GetShape();
    6934           1 :   Double_t endcapassemblycenter[3] = {endcapassemblyshape->GetDX(),
    6935           1 :                                                                           endcapassemblyshape->GetDY(),
    6936           1 :                                                                           endcapassemblyshape->GetDZ()};
    6937             :   ///////////////////////////////////////////////
    6938             :   // Setting TGeoPgon Volume for Mother Container
    6939             :   ///////////////////////////////////////////////
    6940           1 :   TGeoPgon* endcapsupportsystemshape[klayernumber];
    6941           1 :   char endcapsupportsystemothername[100];
    6942           6 :   for(Int_t i=0; i<klayernumber; i++){
    6943           4 :         endcapsupportsystemshape[i] = new TGeoPgon(0.0,360.0,kssdlayladdernumber[i],2);
    6944           2 :         snprintf(endcapsupportsystemothername,100,"EndCapSupportSystemLayer%i",i+5);
    6945           6 :         endcapsupportsystemshape[i]->DefineSection(0,-(fgkEndCapCoverPlateWidth[1]
    6946           4 :                                                                                              - fgkEndCapCoverPlateWidth[0]),*radiusmin[i],
    6947           2 :                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
    6948           2 :                                                                                            +2.*endcapassemblycenter[2])
    6949           2 :                                                                                            /CosD(0.5*upedgeangle[i]));  
    6950           4 :     endcapsupportsystemshape[i]->DefineSection(1,2.*endcapassemblycenter[1]
    6951           4 :                                                                                                  -(fgkEndCapCoverPlateWidth[1]
    6952           2 :                                                                                              - fgkEndCapCoverPlateWidth[0]),
    6953           2 :                                                                                            *radiusmin[i],
    6954           2 :                                                                                           (*radiusmax[i]*CosD(0.5*upedgeangle[i])
    6955           2 :                                                                                            +2.*endcapassemblycenter[2])
    6956           2 :                                                                                            /CosD(0.5*upedgeangle[i]));
    6957             :   }
    6958           1 :   fgkEndCapSupportSystem = new TGeoVolume*[4];
    6959           3 :   fgkEndCapSupportSystem[0] = new TGeoVolume("EndCapSupportSystemLayer5Sx",
    6960           1 :                                                                           endcapsupportsystemshape[0],fSSDAir); 
    6961           3 :   fgkEndCapSupportSystem[1] = new TGeoVolume("EndCapSupportSystemLayer5Dx",
    6962           1 :                                                                           endcapsupportsystemshape[0],fSSDAir); 
    6963           3 :   fgkEndCapSupportSystem[2] = new TGeoVolume("EndCapSupportSystemLayer6Sx",
    6964           1 :                                                                           endcapsupportsystemshape[1],fSSDAir); 
    6965           3 :   fgkEndCapSupportSystem[3] = new TGeoVolume("EndCapSupportSystemLayer6Dx",
    6966           1 :                                                                           endcapsupportsystemshape[1],fSSDAir); 
    6967             :   ///////////////////////////////////////////////
    6968           1 :   TGeoTranslation* endcapassemblytrans[klayernumber];
    6969           6 :   for(Int_t i=0; i<klayernumber; i++)
    6970           6 :         endcapassemblytrans[i] = new TGeoTranslation(-fgkEndCapCoverPlateLength[0]
    6971           2 :                                                                            -  fgkEndCapSideCoverThickness
    6972           2 :                                                                            +  endcapassemblycenter[0],
    6973           2 :                                                                            -  0.5*fgkEndCapCoverPlateThickness
    6974           2 :                                                                            -  2.0*fgkEndCapCoolingTubeRadiusMax
    6975           2 :                                                                            +  2.0*endcapassemblycenter[2]
    6976           4 :                                                                            +  0.5*fgkEndCapSupportLength[i]
    6977           4 :                                                                            /  TanD(0.5*upedgeangle[i]),
    6978           4 :                                                                                   0.5*(fgkEndCapCoverPlateWidth[0]
    6979           2 :                                                                            -  fgkEndCapCoverPlateWidth[2]
    6980           2 :                                                                            - (kendcapcoverplatesmallholenumber-1)
    6981           2 :                                                                            *  fgkEndCapCoverPlateSmallHoleSeparation[2]));
    6982           1 :   TGeoRotation** endcapassemblyrot[klayernumber];
    6983           1 :   TGeoHMatrix** endcapassemblymatrix[klayernumber];
    6984           6 :   for(Int_t i=0; i<klayernumber; i++){
    6985           2 :    endcapassemblyrot[i] = new TGeoRotation*[kssdlayladdernumber[i]+2];
    6986           2 :    endcapassemblymatrix[i] = new TGeoHMatrix*[kssdlayladdernumber[i]+2];        
    6987         232 :    for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++) endcapassemblyrot[i][j] = new TGeoRotation();
    6988           2 :    endcapassemblyrot[i][0]->SetAngles(0.,-90.,0.);   
    6989           2 :    endcapassemblyrot[i][1]->SetAngles(90.,180.,-90.);        
    6990           6 :    endcapassemblymatrix[i][0] = new TGeoHMatrix((*endcapassemblyrot[i][1])*(*endcapassemblyrot[i][0]));
    6991           6 :    endcapassemblymatrix[i][1] = new TGeoHMatrix((*endcapassemblytrans[i])*(*endcapassemblymatrix[i][0]));
    6992         148 :    for(Int_t j=0; j<kssdlayladdernumber[i]; j++){
    6993          72 :         endcapassemblyrot[i][j+2]->SetAngles(j*upedgeangle[i],0.,0.); 
    6994         216 :         endcapassemblymatrix[i][j+2] = new TGeoHMatrix((*endcapassemblyrot[i][j+2])*(*endcapassemblymatrix[i][1]));
    6995             :    }
    6996             :   }
    6997           2 :   TGeoTranslation* lay6endcapassemblytrans = new TGeoTranslation(0.,0.,
    6998           1 :                                                         fgkEndCapKaptonFoilWidth-fgkEndCapSupportHighWidth);
    6999          10 :   for(Int_t i=0; i<2*klayernumber; i++){
    7000         296 :         for(Int_t j=0; j<(i<2? kssdlayladdernumber[0]:kssdlayladdernumber[1]); j++){
    7001         432 :                 fgkEndCapSupportSystem[i]->AddNode(endcapassembly[i],j+1,i<2?endcapassemblymatrix[0][j+2]:
    7002          76 :                                                                                                                                            endcapassemblymatrix[1][j+2]);
    7003             :         }
    7004          12 :         fgkEndCapSupportSystem[i]->AddNode(i<2?endcapsupport[0]:endcapsupport[1],1,i<2?0:lay6endcapassemblytrans);
    7005             :   }
    7006             :    /////////////////////////////////////////////////////////////
    7007             :   // Deallocating memory
    7008             :   /////////////////////////////////////////////////////////////
    7009           6 :   for(Int_t i=0; i<klayernumber; i++){
    7010         156 :         for(Int_t j=0; j<kssdlayladdernumber[i]+2; j++){
    7011         152 :                 delete endcapassemblyrot[i][j];
    7012             :         }
    7013           4 :         delete [] endcapassemblyrot[i];
    7014           4 :         delete endcapassemblymatrix[i][0];
    7015           4 :         delete endcapassemblymatrix[i][1];
    7016             :   }
    7017             :   /////////////////////////////////////////////////////////////
    7018           1 :   }
    7019             :   void AliITSv11GeometrySSD::EndCapSupportSystemLayer5(TGeoVolume* moth){
    7020             :   /////////////////////////////////////////////////////////////
    7021             :   // Setting End Cap Support + End Cap Assembly of Layer 5. 
    7022             :   /////////////////////////////////////////////////////////////
    7023           2 :   if (! moth) {
    7024           0 :     AliError("Can't insert end cap support of layer5, mother is null!\n");
    7025           0 :     return;
    7026             :   };
    7027           1 :   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
    7028             :   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
    7029           2 :   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
    7030           1 :                                                                                                 fgkEndCapSupportCenterLay5ITSPosition
    7031           1 :                                                                            +            fgkEndCapSupportCenterLay5Position
    7032           1 :                                                                            -            fgkEndCapSideCoverLength[2]);
    7033           2 :   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
    7034           1 :                                                                                                 fgkEndCapSideCoverLength[2]
    7035           1 :                                                                            -        fgkEndCapSupportCenterLay5Position
    7036           1 :                                                                            -        fgkEndCapSupportCenterLay5ITSPosition);
    7037           1 :   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
    7038           1 :   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
    7039             :   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
    7040           1 :         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
    7041           1 :   moth->AddNode(fgkEndCapSupportSystem[0],1,endcapsupportsystemITSCentertrans[0]);
    7042           1 :   moth->AddNode(fgkEndCapSupportSystem[1],1,endcapsupportsystemITSCentercombitrans);
    7043             :    /////////////////////////////////////////////////////////////
    7044             :   // Deallocating memory
    7045             :   /////////////////////////////////////////////////////////////
    7046           2 :   delete endcapsupportsystemrot;
    7047           2 :   delete endcapsupportsystemITSCentertrans[1];
    7048           2 :  }
    7049             :   /////////////////////////////////////////////////////////////
    7050             :   void AliITSv11GeometrySSD::EndCapSupportSystemLayer6(TGeoVolume* moth){
    7051             :   /////////////////////////////////////////////////////////////
    7052             :   // Setting End Cap Support + End Cap Assembly of Layer 6. 
    7053             :   /////////////////////////////////////////////////////////////
    7054           2 :   if (! moth) {
    7055           0 :     AliError("Can't insert end cap support of layer6, mother is null!\n");
    7056           0 :     return;
    7057             :   };
    7058           2 :   if(!fgkEndCapSupportSystem) SetEndCapSupportAssembly();
    7059             :   TGeoTranslation* endcapsupportsystemITSCentertrans[2];
    7060           2 :   endcapsupportsystemITSCentertrans[0] = new TGeoTranslation(0.,0.,
    7061           1 :                                                                                                 fgkEndCapSupportCenterLay6ITSPosition
    7062           1 :                                                                            +            fgkEndCapSupportCenterLay6Position
    7063           1 :                                                                            -            fgkEndCapSideCoverLength[2]);
    7064           2 :   endcapsupportsystemITSCentertrans[1] = new TGeoTranslation(0.,0.,
    7065           1 :                                                                                                 fgkEndCapSideCoverLength[2]
    7066           1 :                                                                            -        fgkEndCapSupportCenterLay6Position
    7067           1 :                                                                            -        fgkEndCapSupportCenterLay6ITSPosition);
    7068           1 :   TGeoRotation* endcapsupportsystemrot = new TGeoRotation();
    7069           1 :   endcapsupportsystemrot->SetAngles(90.,180.,-90.);
    7070             :   TGeoCombiTrans* endcapsupportsystemITSCentercombitrans = 
    7071           1 :         new TGeoCombiTrans(*endcapsupportsystemITSCentertrans[1],*endcapsupportsystemrot);
    7072           1 :   moth->AddNode(fgkEndCapSupportSystem[2],1,endcapsupportsystemITSCentertrans[0]);
    7073           1 :   moth->AddNode(fgkEndCapSupportSystem[3],1,endcapsupportsystemITSCentercombitrans);
    7074             :    /////////////////////////////////////////////////////////////
    7075             :   // Deallocating memory
    7076             :   /////////////////////////////////////////////////////////////
    7077           2 :   delete endcapsupportsystemrot;
    7078           2 :   delete endcapsupportsystemITSCentertrans[1];
    7079           2 :  }
    7080             :  ////////////////////////////////////////////////////////////////////////////////
    7081             :  void AliITSv11GeometrySSD::LadderSupportLayer5(TGeoVolume* moth){
    7082             :   /////////////////////////////////////////////////////////////
    7083             :   // Setting Ladder Support of Layer 5. 
    7084             :   /////////////////////////////////////////////////////////////
    7085           2 :   if (! moth) {
    7086           0 :     AliError("Can't insert ladder lupport of layer5, mother is null!\n");
    7087           0 :     return;
    7088             :   };
    7089           2 :   if(!fLay5LadderSupportRing) SetLadderSupport(100);
    7090           1 :   fMotherVol = moth;
    7091           1 :   TGeoTranslation* centerITSRingSupportLay5trans[2];
    7092           6 :   for(Int_t i=0; i<2; i++){
    7093           2 :         centerITSRingSupportLay5trans[i] = 
    7094           2 :                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay5Position);
    7095           2 :     moth->AddNode(fLay5LadderSupportRing,i+1,centerITSRingSupportLay5trans[i]);
    7096             :   }
    7097           2 :  }
    7098             :  ////////////////////////////////////////////////////////////////////////////////
    7099             :  void AliITSv11GeometrySSD::LadderSupportLayer6(TGeoVolume* moth){
    7100             :   /////////////////////////////////////////////////////////////
    7101             :   // Setting Ladder Support of Layer 6. 
    7102             :   /////////////////////////////////////////////////////////////
    7103           2 :   if (! moth) {
    7104           0 :     AliError("Can't insert ladder lupport of layer6, mother is null!\n");
    7105           0 :     return;
    7106             :   };
    7107           1 :   if(!fLay6LadderSupportRing) SetLadderSupport(100);
    7108           1 :   fMotherVol = moth;
    7109           1 :   TGeoTranslation* centerITSRingSupportLay6trans[2];
    7110           6 :   for(Int_t i=0; i<2; i++){
    7111           2 :         centerITSRingSupportLay6trans[i] = 
    7112           2 :                 new TGeoTranslation(0.,0.,TMath::Power(-1.,i)*fgkLadderSupportRingLay6Position);
    7113           2 :     moth->AddNode(fLay6LadderSupportRing,i+1,centerITSRingSupportLay6trans[i]);
    7114             :   }
    7115           2 :  }
    7116             :  ////////////////////////////////////////////////////////////////////////////////
    7117             :  void AliITSv11GeometrySSD::SSDCone(TGeoVolume* moth){
    7118             :   /////////////////////////////////////////////////////////////
    7119             :   // Setting Ladder Support of Layer 6. 
    7120             :   /////////////////////////////////////////////////////////////
    7121           0 :   if (! moth) {
    7122           0 :     AliError("Can't insert SSD Cone, mother is null!\n");
    7123           0 :     return;
    7124             :   };
    7125           0 :   if(!fSSDCone) SetSSDCone();
    7126           0 :   TGeoTranslation* ssdconetrans = new TGeoTranslation(0.,0.,0.5*fgkSSDCentralSupportLength
    7127           0 :                                                                 +                                         fgkSSDCentralAL3SupportLength);
    7128           0 :     moth->AddNode(fSSDCone,1,ssdconetrans);
    7129           0 : }
    7130             :  ////////////////////////////////////////////////////////////////////////////////
    7131             :  void AliITSv11GeometrySSD::SetSSDCone(){
    7132             :   /////////////////////////////////////////////////////////////
    7133             :   // Method generating SSDCone 
    7134             :   /////////////////////////////////////////////////////////////
    7135           0 :   if(!fCreateMaterials) CreateMaterials();
    7136           0 :   fSSDCone = new TGeoVolumeAssembly("ITSssdCone");
    7137           0 :   Double_t ssdpconesectionradiusmax[16];
    7138           0 :   Double_t ssdpconesectionradiusmin[16];
    7139           0 :   Double_t ssdpconezsection[16];
    7140             :   TGeoPcon* ssdpconelittleholeshape[8];
    7141             :   TGeoVolume* ssdpconelittlehole[8];
    7142           0 :   ssdpconezsection[0] = (fgkSSDPConeZLength[0]-fgkSSDPConeZLength[1]);
    7143           0 :   ssdpconesectionradiusmin[0] = fgkSSDLowerPConeRadius;
    7144           0 :   ssdpconesectionradiusmax[0] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
    7145           0 :                                                       / SinD(fgkSSDPConeAngle)
    7146           0 :                                                           + ssdpconesectionradiusmin[0];
    7147           0 :   ssdpconesectionradiusmin[1] = fgkSSDPConeLittleHoleRadius
    7148           0 :                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
    7149           0 :                                                           / SinD(fgkSSDPConeAngle);
    7150           0 :   ssdpconesectionradiusmax[1] = fgkSSDPConeLittleHoleRadius; 
    7151           0 :   ssdpconezsection[1] = (ssdpconesectionradiusmin[1]-ssdpconesectionradiusmin[0])
    7152           0 :                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[0];
    7153           0 :   ssdpconelittleholeshape[0] = new TGeoPcon(0.,360.,2);    
    7154           0 :   for(Int_t i=0; i<2;i++) ssdpconelittleholeshape[0]->DefineSection(i,ssdpconezsection[i],
    7155           0 :                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
    7156           0 :   ssdpconelittlehole[0] = new TGeoVolume("SSDConeLittleHole1",ssdpconelittleholeshape[0],fSSDCarbonFiberMedium);
    7157           0 :   ssdpconelittlehole[0]->SetLineColor(4);
    7158             :   /////////////////////////////////////////////////////////////
    7159           0 :   ssdpconezsection[2] = ssdpconezsection[1];  
    7160           0 :   ssdpconesectionradiusmin[2] = ssdpconesectionradiusmin[1];
    7161           0 :   ssdpconesectionradiusmax[2] = ssdpconesectionradiusmax[1];
    7162           0 :   ssdpconesectionradiusmin[3] = fgkSSDPConeLittleHoleRadius+fgkSSDPConeLittleHoleLength
    7163           0 :                                                           - ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
    7164           0 :                                                           / SinD(fgkSSDPConeAngle);
    7165           0 :   ssdpconesectionradiusmax[3] = ssdpconezsection[0]*CosD(fgkSSDPConeAngle)
    7166           0 :                                                           / SinD(fgkSSDPConeAngle)+ssdpconesectionradiusmin[3];
    7167           0 :   ssdpconezsection[3] = (ssdpconesectionradiusmin[3]-ssdpconesectionradiusmin[2])
    7168           0 :                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[2];
    7169           0 :   Double_t ssdpconelittleholeangle = fgkSSDPConeLittleHoleLength/fgkSSDPConeLittleHoleRadius
    7170           0 :                                                                    * TMath::RadToDeg();
    7171           0 :   ssdpconelittleholeshape[1] = new TGeoPcon(30.+0.5*ssdpconelittleholeangle,
    7172           0 :                                                                                                           60.-ssdpconelittleholeangle,2);    
    7173           0 :   for(Int_t i=2;i<4;i++) ssdpconelittleholeshape[1]->DefineSection(i-2,ssdpconezsection[i],
    7174           0 :                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
    7175           0 :   ssdpconelittlehole[1] = new TGeoVolume("SSDConeLittleHole2",ssdpconelittleholeshape[1],fSSDCarbonFiberMedium);
    7176           0 :   ssdpconelittlehole[1]->SetLineColor(4);
    7177           0 :   TGeoRotation* ssdconelittleholerot[6];
    7178           0 :   for(Int_t i=0; i<6; i++){
    7179           0 :         ssdconelittleholerot[i] = new TGeoRotation();
    7180           0 :     ssdconelittleholerot[i]->SetAngles(i*60,0.,0.);
    7181             :   }
    7182             :   /////////////////////////////////////////////////////////////
    7183           0 :   ssdpconezsection[4] = ssdpconezsection[3];  
    7184           0 :   ssdpconesectionradiusmin[4] = ssdpconesectionradiusmin[3];
    7185           0 :   ssdpconesectionradiusmax[4] = ssdpconesectionradiusmax[3];
    7186           0 :   ssdpconesectionradiusmin[5] = fgkSSDConeMiddleRadius-ssdpconezsection[0]
    7187           0 :                                                           * CosD(fgkSSDPConeAngle)
    7188           0 :                                                           / SinD(fgkSSDPConeAngle);
    7189           0 :   ssdpconesectionradiusmax[5] = fgkSSDConeMiddleRadius;
    7190           0 :   ssdpconezsection[5] = (ssdpconesectionradiusmin[5]-ssdpconesectionradiusmin[4])
    7191           0 :                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[4];
    7192           0 :   ssdpconelittleholeshape[2] = new TGeoPcon(0.,360.,2);
    7193           0 :   for(Int_t i=4; i<6;i++) ssdpconelittleholeshape[2]->DefineSection(i-4,ssdpconezsection[i],
    7194           0 :                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
    7195           0 :   ssdpconelittlehole[2] = new TGeoVolume("SSDConeLittleHole3",ssdpconelittleholeshape[2],fSSDCarbonFiberMedium);
    7196           0 :   ssdpconelittlehole[2]->SetLineColor(4);
    7197             :   ///////////////////////////////////////////////////
    7198           0 :   ssdpconezsection[6] = ssdpconezsection[5];  
    7199           0 :   ssdpconesectionradiusmin[6] = ssdpconesectionradiusmin[5];
    7200           0 :   ssdpconesectionradiusmax[6] = ssdpconesectionradiusmax[5];
    7201           0 :   ssdpconesectionradiusmin[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength
    7202           0 :                                                           -ssdpconezsection[0]
    7203           0 :                                                           * CosD(fgkSSDPConeAngle)
    7204           0 :                                                           / SinD(fgkSSDPConeAngle);
    7205           0 :   ssdpconesectionradiusmax[7] = fgkSSDConeMiddleRadius+fgkSSDPConeMiddleLength;
    7206           0 :   ssdpconezsection[7] = (ssdpconesectionradiusmin[7]-ssdpconesectionradiusmin[6])
    7207           0 :                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[6];
    7208           0 :   Double_t ssdpconemiddleholeangle = fgkSSDPConeMiddleWidth/fgkSSDConeMiddleRadius
    7209           0 :                                                                    * TMath::RadToDeg();
    7210           0 :   ssdpconelittleholeshape[3] = new TGeoPcon(22.5+0.5*ssdpconemiddleholeangle,
    7211           0 :                                                                                                           45.-ssdpconemiddleholeangle,2);    
    7212           0 :   for(Int_t i=6;i<8;i++) ssdpconelittleholeshape[3]->DefineSection(i-6,ssdpconezsection[i],
    7213           0 :                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
    7214           0 :   ssdpconelittlehole[3] = new TGeoVolume("SSDConeLittleHole4",ssdpconelittleholeshape[3],fSSDCarbonFiberMedium);
    7215           0 :   ssdpconelittlehole[3]->SetLineColor(4);
    7216           0 :   TGeoRotation* ssdconemiddleholerot[8];
    7217           0 :   for(Int_t i=0; i<8; i++){
    7218           0 :         ssdconemiddleholerot[i] = new TGeoRotation();
    7219           0 :     ssdconemiddleholerot[i]->SetAngles(i*45,0.,0.);
    7220             :   }
    7221             :   /////////////////////////////////////////////////////////////
    7222           0 :   ssdpconezsection[8] = ssdpconezsection[7];  
    7223           0 :   ssdpconesectionradiusmin[8] = ssdpconesectionradiusmin[7];
    7224           0 :   ssdpconesectionradiusmax[8] = ssdpconesectionradiusmax[7];
    7225           0 :   ssdpconesectionradiusmin[9] = fgkSSDPConeUpRadius-ssdpconezsection[0]
    7226           0 :                                                           * CosD(fgkSSDPConeAngle)
    7227           0 :                                                           / SinD(fgkSSDPConeAngle);
    7228           0 :   ssdpconesectionradiusmax[9] = fgkSSDPConeUpRadius;
    7229           0 :   ssdpconezsection[9] = (ssdpconesectionradiusmin[9]-ssdpconesectionradiusmin[8])
    7230           0 :                                           * TanD(fgkSSDPConeAngle)+ssdpconezsection[8];
    7231           0 :   ssdpconelittleholeshape[4] = new TGeoPcon(0.,360.,2);
    7232           0 :   for(Int_t i=8; i<10;i++) ssdpconelittleholeshape[4]->DefineSection(i-8,ssdpconezsection[i],
    7233           0 :                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
    7234           0 :   ssdpconelittlehole[4] = new TGeoVolume("SSDConeLittleHole5",ssdpconelittleholeshape[4],fSSDCarbonFiberMedium);
    7235           0 :   ssdpconelittlehole[4]->SetLineColor(4);
    7236             :   /////////////////////////////////////////////////////////////
    7237           0 :   Double_t ssdconetrapezoidheight = fgkSSDPConeUpMaxRadius-fgkSSDPConeUpRadius;
    7238           0 :   Double_t ssdconetrapezoidbasis = fgkSSDPConeTrapezoidBasis-2.0
    7239           0 :                                                                  * (0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)
    7240           0 :                                                                  -  0.5*ssdconetrapezoidheight/(fgkSSDPConeUpMaxRadius
    7241           0 :                                                                  -  0.5*ssdconetrapezoidheight)*(0.5*fgkSSDPConeTrapezoidBasis
    7242           0 :                                                                  -  0.5*ssdconetrapezoidheight/TanD(fgkSSDPConeTrapezoidAngle)));
    7243           0 :   Double_t ssdconetrapezoidsection = (2.0*TMath::Pi()*fgkSSDPConeUpMaxRadius-8.0*ssdconetrapezoidbasis)/8.;
    7244           0 :   Double_t ssdpconetrapezoidsectionangle = ssdconetrapezoidsection/fgkSSDPConeUpMaxRadius
    7245           0 :                                                                                  * TMath::RadToDeg();
    7246           0 :   ssdpconezsection[10] = ssdpconezsection[9];
    7247           0 :   ssdpconesectionradiusmin[10] = ssdpconesectionradiusmin[9];
    7248           0 :   ssdpconesectionradiusmax[10] = ssdpconesectionradiusmax[9];
    7249           0 :   ssdpconesectionradiusmin[11] = fgkSSDPConeUpMaxRadius-ssdpconezsection[0]
    7250           0 :                                                           * CosD(fgkSSDPConeAngle)
    7251           0 :                                                           / SinD(fgkSSDPConeAngle);
    7252           0 :   ssdpconesectionradiusmax[11] = fgkSSDPConeUpMaxRadius;
    7253           0 :   ssdpconezsection[11] = (ssdpconesectionradiusmin[11]-ssdpconesectionradiusmin[10])
    7254           0 :                                            * TanD(fgkSSDPConeAngle)+ssdpconezsection[10];
    7255           0 :   ssdpconelittleholeshape[5] = new TGeoPcon(90.-0.5*ssdpconetrapezoidsectionangle,
    7256             :                                                                                         ssdpconetrapezoidsectionangle,2);    
    7257           0 :   for(Int_t i=10;i<12;i++) ssdpconelittleholeshape[5]->DefineSection(i-10,ssdpconezsection[i],
    7258           0 :                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
    7259           0 :   ssdpconelittlehole[5] = new TGeoVolume("SSDConeLittleHole6",ssdpconelittleholeshape[5],fSSDCarbonFiberMedium);
    7260           0 :   ssdpconelittlehole[5]->SetLineColor(4);
    7261           0 :   TGeoRotation* ssdconeupradiusrot[8];
    7262           0 :   for(Int_t i=0; i<8; i++){
    7263           0 :         ssdconeupradiusrot[i] = new TGeoRotation();
    7264           0 :     ssdconeupradiusrot[i]->SetAngles(i*45,0.,0.);
    7265             :   }
    7266             :   /////////////////////////////////////////////////////////////
    7267           0 :   ssdpconezsection[12] = ssdpconezsection[11];
    7268           0 :   ssdpconezsection[13] = ssdpconezsection[12]+fgkSSDPConeRadiusWidth;   
    7269           0 :   ssdpconesectionradiusmin[12] = ssdpconesectionradiusmin[11]; 
    7270           0 :   ssdpconesectionradiusmax[12] = fgkSSDPConeExternalRadius;
    7271           0 :   ssdpconesectionradiusmin[13] = ssdpconesectionradiusmin[12];
    7272           0 :   ssdpconesectionradiusmax[13] = fgkSSDPConeExternalRadius;
    7273           0 :   ssdpconelittleholeshape[6] = new TGeoPcon(0.,360.,2);
    7274           0 :   for(Int_t i=12; i<14;i++) ssdpconelittleholeshape[6]->DefineSection(i-12,ssdpconezsection[i],
    7275           0 :                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
    7276           0 :   ssdpconelittlehole[6] = new TGeoVolume("SSDConeLittleHole7",ssdpconelittleholeshape[6],fSSDCarbonFiberMedium);
    7277           0 :   ssdpconelittlehole[6]->SetLineColor(4);
    7278             :   /////////////////////////////////////////////////////////////
    7279           0 :   ssdpconezsection[14] = 0.0;
    7280           0 :   ssdpconezsection[15] = ssdpconezsection[0];
    7281           0 :   ssdpconesectionradiusmin[14] = ssdpconesectionradiusmin[0];
    7282           0 :   ssdpconesectionradiusmax[14] = ssdpconesectionradiusmin[14];
    7283           0 :   ssdpconesectionradiusmin[15] = ssdpconesectionradiusmin[0];
    7284           0 :   ssdpconesectionradiusmax[15] = ssdpconesectionradiusmax[0];
    7285           0 :   ssdpconelittleholeshape[7] = new TGeoPcon(0.,360.,2);
    7286           0 :   for(Int_t i=14; i<16;i++) ssdpconelittleholeshape[7]->DefineSection(i-14,ssdpconezsection[i],
    7287           0 :                                                   ssdpconesectionradiusmin[i],ssdpconesectionradiusmax[i]); 
    7288           0 :   ssdpconelittlehole[7] = new TGeoVolume("SSDConeLittleHole8",ssdpconelittleholeshape[7],fSSDCarbonFiberMedium);
    7289           0 :   ssdpconelittlehole[7]->SetLineColor(4);
    7290             :   /////////////////////////////////////////////////////////////
    7291             :   TGeoTube* ssdtubeconeshape[2];
    7292             :   TGeoVolume* ssdtubecone[2];
    7293             :   TGeoTranslation* ssdtubeconetrans[2];
    7294           0 :   ssdtubeconeshape[0] = new TGeoTube(fgkSSDPConeUpMiddleRadius,
    7295           0 :                                                                            fgkSSDPConeExternalRadius,
    7296           0 :                                                                            0.5*(fgkSSDPConeLength-ssdpconezsection[13]));
    7297           0 :   ssdtubeconeshape[1] = new TGeoTube(fgkSSDPConeDownRadius,ssdpconesectionradiusmin[0],
    7298           0 :                                                                            0.5*ssdpconezsection[0]); 
    7299           0 :   ssdtubecone[0] = new TGeoVolume("SSDConeTube1",ssdtubeconeshape[0],fSSDSupportRingAl);
    7300           0 :   ssdtubecone[1] = new TGeoVolume("SSDConeTube2",ssdtubeconeshape[1],fSSDSupportRingAl);
    7301           0 :   ssdtubeconetrans[0] = new TGeoTranslation(0.,0.,
    7302           0 :                                                 0.5*(fgkSSDPConeLength-ssdpconezsection[13])
    7303           0 :                                           + ssdpconezsection[13]);
    7304           0 :   ssdtubeconetrans[1] = new TGeoTranslation(0.,0.,0.5*ssdpconezsection[0]);
    7305           0 :   ssdtubecone[0]->SetLineColor(4);
    7306           0 :   ssdtubecone[1]->SetLineColor(4);
    7307             :   /////////////////////////////////////////////////////////////
    7308             :   // Mother Volume Container
    7309             :   /////////////////////////////////////////////////////////////
    7310           0 :   Double_t ssdconemotherradiusmin[8];
    7311           0 :   Double_t ssdconemotherradiusmax[8];
    7312           0 :   Double_t ssdconemothersection[8]; 
    7313           0 :   ssdconemotherradiusmin[0] = fgkSSDPConeDownRadius;
    7314           0 :   ssdconemotherradiusmax[0] = ssdpconesectionradiusmin[0];
    7315           0 :   ssdconemotherradiusmin[1] = fgkSSDPConeDownRadius;
    7316           0 :   ssdconemotherradiusmax[1] = ssdpconesectionradiusmax[0];
    7317           0 :   ssdconemotherradiusmin[2] = ssdpconesectionradiusmin[0];
    7318           0 :   ssdconemotherradiusmax[2] = ssdpconesectionradiusmax[0];
    7319           0 :   ssdconemotherradiusmin[3] = ssdpconesectionradiusmin[11];
    7320           0 :   ssdconemotherradiusmax[3] = ssdpconesectionradiusmax[11];
    7321           0 :   ssdconemotherradiusmin[4] = ssdpconesectionradiusmin[12];
    7322           0 :   ssdconemotherradiusmax[4] = ssdpconesectionradiusmax[12];
    7323           0 :   ssdconemotherradiusmin[5] = ssdpconesectionradiusmin[13];
    7324           0 :   ssdconemotherradiusmax[5] = ssdpconesectionradiusmax[13];
    7325           0 :   ssdconemotherradiusmin[6] = fgkSSDPConeUpMiddleRadius;
    7326           0 :   ssdconemotherradiusmax[6] = fgkSSDPConeExternalRadius;
    7327           0 :   ssdconemotherradiusmin[7] = fgkSSDPConeUpMiddleRadius;
    7328           0 :   ssdconemotherradiusmax[7] = fgkSSDPConeExternalRadius;
    7329           0 :   ssdconemothersection[0] = 0.0;
    7330           0 :   ssdconemothersection[1] = ssdpconezsection[0];
    7331           0 :   ssdconemothersection[2] = ssdpconezsection[0];
    7332           0 :   ssdconemothersection[3] = ssdpconezsection[11];
    7333           0 :   ssdconemothersection[4] = ssdpconezsection[11];
    7334           0 :   ssdconemothersection[5] = ssdpconezsection[13];
    7335           0 :   ssdconemothersection[6] = ssdpconezsection[13];
    7336           0 :   ssdconemothersection[7] = fgkSSDPConeLength;
    7337           0 :   TGeoPcon* ssdconemothershape = new TGeoPcon(0.,360,8);
    7338           0 :   for(Int_t i=0; i<8; i++) ssdconemothershape->DefineSection(i,ssdconemothersection[i],
    7339           0 :                                                                         ssdconemotherradiusmin[i],ssdconemotherradiusmax[i]);
    7340           0 :   TGeoVolume* ssdconemother = new TGeoVolume("SSDMotherCone",ssdconemothershape,fSSDAir);
    7341             :   /////////////////////////////////////////////////////////////
    7342             :   //Placing the Volumes into Mother 
    7343             :   /////////////////////////////////////////////////////////////
    7344           0 :   ssdconemother->AddNode(ssdpconelittlehole[0],1);
    7345           0 :   for(Int_t i=0; i<6; i++){
    7346           0 :         ssdconemother->AddNode(ssdpconelittlehole[1],i+1,ssdconelittleholerot[i]);
    7347             :   }
    7348           0 :   ssdconemother->AddNode(ssdpconelittlehole[2],1);
    7349           0 :   for(Int_t i=0; i<8; i++){
    7350           0 :     ssdconemother->AddNode(ssdpconelittlehole[3],i+1,ssdconemiddleholerot[i]);
    7351             :   }
    7352           0 :   ssdconemother->AddNode(ssdpconelittlehole[4],1);
    7353           0 :   for(Int_t i=0; i<8; i++){
    7354           0 :     ssdconemother->AddNode(ssdpconelittlehole[5],i+1,ssdconeupradiusrot[i]);
    7355             :   }
    7356           0 :   ssdconemother->AddNode(ssdpconelittlehole[6],1);
    7357           0 :   ssdconemother->AddNode(ssdpconelittlehole[7],1);
    7358           0 :   ssdconemother->AddNode(ssdtubecone[0],1,ssdtubeconetrans[0]);
    7359           0 :   ssdconemother->AddNode(ssdtubecone[1],1,ssdtubeconetrans[1]);
    7360             :   /////////////////////////////////////////////////////////////
    7361             :   // ITS General Support
    7362             :   /////////////////////////////////////////////////////////////
    7363           0 :   TGeoTube* ssdcentralsupportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
    7364           0 :                                                                 fgkSSDCentralSupportRadius,0.5*fgkSSDCentralSupportLength); 
    7365           0 :   TGeoVolume* ssdcentralsupport = new TGeoVolume("SSDCentralSupport",ssdcentralsupportshape,fSSDRohaCellCone);
    7366           0 :   TGeoTranslation* ssdcentralsupportrans = new TGeoTranslation(0.,0.,-0.5*fgkSSDCentralSupportLength
    7367           0 :                                                                              - fgkSSDCentralAL3SupportLength);
    7368           0 :   ssdcentralsupport->SetLineColor(4);
    7369           0 :   fSSDCone->AddNode(ssdcentralsupport,1,ssdcentralsupportrans);
    7370           0 :   TGeoTube* ssdcentralal3supportshape = new TGeoTube(fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth,
    7371           0 :                                                                 fgkSSDCentralSupportRadius,0.25*fgkSSDCentralAL3SupportLength);
    7372           0 :   TGeoVolume* ssdcentralal3support = new TGeoVolume("SSDCentralAl3Support",ssdcentralal3supportshape,fSSDSupportRingAl);
    7373             :   TGeoTranslation* ssdcentralal3supportrans[3]; 
    7374           0 :   ssdcentralal3supportrans[0] = new TGeoTranslation(0.,0.,-0.75*fgkSSDCentralAL3SupportLength);
    7375           0 :   ssdcentralal3supportrans[1] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
    7376           0 :                                                           - 1.25*fgkSSDCentralAL3SupportLength);
    7377           0 :   ssdcentralal3support->SetLineColor(4);
    7378           0 :   fSSDCone->AddNode(ssdcentralal3support,1,ssdcentralal3supportrans[0]);
    7379           0 :   fSSDCone->AddNode(ssdcentralal3support,2,ssdcentralal3supportrans[1]);
    7380           0 :   TGeoPcon* ssdpconcentralal3shape = new TGeoPcon(0.,360.,2);
    7381           0 :   Double_t ssdpconcentralradiusmin[2];
    7382           0 :   Double_t ssdpconcentralradiusmax[2];
    7383           0 :   Double_t ssdpconcentralsection[2];
    7384           0 :   ssdpconcentralradiusmin[0] = fgkSSDCentralSupportRadius-fgkSSDCentralSupportWidth;  
    7385           0 :   ssdpconcentralradiusmin[1] = fgkSSDCentralSupportRadius-fgkSSDCentralAL3SupportWidth;  
    7386           0 :   ssdpconcentralradiusmax[0] = fgkSSDCentralSupportRadius;
    7387           0 :   ssdpconcentralradiusmax[1] = fgkSSDCentralSupportRadius;
    7388           0 :   ssdpconcentralsection[0] = -0.5*fgkSSDCentralAL3SupportLength; 
    7389           0 :   ssdpconcentralsection[1] = 0.;
    7390           0 :   for(Int_t i=0; i<2;i++) ssdpconcentralal3shape->DefineSection(i,ssdpconcentralsection[i],
    7391           0 :                                                   ssdpconcentralradiusmin[i],ssdpconcentralradiusmax[i]); 
    7392           0 :   TGeoVolume* ssdpconcentralal3 = new TGeoVolume("SSDPConeCentralAl3",ssdpconcentralal3shape,fSSDSupportRingAl);
    7393           0 :   ssdpconcentralal3->SetLineColor(4);
    7394           0 :   fSSDCone->AddNode(ssdpconcentralal3,1);
    7395           0 :   TGeoRotation* ssdcentralal3supportrot = new TGeoRotation();
    7396           0 :   ssdcentralal3supportrot->SetAngles(90.,180,-90.);
    7397           0 :   ssdcentralal3supportrans[2] = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
    7398           0 :                                                                 -2.*fgkSSDCentralAL3SupportLength);
    7399           0 :   TGeoCombiTrans* ssdcentralal3supporcombitrans = new TGeoCombiTrans(*ssdcentralal3supportrans[2],
    7400             :                                                                                                                      *ssdcentralal3supportrot);
    7401           0 :   fSSDCone->AddNode(ssdpconcentralal3,2,ssdcentralal3supporcombitrans);
    7402           0 :   TGeoRotation* ssdconemotherot = new TGeoRotation();
    7403           0 :   ssdconemotherot->SetAngles(90.,180.,-90.);
    7404           0 :   TGeoTranslation* ssdconemothertrans = new TGeoTranslation(0.,0.,-fgkSSDCentralSupportLength
    7405           0 :                                                                                                                         -2.*fgkSSDCentralAL3SupportLength);
    7406           0 :   TGeoCombiTrans* ssdconemothercombitrans = new TGeoCombiTrans(*ssdconemothertrans,*ssdconemotherot);
    7407           0 :   fSSDCone->AddNode(ssdconemother,1);
    7408           0 :   fSSDCone->AddNode(ssdconemother,2,ssdconemothercombitrans);
    7409             :   /////////////////////////////////////////////////////////////
    7410             :   // Deallocating memory
    7411             :   /////////////////////////////////////////////////////////////
    7412           0 :   delete ssdcentralal3supportrot;
    7413           0 :   delete ssdcentralal3supportrans[2];
    7414           0 :   delete ssdconemotherot;
    7415           0 :   delete ssdconemothertrans;
    7416             :   /////////////////////////////////////////////////////////////
    7417           0 :  }
    7418             :  ////////////////////////////////////////////////////////////////////////////////
    7419             :  void AliITSv11GeometrySSD::SSDCables(TGeoVolume* moth){
    7420             :   /////////////////////////////////////////////////////////////
    7421             :   // Setting SSD Cables
    7422             :   /////////////////////////////////////////////////////////////
    7423           2 :   if (! moth) {
    7424           0 :     AliError("Can't insert SSD Cables, mother is null!\n");
    7425           0 :     return;
    7426             :   };
    7427           1 :   TGeoVolume* ssdcables = SetSSDCables();
    7428           1 :   moth->AddNode(ssdcables,1);
    7429           2 : }
    7430             :  ////////////////////////////////////////////////////////////////////////////////
    7431             :  TGeoVolume* AliITSv11GeometrySSD::SetSSDCables(){
    7432             :    /////////////////////////////////////////////////////////////
    7433             :    // Method generating SSDCables
    7434             :    /////////////////////////////////////////////////////////////
    7435             : 
    7436             :    /////////////////////////////////////////////////////////////////////////////////
    7437             :    // SSD Cables Parameters (lengths are in mm and angles in degrees)
    7438             :    /////////////////////////////////////////////////////////////////////////////////
    7439             :    
    7440           2 :    const Double_t kSSDCablesLay5TubeRadiusMin = 11.9*fgkmm;
    7441             :    const Double_t kSSDCablesLay6TubeRadiusMin = 11.9*fgkmm;
    7442             :    
    7443             :    // Cable thickness for rings at outer Z
    7444             :    // Average: 9/2 = 4.5 cables per quadrant
    7445             :    // Ideally 1/16 * 38(34) cables, but take factor to (1/8) to accomodate kinks and loops (there are only 2 different cable lengths); 21 mm^2 Cu each
    7446             : 
    7447           1 :    const Double_t kSSDCablesLay5RingArea = 21.*34./8.*fgkmm*fgkmm;  // to be fixed in order to reproduce material budget
    7448           1 :    const Double_t kSSDCablesLay6RingArea = 21.*38./8.*fgkmm*fgkmm;  // to be fixed in order to reproduce material budget
    7449             :    
    7450             :    
    7451           1 :    const Double_t kSSDCablesHeight = 3.2*fgkmm;  // 3.2 mm*13 cm width = 18 cables, 185g/m each Add fudge factor of 2 to get to ~25 kg measured
    7452             : 
    7453             :    const Double_t kSSDCableAngle = 22.5;
    7454             :    // MvL: remove water?
    7455           1 :    const Double_t kSSDCablesLay5RightSideWaterHeight = 2.5*fgkmm;  // to be fixed in order to reproduce material budget
    7456             :    const Double_t kSSDCablesPatchPanel2RB26Angle[2] = {25.0,53.2};
    7457             :    const Double_t kSSDCablesPatchPanel2RB24Angle[2] = {23.0,53.6};
    7458           1 :    const Double_t kSSDPatchPanel2RB26ITSDistance = 975.0*fgkmm;
    7459           1 :    const Double_t kSSDPatchPanel2RB24ITSDistance = 1020.0*fgkmm;
    7460           1 :    const Double_t kSSDPatchPanel2RB26Radius = 451.3*fgkmm;
    7461             :    const Double_t kSSDPatchPanel2RB24Radius = 451.3*fgkmm;
    7462           1 :    const Double_t kSSDPatchPanelHeight = 87.5*fgkmm;
    7463             :    
    7464             :    // SSD Layer 5 Cables
    7465             :    //////////////////////////////////////////////////////////////////////////////////////////////////
    7466           1 :    TGeoVolumeAssembly* ssdcablesmother = new TGeoVolumeAssembly("SSDCables");
    7467             :    Double_t ssdcablelayvertical = 0.05; // Internal variables to control overlapping with SDD cables
    7468             :    Double_t ssdcablelaylateral = 0.55;   // Internal variables to control overlapping with SDD cables
    7469             :    //////////////////////////////////////////////////////////////////////////////////////////////////
    7470             :   // Printf(Form("Cable ring: rad min: %g length %g thick %g", ssdcableslay5rigthsideradiusmin, ssdcablelay5rightsidelength, kSSDCablesLay5RingArea/ssdcablelay5rightsidelength));
    7471             :   
    7472             : 
    7473             :   
    7474             :   ////////////////////////////////////
    7475             :   //  Double_t cablescapacity[20];
    7476             :   //  cablescapacity[0] = ssdcablelay5rightubeshape->Capacity();
    7477             :   ////////////////////////////////////
    7478             :   //ssdcablesmother->AddNode(ssdcablelay5righttube,1,ssdcablelay5rightrans);
    7479             :   ////////////////////////////////////
    7480             :   // TGeoPCone Volumes
    7481             :   ///////////////////////////////////
    7482             :   TGeoPcon* ssdcableslay5pconshape[3];
    7483             :   TGeoVolume* ssdcableslay5pcon[3]; 
    7484           1 :   ssdcableslay5pconshape[0] = new TGeoPcon(0.,360.,2);   
    7485           1 :   Double_t ssdcableslay5pconzsection[6];
    7486           1 :   Double_t ssdcableslay5pconrmin[6];
    7487           1 :   Double_t ssdcableslay5pconrmax[6];
    7488           1 :   ssdcableslay5pconrmin[0] = fgkEndCapSupportMiddleRadius[0]+kSSDCablesLay5TubeRadiusMin;
    7489           1 :   ssdcableslay5pconrmin[1] = fgkSSDPConeUpRadius*(1.0+ssdcablelayvertical);
    7490             : 
    7491           2 :   ssdcableslay5pconzsection[0] = fgkEndCapSupportCenterLay5ITSPosition
    7492           1 :                                  + fgkEndCapSupportCenterLay5Position;
    7493             :                                 //+ 2.*ssdcablelay5rightsidelength;  // removing this generates overlap with the water ring 
    7494             :                                 // Keeping it generates overlap with the cones...
    7495             :   // SSDCables/SSDCableLay5RightSideWaterTube_2 ovlp=0.0939792
    7496           2 :   ssdcableslay5pconzsection[1] = 0.5*fgkSSDCentralSupportLength
    7497           1 :                                                            + fgkSSDCentralAL3SupportLength
    7498           2 :                                                            + (fgkSSDPConeUpRadius-fgkSSDLowerPConeRadius)
    7499           1 :                                                            * TanD(fgkSSDPConeAngle);      
    7500           1 :   Double_t dz = ssdcableslay5pconzsection[1]-ssdcableslay5pconzsection[0];
    7501           1 :   Double_t pconethickness = kSSDCablesLay5RingArea/TMath::Abs(dz);
    7502           1 :   ssdcableslay5pconrmax[0] = ssdcableslay5pconrmin[0]+pconethickness;
    7503           1 :   ssdcableslay5pconrmax[1] = ssdcableslay5pconrmin[1]+pconethickness;
    7504             :   //Printf(Form("pcone: r1 %g  r2 %g z1 %g z2 %g thickness %g", ssdcableslay5pconrmax[0], ssdcableslay5pconrmax[1], 
    7505             :   //          ssdcableslay5pconzsection[0],ssdcableslay5pconzsection[1],pconethickness));
    7506             :   
    7507           8 :   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[0]->DefineSection(i,ssdcableslay5pconzsection[i],
    7508           2 :                                                   ssdcableslay5pconrmin[i],ssdcableslay5pconrmax[i]); 
    7509           2 :   ssdcableslay5pcon[0] = new TGeoVolume("SSDCableLay5RightSidePCon1",
    7510           1 :                                                            ssdcableslay5pconshape[0],fSSDCopper);
    7511           1 :   ssdcableslay5pcon[0]->SetLineColor(9);
    7512           1 :   ssdcablesmother->AddNode(ssdcableslay5pcon[0],1);
    7513             : 
    7514           1 :   Double_t totvol = ssdcableslay5pcon[0]->Capacity();
    7515             :   // Printf(Form("Cables, lay5, pCone,volume: %g", ssdcableslay5pcon[0]->Capacity()));
    7516             : ////////////////////////////////////
    7517             : //  cablescapacity[1] = ssdcableslay5pconshape[0]->Capacity();
    7518             : ////////////////////////////////////
    7519             : 
    7520             :   //
    7521             :   //   PCon 2 and 3 are cables going through/towards holes in supports
    7522             :   //
    7523           1 :   ssdcableslay5pconzsection[2] = ssdcableslay5pconzsection[1];
    7524           2 :   ssdcableslay5pconzsection[3] = 0.5*fgkSSDCentralSupportLength
    7525           1 :                                                            + fgkSSDCentralAL3SupportLength
    7526           2 :                                                            + 0.25*TanD(fgkSSDPConeAngle)*(fgkSSDPConeUpMaxRadius
    7527           1 :                                                            + 3.*fgkSSDPConeUpRadius-4.*fgkSSDLowerPConeRadius);
    7528           3 :   Double_t ssdcableangle = (fgkSSDPConeTrapezoidBasis-2.*(fgkSSDPConeUpMaxRadius
    7529           2 :                                              -  fgkSSDPConeUpRadius)/TanD(fgkSSDPConeTrapezoidAngle))
    7530           1 :                                                  /  fgkSSDPConeUpRadius*TMath::RadToDeg()*2;
    7531           1 :   ssdcableslay5pconshape[1] = new TGeoPcon(90.0-kSSDCableAngle-0.5*ssdcableangle,
    7532             :                                                                                    ssdcableangle,2);
    7533             :   // Printf(Form("PCon2, phi %g dphi %g ",90.0-kSSDCableAngle-0.5*ssdcableangle, ssdcableangle));
    7534           1 :   ssdcableslay5pconrmin[2] = ssdcableslay5pconrmin[1];
    7535           1 :   ssdcableslay5pconrmax[2] = ssdcableslay5pconrmax[1]; 
    7536           3 :   ssdcableslay5pconrmin[3] = 0.25*(fgkSSDPConeUpMaxRadius+3.*fgkSSDPConeUpRadius
    7537           2 :                                                    - 4.*fgkSSDLowerPConeRadius)+fgkSSDLowerPConeRadius;
    7538           1 :   ssdcableslay5pconrmin[3]*=(1.0+ssdcablelayvertical);
    7539           1 :   ssdcableslay5pconrmax[3] = ssdcableslay5pconrmin[3] + kSSDCablesHeight; 
    7540           8 :   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[1]->DefineSection(i,ssdcableslay5pconzsection[i+2],
    7541           2 :                                                   ssdcableslay5pconrmin[i+2],ssdcableslay5pconrmax[i+2]); 
    7542           1 :   ssdcableslay5pcon[1] = new TGeoVolume("SSDCableLay5RightSidePCon2",ssdcableslay5pconshape[1],fSSDCopper);
    7543           1 :   ssdcableslay5pcon[1]->SetLineColor(9);
    7544             :   ////////////////////////////////////
    7545           1 :   ssdcableslay5pconshape[2] = new TGeoPcon(90.0-kSSDCableAngle-0.5*ssdcableangle,
    7546             :                                                                                    ssdcableangle,2);   
    7547           1 :   ssdcableslay5pconrmin[4] = ssdcableslay5pconrmin[3];
    7548           1 :   ssdcableslay5pconrmax[4] = ssdcableslay5pconrmax[3];
    7549           1 :   ssdcableslay5pconrmin[5] = ssdcableslay5pconrmin[4];
    7550           1 :   ssdcableslay5pconrmax[5] = ssdcableslay5pconrmax[4];
    7551           1 :   ssdcableslay5pconzsection[4] = ssdcableslay5pconzsection[3];
    7552           2 :   ssdcableslay5pconzsection[5] = (ssdcableslay5pconrmin[5]-fgkSSDLowerPConeRadius)
    7553           1 :                                                            * TanD(fgkSSDPConeAngle)
    7554           1 :                                                            + 0.5*fgkSSDCentralSupportLength
    7555           1 :                                                            + fgkSSDCentralAL3SupportLength;
    7556           1 :   ssdcableslay5pconzsection[5]-= ssdcablelaylateral;
    7557           8 :   for(Int_t i=0; i<2;i++) ssdcableslay5pconshape[2]->DefineSection(i,ssdcableslay5pconzsection[i+4],
    7558           2 :                                                   ssdcableslay5pconrmin[i+4],ssdcableslay5pconrmax[i+4]); 
    7559           1 :   ssdcableslay5pcon[2] = new TGeoVolume("SSDCableLay5RightSidePCon3",ssdcableslay5pconshape[2],fSSDCopper);
    7560           1 :   ssdcableslay5pcon[2]->SetLineColor(9);
    7561             : ////////////////////////////////////
    7562           1 :   TGeoRotation* ssdcableslay5pconrot[4];        
    7563          10 :   for(Int_t i=0; i<4; i++){
    7564           8 :    ssdcableslay5pconrot[i] = new TGeoRotation();
    7565           4 :    ssdcableslay5pconrot[i]->SetAngles(90.0*i,0.,0.);
    7566           4 :    ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+1,ssdcableslay5pconrot[i]);
    7567           4 :    ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+1,ssdcableslay5pconrot[i]);       
    7568             :    // Printf(Form("Pcon2, Pcon3, vol %g %g",ssdcableslay5pcon[1]->Capacity(),ssdcableslay5pcon[2]->Capacity()));
    7569           4 :    totvol += ssdcableslay5pcon[1]->Capacity()+ssdcableslay5pcon[2]->Capacity();
    7570             :   }
    7571             :   ////////////////////////////////////
    7572             :   //cablescapacity[2] = 4.0*ssdcableslay5pconshape[1]->Capacity();
    7573             :   //cablescapacity[3] = 4.0*ssdcableslay5pconshape[2]->Capacity();
    7574             :   ////////////////////////////////////
    7575             :   // Positioning Left SSD Cables Part
    7576             :   ////////////////////////////////////
    7577           1 :   TGeoRotation* ssdcablesLay5RightPConToLeftRot = new TGeoRotation();
    7578           1 :   ssdcablesLay5RightPConToLeftRot->SetAngles(90.,180.,-90);
    7579           1 :   ssdcablesmother->AddNode(ssdcableslay5pcon[0],2,ssdcablesLay5RightPConToLeftRot);  
    7580           1 :   TGeoHMatrix* ssdcablesLay5RightPConToLeftMatrix[4];  
    7581          14 :   for(Int_t i=0; i<4; i++){ ssdcablesLay5RightPConToLeftMatrix[i] = 
    7582           8 :         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconrot[i]));
    7583           4 :         ssdcablesmother->AddNode(ssdcableslay5pcon[1],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
    7584           4 :     ssdcablesmother->AddNode(ssdcableslay5pcon[2],i+5,ssdcablesLay5RightPConToLeftMatrix[i]);        
    7585             :   }
    7586             :   ////////////////////////////////////
    7587             :   //cablescapacity[4] = ssdcablelay5rightubeshape->Capacity();
    7588             :   //cablescapacity[5] = ssdcableslay5pconshape[0]->Capacity();
    7589             :   //cablescapacity[6] = 4.*ssdcableslay5pconshape[1]->Capacity();
    7590             :   //cablescapacity[7] = 4.*ssdcableslay5pconshape[2]->Capacity();
    7591             :   /////////////////////////////////////////////////////////////
    7592             :   // Water Tubes Layer 5
    7593             :   /////////////////////////
    7594             :   /*  Remove ring; could be replaced with a PCone next to/on top of the cables
    7595             : 
    7596             :    //
    7597             :    // MvL: Remove ring; put everything in PCone
    7598             :    //
    7599             :    // Need to keep dimensions for water ring...
    7600             : 
    7601             :    Double_t ssdcablesfactor = 0.5;     // Internal variables to control overlapping with SDD cables
    7602             : 
    7603             :   Double_t ssdcableslay5rigthsideradiusmin = fgkEndCapSupportMiddleRadius[0]+kSSDCablesLay5TubeRadiusMin;  
    7604             :   Double_t ssdcableslay5endconedistance = (ssdcableslay5rigthsideradiusmin
    7605             :                                                                             -  fgkSSDLowerPConeRadius)
    7606             :                                                                             * TanD(fgkSSDPConeAngle);
    7607             :   Double_t ssdcableslay5startconedistance = fgkEndCapSupportCenterLay5ITSPosition
    7608             :                                                                               + fgkEndCapSupportCenterLay5Position
    7609             :                                                                               - 0.5*fgkSSDCentralSupportLength-fgkSSDCentralAL3SupportLength;
    7610             :   Double_t ssdcablelay5rightsidelength = ssdcableslay5endconedistance
    7611             :                                                                            - ssdcableslay5startconedistance; 
    7612             :   ssdcablelay5rightsidelength *= ssdcablesfactor;
    7613             :   Double_t ssdcableslay5rightsideradiusmax = ssdcableslay5rigthsideradiusmin+kSSDCablesLay5RingArea/ssdcablelay5rightsidelength; 
    7614             : 
    7615             : 
    7616             :   TGeoTranslation* ssdcablelay5rightrans = 
    7617             :                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay5ITSPosition
    7618             :                                                                     + fgkEndCapSupportCenterLay5Position
    7619             :                                                                     + 0.5*ssdcablelay5rightsidelength);
    7620             : 
    7621             :   TGeoTranslation* ssdcablesLay5RightTubeToLeftrans = new TGeoTranslation(0.,0.,
    7622             :                                                                                                         - 0.5*ssdcablelay5rightsidelength
    7623             :                                                                                                         - fgkEndCapSupportCenterLay5Position
    7624             :                                                                                                     - fgkEndCapSupportCenterLay5ITSPosition);
    7625             : 
    7626             :   TGeoTube* ssdcablelay5rightubewatershape = new TGeoTube(ssdcableslay5rightsideradiusmax,
    7627             :                                                                                      ssdcableslay5rightsideradiusmax
    7628             :                                                                                + kSSDCablesLay5RightSideWaterHeight,
    7629             :                                                                                      0.5*ssdcablelay5rightsidelength); 
    7630             :   TGeoVolume* ssdcablelay5rightwatertube = new TGeoVolume("SSDCableLay5RightSideWaterTube",
    7631             :                                                                                                          ssdcablelay5rightubewatershape,
    7632             :                                                                                                          fSSDCoolingTubeWater);
    7633             :   ssdcablelay5rightwatertube->SetLineColor(7);
    7634             :   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,1,ssdcablelay5rightrans);
    7635             :   ssdcablesmother->AddNode(ssdcablelay5rightwatertube,2,ssdcablesLay5RightTubeToLeftrans);
    7636             :   */
    7637             :   ////////////////////////////////////
    7638             :   // TGeoPCone Water Volumes Layer 
    7639             :   ///////////////////////////////////
    7640             :   TGeoPcon* ssdcableslay5pconwatershape[3];
    7641             :   TGeoVolume* ssdcableslay5pconwater[3]; 
    7642           1 :   ssdcableslay5pconwatershape[0] = new TGeoPcon(0.,360.,2);   
    7643           1 :   Double_t ssdcableslay5pconwaterzsection[6];
    7644           1 :   Double_t ssdcableslay5pcwateronrmin[6];
    7645           1 :   Double_t ssdcableslay5pconwaterrmax[6];
    7646           1 :   ssdcableslay5pcwateronrmin[0] = ssdcableslay5pconrmax[0];
    7647           1 :   ssdcableslay5pconwaterrmax[0] = ssdcableslay5pcwateronrmin[0]
    7648           1 :                                                                 + kSSDCablesLay5RightSideWaterHeight;
    7649           1 :   ssdcableslay5pcwateronrmin[1] = ssdcableslay5pconrmax[1];
    7650           1 :   ssdcableslay5pconwaterrmax[1] = ssdcableslay5pcwateronrmin[1]
    7651           1 :                                                                 + kSSDCablesLay5RightSideWaterHeight;
    7652           1 :   ssdcableslay5pconwaterzsection[0] = ssdcableslay5pconzsection[0];
    7653           1 :   ssdcableslay5pconwaterzsection[1] = ssdcableslay5pconzsection[1];
    7654           8 :   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[0]->DefineSection(i,ssdcableslay5pconwaterzsection[i],
    7655           2 :                                                   ssdcableslay5pcwateronrmin[i],ssdcableslay5pconwaterrmax[i]); 
    7656           2 :   ssdcableslay5pconwater[0] = new TGeoVolume("SSDCableLay5RightSidePConWater1",
    7657           1 :                                                            ssdcableslay5pconwatershape[0],fSSDCoolingTubeWater);
    7658           1 :   ssdcableslay5pconwater[0]->SetLineColor(7);
    7659           1 :   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],1);
    7660           1 :   ssdcablesmother->AddNode(ssdcableslay5pconwater[0],2,ssdcablesLay5RightPConToLeftRot);
    7661             : ////////////////////////////////////
    7662           1 :   ssdcableslay5pconwaterzsection[2] = ssdcableslay5pconzsection[2];
    7663           1 :   ssdcableslay5pconwaterzsection[3] = ssdcableslay5pconzsection[3];
    7664           1 :   ssdcableslay5pconwatershape[1] = new TGeoPcon(90.0-kSSDCableAngle-0.5*ssdcableangle,
    7665             :                                                                                                 ssdcableangle,2);   
    7666           1 :   ssdcableslay5pcwateronrmin[2] = ssdcableslay5pconrmax[1];
    7667           1 :   ssdcableslay5pconwaterrmax[2] = ssdcableslay5pcwateronrmin[2]
    7668           1 :                                                                 + kSSDCablesLay5RightSideWaterHeight;
    7669           1 :   ssdcableslay5pcwateronrmin[3] = ssdcableslay5pconrmax[3];
    7670           1 :   ssdcableslay5pconwaterrmax[3] = ssdcableslay5pcwateronrmin[3]
    7671           1 :                                                                 + kSSDCablesLay5RightSideWaterHeight;
    7672           8 :   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[1]->DefineSection(i,ssdcableslay5pconwaterzsection[i+2],
    7673           2 :                                                   ssdcableslay5pcwateronrmin[i+2],ssdcableslay5pconwaterrmax[i+2]); 
    7674           2 :   ssdcableslay5pconwater[1] = new TGeoVolume("SSDCableLay5RightSidePConWater2",
    7675           1 :                                                            ssdcableslay5pconwatershape[1],fSSDCoolingTubeWater);
    7676           1 :   ssdcableslay5pconwater[1]->SetLineColor(7);
    7677             : ////////////////////////////////////
    7678           1 :   ssdcableslay5pconwatershape[2] = new TGeoPcon(90.0-kSSDCableAngle-0.5*ssdcableangle,
    7679             :                                                                                                 ssdcableangle,2);   
    7680           1 :   ssdcableslay5pcwateronrmin[4] = ssdcableslay5pconrmax[3];
    7681           1 :   ssdcableslay5pconwaterrmax[4] = ssdcableslay5pcwateronrmin[4]
    7682           1 :                                                                 + kSSDCablesLay5RightSideWaterHeight;
    7683           1 :   ssdcableslay5pcwateronrmin[5] = ssdcableslay5pconrmax[4];
    7684           2 :   ssdcableslay5pconwaterrmax[5] = ssdcableslay5pcwateronrmin[4]
    7685           1 :                                                                 + kSSDCablesLay5RightSideWaterHeight;
    7686           1 :   ssdcableslay5pconwaterzsection[4] = ssdcableslay5pconzsection[4];
    7687           1 :   ssdcableslay5pconwaterzsection[5] = ssdcableslay5pconzsection[5];
    7688           8 :   for(Int_t i=0; i<2;i++) ssdcableslay5pconwatershape[2]->DefineSection(i,ssdcableslay5pconwaterzsection[i+4],
    7689           2 :                                                   ssdcableslay5pcwateronrmin[i+4],ssdcableslay5pconwaterrmax[i+4]); 
    7690           2 :   ssdcableslay5pconwater[2] = new TGeoVolume("SSDCableLay5RightSidePConWater3",
    7691           1 :                                                            ssdcableslay5pconwatershape[2],fSSDCoolingTubeWater);
    7692           1 :   ssdcableslay5pconwater[2]->SetLineColor(7);
    7693             : ////////////////////////////////////
    7694           1 :   TGeoRotation* ssdcableslay5pconwaterot[4];    
    7695           1 :   TGeoHMatrix* ssdcablesLay5RightPConWaterToLeftMatrix[4];  
    7696          10 :   for(Int_t i=0; i<4; i++){
    7697           8 :    ssdcableslay5pconwaterot[i] = new TGeoRotation();
    7698           4 :    ssdcableslay5pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
    7699           4 :    ssdcablesLay5RightPConWaterToLeftMatrix[i] = 
    7700           8 :         new TGeoHMatrix((*ssdcablesLay5RightPConToLeftRot)*(*ssdcableslay5pconwaterot[i]));
    7701           4 :         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+1,ssdcableslay5pconwaterot[i]);
    7702           4 :         ssdcablesmother->AddNode(ssdcableslay5pconwater[1],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
    7703           4 :         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+1,ssdcableslay5pconwaterot[i]);
    7704           4 :         ssdcablesmother->AddNode(ssdcableslay5pconwater[2],i+5,ssdcablesLay5RightPConWaterToLeftMatrix[i]);
    7705             :   }
    7706             :   /////////////////////////
    7707             :   // SSD Layer 6 Cables
    7708             :   /////////////////////////
    7709           1 :   Double_t ssdcableslay6rigthsideradiusmin = fgkEndCapSupportMiddleRadius[1]+kSSDCablesLay6TubeRadiusMin;  
    7710             :   Double_t ssdcablelay6rightsidelength = 2.; // cm  was 2.*ssdcablelay5rightsidelength;
    7711           1 :   Double_t ssdcableslay6rightsideradiusmax = ssdcableslay6rigthsideradiusmin+kSSDCablesLay6RingArea/ssdcablelay6rightsidelength;
    7712             :   // Printf(Form("Lay 6 cables, length %g, radius %g, thickness %g", ssdcablelay6rightsidelength, ssdcableslay6rigthsideradiusmin, kSSDCablesLay6RingArea/ssdcablelay6rightsidelength));
    7713           1 :   TGeoTube* ssdcablelay6rightubeshape = new TGeoTube(ssdcableslay6rigthsideradiusmin,
    7714             :                                                                                                 ssdcableslay6rightsideradiusmax,
    7715             :                                                                                                 0.5*ssdcablelay6rightsidelength); 
    7716           2 :   TGeoVolume* ssdcablelay6righttube = new TGeoVolume("SSDCableLay6RightSideTube",
    7717           1 :                                                                                                          ssdcablelay6rightubeshape,
    7718           1 :                                                                                                          fSSDCopper);
    7719           1 :   ssdcablelay6righttube->SetLineColor(9);
    7720             :   TGeoTranslation* ssdcablelay6rightrans = 
    7721           2 :                                           new TGeoTranslation(0.,0.,fgkEndCapSupportCenterLay6ITSPosition
    7722           1 :                                                                                  +              fgkEndCapSupportCenterLay6Position
    7723           1 :                                                                                  +      0.5*ssdcablelay6rightsidelength);
    7724           2 :   TGeoTranslation* ssdcablesLay6RightTubeToLeftrans = new TGeoTranslation(0.,0.,
    7725             :                                                                                                         - 0.5*ssdcablelay6rightsidelength
    7726           1 :                                                                                                         - fgkEndCapSupportCenterLay6Position
    7727           1 :                                                                                                     - fgkEndCapSupportCenterLay6ITSPosition);
    7728           1 :   ssdcablesmother->AddNode(ssdcablelay6righttube,1,ssdcablelay6rightrans);
    7729           1 :   ssdcablesmother->AddNode(ssdcablelay6righttube,2,ssdcablesLay6RightTubeToLeftrans);
    7730             :   // Printf(Form("Cables; ring layer 6, volume: %g",ssdcablelay6rightubeshape->Capacity()));
    7731           1 :   totvol += ssdcablelay6rightubeshape->Capacity();
    7732             :   ////////////////////////////////////
    7733             :   //cablescapacity[8] = 2.*ssdcablelay6rightubeshape->Capacity();
    7734             :   ////////////////////////////////////
    7735             :   // MvL: PCon is part of connection to patch panels;
    7736             :   // removed since current volume is too thick; now absorbed in rings+connections
    7737             :   /*
    7738             :   TGeoPcon* ssdcableslay6pconshape = new TGeoPcon(90.0-kSSDCableAngle-0.5*ssdcableangle,
    7739             :                                                                                    ssdcableangle,2);   
    7740             :   TGeoVolume* ssdcableslay6pcon;
    7741             :   Double_t ssdcableslay6pconrmin[2];
    7742             :   Double_t ssdcableslay6pconrmax[2];
    7743             :   Double_t ssdcableslay6pconzsection[2];
    7744             :   ssdcableslay6pconrmin[0] = ssdcableslay6rigthsideradiusmin;
    7745             :   ssdcableslay6pconrmax[0] = ssdcableslay6rightsideradiusmax;
    7746             :   ssdcableslay6pconrmin[1] = ssdcableslay6pconrmin[0];
    7747             :   ssdcableslay6pconrmax[1] = ssdcableslay6pconrmax[0];
    7748             :   ssdcableslay6pconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
    7749             :                                                            + fgkEndCapSupportCenterLay6Position
    7750             :                                                            + ssdcablelay6rightsidelength;
    7751             :   ssdcableslay6pconzsection[1] = ssdcableslay5pconwaterzsection[5];
    7752             :   for(Int_t i=0; i<2;i++) ssdcableslay6pconshape->DefineSection(i,ssdcableslay6pconzsection[i],
    7753             :                                                   ssdcableslay6pconrmin[i],ssdcableslay6pconrmax[i]); 
    7754             :   
    7755             :   ssdcableslay6pcon = new TGeoVolume("SSDCableLay6RightSidePCon",
    7756             :                                                            ssdcableslay6pconshape,fSSDCopper);
    7757             :   ssdcableslay6pcon->SetLineColor(9);
    7758             :   for(Int_t i=0; i<4; i++){
    7759             :    ssdcablesmother->AddNode(ssdcableslay6pcon,i+1,ssdcableslay5pconrot[i]);
    7760             :    ssdcablesmother->AddNode(ssdcableslay6pcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
    7761             :   }
    7762             :   */
    7763             :   ////////////////////////////////////
    7764             :   //cablescapacity[9] = 8.*ssdcableslay6pconshape->Capacity();
    7765             :   /////////////////////////
    7766             :   // Water Tubes Layer 6
    7767             :   /////////////////////////
    7768           2 :   TGeoTube* ssdcablelay6righwatertubeshape = new TGeoTube(ssdcableslay6rightsideradiusmax,
    7769             :                                                                                                                   ssdcableslay6rightsideradiusmax
    7770           1 :                                                                                    +                      kSSDCablesLay5RightSideWaterHeight,
    7771             :                                                                                                                   0.5*ssdcablelay6rightsidelength); 
    7772           2 :   TGeoVolume* ssdcablelay6rightwatertube = new TGeoVolume("SSDCableLay6RightSideWaterTube",
    7773           1 :                                                                                                          ssdcablelay6righwatertubeshape,
    7774           1 :                                                                                                          fSSDCoolingTubeWater);
    7775           1 :   ssdcablelay6rightwatertube->SetLineColor(7);
    7776           1 :   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,1,ssdcablelay6rightrans);
    7777           1 :   ssdcablesmother->AddNode(ssdcablelay6rightwatertube,2,ssdcablesLay6RightTubeToLeftrans);
    7778           1 :   TGeoPcon* ssdcableslay6waterpconshape = new TGeoPcon(90.0-kSSDCableAngle-0.5*ssdcableangle,
    7779             :                                                                                    ssdcableangle,2);   
    7780             :   TGeoVolume* ssdcableslay6waterpcon;
    7781           1 :   Double_t ssdcableslay6waterpconrmin[2];
    7782           1 :   Double_t ssdcableslay6waterpconrmax[2];
    7783           1 :   Double_t ssdcableslay6waterpconzsection[2];
    7784           1 :   ssdcableslay6waterpconrmin[0] = ssdcableslay6rightsideradiusmax;
    7785           1 :   ssdcableslay6waterpconrmax[0] = ssdcableslay6rightsideradiusmax
    7786             :                                                             + kSSDCablesLay5RightSideWaterHeight;
    7787           1 :   ssdcableslay6waterpconrmin[1] = ssdcableslay6waterpconrmin[0];
    7788           1 :   ssdcableslay6waterpconrmax[1] = ssdcableslay6waterpconrmax[0];
    7789           2 :   ssdcableslay6waterpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
    7790           1 :                                                            + fgkEndCapSupportCenterLay6Position
    7791           1 :                                                            + ssdcablelay6rightsidelength;
    7792           1 :   ssdcableslay6waterpconzsection[1] = ssdcableslay5pconwaterzsection[5];
    7793           8 :   for(Int_t i=0; i<2;i++) ssdcableslay6waterpconshape->DefineSection(i,ssdcableslay6waterpconzsection[i],
    7794           2 :                                                   ssdcableslay6waterpconrmin[i],ssdcableslay6waterpconrmax[i]); 
    7795           2 :   ssdcableslay6waterpcon = new TGeoVolume("SSDCableLay6RightSideWaterPCon",
    7796           1 :                                                            ssdcableslay6waterpconshape,fSSDCoolingTubeWater);
    7797           1 :   ssdcableslay6waterpcon->SetLineColor(7);
    7798           1 :   TGeoRotation* ssdcableslay6pconwaterot[4];    
    7799           1 :   TGeoRotation* ssdcablesLay6RightPConToLeftRot = new TGeoRotation();
    7800           1 :   ssdcablesLay6RightPConToLeftRot->SetAngles(90.,180.,-90);
    7801           1 :   TGeoHMatrix* ssdcablesLay6RightPConToLeftMatrix[4];  
    7802          10 :   for(Int_t i=0; i<4; i++){
    7803           8 :    ssdcableslay6pconwaterot[i] = new TGeoRotation();
    7804           4 :    ssdcableslay6pconwaterot[i]->SetAngles(90.0*i+45.0,0.,0.);
    7805          12 :    ssdcablesLay6RightPConToLeftMatrix[i] = new TGeoHMatrix((*ssdcablesLay6RightPConToLeftRot)
    7806           4 :                                                                                  * (*ssdcableslay6pconwaterot[i]));   
    7807           4 :    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+1,ssdcableslay6pconwaterot[i]);
    7808           4 :    ssdcablesmother->AddNode(ssdcableslay6waterpcon,i+5,ssdcablesLay6RightPConToLeftMatrix[i]);
    7809             :   }
    7810             :   ////////////////////////////////////////
    7811             :   // From ITS Ring to Patch Panel3-RB26
    7812             :   ////////////////////////////////////////
    7813           1 :   Double_t ssdcablepatchpanel3BB26radiusmin[2];
    7814           1 :   Double_t ssdcablepatchpanel3BB26radiusmax[2];
    7815           1 :   Double_t ssdcablepatchpanel3RB26zsection[2];
    7816           1 :   ssdcablepatchpanel3BB26radiusmin[0] = ssdcableslay5pconrmin[3]-0.5*kSSDPatchPanelHeight;// +2.8+0.003;//Avoid small overlap with SPDshieldring;
    7817           1 :   ssdcablepatchpanel3BB26radiusmax[0] = ssdcablepatchpanel3BB26radiusmin[0]
    7818           1 :                                         + kSSDCablesHeight;
    7819           1 :   ssdcablepatchpanel3BB26radiusmin[1] = kSSDPatchPanel2RB26Radius;
    7820           1 :   ssdcablepatchpanel3BB26radiusmax[1] = ssdcablepatchpanel3BB26radiusmin[1]
    7821           1 :                                         + kSSDCablesHeight;
    7822           2 :   ssdcablepatchpanel3RB26zsection[0] = 0.5*fgkSSDCentralSupportLength
    7823           1 :                                         + fgkSSDCentralAL3SupportLength
    7824           1 :                                                                                  + fgkSSDPConeZLength[0];
    7825           1 :   ssdcablepatchpanel3RB26zsection[1] = kSSDPatchPanel2RB26ITSDistance;  
    7826             :   // Printf(Form("RB26 cable length %g",ssdcablepatchpanel3RB26zsection[1]-ssdcablepatchpanel3RB26zsection[0]));
    7827             :   // Printf(Form("Angular range %g",ssdcableangle));
    7828             : 
    7829             :   TGeoPcon* ssdcablepatchpanel3RB26pconshape = 
    7830           2 :                                                                 new TGeoPcon(90.0-kSSDCablesPatchPanel2RB26Angle[0]
    7831           1 :                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
    7832           8 :   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB26pconshape->DefineSection(i,ssdcablepatchpanel3RB26zsection[i],
    7833           2 :                                                   ssdcablepatchpanel3BB26radiusmin[i],ssdcablepatchpanel3BB26radiusmax[i]); 
    7834           2 :   TGeoVolume* ssdcablepatchpanel3RB26pcon = new TGeoVolume("SSDCablePatchPanel3RB26",
    7835           1 :                                                                                                 ssdcablepatchpanel3RB26pconshape,fSSDCopper);
    7836           1 :   ssdcablepatchpanel3RB26pcon->SetLineColor(9);
    7837           1 :   TGeoRotation* ssdcablepatchpanel3B26rot[4];
    7838          14 :   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B26rot[i] = new TGeoRotation();
    7839           1 :   ssdcablepatchpanel3B26rot[0]->SetAngles(0.0,0.0,0.0);
    7840           1 :   ssdcablepatchpanel3B26rot[1]->SetAngles(kSSDCablesPatchPanel2RB26Angle[0]
    7841             :                                           + kSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
    7842           1 :   ssdcablepatchpanel3B26rot[2]->SetAngles(180.0,0.0,0.0);
    7843           1 :   ssdcablepatchpanel3B26rot[3]->SetAngles(180.0 + kSSDCablesPatchPanel2RB26Angle[0]
    7844             :                                                 + kSSDCablesPatchPanel2RB26Angle[1]+6.0,0.0,0.0);
    7845          10 :   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB26pcon,i+1,ssdcablepatchpanel3B26rot[i]);
    7846             :   // Printf(Form("Cable to patch panels RB26 volume: %g (x4)",ssdcablepatchpanel3RB26pcon->Capacity()));
    7847             :   ////////////////////////////////////
    7848             :   //cablescapacity[10] = 4.*ssdcablepatchpanel3RB26pconshape->Capacity();
    7849             :   ////////////////////////////////////////
    7850             :   //  ITS Ring Cables RB26 Part
    7851             :   ////////////////////////////////////////
    7852           1 :   Double_t ssdcableitsring3BB26pconzsection[2];
    7853           1 :   Double_t ssdcableitsring3BB26pconrmin[2];
    7854           1 :   Double_t ssdcableitsring3BB26pconrmax[2];
    7855           2 :   ssdcableitsring3BB26pconzsection[0] = 0.5*fgkSSDCentralSupportLength
    7856           1 :                                                                           + fgkSSDCentralAL3SupportLength
    7857           1 :                                                                           + (4.0/5.0)*fgkSSDPConeZLength[0];
    7858           1 :   ssdcableitsring3BB26pconzsection[1] = ssdcablepatchpanel3RB26zsection[0];
    7859           1 :   ssdcableitsring3BB26pconrmin[0] = fgkSSDPConeUpRadius-0.5*kSSDPatchPanelHeight;
    7860           1 :   ssdcableitsring3BB26pconrmax[0] = ssdcableitsring3BB26pconrmin[0] + 2.5*kSSDCablesHeight; // widths of cable bunch is about half of patch panels; need factor 2.5
    7861             : 
    7862           1 :   ssdcableitsring3BB26pconrmin[1] = ssdcablepatchpanel3BB26radiusmin[0];
    7863           1 :   ssdcableitsring3BB26pconrmax[1] = ssdcablepatchpanel3BB26radiusmax[0];
    7864           1 :   TGeoPcon* ssdcableitsring3BB26pconshape[4];
    7865           3 :   ssdcableitsring3BB26pconshape[0] = new TGeoPcon(90.0 - kSSDCablesPatchPanel2RB26Angle[0]
    7866             :                                                                    -              0.5*ssdcableangle,ssdcableangle
    7867           1 :                                                                    +                            (kSSDCablesPatchPanel2RB26Angle[0]
    7868             :                                                                    -                             kSSDCableAngle),2);
    7869           3 :   ssdcableitsring3BB26pconshape[1] = new TGeoPcon(90.0 + kSSDCablesPatchPanel2RB26Angle[1]
    7870           1 :                                                                    -              0.5*ssdcableangle,ssdcableangle
    7871           1 :                                                                    +                      3.0*kSSDCableAngle
    7872           1 :                                                                    -                      kSSDCablesPatchPanel2RB26Angle[1],2);
    7873           3 :   ssdcableitsring3BB26pconshape[2] = new TGeoPcon(270-kSSDCablesPatchPanel2RB26Angle[0]
    7874           1 :                                                                    -              0.5*ssdcableangle,ssdcableangle
    7875           1 :                                                                    -                      kSSDCableAngle
    7876           1 :                                                                    +                      kSSDCablesPatchPanel2RB26Angle[0],2);
    7877           3 :   ssdcableitsring3BB26pconshape[3] = new TGeoPcon(270.0+kSSDCablesPatchPanel2RB26Angle[1]
    7878           1 :                                                                    -              0.5*ssdcableangle,ssdcableangle
    7879             :                                                                    +                      3.0*kSSDCableAngle
    7880             :                                                                    -                      kSSDCablesPatchPanel2RB26Angle[1],2);
    7881          10 :   for(Int_t i=0;i<4;i++)
    7882          32 :         for(Int_t j=0; j<2; j++) ssdcableitsring3BB26pconshape[i]->DefineSection(j,ssdcableitsring3BB26pconzsection[j],
    7883           8 :                                                          ssdcableitsring3BB26pconrmin[j],
    7884           8 :                                                          ssdcableitsring3BB26pconrmax[j]); 
    7885           1 :   TGeoVolume* ssdcableitsring3BB26pcon[4];
    7886           3 :   ssdcableitsring3BB26pcon[0] = new TGeoVolume("SSDCableITSRing3RB26Part1",
    7887           1 :                                                                                                 ssdcableitsring3BB26pconshape[0],fSSDCopper);
    7888           3 :   ssdcableitsring3BB26pcon[1] = new TGeoVolume("SSDCableITSRing3RB26Part2",
    7889           1 :                                                                                                 ssdcableitsring3BB26pconshape[1],fSSDCopper);
    7890           3 :   ssdcableitsring3BB26pcon[2] = new TGeoVolume("SSDCableITSRing3RB26Part3",
    7891           1 :                                                                                                 ssdcableitsring3BB26pconshape[2],fSSDCopper);
    7892           3 :   ssdcableitsring3BB26pcon[3] = new TGeoVolume("SSDCableITSRing3RB26Part4",
    7893           1 :                                                                                                 ssdcableitsring3BB26pconshape[3],fSSDCopper);
    7894          10 :   for(Int_t i=0;i<4;i++){
    7895           4 :         ssdcableitsring3BB26pcon[i]->SetLineColor(9);
    7896           4 :         ssdcablesmother->AddNode(ssdcableitsring3BB26pcon[i],1);
    7897             :         //Printf(Form("Cable to patch panels RB26 volume part 2: %g (%d)",ssdcableitsring3BB26pcon[i]->Capacity(),i));
    7898             : }
    7899             : 
    7900             :   ////////////////////////////////////
    7901             :   //cablescapacity[11] = ssdcableitsring3BB26pconshape[0]->Capacity()
    7902             :   //                             + ssdcableitsring3BB26pconshape[1]->Capacity() 
    7903             :   //                             + ssdcableitsring3BB26pconshape[2]->Capacity() 
    7904             :   //                             + ssdcableitsring3BB26pconshape[3]->Capacity(); 
    7905             :   ////////////////////////////////////////
    7906             :   // From ITS Ring to Patch Panel2-RB24
    7907             :   ////////////////////////////////////////
    7908           1 :   Double_t ssdcablepatchpanel3BB24radiusmin[2];
    7909           1 :   Double_t ssdcablepatchpanel3BB24radiusmax[2];
    7910           1 :   Double_t ssdcablepatchpanel3RB24zsection[2];
    7911           1 :   ssdcablepatchpanel3BB24radiusmin[0] = ssdcablepatchpanel3BB26radiusmin[0];
    7912           1 :   ssdcablepatchpanel3BB24radiusmax[0] = ssdcablepatchpanel3BB26radiusmax[0];
    7913           1 :   ssdcablepatchpanel3BB24radiusmin[1] = kSSDPatchPanel2RB24Radius;
    7914           1 :   ssdcablepatchpanel3BB24radiusmax[1] = ssdcablepatchpanel3BB24radiusmin[1]
    7915             :                                         + kSSDCablesHeight;
    7916           2 :   ssdcablepatchpanel3RB24zsection[0] = -0.5*fgkSSDCentralSupportLength
    7917           1 :                                                                          -  fgkSSDCentralAL3SupportLength
    7918           1 :                                                                          -  fgkSSDPConeZLength[0];
    7919           1 :   ssdcablepatchpanel3RB24zsection[1] = -kSSDPatchPanel2RB24ITSDistance;  
    7920             :   //Printf(Form("RB24 cable length %g",ssdcablepatchpanel3RB24zsection[1]-ssdcablepatchpanel3RB24zsection[0]));
    7921             :   TGeoPcon* ssdcablepatchpanel3RB24pconshape = 
    7922           2 :                                                                 new TGeoPcon(90.0-kSSDCablesPatchPanel2RB24Angle[1]
    7923           1 :                                                                                                 - 0.5*ssdcableangle,ssdcableangle,2);   
    7924           8 :   for(Int_t i=0; i<2;i++) ssdcablepatchpanel3RB24pconshape->DefineSection(i,ssdcablepatchpanel3RB24zsection[i],
    7925           2 :                                                   ssdcablepatchpanel3BB24radiusmin[i],ssdcablepatchpanel3BB24radiusmax[i]); 
    7926           2 :   TGeoVolume* ssdcablepatchpanel3RB24pcon = new TGeoVolume("SSDCablePatchPanel3RB24",
    7927           1 :                                                                                                 ssdcablepatchpanel3RB24pconshape,
    7928           1 :                                                                                                 fSSDCopper);
    7929           1 :   ssdcablepatchpanel3RB24pcon->SetLineColor(9);
    7930           1 :   TGeoRotation* ssdcablepatchpanel3B24rot[4];
    7931          14 :   for(Int_t i=0; i<4; i++) ssdcablepatchpanel3B24rot[i] = new TGeoRotation();
    7932           1 :   ssdcablepatchpanel3B24rot[0]->SetAngles(-6.0,0.0,0.0);
    7933           1 :   ssdcablepatchpanel3B24rot[1]->SetAngles(kSSDCablesPatchPanel2RB24Angle[0]
    7934             :                                           + kSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
    7935           1 :   ssdcablepatchpanel3B24rot[2]->SetAngles(174.0,0.0,0.0);
    7936           1 :   ssdcablepatchpanel3B24rot[3]->SetAngles(180.0+kSSDCablesPatchPanel2RB24Angle[0]
    7937             :                                           + kSSDCablesPatchPanel2RB24Angle[1],0.0,0.0);
    7938          10 :   for(Int_t i=0; i<4; i++) ssdcablesmother->AddNode(ssdcablepatchpanel3RB24pcon,i+1,ssdcablepatchpanel3B24rot[i]);
    7939             :   //Printf(Form("Cable to patch panels RB24 volume: %g (x4)",ssdcablepatchpanel3RB24pcon->Capacity()));
    7940             :   ////////////////////////////////////
    7941             :   //cablescapacity[12] = 4.*ssdcablepatchpanel3RB24pconshape->Capacity();
    7942             :   ////////////////////////////////////////
    7943             :   //  ITS Ring Cables RB24 Part
    7944             :   ////////////////////////////////////////
    7945           1 :   Double_t ssdcableitsring3BB24pconzsection[2];
    7946           1 :   Double_t ssdcableitsring3BB24pconrmin[2];
    7947           1 :   Double_t ssdcableitsring3BB24pconrmax[2];
    7948           1 :   ssdcableitsring3BB24pconzsection[0] = -ssdcableitsring3BB26pconzsection[0];
    7949           1 :   ssdcableitsring3BB24pconzsection[1] = ssdcablepatchpanel3RB24zsection[0];
    7950           1 :   ssdcableitsring3BB24pconrmin[0] = fgkSSDPConeUpRadius-0.5*kSSDPatchPanelHeight;
    7951           1 :   ssdcableitsring3BB24pconrmax[0] = ssdcableitsring3BB24pconrmin[0] + 2.5*kSSDCablesHeight;  // Cable bunch width smaller; make it thicker
    7952             : 
    7953           1 :   ssdcableitsring3BB24pconrmin[1] = ssdcablepatchpanel3BB24radiusmin[0];
    7954           1 :   ssdcableitsring3BB24pconrmax[1] = ssdcablepatchpanel3BB24radiusmax[0];
    7955           1 :   TGeoPcon* ssdcableitsring3BB24pconshape[4];
    7956           3 :   ssdcableitsring3BB24pconshape[0] = new TGeoPcon(kSSDCableAngle-0.5*ssdcableangle,ssdcableangle
    7957           1 :                                                                + (90.0-kSSDCablesPatchPanel2RB24Angle[1]
    7958             :                                                                    - kSSDCableAngle),2);
    7959           3 :   ssdcableitsring3BB24pconshape[1] = new TGeoPcon(90.0+kSSDCableAngle-0.5*ssdcableangle,
    7960             :                                                                      ssdcableangle-kSSDCableAngle
    7961           1 :                                                                    + kSSDCablesPatchPanel2RB24Angle[0],2);
    7962           3 :   ssdcableitsring3BB24pconshape[2] = new TGeoPcon(180.0+kSSDCableAngle-0.5*ssdcableangle,ssdcableangle
    7963             :                                                                    - kSSDCableAngle
    7964           1 :                                                                    + 90.0 - kSSDCablesPatchPanel2RB24Angle[1],2);
    7965           2 :   ssdcableitsring3BB24pconshape[3] = new TGeoPcon(270.0+kSSDCableAngle-0.5*ssdcableangle,
    7966             :                                                                    ssdcableangle-kSSDCableAngle
    7967             :                                                                    + kSSDCablesPatchPanel2RB24Angle[0],2);
    7968          10 :   for(Int_t i=0;i<4;i++)
    7969          32 :         for(Int_t j=0; j<2; j++) ssdcableitsring3BB24pconshape[i]->DefineSection(j,ssdcableitsring3BB24pconzsection[j],
    7970           8 :                                                          ssdcableitsring3BB24pconrmin[j],
    7971           8 :                                                          ssdcableitsring3BB24pconrmax[j]); 
    7972           1 :   TGeoVolume* ssdcableitsring3BB24pcon[4];
    7973           3 :   ssdcableitsring3BB24pcon[0] = new TGeoVolume("SSDCableITSRing3RB24Part1",
    7974           1 :                                                                                                 ssdcableitsring3BB24pconshape[0],fSSDCopper);
    7975           3 :   ssdcableitsring3BB24pcon[1] = new TGeoVolume("SSDCableITSRing3RB24Part2",
    7976           1 :                                                                                                 ssdcableitsring3BB24pconshape[1],fSSDCopper);
    7977           3 :   ssdcableitsring3BB24pcon[2] = new TGeoVolume("SSDCableITSRing3RB24Part3",
    7978           1 :                                                                                                 ssdcableitsring3BB24pconshape[2],fSSDCopper);
    7979           3 :   ssdcableitsring3BB24pcon[3] = new TGeoVolume("SSDCableITSRing3RB24Part4",
    7980           1 :                                                                                                 ssdcableitsring3BB24pconshape[3],fSSDCopper);
    7981          10 :   for(Int_t i=0;i<4;i++){
    7982           4 :         ssdcableitsring3BB24pcon[i]->SetLineColor(9);
    7983           4 :         ssdcablesmother->AddNode(ssdcableitsring3BB24pcon[i],1);
    7984             :         // Printf(Form("Cable to patch panels RB24 (part 2) volume: %g (%d)",ssdcableitsring3BB24pcon[i]->Capacity(),i));
    7985             : }
    7986             : 
    7987             :   ////////////////////////////////////
    7988             :   //cablescapacity[13] = ssdcableitsring3BB24pconshape[0]->Capacity()
    7989             :   //                                     + ssdcableitsring3BB24pconshape[1]->Capacity()
    7990             :   //                                     + ssdcableitsring3BB24pconshape[2]->Capacity()
    7991             :   //                                     + ssdcableitsring3BB24pconshape[3]->Capacity();
    7992             : 
    7993             :   // MvL: Pcon are connection to patch panels (part of)
    7994             :   // Removed; do not contribute much; put into ring structure
    7995             :   /*
    7996             :   TGeoPcon* ssdcablelay6materialbudgetpconshape = 
    7997             :                                         new TGeoPcon(90.0-kSSDCableAngle-0.5*ssdcableangle,ssdcableangle,2); 
    7998             :   TGeoVolume* ssdcablelay6materialbudgetpcon;
    7999             :   Double_t ssdcablelay6materialbudgetpconrmin[2];
    8000             :   Double_t ssdcablelay6materialbudgetpconrmax[2];
    8001             :   Double_t ssdcablelay6materialbudgetpconzsection[2];
    8002             :   ssdcablelay6materialbudgetpconrmin[0] = ssdcableslay6rightsideradiusmax
    8003             :                                                                                 + kSSDCablesLay5RightSideWaterHeight;
    8004             :   ssdcablelay6materialbudgetpconrmax[0] = ssdcablelay6materialbudgetpconrmin[0]
    8005             :                                                                                 + kSSDCableMaterialBudgetHeight;
    8006             :   ssdcablelay6materialbudgetpconrmin[1] = ssdcablelay6materialbudgetpconrmin[0];
    8007             :   ssdcablelay6materialbudgetpconrmax[1] = ssdcablelay6materialbudgetpconrmax[0];
    8008             :   ssdcablelay6materialbudgetpconzsection[0] = fgkEndCapSupportCenterLay6ITSPosition
    8009             :                                                                                         + fgkEndCapSupportCenterLay6Position
    8010             :                                                                                         + ssdcablelay6rightsidelength;
    8011             :   ssdcablelay6materialbudgetpconzsection[1] = ssdcableslay5pconwaterzsection[5];
    8012             :   for(Int_t i=0; i<2;i++) ssdcablelay6materialbudgetpconshape->DefineSection(i,
    8013             :                                                   ssdcablelay6materialbudgetpconzsection[i],
    8014             :                                                   ssdcablelay6materialbudgetpconrmin[i],
    8015             :                                                   ssdcablelay6materialbudgetpconrmax[i]); 
    8016             :   ssdcablelay6materialbudgetpcon = new TGeoVolume("SSDCableLay6MaterialBudgetPCon",
    8017             :                                                            ssdcablelay6materialbudgetpconshape,fSSDCopper);
    8018             :   ssdcablelay6materialbudgetpcon->SetLineColor(9);
    8019             :   for(Int_t i=0; i<4; i++){
    8020             :    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+1,ssdcableslay5pconrot[i]);
    8021             :    ssdcablesmother->AddNode(ssdcablelay6materialbudgetpcon,i+5,ssdcablesLay5RightPConToLeftMatrix[i]);
    8022             :   }
    8023             :   */
    8024             : ////////////////////////////////////
    8025             :  /* cablescapacity[14] = 2.*ssdcablelay6materialbudgetubeshape->Capacity();
    8026             :   cablescapacity[15] = 2.*ssdcablelay6materialbudgetpconshape->Capacity();
    8027             :   Double_t ssdcablesvolume = 0.0;
    8028             :   for(Int_t i=0;i<16;i++) ssdcablesvolume+=cablescapacity[i];
    8029             :   std::cout << ssdcablesvolume << std::endl;*/
    8030             :   // Printf(Form("Total volume (one side; without conn to patch panel): %g",totvol));
    8031             : 
    8032           1 :   ssdcablesmother->GetShape()->ComputeBBox(); //RS: enforce recompting of BBox
    8033           1 :   return ssdcablesmother;
    8034           1 :  }
    8035             :  ////////////////////////////////////////////////////////////////////////////////
    8036             : TGeoArb8* AliITSv11GeometrySSD::GetArbShape(TVector3 const * const vertexpos[4] , const Double_t* width, 
    8037             :                                             Double_t height, const char* shapename, Int_t isign) const{
    8038             :   /////////////////////////////////////////////////////////////
    8039             :   // Method generating an Arb shape 
    8040             :   /////////////////////////////////////////////////////////////
    8041             :   const Int_t kvertexnumber = 8;
    8042             :   const Int_t ktransvectnumber = 2;
    8043         108 :   TVector3 vertex[kvertexnumber];
    8044          30 :   TVector3 transvector[2];
    8045          36 :   for(Int_t i=0; i<ktransvectnumber; i++) transvector[i].SetY(width[i]);
    8046             :   /////////////////////////////////////////////////////////////
    8047             :   //Setting the vertices for TGeoArb8
    8048             :   /////////////////////////////////////////////////////////////
    8049           6 :   vertex[0] = *vertexpos[0];
    8050           6 :   vertex[1] = *vertexpos[1];
    8051           6 :   vertex[2] = vertex[1]; 
    8052           6 :   vertex[3] = vertex[0]; 
    8053           6 :   vertex[4] = *vertexpos[2];
    8054           6 :   vertex[5] = *vertexpos[3];
    8055           6 :   vertex[6] = vertex[5];
    8056           6 :   vertex[7] = vertex[4];
    8057             : 
    8058             :   // NB: order of points is clockwise
    8059           6 :   if (isign < 0) {
    8060           1 :     vertex[2] -= transvector[0];
    8061           1 :     vertex[3] -= transvector[0];
    8062           1 :     vertex[6] -= transvector[1];
    8063           1 :     vertex[7] -= transvector[1];
    8064           1 :   }
    8065             :   else {
    8066           5 :     vertex[0] += transvector[0];
    8067           5 :     vertex[1] += transvector[0];
    8068           5 :     vertex[4] += transvector[1];
    8069           5 :     vertex[5] += transvector[1];
    8070             :   }
    8071             : 
    8072             :   /////////////////////////////////////////////////////////////
    8073          12 :   TGeoArb8* arbshape = new TGeoArb8(shapename,0.5*height);
    8074         108 :   for(Int_t i = 0; i<kvertexnumber;i++) {
    8075          48 :     arbshape->SetVertex(i,vertex[i].X(),vertex[i].Y());
    8076             :   }
    8077             : 
    8078             :   return arbshape;
    8079          78 : } 
    8080             : ///////////////////////////////////////////////////////////////////////////////
    8081             : TGeoXtru* AliITSv11GeometrySSD::GetArcShape(Double_t phi, Double_t rmin, 
    8082             :                                                                 Double_t rmax, Int_t nedges, Double_t height){
    8083             :   /////////////////////////////////////////////////////////////
    8084             :   // Method generating Arc shape 
    8085             :   /////////////////////////////////////////////////////////////
    8086           2 :         const Int_t kvertexnumber = 2*nedges+2;
    8087           1 :         TGeoXtru* arcshape = new TGeoXtru(2);   
    8088           1 :         TVector3** vertexposition[2];
    8089           6 :         for(Int_t i=0; i<2; i++) vertexposition[i] = new TVector3*[nedges+1];
    8090             :         Double_t angle = 0.;
    8091           8 :     for(Int_t i=0; i<nedges+1; i++){ 
    8092           3 :                 angle = 90.+0.5*phi-i*(phi/nedges);
    8093          12 :                 vertexposition[0][i] = new TVector3(rmin*CosD(angle),rmin*SinD(angle),0);
    8094          12 :                 vertexposition[1][i] = new TVector3(rmax*CosD(angle),rmax*SinD(angle),0);
    8095             :         }
    8096           1 :         Double_t *xvertexpoints = new Double_t[kvertexnumber];
    8097           1 :         Double_t *yvertexpoints = new Double_t[kvertexnumber];
    8098          14 :         for(Int_t i=0; i<kvertexnumber; i++){ 
    8099           7 :                 if(i==0){ xvertexpoints[i] = vertexposition[0][i]->X(),
    8100           1 :                                   yvertexpoints[i] = vertexposition[0][i]->Y();      
    8101           1 :                 }
    8102          10 :                 else if(i>=1&&i<nedges+2)
    8103             :                 {
    8104           3 :                         xvertexpoints[i] = vertexposition[1][i-1]->X(); 
    8105           3 :                         yvertexpoints[i] = vertexposition[1][i-1]->Y(); 
    8106           3 :                 }
    8107             :         else
    8108             :                 {
    8109           2 :                         xvertexpoints[i] = vertexposition[0][kvertexnumber-i]->X(); 
    8110           2 :                         yvertexpoints[i] = vertexposition[0][kvertexnumber-i]->Y(); 
    8111             :                 }
    8112             :     }
    8113           1 :   arcshape->DefinePolygon(kvertexnumber,xvertexpoints,yvertexpoints);
    8114           1 :   arcshape->DefineSection(0,-0.5*height);
    8115           1 :   arcshape->DefineSection(1,0.5*height);
    8116             :   /////////////////////////////////////////////////////////////
    8117             :   // Deallocating memory
    8118             :   /////////////////////////////////////////////////////////////
    8119           6 :   for(Int_t i=0; i<2; i++){
    8120          16 :         for(Int_t j=0; j<nedges+1; j++)
    8121          12 :                 delete vertexposition[i][j];
    8122           4 :         delete [] vertexposition[i];
    8123             :   }
    8124           2 :   delete [] xvertexpoints;
    8125           2 :   delete [] yvertexpoints;
    8126             :   /////////////////////////////////////////////////////////////
    8127           1 :         return arcshape;
    8128           1 : }
    8129             : ////////////////////////////////////////////////////////////////////////////////
    8130             : TGeoShape* AliITSv11GeometrySSD::GetScrewShape(const Double_t* radius,const Int_t* edgesnumber,const Double_t* section) const {
    8131             :   ///////////////////////////////////////////////////////////////////////
    8132             :   // Method Generating the Screw Shape  
    8133             :   // radius[0]: outer radius
    8134             :   // radius[1]: inner radius
    8135             :   // edgesnumber[0]: outer number of edges
    8136             :   // edgesnumber[1]: inner number of edges
    8137             :   // section[0]: lower section position
    8138             :   // section[1]: higher section position
    8139             :   ///////////////////////////////////////////////////////////////////////
    8140           4 :   Double_t outradius = radius[0];
    8141           2 :   Double_t inradius = radius[1];
    8142           2 :   Int_t outvertexnumber = edgesnumber[0];
    8143           2 :   Int_t invertexnumber = edgesnumber[1];
    8144           2 :   Double_t* xscrewvertex = new Double_t[outvertexnumber+invertexnumber];
    8145           2 :   Double_t* yscrewvertex = new Double_t[outvertexnumber+invertexnumber];
    8146         144 :   for(Int_t i=0; i<outvertexnumber; i++){
    8147          70 :         xscrewvertex[i] = outradius*CosD(90.+i*360./outvertexnumber);
    8148          70 :         yscrewvertex[i] = outradius*SinD(90.+i*360./outvertexnumber);
    8149             :   }
    8150          56 :   for(Int_t i=0; i<invertexnumber; i++){
    8151          26 :         xscrewvertex[outvertexnumber+i] = inradius*CosD(90.+i*360./invertexnumber);
    8152          26 :         yscrewvertex[outvertexnumber+i] = inradius*SinD(90.+i*360./invertexnumber);
    8153             :   }
    8154           2 :   TGeoXtru* screwshapeout = new TGeoXtru(2);
    8155           2 :   screwshapeout->DefinePolygon(outvertexnumber,xscrewvertex,yscrewvertex);
    8156           2 :   screwshapeout->DefineSection(0,section[0]);
    8157           2 :   screwshapeout->DefineSection(1,section[1]);
    8158           2 :   TGeoXtru* screwshapein = new TGeoXtru(2);
    8159           2 :   screwshapein->DefinePolygon(invertexnumber,&xscrewvertex[outvertexnumber],&yscrewvertex[outvertexnumber]);
    8160           2 :   screwshapein->DefineSection(0,section[0]-0.01); // make inner part bigger in Z
    8161           2 :   screwshapein->DefineSection(1,section[1]+0.01); // safer when we subtract it
    8162           2 :   TGeoSubtraction *snode = new TGeoSubtraction(screwshapeout, screwshapein);
    8163           2 :   TGeoCompositeShape *screwshape = new TGeoCompositeShape("", snode);
    8164             :   
    8165           4 :   delete [] xscrewvertex;
    8166           4 :   delete [] yscrewvertex;
    8167           2 :   return screwshape;
    8168           0 : }
    8169             : ////////////////////////////////////////////////////////////////////////////////
    8170             : TGeoShape* AliITSv11GeometrySSD::GetHoleShape(Double_t radius, Int_t nedges, const Double_t *section) const {
    8171             :   ///////////////////////////////////////////////////////////////////////
    8172             :   // Method Generating the Hole Shape  
    8173             :   // radius of the Hole
    8174             :   // nedges: number of edges to approximate the circle
    8175             :   ///////////////////////////////////////////////////////////////////////
    8176           4 :   Double_t* xholevertex = new Double_t[nedges];
    8177           2 :   Double_t* yholevertex = new Double_t[nedges];
    8178           2 :   Double_t z  = 0.5*(section[0]+section[1]);
    8179           2 :   Double_t dz = 0.5*(section[1]-section[0]);
    8180             :   TGeoTranslation *tr = 0;
    8181           2 :   if (TMath::Abs(z) > TGeoShape::Tolerance()) {
    8182           0 :      tr = new TGeoTranslation(0.,0.,z);
    8183           0 :      tr->RegisterYourself();
    8184           0 :   }   
    8185           2 :   TGeoBBox *box = new TGeoBBox("",radius,radius,dz);
    8186         124 :   for(Int_t i=0; i<nedges; i++){
    8187          60 :         xholevertex[i] = radius*CosD(i*360./nedges);
    8188          60 :         yholevertex[i] = radius*SinD(i*360./nedges);
    8189             :   }
    8190           2 :   TGeoXtru* holeshapeout = new TGeoXtru(2);
    8191           2 :   holeshapeout->DefinePolygon(nedges,xholevertex,yholevertex);
    8192           2 :   holeshapeout->DefineSection(0,section[0]-0.01); // make subtracted part larger in Z
    8193           2 :   holeshapeout->DefineSection(1,section[1]+0.01);
    8194           2 :   TGeoSubtraction *snode = new TGeoSubtraction(box,holeshapeout,tr);
    8195           2 :   TGeoCompositeShape *holeshape = new TGeoCompositeShape("", snode);
    8196             :   
    8197           4 :   delete [] xholevertex;
    8198           4 :   delete [] yholevertex;
    8199           2 :   return holeshape;
    8200           0 : }
    8201             : ////////////////////////////////////////////////////////////////////////////////
    8202             : TVector3* AliITSv11GeometrySSD::GetReflection(const TVector3* vector,const Double_t* param) const{
    8203             :   /////////////////////////////////////////////////////////////
    8204             :   // Given an axis specified by param, it gives the reflection of the point
    8205             :   // respect to the axis
    8206             :   /////////////////////////////////////////////////////////////
    8207          52 :   TVector3* n = new TVector3(param[0],param[1],param[2]);
    8208          26 :   Double_t d = ((*vector)*(*n)+param[3])/n->Mag2();
    8209          78 :   TVector3* reflectedvector = new TVector3(*vector-2*d*(*n));
    8210             :   /////////////////////////////////////////////////////////////
    8211             :   // Deallocating memory
    8212             :   /////////////////////////////////////////////////////////////
    8213          52 :   delete n;
    8214             :   /////////////////////////////////////////////////////////////
    8215          26 :   return reflectedvector;
    8216           0 : }
    8217             : ////////////////////////////////////////////////////////////////////////////////
    8218             : TGeoHMatrix* AliITSv11GeometrySSD::AddTranslationToHMatrix(const TGeoHMatrix* ct,
    8219             :                                                        Double_t dx,
    8220             :                                                        Double_t dy,
    8221             :                                                        Double_t dz) const{
    8222             :   /////////////////////////////////////////////////////////////
    8223             :   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
    8224             :   /////////////////////////////////////////////////////////////
    8225           8 :   TGeoHMatrix* hmatrix = new TGeoHMatrix(*ct);
    8226           4 :   const Double_t *vect = hmatrix->GetTranslation();
    8227           4 :   Double_t newvect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
    8228           4 :   hmatrix->SetTranslation(newvect);
    8229           4 :   TGeoHMatrix* matrix = new TGeoHMatrix(*hmatrix);
    8230           8 :   delete hmatrix;
    8231           4 :   return matrix;
    8232           4 : }
    8233             : ////////////////////////////////////////////////////////////////////////////////
    8234             : TGeoMedium* AliITSv11GeometrySSD::GetMedium(const char* mediumName) {
    8235             :   /////////////////////////////////////////////////////////////
    8236             :   // Method returning the Medium type 
    8237             :   /////////////////////////////////////////////////////////////
    8238          56 :   char ch[100];
    8239          28 :   snprintf(ch,100, "ITS_%s",mediumName);
    8240          28 :   TGeoMedium* medium =  gGeoManager->GetMedium(ch);
    8241          28 :   if (! medium)
    8242           0 :     AliError(Form("medium %s not found !\n", mediumName));
    8243          28 :   return medium;
    8244          28 : }
    8245             : ////////////////////////////////////////////////////////////////////////////////
    8246             : void AliITSv11GeometrySSD::CreateMaterials(){
    8247             : ///////////////////////////////////
    8248             : // This part has to be modified
    8249             : ///////////////////////////////////
    8250             :   ///////////////////////////////////
    8251             :   // Silicon for Sensor
    8252             :   /////////////////////////////////// 
    8253           2 :   fSSDSensorMedium = GetMedium("SI$");
    8254             :   ///////////////////////////////////
    8255             :   // Silicon Mixture for Sensor
    8256             :   /////////////////////////////////// 
    8257           1 :   fSSDChipMedium = GetMedium("SPD SI CHIP$");
    8258           1 :   fSSDChipGlueMedium = GetMedium("EPOXY$");
    8259             :   ///////////////////////////////////
    8260             :   // Stiffener Components Materials
    8261             :   /////////////////////////////////// 
    8262           1 :   fSSDStiffenerMedium = GetMedium("SDD C AL (M55J)$");
    8263             :   ///////////////////////////  
    8264             :   // Stiffener Connectors 
    8265             :   ///////////////////////////  
    8266           1 :   fSSDStiffenerConnectorMedium = GetMedium("COPPER$");
    8267             :   ////////////////////////////////  
    8268             :   // Stiffener 0603-1812 Capacitor
    8269             :   ////////////////////////////////  
    8270           1 :   fSSDStiffener0603CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
    8271           1 :   fSSDStiffener1812CapacitorMedium = GetMedium("SDD ruby sph. Al2O3$");
    8272           1 :   fSSDStiffenerCapacitorCapMedium = GetMedium("NiSn$");
    8273             :   ///////////////////////////  
    8274             :   // Stiffener Hybrid Wire 
    8275             :   ///////////////////////////  
    8276           1 :   fSSDStiffenerHybridWireMedium = GetMedium("COPPER$");
    8277             :   ///////////////////////////  
    8278             :   // Al for Cooling Block
    8279             :   ///////////////////////////  
    8280           1 :   fSSDAlCoolBlockMedium = GetMedium("AL$");
    8281             :   //////////////////////////////////////////////////////  
    8282             :   // Kapton and Al for Chip Cable Flex and Ladder Cables
    8283             :   //////////////////////////////////////////////////////  
    8284           1 :   fSSDKaptonChipCableMedium = GetMedium("KAPTONH(POLYCH2)$");
    8285           1 :   fSSDAlTraceChipCableMedium = GetMedium("AL$");
    8286           1 :   fSSDKaptonFlexMedium = GetMedium("KAPTONH(POLYCH2)$");
    8287           1 :   fSSDAlTraceFlexMedium = GetMedium("AL$");
    8288           1 :   fSSDKaptonLadderCableMedium = GetMedium("KAPTONH(POLYCH2)$");
    8289           1 :   fSSDAlTraceLadderCableMedium = GetMedium("AL$");
    8290             :   /////////////////////////////////////////////////////////////////  
    8291             :   // M55J for Carbon Fiber, CarbonFiber Lower Support and Junction
    8292             :   //////////////////////////////////////////////////////////////////  
    8293           1 :   fSSDCarbonFiberMedium = GetMedium("GEN C (M55J)$");
    8294             :   /////////////////////////////////////////////////////////////////  
    8295             :   // G10 for Detector Leg, TubeHolder
    8296             :   //////////////////////////////////////////////////////////////////  
    8297           1 :   fSSDTubeHolderMedium = GetMedium("G10FR4$");
    8298           1 :   fSSDSensorSupportMedium = GetMedium("G10FR4$");
    8299           1 :   fSSDMountingBlockMedium = GetMedium("G10FR4$");
    8300           1 :   fSSDMountingBlockMedium = GetMedium("G10FR4$");
    8301             :   /////////////////////////////////////////////////////////////////  
    8302             :   // Water and Phynox for Cooling Tube
    8303             :   //////////////////////////////////////////////////////////////////  
    8304           1 :   fSSDCoolingTubeWater = GetMedium("WATER$");
    8305           1 :   fSSDCoolingTubePhynox = GetMedium("INOX$");
    8306             :   /////////////////////////////////////////////////////////////////////
    8307             :   // Material for Support Rings
    8308             :   /////////////////////////////////////////////////////////////////////
    8309           1 :   fSSDSupportRingAl = GetMedium("AL$");
    8310           1 :   fSSDRohaCellCone = GetMedium("ROHACELL$");
    8311             :   /////////////////////////////////////////////////////////////////////
    8312           1 :   fSSDAir = GetMedium("SDD AIR$");
    8313           1 :   fSSDCopper = GetMedium("COPPER$");
    8314           1 :   fSSDSn = GetMedium("Sn$");
    8315           1 :   fCreateMaterials = kTRUE;
    8316           1 : }
    8317             : /////////////////////////////////////////////////////////////////////
    8318             : 

Generated by: LCOV version 1.11