]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11GeometrySDD.cxx
bugfix in copy constructor
[u/mrichter/AliRoot.git] / ITS / AliITSv11GeometrySDD.cxx
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 //*************************************************************************
17 // SDD geometry, based on ROOT geometrical modeler
18 //
19 // Ludovic Gaudichet (Ludovic.Gaudichet@to.infn.it)
20 //*************************************************************************
21
22
23 #include <stdio.h>
24 #include <stdlib.h>
25
26 // General Root includes
27 #include <Riostream.h>
28 #include <TMath.h>
29
30 // Root Geometry includes
31 #include <TGeoManager.h>
32 #include <TGeoVolume.h>
33 #include <TGeoPcon.h>
34 #include <TGeoCone.h>
35 #include <TGeoTube.h>
36 #include <TGeoArb8.h>
37 #include <TGeoCompositeShape.h>
38 #include <TGeoMatrix.h>
39 #include <TGeoMaterial.h>
40 #include <TGeoMedium.h>
41
42 #include "AliITSv11Geometry.h"
43 #include "AliITSv11GeometrySDD.h"
44
45
46
47 ClassImp(AliITSv11GeometrySDD)
48
49
50 AliITSv11GeometrySDD::AliITSv11GeometrySDD():AliITSv11Geometry() {
51   fAddOnlyLadder3 = -1;
52   fAddOnlyLadder4 = -1;
53   fAddOnlySegment = 0;
54   SetGeomParameters();
55 };
56 //----------------------------------------------------------------------
57 AliITSv11GeometrySDD::AliITSv11GeometrySDD(Int_t debug):AliITSv11Geometry(debug) {
58   fAddOnlyLadder3 = -1;
59   fAddOnlyLadder4 = -1;
60   fAddOnlySegment = 0;
61   SetGeomParameters();
62 };
63 //----------------------------------------------------------------------
64 void AliITSv11GeometrySDD::SetGeomParameters() {
65
66   fSegmentLength       = 37.2*2*fgkmm;
67   fLadderWidth         = 50.0*fgkmm;
68   fLadderHeight        = 30.0*fgkmm;
69   fLadderBeamRadius    =  0.6*fgkmm;
70   fLadderLa            =  3.*fgkmm;
71   fLadderHa            =  0.6*fgkmm; //total pifometer
72   fLadderLb            =  3.7*fgkmm;
73   fLadderHb            =  0.6*fgkmm; //total pifometer
74   fLadderl             =  0.25*fgkmm;
75
76   fBottomBeamAngle     = 56.5;
77   fBeamSidePhi         = 65;
78
79   fWaferThickness      = 0.3*fgkmm;
80   fWaferWidth          = 72.5*fgkmm;
81   fWaferLength         = 87.6*fgkmm;
82
83   fHybridLength        = (37.2*2-15)*fgkmm; //total pifometer
84   fHybridWidth         = 35*fgkmm; //total pifometer
85
86   fLadWaferSep         = 2*fgkmm;
87   fPinSuppWidth        = 2.5*fgkmm; // pifometer
88   fPinSuppHeight       = 2.*fgkmm; // pifometer
89   fPinSuppRmax         = 2.5/2.*fgkmm;
90   fPinR                = 1.5/2.*fgkmm;
91   fPinSuppLength       = 5.*fgkmm;
92   fPinSuppThickness    = 0.5*fgkmm;
93   fPinSuppConeAngle    = 4;
94
95   fLay3Rmin            = 130.*fgkmm; //not min! Rmin virtual tube
96   fLay3Rmax            = 190.*fgkmm; //not min! Rmax virtual tube
97   fLay3Length          = (524.+0.)*fgkmm; // ladder+supporting rings (length of the virtual tube)
98   fLay3LadderLength    = 524.*fgkmm;
99   fLay3DetShortRadius  = 146.0*fgkmm;
100   fLay3DetLongRadius   = 152.0*fgkmm;
101   fLay3LaddShortRadius = fLay3DetShortRadius-fLadderBeamRadius+(8-1)*fgkmm; // radius from the center to the CF ladder
102   fLay3LaddLongRadius  = fLay3DetLongRadius-fLadderBeamRadius+(8-1)*fgkmm; // radius from the center to the CF ladder
103   fLay3LaddTopCornerEnd = 15.6*fgkmm;
104   fLay3Ndet            = 6;
105   fLay3Nladd           = 14;
106   
107   fLay4Rmin            = 220.*fgkmm; //not min! Rmin virtual tube
108   fLay4Rmax            = 290.*fgkmm; //not min! Rmax virtual tube
109   fLay4Length          = (671.+0.)*fgkmm; // ladder+supporting rings (length of the virtual tube)
110   fLay4LadderLength    = 671.*fgkmm;
111   fLay4DetShortRadius  = 235.0*fgkmm;
112   fLay4DetLongRadius   = 240.5*fgkmm;
113   fLay4LaddShortRadius = fLay4DetShortRadius-fLadderBeamRadius+(8-1)*fgkmm; // radius from the center to the CF ladder
114   fLay4LaddLongRadius  = fLay4DetLongRadius-fLadderBeamRadius+(8-1)*fgkmm;  // radius from the center to the CF ladder
115   fLay4LaddTopCornerEnd = 15.6*fgkmm;
116   fLay4Ndet            = 8;
117   fLay4Nladd           = 22;
118
119   for (Int_t i=0; i<fLay3Ndet; i++)
120     fLay3sensorZPos[i] = -fSegmentLength*fLay3Ndet/2.+fSegmentLength/2.+i*fSegmentLength;
121
122   for (Int_t i=0; i<fLay4Ndet; i++)
123     fLay4sensorZPos[i] = -fSegmentLength*fLay4Ndet/2.+fSegmentLength/2.+i*fSegmentLength;
124
125 };
126 //________________________________________________________________________
127 TGeoCombiTrans *AliITSv11GeometrySDD::
128 CreateCombiTrans(const char *name, Double_t dy, Double_t dz, Double_t dphi) {
129     //
130     // return the TGeoCombiTrans which make a translation in y and z
131     // and a rotation in phi in the global coord system
132     //
133
134     TGeoTranslation t1(dy*CosD(90.+dphi),dy*SinD(90.+dphi), dz);
135     TGeoRotation r1("",0.,0.,dphi);
136
137     TGeoCombiTrans *combiTrans1 = new TGeoCombiTrans(name);
138     combiTrans1->SetTranslation(t1);
139     combiTrans1->SetRotation(r1);
140     return combiTrans1;
141 };
142 //________________________________________________________________________
143 void AliITSv11GeometrySDD::AddTranslationTotCombiTrans(TGeoCombiTrans* ct,
144                                                        Double_t dx,
145                                                        Double_t dy,
146                                                        Double_t dz) {
147     // Add a dx,dy,dz translation to the initial TGeoCombiTrans
148     const Double_t *vect = ct->GetTranslation();
149     Double_t newVect[3];
150     newVect[0] = vect[0]+dx; 
151     newVect[1] = vect[1]+dy; 
152     newVect[2] = vect[2]+dz;
153     ct->SetTranslation(newVect);
154 };
155 //________________________________________________________________________
156 void AliITSv11GeometrySDD::Layer3(TGeoVolume *Moth) {
157     // Insert the layer 3 in the mother volume. This is a virtual volume
158     // containing ladders of layer 3 and the supporting rings
159
160     TGeoTube *virtualLayer3Shape = new TGeoTube("ITSsddLayer3Shape",
161                                        fLay3Rmin,fLay3Rmax,fLay3Length*0.5);
162     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
163     TGeoVolume *virtualLayer3 = new TGeoVolume("ITSsddLayer3",
164                                                virtualLayer3Shape, airSDD);
165     TGeoVolume *lay3Ladder = CreateLay3Ladder();
166     TGeoVolume *lay3Detectors = CreateLay3Detectors();
167
168     Double_t dPhi = 360./fLay3Nladd;
169     Double_t detBoxThickness = fLadWaferSep + 2*fWaferThickness;
170     // placing virtual ladder and detectors volumes following ladder 
171     // ordering convention
172     char rotName[20];
173     Int_t iLaddMin = 0;
174     Int_t iLaddMax = fLay3Nladd;
175     if ((fAddOnlyLadder3>=0)&&(fAddOnlyLadder3<fLay3Nladd)) {
176         iLaddMin = fAddOnlyLadder3;
177         iLaddMax = fAddOnlyLadder3+1;
178     }
179     for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
180         sprintf(rotName, "ITSsddLay3Ladd%i",iLadd);
181         Double_t minRadiusLadBox = fLay3LaddShortRadius;
182         if (iLadd%2 != 0) minRadiusLadBox = fLay3LaddLongRadius;
183         minRadiusLadBox += ((TGeoBBox*)lay3Ladder->GetShape())->GetDY();
184         
185         TGeoCombiTrans *ctLadd = CreateCombiTrans(rotName,minRadiusLadBox,0,
186                                                   -90+iLadd*dPhi);
187         virtualLayer3->AddNode(lay3Ladder,iLadd,ctLadd);
188         sprintf(rotName, "ITSsddLay3DetBox%i",iLadd);
189         Double_t minRadiusDetBox = fLay3DetShortRadius;
190         if (iLadd%2 != 0) minRadiusDetBox = fLay3DetLongRadius;
191         minRadiusDetBox += detBoxThickness/2;
192         TGeoCombiTrans *ctDet = CreateCombiTrans(rotName, minRadiusDetBox,0,
193                                                  -90+iLadd*dPhi);
194         virtualLayer3->AddNode(lay3Detectors, iLadd, ctDet);
195     }
196     virtualLayer3->SetVisibility(kFALSE);
197     Moth->AddNode(virtualLayer3,1,0);
198 };
199 //________________________________________________________________________
200 TGeoVolume *AliITSv11GeometrySDD::CreateLay3Ladder() {
201     // return a box volume containing the CF ladder
202     TGeoVolume *laddSegment = CreateLadderSegment();
203     TGeoBBox *ladBox = new TGeoBBox("ITSsddLadBox",
204                                ((TGeoBBox*)laddSegment->GetShape())->GetDX(),
205                                ((TGeoBBox*)laddSegment->GetShape())->GetDY(),
206                                     //dX,dY = dX,dY of the segment
207                                fLay3LadderLength/2);  
208     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
209     TGeoVolume *virtualLadder = new TGeoVolume("ITSsddLadder",ladBox, airSDD);
210     Double_t segmentLength = fSegmentLength;
211     char transName[20];
212     // placing virtual ladder segment following detector ordering convention
213     //=======================================================================
214     Int_t iSegmentMin = 1;
215     Int_t iSegmentMax = fLay3Ndet;
216     if (fAddOnlySegment) {
217         iSegmentMin = fAddOnlySegment;
218         iSegmentMax = fAddOnlySegment;
219     }
220     for (Int_t iSegment = iSegmentMin; iSegment <= iSegmentMax; iSegment++ ) {
221         sprintf(transName, "ITSsddLay3LaddSeg%i", iSegment);
222         Double_t segmentPos = segmentLength*(3-iSegment) + segmentLength/2;
223         TGeoTranslation *segTr = new TGeoTranslation(transName,0,0,segmentPos);
224         virtualLadder->AddNode(laddSegment, iSegment, segTr);
225     }
226     // putting virtual volume corresponding to the end of ladder
227     //=======================================================================
228     Double_t endLength = (fLay3LadderLength-fLay3Ndet*fSegmentLength)/2.;
229     TGeoVolume *endLadder = CreateEndLadder( endLength );
230     TGeoTranslation *endTrZPos = new TGeoTranslation("ITSsddEndTrZPos",0,0,
231                                    fSegmentLength*(fLay3Ndet/2)+endLength/2.);
232     //Euler rotation : about Z, then new X, then new Z
233     TGeoRotation *endZNegRot = new TGeoRotation("",90, 180, -90);
234     TGeoCombiTrans *endTrZNeg = new TGeoCombiTrans(0,0,
235                     -fSegmentLength*(fLay3Ndet/2)-endLength/2., endZNegRot);
236     if ((fAddOnlySegment==0)||(fAddOnlySegment==1))
237         virtualLadder->AddNode(endLadder, 1, endTrZPos);
238     if ((fAddOnlySegment==0)||(fAddOnlySegment==fLay3Ndet))
239         virtualLadder->AddNode(endLadder, 2, endTrZNeg);
240     virtualLadder->SetVisibility(kFALSE);
241     return virtualLadder;
242 };
243 //________________________________________________________________________
244 TGeoArb8 *AliITSv11GeometrySDD::CreateLadderSide(Double_t dz,Double_t angle,
245                           Double_t xSign,Double_t L, Double_t H, Double_t l) {
246     // Create one half of the V shape corner of CF ladder
247   
248     TGeoArb8 *cfLaddSide = new TGeoArb8(dz);
249     cfLaddSide->SetVertex(0, 0,0);
250     cfLaddSide->SetVertex(1, 0, -H);
251     cfLaddSide->SetVertex(2,xSign*(L*TMath::Sin(angle)-l*TMath::Cos(angle)),
252                           -L*TMath::Cos(angle)-l*TMath::Sin(angle));
253     cfLaddSide->SetVertex(3,xSign*L*TMath::Sin(angle),-L*TMath::Cos(angle));
254     cfLaddSide->SetVertex(4, 0,0);
255     cfLaddSide->SetVertex(5, 0, -H);
256     cfLaddSide->SetVertex(6,xSign*(L*TMath::Sin(angle)-l*TMath::Cos(angle)),
257                           -L*TMath::Cos(angle)-l*TMath::Sin(angle));
258     cfLaddSide->SetVertex(7,xSign*L*TMath::Sin(angle),-L*TMath::Cos(angle));
259     return cfLaddSide;
260 };
261 //________________________________________________________________________
262 void AliITSv11GeometrySDD::AddLadderCFstruct(Double_t dy, TGeoVolume* vol) {
263     // fill a volume (segment) with the CF structure of a ladder
264
265     TGeoMedium *carbonFiberLadderStruct = gGeoManager->GetMedium(
266                                                         "ITSsddCarbonFiber");
267     Double_t segmentLength = fSegmentLength;
268     Double_t triangleHeight = fLadderHeight - fLadderBeamRadius;
269     Double_t halfTheta = TMath::ATan( 0.5*fLadderWidth/triangleHeight );
270     Double_t beta = (TMath::Pi()-2.*halfTheta)/4.;
271     Double_t alpha = TMath::Pi()*3./4. - halfTheta/2.;
272     Int_t colorCarbonFiber = 4;
273
274     //--- The 3 V shape corners of the Carbon Fiber Ladder
275     //--- the top V
276     TGeoArb8 *cfLaddTop1 = CreateLadderSide(segmentLength/2., halfTheta, -1,
277                                             fLadderLa, fLadderHa, fLadderl);
278     TGeoVolume *cfLaddTopVol1 = new TGeoVolume("ITSsddCFladdTopCornerVol1",
279                                            cfLaddTop1,carbonFiberLadderStruct);
280     cfLaddTopVol1->SetLineColor(colorCarbonFiber);
281     TGeoArb8 *cfLaddTop2 = CreateLadderSide(segmentLength/2., halfTheta, 1,
282                                             fLadderLa, fLadderHa, fLadderl);
283     TGeoVolume *cfLaddTopVol2 = new TGeoVolume("ITSsddCFladdTopCornerV2",
284                                            cfLaddTop2,carbonFiberLadderStruct);
285     cfLaddTopVol2->SetLineColor(colorCarbonFiber);
286     TGeoTranslation *trTop1 = new TGeoTranslation(0, fLadderHeight/2+dy, 0);
287     vol->AddNode(cfLaddTopVol1, 1, trTop1);
288     vol->AddNode(cfLaddTopVol2, 1, trTop1);
289     //--- the 2 side V
290     TGeoArb8 *cfLaddSide1 = CreateLadderSide( segmentLength/2., beta, -1,
291                                               fLadderLb, fLadderHb, fLadderl);
292     TGeoVolume *cfLaddSideVol1 = new TGeoVolume("ITSsddCFladdSideCornerV1",
293                                          cfLaddSide1,carbonFiberLadderStruct);
294     cfLaddSideVol1->SetLineColor(colorCarbonFiber);
295     TGeoArb8 *cfLaddSide2 = CreateLadderSide( segmentLength/2., beta, 1,
296                                               fLadderLb, fLadderHb, fLadderl);
297     TGeoVolume *cfLaddSideVol2 = new TGeoVolume("ITSsddCFladdSideCornerV2",
298                                          cfLaddSide2,carbonFiberLadderStruct);
299     cfLaddSideVol2->SetLineColor(colorCarbonFiber);
300
301     Double_t dYTranslation = fLadderHeight/2. - 
302                       0.5*fLadderWidth*TMath::Tan(beta) - fLadderBeamRadius;
303     // because center of the triangle doesn't correspond to virtual vol. center
304     Double_t distCenterSideDown =  0.5*fLadderWidth/TMath::Cos(beta);
305     TGeoCombiTrans *ctSideR = CreateCombiTrans("", distCenterSideDown, 0,
306                                                alpha*TMath::RadToDeg());
307     AddTranslationTotCombiTrans(ctSideR, 0, -dYTranslation+dy, 0);
308     TGeoCombiTrans *ctSideL = CreateCombiTrans("", distCenterSideDown,0,
309                                                -alpha*TMath::RadToDeg());
310     AddTranslationTotCombiTrans(ctSideL, 0, -dYTranslation+dy, 0);
311     vol->AddNode(cfLaddSideVol1, 1, ctSideR);
312     vol->AddNode(cfLaddSideVol2, 1, ctSideR);
313     vol->AddNode(cfLaddSideVol1, 2, ctSideL);
314     vol->AddNode(cfLaddSideVol2, 2, ctSideL);
315     //--- The beams
316     // Beams on the sides
317     Double_t beamPhiPrime = TMath::ASin(1./TMath::Sqrt( (1+TMath::Sin(2*beta)*
318                 TMath::Sin(2*beta)/(TanD(fBeamSidePhi)*TanD(fBeamSidePhi))) ));
319     if(GetDebug(1)) cout<<"Phi prime = "<<beamPhiPrime*TMath::RadToDeg()<<endl;
320     Double_t beamLength = TMath::Sqrt( fLadderHeight*fLadderHeight/
321                            (TMath::Sin(beamPhiPrime)*TMath::Sin(beamPhiPrime))
322                                +fLadderWidth*fLadderWidth/4.)-fLadderLa/2-fLadderLb/2;
323     TGeoTubeSeg *sideBeam = new TGeoTubeSeg(0,fLadderBeamRadius,beamLength/2.,
324                                           0, 180);
325     TGeoVolume *cfSideBeamVol = new TGeoVolume("ITSsddCFSideBeamVol", sideBeam,
326                                                carbonFiberLadderStruct);
327     cfSideBeamVol->SetLineColor(colorCarbonFiber);
328     //Euler rotation : about Z, then new X, then new Z
329     TGeoRotation *beamRot1 = new TGeoRotation("",90-2.*beta*TMath::RadToDeg(),
330                                          -beamPhiPrime*TMath::RadToDeg(),-90);
331     TGeoCombiTrans *beamTransf1 = new TGeoCombiTrans(0.5*triangleHeight*
332     TMath::Tan(halfTheta),fLadderBeamRadius/2.+dy,-3*segmentLength/8,beamRot1);
333     TGeoCombiTrans *beamTransf2 = new TGeoCombiTrans(0.5*triangleHeight*
334        TMath::Tan(halfTheta),fLadderBeamRadius/2.+dy,segmentLength/8,beamRot1);
335     TGeoRotation *beamRot2 = new TGeoRotation("",90-2.*beta*TMath::RadToDeg(),
336                                             beamPhiPrime*TMath::RadToDeg(), -90);
337     TGeoCombiTrans *beamTransf3 = new TGeoCombiTrans(0.5*triangleHeight*
338      TMath::Tan(halfTheta),fLadderBeamRadius/2.+dy,-segmentLength/8,beamRot2);
339     TGeoCombiTrans *beamTransf4 = new TGeoCombiTrans(0.5*triangleHeight*
340      TMath::Tan(halfTheta),fLadderBeamRadius/2.+dy,3*segmentLength/8,beamRot2);
341     TGeoRotation *beamRot3 = new TGeoRotation("",90+2.*beta*TMath::RadToDeg(),
342                                             beamPhiPrime*TMath::RadToDeg(), -90);
343     TGeoCombiTrans *beamTransf5 = new TGeoCombiTrans(-0.5*triangleHeight*
344                                 TMath::Tan(halfTheta),fLadderBeamRadius/2.+dy,
345                                               -3*segmentLength/8,beamRot3);
346     TGeoCombiTrans *beamTransf6 = new TGeoCombiTrans(-0.5*triangleHeight*
347        TMath::Tan(halfTheta),fLadderBeamRadius/2.+dy,segmentLength/8,beamRot3);
348     TGeoRotation *beamRot4 = new TGeoRotation("",90+2.*beta*TMath::RadToDeg(),
349                                             -beamPhiPrime*TMath::RadToDeg(), -90);
350     TGeoCombiTrans *beamTransf7 = new TGeoCombiTrans(-0.5*triangleHeight*
351       TMath::Tan(halfTheta),fLadderBeamRadius/2.+dy,-segmentLength/8,beamRot4);
352     TGeoCombiTrans *beamTransf8 = new TGeoCombiTrans(-0.5*triangleHeight*
353      TMath::Tan(halfTheta),fLadderBeamRadius/2.+dy,3*segmentLength/8,beamRot4);
354
355     vol->AddNode(cfSideBeamVol, 1, beamTransf1);
356     vol->AddNode(cfSideBeamVol, 2, beamTransf2);
357     vol->AddNode(cfSideBeamVol, 3, beamTransf3);
358     vol->AddNode(cfSideBeamVol, 4, beamTransf4);
359     vol->AddNode(cfSideBeamVol, 5, beamTransf5);
360     vol->AddNode(cfSideBeamVol, 6, beamTransf6);
361     vol->AddNode(cfSideBeamVol, 7, beamTransf7);
362     vol->AddNode(cfSideBeamVol, 8, beamTransf8);
363     //--- Beams of the bottom
364     TGeoTubeSeg *bottomBeam1 = new TGeoTubeSeg(0, fLadderBeamRadius,
365                                              fLadderWidth/2.-fLadderLb/3, 0, 180);
366     TGeoVolume *bottomBeam1Vol = new TGeoVolume("ITSsddBottomBeam1Vol",
367                                      bottomBeam1, carbonFiberLadderStruct);
368     bottomBeam1Vol->SetLineColor(colorCarbonFiber);
369
370     TGeoRotation *bottomBeamRot1 = new TGeoRotation("",90, 90, 90);
371     TGeoCombiTrans *bottomBeamTransf1 = new TGeoCombiTrans(0,
372                     -(fLadderHeight/2-fLadderBeamRadius)+dy,0, bottomBeamRot1);
373     vol->AddNode(bottomBeam1Vol, 1, bottomBeamTransf1);
374     TGeoTubeSeg *bottomBeam2 = new TGeoTubeSeg(0, fLadderBeamRadius,
375                                                        fLadderWidth/2.-fLadderLb/3, 0, 90);
376     TGeoVolume *bottomBeam2Vol = new TGeoVolume("ITSsddBottomBeam2Vol",
377                                 bottomBeam2, carbonFiberLadderStruct);
378     bottomBeam2Vol->SetLineColor(colorCarbonFiber);
379     TGeoCombiTrans *bottomBeamTransf2 = new TGeoCombiTrans(0,
380                                      -(fLadderHeight/2-fLadderBeamRadius)+dy,
381                                      -segmentLength/2, bottomBeamRot1);
382     TGeoRotation *bottomBeamRot2 = new TGeoRotation("",-90, 90, -90);
383     TGeoCombiTrans *bottomBeamTransf3 = new TGeoCombiTrans(0,
384                                     -(fLadderHeight/2-fLadderBeamRadius)+dy,
385                                                          segmentLength/2, bottomBeamRot2);
386     vol->AddNode(bottomBeam2Vol, 1, bottomBeamTransf2);
387     vol->AddNode(bottomBeam2Vol, 2, bottomBeamTransf3);
388     TGeoTubeSeg *bottomBeam3 = new TGeoTubeSeg(0, fLadderBeamRadius,
389                             0.5*fLadderWidth/SinD(fBottomBeamAngle)-fLadderLb/3,0,180);
390     TGeoVolume *bottomBeam3Vol = new TGeoVolume("ITSsddBottomBeam3Vol",
391                   bottomBeam3, carbonFiberLadderStruct);
392     bottomBeam3Vol->SetLineColor(colorCarbonFiber);
393     //bottomBeam3Vol->SetLineColor(2);
394     // be careful on the next 2 beams : when "reading" from -z to +z and 
395     // from the bottom of the ladder,
396     // it should draw a Lambda, and not a V
397     TGeoRotation *bottomBeamRot4 = new TGeoRotation("", -90, fBottomBeamAngle,
398                                                     -90);
399     TGeoCombiTrans *bottomBeamTransf4 = new TGeoCombiTrans(0, 
400       -(fLadderHeight/2-fLadderBeamRadius)+dy,-segmentLength/4,bottomBeamRot4);
401     TGeoRotation *bottomBeamRot5 = new TGeoRotation("",-90,-fBottomBeamAngle,
402                                                     -90);
403     TGeoCombiTrans *bottomBeamTransf5 = new TGeoCombiTrans(0,
404      -(fLadderHeight/2-fLadderBeamRadius)+dy,segmentLength/4, bottomBeamRot5);
405     vol->AddNode(bottomBeam3Vol, 1, bottomBeamTransf4);
406     vol->AddNode(bottomBeam3Vol, 2, bottomBeamTransf5);
407 };
408 //________________________________________________________________________
409 TGeoVolume* AliITSv11GeometrySDD::CreateHybrid() {
410     // return a box containing the front-end hybrid
411     TGeoBBox *hybridBox = new TGeoBBox("ITSsddHybridBox",fHybridWidth/2,0.3/2,
412                                        fHybridLength/2); // <===== 0.3 tempo
413     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
414     TGeoVolume *VirtualHybrid =new TGeoVolume("ITSsddHybrid",hybridBox,airSDD);
415
416     VirtualHybrid->SetVisibility(kFALSE);
417     return VirtualHybrid;
418 };
419 //________________________________________________________________________
420 TGeoVolume* AliITSv11GeometrySDD::CreateLadderSegment() {
421     // Return a box volume containing a segment of a ladder.
422
423     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
424
425     Double_t tDY = -0.5; //space left on top of the ladder
426     Double_t segmentLength = fSegmentLength;
427
428     TGeoBBox *segBox = new TGeoBBox("ITSsddSegBox",
429                                     (fLadderWidth+fPinSuppWidth)/2,
430                                     fLadderHeight/2+TMath::Abs(tDY),
431                                     segmentLength/2);
432     TGeoVolume *VirtualSeg = new TGeoVolume("ITSsddSegment",segBox, airSDD);
433     // the carbon fiber structure :
434     AddLadderCFstruct(tDY, VirtualSeg);
435     // the 2 hybrids :
436     TGeoVolume *Hybrid = CreateHybrid();
437     Double_t hybDx = ((TGeoBBox*)Hybrid->GetShape())->GetDX();
438     Double_t hybDy = ((TGeoBBox*)Hybrid->GetShape())->GetDY();
439     Double_t halfDiag = TMath::Sqrt(hybDx*hybDx+hybDy*hybDy);
440     Double_t theta = 50;  //angle in the transverse plane of hybrids 
441     // laying on the CF structure  // <========== 50° tempo
442     Double_t thetaPrim = theta*TMath::DegToRad()+TMath::ATan(hybDy/hybDx);
443     TGeoRotation *HybridRot1 = new TGeoRotation("",   90-theta, 0, 0);
444     TGeoRotation *HybridRot2 = new TGeoRotation("", -(90-theta), 0, 0);
445     Double_t hybZ = 0;
446     Double_t hybY = fLadderHeight/2-halfDiag*TMath::Cos(thetaPrim)+tDY;
447     Double_t hybX = halfDiag*TMath::Sin(thetaPrim);
448     TGeoCombiTrans *HybTransf1 = new TGeoCombiTrans(-hybX,hybY,hybZ,
449                                                     HybridRot1);
450     VirtualSeg->AddNode(Hybrid, 1, HybTransf1);
451     TGeoCombiTrans *HybTransf2 = new TGeoCombiTrans(hybX,hybY,hybZ,HybridRot2);
452     VirtualSeg->AddNode(Hybrid, 2, HybTransf2);
453     //**********************************
454     TGeoVolume *pinSupport = CreatePinSupport(0);
455     VirtualSeg->AddNode(pinSupport, 1, 0);
456     VirtualSeg->SetVisibility(kFALSE);
457     return VirtualSeg;
458 };
459 //________________________________________________________________________
460 TGeoVolume* AliITSv11GeometrySDD::CreatePinSupport(Double_t rotY) {
461     //medium = ryton ? To code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
462
463     TGeoMedium *rytonSDD = gGeoManager->GetMedium("ITSsddStaselite4411w");
464     TGeoCone *cone = new TGeoCone("ITSsddPinSuppCone",fPinSuppHeight/2.,
465                                   0,fPinSuppRmax,0,fPinSuppRmax-
466                                   fPinSuppHeight*TanD(fPinSuppConeAngle) );
467     TGeoBBox *tong = new TGeoBBox("ITSsddPinSuppTong",fPinSuppRmax,
468                                   fPinSuppLength/2.,fPinSuppThickness/2.);
469     TGeoTube *hole = new TGeoTube("ITSsddPinSuppHole",0,fPinR,
470                                   fPinSuppHeight/2.);
471     rotY = 0.0; // Remove compiler warning.
472     if(GetDebug(3)){
473         cone->InspectShape();
474         tong->InspectShape();
475         hole->InspectShape();
476     }
477
478     TGeoTranslation *tongTrans = new TGeoTranslation("ITSsddPinSuppTongTr",0,
479                    fPinSuppLength/2.,-fPinSuppHeight/2.+fPinSuppThickness/2.);
480     tongTrans->RegisterYourself();
481     TGeoCompositeShape *pinSupportShape = new TGeoCompositeShape(
482                "ITSssdPinSupportShape","(ITSsddPinSuppCone+"
483                "ITSsddPinSuppTong:ITSsddPinSuppTongTr)-ITSsddPinSuppHole");
484
485     TGeoVolume *pinSupport = new TGeoVolume("ITSssdPinSupport",pinSupportShape,
486                                             rytonSDD);
487     return pinSupport;
488     // include the pin itself !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
489     // le centre de rotation, translation est le centre du cone
490     // (puisque celui-ci n'a pas bouger dans la composition)
491 };
492 //________________________________________________________________________
493 TGeoVolume* AliITSv11GeometrySDD::CreateEndLadder(Double_t length) {
494     // Return a box volume containing a end of a CF ladder.
495     Double_t tDY = -0.5; //space left on top of the ladder
496     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
497     TGeoMedium *carbonFiberLadderStruct = gGeoManager->GetMedium(
498                                                        "ITSsddCarbonFiber");
499     Double_t segmentLength = fSegmentLength;
500     Double_t topCornerLength = fSegmentLength/2.-fLay4LaddTopCornerEnd;
501
502     TGeoBBox *endBox = new TGeoBBox("ITSsddEndLaddBox",
503                                     //(fLadderWidth+fPinSuppWidth)/2,
504                                     (fLadderWidth)/2,
505                                     fLadderHeight/2+TMath::Abs(tDY),
506                                     length/2);
507     TGeoVolume *virtualEnd = new TGeoVolume("ITSsddEnd",endBox, airSDD);
508     //**********************************
509     // coding real matter :
510     //**********************************
511     Double_t triangleHeight = fLadderHeight - fLadderBeamRadius;
512     Double_t halfTheta = TMath::ATan( 0.5*fLadderWidth/triangleHeight );
513     Double_t beta = (TMath::Pi()-2.*halfTheta)/4.;
514     Double_t alpha = TMath::Pi()*3./4. - halfTheta/2.;
515     Int_t colorCarbonFiber = 4;
516     //--- The 3 V shape corners of the Carbon Fiber Ladder
517     //--- the top V
518     TGeoArb8 *cfLaddTop1 = CreateLadderSide( topCornerLength/2., halfTheta, -1,
519                                              fLadderLa, fLadderHa, fLadderl);
520     TGeoVolume *cfLaddTopVol1 = new TGeoVolume("ITSsddCFladdTopCornerVol1",
521                                           cfLaddTop1,carbonFiberLadderStruct);
522     cfLaddTopVol1->SetLineColor(colorCarbonFiber);
523     TGeoArb8 *cfLaddTop2 = CreateLadderSide( topCornerLength/2., halfTheta, 1,
524                                              fLadderLa, fLadderHa, fLadderl);
525     TGeoVolume *cfLaddTopVol2 = new TGeoVolume("ITSsddCFladdTopCornerV2",
526                                         cfLaddTop2,carbonFiberLadderStruct);
527     cfLaddTopVol2->SetLineColor(colorCarbonFiber);
528     TGeoTranslation *trTop1 = new TGeoTranslation(0, fLadderHeight/2+tDY,
529                                                -(length-topCornerLength)/2.);
530     virtualEnd->AddNode(cfLaddTopVol1, 1, trTop1);
531     virtualEnd->AddNode(cfLaddTopVol2, 1, trTop1);
532     //--- the 2 side V
533     TGeoArb8 *cfLaddSide1 = CreateLadderSide( length/2., beta, -1,
534                                               fLadderLb, fLadderHb, fLadderl);
535     TGeoVolume *cfLaddSideVol1 = new TGeoVolume("ITSsddCFladdSideCornerV1",
536                                           cfLaddSide1,carbonFiberLadderStruct);
537     cfLaddSideVol1->SetLineColor(colorCarbonFiber);
538     TGeoArb8 *cfLaddSide2 = CreateLadderSide( length/2., beta, 1,
539                                               fLadderLb, fLadderHb, fLadderl);
540     TGeoVolume *cfLaddSideVol2 = new TGeoVolume("ITSsddCFladdSideCornerV2",
541                                           cfLaddSide2,carbonFiberLadderStruct);
542     cfLaddSideVol2->SetLineColor(colorCarbonFiber);
543     Double_t dYTranslation = ( fLadderHeight/2. - 0.5*fLadderWidth*
544                                TMath::Tan(beta)- fLadderBeamRadius );
545     // because center of the triangle doesn't correspond to virtual vol. center
546     Double_t distCenterSideDown =  0.5*fLadderWidth/TMath::Cos(beta);
547     TGeoCombiTrans *ctSideR = CreateCombiTrans("", distCenterSideDown, 0,
548                                                alpha*TMath::RadToDeg());
549     AddTranslationTotCombiTrans(ctSideR, 0, -dYTranslation+tDY, 0);
550     TGeoCombiTrans *ctSideL = CreateCombiTrans("", distCenterSideDown, 0, 
551                                                -alpha*TMath::RadToDeg());
552     AddTranslationTotCombiTrans(ctSideL, 0, -dYTranslation+tDY, 0);
553     virtualEnd->AddNode(cfLaddSideVol1, 1, ctSideR);
554     virtualEnd->AddNode(cfLaddSideVol2, 1, ctSideR);
555     virtualEnd->AddNode(cfLaddSideVol1, 2, ctSideL);
556     virtualEnd->AddNode(cfLaddSideVol2, 2, ctSideL);
557     //--- The beams
558     // Beams on the sides
559     Double_t beamPhiPrime = TMath::ASin(1./TMath::Sqrt( (1+TMath::Sin(2*beta)*
560                 TMath::Sin(2*beta)/(TanD(fBeamSidePhi)*TanD(fBeamSidePhi))) ));
561     if(GetDebug(3)) cout<<"Phi prime = "<<beamPhiPrime*TMath::RadToDeg()<<endl;
562      Double_t beamLength = TMath::Sqrt( fLadderHeight*fLadderHeight/
563                                      (TMath::Sin(beamPhiPrime)*TMath::Sin(beamPhiPrime))
564                                    +fLadderWidth*fLadderWidth/4.)-fLadderLa/2-fLadderLb/2;
565      TGeoTubeSeg *sideBeam = new TGeoTubeSeg(0, fLadderBeamRadius,
566                                              beamLength/2., 0, 180);
567      TGeoVolume *cfSideBeamVol = new TGeoVolume("ITSsddCFSideBeamVol",
568                                       sideBeam, carbonFiberLadderStruct);
569      cfSideBeamVol->SetLineColor(colorCarbonFiber);
570      //Euler rotation : about Z, then new X, then new Z
571      TGeoRotation *beamRot1 = new TGeoRotation("",90-2.*beta*TMath::RadToDeg(),
572                                                         -beamPhiPrime*TMath::RadToDeg(), -90);
573      TGeoCombiTrans *beamTransf1 = new TGeoCombiTrans(0.5*triangleHeight*
574                    TMath::Tan(halfTheta),fLadderBeamRadius/2.+tDY,
575                                                    -length/2+segmentLength/8,beamRot1);
576      TGeoRotation *beamRot2 = new TGeoRotation("",90-2.*beta*TMath::RadToDeg(),
577                                             beamPhiPrime*TMath::RadToDeg(), -90);
578      TGeoCombiTrans *beamTransf3 = new TGeoCombiTrans(0.5*triangleHeight*
579                      TMath::Tan(halfTheta),fLadderBeamRadius/2.+tDY,
580                                                    -length/2+3*segmentLength/8,beamRot2);
581      TGeoRotation *beamRot3 = new TGeoRotation("",90+2.*beta*TMath::RadToDeg(),
582                                             beamPhiPrime*TMath::RadToDeg(), -90);
583      TGeoCombiTrans *beamTransf5 = new TGeoCombiTrans(-0.5*triangleHeight*
584                           TMath::Tan(halfTheta),fLadderBeamRadius/2.+tDY,
585                                                    -length/2+segmentLength/8,beamRot3);
586      TGeoRotation *beamRot4 = new TGeoRotation("",90+2.*beta*TMath::RadToDeg(),
587                                             -beamPhiPrime*TMath::RadToDeg(), -90);
588      TGeoCombiTrans *beamTransf7 = new TGeoCombiTrans(-0.5*triangleHeight*
589             TMath::Tan(halfTheta),fLadderBeamRadius/2.+tDY,
590                                                    -length/2+3*segmentLength/8,beamRot4);
591      virtualEnd->AddNode(cfSideBeamVol, 1, beamTransf1);
592      virtualEnd->AddNode(cfSideBeamVol, 2, beamTransf3);
593      virtualEnd->AddNode(cfSideBeamVol, 3, beamTransf5);
594      virtualEnd->AddNode(cfSideBeamVol, 4, beamTransf7);
595      //--- Beams of the bottom
596      TGeoTubeSeg *bottomBeam1 = new TGeoTubeSeg(0, fLadderBeamRadius,
597                                              fLadderWidth/2.-fLadderLb/3, 0, 180);
598      TGeoVolume *bottomBeam1Vol = new TGeoVolume("ITSsddBottomBeam1Vol",
599                                       bottomBeam1, carbonFiberLadderStruct);
600      bottomBeam1Vol->SetLineColor(colorCarbonFiber);
601      TGeoRotation *bottomBeamRot1 = new TGeoRotation("",90, 90, 90);
602      TGeoCombiTrans *bottomBeamTransf1 = new TGeoCombiTrans(0,
603                             -(fLadderHeight/2-fLadderBeamRadius)+tDY,
604                                                  -length/2+fSegmentLength/2, bottomBeamRot1);
605      virtualEnd->AddNode(bottomBeam1Vol, 1, bottomBeamTransf1);
606      TGeoTubeSeg *bottomBeam2 = new TGeoTubeSeg(0, fLadderBeamRadius,
607                                              fLadderWidth/2.-fLadderLb/3, 0, 90);
608      TGeoVolume *bottomBeam2Vol = new TGeoVolume("ITSsddBottomBeam2Vol",
609                                    bottomBeam2, carbonFiberLadderStruct);
610      bottomBeam2Vol->SetLineColor(colorCarbonFiber);
611      TGeoCombiTrans *bottomBeamTransf2 = new TGeoCombiTrans(0,
612            -(fLadderHeight/2-fLadderBeamRadius)+tDY,-length/2, bottomBeamRot1);
613      virtualEnd->AddNode(bottomBeam2Vol, 1, bottomBeamTransf2);
614      //**********************************
615      virtualEnd->SetVisibility(kFALSE);
616      return virtualEnd;
617 };
618 //________________________________________________________________________
619 TGeoVolume* AliITSv11GeometrySDD::CreateSDDsensor() {
620     // return a box containing the SDD sensor
621
622     TGeoBBox *sensorBox = new TGeoBBox("ITSsddSensorBox",
623                                   fWaferWidth/2, fWaferThickness/2,fWaferLength/2);
624     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
625     TGeoVolume *virtualSensor =new TGeoVolume("ITSsddSensor",sensorBox,airSDD);
626
627     //virtualSensor->SetVisibility(kFALSE);
628     return virtualSensor;
629 };
630 //________________________________________________________________________
631 TGeoVolume *AliITSv11GeometrySDD::CreateLay3Detectors() {
632     // return a box volume containing the detectors
633
634     TGeoBBox *detBox = new TGeoBBox("ITSssdDetBox3",
635                                     fWaferWidth/2,
636                                     (fLadWaferSep + 2*fWaferThickness)/2,
637                              fLay3LadderLength*((fLay3Ndet-0.5)/fLay3Ndet)/2);
638     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
639     TGeoVolume *virtualDet = new TGeoVolume("ITSsddDet3",detBox, airSDD);
640     TGeoVolume *vSDD = CreateSDDsensor();
641     char transName[30];
642     for (Int_t i=0; i<fLay3Ndet; i++) {
643         Double_t localZ = fLay3sensorZPos[i];
644         Double_t localY = fLadWaferSep/2+fWaferThickness/2;
645         if (i%2!=0)
646             localY = -localY;
647         sprintf(transName, "ITSsddLay3SensorPos%i", i+1);
648         TGeoTranslation *sensorPos = new TGeoTranslation(transName,0,localY,
649                                                          localZ);
650         virtualDet->AddNode(vSDD, i+1, sensorPos);
651     }
652     virtualDet->SetVisibility(kFALSE);
653     return virtualDet;
654 };
655 //________________________________________________________________________
656 void AliITSv11GeometrySDD::Layer4(TGeoVolume *Moth) {
657     // Insert the layer 4 in the mother volume. This is a virtual volume
658     // containing ladders of layer 4 and the supporting rings
659
660     TGeoTube *virtualLayer4Shape =new TGeoTube("ITSsddLayer4Shape",
661                                         fLay4Rmin,fLay4Rmax,fLay4Length*0.5);
662     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
663     TGeoVolume *virtualLayer4 = new TGeoVolume("ITSsddLayer4",
664                                           virtualLayer4Shape, airSDD);
665     TGeoVolume *lay4Ladder = CreateLay4Ladder();
666     TGeoVolume *lay4Detectors = CreateLay4Detectors();
667     Double_t dPhi = 360./fLay4Nladd;
668     Double_t detBoxThickness = fLadWaferSep + 2*fWaferThickness;
669     // placing virtual ladder and detectors volumes following ladder 
670     // ordering convention
671     char rotName[20];
672     Int_t iLaddMin = 0;
673     Int_t iLaddMax = fLay4Nladd;
674     if ((fAddOnlyLadder4>=0)&&(fAddOnlyLadder4<fLay4Nladd)) {
675         iLaddMin = fAddOnlyLadder4;
676         iLaddMax = fAddOnlyLadder4+1;
677     }
678     for (Int_t iLadd = iLaddMin; iLadd < iLaddMax; iLadd++) {
679         sprintf(rotName, "ITSsddLay4Ladd%i",iLadd);
680         Double_t minRadiusLadBox = fLay4LaddShortRadius;
681         if (iLadd%2 != 0)
682             minRadiusLadBox = fLay4LaddLongRadius;
683         minRadiusLadBox += ((TGeoBBox*)lay4Ladder->GetShape())->GetDY();
684         TGeoCombiTrans *ctLadd = CreateCombiTrans(rotName, minRadiusLadBox,
685                                                   0, -90+iLadd*dPhi);
686         virtualLayer4->AddNode(lay4Ladder, iLadd, ctLadd);
687         sprintf(rotName, "ITSsddLay4DetBox%i",iLadd);
688         Double_t minRadiusDetBox = fLay4DetShortRadius;
689         if (iLadd%2 != 0)
690             minRadiusDetBox = fLay4DetLongRadius;
691         minRadiusDetBox += detBoxThickness/2;
692         TGeoCombiTrans *ctDet = CreateCombiTrans(rotName, minRadiusDetBox,
693                                                  0, -90+iLadd*dPhi);
694         virtualLayer4->AddNode(lay4Detectors, iLadd, ctDet);
695     }
696     virtualLayer4->SetVisibility(kFALSE);
697     Moth->AddNode(virtualLayer4,1,0);
698 };
699 //________________________________________________________________________
700 TGeoVolume *AliITSv11GeometrySDD::CreateLay4Ladder() {
701     // return a box volume containing the CF ladder and all pieces on it
702
703     TGeoVolume *laddSegment = CreateLadderSegment();
704     TGeoBBox *ladBox = new TGeoBBox("ITSsddLadBox",
705                                ((TGeoBBox*)laddSegment->GetShape())->GetDX(),
706                                   ((TGeoBBox*)laddSegment->GetShape())->GetDY(),
707                                   //dX,dY = dX,dY of the segment
708                                   fLay4LadderLength/2);  
709     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
710     TGeoVolume *virtualLadder = new TGeoVolume("ITSsddLadder",ladBox, airSDD);
711     Double_t segmentLength = fSegmentLength;
712     char transName[20];
713     // placing virtual ladder segment following detector ordering convention
714     //=======================================================================
715     Int_t iSegmentMin = 1;
716     Int_t iSegmentMax = fLay4Ndet;
717     if (fAddOnlySegment) {
718         iSegmentMin = fAddOnlySegment;
719         iSegmentMax = fAddOnlySegment;
720     }
721     for (Int_t iSegment = iSegmentMin; iSegment <= iSegmentMax; iSegment++ ) {
722         sprintf(transName, "ITSsddLay4LaddSeg%i", iSegment);
723         Double_t segmentPos = segmentLength*(fLay4Ndet/2-iSegment) +
724             segmentLength/2;
725         TGeoTranslation *segTr = new TGeoTranslation(transName,0,0,segmentPos);
726         virtualLadder->AddNode(laddSegment, iSegment, segTr);
727     }
728     // putting virtual volume corresponding to the end of ladder
729     //=======================================================================
730     Double_t endLength = (fLay4LadderLength-fLay4Ndet*fSegmentLength)/2.;
731     TGeoVolume *endLadder = CreateEndLadder( endLength );
732     TGeoTranslation *endTrZPos =
733         new TGeoTranslation("ITSsddEndTrZPos",0,0,
734                             fSegmentLength*(fLay4Ndet/2)+endLength/2.);
735     //Euler rotation : about Z, then new X, then new Z
736     TGeoRotation *endZNegRot = new TGeoRotation("",90, 180, -90);
737     TGeoCombiTrans *endTrZNeg =
738         new TGeoCombiTrans(0,0,-fSegmentLength*(fLay4Ndet/2)-endLength/2.,
739                            endZNegRot);
740     if ((fAddOnlySegment==0)||(fAddOnlySegment==1))
741         virtualLadder->AddNode(endLadder, 1, endTrZPos);
742     if ((fAddOnlySegment==0)||(fAddOnlySegment==fLay4Ndet))
743         virtualLadder->AddNode(endLadder, 2, endTrZNeg);
744     virtualLadder->SetVisibility(kFALSE);
745     return virtualLadder;
746 };
747 //________________________________________________________________________
748 TGeoVolume *AliITSv11GeometrySDD::CreateLay4Detectors() {
749     // return a box volume containing the detectors
750
751     TGeoBBox *detBox = new TGeoBBox("ITSssdDetBox4",
752                                     fWaferWidth/2,
753                                     (fLadWaferSep + 2*fWaferThickness)/2,
754                              fLay4LadderLength*((fLay4Ndet-0.5)/fLay4Ndet)/2);
755     TGeoMedium *airSDD = gGeoManager->GetMedium("ITSsddAir");
756     TGeoVolume *virtualDet = new TGeoVolume("ITSsddDet4",detBox, airSDD);
757     TGeoVolume *vSDD = CreateSDDsensor();
758     char transName[30];
759     for (Int_t i=0; i<fLay4Ndet; i++) {
760         Double_t localZ = fLay4sensorZPos[i];
761         Double_t localY = fLadWaferSep/2+fWaferThickness/2;
762         if (i%2!=0)
763             localY = -localY;
764         sprintf(transName, "ITSsddLay4SensorPos%i", i+1);
765         TGeoTranslation *sensorPos = new TGeoTranslation(transName,0,localY,
766                                                          localZ);
767         virtualDet->AddNode(vSDD, i+1, sensorPos);
768     }
769     virtualDet->SetVisibility(kFALSE);
770     return virtualDet;
771 };