Small overlaps corrected.
[u/mrichter/AliRoot.git] / STRUCT / AliSHILv3.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 /* $Id$ */
17
18 //-------------------------------------------------------------------------
19 // The small angle absorber SAA (beam shield)
20 // Author: A.Morsch
21 // andreas.morsch@cern.ch
22 //-------------------------------------------------------------------------
23
24 #include <TVirtualMC.h>
25 #include <TArrayI.h>
26 #include <TGeoVolume.h>
27 #include <TGeoTube.h>
28 #include <TGeoManager.h>
29 #include <TGeoMatrix.h>
30 #include <TGeoCompositeShape.h>
31 #include <TGeoBBox.h>
32 #include <TGeoPgon.h>
33 #include <TGeoCone.h>
34
35 #include "AliSHILv3.h"
36 #include "AliConst.h"
37 #include "AliLog.h"
38
39 ClassImp(AliSHILv3)
40  
41 //_____________________________________________________________________________
42 AliSHILv3::AliSHILv3()
43 {
44   //
45   // Default constructor for muon shield
46   //
47 }
48  
49 //_____________________________________________________________________________
50 AliSHILv3::AliSHILv3(const char *name, const char *title)
51   : AliSHIL(name,title)
52 {
53   //
54   // Standard constructor for muon shield
55   //
56 }
57  
58 //_____________________________________________________________________________
59 void AliSHILv3::CreateGeometry()
60 {
61 //
62 // The geometry of the small angle absorber "Beam Shield"
63 //
64     Float_t dz, dr, z, rmax;
65 //
66 // The top volume
67 //
68     TGeoVolume* top = gGeoManager->GetVolume("ALIC");
69 //  Rotations
70     TGeoRotation* rot000 = new TGeoRotation("rot000",  90.,   0., 90.,  90., 0., 0.);
71     TGeoRotation* rot090 = new TGeoRotation("rot090",  90.,  90., 90., 180., 0., 0.);
72     TGeoRotation* rot180 = new TGeoRotation("rot180",  90., 180., 90., 270., 0., 0.);
73     TGeoRotation* rot270 = new TGeoRotation("rot270",  90., 270., 90.,   0., 0., 0.);
74     Float_t alhc = 0.794;
75     TGeoRotation* rotxzlhc   = new TGeoRotation("rotxzlhc", 0.,  -alhc, 0.);
76     TGeoRotation* rotlhc     = new TGeoRotation("rotlhc",   0.,   alhc, 0.);
77
78 //
79 // Media
80 //
81     TGeoMedium* kMedNiW     = gGeoManager->GetMedium("SHIL_Ni/W0");
82     TGeoMedium* kMedNiWsh   = gGeoManager->GetMedium("SHIL_Ni/W3");
83 //
84     TGeoMedium* kMedSteel   = gGeoManager->GetMedium("SHIL_ST_C0");
85     TGeoMedium* kMedSteelSh = gGeoManager->GetMedium("SHIL_ST_C3");
86 //
87     TGeoMedium* kMedAir     = gGeoManager->GetMedium("SHIL_AIR_C0");
88     TGeoMedium* kMedAirMu   = gGeoManager->GetMedium("SHIL_AIR_MUON");
89 //
90     TGeoMedium* kMedPb      = gGeoManager->GetMedium("SHIL_PB_C0");
91     TGeoMedium* kMedPbSh    = gGeoManager->GetMedium("SHIL_PB_C2");
92 //
93     TGeoMedium* kMedConcSh  = gGeoManager->GetMedium("SHIL_CC_C2");
94 //
95     const Float_t kDegRad = TMath::Pi() / 180.;
96     const Float_t kAngle02   = TMath::Tan( 2.00   * kDegRad);   
97     const Float_t kAngle0071 = TMath::Tan( 0.71   * kDegRad);   
98
99
100 ///////////////////////////////////
101 //    FA Tungsten Tail           //
102 //    Drawing ALIP2A__0049       //
103 //    Drawing ALIP2A__0111       //
104 ///////////////////////////////////
105 //
106 //    The tail as built is shorter than in drawing ALIP2A__0049. 
107 //    The CDD data base has to be updated !
108 //
109 //    Inner radius at the entrance of the flange
110       Float_t rInFaWTail1  = 13.98/2.;
111 //    Outer radius at the entrance of the flange
112       Float_t rOuFaWTail1  = 52.00/2.;
113 //    Outer radius at the end of the section inside the FA
114       Float_t rOuFaWTail2  = 35.27/2.;
115 //    Length of the Flange section inside the FA
116       Float_t dzFaWTail1   =  6.00;
117 //    Length of the Flange section ouside the FA
118       Float_t dzFaWTail2   = 12.70;
119 //    Inner radius at the end of the section inside the FA 
120       Float_t rInFaWTail2  = rInFaWTail1 +  dzFaWTail1 * kAngle0071;
121 //    Inner radius at the end of the flange
122       Float_t rInFaWTail3  = rInFaWTail2 +  dzFaWTail2 * kAngle0071;
123 //    Outer radius at the end of the flange
124       Float_t rOuFaWTail3  = rOuFaWTail2 +  dzFaWTail2 * kAngle02;
125 //    Outer radius of the recess for station 1
126       Float_t rOuFaWTailR  = 30.8/2.;
127 //    Length of the recess
128       Float_t dzFaWTailR   = 36.00;
129 //    Inner radiues at the end of the recess      
130       Float_t rInFaWTail4  =  rInFaWTail3 +  dzFaWTailR * kAngle0071;
131 //    Outer radius at the end of the recess      
132       Float_t rOuFaWTail4  =  rOuFaWTail3 +  dzFaWTailR * kAngle02;
133 //    Inner radius of the straight section
134       Float_t rInFaWTailS  = 22.30/2.;
135 //    Length of the bulge
136       Float_t dzFaWTailB   = 13.0;
137 //    Outer radius at the end of the bulge
138       Float_t rOuFaWTailB  =  rOuFaWTail4 +  dzFaWTailB * kAngle02;
139 //    Outer radius at the end of the tail 
140       Float_t rOuFaWTailE  = 31.6/2.;
141 //    Total length of the tail
142       Float_t dzFaWTail    = 70.7;
143
144       TGeoPcon* shFaWTail = new TGeoPcon(0., 360., 10);
145       z    = 0.;
146 //    Flange section inside FA
147       shFaWTail->DefineSection(0,  z, rInFaWTail1, rOuFaWTail1);
148       z += dzFaWTail1;
149       shFaWTail->DefineSection(1,  z, rInFaWTail2, rOuFaWTail1);      
150       shFaWTail->DefineSection(2,  z, rInFaWTail2, rOuFaWTail2);      
151 //    Flange section outside FA
152       z +=  dzFaWTail2;
153       shFaWTail->DefineSection(3,  z, rInFaWTail3, rOuFaWTail3);      
154       shFaWTail->DefineSection(4,  z, rInFaWTail3, rOuFaWTailR);
155 //    Recess Station 1
156       z +=  dzFaWTailR;
157       shFaWTail->DefineSection(5,  z, rInFaWTail4, rOuFaWTailR); 
158       shFaWTail->DefineSection(6,  z, rInFaWTailS, rOuFaWTail4);
159 //    Bulge
160       z += dzFaWTailB;
161       shFaWTail->DefineSection(7,  z, rInFaWTailS, rOuFaWTailB);
162       shFaWTail->DefineSection(8,  z, rInFaWTailS, rOuFaWTailE);
163 //    End
164       z =  dzFaWTail;
165       shFaWTail->DefineSection(9,  z, rInFaWTailS, rOuFaWTailE);
166       
167       TGeoVolume* voFaWTail = new TGeoVolume("YFaWTail", shFaWTail, kMedNiW);
168 //
169 //    Define an inner region with higher transport cuts
170       TGeoPcon* shFaWTailI = new TGeoPcon(0., 360., 4);
171       z  = 0.;
172       dr = 3.5;
173       shFaWTailI->DefineSection(0, z, rInFaWTail1,  rInFaWTail1 + dr);
174       z += (dzFaWTail1 + dzFaWTail2 +  dzFaWTailR);
175       shFaWTailI->DefineSection(1, z, rInFaWTail4,  rInFaWTail4 + dr);
176       shFaWTailI->DefineSection(2, z, rInFaWTailS,  rInFaWTailS + dr);
177       z = dzFaWTail;
178       shFaWTailI->DefineSection(3, z, rInFaWTailS,  rInFaWTailS + dr);
179       TGeoVolume* voFaWTailI = new TGeoVolume("YFaWTailI", shFaWTailI, kMedNiWsh);
180       voFaWTail->AddNode(voFaWTailI, 1, gGeoIdentity);
181       
182 ///////////////////////////////////
183 //                               //
184 // Recess Station 1              //
185 // Drawing ALIP2A__0260          //
186 ///////////////////////////////////
187
188 ///////////////////////////////////
189 //    FA W-Ring 2                //
190 //    Drawing ALIP2A__0220       //
191 ///////////////////////////////////
192       const Float_t kFaWring2Rinner  = 15.41;
193       const Float_t kFaWring2Router  = 18.40;
194       const Float_t kFaWring2HWidth  =  3.75;
195       const Float_t kFaWring2Cutoffx =  3.35;
196       const Float_t kFaWring2Cutoffy =  3.35;
197       TGeoTubeSeg* shFaWring2a  = new TGeoTubeSeg(kFaWring2Rinner, kFaWring2Router, kFaWring2HWidth, 0., 90.);
198       shFaWring2a->SetName("shFaWring2a");
199       TGeoBBox* shFaWring2b  = new TGeoBBox(kFaWring2Router / 2., kFaWring2Router / 2., kFaWring2HWidth);
200       shFaWring2b->SetName("shFaWring2b");
201       TGeoTranslation* trFaWring2b 
202           = new TGeoTranslation("trFaWring2b", kFaWring2Router / 2. + kFaWring2Cutoffx, kFaWring2Router / 2. + kFaWring2Cutoffy, 0.);
203       trFaWring2b->RegisterYourself();
204       TGeoCompositeShape*  shFaWring2 = new TGeoCompositeShape("shFaWring2", "(shFaWring2a)*(shFaWring2b:trFaWring2b)");
205       TGeoVolume* voFaWring2    = new TGeoVolume("YFA_WRING2", shFaWring2, kMedNiW);
206
207 ///////////////////////////////////
208 //    FA W-Ring 3                //
209 //    Drawing ALIP2A__0219       //
210 ///////////////////////////////////
211       const Float_t kFaWring3Rinner  = 15.41;
212       const Float_t kFaWring3Router  = 18.40;
213       const Float_t kFaWring3HWidth  =  3.75;
214       const Float_t kFaWring3Cutoffx =  3.35;
215       const Float_t kFaWring3Cutoffy =  3.35;
216       TGeoTubeSeg* shFaWring3a  = new TGeoTubeSeg(kFaWring3Rinner, kFaWring3Router, kFaWring3HWidth, 0., 90.);
217       shFaWring3a->SetName("shFaWring3a");
218       TGeoBBox* shFaWring3b  = new TGeoBBox(kFaWring3Router / 2., kFaWring3Router / 2., kFaWring3HWidth);
219       shFaWring3b->SetName("shFaWring3b");
220       TGeoTranslation* trFaWring3b 
221           = new TGeoTranslation("trFaWring3b", kFaWring3Router / 2. + kFaWring3Cutoffx, kFaWring3Router / 2. + kFaWring3Cutoffy, 0.);
222       trFaWring3b->RegisterYourself();
223       TGeoCompositeShape*  shFaWring3 = new TGeoCompositeShape("shFaWring3", "(shFaWring3a)*(shFaWring3b:trFaWring3b)");
224       TGeoVolume* voFaWring3    = new TGeoVolume("YFA_WRING3", shFaWring3, kMedNiW);
225
226 ///////////////////////////////////
227 //    FA W-Ring 5                //
228 //    Drawing ALIP2A__0221       //
229 ///////////////////////////////////
230       const Float_t kFaWring5Rinner = 15.41;
231       const Float_t kFaWring5Router = 18.67;
232       const Float_t kFaWring5HWidth =  1.08;
233       TGeoVolume* voFaWring5    = new TGeoVolume("YFA_WRING5", new TGeoTube(kFaWring5Rinner, kFaWring5Router, kFaWring5HWidth), kMedNiW);
234
235 //
236 // Position the rings in the assembly 
237 //      
238       TGeoVolumeAssembly* asFaExtraShield = new TGeoVolumeAssembly("YCRE");
239 // Distance between rings
240       const Float_t kFaDWrings = 1.92;
241 //
242       dz = 0.;
243       
244       dz +=  kFaWring2HWidth;
245       asFaExtraShield->AddNode(voFaWring2,    1, new TGeoCombiTrans(0., 0., dz, rot090));
246       asFaExtraShield->AddNode(voFaWring2,    2, new TGeoCombiTrans(0., 0., dz, rot270));
247       dz +=   kFaWring2HWidth;
248       dz +=   kFaDWrings;
249       dz +=   kFaWring3HWidth;
250       asFaExtraShield->AddNode(voFaWring3,    1, new TGeoCombiTrans(0., 0., dz, rot000));
251       asFaExtraShield->AddNode(voFaWring3,    2, new TGeoCombiTrans(0., 0., dz, rot180));
252       dz +=   kFaWring3HWidth;   
253       dz +=   kFaWring5HWidth;   
254       asFaExtraShield->AddNode(voFaWring5,    1, new TGeoTranslation(0., 0., dz));
255       dz +=   kFaWring5HWidth;   
256       dz +=   kFaWring3HWidth;   
257       asFaExtraShield->AddNode(voFaWring3,    3, new TGeoCombiTrans(0., 0., dz, rot090));
258       asFaExtraShield->AddNode(voFaWring3,    4, new TGeoCombiTrans(0., 0., dz, rot270));
259       dz +=   kFaWring3HWidth;   
260       dz +=   kFaDWrings;
261       dz +=   kFaWring2HWidth;
262       asFaExtraShield->AddNode(voFaWring2,    3, new TGeoCombiTrans(0., 0., dz, rot000));
263       asFaExtraShield->AddNode(voFaWring2,    4, new TGeoCombiTrans(0., 0., dz, rot180));
264       dz +=   kFaWring2HWidth;
265
266       
267 ///////////////////////////////////////
268 //                SAA1               //
269 ///////////////////////////////////////
270
271
272 ///////////////////////////////////////
273 //          FA/SAA1  W Joint         //
274 //          Drawing ALIP2A__0060     //
275 ///////////////////////////////////////
276
277 // Length of flange FA side      
278       Float_t dzFaSaa1F1  =  2.8;
279 // Inner radius of flange FA side
280       Float_t rInFaSaa1F1 = 32.0/2.;
281 // Outer radius of flange FA side
282       Float_t rOuFaSaa1F1 = 39.5/2.;
283 // Length of first straight section
284       Float_t dzFaSaa1S1  = 18.5 - dzFaSaa1F1;
285 // Inner radius of first straight section
286       Float_t rInFaSaa1S1 = 22.3/2.;
287 // Length of 45 deg transition region
288       Float_t  dzFaSaa1T1 =  2.2;
289 // Inner radius of second straight section
290       Float_t rInFaSaa1S2 = 17.9/2.;
291 // Length of second straight section
292       Float_t dzFaSaa1S2  = 10.1;
293 // Length of flange SAA1 side      
294 //    Float_t dzFaSaa1F2  =  4.0;
295 // Inner radius of flange FA side
296       Float_t rInFaSaa1F2 = 25.2/2.;
297 // Length of joint
298       Float_t dzFaSaa1    = 34.8;
299 // Outer Radius at the end of the joint
300       Float_t rOuFaSaa1E  = 41.93/2.;
301       
302       
303       TGeoPcon* shFaSaa1 = new TGeoPcon(0., 360., 8);
304       z = 0;
305 // Flange FA side      
306       shFaSaa1->DefineSection( 0, z, rInFaSaa1F1, rOuFaSaa1F1 - 0.01);
307       z += dzFaSaa1F1;
308       shFaSaa1->DefineSection( 1, z, rInFaSaa1F1, 40.0);
309       shFaSaa1->DefineSection( 2, z, rInFaSaa1S1, 40.0);
310 // First straight section
311       z += dzFaSaa1S1;
312       shFaSaa1->DefineSection( 3, z, rInFaSaa1S1, 40.0);
313 // 45 deg transition region
314       z += dzFaSaa1T1;
315       shFaSaa1->DefineSection( 4, z, rInFaSaa1S2, 40.0);
316 // Second straight section
317       z += dzFaSaa1S2;
318       shFaSaa1->DefineSection( 5, z, rInFaSaa1S2, 40.0);
319       shFaSaa1->DefineSection( 6, z, rInFaSaa1F2, 40.0);
320 // Flange SAA1 side
321       z = dzFaSaa1;
322       shFaSaa1->DefineSection( 7, z, rInFaSaa1F2, rOuFaSaa1E - 0.01);
323
324 // Outer 2 deg line
325       for (Int_t i  = 1; i < 7; i++) {
326           Double_t zp   = shFaSaa1->GetZ(i);
327           Double_t r1   = shFaSaa1->GetRmin(i);  
328           Double_t r2 = 39.5/2. + zp * TMath::Tan(2. * kDegRad) - 0.01;
329           shFaSaa1->DefineSection(i, zp, r1, r2);
330       }
331       TGeoVolume* voFaSaa1 = new TGeoVolume("YFASAA1", shFaSaa1, kMedNiWsh);
332 //
333 // Outer region with lower transport cuts
334       TGeoCone* shFaSaa1O   = new TGeoCone(dzFaSaa1/2., rOuFaSaa1F1 - 3.5, rOuFaSaa1F1 - 0.01, rOuFaSaa1E - 3.5, rOuFaSaa1E - 0.01);
335       TGeoVolume* voFaSaa1O = new TGeoVolume("YFASAA1O", shFaSaa1O, kMedNiW);
336       voFaSaa1->AddNode(voFaSaa1O, 1, new TGeoTranslation(0., 0., dzFaSaa1/2.));
337       
338
339 ///////////////////////////////////
340 //    SAA1 Steel Envelope        //
341 //    Drawing ALIP2A__0039       //
342 ///////////////////////////////////
343       
344       Float_t rOut;      // Outer radius
345 // Thickness of the steel envelope
346       Float_t dSt = 4.;
347 // 4 Section
348 // z-positions
349       Float_t zSaa1StEnv[5] = {111.2, 113.7, 229.3, 195.0};
350 // Radii
351 // 1
352       Float_t rOuSaa1StEnv1 = 40.4/2.;
353       Float_t rInSaa1StEnv1 = rOuSaa1StEnv1 - dSt - 0.05;
354 // 2  
355       Float_t rInSaa1StEnv2 = 41.7/2.;
356       Float_t rOuSaa1StEnv2 = rInSaa1StEnv2 + dSt / TMath::Cos(2.0 * kDegRad) - 0.05;
357 // 3         
358       Float_t rOuSaa1StEnv3 = 57.6/2.; 
359       Float_t rInSaa1StEnv3 = rOuSaa1StEnv3 - dSt + 0.05;
360 // 4
361       Float_t rInSaa1StEnv4 = 63.4/2.;
362       Float_t rOuSaa1StEnv4 = rInSaa1StEnv4 + dSt / TMath::Cos(1.6 * kDegRad) - 0.05;
363 // end         
364       Float_t rInSaa1StEnv5 = 74.28/2.;
365       Float_t rOuSaa1StEnv5 = rInSaa1StEnv5 + dSt / TMath::Cos(1.6 * kDegRad) - 0.05;
366 // Relative starting position
367       Float_t zSaa1StEnvS = 3.;
368       
369       TGeoPcon* shSaa1StEnv  = new TGeoPcon(0., 360., 11);
370 // 1st Section
371       z = zSaa1StEnvS;
372       shSaa1StEnv->DefineSection( 0, z, rInSaa1StEnv1, rOuSaa1StEnv1);
373       z += (zSaa1StEnv[0] - dSt);
374       shSaa1StEnv->DefineSection( 1, z, rInSaa1StEnv1, rOuSaa1StEnv1);
375 // 1 - 2
376       shSaa1StEnv->DefineSection( 2, z, rInSaa1StEnv1, rOuSaa1StEnv2);
377       z +=  dSt;
378       shSaa1StEnv->DefineSection( 3, z, rInSaa1StEnv1, rOuSaa1StEnv2);      
379 // 2nd Section
380       shSaa1StEnv->DefineSection( 4, z, rInSaa1StEnv2, rOuSaa1StEnv2);      
381       z += zSaa1StEnv[1];
382       shSaa1StEnv->DefineSection( 5, z, rInSaa1StEnv3, rOuSaa1StEnv3);      
383 // 3rd Section  
384       z += (zSaa1StEnv[2] - dSt);
385       shSaa1StEnv->DefineSection( 6, z, rInSaa1StEnv3, rOuSaa1StEnv3);      
386 // 3 - 4
387       shSaa1StEnv->DefineSection( 7, z, rInSaa1StEnv3, rOuSaa1StEnv4);
388       z += dSt;
389       shSaa1StEnv->DefineSection( 8, z, rInSaa1StEnv3, rOuSaa1StEnv4);
390 // 4th Section
391       shSaa1StEnv->DefineSection( 9, z, rInSaa1StEnv4, rOuSaa1StEnv4);
392       z += zSaa1StEnv[3];
393       shSaa1StEnv->DefineSection(10, z, rInSaa1StEnv5, rOuSaa1StEnv5);      
394       TGeoVolume* voSaa1StEnv  =  new TGeoVolume("YSAA1_SteelEnvelope", shSaa1StEnv, kMedSteel);
395
396
397       
398  
399
400 ///////////////////////////////////
401 //    SAA1 W-Pipe                //
402 //    Drawing ALIP2A__0059       //
403 ///////////////////////////////////
404 //
405 //    Flange FA side
406 //    Length of first section      
407       Float_t dzSaa1WPipeF1  = 0.9;
408 //    Outer radius 
409       Float_t rOuSaa1WPipeF1 = 24.5/2.;
410 //    Inner Radius
411       Float_t rInSaa1WPipeF1 = 22.0/2.;
412 //    Length of second section
413       Float_t dzSaa1WPipeF11 =  2.1;
414 //    Inner Radius
415       Float_t rInSaa1WPipeF11 = 18.5/2.;
416 //
417 //    Central tube 
418 //    Length 
419       Float_t dzSaa1WPipeC = 111.2;
420 //    Inner Radius at the end
421       Float_t rInSaa1WPipeC = 22.0/2.;
422 //    Outer Radius
423       Float_t rOuSaa1WPipeC = 31.9/2.;
424 //
425 //    Flange SAA2 Side
426 //    Length
427       Float_t dzSaa1WPipeF2  = 6.0;
428 //    Outer radius 
429       Float_t rOuSaa1WPipeF2 = 41.56/2.;
430
431 //
432       TGeoPcon* shSaa1WPipe  = new TGeoPcon(0., 360., 8);
433       z = 0.;
434 // Flange FA side first section
435       shSaa1WPipe->DefineSection( 0, z, rInSaa1WPipeF1 , rOuSaa1WPipeF1);
436       z += dzSaa1WPipeF1;
437       shSaa1WPipe->DefineSection( 1, z, rInSaa1WPipeF1 , rOuSaa1WPipeF1);
438 // Flange FA side second section
439       shSaa1WPipe->DefineSection( 2, z, rInSaa1WPipeF11, rOuSaa1WPipeF1);
440       z += dzSaa1WPipeF11;
441       shSaa1WPipe->DefineSection( 3, z, rInSaa1WPipeF11, rOuSaa1WPipeF1);
442 // Central Section
443       shSaa1WPipe->DefineSection( 4, z, rInSaa1WPipeF11, rOuSaa1WPipeC);
444       z += dzSaa1WPipeC;
445       shSaa1WPipe->DefineSection( 5, z, rInSaa1WPipeC,   rOuSaa1WPipeC);
446 // Flange SAA2 side
447       shSaa1WPipe->DefineSection( 6, z, rInSaa1WPipeC,   rOuSaa1WPipeF2);
448       z +=  dzSaa1WPipeF2;
449       shSaa1WPipe->DefineSection( 7, z, rInSaa1WPipeC,   rOuSaa1WPipeF2);
450
451       TGeoVolume* voSaa1WPipe  =  new TGeoVolume("YSAA1_WPipe", shSaa1WPipe, kMedNiW);
452 //
453 // Inner region with higher transport cuts
454       TGeoTube*   shSaa1WPipeI = new TGeoTube(rInSaa1WPipeC, rOuSaa1WPipeC, dzSaa1WPipeC/2.);
455       TGeoVolume* voSaa1WPipeI =  new TGeoVolume("YSAA1_WPipeI", shSaa1WPipeI, kMedNiWsh);
456       voSaa1WPipe->AddNode(voSaa1WPipeI, 1, new TGeoTranslation(0., 0., dzSaa1WPipeF1 + dzSaa1WPipeF11 + dzSaa1WPipeC/2));
457       
458
459 ///////////////////////////////////
460 //    SAA1 Pb Components         //
461 //    Drawing ALIP2A__0078       //
462 ///////////////////////////////////
463 //
464 //    Inner angle
465       Float_t tanAlpha = TMath::Tan(1.69    / 2. * kDegRad);
466       Float_t tanBeta  = TMath::Tan(3.20    / 2. * kDegRad);    
467 // 
468 //    1st Section 2deg opening cone
469 //    Length 
470       Float_t dzSaa1PbComp1 = 100.23;
471 //    Inner radius at entrance
472       Float_t rInSaa1PbComp1 = 22.0/2.; // It's 21 cm diameter in the drawing. Is this a typo ??!!
473 //    Outer radius at entrance
474       Float_t rOuSaa1PbComp1 = 42.0/2.;
475 //
476 //    2nd Section: Straight Section
477 //    Length 
478       Float_t dzSaa1PbComp2  = 236.77;
479 //    Inner radius
480       Float_t rInSaa1PbComp2 = rInSaa1PbComp1 + dzSaa1PbComp1 * tanAlpha;
481 //    Outer radius
482       Float_t rOuSaa1PbComp2 = 49.0/2.;
483 //
484 //    3rd Section: 1.6deg opening cone until bellow
485 //    Length 
486       Float_t dzSaa1PbComp3 = 175.6;
487 //    Inner radius        
488       Float_t  rInSaa1PbComp3 = rInSaa1PbComp2 + dzSaa1PbComp2 * tanAlpha;
489 //    Outer radius
490       Float_t rOuSaa1PbComp3 = 62.8/2.;
491 //   
492 //   4th Section: Bellow region
493       Float_t dzSaa1PbComp4  = 26.4;
494 //    Inner radius        
495       Float_t  rInSaa1PbComp4 = 37.1/2.;
496       Float_t  rInSaa1PbCompB = 43.0/2.;
497 //    Outer radius
498       Float_t rOuSaa1PbComp4  = rOuSaa1PbComp3 +  dzSaa1PbComp3 * tanBeta;
499 //
500 //   5th Section: Flange SAA2 side
501 //   1st detail 
502       Float_t dzSaa1PbCompF1  = 4.;
503       Float_t rOuSaa1PbCompF1 = 74.1/2.;
504 //   2nd detail       
505       Float_t dzSaa1PbCompF2  = 3.;
506       Float_t rOuSaa1PbCompF2 = 66.0/2.;
507       Float_t rOuSaa1PbCompF3 = 58.0/2.;
508       
509
510       TGeoPcon* shSaa1PbComp  = new TGeoPcon(0., 360., 11);
511       z = 120.2;
512 // 2 deg opening cone
513       shSaa1PbComp->DefineSection( 0, z, rInSaa1PbComp1, rOuSaa1PbComp1);
514       z += dzSaa1PbComp1;
515       shSaa1PbComp->DefineSection( 1, z, rInSaa1PbComp2, rOuSaa1PbComp2);
516 // Straight section
517       z += dzSaa1PbComp2;
518       shSaa1PbComp->DefineSection( 2, z, rInSaa1PbComp3, rOuSaa1PbComp2);
519 // 1.6 deg opening cone
520       shSaa1PbComp->DefineSection( 3, z, rInSaa1PbComp3, rOuSaa1PbComp3);
521       z += dzSaa1PbComp3;
522       shSaa1PbComp->DefineSection( 4, z, rInSaa1PbComp4, rOuSaa1PbComp4);
523 // Bellow region until outer flange
524       shSaa1PbComp->DefineSection( 5, z, rInSaa1PbCompB, rOuSaa1PbComp4);
525       z += (dzSaa1PbComp4 - dzSaa1PbCompF1 -  dzSaa1PbCompF2);
526       shSaa1PbComp->DefineSection( 6, z, rInSaa1PbCompB, rOuSaa1PbCompF1);
527       shSaa1PbComp->DefineSection( 7, z, rInSaa1PbCompB, rOuSaa1PbCompF2);
528 // Flange first step
529       z +=  dzSaa1PbCompF1;
530       shSaa1PbComp->DefineSection( 8, z, rInSaa1PbCompB, rOuSaa1PbCompF2);
531       shSaa1PbComp->DefineSection( 9, z, rInSaa1PbCompB, rOuSaa1PbCompF3);
532 // Flange second step
533       z +=  dzSaa1PbCompF2;
534       shSaa1PbComp->DefineSection( 10, z, rInSaa1PbCompB, rOuSaa1PbCompF3);
535
536       TGeoVolume* voSaa1PbComp  =  new TGeoVolume("YSAA1_PbComp", shSaa1PbComp, kMedPb);
537 //
538 // Inner region with higher transport cuts
539       TGeoPcon*   shSaa1PbCompI = MakeShapeFromTemplate(shSaa1PbComp, 0., -3.);
540       TGeoVolume* voSaa1PbCompI =  new TGeoVolume("YSAA1_PbCompI", shSaa1PbCompI, kMedPbSh);
541       voSaa1PbComp->AddNode(voSaa1PbCompI, 1, gGeoIdentity);
542       
543 ///////////////////////////////////
544 //    SAA1 W-Cone                //
545 //    Drawing ALIP2A__0058       //
546 ///////////////////////////////////
547       // Length of the Cone
548       Float_t dzSaa1WCone = 52.9;
549       // Inner and outer radii
550       Float_t rInSaa1WCone1 = 20.4;
551       Float_t rOuSaa1WCone1 = rInSaa1WCone1 + 0.97;
552       Float_t rOuSaa1WCone2 = rInSaa1WCone1 + 2.80;
553       // relative z-position 
554       Float_t zSaa1WCone    = 9.3;
555       
556       
557       TGeoPcon* shSaa1WCone  = new TGeoPcon(0., 360., 2);
558       z = zSaa1WCone;
559       shSaa1WCone->DefineSection( 0, z, rInSaa1WCone1, rOuSaa1WCone1);
560       z += dzSaa1WCone;
561       shSaa1WCone->DefineSection( 1, z, rInSaa1WCone1, rOuSaa1WCone2);
562       TGeoVolume* voSaa1WCone  =  new TGeoVolume("YSAA1_WCone", shSaa1WCone, kMedNiW);
563
564 ///////////////////////////////////
565 //    SAA1 Steel-Ring            //
566 //    Drawing ALIP2A__0040       //
567 ///////////////////////////////////
568 //
569 //    Length of the ring
570       Float_t dzSaa1StRing = 4.;
571 //    Inner and outer radius
572       Float_t rInSaa1String = 33.0;
573       Float_t rOuSaa1String = 41.1;      
574 //    Relative z-position
575       Float_t zSaa1StRing   = 652.2;
576       TGeoPcon* shSaa1StRing  = new TGeoPcon(0., 360., 2);
577       z = zSaa1StRing;
578       shSaa1StRing->DefineSection( 0, z, rInSaa1String, rOuSaa1String);
579       z += dzSaa1StRing;
580       shSaa1StRing->DefineSection( 1, z, rInSaa1String, rOuSaa1String);
581       TGeoVolume* voSaa1StRing  =  new TGeoVolume("YSAA1_StRing", shSaa1StRing, kMedSteel);
582
583 ///////////////////////////////////
584 //    SAA1 Inner Tube            //
585 //    Drawing ALIP2A__0082       //
586 ///////////////////////////////////
587 //
588 // Length of saa2:               659.2 cm
589 // Length of inner tube:         631.9 cm
590 // Lenth of bellow cavern:        27.3 cm    
591 // Radius at entrance 18.5/2,  d = 0.3
592 // Radius at exit     37.1/2,  d = 0.3 
593 //
594       Float_t dzSaa1InnerTube     = 631.9/2.;  // Half length of the tube  
595       Float_t rInSaa1InnerTube    =  18.2/2.;  // Radius at entrance
596       Float_t rOuSaa1InnerTube    =  36.8/2.;  // Radius at exit
597       Float_t dSaa1InnerTube      =   0.2   ;  // Thickness      
598       TGeoVolume* voSaa1InnerTube = new TGeoVolume("YSAA1_InnerTube", 
599                                                    new TGeoCone(dzSaa1InnerTube, 
600                                                                 rInSaa1InnerTube - dSaa1InnerTube, rInSaa1InnerTube,
601                                                                 rOuSaa1InnerTube - dSaa1InnerTube, rOuSaa1InnerTube),
602                                                    kMedSteelSh);
603
604 ///////////////////////////////////
605 //    SAA1 Outer Shape           //
606 //    Drawing ALIP2A__0107       //
607 ///////////////////////////////////
608       // Total length 
609       Float_t dzSaa1 = 659.2;
610       //
611       TGeoPcon* shSaa1M  = new TGeoPcon(0., 360., 20);
612       Float_t kSec = 0.2; // security distance to avoid trivial extrusions
613       Float_t rmin = rInSaa1InnerTube - dSaa1InnerTube - kSec;
614       rmax = rOuSaa1InnerTube - dSaa1InnerTube - kSec;
615       z = 0.;
616       shSaa1M->DefineSection( 0, z, rmin, rOuSaa1WPipeF1);
617       z += dzSaa1WPipeF1;
618       shSaa1M->DefineSection( 1, z, rmin, rOuSaa1WPipeF1);
619       shSaa1M->DefineSection( 2, z, 0.,   rOuSaa1WPipeF1);
620       z += dzSaa1WPipeF11;
621       shSaa1M->DefineSection( 3, z, 0.,   rOuSaa1WPipeF1);
622       shSaa1M->DefineSection( 4, z, 0.,   rOuSaa1StEnv1);
623       z = zSaa1WCone;
624       shSaa1M->DefineSection( 5, z, 0.,   rOuSaa1StEnv1);
625       shSaa1M->DefineSection( 6, z, 0.,   rOuSaa1WCone1);
626       z += dzSaa1WCone;
627       shSaa1M->DefineSection( 7, z, 0.,   rOuSaa1WCone2);
628       shSaa1M->DefineSection( 8, z, 0.,   rOuSaa1StEnv1);
629       z =  zSaa1StEnv[0] - dSt + zSaa1StEnvS;
630       shSaa1M->DefineSection( 9, z, 0.,   rOuSaa1StEnv1);
631       shSaa1M->DefineSection(10, z, 0.,   rOuSaa1StEnv2);
632       z +=  (zSaa1StEnv[1] + dSt);
633       shSaa1M->DefineSection(11, z, 0.,   rOuSaa1StEnv3);
634       z +=  (zSaa1StEnv[2] - dSt);
635       shSaa1M->DefineSection(12, z, 0.,   rOuSaa1StEnv3);
636       shSaa1M->DefineSection(13, z, 0.,   rOuSaa1StEnv4);
637
638       z += (zSaa1StEnv[3] - dSt +  dzSaa1PbCompF1 + dzSaa1PbCompF2 - dzSaa1PbComp4);
639       Float_t rmaxSaa1 = shSaa1M->GetRmax(13) + (z - shSaa1M->GetZ(13)) * TMath::Tan(1.6 * kDegRad);
640
641       shSaa1M->DefineSection(14, z, 0.,    rmaxSaa1);
642       shSaa1M->DefineSection(15, z, rmax,  rmaxSaa1);
643       z = zSaa1StRing;     
644       shSaa1M->DefineSection(16, z, rmax + 0.4, rOuSaa1String);
645       z += dzSaa1PbCompF1;
646       shSaa1M->DefineSection(17, z, rmax + 0.4, rOuSaa1String);
647       shSaa1M->DefineSection(18, z, rmax + 0.4, rOuSaa1PbCompF3);
648       z += dzSaa1PbCompF2;
649       shSaa1M->DefineSection(19, z, rmax + 0.4, rOuSaa1PbCompF3);
650
651 //
652 //    Inner 1.69deg line
653       for (Int_t i  = 2; i < 15; i++) {
654           Double_t zp = shSaa1M->GetZ(i);
655           Double_t r2 = shSaa1M->GetRmax(i);     
656           Double_t r1 = rmin + (zp - 0.9) * TMath::Tan(1.686 / 2. * kDegRad) - kSec;
657           shSaa1M->DefineSection(i, zp, r1, r2);
658       }
659
660       TGeoVolume* voSaa1M  =  new TGeoVolume("YSAA1M", shSaa1M, kMedAir);
661       voSaa1M->SetVisibility(0);
662       
663
664 ///////////////////////////////////
665 //                               //
666 // Recess Station 2              //
667 // Drawing ALIP2A__0260          //
668 ///////////////////////////////////
669 ///////////////////////////////////
670 //    SAA1 W-Ring 1              //
671 //    Drawing ALIP2A__0217       //
672 ///////////////////////////////////
673       Float_t saa1Wring1Width  =  5.85;
674       TGeoPcon* shSaa1Wring1    = new TGeoPcon(0., 360., 2);
675       shSaa1Wring1->DefineSection(0, 0.00           , 20.31, 23.175);
676       shSaa1Wring1->DefineSection(1, saa1Wring1Width, 20.31, 23.400);
677       TGeoVolume* voSaa1Wring1  =  new TGeoVolume("YSAA1_WRING1", shSaa1Wring1, kMedNiW);
678
679 ///////////////////////////////////
680 //    SAA1 W-Ring 2              //
681 //    Drawing ALIP2A__0055       //
682 ///////////////////////////////////
683       Float_t saa1Wring2Rinner  = 20.31;
684       Float_t saa1Wring2Router  = 23.40;
685       Float_t saa1Wring2HWidth  =  3.75;
686       Float_t saa1Wring2Cutoffx =  4.45;
687       Float_t saa1Wring2Cutoffy =  4.45;
688       TGeoTubeSeg* shSaa1Wring2a  = new TGeoTubeSeg(saa1Wring2Rinner, saa1Wring2Router, saa1Wring2HWidth, 0., 90.);
689       shSaa1Wring2a->SetName("shSaa1Wring2a");
690       TGeoBBox* shSaa1Wring2b  = new TGeoBBox(saa1Wring2Router / 2., saa1Wring2Router / 2., saa1Wring2HWidth);
691       shSaa1Wring2b->SetName("shSaa1Wring2b");
692       TGeoTranslation* trSaa1Wring2b 
693           = new TGeoTranslation("trSaa1Wring2b", saa1Wring2Router / 2. + saa1Wring2Cutoffx, saa1Wring2Router / 2. + saa1Wring2Cutoffy, 0.);
694       trSaa1Wring2b->RegisterYourself();
695       TGeoCompositeShape*  shSaa1Wring2 = new TGeoCompositeShape("shSaa1Wring2", "(shSaa1Wring2a)*(shSaa1Wring2b:trSaa1Wring2b)");
696       TGeoVolume* voSaa1Wring2 = new TGeoVolume("YSAA1_WRING2", shSaa1Wring2, kMedNiW);
697
698 ///////////////////////////////////
699 //    SAA1 W-Ring 3              //
700 //    Drawing ALIP2A__0216       //
701 ///////////////////////////////////
702
703       Float_t saa1Wring3Rinner  = 20.31;
704       Float_t saa1Wring3Router  = 23.40;
705       Float_t saa1Wring3HWidth  =  3.75;
706       Float_t saa1Wring3Cutoffx =  4.50;
707       Float_t saa1Wring3Cutoffy =  4.40;
708       TGeoTubeSeg* shSaa1Wring3a  = new TGeoTubeSeg(saa1Wring3Rinner, saa1Wring3Router, saa1Wring3HWidth, 0., 90.);
709       shSaa1Wring3a->SetName("shSaa1Wring3a");
710       TGeoBBox* shSaa1Wring3b  = new TGeoBBox(saa1Wring3Router / 2., saa1Wring3Router / 2., saa1Wring3HWidth);
711       shSaa1Wring3b->SetName("shSaa1Wring3b");
712       TGeoTranslation* trSaa1Wring3b 
713           = new TGeoTranslation("trSaa1Wring3b", saa1Wring3Router / 2. + saa1Wring3Cutoffx, saa1Wring3Router / 2. + saa1Wring3Cutoffy, 0.);
714       trSaa1Wring3b->RegisterYourself();
715       TGeoCompositeShape*  shSaa1Wring3 = new TGeoCompositeShape("shSaa1Wring3", "(shSaa1Wring3a)*(shSaa1Wring3b:trSaa1Wring3b)");
716       TGeoVolume* voSaa1Wring3 = new TGeoVolume("YSAA1_WRING3", shSaa1Wring3, kMedNiW);
717
718 ///////////////////////////////////
719 //    SAA1 W-Ring 4              //
720 //    Drawing ALIP2A__0215       //
721 ///////////////////////////////////
722       Float_t saa1Wring4Width  =  5.85;
723       TGeoPcon* shSaa1Wring4  = new TGeoPcon(0., 360., 5);
724       shSaa1Wring4->DefineSection(0, 0.00, 20.31, 23.40);
725       shSaa1Wring4->DefineSection(1, 1.00, 20.31, 23.40);
726       shSaa1Wring4->DefineSection(2, 1.00, 20.31, 24.50);      
727       shSaa1Wring4->DefineSection(3, 4.85, 20.31, 24.80);
728       shSaa1Wring4->DefineSection(4, 5.85, 24.10, 24.80);
729       TGeoVolume* voSaa1Wring4  =  new TGeoVolume("YSAA1_WRING4", shSaa1Wring4, kMedNiW);
730
731 ///////////////////////////////////
732 //    SAA1 W-Ring 5              //
733 //    Drawing ALIP2A__0218       //
734 ///////////////////////////////////
735       Float_t saa1Wring5Rinner = 20.31;
736       Float_t saa1Wring5Router = 23.40;
737       Float_t saa1Wring5HWidth =  0.85;
738       TGeoVolume* voSaa1Wring5    = new TGeoVolume("YSAA1_WRING5", 
739                                                    new TGeoTube(saa1Wring5Rinner, saa1Wring5Router, saa1Wring5HWidth), kMedNiW);
740 //
741 // Position the rings in the assembly 
742 //      
743       TGeoVolumeAssembly* asSaa1ExtraShield = new TGeoVolumeAssembly("YSAA1ExtraShield");
744 // Distance between rings
745       Float_t saa1DWrings = 2.3;
746 //
747       dz = - (saa1Wring1Width + 6. * saa1Wring2HWidth + 2. * saa1Wring3HWidth + saa1Wring4Width + 2. * saa1Wring5HWidth + 2. * saa1DWrings) / 2.;
748       asSaa1ExtraShield->AddNode(voSaa1Wring1,    1, new TGeoTranslation(0., 0., dz));
749       dz +=   saa1Wring1Width;
750       dz +=   saa1Wring2HWidth;   
751       asSaa1ExtraShield->AddNode(voSaa1Wring2,    1, new TGeoCombiTrans(0., 0., dz, rot000));
752       asSaa1ExtraShield->AddNode(voSaa1Wring2,    2, new TGeoCombiTrans(0., 0., dz, rot180));
753       dz +=   saa1Wring2HWidth;   
754       dz +=   saa1DWrings;
755       dz +=   saa1Wring2HWidth;   
756       asSaa1ExtraShield->AddNode(voSaa1Wring2,    3, new TGeoCombiTrans(0., 0., dz, rot090));
757       asSaa1ExtraShield->AddNode(voSaa1Wring2,    4, new TGeoCombiTrans(0., 0., dz, rot270));
758       dz +=   saa1Wring2HWidth;   
759       dz +=   saa1Wring5HWidth;   
760       asSaa1ExtraShield->AddNode(voSaa1Wring5,    1, new TGeoTranslation(0., 0., dz));
761       dz +=   saa1Wring5HWidth;   
762       dz +=   saa1Wring2HWidth;   
763       asSaa1ExtraShield->AddNode(voSaa1Wring2,    5, new TGeoCombiTrans(0., 0., dz, rot000));
764       asSaa1ExtraShield->AddNode(voSaa1Wring2,    6, new TGeoCombiTrans(0., 0., dz, rot180));
765       dz +=   saa1Wring2HWidth;   
766       dz +=   saa1DWrings;
767       dz +=   saa1Wring3HWidth;   
768       asSaa1ExtraShield->AddNode(voSaa1Wring3,    1, new TGeoCombiTrans(0., 0., dz, rot090));
769       asSaa1ExtraShield->AddNode(voSaa1Wring3,    2, new TGeoCombiTrans(0., 0., dz, rot270));
770       dz +=   saa1Wring3HWidth;   
771       asSaa1ExtraShield->AddNode(voSaa1Wring4,    1, new TGeoTranslation(0., 0., dz));
772       dz +=   saa1Wring4Width;   
773       const Float_t saa1ExtraShieldL = 48;
774 //
775 // Assemble SAA1
776       voSaa1M->AddNode(voSaa1StEnv,     1, gGeoIdentity);
777       voSaa1M->AddNode(voSaa1WPipe,     1, gGeoIdentity);
778       voSaa1M->AddNode(voSaa1PbComp,    1, gGeoIdentity);
779       voSaa1M->AddNode(voSaa1WCone,     1, gGeoIdentity);
780       voSaa1M->AddNode(voSaa1StRing,    1, gGeoIdentity);
781       voSaa1M->AddNode(voSaa1InnerTube, 1, new TGeoTranslation(0., 0., dzSaa1InnerTube + 0.9));               
782       TGeoVolumeAssembly* voSaa1 = new TGeoVolumeAssembly("YSAA1");
783       voSaa1->AddNode(voSaa1M, 1, gGeoIdentity);
784       
785 ///////////////////////////////////////
786 //          SAA1/SAA2  Pb Joint      //
787 //          Drawing ALIP2A__0081     //
788 ///////////////////////////////////////
789 //
790 // Outer radius
791       Float_t rOuSaa1Saa2      = 70.0/2.;
792 // Flange SAA1 side
793       Float_t dzSaa1Saa2F1     =  3.;
794       Float_t rInSaa1Saa2F1    = 58.5/2.;
795 // 1st Central Section
796       Float_t dzSaa1Saa2C1     = 19.3;
797       Float_t rInSaa1Saa2C1    = 42.8/2.;
798 // Transition Region
799       Float_t dzSaa1Saa2T      =  3.3;
800 // 1st Central Section
801       Float_t dzSaa1Saa2C2     =  6.2;
802       Float_t rInSaa1Saa2C2    = 36.2/2.;
803 // Flange SAA2 side
804       Float_t dzSaa1Saa2F2     =  3.1;
805       Float_t rInSaa1Saa2F2    = 54.1/2.;
806 // Total length
807       Float_t dzSaa1Saa2       = 34.9;
808       
809       
810       TGeoPcon* shSaa1Saa2Pb = new TGeoPcon(0., 360., 8);
811       z = 0.;
812 // Flange SAA1 side
813       shSaa1Saa2Pb->DefineSection( 0,  z, rInSaa1Saa2F1, rOuSaa1Saa2);
814       z += dzSaa1Saa2F1;
815       shSaa1Saa2Pb->DefineSection( 1,  z, rInSaa1Saa2F1, rOuSaa1Saa2);
816       shSaa1Saa2Pb->DefineSection( 2,  z, rInSaa1Saa2C1, rOuSaa1Saa2);
817 // Central region 1
818       z +=  dzSaa1Saa2C1;
819       shSaa1Saa2Pb->DefineSection( 3,  z, rInSaa1Saa2C1, rOuSaa1Saa2);
820 // 45 deg transition
821       z += dzSaa1Saa2T;
822       shSaa1Saa2Pb->DefineSection( 4, z, rInSaa1Saa2C2, rOuSaa1Saa2);
823       z += dzSaa1Saa2C2;
824       shSaa1Saa2Pb->DefineSection( 5, z, rInSaa1Saa2C2, rOuSaa1Saa2);
825       shSaa1Saa2Pb->DefineSection( 6, z, rInSaa1Saa2F2, rOuSaa1Saa2);
826       z += dzSaa1Saa2F2;
827       shSaa1Saa2Pb->DefineSection( 7, z, rInSaa1Saa2F2, rOuSaa1Saa2);
828       TGeoVolume* voSaa1Saa2Pb = new TGeoVolume("YSAA1SAA2Pb", shSaa1Saa2Pb, kMedPb);
829 //
830 //    Mother volume and outer steel envelope
831       Float_t rOuSaa1Saa2Steel = 36.9;
832       
833       TGeoPcon* shSaa1Saa2 = MakeShapeFromTemplate(shSaa1Saa2Pb, 0., rOuSaa1Saa2Steel-rOuSaa1Saa2);
834       TGeoVolume* voSaa1Saa2 = new TGeoVolume("YSAA1SAA2", shSaa1Saa2, kMedSteel);
835       voSaa1Saa2->AddNode(voSaa1Saa2Pb, 1, gGeoIdentity);
836 //
837 //    Inner region with higher transport cuts
838 //
839       TGeoPcon*   shSaa1Saa2I = MakeShapeFromTemplate(shSaa1Saa2Pb, 0., -3.);
840       TGeoVolume* voSaa1Saa2I = new TGeoVolume("YSAA1_SAA2I", shSaa1Saa2I, kMedPbSh);
841       voSaa1Saa2Pb->AddNode(voSaa1Saa2I, 1, gGeoIdentity);
842       
843
844
845 ///////////////////////////////////////
846 //                SAA2               //
847 ///////////////////////////////////////
848
849       
850 ///////////////////////////////////
851 //    SAA2 Steel Envelope        //
852 //    Drawing ALIP2A__0041       //
853 ///////////////////////////////////
854       dSt = 4.;  // Thickness of steel envelope
855       // Length of the first section
856       Float_t dzSaa2StEnv1  = 163.15;
857       Float_t rInSaa2StEnv1 = 65.8/2.;
858       // Length of the second section
859       Float_t dzSaa2StEnv2  = 340.35 - 4.;
860       Float_t rInSaa2StEnv2 = 87.2/2.;
861       // Rel. starting position 
862       Float_t zSaa2StEnv = 3.;
863       
864       TGeoPcon* shSaa2StEnv  = new TGeoPcon(0., 360., 6);
865       // First Section
866       z = zSaa2StEnv;
867       shSaa2StEnv->DefineSection( 0, z, rInSaa2StEnv1, rInSaa2StEnv1 + dSt);
868       z += dzSaa2StEnv1;
869       shSaa2StEnv->DefineSection( 1, z, rInSaa2StEnv1, rInSaa2StEnv1 + dSt);
870       // Transition region
871       shSaa2StEnv->DefineSection( 2, z, rInSaa2StEnv1, rInSaa2StEnv2 + dSt);           
872       z += dSt;
873       shSaa2StEnv->DefineSection( 3, z, rInSaa2StEnv1, rInSaa2StEnv2 + dSt);          
874       // Second section
875       shSaa2StEnv->DefineSection( 4, z, rInSaa2StEnv2, rInSaa2StEnv2 + dSt);           
876       z += dzSaa2StEnv2;
877       shSaa2StEnv->DefineSection( 5, z, rInSaa2StEnv2, rInSaa2StEnv2 + dSt);           
878
879       TGeoVolume* voSaa2StEnv  =  new TGeoVolume("YSAA2_SteelEnvelope", shSaa2StEnv, kMedSteel);
880
881
882 ///////////////////////////////////
883 //    SAA2 Pb Ring               //
884 //    Drawing ALIP2A__0080       //
885 //    Drawing ALIP2A__0111       //
886 ///////////////////////////////////
887 //
888 // Rel. position in z
889       Float_t zSaa2PbRing    = 35.25;  
890 // Length
891       Float_t dzSaa2PbRing   = 65.90;  
892 // Inner radius
893       Float_t rInSaa2PbRing  = 37.00;
894 // Outer radius at front
895       Float_t rOuSaa2PbRingF = 42.74;
896 // Outer Rradius at rear
897       Float_t rOuSaa2PbRingR = 44.58;      
898       
899       TGeoPcon* shSaa2PbRing  = new TGeoPcon(0., 360., 2);
900       z = zSaa2PbRing;
901       shSaa2PbRing->DefineSection(0, z, rInSaa2PbRing, rOuSaa2PbRingF);
902       z += dzSaa2PbRing;
903       shSaa2PbRing->DefineSection(1, z, rInSaa2PbRing, rOuSaa2PbRingR);
904
905       TGeoVolume* voSaa2PbRing  =  new TGeoVolume("YSAA2_PbRing", shSaa2PbRing, kMedPb);
906
907
908 ///////////////////////////////////
909 //    SAA2 Pb Components         //
910 //    Drawing ALIP2A__0079       //
911 ///////////////////////////////////
912       tanAlpha = TMath::Tan(1.89 / 2. * kDegRad);
913       TGeoPcon* shSaa2PbComp  = new TGeoPcon(0., 360., 16);
914       // Total length 
915       Float_t dzSaa2PbComp    = 512.;
916       // Length of 1st bellow recess
917       Float_t dzSaa2PbCompB1  =  24.;
918       // Length of 2nd bellow recess
919       Float_t dzSaa2PbCompB2   = 27.;
920       // Flange on the SAA1 side Detail A
921       // 1st Step
922       Float_t dzSaa2PbCompA1  =   1.5;
923       Float_t rInSaa2PbCompA1 =  43.0/2.;
924       Float_t rOuSaa2PbCompA1 =  53.0/2.;
925       // 2nd Step
926       Float_t dzSaa2PbCompA2  =   1.5;
927       Float_t rInSaa2PbCompA2 =  36.8/2.;
928       Float_t rOuSaa2PbCompA2 =  rOuSaa2PbCompA1;
929       // Straight section
930       Float_t dzSaa2PbCompA3  =  21.0;
931       Float_t rInSaa2PbCompA3 =  rInSaa2PbCompA2;
932       Float_t rOuSaa2PbCompA3 =  65.2/2.;
933       //
934       // 1st Section (outer straight, inner 1.89/2. deg opening cone)
935       // Length
936       Float_t dzSaa2PbComp1   = 146.15;
937       // Inner radius at the end 
938       Float_t rInSaa2PbComp1  = rInSaa2PbCompA3 + dzSaa2PbComp1 * tanAlpha;
939       // Outer radius
940       Float_t rOuSaa2PbComp1  = rOuSaa2PbCompA3;
941       //
942       // 2nd Section (outer straight, inner 1.89/2. deg opening cone)
943       // Length 
944       Float_t dzSaa2PbComp2   = (dzSaa2PbComp - dzSaa2PbComp1 - dzSaa2PbCompB1 - dzSaa2PbCompB2);
945       // Inner radius at the end 
946       Float_t rInSaa2PbComp2  = rInSaa2PbComp1 + dzSaa2PbComp2 * tanAlpha;
947       // Outer radius
948       Float_t rOuSaa2PbComp2  = 86.6/2.;
949       //
950       // Flange on the SAA3 side (Detail E)
951       //
952       // Straight Section
953       // Length  dzSaa2PbCompB2 - 8.8 = 27 - 8.8 = 18.2
954       Float_t dzSaa2PbCompE1  =  18.2;
955       Float_t rInSaa2PbCompE1 =  52.0/2.;
956       Float_t rOuSaa2PbCompE1 =  86.6/2.;
957       // 45 deg transition
958       Float_t dzSaa2PbCompE2  =   2.7;
959       // 1st Step
960       Float_t dzSaa2PbCompE3  =   0.6;
961       Float_t rInSaa2PbCompE3 =  52.0/2.+ dzSaa2PbCompE2;
962       Float_t rOuSaa2PbCompE3 =  83.0/2.;
963       // 2nd Step
964       Float_t dzSaa2PbCompE4  =   4.0;
965       Float_t rOuSaa2PbCompE4 =  61.6/2.;
966       // end
967       Float_t dzSaa2PbCompE5  =   1.5;
968
969
970       //
971       // Flange on SAA1 side (Detail A)
972       z = 0.;
973       // 1st Step
974       shSaa2PbComp->DefineSection(  0,  z, rInSaa2PbCompA1, rOuSaa2PbCompA1);
975       z += dzSaa2PbCompA1;
976       shSaa2PbComp->DefineSection(  1,  z, rInSaa2PbCompA1, rOuSaa2PbCompA1);
977       shSaa2PbComp->DefineSection(  2,  z, rInSaa2PbCompA2, rOuSaa2PbCompA2);
978       // 2nd Step
979       z += dzSaa2PbCompA2;
980       shSaa2PbComp->DefineSection(  3,  z, rInSaa2PbCompA2, rOuSaa2PbCompA2);
981       shSaa2PbComp->DefineSection(  4,  z, rInSaa2PbCompA3, rOuSaa2PbCompA3);
982       // straight section
983       z += dzSaa2PbCompA3;
984       shSaa2PbComp->DefineSection(  5,  z, rInSaa2PbCompA3, rOuSaa2PbCompA3);
985       //
986       // Section 1
987       z += dzSaa2PbComp1;
988       shSaa2PbComp->DefineSection(  6,  z, rInSaa2PbComp1, rOuSaa2PbComp1);
989       shSaa2PbComp->DefineSection(  7,  z, rInSaa2PbComp1, rOuSaa2PbComp2);
990       //
991       // Section 2
992       z += dzSaa2PbComp2;
993       shSaa2PbComp->DefineSection(  8,  z, rInSaa2PbComp2, rOuSaa2PbComp2);
994       //
995       // Flange SAA3 side (Detail E)
996       z += dzSaa2PbCompE1;
997       shSaa2PbComp->DefineSection(  9,  z, rInSaa2PbCompE1, rOuSaa2PbCompE1);
998       // 45 deg transition
999       z += dzSaa2PbCompE2;
1000       shSaa2PbComp->DefineSection( 10,  z, rInSaa2PbCompE3, rOuSaa2PbCompE1);
1001       // 1st step
1002       z += dzSaa2PbCompE3;
1003       shSaa2PbComp->DefineSection( 11,  z, rInSaa2PbCompE3, rOuSaa2PbCompE1);
1004       shSaa2PbComp->DefineSection( 12,  z, rInSaa2PbCompE3, rOuSaa2PbCompE3);
1005       // 2nd step
1006       z += dzSaa2PbCompE4;
1007       shSaa2PbComp->DefineSection( 13,  z, rInSaa2PbCompE3, rOuSaa2PbCompE3);
1008       shSaa2PbComp->DefineSection( 14,  z, rInSaa2PbCompE3, rOuSaa2PbCompE4);
1009       // end
1010       z += dzSaa2PbCompE5;
1011       shSaa2PbComp->DefineSection( 15,  z, rInSaa2PbCompE3, rOuSaa2PbCompE4);
1012
1013       TGeoVolume* voSaa2PbComp  =  new TGeoVolume("YSAA2_PbComp", shSaa2PbComp, kMedPbSh);
1014
1015
1016 ///////////////////////////////////
1017 //    SAA2 Inner Tube            //
1018 //    Drawing ALIP2A__0083       //
1019 ///////////////////////////////////
1020 //
1021 //
1022 //
1023 // Length of saa2:               512.0 cm
1024 // Length of inner tube:         501.7 cm 
1025 // Lenth of bellow recess:        10.3 cm   ( 1.5 + 8.8) 
1026 // Radius at entrance 36.8/2,  d = 0.1
1027 // Radius at exit     52.0/2,  d = 0.1 
1028 //
1029       const Float_t kSaa2InnerTubeL     =  501.7;    // Length of the tube  
1030       const Float_t kSaa2InnerTubeRmin  =  36.6/2.;  // Radius at entrance
1031       const Float_t kSaa2InnerTubeRmax  =  51.8/2.;  // Radius at exit
1032       const Float_t kSaa2InnerTubeD     =   0.2   ;  // Thickness     
1033       TGeoPcon*   shSaa2InnerTube = new TGeoPcon(0., 360., 4);
1034       z = 0.;
1035       shSaa2InnerTube->DefineSection( 0, z, kSaa2InnerTubeRmin - kSaa2InnerTubeD, kSaa2InnerTubeRmin);
1036       z += dzSaa2PbCompA2 + dzSaa2PbCompA3;
1037       shSaa2InnerTube->DefineSection( 1, z, kSaa2InnerTubeRmin - kSaa2InnerTubeD, kSaa2InnerTubeRmin);
1038       z =  kSaa2InnerTubeL - dzSaa2PbCompE1;
1039       shSaa2InnerTube->DefineSection( 2, z, kSaa2InnerTubeRmax - kSaa2InnerTubeD, kSaa2InnerTubeRmax);
1040       z =  kSaa2InnerTubeL;
1041       shSaa2InnerTube->DefineSection( 3, z, kSaa2InnerTubeRmax - kSaa2InnerTubeD, kSaa2InnerTubeRmax);
1042       TGeoVolume* voSaa2InnerTube = new TGeoVolume("YSAA2_InnerTube", shSaa2InnerTube, kMedSteelSh);
1043       
1044 ///////////////////////////////////
1045 //    SAA2 Steel Ring            //
1046 //    Drawing ALIP2A__0042       //
1047 ///////////////////////////////////
1048       //  HalfWidth
1049       Float_t dzSaa2SteelRing = 2.;
1050       TGeoTube*   shSaa2SteelRing  = new TGeoTube(41.6, 47.6, dzSaa2SteelRing);
1051       TGeoVolume* voSaa2SteelRing  = new TGeoVolume("YSAA2_SteelRing", shSaa2SteelRing, kMedSteel);
1052
1053 ///////////////////////////////////
1054 //    SAA2 Outer Shape           //
1055 //    Drawing ALIP2A__0108       //
1056 ///////////////////////////////////
1057
1058       TGeoPcon* shSaa2  = new TGeoPcon(0., 360., 16);
1059       kSec = 0.02; // security distance to avoid trivial extrusions
1060       rmin = kSaa2InnerTubeRmin - kSaa2InnerTubeD - kSec;
1061       rmax = kSaa2InnerTubeRmax - kSaa2InnerTubeD - kSec;
1062       // Flange SAA1 side
1063       z = 0.;
1064       shSaa2->DefineSection( 0, z, rmin           , rOuSaa2PbCompA1);
1065       z += dzSaa2PbCompA1 + dzSaa2PbCompA2;
1066       shSaa2->DefineSection( 1, z, rmin           , rOuSaa2PbCompA1);
1067       shSaa2->DefineSection( 2, z, rmin           , rInSaa2StEnv1 + dSt);
1068       z += dzSaa2PbCompA3;
1069       shSaa2->DefineSection( 3, z, rmin           , rInSaa2StEnv1 + dSt);
1070       z = zSaa2PbRing;
1071       shSaa2->DefineSection( 4, z, 0.             , rInSaa2StEnv1 + dSt);
1072       shSaa2->DefineSection( 5, z, 0.             , rOuSaa2PbRingF);
1073       z += dzSaa2PbRing;
1074       shSaa2->DefineSection( 6, z, 0.             , rOuSaa2PbRingR);
1075       shSaa2->DefineSection( 7, z, 0.             , rInSaa2StEnv1 + dSt);
1076       z = dzSaa2PbCompA1 + dzSaa2PbCompA2 + dzSaa2StEnv1;
1077       shSaa2->DefineSection( 8, z, 0.             , rInSaa2StEnv1 + dSt);
1078       shSaa2->DefineSection( 9, z, 0.             , rInSaa2StEnv2 + dSt);
1079       z = dzSaa2PbComp - dzSaa2PbCompB2;
1080       shSaa2->DefineSection(10, z, rmax           , rInSaa2StEnv2 + dSt);
1081       z += dzSaa2PbCompE1;
1082       shSaa2->DefineSection(11, z, rmax           , rInSaa2StEnv2 + dSt);
1083       z += dzSaa2PbCompE2;
1084       shSaa2->DefineSection(12, z, rInSaa2PbCompE3, rInSaa2StEnv2 + dSt);
1085       z += (dzSaa2PbCompE3 + dzSaa2PbCompE4);
1086       shSaa2->DefineSection(13, z, rInSaa2PbCompE3, rInSaa2StEnv2 + dSt);
1087       shSaa2->DefineSection(14, z, rInSaa2PbCompE3, rOuSaa2PbCompE4);
1088       z += dzSaa2PbCompE5;
1089       shSaa2->DefineSection(15, z, rInSaa2PbCompE3, rOuSaa2PbCompE4);
1090
1091       TGeoVolume* voSaa2  =  new TGeoVolume("YSAA2", shSaa2, kMedAir);
1092       voSaa2->SetVisibility(0);
1093 // Inner 1.89/2 deg line
1094       Double_t zref   = dzSaa2PbCompA1 + dzSaa2PbCompA2 + dzSaa2PbCompA3;
1095       for (Int_t i  = 4; i < 10; i++) {
1096           Double_t zp = shSaa2->GetZ(i);
1097           Double_t r2 = shSaa2->GetRmax(i);      
1098           Double_t r1 = rmin + (zp -  zref) * TMath::Tan(1.89 / 2. * kDegRad) - kSec;
1099           shSaa2->DefineSection(i, zp, r1, r2);
1100       }
1101
1102 //
1103 //    Assemble SAA2
1104       voSaa2->AddNode(voSaa2StEnv,     1, gGeoIdentity);
1105       voSaa2->AddNode(voSaa2PbRing,    1, gGeoIdentity);
1106       voSaa2->AddNode(voSaa2PbComp,    1, gGeoIdentity);
1107       voSaa2->AddNode(voSaa2InnerTube, 1, new TGeoTranslation(0., 0., dzSaa2PbCompA1));
1108       z = (dzSaa2PbComp - dzSaa2PbCompE4 - dzSaa2PbCompE5) + dzSaa2SteelRing;
1109       voSaa2->AddNode(voSaa2SteelRing, 1, new TGeoTranslation(0., 0., z));
1110
1111
1112 ///////////////////////////////////////
1113 //                SAA3               //
1114 ///////////////////////////////////////
1115 //
1116 //
1117 //  This is a study performed by S. Maridor
1118 //  The SAA3 has not yet been designed !!!!!!!!
1119 //
1120 ///////////////////////////////////
1121 //    SAA3 Outer Shape           //
1122 //    Drawing ALIP2A__0288       //
1123 ///////////////////////////////////
1124       
1125       TGeoVolumeAssembly* voSaa3  = new TGeoVolumeAssembly("YSAA3");
1126       
1127 ///////////////////////////////////
1128 //    SAA3 Concrete cone         //
1129 //    Drawing ALIP2A__0284       //
1130 ///////////////////////////////////
1131 //    Block
1132       TGeoBBox* shSaa3CCBlockO   = new TGeoBBox(80./2., 80./2., 100./2.);
1133       shSaa3CCBlockO->SetName("Saa3CCBlockO");
1134
1135       TGeoPcon* shSaa3InnerRegion  = new TGeoPcon(0., 360., 4);
1136       shSaa3InnerRegion->DefineSection( 0, -60.0, 0., 27.1);
1137       shSaa3InnerRegion->DefineSection( 1, -23.0, 0., 27.1);
1138       shSaa3InnerRegion->DefineSection( 2,  29.1, 0., 12.3);
1139       shSaa3InnerRegion->DefineSection( 3,  60.0, 0., 12.3);
1140       shSaa3InnerRegion->SetName("Saa3InnerRegion");
1141
1142       TGeoCompositeShape* shSaa3CCBlock = new TGeoCompositeShape("Saa3CCBlock", "Saa3CCBlockO-Saa3InnerRegion");
1143       TGeoVolume* voSaa3CCBlock         = new TGeoVolume("YSAA3CCBlock", shSaa3CCBlock, kMedConcSh);     
1144
1145
1146       voSaa3->AddNode(voSaa3CCBlock, 1, gGeoIdentity);
1147       
1148 //    Plate 1: 240 cm x 80 cm x 100 cm (x 2)
1149       TGeoVolume* voSaa3SteelPlate1  =  new TGeoVolume("YSAA3SteelPlate1", 
1150                                                        new TGeoBBox(240./2., 80./2., 100./2.),
1151                                                        kMedSteelSh);
1152       TGeoVolume* voSaa3SteelPlate11 =  new TGeoVolume("YSAA3SteelPlate11", 
1153                                                        new TGeoBBox(240./2., 80./2., 10./2.),
1154                                                        kMedSteel);
1155       voSaa3SteelPlate1->AddNode(voSaa3SteelPlate11, 1, new TGeoTranslation(0., 0., -45.));
1156       voSaa3->AddNode(voSaa3SteelPlate1, 1, new TGeoTranslation(0., +80., 0.));
1157       voSaa3->AddNode(voSaa3SteelPlate1, 2, new TGeoTranslation(0., -80., 0.));
1158
1159
1160 //    Plate 2:  80 cm x 80 cm x 100 cm (x 2)
1161       TGeoVolume* voSaa3SteelPlate2  =  new TGeoVolume("YSAA3SteelPlate2", 
1162                                                        new TGeoBBox( 80./2., 80./2., 100./2.),
1163                                                        kMedSteelSh);
1164       TGeoVolume* voSaa3SteelPlate21 =  new TGeoVolume("YSAA3SteelPlate21", 
1165                                                        new TGeoBBox( 80./2., 80./2., 10./2.),
1166                                                        kMedSteel);
1167       voSaa3SteelPlate2->AddNode(voSaa3SteelPlate21, 1, new TGeoTranslation(0., 0., -45.));
1168
1169       voSaa3->AddNode(voSaa3SteelPlate2, 1, new TGeoTranslation(+80, 0., 0.));
1170       voSaa3->AddNode(voSaa3SteelPlate2, 2, new TGeoTranslation(-80, 0., 0.));
1171
1172
1173 ///////////////////////////////////
1174 //    Muon Filter                //
1175 //    Drawing ALIP2A__0105       //
1176 ///////////////////////////////////
1177       // Half Length 
1178       Float_t dzMuonFilter = 60.;
1179       
1180       TGeoBBox*   shMuonFilterO  = new TGeoBBox(550./2., 620./2., dzMuonFilter);
1181       shMuonFilterO->SetName("FilterO");
1182       TGeoCombiTrans* trFilter = new TGeoCombiTrans("trFilter", 0., -dzMuonFilter * TMath::Tan(alhc * kDegrad), 0., rotlhc);
1183       trFilter->RegisterYourself();
1184       TGeoTube*   shMuonFilterI  = new TGeoTube(0., 48.8, dzMuonFilter + 20.);
1185       shMuonFilterI->SetName("FilterI");
1186       TGeoCompositeShape* shMuonFilter = new TGeoCompositeShape("MuonFilter", "FilterO-FilterI:trFilter");
1187       //
1188       // !!!!! Needs to be inclined
1189       TGeoVolume* voMuonFilter = new TGeoVolume("YMuonFilter", shMuonFilter, kMedSteel);
1190
1191       // Inner part with higher transport cuts
1192       Float_t dzMuonFilterH = 50.;
1193       TGeoBBox*   shMuonFilterOH  = new TGeoBBox(550./2., 620./2., dzMuonFilterH);
1194       shMuonFilterOH->SetName("FilterOH");
1195       TGeoTube*   shMuonFilterIH  = new TGeoTube(0., 50., dzMuonFilterH + 5.);
1196       shMuonFilterIH->SetName("FilterIH");
1197       TGeoCompositeShape* shMuonFilterH = new TGeoCompositeShape("MuonFilterH", "FilterOH-FilterIH:trFilter");
1198       TGeoVolume* voMuonFilterH = new TGeoVolume("YMuonFilterH", shMuonFilterH, kMedSteelSh);
1199       voMuonFilter->AddNode(voMuonFilterH, 1, gGeoIdentity);
1200       
1201 //  
1202       TGeoVolumeAssembly* voSaa  = new TGeoVolumeAssembly("YSAA");
1203 //
1204 //    
1205 //    
1206 //
1207 //
1208 //    Starting position of the FA Flange/Tail 
1209       Float_t ziFaWTail   = 499.0;
1210 //    End of the FA Flange/Tail
1211       Float_t zoFaWTail   = ziFaWTail + dzFaWTail;
1212 //    Starting position of the FA/SAA1 Joint (2.8 cm overlap with tail)
1213       Float_t ozFaSaa1    = 2.8;
1214       Float_t ziFaSaa1    = zoFaWTail - ozFaSaa1;
1215 //    End of the FA/SAA1 Joint
1216       Float_t zoFaSaa1    = ziFaSaa1 +  dzFaSaa1;
1217 //    Starting position of SAA1 (2.0 cm overlap with joint)     
1218       Float_t ozSaa1      = 2.;
1219       Float_t ziSaa1      = zoFaSaa1 - ozSaa1;
1220 //    End of SAA1
1221       Float_t zoSaa1      = ziSaa1 + dzSaa1;
1222 //    Starting position of SAA1/SAA2 Joint (1.95 cm overlap with SAA1)
1223       Float_t ziSaa1Saa2  = zoSaa1 - 1.95;
1224 //    End of SAA1/SAA2 Joint
1225       Float_t zoSaa1Saa2  = ziSaa1Saa2 + dzSaa1Saa2;
1226 //    Starting position of SAA2 (3.1 cm overlap with the joint)
1227       Float_t ziSaa2      = zoSaa1Saa2 - 3.1;
1228 //    End of SAA2
1229       Float_t zoSaa2      = ziSaa2 + dzSaa2PbComp;
1230 //    Position of SAA3
1231       Float_t zcSaa3      = zoSaa2 + 50.;
1232 //    Position of the Muon Filter
1233       Float_t zcFilter    = 1465.9 + dzMuonFilter;
1234
1235       voSaa->AddNode(voFaWTail,    1, new TGeoTranslation(0., 0., ziFaWTail));
1236       voSaa->AddNode(voFaSaa1,     1, new TGeoTranslation(0., 0., ziFaSaa1));
1237       voSaa->AddNode(voSaa1 ,      1, new TGeoTranslation(0., 0., ziSaa1));
1238       voSaa->AddNode(voSaa1Saa2,   1, new TGeoTranslation(0., 0., ziSaa1Saa2 - 0.1));
1239       voSaa->AddNode(voSaa2 ,      1, new TGeoTranslation(0., 0., ziSaa2));
1240       voSaa->AddNode(voSaa3,       1, new TGeoTranslation(0., 0., zcSaa3));
1241       
1242
1243       TGeoRotation* rotxz  = new TGeoRotation("rotxz",   90.,   0., 90.,  90., 180., 0.);
1244       top->AddNode(voSaa, 1, new TGeoCombiTrans(0., 0., 0., rotxz));
1245 //
1246 //  Mother volume for muon stations 1+2 and shielding material placed between the quadrants
1247 //
1248       // Position of the dipole
1249       Float_t ziDipole = 741.;
1250       
1251       TGeoPcon* shYOUT1 = new TGeoPcon(0., 360., 24);
1252       Float_t eps = 1.e-2;
1253       // FA Tail Section
1254       for (Int_t iz =  1; iz < 9; iz++) {
1255           z = shFaWTail->GetZ(iz+1);
1256           if (iz == 8) z -= ozFaSaa1;
1257           shYOUT1->DefineSection(iz-1, z + ziFaWTail, shFaWTail->GetRmax(iz+1) + eps, 150.);
1258       }
1259       // FA-SAA1 Joint
1260       z = shYOUT1->GetZ(7);
1261       
1262       for (Int_t iz =  9; iz < 17; iz++) 
1263           shYOUT1->DefineSection(iz-1, z + shFaSaa1->GetZ(iz-9), shFaSaa1->GetRmax(iz-9) + eps, 150.);
1264
1265       z = shYOUT1->GetZ(15) - ozSaa1;
1266       // SAA1  - Dipole
1267       for (Int_t iz = 17; iz < 24; iz++) 
1268           shYOUT1->DefineSection(iz-1, z + shSaa1M->GetZ(iz-13), shSaa1M->GetRmax(iz-13) + eps, 150.); 
1269       // Distance between dipole and start of SAA1 2deg opening cone
1270       dz   = ziDipole - (zSaa1StEnv[0] - dSt + zSaa1StEnvS + ziSaa1);
1271       rOut = rOuSaa1StEnv2 + dz * TMath::Tan(2. * kDegRad);
1272       
1273       shYOUT1->DefineSection(23, ziDipole, rOut + eps, 150.);
1274
1275       InvertPcon(shYOUT1);
1276       TGeoVolume* voYOUT1 = new TGeoVolume("YOUT1", shYOUT1, kMedAirMu);
1277       voYOUT1->SetVisibility(0);
1278
1279       voYOUT1->AddNode(asSaa1ExtraShield, 1, new TGeoCombiTrans(0., 0., - (100.7 + 62.2 + saa1ExtraShieldL / 2. + ziFaWTail), rotxz));
1280       voYOUT1->AddNode(asFaExtraShield,   1, new TGeoCombiTrans(0., 0., - (16.41 + kFaWring2HWidth + ziFaWTail), rotxz));
1281       top->AddNode(voYOUT1, 1, gGeoIdentity);
1282 //
1283 //  Mother volume for muon stations 4+5 and trigger stations.
1284 //
1285       Float_t zoDipole = 1249.;
1286       
1287       TGeoPcon* shYOUT21 = new TGeoPcon(0., 360., 14);
1288       z =  zoDipole;
1289       shYOUT21->DefineSection(0, z,             rOuSaa1String,       375.);
1290 //    Start of SAA1-SAA2
1291       z = ziSaa1Saa2;
1292       shYOUT21->DefineSection(1, z,             rOuSaa1String,       375.);
1293       shYOUT21->DefineSection(2, z,             rOuSaa1Saa2Steel,    375.);
1294 //    End of SAA1-SAA2
1295       z = ziSaa2;
1296       shYOUT21->DefineSection(3, z,             rOuSaa1Saa2Steel,    375.);
1297 //    SAA2
1298       shYOUT21->DefineSection( 4, z,            rInSaa2StEnv1 + dSt, 375.);
1299       z = ziSaa2 + zSaa2PbRing;
1300       shYOUT21->DefineSection( 5, z,            rInSaa2StEnv1 + dSt, 375.);
1301 //    Pb Cone
1302       shYOUT21->DefineSection( 6, z,            rOuSaa2PbRingF,      375.);
1303       rmin = rOuSaa2PbRingF + (1380. - z) * TMath::Tan(1.6 * kDegRad);
1304       shYOUT21->DefineSection( 7, 1380., rmin, 375.);
1305       shYOUT21->DefineSection( 8, 1380., rmin, 375.);
1306       z = ziSaa2 + zSaa2PbRing + dzSaa2PbRing;
1307       shYOUT21->DefineSection( 9, z,            rOuSaa2PbRingR,      375.);
1308 //    Straight Sections
1309       shYOUT21->DefineSection(10, z,            rInSaa2StEnv1 + dSt, 460.);
1310       z = ziSaa2 + dzSaa2StEnv1;
1311       shYOUT21->DefineSection(11, z,            rInSaa2StEnv1 + dSt, 460.);
1312       shYOUT21->DefineSection(12, z,            rInSaa2StEnv2 + dSt, 460.);
1313       z += dzSaa2StEnv2;
1314       shYOUT21->DefineSection(13, z,            rInSaa2StEnv2 + dSt, 460.);
1315             
1316       InvertPcon(shYOUT21);
1317       shYOUT21->SetName("shYOUT21");
1318
1319       TGeoBBox* shYOUT22 = new TGeoBBox(460. , 200., 65.);
1320       shYOUT22->SetName("shYOUT22");
1321       
1322       TGeoTranslation* tYOUT22 = new TGeoTranslation(0., -310. - 200., -zcFilter);
1323       tYOUT22->SetName("tYOUT22");
1324       tYOUT22->RegisterYourself();
1325       
1326
1327       TGeoCompositeShape* shYOUT2 = new TGeoCompositeShape("shYOUT2", "shYOUT21-shYOUT22:tYOUT22");
1328       
1329       TGeoVolume* voYOUT2 = new TGeoVolume("YOUT2", shYOUT2, kMedAirMu);
1330       voYOUT2->SetVisibility(1);
1331       voYOUT2->AddNode(voMuonFilter, 1, new TGeoCombiTrans(0., dzMuonFilter * TMath::Tan(alhc * kDegrad), -zcFilter, rotxzlhc));
1332       top->AddNode(voYOUT2, 1, gGeoIdentity);
1333 }
1334
1335 void AliSHILv3::Init()
1336 {
1337   //
1338   // Initialise the muon shield after it has been built
1339   //
1340   Int_t i;
1341   //
1342   if(AliLog::GetGlobalDebugLevel()>0) {
1343     printf("\n%s: ",ClassName());
1344     for(i=0;i<35;i++) printf("*");
1345     printf(" SHILv3_INIT ");
1346     for(i=0;i<35;i++) printf("*");
1347     printf("\n%s: ",ClassName());
1348     //
1349     // Here the SHIL initialisation code (if any!)
1350     for(i=0;i<80;i++) printf("*");
1351     printf("\n");
1352   }
1353 }
1354
1355 void AliSHILv3::InvertPcon(TGeoPcon* pcon)
1356 {
1357 //
1358 //  z -> -z
1359 // 
1360     Int_t nz = pcon->GetNz();
1361     Double_t* z    = new Double_t[nz];
1362     Double_t* rmin = new Double_t[nz];
1363     Double_t* rmax = new Double_t[nz];
1364
1365     Double_t*  z0    = pcon->GetZ();
1366     Double_t*  rmin0 = pcon->GetRmin();
1367     Double_t*  rmax0 = pcon->GetRmax();
1368     
1369     for (Int_t i = 0; i < nz; i++) {
1370         z[i] = z0[i];
1371         rmin[i] = rmin0[i];
1372         rmax[i] = rmax0[i];     
1373     }
1374     
1375     for (Int_t i = 0; i < nz; i++) {
1376         Int_t j = nz - i - 1;
1377         pcon->DefineSection(i, - z[j], rmin[j], rmax[j]);
1378     }
1379     
1380     delete[] z;
1381     delete[] rmin;
1382     delete[] rmax;
1383 }
1384
1385 TGeoPcon* AliSHILv3::MakeShapeFromTemplate(TGeoPcon* pcon, Float_t drMin, Float_t drMax)
1386 {
1387     // 
1388     // Returns new shape based on a template changing
1389     // the inner radii by drMin and the outer radii by drMax.
1390     //
1391     Int_t nz = pcon->GetNz();
1392     TGeoPcon* cpcon = new TGeoPcon(0., 360., nz);
1393     for (Int_t i = 0; i < nz; i++) 
1394         cpcon->DefineSection(i, pcon->GetZ(i), pcon->GetRmin(i) + drMin, pcon->GetRmax(i) + drMax);
1395     return cpcon;
1396 }
1397
1398