Adding more bins in QA (Alis)
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerGeometryBuilder.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 /// Class AliMUONTriggerGeometryBuilder
20 // -----------------------------------
21 // MUON Trigger stations geometry 
22 // construction class.
23 // Author: Philippe Crochet (LPCCFd)
24 // Support for trigger chambers added April 07 by Enrico Scomparin (INFN To)
25 //-----------------------------------------------------------------------------
26
27 #include <TVirtualMC.h>
28 #include <TGeoMatrix.h>
29 #include <TArrayI.h>
30
31 #include "AliLog.h"
32 #include "AliRun.h"
33
34 #include "AliMUONTriggerGeometryBuilder.h"
35 #include "AliMUON.h"
36 #include "AliMUONConstants.h"
37 #include "AliMUONGeometryModule.h"
38 #include "AliMUONGeometryEnvelopeStore.h"
39
40 using std::endl;
41 using std::cout;
42 /// \cond CLASSIMP
43 ClassImp(AliMUONTriggerGeometryBuilder)
44 /// \endcond
45
46 // vertical gap between right and left chambers (kDXZERO*2=4cm)
47 const Float_t AliMUONTriggerGeometryBuilder::fgkDXZERO=2.; 
48 // main distances for chamber definition in first plane/first station
49 const Float_t AliMUONTriggerGeometryBuilder::fgkXMIN=34.;       
50 const Float_t AliMUONTriggerGeometryBuilder::fgkXMED=51.;                                
51 const Float_t AliMUONTriggerGeometryBuilder::fgkXMAX=255.; 
52 // 090704 fgkXMAX changed from 272 to 255.
53 // (see fig.2-4 & 2-5 of Local Trigger Board PRR)
54 // segmentation updated accordingly
55 const Float_t AliMUONTriggerGeometryBuilder::fgkYMIN=34.;                              
56 const Float_t AliMUONTriggerGeometryBuilder::fgkYMAX=51.;                              
57 // inner/outer radius of flange between beam shield. and chambers (1/station)
58 //const Float_t AliMUONTriggerGeometryBuilder::fgkRMIN[2]={50.,50.};
59 //const Float_t AliMUONTriggerGeometryBuilder::fgkRMAX[2]={64.,68.};
60 // z position of the middle of the gas gap in mother vol 
61 const Float_t AliMUONTriggerGeometryBuilder::fgkZm=-3.6;
62 const Float_t AliMUONTriggerGeometryBuilder::fgkZp=+3.6;
63     
64 // y positions of vertical supports
65 const Float_t AliMUONTriggerGeometryBuilder::fgkYVSup[4]={61.45,122.45,192.95,236.95}; 
66 // dimensions of vertical supports 
67 const Float_t AliMUONTriggerGeometryBuilder::fgkSizeVSupExt[3]={1.5,1.5,306.+5.}; 
68 const Float_t AliMUONTriggerGeometryBuilder::fgkSizeVSupInt[3]={1.2,1.2,306.+5.};  
69 // transverse dimensions of angular supports 
70 const Float_t AliMUONTriggerGeometryBuilder::fgkSizeSupport1V[3]={0.,1.5,0.1}; 
71 const Float_t AliMUONTriggerGeometryBuilder::fgkSizeSupport1H[3]={0.,0.1,1.15}; // z should be 1.4 in the installed set-up 
72 const Float_t AliMUONTriggerGeometryBuilder::fgkSizeSupport2V[3]={0.,3.0,0.1}; 
73 const Float_t AliMUONTriggerGeometryBuilder::fgkSizeSupport2H[3]={0.,0.1,1.9}; 
74 const Float_t AliMUONTriggerGeometryBuilder::fgkSizeSupportXV[3]={0.,1.25,0.25}; 
75 const Float_t AliMUONTriggerGeometryBuilder::fgkSizeSupportXH[3]={0.,0.25,1.5}; 
76 // transverse dimensions of horizontal cable supports
77 const Float_t AliMUONTriggerGeometryBuilder::fgkSizeSupportCable[3]={0.,2.,3.}; 
78 // dimensions of gas pipes (inner and outer radius)
79 const Float_t AliMUONTriggerGeometryBuilder::fgkSizeGasPipe[3]={0.2,0.4,0.}; 
80 // Position of gas pipe with respect to angular support
81 const Float_t AliMUONTriggerGeometryBuilder::fgkOffsetGasPipe=0.75; 
82 // Small cut on some volumes to avoid extrusion from SC1x
83 const Float_t AliMUONTriggerGeometryBuilder::fgkAvoidExtrusion=2.9;    
84
85 //______________________________________________________________________________
86 AliMUONTriggerGeometryBuilder::AliMUONTriggerGeometryBuilder(AliMUON* muon)
87  : AliMUONVGeometryBuilder(16, 4),
88    fMUON(muon),
89    fIdtmed(0),
90    fIdAir(0),  
91    fIdAlu1(0),
92    fIdInox(0),
93    fYEnvPsave(0.), 
94    fYEnvMsave(0.), 
95    fDYsave(0.),
96    fDXsave(0.),
97    fRsupportpipe()
98 {
99 /// Standard constructor
100    fRsupportpipe.SetAngles(90.,90.,0.);
101 }
102
103 //______________________________________________________________________________
104 AliMUONTriggerGeometryBuilder::AliMUONTriggerGeometryBuilder()
105  : AliMUONVGeometryBuilder(),
106    fMUON(0),
107    fIdtmed(0),
108    fIdAir(0),  
109    fIdAlu1(0),
110    fIdInox(0),
111    fYEnvPsave(0.), 
112    fYEnvMsave(0.), 
113    fDYsave(0.),
114    fDXsave(0.),
115    fRsupportpipe()
116 {
117 /// Default constructor
118 }
119
120 //______________________________________________________________________________
121 AliMUONTriggerGeometryBuilder::~AliMUONTriggerGeometryBuilder() 
122 {
123 /// Destructor
124 }
125
126 //______________________________________________________________________________
127 TString AliMUONTriggerGeometryBuilder::GetVolumeName(const TString& volume, Int_t icount) const
128 {
129 // Function to generate a short volume name from its long variant
130
131   if ( volume == "volAlu" ) {
132     char volAlu[5];     // Alu 
133     snprintf(volAlu,5,"SC%dA",icount+1);
134     return volAlu;
135   }
136   else if ( volume == "volAluSupportH") {
137     char volAluSupportH[6];
138     snprintf(volAluSupportH,6,"SALH%d",icount+1);
139     return  volAluSupportH;
140   }         
141   else if ( volume == "volAirSupportH") {
142     char volAirSupportH[6];
143     snprintf(volAirSupportH,6,"SAIH%d",icount+1);
144     return  volAirSupportH;
145   }
146   else if ( volume == "volInoxGasPipe") {
147     char volInoxGasPipe[7];
148     snprintf(volInoxGasPipe,7,"SPINO%d",icount+1);
149     return volInoxGasPipe;
150   }
151   
152   AliErrorStream() << "Volume " << volume << " name is not defined." << endl; 
153   return "";
154 }
155
156 //______________________________________________________________________________
157 TString AliMUONTriggerGeometryBuilder::GetVolEnvName(Int_t icount, Int_t ienv) const
158 {
159 /// Compose envelope names as:
160 /// S0R1, S0R2, ..., S0R9, S0L1, S0L2, ..., S0L9
161 /// where ienv = 0, .., 17
162
163   TString name = "S";
164   name += icount;
165   if ( ienv < 9 ) {
166     name += "R";
167     name += (ienv + 1);
168   }  
169   else {
170     name += "L";
171     name += (ienv - 8) ;
172   }  
173   return name;
174 }     
175
176 //______________________________________________________________________________
177 TString AliMUONTriggerGeometryBuilder::GetVolAluAngSuppName(
178                                           const TString& type1234X, 
179                                           const TString& typeHV,
180                                           Int_t icount) const
181 {
182 /// Utility function to generate volume name 
183
184   TString name = "SA";
185   name += type1234X;
186   name += typeHV;
187   name += icount+1;
188   return name;
189 }  
190    
191 //______________________________________________________________________________
192 TString AliMUONTriggerGeometryBuilder::GetVolEnvSuppAngName(
193                                           const TString& type1234X, 
194                                           const TString& typeHV, 
195                                           const TString& typeABDEF,
196                                           Int_t icount, Int_t ivol) const
197 {
198 /// Utility function to generate volume name 
199
200   TString name = "S";
201   name += typeHV;
202   name += type1234X;
203   name += icount+1;
204   name += typeABDEF;
205   name += ivol;
206   return name;
207 }  
208
209 //______________________________________________________________________________
210 TString AliMUONTriggerGeometryBuilder::GetVolEnvInoxGasPipeName(
211                                           const TString& type12, 
212                                           const TString& typeABCDEF,
213                                           Int_t icount, Int_t ivol) const
214 {
215 /// Utility function to generate volume name 
216
217   TString name = "SP";
218   name += type12;
219   name += icount+1;
220   name += typeABCDEF;
221   name += ivol;
222   return name;
223 }  
224
225 //______________________________________________________________________________
226 void AliMUONTriggerGeometryBuilder::BuildChamberPrototype(Int_t icount) const
227 {   
228 /// Build chamber prototype
229
230     Float_t tpar[3];
231     tpar[0]= 0.;
232     tpar[1]= 0.;
233     tpar[2]= 0.;            
234     char volBak[5];     // Bakelite
235     char volGaz[5];     // Gas streamer     
236     snprintf(volBak,5,"SB%dA",icount+1);
237     snprintf(volGaz,5,"S%dG",icount+11);
238     gMC->Gsvolu(GetVolumeName("volAlu", icount),"BOX",fIdAlu1,tpar,0);         // Al
239     gMC->Gsvolu(volBak,"BOX",fIdtmed[1107],tpar,0);   // Bakelite
240     gMC->Gsvolu(volGaz,"BOX",fIdtmed[1106],tpar,0);   // Gas streamer
241     tpar[0] = -1.;
242     tpar[1] = -1.;
243     tpar[2] = 0.1;    
244     gMC->Gsposp(volGaz,1,volBak,0.,0.,0.,0,"ONLY",tpar,3);
245     tpar[2] = 0.3;
246     gMC->Gsposp(volBak,1,GetVolumeName("volAlu", icount),0.,0.,0.,0,"ONLY",tpar,3);
247 }    
248
249 //______________________________________________________________________________
250 void AliMUONTriggerGeometryBuilder::BuildRPCSupportsVertical(Int_t& iVolNum, Int_t icount) const
251 {
252 /// Build RPC vertical supports
253
254    Float_t zRatio = AliMUONConstants::DefaultRatioTriggerChamber(icount);                   
255    char volAluSupport[5],volAirSupport[5];
256    snprintf(volAluSupport,5,"SAL%d",icount+1);
257    snprintf(volAirSupport,5,"SAI%d",icount+1);
258    char volEnvSupport[12][7];
259    for(Int_t ii=0;ii<8;ii++){
260      snprintf(volEnvSupport[ii],7,"SEA%dV%d",icount+1,ii);
261    }
262    Float_t tpar[3];
263    tpar[0]= 0.;
264    tpar[1]= 0.;
265    tpar[2]= 0.;            
266    gMC->Gsvolu(volAluSupport,"BOX",fIdAlu1,tpar,0);
267    gMC->Gsvolu(volAirSupport,"BOX",fIdAir,tpar,0);
268    tpar[0]=fgkSizeVSupInt[0];
269    tpar[1]=fgkSizeVSupInt[1];
270    tpar[2]=-1.;
271    gMC->Gsposp(volAirSupport,1,volAluSupport,0.,0.,0.,0,"ONLY",tpar,3);
272    
273    TGeoRotation rsupportv;
274    rsupportv.SetAngles(0.,90.,0.);
275    Double_t dpar[3];
276    dpar[0]=fgkSizeVSupExt[0];
277    dpar[1]=fgkSizeVSupExt[1];
278    dpar[2]=fgkSizeVSupExt[2]*zRatio;
279    for(Int_t ii=0;ii<4;ii++){
280      GetEnvelopes(16+icount)->AddEnvelope(volEnvSupport[ii], 0, true,
281      TGeoTranslation(-fgkYVSup[ii]*zRatio,0.,0.),rsupportv);
282      GetEnvelopes(16+icount)
283      ->AddEnvelopeConstituentParam(volAluSupport,volEnvSupport[ii],iVolNum++,3, dpar);
284    }       
285    for(Int_t ii=4;ii<8;ii++){
286      GetEnvelopes(16+icount)->AddEnvelope(volEnvSupport[ii], 0, true,
287      TGeoTranslation(fgkYVSup[ii-4]*zRatio,0.,0.),rsupportv);
288      GetEnvelopes(16+icount)
289      ->AddEnvelopeConstituentParam(volAluSupport,volEnvSupport[ii],iVolNum++,3, dpar);
290    }   
291 }               
292
293 //______________________________________________________________________________
294 void AliMUONTriggerGeometryBuilder::BuildRPCSupportsHorizontal(Int_t icount) const
295
296 /// Build RPC horizontal supports   
297
298 // RPC supports (horizontal)
299
300 // supports for cables
301
302    Float_t tpar[3];
303    tpar[0]= 0.;
304    tpar[1]= 0.;
305    tpar[2]= 0.;  
306    TString volAluSupportH = GetVolumeName("volAluSupportH", icount);        
307    TString volAirSupportH = GetVolumeName("volAirSupportH", icount);        
308    gMC->Gsvolu(volAluSupportH,"BOX",fIdAlu1,tpar,0);
309    gMC->Gsvolu(volAirSupportH,"BOX",fIdAir,tpar,0);
310    tpar[0]=-1.;
311    tpar[1]=1.9;
312    tpar[2]=2.8;
313    gMC->Gsposp(volAirSupportH,1,volAluSupportH,0.,0.,0.,0,"ONLY",tpar,3);
314 }           
315
316 //______________________________________________________________________________
317 void AliMUONTriggerGeometryBuilder::BuildAngularSupportForChambers(Int_t icount) const
318 {
319 /// Build angular supports for chambers
320
321    Float_t tpar[3];
322    tpar[0]= 0.;
323    tpar[1]= 0.;
324    tpar[2]= 0.;            
325    gMC->Gsvolu(GetVolAluAngSuppName("1","V",icount),"BOX",fIdAlu1,tpar,0);
326    gMC->Gsvolu(GetVolAluAngSuppName("1","H",icount),"BOX",fIdAlu1,tpar,0);
327    gMC->Gsvolu(GetVolAluAngSuppName("2","V",icount),"BOX",fIdAlu1,tpar,0);
328    gMC->Gsvolu(GetVolAluAngSuppName("2","H",icount),"BOX",fIdAlu1,tpar,0);
329    gMC->Gsvolu(GetVolAluAngSuppName("3","V",icount),"BOX",fIdAlu1,tpar,0);
330    gMC->Gsvolu(GetVolAluAngSuppName("3","H",icount),"BOX",fIdAlu1,tpar,0);
331    gMC->Gsvolu(GetVolAluAngSuppName("4","V",icount),"BOX",fIdAlu1,tpar,0);
332    gMC->Gsvolu(GetVolAluAngSuppName("4","H",icount),"BOX",fIdAlu1,tpar,0);
333    gMC->Gsvolu(GetVolAluAngSuppName("X","V",icount),"BOX",fIdAlu1,tpar,0);
334    gMC->Gsvolu(GetVolAluAngSuppName("X","H",icount),"BOX",fIdAlu1,tpar,0);
335 }           
336
337 //______________________________________________________________________________
338 void AliMUONTriggerGeometryBuilder::BuildGasPipes(Int_t icount) const
339 {        
340 /// Build gas pipes
341    TString volInoxGasPipe = GetVolumeName("volInoxGasPipe", icount);
342    Float_t tpar[3];
343    tpar[0]= 0.;
344    tpar[1]= 0.;
345    tpar[2]= 0.;            
346    gMC->Gsvolu(volInoxGasPipe,"TUBE",fIdInox,tpar,0);
347 }          
348   
349 //______________________________________________________________________________
350 void AliMUONTriggerGeometryBuilder::BuildChamberTypeA(Int_t& iVolNum, Int_t icount) 
351 {
352 /// Build chamber type A and horizontal support 
353
354    Double_t dpar[3];    
355    Double_t spar[3];    
356    Double_t ppar[3];    
357
358 // chamber type A 
359    Float_t zRatio = AliMUONConstants::DefaultRatioTriggerChamber(icount);                   
360    Float_t xEnv = (fgkDXZERO+fgkXMED+(fgkXMAX-fgkXMED)/2.)*zRatio;
361    Float_t yEnvM = 0.;   // y low position of envelope in chamber
362    Float_t yEnvP = 0.;   // y up position of envelope in chamber
363    fYEnvPsave = 0.; // tmp data
364    fYEnvMsave = 0.; // tmp data
365    //Float_t xpos = 0.; // x position of RPC in envelope            
366    //Float_t ypos = 0.; // y position of RPC in envelope
367    dpar[2] = 0.4;           
368    dpar[0] = ((fgkXMAX-fgkXMED)/2.)*zRatio;
369    dpar[1] = fgkYMIN * zRatio;
370
371    Int_t detElemId = (10+icount+1)*100;
372    TString volEnv4 = GetVolEnvName(icount, 4);
373    TString volEnv13 = GetVolEnvName(icount, 13);
374    GetEnvelopes(16+icount)->AddEnvelope(volEnv4, detElemId, true,  
375    TGeoTranslation(xEnv,yEnvP,fgkZp));
376    detElemId = (10+icount+1)*100+9;
377    GetEnvelopes(16+icount)->AddEnvelope(volEnv13, detElemId, true,    
378    TGeoTranslation(-xEnv,yEnvM,fgkZm),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
379
380    TString volAlu = GetVolumeName("volAlu", icount);
381    GetEnvelopes(16+icount)->AddEnvelopeConstituentParam(volAlu,volEnv4,iVolNum++,3, dpar);
382    GetEnvelopes(16+icount)->AddEnvelopeConstituentParam(volAlu,volEnv13,iVolNum++,3, dpar);         
383
384 // horizontal cable support chamber type A
385    char volEnvSupportHA[6][8];
386    for(Int_t jj=0;jj<2;jj++){
387      for(Int_t ii=0;ii<6;ii++){
388        if(ii<3)snprintf(volEnvSupportHA[3*jj+ii],8,"SA%dHA%d",icount+1,3*jj+ii);
389      }
390    }
391
392    spar[0]=((fgkXMAX/2)-fgkYVSup[0]/2.)*zRatio;
393    spar[1]=fgkSizeSupportCable[1];
394    spar[2]=fgkSizeSupportCable[2];
395    Float_t offsetSuppA = ((fgkXMAX-fgkXMED)/2.)*zRatio-(((fgkXMAX/2)-fgkYVSup[0]/2.)*zRatio);
396    for(Int_t in=0;in<3;in++){
397      GetEnvelopes(16+icount)->AddEnvelope(volEnvSupportHA[in], 0, true, 
398      TGeoTranslation(xEnv+offsetSuppA/2.,yEnvP+dpar[1]/2.*(in-1),-(fgkSizeVSupExt[0]+spar[2])));    
399      GetEnvelopes(16+icount)->AddEnvelope(volEnvSupportHA[in+3], 0, true, 
400      TGeoTranslation(-(xEnv+offsetSuppA/2.),yEnvM+dpar[1]/2.*(in-1),fgkSizeVSupExt[0]+spar[2]),
401      TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
402    }
403    for(Int_t ii=0;ii<6;ii++) {
404      TString volAluSupportH = GetVolumeName("volAluSupportH", icount);
405      GetEnvelopes(16+icount)
406      ->AddEnvelopeConstituentParam(volAluSupportH,volEnvSupportHA[ii],iVolNum++,3, spar);
407    }  
408
409    spar[0]=dpar[0];
410    spar[1]=fgkSizeSupport1V[1];
411    spar[2]=fgkSizeSupport1V[2];
412    Float_t sparysave=spar[1];
413    TString volEnvSuppAng1VA0 = GetVolEnvSuppAngName("1", "V", "A", icount, 0);
414    TString volEnvSuppAng1VA1 = GetVolEnvSuppAngName("1", "V", "A", icount, 1);
415    
416    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VA0, 0, true,
417    TGeoTranslation(xEnv,yEnvP-dpar[1],fgkZp+dpar[2]+spar[2]));
418    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VA1, 0, true,
419    TGeoTranslation(-xEnv,yEnvM-dpar[1],fgkZm-dpar[2]-spar[2]),
420    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
421
422    TString volAluAngSupport1V = GetVolAluAngSuppName("1", "V", icount);
423    GetEnvelopes(16+icount)
424    ->AddEnvelopeConstituentParam(volAluAngSupport1V,volEnvSuppAng1VA0,iVolNum++,3, spar);
425    GetEnvelopes(16+icount)
426    ->AddEnvelopeConstituentParam(volAluAngSupport1V,volEnvSuppAng1VA1,iVolNum++,3, spar);           
427
428 // 1 horizontal    
429  
430    spar[0]=dpar[0];
431    spar[1]=fgkSizeSupport1H[1];
432    spar[2]=fgkSizeSupport1H[2];
433    TString volEnvSuppAng1HA0 = GetVolEnvSuppAngName("1", "H", "A", icount, 0);
434    TString volEnvSuppAng1HA1 = GetVolEnvSuppAngName("1", "H", "A", icount, 1);
435    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HA0, 0, true,
436    TGeoTranslation(xEnv,yEnvP-dpar[1]-sparysave,fgkZp+dpar[2]-spar[2]));
437    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HA1, 0, true, 
438    TGeoTranslation(-xEnv,yEnvM-dpar[1]-sparysave,fgkZm-(dpar[2]-spar[2])),
439    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
440
441    TString volAluAngSupport1H = GetVolAluAngSuppName("1", "H", icount);
442    GetEnvelopes(16+icount)
443    ->AddEnvelopeConstituentParam(volAluAngSupport1H,volEnvSuppAng1HA0,iVolNum++,3, spar);
444    GetEnvelopes(16+icount)
445    ->AddEnvelopeConstituentParam(volAluAngSupport1H,volEnvSuppAng1HA1,iVolNum++,3, spar);           
446
447 // gas pipe (low)
448    ppar[0]=fgkSizeGasPipe[0];
449    ppar[1]=fgkSizeGasPipe[1];
450    ppar[2]=dpar[0];
451    TString volEnvInoxGasPipe1A0 = GetVolEnvInoxGasPipeName("1", "A", icount, 0);
452    TString volEnvInoxGasPipe1A1 = GetVolEnvInoxGasPipeName("1", "A", icount, 1);
453    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1A0, 0, true,
454    TGeoTranslation(xEnv,yEnvP-dpar[1]-sparysave-fgkOffsetGasPipe,fgkZp),fRsupportpipe);
455    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1A1, 0, true,
456    TGeoTranslation(-xEnv,yEnvM-dpar[1]-sparysave-fgkOffsetGasPipe,fgkZm),fRsupportpipe);
457    TString volInoxGasPipe = GetVolumeName("volInoxGasPipe", icount);
458    GetEnvelopes(16+icount)
459    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe1A0,iVolNum++,3, ppar);
460    GetEnvelopes(16+icount)
461    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe1A1,iVolNum++,3, ppar);
462
463 // 2 vertical      
464  
465    spar[0]=dpar[0];
466    spar[1]=fgkSizeSupport2V[1];
467    spar[2]=fgkSizeSupport2V[2];
468    sparysave=spar[1]+fgkSizeSupport2H[1];
469    TString volEnvSuppAng2VA0 = GetVolEnvSuppAngName("2", "V", "A", icount, 0);
470    TString volEnvSuppAng2VA1 = GetVolEnvSuppAngName("2", "V", "A", icount, 1);
471    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VA0, 0, true,
472    TGeoTranslation(xEnv,yEnvP-dpar[1],fgkSizeVSupExt[0]+spar[2]));
473    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VA1, 0, true,
474    TGeoTranslation(-xEnv,yEnvM-dpar[1],-(fgkSizeVSupExt[0]+spar[2])),
475    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
476
477    TString volAluAngSupport2V = GetVolAluAngSuppName("2", "V", icount);
478    GetEnvelopes(16+icount)
479    ->AddEnvelopeConstituentParam(volAluAngSupport2V,volEnvSuppAng2VA0,iVolNum++,3, spar);
480    GetEnvelopes(16+icount)
481    ->AddEnvelopeConstituentParam(volAluAngSupport2V,volEnvSuppAng2VA1,iVolNum++,3, spar);           
482
483 // 2 horizontal    
484  
485    spar[0]=dpar[0];
486    spar[1]=fgkSizeSupport2H[1];
487    spar[2]=fgkSizeSupport2H[2]; 
488    TString volEnvSuppAng2HA0 = GetVolEnvSuppAngName("2", "H", "A", icount, 0);
489    TString volEnvSuppAng2HA1 = GetVolEnvSuppAngName("2", "H", "A", icount, 1);
490    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HA0, 0, true,
491    TGeoTranslation(xEnv,yEnvP-dpar[1]-sparysave,fgkSizeVSupExt[0]+spar[2]));
492    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HA1, 0, true,   
493    TGeoTranslation(-xEnv,yEnvM-dpar[1]-sparysave,-(fgkSizeVSupExt[0]+spar[2])),
494    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
495
496    TString volAluAngSupport2H = GetVolAluAngSuppName("2", "H", icount);
497    GetEnvelopes(16+icount)
498    ->AddEnvelopeConstituentParam(volAluAngSupport2H,volEnvSuppAng2HA0,iVolNum++,3, spar);
499    GetEnvelopes(16+icount)
500    ->AddEnvelopeConstituentParam(volAluAngSupport2H,volEnvSuppAng2HA1,iVolNum++,3, spar);           
501
502 // 3 vertical      
503  
504    spar[0]=dpar[0];
505    spar[1]=fgkSizeSupport1V[1];
506    spar[2]=fgkSizeSupport1V[2];
507    sparysave=spar[1];
508    TString volEnvSuppAng3VA0 = GetVolEnvSuppAngName("3", "V", "A", icount, 0);
509    TString volEnvSuppAng3VA1 = GetVolEnvSuppAngName("3", "V", "A", icount, 1);
510    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VA0, 0, true,
511    TGeoTranslation(xEnv,yEnvP+dpar[1],fgkZp+dpar[2]+spar[2]));
512    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VA1, 0, true,
513    TGeoTranslation(-xEnv,yEnvM+dpar[1],fgkZm-dpar[2]-spar[2]),
514    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
515
516    TString volAluAngSupport3V = GetVolAluAngSuppName("3", "V", icount);
517    GetEnvelopes(16+icount)
518    ->AddEnvelopeConstituentParam(volAluAngSupport3V,volEnvSuppAng3VA0,iVolNum++,3, spar);
519    GetEnvelopes(16+icount)
520    ->AddEnvelopeConstituentParam(volAluAngSupport3V,volEnvSuppAng3VA1,iVolNum++,3, spar);           
521
522 // 3 horizontal    
523  
524    spar[0]=dpar[0];
525    spar[1]=fgkSizeSupport1H[1];
526    spar[2]=fgkSizeSupport1H[2];
527    TString volEnvSuppAng3HA0 = GetVolEnvSuppAngName("3", "H", "A", icount, 0);
528    TString volEnvSuppAng3HA1 = GetVolEnvSuppAngName("3", "H", "A", icount, 1);
529    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HA0, 0, true,
530    TGeoTranslation(xEnv,yEnvP+dpar[1]+sparysave,fgkZp+dpar[2]-spar[2]));
531    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HA1, 0, true,   
532    TGeoTranslation(-xEnv,yEnvM+dpar[1]+sparysave,fgkZm-(dpar[2]-spar[2])),
533    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
534
535    TString volAluAngSupport3H = GetVolAluAngSuppName("3", "H", icount);
536    GetEnvelopes(16+icount)
537    ->AddEnvelopeConstituentParam(volAluAngSupport3H,volEnvSuppAng3HA0,iVolNum++,3, spar);
538    GetEnvelopes(16+icount)
539    ->AddEnvelopeConstituentParam(volAluAngSupport3H,volEnvSuppAng3HA1,iVolNum++,3, spar);       
540        
541 // gas pipe (high)
542    ppar[0]=fgkSizeGasPipe[0];
543    ppar[1]=fgkSizeGasPipe[1];
544    ppar[2]=dpar[0];
545    TString volEnvInoxGasPipe2A0 = GetVolEnvInoxGasPipeName("2", "A", icount, 0);
546    TString volEnvInoxGasPipe2A1 = GetVolEnvInoxGasPipeName("2", "A", icount, 1);
547    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2A0, 0, true,
548    TGeoTranslation(xEnv,yEnvP+dpar[1]+sparysave+fgkOffsetGasPipe,fgkZp),fRsupportpipe);
549    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2A1, 0, true,
550    TGeoTranslation(-xEnv,yEnvM+dpar[1]+sparysave+fgkOffsetGasPipe,fgkZm),fRsupportpipe);
551    GetEnvelopes(16+icount)
552    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe2A0,iVolNum++,3, ppar);
553    GetEnvelopes(16+icount)
554    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe2A1,iVolNum++,3, ppar);
555
556 // 4 vertical      
557  
558    spar[0]=dpar[0];
559    spar[1]=fgkSizeSupport2V[1];
560    spar[2]=fgkSizeSupport2V[2];
561    sparysave=spar[1]+fgkSizeSupport2H[1];
562    TString volEnvSuppAng4VA0 = GetVolEnvSuppAngName("4", "V", "A", icount, 0);
563    TString volEnvSuppAng4VA1 = GetVolEnvSuppAngName("4", "V", "A", icount, 1);
564    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4VA0, 0, true,
565    TGeoTranslation(xEnv,yEnvP+dpar[1],fgkSizeVSupExt[0]+spar[2]));
566    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4VA1, 0, true,
567    TGeoTranslation(-xEnv,yEnvM+dpar[1],-(fgkSizeVSupExt[0]+spar[2])),
568    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
569
570    TString volAluAngSupport4V = GetVolAluAngSuppName("4", "V", icount);
571    GetEnvelopes(16+icount)
572    ->AddEnvelopeConstituentParam(volAluAngSupport4V,volEnvSuppAng4VA0,iVolNum++,3, spar);
573    GetEnvelopes(16+icount)
574    ->AddEnvelopeConstituentParam(volAluAngSupport4V,volEnvSuppAng4VA1,iVolNum++,3, spar);   
575
576 // 4 horizontal    
577  
578    spar[0]=dpar[0];
579    spar[1]=fgkSizeSupport2H[1];
580    spar[2]=fgkSizeSupport2H[2];
581    TString volEnvSuppAng4HA0 = GetVolEnvSuppAngName("4", "H", "A", icount, 0);
582    TString volEnvSuppAng4HA1 = GetVolEnvSuppAngName("4", "H", "A", icount, 1);
583    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4HA0, 0, true,
584    TGeoTranslation(xEnv,yEnvP+dpar[1]+sparysave,fgkSizeVSupExt[0]+spar[2]));
585    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4HA1, 0, true, 
586    TGeoTranslation(-xEnv,yEnvM+dpar[1]+sparysave,-(fgkSizeVSupExt[0]+spar[2])),
587    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
588
589    TString volAluAngSupport4H = GetVolAluAngSuppName("4", "H", icount);
590    GetEnvelopes(16+icount)
591    ->AddEnvelopeConstituentParam(volAluAngSupport4H,volEnvSuppAng4HA0,iVolNum++,3, spar);
592    GetEnvelopes(16+icount)
593    ->AddEnvelopeConstituentParam(volAluAngSupport4H,volEnvSuppAng4HA1,iVolNum++,3, spar);   
594
595 // X horizontal    
596    spar[0]=(fgkYVSup[3]-fgkYVSup[0])/2.*zRatio;
597    spar[1]=fgkSizeSupportXH[1];
598    spar[2]=fgkSizeSupportXH[2];
599    Float_t sparysavex=spar[1];
600    TString volEnvSuppAngXHA0 = GetVolEnvSuppAngName("X", "H", "A", icount, 0);
601    TString volEnvSuppAngXHA1 = GetVolEnvSuppAngName("X", "H", "A", icount, 1);
602    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXHA0, 0, true,
603    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,yEnvP+dpar[1]+sparysave+1.0,
604    fgkSizeVSupExt[0]+spar[2]));
605    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXHA1, 0, true, 
606    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),yEnvM+dpar[1]+sparysave+1.0,
607    -(fgkSizeVSupExt[0]+spar[2])),
608    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
609
610    TString volAluAngSupportXH = GetVolAluAngSuppName("X", "H", icount);
611    GetEnvelopes(16+icount)
612    ->AddEnvelopeConstituentParam(volAluAngSupportXH,volEnvSuppAngXHA0,iVolNum++,3, spar);   
613    GetEnvelopes(16+icount)
614    ->AddEnvelopeConstituentParam(volAluAngSupportXH,volEnvSuppAngXHA1,iVolNum++,3, spar);   
615
616 // X vertical      
617    spar[0]=(fgkYVSup[3]-fgkYVSup[0])/2.*zRatio;
618    spar[1]=fgkSizeSupportXV[1];
619    spar[2]=fgkSizeSupportXV[2];
620    TString volEnvSuppAngXVA0 = GetVolEnvSuppAngName("X", "V", "A", icount, 0);
621    TString volEnvSuppAngXVA1 = GetVolEnvSuppAngName("X", "V", "A", icount, 1);
622    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXVA0, 0, true, 
623    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,yEnvP+dpar[1]+sparysave+1.0+sparysavex+spar[1],
624    fgkSizeVSupExt[0]+spar[2]));
625    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXVA1, 0, true, 
626    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),yEnvM+dpar[1]+sparysave+1.0+sparysavex+spar[1],
627    -(fgkSizeVSupExt[0]+spar[2])),
628    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
629
630    TString volAluAngSupportXV = GetVolAluAngSuppName("X", "V", icount);
631    GetEnvelopes(16+icount)
632    ->AddEnvelopeConstituentParam(volAluAngSupportXV,volEnvSuppAngXVA0,iVolNum++,3, spar);   
633    GetEnvelopes(16+icount)
634    ->AddEnvelopeConstituentParam(volAluAngSupportXV,volEnvSuppAngXVA1,iVolNum++,3, spar);          
635
636    // keep values of yEnvP, yEnvM
637    fYEnvPsave = yEnvP;
638    fYEnvMsave = yEnvM;   
639
640
641 //______________________________________________________________________________
642 void AliMUONTriggerGeometryBuilder::BuildChamberTypeB(Int_t& iVolNum, Int_t icount)
643 {
644 // ratio of zpos1m/zpos1p and inverse for first plane
645    Float_t zpos1= AliMUONConstants::DefaultChamberZ(10); 
646    Float_t zmp=(zpos1-3.6)/(zpos1+3.6);
647    Float_t zpm=1./zmp;
648     
649 // chamber type B (plus envelope chambers B & C)   
650    Double_t dpar[3];    
651    Double_t spar[3];    
652    Double_t ppar[3];    
653
654 // chamber type B
655    Float_t zRatio = AliMUONConstants::DefaultRatioTriggerChamber(icount);      
656    Float_t xEnv = (fgkDXZERO+fgkXMAX/2.)*zRatio;
657    Float_t yEnvP = 0;
658    Float_t yEnvM = 0;
659    yEnvP = (fYEnvMsave + fgkYMIN * zRatio ) * zpm + fgkYMIN * zRatio;
660    yEnvM = (fYEnvPsave + fgkYMIN * zRatio ) * zmp + fgkYMIN * zRatio;
661    dpar[0] = ((fgkXMAX-fgkXMIN)/2.) * zRatio;
662    dpar[1] = ((fgkYMAX-fgkYMIN)/2.) * zRatio;
663    dpar[2] = 0.4;   
664    fDYsave = dpar[1];
665    fDXsave = dpar[0];
666    Float_t xpos = fgkXMIN/2. * zRatio;
667    Float_t ypos = (fgkYMIN - fgkYMIN/4.) * zRatio;
668    Float_t xpossave = xpos;
669
670    Int_t detElemId = (10+icount+1)*100+17;            
671    TString volEnv3 = GetVolEnvName(icount, 3);
672    TString volEnv5 = GetVolEnvName(icount, 5);
673    TString volEnv12 = GetVolEnvName(icount, 12);
674    TString volEnv14 = GetVolEnvName(icount, 14);
675    TString volAlu = GetVolumeName("volAlu", icount);
676
677    GetEnvelopes(16+icount)->AddEnvelope(volEnv3, detElemId, true,
678    TGeoTranslation(xEnv,-yEnvM,fgkZm));   
679    detElemId = (10+icount+1)*100+1;
680    GetEnvelopes(16+icount)->AddEnvelope(volEnv5, detElemId, true, 
681    TGeoTranslation( xEnv, yEnvM,fgkZm));
682    detElemId = (10+icount+1)*100+10;
683    GetEnvelopes(16+icount)->AddEnvelope(volEnv12, detElemId, true,
684    TGeoTranslation(-xEnv,-yEnvP,fgkZp),
685    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
686    detElemId = (10+icount+1)*100+8;
687    GetEnvelopes(16+icount)->AddEnvelope(volEnv14, detElemId, true, 
688    TGeoTranslation(-xEnv, yEnvP,fgkZp),
689    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
690
691    GetEnvelopes(16+icount)
692    ->AddEnvelopeConstituentParam(volAlu,volEnv3,iVolNum++,TGeoTranslation(xpos, ypos,0.),3,dpar);
693    GetEnvelopes(16+icount)
694    ->AddEnvelopeConstituentParam(volAlu,volEnv5,iVolNum++,TGeoTranslation(xpos,-ypos,0.),3,dpar);
695    GetEnvelopes(16+icount)
696    ->AddEnvelopeConstituentParam(volAlu,volEnv12,iVolNum++,TGeoTranslation(xpos, ypos,0.),3,dpar);
697    GetEnvelopes(16+icount)
698    ->AddEnvelopeConstituentParam(volAlu,volEnv14,iVolNum++,TGeoTranslation(xpos,-ypos,0.),3,dpar);
699
700 // chamber type C (note: same Z than type B)
701    dpar[0] = (fgkXMAX/2)*zRatio;
702    dpar[1] = (fgkYMAX/2)*zRatio;
703    xpos = 0.;   
704    ypos = ((fgkYMAX - fgkYMIN)/2.) * zRatio;
705
706    GetEnvelopes(16+icount)
707    ->AddEnvelopeConstituentParam(volAlu,volEnv3,iVolNum++,TGeoTranslation(xpos,-ypos,0.),3,dpar);
708    GetEnvelopes(16+icount)
709    ->AddEnvelopeConstituentParam(volAlu,volEnv5,iVolNum++,TGeoTranslation(xpos, ypos,0.),3,dpar);
710    GetEnvelopes(16+icount)
711    ->AddEnvelopeConstituentParam(volAlu,volEnv12,iVolNum++,TGeoTranslation(xpos,-ypos,0.),3,dpar);
712    GetEnvelopes(16+icount)
713    ->AddEnvelopeConstituentParam(volAlu,volEnv14,iVolNum++,TGeoTranslation(xpos, ypos,0.),3,dpar);
714
715 // horizontal cable support chamber type B+C
716
717    char volEnvSupportHBC[12][8];
718    for(Int_t jj=0;jj<2;jj++){
719      for(Int_t ii=0;ii<6;ii++){
720        snprintf(volEnvSupportHBC[6*jj+ii],8,"SA%dHB%d",icount+1,6*jj+ii);
721      }
722    }
723       
724    spar[0]=dpar[0]-fgkYVSup[0]/2.;
725    spar[1]=fgkSizeSupportCable[1];
726    spar[2]=fgkSizeSupportCable[2];
727    for(Int_t in=0;in<3;in++){
728      GetEnvelopes(16+icount)->AddEnvelope(volEnvSupportHBC[in], 0, true, 
729      TGeoTranslation(xEnv+fgkYVSup[0]/2.*zRatio,-(yEnvM+(fgkYMAX-fgkYMIN/2.*zRatio)/2.*(in-1)),
730      fgkSizeVSupExt[0]+spar[2]));
731      GetEnvelopes(16+icount)->AddEnvelope(volEnvSupportHBC[in+3], 0, true, 
732      TGeoTranslation(xEnv+fgkYVSup[0]/2.*zRatio, yEnvM+(fgkYMAX-fgkYMIN/2.*zRatio)/2.*(in-1),
733      fgkSizeVSupExt[0]+spar[2]));
734      GetEnvelopes(16+icount)->AddEnvelope(volEnvSupportHBC[in+6], 0, true, 
735      TGeoTranslation(-(xEnv+fgkYVSup[0]/2.*zRatio),-(yEnvP+(fgkYMAX-fgkYMIN/2.*zRatio)/2.*(in-1)),
736      -(fgkSizeVSupExt[0]+spar[2])),
737      TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
738      GetEnvelopes(16+icount)->AddEnvelope(volEnvSupportHBC[in+9], 0, true, 
739      TGeoTranslation(-(xEnv+fgkYVSup[0]/2.*zRatio), yEnvP+(fgkYMAX-fgkYMIN/2.*zRatio)/2.*(in-1),
740      -(fgkSizeVSupExt[0]+spar[2])),
741      TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
742    }
743    for(Int_t ii=0;ii<12;ii++) { 
744      TString volAluSupportH = GetVolumeName("volAluSupportH", icount);
745      GetEnvelopes(16+icount)
746    ->AddEnvelopeConstituentParam(volAluSupportH,volEnvSupportHBC[ii],iVolNum++,3, spar);
747    }  
748
749 // angular supports chamber type B and C
750 // C       
751 // 1 vertical
752    spar[0]=dpar[0];
753    spar[1]=fgkSizeSupport1V[1];
754    spar[2]=fgkSizeSupport1V[2];
755    Float_t sparysave=spar[1];
756
757    TString volEnvSuppAng1VBC0 = GetVolEnvSuppAngName("1", "V", "B", icount, 0); 
758    TString volEnvSuppAng1VBC2 = GetVolEnvSuppAngName("1", "V", "B", icount, 2); 
759    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VBC0, 0, true,
760    TGeoTranslation(xEnv,-yEnvM-dpar[1]-fDYsave,fgkZm-dpar[2]-spar[2]));
761    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VBC2, 0, true,
762    TGeoTranslation(-xEnv,-yEnvP-dpar[1]-fDYsave,fgkZp+dpar[2]+spar[2]),
763    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
764    
765    TString volAluAngSupport1V = GetVolAluAngSuppName("1", "V", icount);
766    GetEnvelopes(16+icount)
767    ->AddEnvelopeConstituentParam(volAluAngSupport1V,volEnvSuppAng1VBC0,iVolNum++,3, spar);
768    GetEnvelopes(16+icount)
769    ->AddEnvelopeConstituentParam(volAluAngSupport1V,volEnvSuppAng1VBC2,iVolNum++,3, spar);
770
771 // 1 horizontal
772    spar[0]=dpar[0];
773    spar[1]=fgkSizeSupport1H[1];
774    spar[2]=fgkSizeSupport1H[2];
775    
776    TString volEnvSuppAng1HBC0 = GetVolEnvSuppAngName("1", "H", "B", icount, 0);
777    TString volEnvSuppAng1HBC2 = GetVolEnvSuppAngName("1", "H", "B", icount, 2);
778    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HBC0, 0, true,
779    TGeoTranslation(xEnv,-yEnvM-dpar[1]-fDYsave-sparysave,fgkZm-(dpar[2]-spar[2])));
780    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HBC2, 0, true, 
781    TGeoTranslation(-xEnv,-yEnvP-dpar[1]-fDYsave-sparysave,fgkZp+dpar[2]-spar[2]),
782    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
783
784    TString volAluAngSupport1H = GetVolAluAngSuppName("1", "H", icount);
785    GetEnvelopes(16+icount)
786    ->AddEnvelopeConstituentParam(volAluAngSupport1H,volEnvSuppAng1HBC0,iVolNum++,3, spar);
787    GetEnvelopes(16+icount)
788    ->AddEnvelopeConstituentParam(volAluAngSupport1H,volEnvSuppAng1HBC2,iVolNum++,3, spar);   
789
790 // gas pipe (low)
791    ppar[0]=fgkSizeGasPipe[0];
792    ppar[1]=fgkSizeGasPipe[1];
793    ppar[2]=dpar[0];
794    TString volEnvInoxGasPipe1BC0 = GetVolEnvInoxGasPipeName("1", "BC", icount, 0);
795    TString volEnvInoxGasPipe1BC2 = GetVolEnvInoxGasPipeName("1", "BC", icount, 2);
796    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1BC0, 0, true,
797    TGeoTranslation(xEnv,-yEnvM-dpar[1]-fDYsave-sparysave-fgkOffsetGasPipe,fgkZm),fRsupportpipe);
798    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1BC2, 0, true,
799    TGeoTranslation(-xEnv,-yEnvP-dpar[1]-fDYsave-sparysave-fgkOffsetGasPipe,fgkZp),fRsupportpipe);
800    TString volInoxGasPipe = GetVolumeName("volInoxGasPipe", icount);
801    GetEnvelopes(16+icount)
802    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe1BC0,iVolNum++,3, ppar);
803    GetEnvelopes(16+icount)
804    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe1BC2,iVolNum++,3, ppar);
805
806 // 2 vertical      
807    spar[0]=dpar[0];
808    spar[1]=fgkSizeSupport2V[1];
809    spar[2]=fgkSizeSupport2V[2];
810    sparysave=spar[1]+fgkSizeSupport2H[1];
811    TString volEnvSuppAng2VBC0 = GetVolEnvSuppAngName("2", "V", "B", icount, 0);
812    TString volEnvSuppAng2VBC2 = GetVolEnvSuppAngName("2", "V", "B", icount, 2);
813    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VBC0, 0, true,
814    TGeoTranslation(xEnv,-yEnvM-dpar[1]-fDYsave,-(fgkSizeVSupExt[0]+spar[2])));
815    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VBC2, 0, true, 
816    TGeoTranslation(-xEnv,-yEnvP-dpar[1]-fDYsave,fgkSizeVSupExt[0]+spar[2]),
817    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
818    
819    TString volAluAngSupport2V = GetVolAluAngSuppName("2", "V", icount);
820    GetEnvelopes(16+icount)
821    ->AddEnvelopeConstituentParam(volAluAngSupport2V,volEnvSuppAng2VBC0,iVolNum++,3, spar);   
822    GetEnvelopes(16+icount)
823    ->AddEnvelopeConstituentParam(volAluAngSupport2V,volEnvSuppAng2VBC2,iVolNum++,3, spar);   
824
825 // 2 horizontal    
826    spar[0]=dpar[0];
827    spar[1]=fgkSizeSupport2H[1];
828    spar[2]=fgkSizeSupport2H[2];
829    TString volEnvSuppAng2HBC0 = GetVolEnvSuppAngName("2", "H", "B", icount, 0);
830    TString volEnvSuppAng2HBC2 = GetVolEnvSuppAngName("2", "H", "B", icount, 2);
831    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HBC0, 0, true,
832    TGeoTranslation(xEnv,-yEnvM-dpar[1]-fDYsave-sparysave,-(fgkSizeVSupExt[0]+spar[2])));
833    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HBC2, 0, true, 
834    TGeoTranslation(-xEnv,-yEnvP-dpar[1]-fDYsave-sparysave,fgkSizeVSupExt[0]+spar[2]),
835    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
836
837    TString volAluAngSupport2H = GetVolAluAngSuppName("2", "H", icount);
838    GetEnvelopes(16+icount)
839    ->AddEnvelopeConstituentParam(volAluAngSupport2H,volEnvSuppAng2HBC0,iVolNum++,3, spar);   
840    GetEnvelopes(16+icount)
841    ->AddEnvelopeConstituentParam(volAluAngSupport2H,volEnvSuppAng2HBC2,iVolNum++,3, spar);   
842
843 // 3 vertical
844    spar[0]=fDXsave-fgkAvoidExtrusion;
845    spar[1]=fgkSizeSupport1V[1];
846    spar[2]=fgkSizeSupport1V[2];
847    sparysave=spar[1];
848    TString volEnvSuppAng3VBC0 = GetVolEnvSuppAngName("3", "V", "B", icount, 0);
849    TString volEnvSuppAng3VBC2 = GetVolEnvSuppAngName("3", "V", "B", icount, 2);
850    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VBC0, 0, true,
851    TGeoTranslation(xEnv+xpossave,-yEnvM+dpar[1]+fDYsave,fgkZm-dpar[2]-spar[2]));
852    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VBC2, 0, true, 
853    TGeoTranslation(-xEnv-xpossave,-yEnvP+dpar[1]+fDYsave,fgkZp+dpar[2]+spar[2]),
854    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
855    
856    TString volAluAngSupport3V = GetVolAluAngSuppName("3", "V", icount);
857    GetEnvelopes(16+icount)
858    ->AddEnvelopeConstituentParam(volAluAngSupport3V,volEnvSuppAng3VBC0,iVolNum++,3, spar);
859    GetEnvelopes(16+icount)
860    ->AddEnvelopeConstituentParam(volAluAngSupport3V,volEnvSuppAng3VBC2,iVolNum++,3, spar);
861
862 // 3 horizontal
863    spar[0]=fDXsave-fgkAvoidExtrusion;
864    spar[1]=fgkSizeSupport1H[1];
865    spar[2]=fgkSizeSupport1H[2];
866    TString volEnvSuppAng3HBC0 = GetVolEnvSuppAngName("3", "H", "B", icount, 0);
867    TString volEnvSuppAng3HBC2 = GetVolEnvSuppAngName("3", "H", "B", icount, 2);
868    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HBC0, 0, true,
869    TGeoTranslation(xEnv+xpossave,-yEnvM+dpar[1]+fDYsave+sparysave,fgkZm-(dpar[2]-spar[2])));
870    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HBC2, 0, true, 
871    TGeoTranslation(-xEnv-xpossave,-yEnvP+dpar[1]+fDYsave+sparysave,fgkZp+dpar[2]-spar[2]),
872    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
873
874    TString volAluAngSupport3H = GetVolAluAngSuppName("3", "H", icount);
875    GetEnvelopes(16+icount)
876    ->AddEnvelopeConstituentParam(volAluAngSupport3H,volEnvSuppAng3HBC0,iVolNum++,3, spar);
877    GetEnvelopes(16+icount)
878    ->AddEnvelopeConstituentParam(volAluAngSupport3H,volEnvSuppAng3HBC2,iVolNum++,3, spar);   
879        
880 // gas pipe (high)
881    ppar[0]=fgkSizeGasPipe[0];
882    ppar[1]=fgkSizeGasPipe[1];
883    ppar[2]=fDXsave-fgkAvoidExtrusion;
884    TString volEnvInoxGasPipe2BC0 = GetVolEnvInoxGasPipeName("2", "BC", icount, 0);
885    TString volEnvInoxGasPipe2BC2 = GetVolEnvInoxGasPipeName("2", "BC", icount, 2);
886    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2BC0, 0, true,
887    TGeoTranslation(xEnv+xpossave,-yEnvM+dpar[1]+fDYsave+sparysave+fgkOffsetGasPipe,fgkZm),
888    fRsupportpipe);
889    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2BC2, 0, true,
890    TGeoTranslation(-xEnv-xpossave,-yEnvP+dpar[1]+fDYsave+sparysave+fgkOffsetGasPipe,fgkZp),
891    fRsupportpipe);
892    GetEnvelopes(16+icount)
893    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe2BC0,iVolNum++,3, ppar);
894    GetEnvelopes(16+icount)
895    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe2BC2,iVolNum++,3, ppar);
896
897 // 4 vertical      
898    spar[0]=fDXsave-fgkAvoidExtrusion;
899    spar[1]=fgkSizeSupport2V[1];
900    spar[2]=fgkSizeSupport2V[2];
901    sparysave=spar[1]+fgkSizeSupport2H[1];
902    TString volEnvSuppAng4VBC0 = GetVolEnvSuppAngName("4", "V", "B", icount, 0);
903    TString volEnvSuppAng4VBC2 = GetVolEnvSuppAngName("4", "V", "B", icount, 2);
904    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4VBC0, 0, true,
905    TGeoTranslation(xEnv+xpossave,-yEnvM+dpar[1]+fDYsave,-(fgkSizeVSupExt[0]+spar[2])));
906    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4VBC2, 0, true, 
907    TGeoTranslation(-xEnv-xpossave,-yEnvP+dpar[1]+fDYsave,fgkSizeVSupExt[0]+spar[2]),
908    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
909    
910    TString volAluAngSupport4V = GetVolAluAngSuppName("4", "V", icount);
911    GetEnvelopes(16+icount)
912    ->AddEnvelopeConstituentParam(volAluAngSupport4V,volEnvSuppAng4VBC0,iVolNum++,3, spar);   
913    GetEnvelopes(16+icount)
914    ->AddEnvelopeConstituentParam(volAluAngSupport4V,volEnvSuppAng4VBC2,iVolNum++,3, spar);   
915
916 // 4 horizontal    
917    spar[0]=fDXsave-fgkAvoidExtrusion;
918    spar[1]=fgkSizeSupport2H[1];
919    spar[2]=fgkSizeSupport2H[2];
920    TString volEnvSuppAng4HBC0 = GetVolEnvSuppAngName("4", "H", "B", icount, 0);
921    TString volEnvSuppAng4HBC2 = GetVolEnvSuppAngName("4", "H", "B", icount, 2);
922    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4HBC0, 0, true,
923    TGeoTranslation(xEnv+xpossave,-yEnvM+dpar[1]+fDYsave+sparysave,-(fgkSizeVSupExt[0]+spar[2])));
924    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4HBC2, 0, true, 
925    TGeoTranslation(-xEnv-xpossave,-yEnvP+dpar[1]+fDYsave+sparysave,fgkSizeVSupExt[0]+spar[2]),
926    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
927
928    TString volAluAngSupport4H = GetVolAluAngSuppName("4", "H", icount);
929    GetEnvelopes(16+icount)
930    ->AddEnvelopeConstituentParam(volAluAngSupport4H,volEnvSuppAng4HBC0,iVolNum++,3, spar);   
931    GetEnvelopes(16+icount)
932    ->AddEnvelopeConstituentParam(volAluAngSupport4H,volEnvSuppAng4HBC2,iVolNum++,3, spar);   
933
934 // X horizontal    
935    spar[0]=(fgkYVSup[3]-fgkYVSup[0])/2.*zRatio;
936    spar[1]=fgkSizeSupportXH[1];
937    spar[2]=fgkSizeSupportXH[2];
938    Float_t sparysavex=spar[1];
939    TString volEnvSuppAngXHBC0 = GetVolEnvSuppAngName("X", "H", "B", icount, 0);
940    TString volEnvSuppAngXHBC2 = GetVolEnvSuppAngName("X", "H", "B", icount, 2);
941    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXHBC0, 0, true,
942    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,-yEnvM+dpar[1]+fDYsave+sparysave+1.0,
943    -(fgkSizeVSupExt[0]+spar[2])));
944    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXHBC2, 0, true, 
945    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),-yEnvP+dpar[1]+fDYsave+sparysave+1.0,
946    fgkSizeVSupExt[0]+spar[2]),
947    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
948
949    TString volAluAngSupportXH = GetVolAluAngSuppName("X", "H", icount);
950    GetEnvelopes(16+icount)
951    ->AddEnvelopeConstituentParam(volAluAngSupportXH,volEnvSuppAngXHBC0,iVolNum++,3, spar);   
952    GetEnvelopes(16+icount)
953    ->AddEnvelopeConstituentParam(volAluAngSupportXH,volEnvSuppAngXHBC2,iVolNum++,3, spar);      
954 // X vertical      
955    spar[0]=(fgkYVSup[3]-fgkYVSup[0])/2.*zRatio;
956    spar[1]=fgkSizeSupportXV[1];
957    spar[2]=fgkSizeSupportXV[2];
958    TString volEnvSuppAngXVBC0 = GetVolEnvSuppAngName("X", "V", "B", icount, 0);
959    TString volEnvSuppAngXVBC2 = GetVolEnvSuppAngName("X", "V", "B", icount, 2);
960    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXVBC0, 0, true, 
961    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,
962    -yEnvM+dpar[1]+fDYsave+sparysave+1.0+sparysavex+spar[1],
963    -(fgkSizeVSupExt[0]+spar[2])));
964    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXVBC2, 0, true, 
965    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),
966    -yEnvP+dpar[1]+fDYsave+sparysave+1.0+sparysavex+spar[1],
967    fgkSizeVSupExt[0]+spar[2]),
968    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
969
970    TString volAluAngSupportXV = GetVolAluAngSuppName("X", "V", icount);
971    GetEnvelopes(16+icount)
972    ->AddEnvelopeConstituentParam(volAluAngSupportXV,volEnvSuppAngXVBC0,iVolNum++,3, spar);   
973    GetEnvelopes(16+icount)
974    ->AddEnvelopeConstituentParam(volAluAngSupportXV,volEnvSuppAngXVBC2,iVolNum++,3, spar);   
975
976 // B
977 // 1 vertical
978    spar[0]=fDXsave-fgkAvoidExtrusion;
979    spar[1]=fgkSizeSupport1V[1];
980    spar[2]=fgkSizeSupport1V[2];
981    sparysave=spar[1];
982    TString volEnvSuppAng1VBC1 = GetVolEnvSuppAngName("1", "V", "B", icount, 1);
983    TString volEnvSuppAng1VBC3 = GetVolEnvSuppAngName("1", "V", "B", icount, 3);
984    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VBC1, 0, true,
985    TGeoTranslation(xEnv+xpossave,yEnvM-dpar[1]-fDYsave,fgkZm-dpar[2]-spar[2]));
986    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VBC3, 0, true, 
987    TGeoTranslation(-xEnv-xpossave,yEnvP-dpar[1]-fDYsave,fgkZp+dpar[2]+spar[2]),
988    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
989    //TString volAluAngSupport1V = GetVolAluAngSuppName("1", "V", icount);
990    GetEnvelopes(16+icount)
991    ->AddEnvelopeConstituentParam(volAluAngSupport1V,volEnvSuppAng1VBC1,iVolNum++,3, spar);
992    GetEnvelopes(16+icount)
993    ->AddEnvelopeConstituentParam(volAluAngSupport1V,volEnvSuppAng1VBC3,iVolNum++,3, spar);
994
995
996 // 1 horizontal
997    spar[0]=fDXsave-fgkAvoidExtrusion;
998    spar[1]=fgkSizeSupport1H[1];
999    spar[2]=fgkSizeSupport1H[2];
1000    
1001    TString volEnvSuppAng1HBC1 = GetVolEnvSuppAngName("1", "H", "B", icount, 1);
1002    TString volEnvSuppAng1HBC3 = GetVolEnvSuppAngName("1", "H", "B", icount, 3);
1003    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HBC1, 0, true,
1004    TGeoTranslation(xEnv+xpossave,yEnvM-dpar[1]-fDYsave-sparysave,fgkZm-(dpar[2]-spar[2])));
1005    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HBC3, 0, true, 
1006    TGeoTranslation(-xEnv-xpossave,yEnvP-dpar[1]-fDYsave-sparysave,fgkZp+dpar[2]-spar[2]),
1007    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1008
1009    //TString volAluAngSupport1H = GetVolAluAngSuppName("1", "H", icount);
1010    GetEnvelopes(16+icount)
1011    ->AddEnvelopeConstituentParam(volAluAngSupport1H,volEnvSuppAng1HBC1,iVolNum++,3, spar);
1012    GetEnvelopes(16+icount)
1013    ->AddEnvelopeConstituentParam(volAluAngSupport1H,volEnvSuppAng1HBC3,iVolNum++,3, spar);   
1014
1015 // gas pipe (low)
1016    ppar[0]=fgkSizeGasPipe[0];
1017    ppar[1]=fgkSizeGasPipe[1];
1018    ppar[2]=fDXsave-fgkAvoidExtrusion;
1019    TString volEnvInoxGasPipe1BC1 = GetVolEnvInoxGasPipeName("1", "BC", icount, 1);
1020    TString volEnvInoxGasPipe1BC3 = GetVolEnvInoxGasPipeName("1", "BC", icount, 3);
1021    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1BC1, 0, true,
1022    TGeoTranslation(xEnv+xpossave,yEnvM-dpar[1]-fDYsave-sparysave-fgkOffsetGasPipe,fgkZm),
1023    fRsupportpipe);
1024    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1BC3, 0, true,
1025    TGeoTranslation(-xEnv-xpossave,yEnvP-dpar[1]-fDYsave-sparysave-fgkOffsetGasPipe,fgkZp),
1026    fRsupportpipe);
1027    GetEnvelopes(16+icount)
1028    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe1BC1,iVolNum++,3, ppar);
1029    GetEnvelopes(16+icount)
1030    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe1BC3,iVolNum++,3, ppar);
1031
1032 // 2 vertical      
1033    spar[0]=fDXsave-fgkAvoidExtrusion;
1034    spar[1]=fgkSizeSupport2V[1];
1035    spar[2]=fgkSizeSupport2V[2];
1036    sparysave=spar[1]+fgkSizeSupport2H[1];
1037    TString volEnvSuppAng2VBC1 = GetVolEnvSuppAngName("2", "V", "B", icount, 1);
1038    TString volEnvSuppAng2VBC3 = GetVolEnvSuppAngName("2", "V", "B", icount, 3);
1039    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VBC1, 0, true,
1040    TGeoTranslation(xEnv+xpossave,yEnvM-dpar[1]-fDYsave,-(fgkSizeVSupExt[0]+spar[2])));
1041    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VBC3, 0, true, 
1042    TGeoTranslation(-xEnv-xpossave,yEnvP-dpar[1]-fDYsave,fgkSizeVSupExt[0]+spar[2]),
1043    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1044    
1045    //TString volAluAngSupport2V = GetVolAluAngSuppName("2", "V", icount);
1046    GetEnvelopes(16+icount)
1047    ->AddEnvelopeConstituentParam(volAluAngSupport2V,volEnvSuppAng2VBC1,iVolNum++,3, spar);   
1048    GetEnvelopes(16+icount)
1049    ->AddEnvelopeConstituentParam(volAluAngSupport2V,volEnvSuppAng2VBC3,iVolNum++,3, spar);   
1050 // 2 horizontal    
1051    spar[0]=fDXsave-fgkAvoidExtrusion;
1052    spar[1]=fgkSizeSupport2H[1];
1053    spar[2]=fgkSizeSupport2H[2];
1054    TString volEnvSuppAng2HBC1 = GetVolEnvSuppAngName("2", "H", "B", icount, 1);
1055    TString volEnvSuppAng2HBC3 = GetVolEnvSuppAngName("2", "H", "B", icount, 3);
1056    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HBC1, 0, true,
1057    TGeoTranslation(xEnv+xpossave,yEnvM-dpar[1]-fDYsave-sparysave,-(fgkSizeVSupExt[0]+spar[2])));
1058    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HBC3, 0, true, 
1059    TGeoTranslation(-xEnv-xpossave,yEnvP-dpar[1]-fDYsave-sparysave,fgkSizeVSupExt[0]+spar[2]),
1060    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1061
1062    //TString volAluAngSupport2H = GetVolAluAngSuppName("2", "H", icount);
1063    GetEnvelopes(16+icount)
1064    ->AddEnvelopeConstituentParam(volAluAngSupport2H,volEnvSuppAng2HBC1,iVolNum++,3, spar);   
1065    GetEnvelopes(16+icount)
1066    ->AddEnvelopeConstituentParam(volAluAngSupport2H,volEnvSuppAng2HBC3,iVolNum++,3, spar);   
1067
1068 // 3 vertical
1069    spar[0]=dpar[0];
1070    spar[1]=fgkSizeSupport1V[1];
1071    spar[2]=fgkSizeSupport1V[2];
1072    sparysave=spar[1];
1073    TString volEnvSuppAng3VBC1 = GetVolEnvSuppAngName("3", "V", "B", icount, 1);
1074    TString volEnvSuppAng3VBC3 = GetVolEnvSuppAngName("3", "V", "B", icount, 3);
1075    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VBC1, 0, true,
1076    TGeoTranslation(xEnv,yEnvM+dpar[1]+fDYsave,fgkZm-dpar[2]-spar[2]));
1077    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VBC3, 0, true,
1078    TGeoTranslation(-xEnv,yEnvP+dpar[1]+fDYsave,fgkZp+dpar[2]+spar[2]),
1079    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1080
1081    //TString volAluAngSupport3V = GetVolAluAngSuppName("3", "V", icount);
1082    GetEnvelopes(16+icount)
1083    ->AddEnvelopeConstituentParam(volAluAngSupport3V,volEnvSuppAng3VBC1,iVolNum++,3, spar);
1084    GetEnvelopes(16+icount)
1085    ->AddEnvelopeConstituentParam(volAluAngSupport3V,volEnvSuppAng3VBC3,iVolNum++,3, spar);
1086
1087 // 3 horizontal
1088    spar[1]=fgkSizeSupport1H[1];
1089    spar[2]=fgkSizeSupport1H[2];
1090    
1091    TString volEnvSuppAng3HBC1 = GetVolEnvSuppAngName("3", "H", "B", icount, 1);
1092    TString volEnvSuppAng3HBC3 = GetVolEnvSuppAngName("3", "H", "B", icount, 3);
1093    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HBC1, 0, true,
1094    TGeoTranslation(xEnv,yEnvM+dpar[1]+fDYsave+sparysave,fgkZm-(dpar[2]-spar[2])));
1095    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HBC3, 0, true, 
1096    TGeoTranslation(-xEnv,yEnvP+dpar[1]+fDYsave+sparysave,fgkZp+dpar[2]-spar[2]),
1097    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1098
1099    GetEnvelopes(16+icount)
1100    ->AddEnvelopeConstituentParam(volAluAngSupport3H,volEnvSuppAng3HBC1,iVolNum++,3, spar);
1101    GetEnvelopes(16+icount)
1102    ->AddEnvelopeConstituentParam(volAluAngSupport3H,volEnvSuppAng3HBC3,iVolNum++,3, spar);   
1103
1104 // gas pipe (high)
1105    ppar[0]=fgkSizeGasPipe[0];
1106    ppar[1]=fgkSizeGasPipe[1];
1107    ppar[2]=dpar[0];
1108    TString volEnvInoxGasPipe2BC1 = GetVolEnvInoxGasPipeName("2", "BC", icount, 1);
1109    TString volEnvInoxGasPipe2BC3 = GetVolEnvInoxGasPipeName("2", "BC", icount, 3);
1110    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2BC1, 0, true,
1111    TGeoTranslation(xEnv,yEnvM+dpar[1]+fDYsave+sparysave+fgkOffsetGasPipe,fgkZm),fRsupportpipe);
1112    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2BC3, 0, true,
1113    TGeoTranslation(-xEnv,yEnvP+dpar[1]+fDYsave+sparysave+fgkOffsetGasPipe,fgkZp),fRsupportpipe);
1114    GetEnvelopes(16+icount)
1115    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe2BC1,iVolNum++,3, ppar);
1116    GetEnvelopes(16+icount)
1117    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe2BC3,iVolNum++,3, ppar);
1118
1119 // 4 vertical      
1120    spar[0]=dpar[0];
1121    spar[1]=fgkSizeSupport2V[1];
1122    spar[2]=fgkSizeSupport2V[2];
1123    sparysave=spar[1]+fgkSizeSupport2H[1];
1124    TString volEnvSuppAng4VBC1 = GetVolEnvSuppAngName("4", "V", "B", icount, 1);
1125    TString volEnvSuppAng4VBC3 = GetVolEnvSuppAngName("4", "V", "B", icount, 3);
1126    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4VBC1, 0, true,
1127    TGeoTranslation(xEnv,yEnvM+dpar[1]+fDYsave,-(fgkSizeVSupExt[0]+spar[2])));
1128    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4VBC3, 0, true, 
1129    TGeoTranslation(-xEnv,yEnvP+dpar[1]+fDYsave,fgkSizeVSupExt[0]+spar[2]),
1130    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1131    
1132    GetEnvelopes(16+icount)
1133    ->AddEnvelopeConstituentParam(volAluAngSupport4V,volEnvSuppAng4VBC1,iVolNum++,3, spar);   
1134    GetEnvelopes(16+icount)
1135    ->AddEnvelopeConstituentParam(volAluAngSupport4V,volEnvSuppAng4VBC3,iVolNum++,3, spar);   
1136
1137 // 4 horizontal    
1138    spar[1]=fgkSizeSupport2H[1];
1139    spar[2]=fgkSizeSupport2H[2];
1140    TString volEnvSuppAng4HBC1 = GetVolEnvSuppAngName("4", "H", "B", icount, 1);
1141    TString volEnvSuppAng4HBC3 = GetVolEnvSuppAngName("4", "H", "B", icount, 3);
1142    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4HBC1, 0, true,
1143    TGeoTranslation(xEnv,yEnvM+dpar[1]+fDYsave+sparysave,-(fgkSizeVSupExt[0]+spar[2])));
1144    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4HBC3, 0, true, 
1145    TGeoTranslation(-xEnv,yEnvP+dpar[1]+fDYsave+sparysave,fgkSizeVSupExt[0]+spar[2]),
1146    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1147
1148    GetEnvelopes(16+icount)
1149    ->AddEnvelopeConstituentParam(volAluAngSupport4H,volEnvSuppAng4HBC1,iVolNum++,3, spar);   
1150    GetEnvelopes(16+icount)
1151    ->AddEnvelopeConstituentParam(volAluAngSupport4H,volEnvSuppAng4HBC3,iVolNum++,3, spar);   
1152
1153 // X horizontal    
1154    spar[0]=(fgkYVSup[3]-fgkYVSup[0])/2.*zRatio;
1155    spar[1]=fgkSizeSupportXH[1];
1156    spar[2]=fgkSizeSupportXH[2];
1157    sparysavex=spar[1];
1158    TString volEnvSuppAngXHBC1 = GetVolEnvSuppAngName("X", "H", "B", icount, 1);
1159    TString volEnvSuppAngXHBC3 = GetVolEnvSuppAngName("X", "H", "B", icount, 3);
1160    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXHBC1, 0, true,
1161    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,yEnvM+dpar[1]+fDYsave+sparysave+1.0,
1162    -(fgkSizeVSupExt[0]+spar[2])));
1163    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXHBC3, 0, true, 
1164    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),yEnvP+dpar[1]+fDYsave+sparysave+1.0,
1165    fgkSizeVSupExt[0]+spar[2]),
1166    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1167
1168    GetEnvelopes(16+icount)
1169    ->AddEnvelopeConstituentParam(volAluAngSupportXH,volEnvSuppAngXHBC1,iVolNum++,3, spar);   
1170    GetEnvelopes(16+icount)
1171    ->AddEnvelopeConstituentParam(volAluAngSupportXH,volEnvSuppAngXHBC3,iVolNum++,3, spar);   
1172
1173 // X vertical      
1174    spar[0]=(fgkYVSup[3]-fgkYVSup[0])/2.*zRatio;
1175    spar[1]=fgkSizeSupportXV[1];
1176    spar[2]=fgkSizeSupportXV[2];
1177    TString volEnvSuppAngXVBC1 = GetVolEnvSuppAngName("X", "V", "B", icount, 1);
1178    TString volEnvSuppAngXVBC3 = GetVolEnvSuppAngName("X", "V", "B", icount, 3);
1179    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXVBC1, 0, true, 
1180    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,
1181    yEnvM+dpar[1]+fDYsave+sparysave+1.0+sparysavex+spar[1],-(fgkSizeVSupExt[0]+spar[2])));
1182    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXVBC3, 0, true, 
1183    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),
1184    yEnvP+dpar[1]+fDYsave+sparysave+1.0+sparysavex+spar[1],fgkSizeVSupExt[0]+spar[2]),
1185    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1186
1187    GetEnvelopes(16+icount)
1188    ->AddEnvelopeConstituentParam(volAluAngSupportXV,volEnvSuppAngXVBC1,iVolNum++,3, spar);   
1189    GetEnvelopes(16+icount)
1190    ->AddEnvelopeConstituentParam(volAluAngSupportXV,volEnvSuppAngXVBC3,iVolNum++,3, spar);   
1191
1192    // keep values of yEnvP, yEnvM
1193    fYEnvPsave = yEnvP;
1194    fYEnvMsave = yEnvM;     
1195 }
1196
1197 //______________________________________________________________________________
1198 void AliMUONTriggerGeometryBuilder::BuildChamberTypeD(Int_t& iVolNum, Int_t icount)
1199 {
1200 // ratio of zpos1m/zpos1p and inverse for first plane
1201     Float_t zpos1= AliMUONConstants::DefaultChamberZ(10); 
1202     Float_t zmp=(zpos1-3.6)/(zpos1+3.6);
1203     Float_t zpm=1./zmp;
1204     Float_t zRatio = AliMUONConstants::DefaultRatioTriggerChamber(icount);      
1205     Float_t xEnv = (fgkDXZERO+fgkXMAX/2.)*zRatio;
1206
1207    Double_t dpar[3];    
1208    Double_t spar[3];    
1209    Double_t ppar[3];    
1210
1211 // D   
1212    Float_t yEnvP = 0;
1213    Float_t yEnvM = 0;
1214    yEnvP = (fYEnvMsave + fgkYMIN * zRatio ) * zpm + fgkYMIN * zRatio;
1215    yEnvM = (fYEnvPsave + fgkYMIN * zRatio ) * zmp + fgkYMIN * zRatio;
1216    dpar[0] = (fgkXMAX/2.)*zRatio;
1217    dpar[1] =  fgkYMIN*zRatio;
1218    dpar[2] = 0.4;   
1219
1220    Int_t detElemId = (10+icount+1)*100+16;   
1221    TString volEnv2 = GetVolEnvName(icount, 2);
1222    TString volEnv6 = GetVolEnvName(icount, 6);
1223    TString volEnv11 = GetVolEnvName(icount, 11);
1224    TString volEnv15 = GetVolEnvName(icount, 15);
1225    TString volAlu = GetVolumeName("volAlu", icount);
1226
1227    GetEnvelopes(16+icount)
1228    ->AddEnvelope(volEnv2, detElemId, true, TGeoTranslation(xEnv,-yEnvP,fgkZp));
1229    detElemId = (10+icount+1)*100+2;
1230    GetEnvelopes(16+icount)
1231    ->AddEnvelope(volEnv6, detElemId, true, TGeoTranslation(xEnv, yEnvP,fgkZp));
1232    detElemId = (10+icount+1)*100+11;
1233    GetEnvelopes(16+icount)
1234    ->AddEnvelope(volEnv11, detElemId, true, TGeoTranslation(-xEnv,-yEnvM,fgkZm),
1235    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1236    detElemId = (10+icount+1)*100+7;
1237    GetEnvelopes(16+icount)
1238    ->AddEnvelope(volEnv15, detElemId, true, TGeoTranslation(-xEnv, yEnvM,fgkZm),
1239    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1240
1241    GetEnvelopes(16+icount)
1242    ->AddEnvelopeConstituentParam(volAlu,volEnv2,iVolNum++,3, dpar);
1243    GetEnvelopes(16+icount)
1244    ->AddEnvelopeConstituentParam(volAlu,volEnv6,iVolNum++,3, dpar);
1245    GetEnvelopes(16+icount)
1246    ->AddEnvelopeConstituentParam(volAlu,volEnv11,iVolNum++,3, dpar);
1247    GetEnvelopes(16+icount)
1248    ->AddEnvelopeConstituentParam(volAlu,volEnv15,iVolNum++,3, dpar);
1249
1250 // horizontal cable support chamber type D
1251
1252    char volEnvSupportHD[12][8];
1253    for(Int_t jj=0;jj<2;jj++){
1254      for(Int_t ii=0;ii<6;ii++){
1255        snprintf(volEnvSupportHD[6*jj+ii],8,"SA%dHD%d",icount+1,6*jj+ii);
1256      }
1257    }
1258       
1259    spar[0]=dpar[0]-(fgkYVSup[0]/2.)*zRatio;
1260    spar[1]=fgkSizeSupportCable[1];
1261    spar[2]=fgkSizeSupportCable[2];
1262    for(Int_t in=0;in<3;in++){
1263      GetEnvelopes(16+icount)->AddEnvelope(volEnvSupportHD[in], 0, true,
1264       TGeoTranslation(xEnv+fgkYVSup[0]/2.*zRatio,-(yEnvP+dpar[1]/2.*(in-1)),
1265       -(fgkSizeVSupExt[0]+spar[2])));
1266      GetEnvelopes(16+icount)->AddEnvelope(volEnvSupportHD[in+3], 0, true, 
1267      TGeoTranslation(xEnv+fgkYVSup[0]/2.*zRatio, yEnvP+dpar[1]/2.*(in-1),
1268      -(fgkSizeVSupExt[0]+spar[2])));
1269      GetEnvelopes(16+icount)->AddEnvelope(volEnvSupportHD[in+6], 0, true, 
1270      TGeoTranslation(-(xEnv+fgkYVSup[0]/2.*zRatio),-(yEnvM+dpar[1]/2.*(in-1)),
1271      fgkSizeVSupExt[0]+spar[2]),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1272      GetEnvelopes(16+icount)->AddEnvelope(volEnvSupportHD[in+9], 0, true, 
1273      TGeoTranslation(-(xEnv+fgkYVSup[0]/2.*zRatio),yEnvM+dpar[1]/2.*(in-1),
1274      fgkSizeVSupExt[0]+spar[2]),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1275    }
1276    for(Int_t ii=0;ii<12;ii++) { 
1277      TString volAluSupportH = GetVolumeName("volAluSupportH", icount);
1278      GetEnvelopes(16+icount)
1279      ->AddEnvelopeConstituentParam(volAluSupportH,volEnvSupportHD[ii],iVolNum++,3, spar);
1280    }  
1281    
1282 // angular supports chamber type D
1283 // 1 vertical      
1284  
1285    spar[0]=dpar[0];
1286    spar[1]=fgkSizeSupport1V[1];
1287    spar[2]=fgkSizeSupport1V[2];
1288    Double_t sparysave=spar[1];
1289    
1290    TString volEnvSuppAng1VD[4];
1291    volEnvSuppAng1VD[0] =  GetVolEnvSuppAngName("1", "V", "D", icount, 0);
1292    volEnvSuppAng1VD[1] =  GetVolEnvSuppAngName("1", "V", "D", icount, 1);
1293    volEnvSuppAng1VD[2] =  GetVolEnvSuppAngName("1", "V", "D", icount, 2);
1294    volEnvSuppAng1VD[3] =  GetVolEnvSuppAngName("1", "V", "D", icount, 3);
1295    
1296    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VD[0], 0, true,
1297    TGeoTranslation(xEnv,-yEnvP-dpar[1],fgkZp+dpar[2]+spar[2]));
1298    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VD[1], 0, true,
1299    TGeoTranslation(xEnv,yEnvP-dpar[1],fgkZp+dpar[2]+spar[2]));
1300    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VD[2], 0, true,
1301    TGeoTranslation(-xEnv,-yEnvM-dpar[1],fgkZm-dpar[2]-spar[2]),
1302    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1303    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VD[3], 0, true,
1304    TGeoTranslation(-xEnv,yEnvM-dpar[1],fgkZm-dpar[2]-spar[2]),
1305    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1306
1307        
1308    TString volAluAngSupport1V = GetVolAluAngSuppName("1", "V", icount);
1309    for (Int_t i=0;i<4;i++) 
1310    GetEnvelopes(16+icount)
1311    ->AddEnvelopeConstituentParam(volAluAngSupport1V,volEnvSuppAng1VD[i],iVolNum++,3, spar);
1312
1313
1314 // 1 horizontal    
1315  
1316    spar[0]=dpar[0];
1317    spar[1]=fgkSizeSupport1H[1];
1318    spar[2]=fgkSizeSupport1H[2];
1319
1320    TString volEnvSuppAng1HD[4];
1321    volEnvSuppAng1HD[0] =  GetVolEnvSuppAngName("1", "H", "D", icount, 0);
1322    volEnvSuppAng1HD[1] =  GetVolEnvSuppAngName("1", "H", "D", icount, 1);
1323    volEnvSuppAng1HD[2] =  GetVolEnvSuppAngName("1", "H", "D", icount, 2);
1324    volEnvSuppAng1HD[3] =  GetVolEnvSuppAngName("1", "H", "D", icount, 3);
1325    
1326    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HD[0], 0, true,
1327    TGeoTranslation(xEnv,-yEnvP-dpar[1]-sparysave,fgkZp+dpar[2]-spar[2]));
1328    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HD[1], 0, true,
1329    TGeoTranslation(xEnv,yEnvP-dpar[1]-sparysave,fgkZp+dpar[2]-spar[2]));
1330    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HD[2], 0, true, 
1331    TGeoTranslation(-xEnv,-yEnvM-dpar[1]-sparysave,fgkZm-(dpar[2]-spar[2])),
1332    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1333    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HD[3], 0, true, 
1334    TGeoTranslation(-xEnv,yEnvM-dpar[1]-sparysave,fgkZm-(dpar[2]-spar[2])),
1335    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1336
1337    TString volAluAngSupport1H = GetVolAluAngSuppName("1", "H", icount);
1338    for (Int_t i=0;i<4;i++)
1339    GetEnvelopes(16+icount)
1340    ->AddEnvelopeConstituentParam(volAluAngSupport1H,volEnvSuppAng1HD[i],iVolNum++,3, spar);
1341
1342 // gas pipe (low)
1343    ppar[0]=fgkSizeGasPipe[0];
1344    ppar[1]=fgkSizeGasPipe[1];
1345    ppar[2]=dpar[0];
1346    TString volEnvInoxGasPipe1D[4];
1347    volEnvInoxGasPipe1D[0] = GetVolEnvInoxGasPipeName("1", "D", icount, 0);
1348    volEnvInoxGasPipe1D[1] = GetVolEnvInoxGasPipeName("1", "D", icount, 1);
1349    volEnvInoxGasPipe1D[2] = GetVolEnvInoxGasPipeName("1", "D", icount, 2);
1350    volEnvInoxGasPipe1D[3] = GetVolEnvInoxGasPipeName("1", "D", icount, 3);
1351    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1D[0], 0, true,
1352    TGeoTranslation(xEnv,-yEnvP-dpar[1]-sparysave-fgkOffsetGasPipe,fgkZp),fRsupportpipe);
1353    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1D[1], 0, true,
1354    TGeoTranslation(xEnv,yEnvP-dpar[1]-sparysave-fgkOffsetGasPipe,fgkZp),fRsupportpipe);
1355    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1D[2], 0, true,
1356    TGeoTranslation(-xEnv,-yEnvM-dpar[1]-sparysave-fgkOffsetGasPipe,fgkZm),fRsupportpipe);
1357    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1D[3], 0, true,
1358    TGeoTranslation(-xEnv,yEnvM-dpar[1]-sparysave-fgkOffsetGasPipe,fgkZm),fRsupportpipe);
1359
1360    TString volInoxGasPipe = GetVolumeName("volInoxGasPipe", icount);
1361    for (Int_t i=0;i<4;i++)
1362    GetEnvelopes(16+icount)
1363    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe1D[i],iVolNum++,3, ppar);
1364
1365 // 2 vertical      
1366  
1367    spar[0]=dpar[0];
1368    spar[1]=fgkSizeSupport2V[1];
1369    spar[2]=fgkSizeSupport2V[2];
1370    sparysave=spar[1]+fgkSizeSupport2H[1];
1371    TString volEnvSuppAng2VD[4];
1372    volEnvSuppAng2VD[0] =  GetVolEnvSuppAngName("2", "V", "D", icount, 0);
1373    volEnvSuppAng2VD[1] =  GetVolEnvSuppAngName("2", "V", "D", icount, 1);
1374    volEnvSuppAng2VD[2] =  GetVolEnvSuppAngName("2", "V", "D", icount, 2);
1375    volEnvSuppAng2VD[3] =  GetVolEnvSuppAngName("2", "V", "D", icount, 3);
1376    
1377    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VD[0], 0, true,
1378    TGeoTranslation(xEnv,-yEnvP-dpar[1],fgkSizeVSupExt[0]+spar[2]));
1379    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VD[1], 0, true,
1380    TGeoTranslation(xEnv,yEnvP-dpar[1],fgkSizeVSupExt[0]+spar[2]));
1381    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VD[2], 0, true,
1382    TGeoTranslation(-xEnv,-yEnvM-dpar[1],-(fgkSizeVSupExt[0]+spar[2])),
1383    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1384    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VD[3], 0, true,
1385    TGeoTranslation(-xEnv,yEnvM-dpar[1],-(fgkSizeVSupExt[0]+spar[2])),
1386    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1387    
1388    TString volAluAngSupport2V = GetVolAluAngSuppName("2", "V", icount);
1389    for (Int_t i=0;i<4;i++)
1390    GetEnvelopes(16+icount)
1391    ->AddEnvelopeConstituentParam(volAluAngSupport2V,volEnvSuppAng2VD[i],iVolNum++,3, spar);   
1392
1393 // 2 horizontal    
1394  
1395    spar[0]=dpar[0];
1396    spar[1]=fgkSizeSupport2H[1];
1397    spar[2]=fgkSizeSupport2H[2];
1398    TString volEnvSuppAng2HD[4];
1399    volEnvSuppAng2HD[0] =  GetVolEnvSuppAngName("2", "H", "D", icount, 0);
1400    volEnvSuppAng2HD[1] =  GetVolEnvSuppAngName("2", "H", "D", icount, 1);
1401    volEnvSuppAng2HD[2] =  GetVolEnvSuppAngName("2", "H", "D", icount, 2);
1402    volEnvSuppAng2HD[3] =  GetVolEnvSuppAngName("2", "H", "D", icount, 3);
1403    
1404    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HD[0], 0, true,
1405    TGeoTranslation(xEnv,-yEnvP-dpar[1]-sparysave,fgkSizeVSupExt[0]+spar[2]));
1406    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HD[1], 0, true,
1407    TGeoTranslation(xEnv,yEnvP-dpar[1]-sparysave,fgkSizeVSupExt[0]+spar[2]));
1408    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HD[2], 0, true, 
1409    TGeoTranslation(-xEnv,-yEnvM-dpar[1]-sparysave,-(fgkSizeVSupExt[0]+spar[2])),
1410    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1411    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HD[3], 0, true, 
1412    TGeoTranslation(-xEnv,yEnvM-dpar[1]-sparysave,-(fgkSizeVSupExt[0]+spar[2])),
1413    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1414
1415    TString volAluAngSupport2H = GetVolAluAngSuppName("2", "H", icount);
1416    for (Int_t i=0;i<4;i++)
1417    GetEnvelopes(16+icount)
1418    ->AddEnvelopeConstituentParam(volAluAngSupport2H,volEnvSuppAng2HD[i],iVolNum++,3, spar);   
1419
1420 // 3 vertical      
1421  
1422    spar[0]=dpar[0];
1423    spar[1]=fgkSizeSupport1V[1];
1424    spar[2]=fgkSizeSupport1V[2];
1425    sparysave=spar[1];
1426    TString volEnvSuppAng3VD[4];
1427    volEnvSuppAng3VD[0] =  GetVolEnvSuppAngName("3", "V", "D", icount, 0);
1428    volEnvSuppAng3VD[1] =  GetVolEnvSuppAngName("3", "V", "D", icount, 1);
1429    volEnvSuppAng3VD[2] =  GetVolEnvSuppAngName("3", "V", "D", icount, 2);
1430    volEnvSuppAng3VD[3] =  GetVolEnvSuppAngName("3", "V", "D", icount, 3);
1431    
1432    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VD[0], 0, true,
1433    TGeoTranslation(xEnv,-yEnvP+dpar[1],fgkZp+dpar[2]+spar[2]));
1434    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VD[1], 0, true,
1435    TGeoTranslation(xEnv,yEnvP+dpar[1],fgkZp+dpar[2]+spar[2]));
1436    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VD[2], 0, true,
1437    TGeoTranslation(-xEnv,-yEnvM+dpar[1],fgkZm-dpar[2]-spar[2]),
1438    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1439    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VD[3], 0, true,
1440    TGeoTranslation(-xEnv,yEnvM+dpar[1],fgkZm-dpar[2]-spar[2]),
1441    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1442
1443    TString volAluAngSupport3V = GetVolAluAngSuppName("3", "V", icount);
1444    for (Int_t i=0;i<4;i++)
1445    GetEnvelopes(16+icount)
1446    ->AddEnvelopeConstituentParam(volAluAngSupport3V,volEnvSuppAng3VD[i],iVolNum++,3, spar);
1447
1448
1449 // 3 horizontal    
1450  
1451    spar[0]=dpar[0];
1452    spar[1]=fgkSizeSupport1H[1];
1453    spar[2]=fgkSizeSupport1H[2];
1454    TString volEnvSuppAng3HD[4];
1455    volEnvSuppAng3HD[0] =  GetVolEnvSuppAngName("3", "H", "D", icount, 0);
1456    volEnvSuppAng3HD[1] =  GetVolEnvSuppAngName("3", "H", "D", icount, 1);
1457    volEnvSuppAng3HD[2] =  GetVolEnvSuppAngName("3", "H", "D", icount, 2);
1458    volEnvSuppAng3HD[3] =  GetVolEnvSuppAngName("3", "H", "D", icount, 3);
1459    
1460    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HD[0], 0, true,
1461    TGeoTranslation(xEnv,-yEnvP+dpar[1]+sparysave,fgkZp+dpar[2]-spar[2]));
1462    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HD[1], 0, true,
1463    TGeoTranslation(xEnv,yEnvP+dpar[1]+sparysave,fgkZp+dpar[2]-spar[2]));
1464    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HD[2], 0, true,   
1465    TGeoTranslation(-xEnv,-yEnvM+dpar[1]+sparysave,fgkZm-(dpar[2]-spar[2])),
1466    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1467    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HD[3], 0, true, 
1468    TGeoTranslation(-xEnv,yEnvM+dpar[1]+sparysave,fgkZm-(dpar[2]-spar[2])),
1469    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1470
1471    TString volAluAngSupport3H = GetVolAluAngSuppName("3", "H", icount);
1472    for (Int_t i=0;i<4;i++)
1473    GetEnvelopes(16+icount)
1474    ->AddEnvelopeConstituentParam(volAluAngSupport3H,volEnvSuppAng3HD[i],iVolNum++,3, spar);
1475        
1476 // gas pipe (high)
1477    ppar[0]=fgkSizeGasPipe[0];
1478    ppar[1]=fgkSizeGasPipe[1];
1479    ppar[2]=dpar[0];
1480    TString volEnvInoxGasPipe2D[4];
1481    volEnvInoxGasPipe2D[0] = GetVolEnvInoxGasPipeName("2", "D", icount, 0);
1482    volEnvInoxGasPipe2D[1] = GetVolEnvInoxGasPipeName("2", "D", icount, 1);
1483    volEnvInoxGasPipe2D[2] = GetVolEnvInoxGasPipeName("2", "D", icount, 2);
1484    volEnvInoxGasPipe2D[3] = GetVolEnvInoxGasPipeName("2", "D", icount, 3);
1485    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2D[0], 0, true,
1486    TGeoTranslation(xEnv,-yEnvP+dpar[1]+sparysave+fgkOffsetGasPipe,fgkZp),fRsupportpipe);
1487    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2D[1], 0, true,
1488    TGeoTranslation(xEnv,yEnvP+dpar[1]+sparysave+fgkOffsetGasPipe,fgkZp),fRsupportpipe);
1489    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2D[2], 0, true,
1490    TGeoTranslation(-xEnv,-yEnvM+dpar[1]+sparysave+fgkOffsetGasPipe,fgkZm),fRsupportpipe);
1491    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2D[3], 0, true,
1492    TGeoTranslation(-xEnv,yEnvM+dpar[1]+sparysave+fgkOffsetGasPipe,fgkZm),fRsupportpipe);
1493
1494    for (Int_t i=0;i<4;i++)
1495    GetEnvelopes(16+icount)
1496    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe2D[i],iVolNum++,3, ppar);
1497
1498 // 4 vertical      
1499  
1500    spar[0]=dpar[0];
1501    spar[1]=fgkSizeSupport2V[1];
1502    spar[2]=fgkSizeSupport2V[2];
1503    sparysave=spar[1]+fgkSizeSupport2H[1];
1504    TString volEnvSuppAng4VD[4];
1505    volEnvSuppAng4VD[0] =  GetVolEnvSuppAngName("4", "V", "D", icount, 0);
1506    volEnvSuppAng4VD[1] =  GetVolEnvSuppAngName("4", "V", "D", icount, 1);
1507    volEnvSuppAng4VD[2] =  GetVolEnvSuppAngName("4", "V", "D", icount, 2);
1508    volEnvSuppAng4VD[3] =  GetVolEnvSuppAngName("4", "V", "D", icount, 3);
1509    
1510    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4VD[0], 0, true,
1511    TGeoTranslation(xEnv,-yEnvP+dpar[1],fgkSizeVSupExt[0]+spar[2]));
1512    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4VD[1], 0, true,
1513    TGeoTranslation(xEnv,yEnvP+dpar[1],fgkSizeVSupExt[0]+spar[2]));
1514    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4VD[2], 0, true,
1515    TGeoTranslation(-xEnv,-yEnvM+dpar[1],-(fgkSizeVSupExt[0]+spar[2])),
1516    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1517    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4VD[3], 0, true,
1518    TGeoTranslation(-xEnv,yEnvM+dpar[1],-(fgkSizeVSupExt[0]+spar[2])),
1519    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1520    
1521    TString volAluAngSupport4V = GetVolAluAngSuppName("4", "V", icount);
1522    for (Int_t i=0;i<4;i++)
1523    GetEnvelopes(16+icount)
1524    ->AddEnvelopeConstituentParam(volAluAngSupport4V,volEnvSuppAng4VD[i],iVolNum++,3, spar);   
1525
1526 // 4 horizontal    
1527  
1528    spar[0]=dpar[0];
1529    spar[1]=fgkSizeSupport2H[1];
1530    spar[2]=fgkSizeSupport2H[2];
1531    TString volEnvSuppAng4HD[4];
1532    volEnvSuppAng4HD[0] =  GetVolEnvSuppAngName("4", "H", "D", icount, 0);
1533    volEnvSuppAng4HD[1] =  GetVolEnvSuppAngName("4", "H", "D", icount, 1);
1534    volEnvSuppAng4HD[2] =  GetVolEnvSuppAngName("4", "H", "D", icount, 2);
1535    volEnvSuppAng4HD[3] =  GetVolEnvSuppAngName("4", "H", "D", icount, 3);
1536    
1537    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4HD[0], 0, true,
1538    TGeoTranslation(xEnv,-yEnvP+dpar[1]+sparysave,fgkSizeVSupExt[0]+spar[2]));
1539    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4HD[1], 0, true,
1540    TGeoTranslation(xEnv,yEnvP+dpar[1]+sparysave,fgkSizeVSupExt[0]+spar[2]));
1541    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4HD[2], 0, true, 
1542    TGeoTranslation(-xEnv,-yEnvM+dpar[1]+sparysave,-(fgkSizeVSupExt[0]+spar[2])),
1543    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1544    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4HD[3], 0, true, 
1545    TGeoTranslation(-xEnv,yEnvM+dpar[1]+sparysave,-(fgkSizeVSupExt[0]+spar[2])),
1546    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1547
1548    TString volAluAngSupport4H = GetVolAluAngSuppName("4", "H", icount);
1549    for (Int_t i=0;i<4;i++)
1550    GetEnvelopes(16+icount)
1551    ->AddEnvelopeConstituentParam(volAluAngSupport4H,volEnvSuppAng4HD[i],iVolNum++,3, spar);   
1552
1553 // X horizontal    
1554    spar[0]=(fgkYVSup[3]-fgkYVSup[0])/2.*zRatio;
1555    spar[1]=fgkSizeSupportXH[1];
1556    spar[2]=fgkSizeSupportXH[2];
1557    Double_t sparysavex=spar[1];
1558    TString volEnvSuppAngXHD[4];
1559    volEnvSuppAngXHD[0] =  GetVolEnvSuppAngName("X", "H", "D", icount, 0);
1560    volEnvSuppAngXHD[1] =  GetVolEnvSuppAngName("X", "H", "D", icount, 1);
1561    volEnvSuppAngXHD[2] =  GetVolEnvSuppAngName("X", "H", "D", icount, 2);
1562    volEnvSuppAngXHD[3] =  GetVolEnvSuppAngName("X", "H", "D", icount, 3);
1563    
1564    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXHD[0], 0, true,
1565    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,-yEnvP+dpar[1]+sparysave+1.0,
1566    fgkSizeVSupExt[0]+spar[2]));
1567    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXHD[1], 0, true,
1568    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,yEnvP+dpar[1]+sparysave+1.0,
1569    fgkSizeVSupExt[0]+spar[2]));
1570    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXHD[2], 0, true,
1571    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),yEnvM+dpar[1]+sparysave+1.0,
1572    -(fgkSizeVSupExt[0]+spar[2])),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1573    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXHD[3], 0, true, 
1574    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),-yEnvM+dpar[1]+sparysave+1.0,
1575    -(fgkSizeVSupExt[0]+spar[2])),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1576
1577    TString volAluAngSupportXH = GetVolAluAngSuppName("X", "H", icount);
1578    for (Int_t i=0;i<4;i++)
1579    GetEnvelopes(16+icount)
1580    ->AddEnvelopeConstituentParam(volAluAngSupportXH,volEnvSuppAngXHD[i],iVolNum++,3, spar);   
1581
1582 // X vertical      
1583    spar[0]=(fgkYVSup[3]-fgkYVSup[0])/2.*zRatio;
1584    spar[1]=fgkSizeSupportXV[1];
1585    spar[2]=fgkSizeSupportXV[2];
1586    TString volEnvSuppAngXVD[4];
1587    volEnvSuppAngXVD[0] =  GetVolEnvSuppAngName("X", "V", "D", icount, 0);
1588    volEnvSuppAngXVD[1] =  GetVolEnvSuppAngName("X", "V", "D", icount, 1);
1589    volEnvSuppAngXVD[2] =  GetVolEnvSuppAngName("X", "V", "D", icount, 2);
1590    volEnvSuppAngXVD[3] =  GetVolEnvSuppAngName("X", "V", "D", icount, 3);
1591    
1592    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXVD[0], 0, true, 
1593    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,-yEnvP+dpar[1]+sparysave+1.0+sparysavex+spar[1],
1594    fgkSizeVSupExt[0]+spar[2]));
1595    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXVD[1], 0, true, 
1596    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,yEnvP+dpar[1]+sparysave+1.0+sparysavex+spar[1],
1597    fgkSizeVSupExt[0]+spar[2]));
1598    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXVD[2], 0, true, 
1599    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),yEnvM+dpar[1]+sparysave+1.0+sparysavex+spar[1],
1600    -(fgkSizeVSupExt[0]+spar[2])),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1601    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXVD[3], 0, true, 
1602    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),-yEnvM+dpar[1]+sparysave+1.0+sparysavex+spar[1],
1603    -(fgkSizeVSupExt[0]+spar[2])),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1604
1605    TString volAluAngSupportXV = GetVolAluAngSuppName("X", "V", icount);
1606    for (Int_t i=0;i<4;i++)
1607    GetEnvelopes(16+icount)
1608    ->AddEnvelopeConstituentParam(volAluAngSupportXV,volEnvSuppAngXVD[i],iVolNum++,3, spar);     
1609
1610    // keep values of yEnvP, yEnvM
1611    fYEnvPsave = yEnvP;
1612    fYEnvMsave = yEnvM;   
1613 }    
1614
1615 //______________________________________________________________________________
1616 void AliMUONTriggerGeometryBuilder::BuildChamberTypeE(Int_t& iVolNum, Int_t icount)
1617 {
1618 // ratio of zpos1m/zpos1p and inverse for first plane
1619     Float_t zpos1= AliMUONConstants::DefaultChamberZ(10); 
1620     Float_t zmp=(zpos1-3.6)/(zpos1+3.6);
1621     Float_t zpm=1./zmp;
1622     Float_t zRatio = AliMUONConstants::DefaultRatioTriggerChamber(icount);      
1623     Float_t xEnv = (fgkDXZERO+fgkXMAX/2.)*zRatio;
1624    
1625    Double_t dpar[3];    
1626    Double_t spar[3];    
1627    Double_t ppar[3];    
1628
1629 // E
1630    Float_t yEnvP = 0;
1631    Float_t yEnvM = 0;
1632    yEnvP = (fYEnvMsave + fgkYMIN * zRatio ) * zpm + fgkYMIN * zRatio;
1633    yEnvM = (fYEnvPsave + fgkYMIN * zRatio ) * zmp + fgkYMIN * zRatio;
1634
1635    Int_t detElemId = (10+icount+1)*100+15;
1636    TString volEnv1 = GetVolEnvName(icount, 1);
1637    TString volEnv7 = GetVolEnvName(icount, 7);
1638    TString volEnv10 = GetVolEnvName(icount, 10);
1639    TString volEnv16 = GetVolEnvName(icount, 16);
1640    TString volAlu = GetVolumeName("volAlu", icount);
1641
1642    GetEnvelopes(16+icount)
1643    ->AddEnvelope(volEnv1, detElemId, true, TGeoTranslation(xEnv,-yEnvM,fgkZm));
1644    detElemId = (10+icount+1)*100+3;
1645    GetEnvelopes(16+icount)
1646    ->AddEnvelope(volEnv7, detElemId, true, TGeoTranslation(xEnv, yEnvM,fgkZm));
1647    detElemId = (10+icount+1)*100+12;
1648    GetEnvelopes(16+icount)->AddEnvelope(volEnv10, detElemId, true, TGeoTranslation(-xEnv,-yEnvP,fgkZp),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1649    detElemId = (10+icount+1)*100+6;
1650    GetEnvelopes(16+icount)->AddEnvelope(volEnv16, detElemId, true, TGeoTranslation(-xEnv, yEnvP,fgkZp),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1651
1652    GetEnvelopes(16+icount)->AddEnvelopeConstituentParam(volAlu,volEnv1,iVolNum++,3,dpar);
1653    GetEnvelopes(16+icount)->AddEnvelopeConstituentParam(volAlu,volEnv7,iVolNum++,3,dpar);
1654    GetEnvelopes(16+icount)->AddEnvelopeConstituentParam(volAlu,volEnv10,iVolNum++,3,dpar);
1655    GetEnvelopes(16+icount)->AddEnvelopeConstituentParam(volAlu,volEnv16,iVolNum++,3,dpar);
1656
1657 // horizontal cable support chamber type E
1658
1659    char volEnvSupportHE[12][8];
1660    for(Int_t jj=0;jj<2;jj++){
1661      for(Int_t ii=0;ii<6;ii++){
1662        snprintf(volEnvSupportHE[6*jj+ii],8,"SA%dHE%d",icount+1,6*jj+ii);
1663      }
1664    }
1665       
1666    spar[0]=dpar[0]-(fgkYVSup[0]/2.)*zRatio;
1667    spar[1]=fgkSizeSupportCable[1];
1668    spar[2]=fgkSizeSupportCable[2];
1669    for(Int_t in=0;in<3;in++){
1670      GetEnvelopes(16+icount)->AddEnvelope(volEnvSupportHE[in], 0, true, TGeoTranslation(xEnv+fgkYVSup[0]/2.*zRatio,-(yEnvM+dpar[1]/2.*(in-1)),fgkSizeVSupExt[0]+spar[2]));
1671      GetEnvelopes(16+icount)->AddEnvelope(volEnvSupportHE[in+3], 0, true, TGeoTranslation(xEnv+fgkYVSup[0]/2.*zRatio, yEnvM+dpar[1]/2.*(in-1),fgkSizeVSupExt[0]+spar[2]));
1672      GetEnvelopes(16+icount)->AddEnvelope(volEnvSupportHE[in+6], 0, true, TGeoTranslation(-(xEnv+fgkYVSup[0]/2.*zRatio),-(yEnvP+dpar[1]/2.*(in-1)),-(fgkSizeVSupExt[0]+spar[2])),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1673      GetEnvelopes(16+icount)->AddEnvelope(volEnvSupportHE[in+9], 0, true, TGeoTranslation(-(xEnv+fgkYVSup[0]/2.*zRatio), yEnvP+dpar[1]/2.*(in-1),-(fgkSizeVSupExt[0]+spar[2])),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1674    }
1675    for(Int_t ii=0;ii<12;ii++) {
1676      TString volAluSupportH = GetVolumeName("volAluSupportH", icount);
1677      GetEnvelopes(16+icount)
1678    ->AddEnvelopeConstituentParam(volAluSupportH,volEnvSupportHE[ii],iVolNum++,3, spar);
1679    }  
1680    
1681 // angular supports chamber type E
1682 // 1 vertical      
1683  
1684    spar[0]=dpar[0];
1685    spar[1]=fgkSizeSupport1V[1];
1686    spar[2]=fgkSizeSupport1V[2];
1687    Double_t sparysave=spar[1];
1688
1689    TString volEnvSuppAng1VE[4];
1690    volEnvSuppAng1VE[0] =  GetVolEnvSuppAngName("1", "V", "E", icount, 0);
1691    volEnvSuppAng1VE[1] =  GetVolEnvSuppAngName("1", "V", "E", icount, 1);
1692    volEnvSuppAng1VE[2] =  GetVolEnvSuppAngName("1", "V", "E", icount, 2);
1693    volEnvSuppAng1VE[3] =  GetVolEnvSuppAngName("1", "V", "E", icount, 3);
1694
1695    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VE[0], 0, true,
1696    TGeoTranslation(xEnv,-yEnvM-dpar[1],fgkZm-dpar[2]-spar[2]));
1697    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VE[1], 0, true,
1698    TGeoTranslation(xEnv,yEnvM-dpar[1],fgkZm-dpar[2]-spar[2]));
1699    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VE[2], 0, true,
1700    TGeoTranslation(-xEnv,-yEnvP-dpar[1],fgkZp+dpar[2]+spar[2]),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1701    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VE[3], 0, true,
1702    TGeoTranslation(-xEnv,yEnvP-dpar[1],fgkZp+dpar[2]+spar[2]),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1703  
1704    TString volAluAngSupport1V = GetVolAluAngSuppName("1", "V", icount);
1705     for (Int_t i=0;i<4;i++)
1706    GetEnvelopes(16+icount)
1707    ->AddEnvelopeConstituentParam(volAluAngSupport1V,volEnvSuppAng1VE[i],iVolNum++,3, spar);
1708
1709
1710 // 1 horizontal    
1711  
1712    spar[0]=dpar[0];
1713    spar[1]=fgkSizeSupport1H[1];
1714    spar[2]=fgkSizeSupport1H[2];
1715
1716    TString volEnvSuppAng1HE[4];
1717    volEnvSuppAng1HE[0] =  GetVolEnvSuppAngName("1", "H", "E", icount, 0);
1718    volEnvSuppAng1HE[1] =  GetVolEnvSuppAngName("1", "H", "E", icount, 1);
1719    volEnvSuppAng1HE[2] =  GetVolEnvSuppAngName("1", "H", "E", icount, 2);
1720    volEnvSuppAng1HE[3] =  GetVolEnvSuppAngName("1", "H", "E", icount, 3);
1721    
1722    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HE[0], 0, true,
1723    TGeoTranslation(xEnv,-yEnvM-dpar[1]-sparysave,fgkZm-(dpar[2]-spar[2])));
1724    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HE[1], 0, true,
1725    TGeoTranslation(xEnv,yEnvM-dpar[1]-sparysave,fgkZm-(dpar[2]-spar[2])));
1726    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HE[2], 0, true, TGeoTranslation(-xEnv,-yEnvP-dpar[1]-sparysave,fgkZp+dpar[2]-spar[2]),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1727    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HE[3], 0, true, TGeoTranslation(-xEnv,yEnvP-dpar[1]-sparysave,fgkZp+dpar[2]-spar[2]),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1728
1729    TString volAluAngSupport1H = GetVolAluAngSuppName("1", "H", icount);
1730    for (Int_t i=0;i<4;i++)
1731    GetEnvelopes(16+icount)
1732    ->AddEnvelopeConstituentParam(volAluAngSupport1H,volEnvSuppAng1HE[i],iVolNum++,3, spar);
1733
1734 // gas pipe (low)
1735    ppar[0]=fgkSizeGasPipe[0];
1736    ppar[1]=fgkSizeGasPipe[1];
1737    ppar[2]=dpar[0];
1738    TString volEnvInoxGasPipe1E[4];
1739    volEnvInoxGasPipe1E[0] = GetVolEnvInoxGasPipeName("1", "E", icount, 0);
1740    volEnvInoxGasPipe1E[1] = GetVolEnvInoxGasPipeName("1", "E", icount, 1);
1741    volEnvInoxGasPipe1E[2] = GetVolEnvInoxGasPipeName("1", "E", icount, 2);
1742    volEnvInoxGasPipe1E[3] = GetVolEnvInoxGasPipeName("1", "E", icount, 3);
1743    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1E[0], 0, true,
1744    TGeoTranslation(xEnv,-yEnvM-dpar[1]-sparysave-fgkOffsetGasPipe,fgkZm),fRsupportpipe);
1745    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1E[1], 0, true,
1746    TGeoTranslation(xEnv,yEnvM-dpar[1]-sparysave-fgkOffsetGasPipe,fgkZm),fRsupportpipe);
1747    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1E[2], 0, true,
1748    TGeoTranslation(-xEnv,-yEnvP-dpar[1]-sparysave-fgkOffsetGasPipe,fgkZp),fRsupportpipe);
1749    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1E[3], 0, true,
1750    TGeoTranslation(-xEnv,yEnvP-dpar[1]-sparysave-fgkOffsetGasPipe,fgkZp),fRsupportpipe);
1751
1752     TString volInoxGasPipe = GetVolumeName("volInoxGasPipe", icount);
1753    for (Int_t i=0;i<4;i++)
1754    GetEnvelopes(16+icount)
1755    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe1E[i],iVolNum++,3, ppar);
1756
1757 // 2 vertical      
1758  
1759    spar[0]=dpar[0];
1760    spar[1]=fgkSizeSupport2V[1];
1761    spar[2]=fgkSizeSupport2V[2];
1762    sparysave=spar[1]+fgkSizeSupport2H[1];
1763    TString volEnvSuppAng2VE[4];
1764    volEnvSuppAng2VE[0] =  GetVolEnvSuppAngName("2", "V", "E", icount, 0);
1765    volEnvSuppAng2VE[1] =  GetVolEnvSuppAngName("2", "V", "E", icount, 1);
1766    volEnvSuppAng2VE[2] =  GetVolEnvSuppAngName("2", "V", "E", icount, 2);
1767    volEnvSuppAng2VE[3] =  GetVolEnvSuppAngName("2", "V", "E", icount, 3);
1768    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VE[0], 0, true,
1769    TGeoTranslation(xEnv,-yEnvM-dpar[1],-(fgkSizeVSupExt[0]+spar[2])));
1770    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VE[1], 0, true,
1771    TGeoTranslation(xEnv,yEnvM-dpar[1],-(fgkSizeVSupExt[0]+spar[2])));
1772    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VE[2], 0, true,
1773     TGeoTranslation(-xEnv,-yEnvP-dpar[1],fgkSizeVSupExt[0]+spar[2]),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1774    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VE[3], 0, true,
1775     TGeoTranslation(-xEnv,yEnvP-dpar[1],fgkSizeVSupExt[0]+spar[2]),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1776    
1777    TString volAluAngSupport2V = GetVolAluAngSuppName("2", "V", icount);
1778    for (Int_t i=0;i<4;i++)
1779    GetEnvelopes(16+icount)
1780    ->AddEnvelopeConstituentParam(volAluAngSupport2V,volEnvSuppAng2VE[i],iVolNum++,3, spar);   
1781
1782 // 2 horizontal    
1783  
1784    spar[0]=dpar[0];
1785    spar[1]=fgkSizeSupport2H[1];
1786    spar[2]=fgkSizeSupport2H[2];
1787
1788    TString volEnvSuppAng2HE[4];
1789    volEnvSuppAng2HE[0] =  GetVolEnvSuppAngName("2", "H", "E", icount, 0);
1790    volEnvSuppAng2HE[1] =  GetVolEnvSuppAngName("2", "H", "E", icount, 1);
1791    volEnvSuppAng2HE[2] =  GetVolEnvSuppAngName("2", "H", "E", icount, 2);
1792    volEnvSuppAng2HE[3] =  GetVolEnvSuppAngName("2", "H", "E", icount, 3);
1793
1794    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HE[0], 0, true,
1795    TGeoTranslation(xEnv,-yEnvM-dpar[1]-sparysave,-(fgkSizeVSupExt[0]+spar[2])));
1796    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HE[1], 0, true,
1797    TGeoTranslation(xEnv,yEnvM-dpar[1]-sparysave,-(fgkSizeVSupExt[0]+spar[2])));
1798    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HE[2], 0, true, TGeoTranslation(-xEnv,-yEnvP-dpar[1]-sparysave,fgkSizeVSupExt[0]+spar[2]),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1799    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HE[3], 0, true, TGeoTranslation(-xEnv,yEnvP-dpar[1]-sparysave,fgkSizeVSupExt[0]+spar[2]),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1800
1801    TString volAluAngSupport2H = GetVolAluAngSuppName("2", "H", icount);
1802    for (Int_t i=0;i<4;i++)
1803    GetEnvelopes(16+icount)
1804    ->AddEnvelopeConstituentParam(volAluAngSupport2H,volEnvSuppAng2HE[i],iVolNum++,3, spar);   
1805
1806 // 3 vertical      
1807  
1808    spar[0]=dpar[0];
1809    spar[1]=fgkSizeSupport1V[1];
1810    spar[2]=fgkSizeSupport1V[2];
1811    sparysave=spar[1];
1812    TString volEnvSuppAng3VE[4];
1813    volEnvSuppAng3VE[0] =  GetVolEnvSuppAngName("3", "V", "E", icount, 0);
1814    volEnvSuppAng3VE[1] =  GetVolEnvSuppAngName("3", "V", "E", icount, 1);
1815    volEnvSuppAng3VE[2] =  GetVolEnvSuppAngName("3", "V", "E", icount, 2);
1816    volEnvSuppAng3VE[3] =  GetVolEnvSuppAngName("3", "V", "E", icount, 3);
1817    
1818    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VE[0], 0, true,
1819    TGeoTranslation(xEnv,-yEnvM+dpar[1],fgkZm-dpar[2]-spar[2]));
1820    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VE[1], 0, true,
1821    TGeoTranslation(xEnv,yEnvM+dpar[1],fgkZm-dpar[2]-spar[2]));
1822    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VE[2], 0, true,
1823    TGeoTranslation(-xEnv,-yEnvP+dpar[1],fgkZp+dpar[2]+spar[2]),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1824    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VE[3], 0, true,
1825    TGeoTranslation(-xEnv,yEnvP+dpar[1],fgkZp+dpar[2]+spar[2]),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1826  
1827    TString volAluAngSupport3V = GetVolAluAngSuppName("3", "V", icount);
1828    for (Int_t i=0;i<4;i++)
1829    GetEnvelopes(16+icount)
1830    ->AddEnvelopeConstituentParam(volAluAngSupport3V,volEnvSuppAng3VE[i],iVolNum++,3, spar);
1831
1832
1833 // 3 horizontal    
1834  
1835    spar[0]=dpar[0];
1836    spar[1]=fgkSizeSupport1H[1];
1837    spar[2]=fgkSizeSupport1H[2];
1838
1839    TString volEnvSuppAng3HE[4];
1840    volEnvSuppAng3HE[0] =  GetVolEnvSuppAngName("3", "H", "E", icount, 0);
1841    volEnvSuppAng3HE[1] =  GetVolEnvSuppAngName("3", "H", "E", icount, 1);
1842    volEnvSuppAng3HE[2] =  GetVolEnvSuppAngName("3", "H", "E", icount, 2);
1843    volEnvSuppAng3HE[3] =  GetVolEnvSuppAngName("3", "H", "E", icount, 3);
1844    
1845    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HE[0], 0, true,
1846    TGeoTranslation(xEnv,-yEnvM+dpar[1]+sparysave,fgkZm-(dpar[2]-spar[2])));
1847    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HE[1], 0, true,
1848    TGeoTranslation(xEnv,yEnvM+dpar[1]+sparysave,fgkZm-(dpar[2]-spar[2])));
1849    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HE[2], 0, true, TGeoTranslation(-xEnv,-yEnvP+dpar[1]+sparysave,fgkZp+dpar[2]-spar[2]),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1850    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HE[3], 0, true, TGeoTranslation(-xEnv,yEnvP+dpar[1]+sparysave,fgkZp+dpar[2]-spar[2]),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1851
1852    TString volAluAngSupport3H = GetVolAluAngSuppName("3", "H", icount);
1853    for (Int_t i=0;i<4;i++)
1854    GetEnvelopes(16+icount)
1855    ->AddEnvelopeConstituentParam(volAluAngSupport3H,volEnvSuppAng3HE[i],iVolNum++,3, spar);
1856
1857 // gas pipe (high)
1858    ppar[0]=fgkSizeGasPipe[0];
1859    ppar[1]=fgkSizeGasPipe[1];
1860    ppar[2]=dpar[0];
1861    TString volEnvInoxGasPipe2E[4];
1862    volEnvInoxGasPipe2E[0] = GetVolEnvInoxGasPipeName("2", "E", icount, 0);
1863    volEnvInoxGasPipe2E[1] = GetVolEnvInoxGasPipeName("2", "E", icount, 1);
1864    volEnvInoxGasPipe2E[2] = GetVolEnvInoxGasPipeName("2", "E", icount, 2);
1865    volEnvInoxGasPipe2E[3] = GetVolEnvInoxGasPipeName("2", "E", icount, 3);
1866          GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2E[0], 0, true,
1867    TGeoTranslation(xEnv,-yEnvM+dpar[1]+sparysave+fgkOffsetGasPipe,fgkZm),fRsupportpipe);
1868    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2E[1], 0, true,
1869    TGeoTranslation(xEnv,yEnvM+dpar[1]+sparysave+fgkOffsetGasPipe,fgkZm),fRsupportpipe);
1870    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2E[2], 0, true,
1871    TGeoTranslation(-xEnv,-yEnvP+dpar[1]+sparysave+fgkOffsetGasPipe,fgkZp),fRsupportpipe);
1872    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2E[3], 0, true,
1873    TGeoTranslation(-xEnv,yEnvP+dpar[1]+sparysave+fgkOffsetGasPipe,fgkZp),fRsupportpipe);
1874
1875    for (Int_t i=0;i<4;i++)
1876    GetEnvelopes(16+icount)
1877    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe2E[i],iVolNum++,3, ppar);
1878
1879 // 4 vertical      
1880  
1881    spar[0]=dpar[0];
1882    spar[1]=fgkSizeSupport2V[1];
1883    spar[2]=fgkSizeSupport2V[2];
1884    sparysave=spar[1]+fgkSizeSupport2H[1];
1885
1886    TString volEnvSuppAng4VE[4];
1887    volEnvSuppAng4VE[0] =  GetVolEnvSuppAngName("4", "V", "E", icount, 0);
1888    volEnvSuppAng4VE[1] =  GetVolEnvSuppAngName("4", "V", "E", icount, 1);
1889    volEnvSuppAng4VE[2] =  GetVolEnvSuppAngName("4", "V", "E", icount, 2);
1890    volEnvSuppAng4VE[3] =  GetVolEnvSuppAngName("4", "V", "E", icount, 3);
1891    
1892    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4VE[0], 0, true,
1893    TGeoTranslation(xEnv,-yEnvM+dpar[1],-(fgkSizeVSupExt[0]+spar[2])));
1894    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4VE[1], 0, true,
1895    TGeoTranslation(xEnv,yEnvM+dpar[1],-(fgkSizeVSupExt[0]+spar[2])));
1896    GetEnvelopes(16+icount)
1897    ->AddEnvelope(volEnvSuppAng4VE[2], 0, true,
1898    TGeoTranslation(-xEnv,-yEnvP+dpar[1],fgkSizeVSupExt[0]+spar[2]),
1899    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1900    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4VE[3], 0, true,
1901    TGeoTranslation(-xEnv,yEnvP+dpar[1],fgkSizeVSupExt[0]+spar[2]),
1902    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1903    
1904    TString volAluAngSupport4V = GetVolAluAngSuppName("4", "V", icount);
1905    for (Int_t i=0;i<4;i++)
1906    GetEnvelopes(16+icount)
1907    ->AddEnvelopeConstituentParam(volAluAngSupport4V,volEnvSuppAng4VE[i],iVolNum++,3, spar);   
1908
1909 // 4 horizontal    
1910  
1911    spar[0]=dpar[0];
1912    spar[1]=fgkSizeSupport2H[1];
1913    spar[2]=fgkSizeSupport2H[2];
1914
1915    TString volEnvSuppAng4HE[4];
1916    volEnvSuppAng4HE[0] =  GetVolEnvSuppAngName("4", "H", "E", icount, 0);
1917    volEnvSuppAng4HE[1] =  GetVolEnvSuppAngName("4", "H", "E", icount, 1);
1918    volEnvSuppAng4HE[2] =  GetVolEnvSuppAngName("4", "H", "E", icount, 2);
1919    volEnvSuppAng4HE[3] =  GetVolEnvSuppAngName("4", "H", "E", icount, 3);
1920    
1921    GetEnvelopes(16+icount)
1922    ->AddEnvelope(volEnvSuppAng4HE[0], 0, true,
1923    TGeoTranslation(xEnv,-yEnvM+dpar[1]+sparysave,-(fgkSizeVSupExt[0]+spar[2])));
1924    GetEnvelopes(16+icount)
1925    ->AddEnvelope(volEnvSuppAng4HE[1], 0, true,
1926    TGeoTranslation(xEnv,yEnvM+dpar[1]+sparysave,-(fgkSizeVSupExt[0]+spar[2])));
1927    GetEnvelopes(16+icount)
1928    ->AddEnvelope(volEnvSuppAng4HE[2], 0, true, 
1929    TGeoTranslation(-xEnv,-yEnvP+dpar[1]+sparysave,fgkSizeVSupExt[0]+spar[2]),
1930    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1931    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4HE[3], 0, true, 
1932    TGeoTranslation(-xEnv,yEnvP+dpar[1]+sparysave,fgkSizeVSupExt[0]+spar[2]),
1933    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1934
1935    TString volAluAngSupport4H = GetVolAluAngSuppName("4", "H", icount);
1936    for (Int_t i=0;i<4;i++)
1937    GetEnvelopes(16+icount)
1938    ->AddEnvelopeConstituentParam(volAluAngSupport4H,volEnvSuppAng4HE[i],iVolNum++,3, spar);   
1939
1940 // X horizontal    
1941    spar[0]=(fgkYVSup[3]-fgkYVSup[0])/2.*zRatio;
1942    spar[1]=fgkSizeSupportXH[1];
1943    spar[2]=fgkSizeSupportXH[2];
1944    Double_t sparysavex=spar[1];
1945
1946    TString volEnvSuppAngXHE[4];
1947    volEnvSuppAngXHE[0] =  GetVolEnvSuppAngName("X", "H", "E", icount, 0);
1948    volEnvSuppAngXHE[1] =  GetVolEnvSuppAngName("X", "H", "E", icount, 1);
1949    volEnvSuppAngXHE[2] =  GetVolEnvSuppAngName("X", "H", "E", icount, 2);
1950    volEnvSuppAngXHE[3] =  GetVolEnvSuppAngName("X", "H", "E", icount, 3);
1951    
1952    GetEnvelopes(16+icount)
1953    ->AddEnvelope(volEnvSuppAngXHE[0], 0, true,
1954    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,-yEnvM+dpar[1]+sparysave+1.0,
1955    -(fgkSizeVSupExt[0]+spar[2])));
1956    GetEnvelopes(16+icount)
1957    ->AddEnvelope(volEnvSuppAngXHE[1], 0, true,
1958    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,yEnvM+dpar[1]+sparysave+1.0,
1959    -(fgkSizeVSupExt[0]+spar[2])));
1960    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXHE[2], 0, true, 
1961    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),-yEnvP+dpar[1]+sparysave+1.0,
1962    fgkSizeVSupExt[0]+spar[2]),
1963    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1964    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXHE[3], 0, true, 
1965    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),yEnvP+dpar[1]+sparysave+1.0,
1966    fgkSizeVSupExt[0]+spar[2]),
1967    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1968
1969    TString volAluAngSupportXH = GetVolAluAngSuppName("X", "H", icount);
1970    for (Int_t i=0;i<4;i++)
1971    GetEnvelopes(16+icount)
1972    ->AddEnvelopeConstituentParam(volAluAngSupportXH,volEnvSuppAngXHE[i],iVolNum++,3, spar);   
1973
1974 // X vertical      
1975    spar[0]=(fgkYVSup[3]-fgkYVSup[0])/2.*zRatio;
1976    spar[1]=fgkSizeSupportXV[1];
1977    spar[2]=fgkSizeSupportXV[2];
1978
1979    TString volEnvSuppAngXVE[4];
1980    volEnvSuppAngXVE[0] =  GetVolEnvSuppAngName("X", "V", "E", icount, 0);
1981    volEnvSuppAngXVE[1] =  GetVolEnvSuppAngName("X", "V", "E", icount, 1);
1982    volEnvSuppAngXVE[2] =  GetVolEnvSuppAngName("X", "V", "E", icount, 2);
1983    volEnvSuppAngXVE[3] =  GetVolEnvSuppAngName("X", "V", "E", icount, 3);
1984    
1985    GetEnvelopes(16+icount)
1986    ->AddEnvelope(volEnvSuppAngXVE[0], 0, true, 
1987    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,-yEnvM+dpar[1]+sparysave+1.0+sparysavex+spar[1],
1988    -(fgkSizeVSupExt[0]+spar[2])));
1989    GetEnvelopes(16+icount)
1990    ->AddEnvelope(volEnvSuppAngXVE[1], 0, true, 
1991    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,yEnvM+dpar[1]+sparysave+1.0+sparysavex+spar[1],
1992    -(fgkSizeVSupExt[0]+spar[2])));
1993    GetEnvelopes(16+icount)
1994    ->AddEnvelope(volEnvSuppAngXVE[2], 0, true, 
1995    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),-yEnvP+dpar[1]+sparysave+1.0+sparysavex+spar[1],
1996    fgkSizeVSupExt[0]+spar[2]),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
1997    GetEnvelopes(16+icount)
1998    ->AddEnvelope(volEnvSuppAngXVE[3], 0, true, 
1999    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),yEnvP+dpar[1]+sparysave+1.0+sparysavex+spar[1],
2000    fgkSizeVSupExt[0]+spar[2]),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2001
2002    TString volAluAngSupportXV = GetVolAluAngSuppName("X", "V", icount);
2003    for (Int_t i=0;i<4;i++)
2004    GetEnvelopes(16+icount)
2005    ->AddEnvelopeConstituentParam(volAluAngSupportXV,volEnvSuppAngXVE[i],iVolNum++,3, spar);
2006    
2007    // keep values of yEnvP, yEnvM
2008    fYEnvPsave = yEnvP;
2009    fYEnvMsave = yEnvM;   
2010 }
2011
2012 //______________________________________________________________________________
2013 void AliMUONTriggerGeometryBuilder::BuildChamberTypeF(Int_t& iVolNum, Int_t icount)
2014
2015 // ratio of zpos1m/zpos1p and inverse for first plane
2016     Float_t zpos1= AliMUONConstants::DefaultChamberZ(10); 
2017     Float_t zmp=(zpos1-3.6)/(zpos1+3.6);
2018     Float_t zpm=1./zmp;
2019     Float_t zRatio = AliMUONConstants::DefaultRatioTriggerChamber(icount);      
2020     Float_t xEnv = (fgkDXZERO+fgkXMAX/2.)*zRatio;
2021     
2022    Double_t dpar[3];    
2023    Double_t spar[3];    
2024    Double_t ppar[3];    
2025
2026 // F
2027    dpar[0] = (fgkXMAX/2.)*zRatio;
2028    dpar[1] =  fgkYMIN*zRatio;
2029    dpar[2] = 0.4;   
2030
2031    Float_t yEnvP = 0;
2032    Float_t yEnvM = 0;
2033    yEnvP = (fYEnvMsave + fgkYMIN * zRatio ) * zpm + fgkYMIN * zRatio;
2034    yEnvM = (fYEnvPsave + fgkYMIN * zRatio ) * zmp + fgkYMIN * zRatio;
2035
2036    Int_t detElemId = (10+icount+1)*100+14;
2037    TString volEnv0 = GetVolEnvName(icount, 0);
2038    TString volEnv8 = GetVolEnvName(icount, 8);
2039    TString volEnv9 = GetVolEnvName(icount, 9);
2040    TString volEnv17 = GetVolEnvName(icount, 17);
2041    TString volAlu = GetVolumeName("volAlu", icount);
2042    GetEnvelopes(16+icount)
2043    ->AddEnvelope(volEnv0, detElemId, true, TGeoTranslation(xEnv,-yEnvP,fgkZp));
2044    detElemId = (10+icount+1)*100+4;
2045    GetEnvelopes(16+icount)
2046    ->AddEnvelope(volEnv8, detElemId, true, TGeoTranslation(xEnv, yEnvP,fgkZp));
2047    detElemId = (10+icount+1)*100+13;
2048    GetEnvelopes(16+icount)
2049    ->AddEnvelope(volEnv9, detElemId, true, TGeoTranslation(-xEnv,-yEnvM,fgkZm),
2050    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2051    detElemId = (10+icount+1)*100+5;
2052    GetEnvelopes(16+icount)
2053    ->AddEnvelope(volEnv17, detElemId, true, TGeoTranslation(-xEnv, yEnvM,fgkZm),
2054    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2055    
2056    GetEnvelopes(16+icount)->AddEnvelopeConstituentParam(volAlu,volEnv0,iVolNum++,3,dpar);
2057    GetEnvelopes(16+icount)->AddEnvelopeConstituentParam(volAlu,volEnv8,iVolNum++,3,dpar);
2058    GetEnvelopes(16+icount)->AddEnvelopeConstituentParam(volAlu,volEnv9,iVolNum++,3,dpar);
2059    GetEnvelopes(16+icount)->AddEnvelopeConstituentParam(volAlu,volEnv17,iVolNum++,3,dpar);
2060
2061 // horizontal cable support chamber type F
2062
2063    char volEnvSupportHF[12][8];
2064    for(Int_t jj=0;jj<2;jj++){
2065      for(Int_t ii=0;ii<6;ii++){
2066        snprintf(volEnvSupportHF[6*jj+ii],8,"SA%dHF%d",icount+1,6*jj+ii);
2067      }
2068    }
2069
2070    spar[0]=dpar[0]-(fgkYVSup[0]/2.)*zRatio;
2071    spar[1]=fgkSizeSupportCable[1];
2072    spar[2]=fgkSizeSupportCable[2];
2073    for(Int_t in=0;in<3;in++){
2074      GetEnvelopes(16+icount)
2075      ->AddEnvelope(volEnvSupportHF[in], 0, true, 
2076      TGeoTranslation(xEnv+fgkYVSup[0]/2.*zRatio,-(yEnvP+dpar[1]/2.*(in-1)),
2077      -(fgkSizeVSupExt[0]+spar[2])));
2078      GetEnvelopes(16+icount)
2079      ->AddEnvelope(volEnvSupportHF[in+3], 0, true, 
2080      TGeoTranslation(xEnv+fgkYVSup[0]/2.*zRatio,yEnvP+dpar[1]/2.*(in-1),
2081      -(fgkSizeVSupExt[0]+spar[2])));
2082      GetEnvelopes(16+icount)
2083      ->AddEnvelope(volEnvSupportHF[in+6], 0, true, 
2084      TGeoTranslation(-(xEnv+fgkYVSup[0]/2.*zRatio),-(yEnvM+dpar[1]/2.*(in-1)),
2085      fgkSizeVSupExt[0]+spar[2]),
2086      TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2087      GetEnvelopes(16+icount)
2088      ->AddEnvelope(volEnvSupportHF[in+9], 0, true, 
2089      TGeoTranslation(-(xEnv+fgkYVSup[0]/2.*zRatio), yEnvM+dpar[1]/2.*(in-1),
2090      fgkSizeVSupExt[0]+spar[2]),
2091      TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2092    }
2093    for(Int_t ii=0;ii<12;ii++) {
2094      TString volAluSupportH = GetVolumeName("volAluSupportH", icount);
2095      GetEnvelopes(16+icount)
2096      ->AddEnvelopeConstituentParam(volAluSupportH,volEnvSupportHF[ii],iVolNum++,3, spar);
2097    }  
2098
2099 // angular supports chamber type F
2100 // 1 vertical      
2101  
2102    spar[0]=dpar[0];
2103    spar[1]=fgkSizeSupport1V[1];
2104    spar[2]=fgkSizeSupport1V[2];
2105    Double_t sparysave=spar[1];
2106    TString volEnvSuppAng1VF[4];
2107    volEnvSuppAng1VF[0] =  GetVolEnvSuppAngName("1", "V", "F", icount, 0);
2108    volEnvSuppAng1VF[1] =  GetVolEnvSuppAngName("1", "V", "F", icount, 1);
2109    volEnvSuppAng1VF[2] =  GetVolEnvSuppAngName("1", "V", "F", icount, 2);
2110    volEnvSuppAng1VF[3] =  GetVolEnvSuppAngName("1", "V", "F", icount, 3);
2111    
2112    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VF[0], 0, true,
2113    TGeoTranslation(xEnv,-yEnvP-dpar[1],fgkZp+dpar[2]+spar[2]));
2114    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VF[1], 0, true,
2115    TGeoTranslation(xEnv,yEnvP-dpar[1],fgkZp+dpar[2]+spar[2]));
2116    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VF[2], 0, true,
2117    TGeoTranslation(-xEnv,-yEnvM-dpar[1],fgkZm-dpar[2]-spar[2]),
2118    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2119    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1VF[3], 0, true,
2120    TGeoTranslation(-xEnv,yEnvM-dpar[1],fgkZm-dpar[2]-spar[2]),
2121    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2122  
2123    TString volAluAngSupport1V = GetVolAluAngSuppName("1", "V", icount);
2124    for (Int_t i=0;i<4;i++)
2125     GetEnvelopes(16+icount)
2126    ->AddEnvelopeConstituentParam(volAluAngSupport1V,volEnvSuppAng1VF[i],iVolNum++,3, spar);
2127
2128 // 1 horizontal    
2129  
2130    spar[0]=dpar[0];
2131    spar[1]=fgkSizeSupport1H[1];
2132    spar[2]=fgkSizeSupport1H[2];
2133
2134    TString volEnvSuppAng1HF[4];
2135    volEnvSuppAng1HF[0] =  GetVolEnvSuppAngName("1", "H", "F", icount, 0);
2136    volEnvSuppAng1HF[1] =  GetVolEnvSuppAngName("1", "H", "F", icount, 1);
2137    volEnvSuppAng1HF[2] =  GetVolEnvSuppAngName("1", "H", "F", icount, 2);
2138    volEnvSuppAng1HF[3] =  GetVolEnvSuppAngName("1", "H", "F", icount, 3);
2139    
2140    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HF[0], 0, true,
2141    TGeoTranslation(xEnv,-yEnvP-dpar[1]-sparysave,fgkZp+dpar[2]-spar[2]));
2142    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HF[1], 0, true,
2143    TGeoTranslation(xEnv,yEnvP-dpar[1]-sparysave,fgkZp+dpar[2]-spar[2]));
2144    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HF[2], 0, true, 
2145    TGeoTranslation(-xEnv,-yEnvM-dpar[1]-sparysave,fgkZm-(dpar[2]-spar[2])),
2146    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2147    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng1HF[3], 0, true, 
2148    TGeoTranslation(-xEnv,yEnvM-dpar[1]-sparysave,fgkZm-(dpar[2]-spar[2])),
2149    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2150
2151    TString volAluAngSupport1H = GetVolAluAngSuppName("1", "H", icount);
2152    for (Int_t i=0;i<4;i++)
2153    GetEnvelopes(16+icount)
2154    ->AddEnvelopeConstituentParam(volAluAngSupport1H,volEnvSuppAng1HF[i],iVolNum++,3, spar);
2155
2156 // gas pipe (low)
2157    ppar[0]=fgkSizeGasPipe[0];
2158    ppar[1]=fgkSizeGasPipe[1];
2159    ppar[2]=dpar[0];
2160    TString volEnvInoxGasPipe1F[4];
2161    volEnvInoxGasPipe1F[0] = GetVolEnvInoxGasPipeName("1", "F", icount, 0);
2162    volEnvInoxGasPipe1F[1] = GetVolEnvInoxGasPipeName("1", "F", icount, 1);
2163    volEnvInoxGasPipe1F[2] = GetVolEnvInoxGasPipeName("1", "F", icount, 2);
2164    volEnvInoxGasPipe1F[3] = GetVolEnvInoxGasPipeName("1", "F", icount, 3);
2165    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1F[0], 0, true,
2166    TGeoTranslation(xEnv,-yEnvP-dpar[1]-sparysave-fgkOffsetGasPipe,fgkZp),fRsupportpipe);
2167    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1F[1], 0, true,
2168    TGeoTranslation(xEnv,yEnvP-dpar[1]-sparysave-fgkOffsetGasPipe,fgkZp),fRsupportpipe);
2169    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1F[2], 0, true,
2170    TGeoTranslation(-xEnv,-yEnvM-dpar[1]-sparysave-fgkOffsetGasPipe,fgkZm),fRsupportpipe);
2171    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe1F[3], 0, true,
2172    TGeoTranslation(-xEnv,yEnvM-dpar[1]-sparysave-fgkOffsetGasPipe,fgkZm),fRsupportpipe);
2173
2174    TString volInoxGasPipe = GetVolumeName("volInoxGasPipe", icount);
2175    for (Int_t i=0;i<4;i++)
2176    GetEnvelopes(16+icount)
2177    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe1F[i],iVolNum++,3, ppar);
2178
2179 // 2 vertical      
2180  
2181    spar[0]=dpar[0];
2182    spar[1]=fgkSizeSupport2V[1];
2183    spar[2]=fgkSizeSupport2V[2];
2184    sparysave=spar[1]+fgkSizeSupport2H[1];
2185  
2186    TString volEnvSuppAng2VF[4];
2187    volEnvSuppAng2VF[0] =  GetVolEnvSuppAngName("2", "V", "F", icount, 0);
2188    volEnvSuppAng2VF[1] =  GetVolEnvSuppAngName("2", "V", "F", icount, 1);
2189    volEnvSuppAng2VF[2] =  GetVolEnvSuppAngName("2", "V", "F", icount, 2);
2190    volEnvSuppAng2VF[3] =  GetVolEnvSuppAngName("2", "V", "F", icount, 3);
2191    
2192    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VF[0], 0, true,
2193    TGeoTranslation(xEnv,-yEnvP-dpar[1],fgkSizeVSupExt[0]+spar[2]));
2194    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VF[1], 0, true,
2195    TGeoTranslation(xEnv,yEnvP-dpar[1],fgkSizeVSupExt[0]+spar[2]));
2196    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VF[2], 0, true,
2197     TGeoTranslation(-xEnv,-yEnvM-dpar[1],-(fgkSizeVSupExt[0]+spar[2])),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2198    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2VF[3], 0, true,
2199     TGeoTranslation(-xEnv,yEnvM-dpar[1],-(fgkSizeVSupExt[0]+spar[2])),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2200    
2201    TString volAluAngSupport2V = GetVolAluAngSuppName("2", "V", icount);
2202    for (Int_t i=0;i<4;i++)
2203    GetEnvelopes(16+icount)
2204    ->AddEnvelopeConstituentParam(volAluAngSupport2V,volEnvSuppAng2VF[i],iVolNum++,3, spar);   
2205
2206 // 2 horizontal    
2207  
2208    spar[0]=dpar[0];
2209    spar[1]=fgkSizeSupport2H[1];
2210    spar[2]=fgkSizeSupport2H[2];
2211
2212    TString volEnvSuppAng2HF[4];
2213    volEnvSuppAng2HF[0] =  GetVolEnvSuppAngName("2", "H", "F", icount, 0);
2214    volEnvSuppAng2HF[1] =  GetVolEnvSuppAngName("2", "H", "F", icount, 1);
2215    volEnvSuppAng2HF[2] =  GetVolEnvSuppAngName("2", "H", "F", icount, 2);
2216    volEnvSuppAng2HF[3] =  GetVolEnvSuppAngName("2", "H", "F", icount, 3);
2217    
2218    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HF[0], 0, true,
2219    TGeoTranslation(xEnv,-yEnvP-dpar[1]-sparysave,fgkSizeVSupExt[0]+spar[2]));
2220    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HF[1], 0, true,
2221    TGeoTranslation(xEnv,yEnvP-dpar[1]-sparysave,fgkSizeVSupExt[0]+spar[2]));
2222    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HF[2], 0, true, 
2223    TGeoTranslation(-xEnv,-yEnvM-dpar[1]-sparysave,-(fgkSizeVSupExt[0]+spar[2])),
2224    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2225    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng2HF[3], 0, true, 
2226    TGeoTranslation(-xEnv,yEnvM-dpar[1]-sparysave,-(fgkSizeVSupExt[0]+spar[2])),
2227    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2228
2229    TString volAluAngSupport2H = GetVolAluAngSuppName("2", "H", icount);
2230    for (Int_t i=0;i<4;i++)
2231    GetEnvelopes(16+icount)
2232    ->AddEnvelopeConstituentParam(volAluAngSupport2H,volEnvSuppAng2HF[i],iVolNum++,3, spar);   
2233
2234 // 3 vertical      
2235  
2236     spar[0]=dpar[0];
2237    spar[1]=fgkSizeSupport1V[1];
2238    spar[2]=fgkSizeSupport1V[2];
2239    sparysave=spar[1];
2240
2241    TString volEnvSuppAng3VF[4];
2242    volEnvSuppAng3VF[0] =  GetVolEnvSuppAngName("3", "V", "F", icount, 0);
2243    volEnvSuppAng3VF[1] =  GetVolEnvSuppAngName("3", "V", "F", icount, 1);
2244    volEnvSuppAng3VF[2] =  GetVolEnvSuppAngName("3", "V", "F", icount, 2);
2245    volEnvSuppAng3VF[3] =  GetVolEnvSuppAngName("3", "V", "F", icount, 3);
2246    
2247    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VF[0], 0, true,
2248    TGeoTranslation(xEnv,-yEnvP+dpar[1],fgkZp+dpar[2]+spar[2]));
2249    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VF[1], 0, true,
2250    TGeoTranslation(xEnv,yEnvP+dpar[1],fgkZp+dpar[2]+spar[2]));
2251    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VF[2], 0, true,
2252    TGeoTranslation(-xEnv,-yEnvM+dpar[1],fgkZm-dpar[2]-spar[2]),
2253    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2254    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3VF[3], 0, true,
2255    TGeoTranslation(-xEnv,yEnvM+dpar[1],fgkZm-dpar[2]-spar[2]),
2256    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2257
2258    TString volAluAngSupport3V = GetVolAluAngSuppName("3", "V", icount);
2259    for (Int_t i=0;i<4;i++)
2260     GetEnvelopes(16+icount)
2261    ->AddEnvelopeConstituentParam(volAluAngSupport3V,volEnvSuppAng3VF[i],iVolNum++,3, spar);
2262
2263 // 3 horizontal    
2264  
2265    spar[0]=dpar[0];
2266    spar[1]=fgkSizeSupport1H[1];
2267    spar[2]=fgkSizeSupport1H[2];
2268  
2269    TString volEnvSuppAng3HF[4];
2270    volEnvSuppAng3HF[0] =  GetVolEnvSuppAngName("3", "H", "F", icount, 0);
2271    volEnvSuppAng3HF[1] =  GetVolEnvSuppAngName("3", "H", "F", icount, 1);
2272    volEnvSuppAng3HF[2] =  GetVolEnvSuppAngName("3", "H", "F", icount, 2);
2273    volEnvSuppAng3HF[3] =  GetVolEnvSuppAngName("3", "H", "F", icount, 3);
2274   
2275    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HF[0], 0, true,
2276    TGeoTranslation(xEnv,-yEnvP+dpar[1]+sparysave,fgkZp+dpar[2]-spar[2]));
2277    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HF[1], 0, true,
2278    TGeoTranslation(xEnv,yEnvP+dpar[1]+sparysave,fgkZp+dpar[2]-spar[2]));
2279    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HF[2], 0, true, 
2280    TGeoTranslation(-xEnv,-yEnvM+dpar[1]+sparysave,fgkZm-(dpar[2]-spar[2])),
2281    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2282    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng3HF[3], 0, true, 
2283    TGeoTranslation(-xEnv,yEnvM+dpar[1]+sparysave,fgkZm-(dpar[2]-spar[2])),
2284    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2285
2286    TString volAluAngSupport3H = GetVolAluAngSuppName("3", "H", icount);
2287    for (Int_t i=0;i<4;i++)
2288    GetEnvelopes(16+icount)
2289    ->AddEnvelopeConstituentParam(volAluAngSupport3H,volEnvSuppAng3HF[i],iVolNum++,3, spar);
2290    
2291 // gas pipe (high)
2292    ppar[0]=fgkSizeGasPipe[0];
2293    ppar[1]=fgkSizeGasPipe[1];
2294    ppar[2]=dpar[0];
2295    TString volEnvInoxGasPipe2F[4];
2296    volEnvInoxGasPipe2F[0] = GetVolEnvInoxGasPipeName("2", "F", icount, 0);
2297    volEnvInoxGasPipe2F[1] = GetVolEnvInoxGasPipeName("2", "F", icount, 1);
2298    volEnvInoxGasPipe2F[2] = GetVolEnvInoxGasPipeName("2", "F", icount, 2);
2299    volEnvInoxGasPipe2F[3] = GetVolEnvInoxGasPipeName("2", "F", icount, 3);
2300    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2F[0], 0, true,
2301    TGeoTranslation(xEnv,-yEnvP+dpar[1]+sparysave+fgkOffsetGasPipe,fgkZp),fRsupportpipe);
2302    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2F[1], 0, true,
2303    TGeoTranslation(xEnv,yEnvP+dpar[1]+sparysave+fgkOffsetGasPipe,fgkZp),fRsupportpipe);
2304    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2F[2], 0, true,
2305    TGeoTranslation(-xEnv,-yEnvM+dpar[1]+sparysave+fgkOffsetGasPipe,fgkZm),fRsupportpipe);
2306    GetEnvelopes(16+icount)->AddEnvelope(volEnvInoxGasPipe2F[3], 0, true,
2307    TGeoTranslation(-xEnv,yEnvM+dpar[1]+sparysave+fgkOffsetGasPipe,fgkZm),fRsupportpipe);
2308
2309    for (Int_t i=0;i<4;i++)
2310    GetEnvelopes(16+icount)
2311    ->AddEnvelopeConstituentParam(volInoxGasPipe,volEnvInoxGasPipe2F[i],iVolNum++,3, ppar);
2312
2313 // 4 vertical      
2314  
2315    spar[0]=dpar[0];
2316    spar[1]=fgkSizeSupport2V[1];
2317    spar[2]=fgkSizeSupport2V[2];
2318    sparysave=spar[1]+fgkSizeSupport2H[1];
2319
2320    TString volEnvSuppAng4VF[4];
2321    volEnvSuppAng4VF[0] =  GetVolEnvSuppAngName("4", "V", "F", icount, 0);
2322    volEnvSuppAng4VF[1] =  GetVolEnvSuppAngName("4", "V", "F", icount, 1);
2323    volEnvSuppAng4VF[2] =  GetVolEnvSuppAngName("4", "V", "F", icount, 2);
2324    volEnvSuppAng4VF[3] =  GetVolEnvSuppAngName("4", "V", "F", icount, 3);
2325    
2326    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4VF[0], 0, true,
2327    TGeoTranslation(xEnv,-yEnvP+dpar[1],fgkSizeVSupExt[0]+spar[2]));
2328    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4VF[1], 0, true,
2329    TGeoTranslation(xEnv,yEnvP+dpar[1],fgkSizeVSupExt[0]+spar[2]));
2330    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4VF[2], 0, true,
2331    TGeoTranslation(-xEnv,-yEnvM+dpar[1],-(fgkSizeVSupExt[0]+spar[2])),
2332    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2333    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4VF[3], 0, true,
2334    TGeoTranslation(-xEnv,yEnvM+dpar[1],-(fgkSizeVSupExt[0]+spar[2])),
2335    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2336    
2337    TString volAluAngSupport4V = GetVolAluAngSuppName("4", "V", icount);
2338    for (Int_t i=0;i<4;i++)
2339    GetEnvelopes(16+icount)
2340    ->AddEnvelopeConstituentParam(volAluAngSupport4V,volEnvSuppAng4VF[i],iVolNum++,3, spar);   
2341
2342 // 4 horizontal    
2343  
2344    spar[0]=dpar[0];
2345    spar[1]=fgkSizeSupport2H[1];
2346    spar[2]=fgkSizeSupport2H[2];
2347
2348    TString volEnvSuppAng4HF[4];
2349    volEnvSuppAng4HF[0] =  GetVolEnvSuppAngName("4", "H", "F", icount, 0);
2350    volEnvSuppAng4HF[1] =  GetVolEnvSuppAngName("4", "H", "F", icount, 1);
2351    volEnvSuppAng4HF[2] =  GetVolEnvSuppAngName("4", "H", "F", icount, 2);
2352    volEnvSuppAng4HF[3] =  GetVolEnvSuppAngName("4", "H", "F", icount, 3);
2353    
2354    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4HF[0], 0, true,
2355    TGeoTranslation(xEnv,-yEnvP+dpar[1]+sparysave,fgkSizeVSupExt[0]+spar[2]));
2356    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4HF[1], 0, true,
2357    TGeoTranslation(xEnv,yEnvP+dpar[1]+sparysave,fgkSizeVSupExt[0]+spar[2]));
2358    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4HF[2], 0, true, 
2359    TGeoTranslation(-xEnv,-yEnvM+dpar[1]+sparysave,-(fgkSizeVSupExt[0]+spar[2])),
2360    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2361    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAng4HF[3], 0, true, 
2362    TGeoTranslation(-xEnv,yEnvM+dpar[1]+sparysave,-(fgkSizeVSupExt[0]+spar[2])),
2363    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2364
2365    TString volAluAngSupport4H = GetVolAluAngSuppName("4", "H", icount);
2366    for (Int_t i=0;i<4;i++)
2367    GetEnvelopes(16+icount)
2368    ->AddEnvelopeConstituentParam(volAluAngSupport4H,volEnvSuppAng4HF[i],iVolNum++,3, spar);   
2369
2370
2371 // X horizontal    
2372    spar[0]=(fgkYVSup[3]-fgkYVSup[0])/2.*zRatio;
2373    spar[1]=fgkSizeSupportXH[1];
2374    spar[2]=fgkSizeSupportXH[2];
2375    Double_t sparysavex=spar[1];
2376
2377    TString volEnvSuppAngXHF[4];
2378    volEnvSuppAngXHF[0] =  GetVolEnvSuppAngName("X", "H", "F", icount, 0);
2379    volEnvSuppAngXHF[1] =  GetVolEnvSuppAngName("X", "H", "F", icount, 1);
2380    volEnvSuppAngXHF[2] =  GetVolEnvSuppAngName("X", "H", "F", icount, 2);
2381    volEnvSuppAngXHF[3] =  GetVolEnvSuppAngName("X", "H", "F", icount, 3);
2382    
2383    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXHF[0], 0, true,
2384    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,-yEnvP+dpar[1]+sparysave+1.0,
2385    fgkSizeVSupExt[0]+spar[2]));
2386    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXHF[1], 0, true,
2387    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,yEnvP+dpar[1]+sparysave+1.0,
2388    fgkSizeVSupExt[0]+spar[2]));
2389    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXHF[2], 0, true, 
2390    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),-yEnvM+dpar[1]+sparysave+1.0,
2391    -(fgkSizeVSupExt[0]+spar[2])),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2392    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXHF[3], 0, true, 
2393    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),yEnvM+dpar[1]+sparysave+1.0,
2394    -(fgkSizeVSupExt[0]+spar[2])),
2395    TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2396
2397    TString volAluAngSupportXH = GetVolAluAngSuppName("X", "H", icount);
2398    for (Int_t i=0;i<4;i++)
2399    GetEnvelopes(16+icount)
2400    ->AddEnvelopeConstituentParam(volAluAngSupportXH,volEnvSuppAngXHF[i],iVolNum++,3, spar);   
2401
2402 // X vertical      
2403    spar[0]=(fgkYVSup[3]-fgkYVSup[0])/2.*zRatio;
2404    spar[1]=fgkSizeSupportXV[1];
2405    spar[2]=fgkSizeSupportXV[2];
2406
2407    TString volEnvSuppAngXVF[4];
2408    volEnvSuppAngXVF[0] =  GetVolEnvSuppAngName("X", "V", "F", icount, 0);
2409    volEnvSuppAngXVF[1] =  GetVolEnvSuppAngName("X", "V", "F", icount, 1);
2410    volEnvSuppAngXVF[2] =  GetVolEnvSuppAngName("X", "V", "F", icount, 2);
2411    volEnvSuppAngXVF[3] =  GetVolEnvSuppAngName("X", "V", "F", icount, 3);
2412    
2413    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXVF[0], 0, true, 
2414    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,-yEnvP+dpar[1]+sparysave+1.0+sparysavex+spar[1],
2415    fgkSizeVSupExt[0]+spar[2]));
2416    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXVF[1], 0, true, 
2417    TGeoTranslation(spar[0]+fgkYVSup[0]*zRatio,yEnvP+dpar[1]+sparysave+1.0+sparysavex+spar[1],
2418    fgkSizeVSupExt[0]+spar[2]));
2419    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXVF[2], 0, true, 
2420    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),-yEnvM+dpar[1]+sparysave+1.0+sparysavex+spar[1],
2421    -(fgkSizeVSupExt[0]+spar[2])),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2422    GetEnvelopes(16+icount)->AddEnvelope(volEnvSuppAngXVF[3], 0, true, 
2423    TGeoTranslation(-(spar[0]+fgkYVSup[0]*zRatio),yEnvM+dpar[1]+sparysave+1.0+sparysavex+spar[1],
2424    -(fgkSizeVSupExt[0]+spar[2])),TGeoRotation("rot1",90.,180.,90.,90.,180.,0.));
2425
2426    TString volAluAngSupportXV = GetVolAluAngSuppName("X", "V", icount);
2427    for (Int_t i=0;i<4;i++)
2428    GetEnvelopes(16+icount)
2429    ->AddEnvelopeConstituentParam(volAluAngSupportXV,volEnvSuppAngXVF[i],iVolNum++,3, spar);
2430    
2431       // keep values of yEnvP, yEnvM
2432    fYEnvPsave = yEnvP;
2433    fYEnvMsave = yEnvM;   
2434 }
2435
2436 //
2437 // public methods
2438 //
2439
2440 //______________________________________________________________________________
2441 void AliMUONTriggerGeometryBuilder::CreateGeometry()
2442 {
2443 /// From AliMUONv1::CreateGeometry()
2444
2445     /* 
2446        zpos1 and zpos2 are the middle of the first and second
2447        planes of station 1 (+1m for second station):
2448        zpos1=(zpos1m+zpos1p)/2=(15999+16071)/2=16035 mm, thick/2=40 mm
2449        zpos2=(zpos2m+zpos2p)/2=(16169+16241)/2=16205 mm, thick/2=40 mm
2450        zposxm and zposxp= middles of gaz gaps within a detection plane
2451        rem: the total thickness accounts for 1 mm of al on both
2452        side of the RPCs (see zpos1 and zpos2)
2453     */
2454     
2455     fIdtmed = fMUON->GetIdtmed()->GetArray()-1099;
2456     fIdAir= fIdtmed[1100]; // medium 1
2457     fIdAlu1=fIdtmed[1103]; // medium 4
2458     fIdInox = fIdtmed[1128];       // medium 29 Stainless Steel (18%Cr,9%Ni,Fe) 
2459     
2460     Double_t dstation =  ( ( - AliMUONConstants::DefaultChamberZ(11)) - 
2461          ( - AliMUONConstants::DefaultChamberZ(10)) ) /2.1;
2462     Float_t par[3];
2463     par[2] = dstation;
2464  
2465     Int_t icount=0;  // chamber counter (0 1 2 3)
2466     
2467     for (Int_t istation=0; istation<2; istation++) { // loop on stations
2468       for (Int_t iplane=0; iplane<2; iplane++) { // loop on detection planes
2469    
2470           Int_t iVolNum=1; // counter Volume Number
2471           icount = Int_t(iplane<<0)+Int_t(istation<<1);
2472           
2473           cout << "## In AliMUONTriggerGeometryBuilder " << icount << endl;
2474     
2475           par[0] = AliMUONConstants::Rmin(5+istation); 
2476           par[1] = AliMUONConstants::Rmax(5+istation);
2477           Char_t volName[6];
2478           snprintf(volName,6,"%s%d", "SC",11+icount);
2479           gMC->Gsvolu(volName,"TUBE", fIdAir, par, 3);
2480           
2481 // chamber prototype
2482           BuildChamberPrototype(icount);
2483
2484 // RPC supports (vertical)
2485           BuildRPCSupportsVertical(iVolNum, icount);
2486             
2487 // RPC supports (horizontal)
2488
2489 // supports for cables
2490           BuildRPCSupportsHorizontal(icount);
2491           
2492 // Angular supports for chambers
2493           BuildAngularSupportForChambers(icount);
2494
2495 // gas pipes
2496           BuildGasPipes(icount);
2497
2498 // chamber type A
2499           BuildChamberTypeA(iVolNum, icount);
2500
2501 // chamber type B (plus envelope chambers B & C)   
2502           BuildChamberTypeB(iVolNum, icount);
2503
2504 // chamber type D, E and F (same size)
2505           BuildChamberTypeD(iVolNum, icount);
2506           BuildChamberTypeE(iVolNum, icount);
2507           BuildChamberTypeF(iVolNum, icount);
2508         } // end loop on detection planes
2509     } // end loop on stations    
2510 }
2511
2512 //______________________________________________________________________________
2513 void AliMUONTriggerGeometryBuilder::SetVolumes() 
2514 {
2515 /// Defines the volumes for the trigger chambers.
2516
2517     if (gAlice->GetModule("SHIL")) {
2518       SetMotherVolume(16, "YOUT2");
2519       SetMotherVolume(17, "YOUT2");
2520       SetMotherVolume(18, "YOUT2");
2521       SetMotherVolume(19, "YOUT2");
2522     }  
2523
2524     SetVolume(16, "SC11");
2525     SetVolume(17, "SC12");
2526     SetVolume(18, "SC13");
2527     SetVolume(19, "SC14");
2528 }
2529
2530 //______________________________________________________________________________
2531 void AliMUONTriggerGeometryBuilder::SetTransformations() 
2532 {
2533 /// Defines the transformations for the trigger chambers.
2534
2535     TGeoRotation st345inclination("rotbeam");
2536     st345inclination.RotateX(-AliMUONConstants::St345Inclination());
2537
2538     Double_t zpos1= AliMUONConstants::DefaultChamberZ(10); 
2539     SetTransformation(16, TGeoTranslation(0., 0, zpos1), st345inclination);
2540     
2541     zpos1= AliMUONConstants::DefaultChamberZ(11); 
2542     SetTransformation(17, TGeoTranslation(0., 0, zpos1), st345inclination);
2543
2544     zpos1= AliMUONConstants::DefaultChamberZ(12); 
2545     SetTransformation(18, TGeoTranslation(0., 0, zpos1), st345inclination);
2546
2547     zpos1= AliMUONConstants::DefaultChamberZ(13); 
2548     SetTransformation(19, TGeoTranslation(0., 0, zpos1), st345inclination);
2549 }
2550
2551 //______________________________________________________________________________
2552 void AliMUONTriggerGeometryBuilder::SetSensitiveVolumes()
2553 {
2554 /// Defines the sensitive volumes for trigger station chambers.
2555
2556   GetGeometry(16)->SetSensitiveVolume("S11G");
2557   GetGeometry(17)->SetSensitiveVolume("S12G");
2558   GetGeometry(18)->SetSensitiveVolume("S13G");
2559   GetGeometry(19)->SetSensitiveVolume("S14G");
2560 }
2561