]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDgeometryFull.cxx
new digitization and reconstruction corresponded to new data format
[u/mrichter/AliRoot.git] / TRD / AliTRDgeometryFull.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17 $Log$
18 Revision 1.16  2005/12/16 12:11:14  cblume
19 First implementation of calibration scheme by Jan Fiete
20
21 Revision 1.15  2005/04/20 13:03:36  cblume
22 Fix of geometry and pad plane parameter
23
24 Revision 1.14  2004/05/07 06:52:50  cblume
25 Bug fix to allow for fPHOShole and not fRICHhole
26
27 Revision 1.13  2004/02/27 15:40:18  cblume
28 Fix definition of rotation matrices
29
30 Revision 1.12  2003/09/18 09:06:07  cblume
31 Geometry update, Removal of compiler warnings
32
33 Revision 1.10  2002/11/21 22:38:47  alibrary
34 Removing AliMC and AliMCProcess
35
36 Revision 1.9  2002/10/31 17:45:35  cblume
37 New chamber geometry
38
39 Revision 1.8  2002/02/11 14:21:16  cblume
40 Update of the geometry. Get rid of MANY
41
42 Revision 1.7  2001/05/11 07:56:12  hristov
43 Consistent declarations needed on Alpha
44
45 Revision 1.6  2001/02/14 18:22:26  cblume
46 Change in the geometry of the padplane
47
48 Revision 1.5  2000/11/01 14:53:21  cblume
49 Merge with TRD-develop
50
51 Revision 1.1.4.6  2000/10/15 23:40:01  cblume
52 Remove AliTRDconst
53
54 Revision 1.1.4.5  2000/10/06 16:49:46  cblume
55 Made Getters const
56
57 Revision 1.1.4.4  2000/10/04 16:34:58  cblume
58 Replace include files by forward declarations
59
60 Revision 1.1.4.3  2000/09/22 14:43:41  cblume
61 Allow the pad/timebin-dimensions to be changed after initialization
62
63 Revision 1.4  2000/10/02 21:28:19  fca
64 Removal of useless dependecies via forward declarations
65
66 Revision 1.3  2000/06/08 18:32:58  cblume
67 Make code compliant to coding conventions
68
69 Revision 1.2  2000/05/08 16:17:27  cblume
70 Merge TRD-develop
71
72 Revision 1.1.4.2  2000/05/08 14:46:44  cblume
73 Include options SetPHOShole() and SetRICHhole()
74
75 Revision 1.1.4.1  2000/04/27 12:46:04  cblume
76 Corrected bug in full geometry
77
78 Revision 1.1  2000/02/28 19:01:15  cblume
79 Add new TRD classes
80
81 */
82
83 ///////////////////////////////////////////////////////////////////////////////
84 //                                                                           //
85 //  TRD geometry for the spaceframe without holes                            //
86 //                                                                           //
87 ///////////////////////////////////////////////////////////////////////////////
88
89 #include "TVirtualMC.h"
90
91 #include "AliTRDgeometryFull.h"
92 #include "AliTRDCommonParam.h"
93
94 ClassImp(AliTRDgeometryFull)
95
96 //_____________________________________________________________________________
97 AliTRDgeometryFull::AliTRDgeometryFull():AliTRDgeometry()
98 {
99   //
100   // AliTRDgeometryFull default constructor
101   //
102
103   Init();
104
105 }
106
107 //_____________________________________________________________________________
108 AliTRDgeometryFull::~AliTRDgeometryFull()
109 {
110   //
111   // AliTRDgeometryFull destructor
112   //
113
114 }
115
116 //_____________________________________________________________________________
117 void AliTRDgeometryFull::Init()
118 {
119   //
120   // Initializes the geometry parameter
121   //
122
123   Int_t icham;
124   Int_t iplan;
125
126   fPHOShole = kFALSE;
127   fRICHhole = kFALSE;
128
129   // The outer lengths of the chambers for the sectors with holes for the PHOS
130   Float_t lengthPH[kNplan][kNcham] = { { 124.0, 117.0,   0.0, 117.0, 124.0 }
131                                      , { 124.0, 117.0,   0.0, 117.0, 124.0 }
132                                      , { 131.0, 124.0,   0.0, 124.0, 131.0 }
133                                      , { 138.0, 131.0,   0.0, 131.0, 138.0 }
134                                      , { 145.0, 138.0,   0.0, 138.0, 145.0 }
135                                      , { 147.0, 140.0,   0.0, 140.0, 147.0 } };
136   // Old layer 6                                     
137   //                                 , { 147.0, 140.0,   0.0, 140.0, 147.0 } };
138
139   // The outer lengths of the chambers for the sectors with holes for the RICH
140   Float_t lengthRH[kNplan][kNcham] = { {  87.5,   0.0,   0.0,   0.0,  87.5 }
141                                      , {  87.5,   0.0,   0.0,   0.0,  87.5 }
142                                      , { 101.5,   0.0,   0.0,   0.0, 101.5 }
143                                      , { 115.5,   0.0,   0.0,   0.0, 115.5 }
144                                      , { 129.5,   0.0,   0.0,   0.0, 129.5 }
145                                      , { 133.5,   0.0,   0.0,   0.0, 133.5 } };
146   // Old layer 6
147   //                                 , { 133.5,   0.0,   0.0,   0.0, 133.5 } };
148
149   for (icham = 0; icham < kNcham; icham++) {
150     for (iplan = 0; iplan < kNplan; iplan++) {
151       fClengthPH[iplan][icham] = lengthPH[iplan][icham];
152       fClengthRH[iplan][icham] = lengthRH[iplan][icham];
153     }
154   }
155
156 }
157
158 //_____________________________________________________________________________
159 void AliTRDgeometryFull::CreateGeometry(Int_t *idtmed)
160 {
161   //
162   // Create the TRD geometry without hole
163   //
164   //
165   // Names of the TRD volumina (xx = detector number):
166   //
167   //      Volume (Air) wrapping the readout chamber components
168   //        UTxx    includes: UAxx, UDxx, UFxx, UUxx
169   //      Obs:
170   //        UUxx    the services volume has been reduced by 7.42 mm
171   //                in order to allow shifts in radial direction
172   //
173   //      Lower part of the readout chambers (gas volume + radiator)
174   //
175   //        UAxx    Aluminum frames             (Al)
176   //        UBxx    G10 frames                  (C)
177   //        UCxx    Inner volumes               (Air)
178   //
179   //      Upper part of the readout chambers (readout plane + fee)
180   //
181   //        UDxx    G10 frames                  (C)
182   //        UExx    Inner volumes of the G10    (Air)
183   //        UFxx    Aluminum frames             (Al)
184   //        UGxx    Inner volumes of the Al     (Air)
185   //
186   //      Inner material layers
187   //
188   //        UHxx    Radiator                    (Rohacell)
189   //        UIxx    Entrance window             (Mylar)
190   //        UJxx    Drift volume                (Xe/CO2)
191   //        UKxx    Amplification volume        (Xe/CO2)
192   //        ULxx    Pad plane                   (Cu)
193   //        UMxx    Support structure           (Rohacell)
194   //
195
196   //const Int_t kNdet    = kNplan * kNcham;  ... replaced by kNdets = 30
197
198   const Int_t kNparTrd = 4;
199   const Int_t kNparCha = 3;
200
201   Float_t xpos, ypos, zpos;
202
203   Float_t parTrd[kNparTrd];
204   Float_t parCha[kNparCha];
205
206   Char_t  cTagV[5];
207   Char_t  cTagM[5];
208
209   AliTRDgeometry::CreateGeometry(idtmed);
210
211   // The TRD mother volume for one sector (Air), full length in z-direction
212   // Provides material for side plates of super module
213   parTrd[0] = fgkSwidth1/2.;
214   parTrd[1] = fgkSwidth2/2.;
215   parTrd[2] = fgkSlenTR1/2.;
216   parTrd[3] = fgkSheight/2.;
217   gMC->Gsvolu("UTR1","TRD1",idtmed[1302-1],parTrd,kNparTrd);
218   // The TRD mother volume for one sector (Al), leaving hole for PHOS
219   if (fPHOShole) {
220     gMC->Gsvolu("UTR2","TRD1",idtmed[1302-1],parTrd,kNparTrd);
221   }
222   // The TRD mother volume for one sector (Al), leaving hole for RICH
223   if (fRICHhole) {
224     gMC->Gsvolu("UTR3","TRD1",idtmed[1302-1],parTrd,kNparTrd);
225   }  
226
227   // 
228   // The side plates of the super module (Al)
229   parTrd[0] = fgkSwidth1/2. - fgkSMgapT;
230   parTrd[1] = fgkSwidth2/2. - fgkSMgapT;
231   parTrd[2] = fgkSlenTR1/2.;
232   parTrd[3] = fgkSheight/2.;
233   gMC->Gsvolu("UTS1","TRD1",idtmed[1301-1],parTrd,kNparTrd);
234   // The TRD mother volume for one sector (Al), leaving hole for PHOS
235   if (fPHOShole) {
236     gMC->Gsvolu("UTS2","TRD1",idtmed[1301-1],parTrd,kNparTrd);
237   }
238   // The TRD mother volume for one sector (Al), leaving hole for RICH
239   if (fRICHhole) {
240     gMC->Gsvolu("UTS3","TRD1",idtmed[1301-1],parTrd,kNparTrd);
241   }  
242
243   // The inner part of the TRD mother volume for one sector (Air), 
244   // full length in z-direction
245   parTrd[0] = fgkSwidth1/2. - fgkSMgapT - fgkSMpltT;
246   parTrd[1] = fgkSwidth2/2. - fgkSMgapT - fgkSMpltT;
247   parTrd[2] = fgkSlenTR1/2.;
248   parTrd[3] = fgkSheight/2.;
249   gMC->Gsvolu("UTI1","TRD1",idtmed[1302-1],parTrd,kNparTrd);
250   // The TRD mother volume for one sector (Air), leaving hole for PHOS
251   if (fPHOShole) {
252     gMC->Gsvolu("UTI2","TRD1",idtmed[1302-1],parTrd,kNparTrd);
253   }
254   // The TRD mother volume for one sector (Air), leaving hole for RICH
255   if (fRICHhole) {
256     gMC->Gsvolu("UTI3","TRD1",idtmed[1302-1],parTrd,kNparTrd);
257   }  
258
259   for (Int_t icham = 0; icham < kNcham; icham++) {
260     for (Int_t iplan = 0; iplan < kNplan; iplan++) {  
261
262       Int_t iDet = GetDetectorSec(iplan,icham);
263
264       // The lower part of the readout chambers (gas volume + radiator) 
265       // The aluminum frames 
266       sprintf(cTagV,"UA%02d",iDet);
267       parCha[0] = fCwidth[iplan]/2.;
268       parCha[1] = fClength[iplan][icham]/2. - fgkHspace/2.;
269       parCha[2] = fgkCraH/2. + fgkCdrH/2.;
270       
271       fChamberUAboxd[iDet][0] = parCha[0];
272       fChamberUAboxd[iDet][1] = parCha[1];
273       fChamberUAboxd[iDet][2] = parCha[2];
274       
275       gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parCha,kNparCha);
276       // The G10 frames 
277       sprintf(cTagV,"UB%02d",iDet);
278       parCha[0] = fCwidth[iplan]/2. - fgkCalT; 
279       parCha[1] = -1.;
280       parCha[2] = -1.;
281       gMC->Gsvolu(cTagV,"BOX ",idtmed[1307-1],parCha,kNparCha);
282       // The inner part (air)
283       sprintf(cTagV,"UC%02d",iDet);
284       parCha[0] = fCwidth[iplan]/2. - fgkCalT - fgkCclsT; 
285       parCha[1] = fClength[iplan][icham]/2. - fgkHspace/2.- fgkCclfT;
286       parCha[2] = -1.;
287       gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
288       if (fPHOShole) {
289         if (fClengthPH[iplan][icham] > 0.0) {
290           // The aluminum frames 
291           sprintf(cTagV,"UA%02d",iDet+kNdets);
292           parCha[0] = fCwidth[iplan]/2.;
293           parCha[1] = fClengthPH[iplan][icham]/2. - fgkHspace/2.;
294           parCha[2] = fgkCraH/2. + fgkCdrH/2.;
295
296           fChamberUAboxd[iDet+kNdets][0] = parCha[0];
297           fChamberUAboxd[iDet+kNdets][1] = parCha[1];
298           fChamberUAboxd[iDet+kNdets][2] = parCha[2];
299       
300           gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parCha,kNparCha);
301           // The G10 frames 
302           sprintf(cTagV,"UB%02d",iDet+kNdets);
303           parCha[0] = fCwidth[iplan]/2. - fgkCalT; 
304           parCha[1] = -1.;
305           parCha[2] = -1.;
306           gMC->Gsvolu(cTagV,"BOX ",idtmed[1307-1],parCha,kNparCha);
307           // The inner part (air)
308           sprintf(cTagV,"UC%02d",iDet+kNdets);
309           parCha[0] = fCwidth[iplan]/2. - fgkCalT - fgkCclsT; 
310           parCha[1] = fClengthPH[iplan][icham]/2. - fgkHspace/2.- fgkCclfT;
311           parCha[2] = -1.;
312           gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
313         }
314       }
315       if (fRICHhole) {
316         if (fClengthRH[iplan][icham] > 0.0) {
317           // The aluminum frames 
318           sprintf(cTagV,"UA%02d",iDet+2*kNdets);
319           parCha[0] = fCwidth[iplan]/2.;
320           parCha[1] = fClengthRH[iplan][icham]/2. - fgkHspace/2.;
321           parCha[2] = fgkCraH/2. + fgkCdrH/2.;
322
323           fChamberUAboxd[iDet+2*kNdets][0] = parCha[0];
324           fChamberUAboxd[iDet+2*kNdets][1] = parCha[1];
325           fChamberUAboxd[iDet+2*kNdets][2] = parCha[2];
326       
327           gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parCha,kNparCha);
328           // The G10 frames 
329           sprintf(cTagV,"UB%02d",iDet+2*kNdets);
330           parCha[0] = fCwidth[iplan]/2. - fgkCalT; 
331           parCha[1] = -1.;
332           parCha[2] = -1.;
333           gMC->Gsvolu(cTagV,"BOX ",idtmed[1307-1],parCha,kNparCha);
334           // The inner part (air)
335           sprintf(cTagV,"UC%02d",iDet+2*kNdets);
336           parCha[0] = fCwidth[iplan]/2. - fgkCalT - fgkCclsT; 
337           parCha[1] = fClengthRH[iplan][icham]/2. - fgkHspace/2.- fgkCclfT;
338           parCha[2] = -1.;
339           gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
340         }
341       }
342
343       // The upper part of the readout chambers (readout plane)
344       // The G10 frames
345       sprintf(cTagV,"UD%02d",iDet);
346       parCha[0] = fCwidth[iplan]/2. + fgkCroW;
347       parCha[1] = fClength[iplan][icham]/2. - fgkHspace/2.;
348       parCha[2] = fgkCamH/2.;
349       
350       fChamberUDboxd[iDet][0] = parCha[0];
351       fChamberUDboxd[iDet][1] = parCha[1];
352       fChamberUDboxd[iDet][2] = parCha[2];
353       
354       gMC->Gsvolu(cTagV,"BOX ",idtmed[1307-1],parCha,kNparCha);
355       // The inner part of the G10 frame (air)
356       sprintf(cTagV,"UE%02d",iDet);
357       parCha[0] = fCwidth[iplan]/2. + fgkCroW - fgkCcuT; 
358       parCha[1] = fClength[iplan][icham]/2. - fgkHspace/2.- fgkCcuT;
359       parCha[2] = -1.;
360       gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
361       // The aluminum frames
362       sprintf(cTagV,"UF%02d",iDet);
363       parCha[0] = fCwidth[iplan]/2. + fgkCroW;
364       parCha[1] = fClength[iplan][icham]/2. - fgkHspace/2.;
365       parCha[2] = fgkCroH/2.;
366       
367       fChamberUFboxd[iDet][0] = parCha[0];
368       fChamberUFboxd[iDet][1] = parCha[1];
369       fChamberUFboxd[iDet][2] = parCha[2];
370       
371       gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parCha,kNparCha);
372       // The inner part of the aluminum frames
373       sprintf(cTagV,"UG%02d",iDet);
374       parCha[0] = fCwidth[iplan]/2. + fgkCroW - fgkCauT; 
375       parCha[1] = fClength[iplan][icham]/2. - fgkHspace/2.- fgkCauT;
376       parCha[2] = -1.;
377       gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
378       if (fPHOShole) {
379         if (fClengthPH[iplan][icham] > 0.0) {
380           sprintf(cTagV,"UD%02d",iDet+kNdets);
381           parCha[0] = fCwidth[iplan]/2. + fgkCroW;
382           parCha[1] = fClengthPH[iplan][icham]/2. - fgkHspace/2.;
383           parCha[2] = fgkCamH/2.;
384
385           fChamberUDboxd[iDet+kNdets][0] = parCha[0];
386           fChamberUDboxd[iDet+kNdets][1] = parCha[1];
387           fChamberUDboxd[iDet+kNdets][2] = parCha[2];
388       
389           gMC->Gsvolu(cTagV,"BOX ",idtmed[1307-1],parCha,kNparCha);
390           // The inner part of the G10 frame (air)
391           sprintf(cTagV,"UE%02d",iDet+kNdets);
392           parCha[0] = fCwidth[iplan]/2. + fgkCroW - fgkCcuT; 
393           parCha[1] = fClengthPH[iplan][icham]/2. - fgkHspace/2.- fgkCcuT;
394           parCha[2] = -1.;
395           gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
396           // The aluminum frames
397           sprintf(cTagV,"UF%02d",iDet+kNdets);
398           parCha[0] = fCwidth[iplan]/2. + fgkCroW;
399           parCha[1] = fClengthPH[iplan][icham]/2. - fgkHspace/2.;
400           parCha[2] = fgkCroH/2.;
401
402           fChamberUFboxd[iDet+kNdets][0] = parCha[0];
403           fChamberUFboxd[iDet+kNdets][1] = parCha[1];
404           fChamberUFboxd[iDet+kNdets][2] = parCha[2];
405           
406           gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parCha,kNparCha);
407           // The inner part of the aluminum frames
408           sprintf(cTagV,"UG%02d",iDet+kNdets);
409           parCha[0] = fCwidth[iplan]/2. + fgkCroW - fgkCauT; 
410           parCha[1] = fClengthPH[iplan][icham]/2. - fgkHspace/2.- fgkCauT;
411           parCha[2] = -1.;
412           gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
413         }
414       }
415       if (fRICHhole) {
416         if (fClengthRH[iplan][icham] > 0.0) {
417           sprintf(cTagV,"UD%02d",iDet+2*kNdets);
418           parCha[0] = fCwidth[iplan]/2. + fgkCroW;
419           parCha[1] = fClengthRH[iplan][icham]/2. - fgkHspace/2.;
420           parCha[2] = fgkCamH/2.;
421
422           fChamberUDboxd[iDet+2*kNdets][0] = parCha[0];
423           fChamberUDboxd[iDet+2*kNdets][1] = parCha[1];
424           fChamberUDboxd[iDet+2*kNdets][2] = parCha[2];
425       
426           gMC->Gsvolu(cTagV,"BOX ",idtmed[1307-1],parCha,kNparCha);
427           // The inner part of the G10 frame (air)
428           sprintf(cTagV,"UE%02d",iDet+2*kNdets);
429           parCha[0] = fCwidth[iplan]/2. + fgkCroW - fgkCcuT; 
430           parCha[1] = fClengthRH[iplan][icham]/2. - fgkHspace/2.- fgkCcuT;
431           parCha[2] = -1.;
432           gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
433           // The aluminum frames
434           sprintf(cTagV,"UF%02d",iDet+2*kNdets);
435           parCha[0] = fCwidth[iplan]/2. + fgkCroW;
436           parCha[1] = fClengthRH[iplan][icham]/2. - fgkHspace/2.;
437           parCha[2] = fgkCroH/2.;
438
439           fChamberUFboxd[iDet+2*kNdets][0] = parCha[0];
440           fChamberUFboxd[iDet+2*kNdets][1] = parCha[1];
441           fChamberUFboxd[iDet+2*kNdets][2] = parCha[2];
442           
443           gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parCha,kNparCha);
444           // The inner part of the aluminum frames
445           sprintf(cTagV,"UG%02d",iDet+2*kNdets);
446           parCha[0] = fCwidth[iplan]/2. + fgkCroW - fgkCauT; 
447           parCha[1] = fClengthRH[iplan][icham]/2. - fgkHspace/2.- fgkCauT;
448           parCha[2] = -1.;
449           gMC->Gsvolu(cTagV,"BOX ",idtmed[1302-1],parCha,kNparCha);
450         }
451       }
452
453       // The material layers inside the chambers
454       parCha[0] = -1.;
455       parCha[1] = -1.;
456       // Rohacell layer (radiator)
457       parCha[2] = fgkRaThick/2;
458       sprintf(cTagV,"UH%02d",iDet);
459       gMC->Gsvolu(cTagV,"BOX ",idtmed[1315-1],parCha,kNparCha);
460       // Mylar layer (entrance window + HV cathode) 
461       parCha[2] = fgkMyThick/2;
462       sprintf(cTagV,"UI%02d",iDet);
463       gMC->Gsvolu(cTagV,"BOX ",idtmed[1308-1],parCha,kNparCha);
464       // Xe/Isobutane layer (drift volume) 
465       parCha[2] = fgkDrThick/2.;
466       sprintf(cTagV,"UJ%02d",iDet);
467       gMC->Gsvolu(cTagV,"BOX ",idtmed[1309-1],parCha,kNparCha);
468       // Xe/Isobutane layer (amplification volume)
469       parCha[2] = fgkAmThick/2.;
470       sprintf(cTagV,"UK%02d",iDet);
471       gMC->Gsvolu(cTagV,"BOX ",idtmed[1309-1],parCha,kNparCha);  
472       // Cu layer (pad plane)
473       parCha[2] = fgkCuThick/2;
474       sprintf(cTagV,"UL%02d",iDet);
475       gMC->Gsvolu(cTagV,"BOX ",idtmed[1305-1],parCha,kNparCha);
476       // G10 layer (support structure / honeycomb)
477       parCha[2] = fgkSuThick/2;
478       sprintf(cTagV,"UM%02d",iDet);
479       gMC->Gsvolu(cTagV,"BOX ",idtmed[1313-1],parCha,kNparCha);
480       if (fPHOShole) {
481         if (fClengthPH[iplan][icham] > 0.0) {
482           // Rohacell layer (radiator)
483           parCha[2] = fgkRaThick/2;
484           sprintf(cTagV,"UH%02d",iDet+kNdets);
485           gMC->Gsvolu(cTagV,"BOX ",idtmed[1315-1],parCha,kNparCha);
486           // Mylar layer (entrance window + HV cathode) 
487           parCha[2] = fgkMyThick/2;
488           sprintf(cTagV,"UI%02d",iDet+kNdets);
489           gMC->Gsvolu(cTagV,"BOX ",idtmed[1308-1],parCha,kNparCha);
490           // Xe/Isobutane layer (drift volume) 
491           parCha[2] = fgkDrThick/2.;
492           sprintf(cTagV,"UJ%02d",iDet+kNdets);
493           gMC->Gsvolu(cTagV,"BOX ",idtmed[1309-1],parCha,kNparCha);
494           // Xe/Isobutane layer (amplification volume)
495           parCha[2] = fgkAmThick/2.;
496           sprintf(cTagV,"UK%02d",iDet+kNdets);
497           gMC->Gsvolu(cTagV,"BOX ",idtmed[1309-1],parCha,kNparCha);  
498           // Cu layer (pad plane)
499           parCha[2] = fgkCuThick/2;
500           sprintf(cTagV,"UL%02d",iDet+kNdets);
501           gMC->Gsvolu(cTagV,"BOX ",idtmed[1305-1],parCha,kNparCha);
502           // G10 layer (support structure / honeycomb)
503           parCha[2] = fgkSuThick/2;
504           sprintf(cTagV,"UM%02d",iDet+kNdets);
505           gMC->Gsvolu(cTagV,"BOX ",idtmed[1313-1],parCha,kNparCha);
506         }
507       }
508       if (fRICHhole) {
509         if (fClengthRH[iplan][icham] > 0.0) {
510           // Rohacell layer (radiator)
511           parCha[2] = fgkRaThick/2;
512           sprintf(cTagV,"UH%02d",iDet+2*kNdets);
513           gMC->Gsvolu(cTagV,"BOX ",idtmed[1315-1],parCha,kNparCha);
514           // Mylar layer (entrance window + HV cathode) 
515           parCha[2] = fgkMyThick/2;
516           sprintf(cTagV,"UI%02d",iDet+2*kNdets);
517           gMC->Gsvolu(cTagV,"BOX ",idtmed[1308-1],parCha,kNparCha);
518           // Xe/Isobutane layer (drift volume) 
519           parCha[2] = fgkDrThick/2.;
520           sprintf(cTagV,"UJ%02d",iDet+2*kNdets);
521           gMC->Gsvolu(cTagV,"BOX ",idtmed[1309-1],parCha,kNparCha);
522           // Xe/Isobutane layer (amplification volume)
523           parCha[2] = fgkAmThick/2.;
524           sprintf(cTagV,"UK%02d",iDet+2*kNdets);
525           gMC->Gsvolu(cTagV,"BOX ",idtmed[1309-1],parCha,kNparCha);  
526           // Cu layer (pad plane)
527           parCha[2] = fgkCuThick/2;
528           sprintf(cTagV,"UL%02d",iDet+2*kNdets);
529           gMC->Gsvolu(cTagV,"BOX ",idtmed[1305-1],parCha,kNparCha);
530           // G10 layer (support structure / honeycomb)
531           parCha[2] = fgkSuThick/2;
532           sprintf(cTagV,"UM%02d",iDet+2*kNdets);
533           gMC->Gsvolu(cTagV,"BOX ",idtmed[1313-1],parCha,kNparCha);
534         }
535       }
536
537       // Position the layers in the chambers
538       xpos = 0;
539       ypos = 0;
540       // Lower part
541       // Rohacell layer (radiator)
542       zpos = fgkRaZpos;
543       sprintf(cTagV,"UH%02d",iDet);
544       sprintf(cTagM,"UC%02d",iDet);
545       gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
546       // Mylar layer (entrance window + HV cathode)   
547       zpos = fgkMyZpos;
548       sprintf(cTagV,"UI%02d",iDet);
549       sprintf(cTagM,"UC%02d",iDet);
550       gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
551       // Xe/Isobutane layer (drift volume) 
552       zpos = fgkDrZpos;
553       sprintf(cTagV,"UJ%02d",iDet);
554       sprintf(cTagM,"UC%02d",iDet);
555       gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
556       // Upper part
557       // Xe/Isobutane layer (amplification volume)
558       zpos = fgkAmZpos;
559       sprintf(cTagV,"UK%02d",iDet);
560       sprintf(cTagM,"UE%02d",iDet);
561       gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
562       // Readout part
563       // Cu layer (pad plane)
564       zpos = fgkCuZpos; 
565       sprintf(cTagV,"UL%02d",iDet);
566       sprintf(cTagM,"UG%02d",iDet);
567       gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
568       // G10 layer (support structure)
569       zpos = fgkSuZpos;
570       sprintf(cTagV,"UM%02d",iDet);
571       sprintf(cTagM,"UG%02d",iDet);
572       gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
573       if (fPHOShole) {
574         if (fClengthPH[iplan][icham] > 0.0) {
575           // Lower part
576           // Rohacell layer (radiator)
577           zpos = fgkRaZpos;
578           sprintf(cTagV,"UH%02d",iDet+kNdets);
579           sprintf(cTagM,"UC%02d",iDet+kNdets);
580           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
581           // Mylar layer (entrance window + HV cathode)   
582           zpos = fgkMyZpos;
583           sprintf(cTagV,"UI%02d",iDet+kNdets);
584           sprintf(cTagM,"UC%02d",iDet+kNdets);
585           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
586           // Xe/Isobutane layer (drift volume) 
587           zpos = fgkDrZpos;
588           sprintf(cTagV,"UJ%02d",iDet+kNdets);
589           sprintf(cTagM,"UC%02d",iDet+kNdets);
590           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
591           // Upper part
592           // Xe/Isobutane layer (amplification volume)
593           zpos = fgkAmZpos;
594           sprintf(cTagV,"UK%02d",iDet+kNdets);
595           sprintf(cTagM,"UE%02d",iDet+kNdets);
596           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
597           // Readout part
598           // Cu layer (pad plane)
599           zpos = fgkCuZpos; 
600           sprintf(cTagV,"UL%02d",iDet+kNdets);
601           sprintf(cTagM,"UG%02d",iDet+kNdets);
602           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
603           // G10 layer (support structure)
604           zpos = fgkSuZpos;
605           sprintf(cTagV,"UM%02d",iDet+kNdets);
606           sprintf(cTagM,"UG%02d",iDet+kNdets);
607           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
608         }
609       }
610       if (fRICHhole) {
611         if (fClengthRH[iplan][icham] > 0.0) {
612           // Lower part
613           // Rohacell layer (radiator)
614           zpos = fgkRaZpos;
615           sprintf(cTagV,"UH%02d",iDet+2*kNdets);
616           sprintf(cTagM,"UC%02d",iDet+2*kNdets);
617           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
618           // Mylar layer (entrance window + HV cathode)   
619           zpos = fgkMyZpos;
620           sprintf(cTagV,"UI%02d",iDet+2*kNdets);
621           sprintf(cTagM,"UC%02d",iDet+2*kNdets);
622           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
623           // Xe/Isobutane layer (drift volume) 
624           zpos = fgkDrZpos;
625           sprintf(cTagV,"UJ%02d",iDet+2*kNdets);
626           sprintf(cTagM,"UC%02d",iDet+2*kNdets);
627           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
628           // Upper part
629           // Xe/Isobutane layer (amplification volume)
630           zpos = fgkAmZpos;
631           sprintf(cTagV,"UK%02d",iDet+2*kNdets);
632           sprintf(cTagM,"UE%02d",iDet+2*kNdets);
633           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
634           // Readout part
635           // Cu layer (pad plane)
636           zpos = fgkCuZpos; 
637           sprintf(cTagV,"UL%02d",iDet+2*kNdets);
638           sprintf(cTagM,"UG%02d",iDet+2*kNdets);
639           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
640           // G10 layer (support structure)
641           zpos = fgkSuZpos;
642           sprintf(cTagV,"UM%02d",iDet+2*kNdets);
643           sprintf(cTagM,"UG%02d",iDet+2*kNdets);
644           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
645         }
646       }
647
648       // Position the inner volumes of the chambers in the frames
649       xpos      = 0.0;
650       ypos      = 0.0;
651       zpos      = 0.0;
652       // The inside of the lower G10 frame
653       sprintf(cTagV,"UC%02d",iDet);
654       sprintf(cTagM,"UB%02d",iDet);
655       gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
656       // The lower G10 frame inside the aluminum frame
657       sprintf(cTagV,"UB%02d",iDet);
658       sprintf(cTagM,"UA%02d",iDet);
659       gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
660       // The inside of the upper G10 frame
661       sprintf(cTagV,"UE%02d",iDet);
662       sprintf(cTagM,"UD%02d",iDet);
663       gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
664       // The inside of the upper aluminum frame
665       sprintf(cTagV,"UG%02d",iDet);
666       sprintf(cTagM,"UF%02d",iDet);
667       gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");      
668       if (fPHOShole) {
669         if (fClengthPH[iplan][icham] > 0.0) {
670           // The inside of the lower G10 frame
671           sprintf(cTagV,"UC%02d",iDet+kNdets);
672           sprintf(cTagM,"UB%02d",iDet+kNdets);
673           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
674           // The lower G10 frame inside the aluminum frame
675           sprintf(cTagV,"UB%02d",iDet+kNdets);
676           sprintf(cTagM,"UA%02d",iDet+kNdets);
677           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
678           // The inside of the upper G10 frame
679           sprintf(cTagV,"UE%02d",iDet+kNdets);
680           sprintf(cTagM,"UD%02d",iDet+kNdets);
681           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
682           // The inside of the upper aluminum frame
683           sprintf(cTagV,"UG%02d",iDet+kNdets);
684           sprintf(cTagM,"UF%02d",iDet+kNdets);
685           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");      
686         }
687       }
688       if (fRICHhole) {
689         if (fClengthRH[iplan][icham] > 0.0) {
690           // The inside of the lower G10 frame
691           sprintf(cTagV,"UC%02d",iDet+2*kNdets);
692           sprintf(cTagM,"UB%02d",iDet+2*kNdets);
693           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
694           // The lower G10 frame inside the aluminum frame
695           sprintf(cTagV,"UB%02d",iDet+2*kNdets);
696           sprintf(cTagM,"UA%02d",iDet+2*kNdets);
697           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
698           // The inside of the upper G10 frame
699           sprintf(cTagV,"UE%02d",iDet+2*kNdets);
700           sprintf(cTagM,"UD%02d",iDet+2*kNdets);
701           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");
702           // The inside of the upper aluminum frame
703           sprintf(cTagV,"UG%02d",iDet+2*kNdets);
704           sprintf(cTagM,"UF%02d",iDet+2*kNdets);
705           gMC->Gspos(cTagV,1,cTagM,xpos,ypos,zpos,0,"ONLY");      
706         }
707       }
708
709       // Position the frames of the chambers in the TRD mother volume
710       xpos  = 0.;
711       ypos  = - fClength[iplan][0] - fClength[iplan][1] - fClength[iplan][2]/2.;
712       for (Int_t ic = 0; ic < icham; ic++) {
713         ypos += fClength[iplan][ic];        
714       }
715       ypos += fClength[iplan][icham]/2.;
716       zpos  = fgkCraH/2. + fgkCdrH/2. - fgkSheight/2. + iplan * (fgkCH + fgkVspace);
717       // The lower aluminum frame, radiator + drift region
718       sprintf(cTagV,"UA%02d",iDet);
719       
720       fChamberUAorig[iDet][0] = xpos;
721       fChamberUAorig[iDet][1] = ypos;
722       fChamberUAorig[iDet][2] = zpos;
723
724       //gMC->Gspos(cTagV,1,"UTI1",xposs,yposs,zposs,0,"ONLY");
725
726       // The upper G10 frame, amplification region
727       sprintf(cTagV,"UD%02d",iDet);
728       zpos += fgkCamH/2. + fgkCraH/2. + fgkCdrH/2.;
729       
730       fChamberUDorig[iDet][0] = xpos;
731       fChamberUDorig[iDet][1] = ypos;
732       fChamberUDorig[iDet][2] = zpos;
733
734       //gMC->Gspos(cTagV,1,"UTI1",xposs,yposs,zposs,0,"ONLY");
735
736       // The upper aluminum frame
737       sprintf(cTagV,"UF%02d",iDet);
738       zpos += fgkCroH/2. + fgkCamH/2.;
739       
740       fChamberUForig[iDet][0] = xpos;
741       fChamberUForig[iDet][1] = ypos;
742       fChamberUForig[iDet][2] = zpos;
743
744       //gMC->Gspos(cTagV,1,"UTI1",xposs,yposs,zposs,0,"ONLY");
745
746       if (fPHOShole) {
747         if (fClengthPH[iplan][icham] > 0.0) {
748           xpos  = 0.;
749           ypos  = - fClength[iplan][0] - fClength[iplan][1] - fClength[iplan][2]/2.;
750           for (Int_t ic = 0; ic < icham; ic++) {
751             ypos += fClength[iplan][ic];        
752           }
753           if (icham > 2) {
754             ypos += fClength[iplan][icham];
755             ypos -= fClengthPH[iplan][icham]/2.;
756           }
757           else {
758             ypos += fClengthPH[iplan][icham]/2.;
759           }
760           zpos  = fgkCraH/2. + fgkCdrH/2. - fgkSheight/2. + iplan * (fgkCH + fgkVspace);
761           // The lower aluminum frame, radiator + drift region
762           sprintf(cTagV,"UA%02d",iDet+kNdets);
763
764           fChamberUAorig[iDet+kNdets][0] = xpos;
765           fChamberUAorig[iDet+kNdets][1] = ypos;
766           fChamberUAorig[iDet+kNdets][2] = zpos;
767
768           //gMC->Gspos(cTagV,1,"UTI2",xpos,ypos,zpos,0,"ONLY");
769
770           // The upper G10 frame, amplification region
771           sprintf(cTagV,"UD%02d",iDet+kNdets);
772           zpos += fgkCamH/2. + fgkCraH/2. + fgkCdrH/2.;
773
774           fChamberUDorig[iDet+kNdets][0] = xpos;
775           fChamberUDorig[iDet+kNdets][1] = ypos;
776           fChamberUDorig[iDet+kNdets][2] = zpos;
777
778           //gMC->Gspos(cTagV,1,"UTI2",xpos,ypos,zpos,0,"ONLY");
779
780           // The upper aluminum frame
781           sprintf(cTagV,"UF%02d",iDet+kNdets);
782           zpos += fgkCroH/2. + fgkCamH/2.;
783
784           fChamberUForig[iDet+kNdets][0] = xpos;
785           fChamberUForig[iDet+kNdets][1] = ypos;
786           fChamberUForig[iDet+kNdets][2] = zpos;
787
788           //gMC->Gspos(cTagV,1,"UTI2",xpos,ypos,zpos,0,"ONLY");
789
790         }
791       }
792       if (fRICHhole) {
793         if (fClengthRH[iplan][icham] > 0.0) {
794           xpos  = 0.;
795           ypos  = - fClength[iplan][0] - fClength[iplan][1] - fClength[iplan][2]/2.;
796           for (Int_t ic = 0; ic < icham; ic++) {
797             ypos += fClength[iplan][ic];        
798           }
799           if (icham > 2) {
800             ypos += fClength[iplan][icham];
801             ypos -= fClengthRH[iplan][icham]/2.;
802           }
803           else {
804             ypos += fClengthRH[iplan][icham]/2.;
805           }
806           zpos  = fgkCraH/2. + fgkCdrH/2. - fgkSheight/2. + iplan * (fgkCH + fgkVspace);
807           // The lower aluminum frame, radiator + drift region
808           sprintf(cTagV,"UA%02d",iDet+2*kNdets);
809
810           fChamberUAorig[iDet+2*kNdets][0] = xpos;
811           fChamberUAorig[iDet+2*kNdets][1] = ypos;
812           fChamberUAorig[iDet+2*kNdets][2] = zpos;
813
814           //gMC->Gspos(cTagV,1,"UTI3",xpos,ypos,zpos,0,"ONLY");
815
816           // The upper G10 frame, amplification region
817           sprintf(cTagV,"UD%02d",iDet+2*kNdets);
818           zpos += fgkCamH/2. + fgkCraH/2. + fgkCdrH/2.;
819
820           fChamberUDorig[iDet+2*kNdets][0] = xpos;
821           fChamberUDorig[iDet+2*kNdets][1] = ypos;
822           fChamberUDorig[iDet+2*kNdets][2] = zpos;
823
824           //gMC->Gspos(cTagV,1,"UTI3",xpos,ypos,zpos,0,"ONLY");
825
826           // The upper aluminum frame
827           sprintf(cTagV,"UF%02d",iDet+2*kNdets);
828           zpos += fgkCroH/2. + fgkCamH/2.;
829
830           fChamberUForig[iDet+2*kNdets][0] = xpos;
831           fChamberUForig[iDet+2*kNdets][1] = ypos;
832           fChamberUForig[iDet+2*kNdets][2] = zpos;
833
834           //gMC->Gspos(cTagV,1,"UTI3",xpos,ypos,zpos,0,"ONLY");
835
836         }
837       }
838
839     }
840   }
841
842   // Create the volumes of the super module frame
843   CreateFrame(idtmed);
844
845   // Create the volumes of the services
846   CreateServices(idtmed);
847   
848   for (Int_t icham = 0; icham < kNcham; icham++) {
849     for (Int_t iplan = 0; iplan < kNplan; iplan++) {  
850
851       GroupChamber(iplan,icham,idtmed,kFALSE,kFALSE);
852
853       if (fPHOShole) {
854         if (fClengthPH[iplan][icham] > 0.0) {
855           GroupChamber(iplan,icham,idtmed,kTRUE,kFALSE);
856         }
857       }
858
859       if (fRICHhole) {
860         if (fClengthRH[iplan][icham] > 0.0) {
861           GroupChamber(iplan,icham,idtmed,kFALSE,kTRUE);
862         }
863       }
864
865     }
866   }
867   
868   xpos = 0.;
869   ypos = 0.;
870   zpos = 0.;
871   gMC->Gspos("UTI1",1,"UTS1",xpos,ypos,zpos,0,"ONLY");
872   if (fPHOShole) {
873     gMC->Gspos("UTI2",2,"UTS2",xpos,ypos,zpos,0,"ONLY");
874   }
875   if (fRICHhole) {
876     gMC->Gspos("UTI3",3,"UTS3",xpos,ypos,zpos,0,"ONLY");
877   }
878
879   xpos = 0.;
880   ypos = 0.;
881   zpos = 0.;
882   gMC->Gspos("UTS1",1,"UTR1",xpos,ypos,zpos,0,"ONLY");
883   if (fPHOShole) {
884     gMC->Gspos("UTS2",2,"UTR2",xpos,ypos,zpos,0,"ONLY");
885   }
886   if (fRICHhole) {
887     gMC->Gspos("UTS3",3,"UTR3",xpos,ypos,zpos,0,"ONLY");
888   }
889
890   xpos = 0.;
891   ypos = 0.;
892   zpos = 0.;
893   gMC->Gspos("UTR1",1,"BTR1",xpos,ypos,zpos,0,"ONLY");
894   if (fPHOShole) {
895     gMC->Gspos("UTR2",2,"BTR2",xpos,ypos,zpos,0,"ONLY");
896   }
897   else {
898     gMC->Gspos("UTR1",2,"BTR2",xpos,ypos,zpos,0,"ONLY");
899   }
900   if (fRICHhole) {
901     gMC->Gspos("UTR3",3,"BTR3",xpos,ypos,zpos,0,"ONLY");
902   }
903   else {
904     gMC->Gspos("UTR1",3,"BTR3",xpos,ypos,zpos,0,"ONLY");
905   }
906
907 }
908
909 //_____________________________________________________________________________
910 void AliTRDgeometryFull::CreateFrame(Int_t *idtmed)
911 {
912   //
913   // Create the geometry of the frame of the supermodule
914   //
915   // Names of the TRD services volumina
916   //
917   //        USRL    Support rails for the chambers (Al)
918   //        USxx    Support cross bars between the chambers (Al)
919   //
920
921   Int_t   iplan = 0;
922
923   Float_t xpos  = 0.0;
924   Float_t ypos  = 0.0;
925   Float_t zpos  = 0.0;
926
927   Char_t  cTagV[5];
928
929   //
930   // The chamber support rails
931   //
932
933   const Float_t kSRLwid  = 2.0;
934   const Float_t kSRLhgt  = 2.3;
935   const Float_t kSRLdst  = 0.6;
936   const Int_t   kNparSRL = 3;
937   Float_t parSRL[kNparSRL];
938   parSRL[0] = kSRLwid/2.;
939   parSRL[1] = fgkSlenTR1/2.;
940   parSRL[2] = kSRLhgt/2.;
941   gMC->Gsvolu("USRL","BOX ",idtmed[1301-1],parSRL,kNparSRL);
942
943   xpos  = 0.0;
944   ypos  = 0.0;
945   zpos  = 0.0;
946   for (iplan = 0; iplan < kNplan; iplan++) {
947     
948     xpos  = fCwidth[iplan]/2. + kSRLwid/2. + kSRLdst;
949     ypos  = 0.0;
950     zpos  = fgkCraH + fgkCdrH - fgkSheight/2. - kSRLhgt/2. 
951           + iplan * (fgkCH + fgkVspace);
952     gMC->Gspos("USRL",iplan+1         ,"UTI1", xpos,ypos,zpos,0,"ONLY");
953     gMC->Gspos("USRL",iplan+1+  kNplan,"UTI1",-xpos,ypos,zpos,0,"ONLY");
954     if (fPHOShole) {
955       gMC->Gspos("USRL",iplan+1+2*kNplan,"UTI2", xpos,ypos,zpos,0,"ONLY");
956       gMC->Gspos("USRL",iplan+1+3*kNplan,"UTI2",-xpos,ypos,zpos,0,"ONLY");
957     }
958     if (fRICHhole) {
959       gMC->Gspos("USRL",iplan+1+4*kNplan,"UTI3", xpos,ypos,zpos,0,"ONLY");
960       gMC->Gspos("USRL",iplan+1+5*kNplan,"UTI3",-xpos,ypos,zpos,0,"ONLY");
961     }
962
963   }
964
965   //
966   // The cross bars between the chambers
967   //
968
969   const Float_t kSCBwid  = 1.0;
970   const Int_t   kNparSCB = 3;
971   Float_t parSCB[kNparSCB];
972   parSCB[1] = kSCBwid/2.;
973   parSCB[2] = fgkCH/2.;
974
975   xpos  = 0.0;
976   ypos  = 0.0;
977   zpos  = 0.0;
978   for (iplan = 0; iplan < kNplan; iplan++) {
979
980     parSCB[0] = fCwidth[iplan]/2. + kSRLdst/2.;
981
982     sprintf(cTagV,"US0%01d",iplan);
983     gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parSCB,kNparSCB);
984     xpos  = 0.0;
985     ypos  =   fgkSlenTR1/2. - kSCBwid/2.;
986     zpos  = fgkCH/2. - fgkSheight/2. + iplan * (fgkCH + fgkVspace);
987     gMC->Gspos(cTagV,1,"UTI1", xpos,ypos,zpos,0,"ONLY");
988     if (fPHOShole) {
989       gMC->Gspos(cTagV,2,"UTI2", xpos,ypos,zpos,0,"ONLY");
990     }
991     if (fRICHhole) {
992       gMC->Gspos(cTagV,3,"UTI3", xpos,ypos,zpos,0,"ONLY");
993     }
994
995     sprintf(cTagV,"US1%01d",iplan);
996     gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parSCB,kNparSCB);
997     xpos  = 0.0;
998     ypos  = fClength[iplan][2]/2. + fClength[iplan][1];
999     zpos  = fgkCH/2. - fgkSheight/2. + iplan * (fgkCH + fgkVspace);
1000     gMC->Gspos(cTagV,1,"UTI1", xpos,ypos,zpos,0,"ONLY");
1001     if (fPHOShole) {
1002       gMC->Gspos(cTagV,2,"UTI2", xpos,ypos,zpos,0,"ONLY");
1003     }
1004     if (fRICHhole) {
1005       ypos += fClength[iplan][0] - fClengthRH[iplan][0];
1006       gMC->Gspos(cTagV,3,"UTI3", xpos,ypos,zpos,0,"ONLY");
1007     }
1008
1009     sprintf(cTagV,"US2%01d",iplan);
1010     gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parSCB,kNparSCB);
1011     xpos  = 0.0;
1012     ypos  = fClength[iplan][2]/2.;
1013     zpos  = fgkCH/2. - fgkSheight/2. + iplan * (fgkCH + fgkVspace);
1014     gMC->Gspos(cTagV,1,"UTI1", xpos,ypos,zpos,0,"ONLY");
1015     if (fPHOShole) {
1016       ypos += fClength[iplan][1] - fClengthPH[iplan][1];
1017       gMC->Gspos(cTagV,2,"UTI2", xpos,ypos,zpos,0,"ONLY");
1018     }
1019
1020     sprintf(cTagV,"US3%01d",iplan);
1021     gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parSCB,kNparSCB);
1022     xpos  = 0.0;
1023     ypos  = - fClength[iplan][2]/2.;
1024     zpos  = fgkCH/2. - fgkSheight/2. + iplan * (fgkCH + fgkVspace);
1025     gMC->Gspos(cTagV,1,"UTI1", xpos,ypos,zpos,0,"ONLY");
1026     if (fPHOShole) {
1027       ypos -= fClength[iplan][3] - fClengthPH[iplan][3];
1028       gMC->Gspos(cTagV,2,"UTI2", xpos,ypos,zpos,0,"ONLY");
1029     }
1030
1031     sprintf(cTagV,"US4%01d",iplan);
1032     gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parSCB,kNparSCB);
1033     xpos  = 0.0;
1034     ypos  = - fClength[iplan][2]/2. - fClength[iplan][1];
1035     zpos  = fgkCH/2. - fgkSheight/2. + iplan * (fgkCH + fgkVspace);
1036     gMC->Gspos(cTagV,1,"UTI1", xpos,ypos,zpos,0,"ONLY");
1037     if (fPHOShole) {
1038       gMC->Gspos(cTagV,2,"UTI2", xpos,ypos,zpos,0,"ONLY");
1039     }
1040     if (fRICHhole) {
1041       ypos -= fClength[iplan][4] - fClengthRH[iplan][4];
1042       gMC->Gspos(cTagV,3,"UTI3", xpos,ypos,zpos,0,"ONLY");
1043     }
1044
1045     sprintf(cTagV,"US5%01d",iplan);
1046     gMC->Gsvolu(cTagV,"BOX ",idtmed[1301-1],parSCB,kNparSCB);
1047     xpos  = 0.0;
1048     ypos  = - fgkSlenTR1/2. + kSCBwid/2.;
1049     zpos  = fgkCH/2. - fgkSheight/2. + iplan * (fgkCH + fgkVspace);
1050     gMC->Gspos(cTagV,1,"UTI1", xpos,ypos,zpos,0,"ONLY");
1051     if (fPHOShole) {
1052       gMC->Gspos(cTagV,2,"UTI2", xpos,ypos,zpos,0,"ONLY");
1053     }
1054     if (fRICHhole) {
1055       gMC->Gspos(cTagV,3,"UTI3", xpos,ypos,zpos,0,"ONLY");
1056     }
1057
1058   }
1059
1060 }
1061
1062 //_____________________________________________________________________________
1063 void AliTRDgeometryFull::CreateServices(Int_t *idtmed)
1064 {
1065   //
1066   // Create the geometry of the services
1067   //
1068   // Names of the TRD services volumina
1069   //
1070   //        UTCL    Cooling arterias (Al)
1071   //        UTCW    Cooling arterias (Water)
1072   //        UUxx    Volumes for the services at the chambers (Air)
1073   //        UTPW    Power bars       (Cu)
1074   //        UTCP    Cooling pipes    (Al)
1075   //        UTCH    Cooling pipes    (Water)
1076   //        UTPL    Power lines      (Cu)
1077   //        UMCM    Readout MCMs     (G10/Cu/Si)
1078   //
1079
1080   //const Int_t kNdet = kNplan * kNcham;  ... replaced by kNdets = 30
1081
1082   Int_t   iplan = 0;
1083   Int_t   icham = 0;
1084
1085   Float_t xpos  = 0.0;
1086   Float_t ypos  = 0.0;
1087   Float_t zpos  = 0.0;
1088
1089   Char_t  cTagV[5];
1090
1091   // The rotation matrices
1092   const Int_t kNmatrix = 3;
1093   Int_t   matrix[kNmatrix];
1094   gMC->Matrix(matrix[0],100.0,  0.0, 90.0, 90.0, 10.0,  0.0);
1095   gMC->Matrix(matrix[1], 80.0,  0.0, 90.0, 90.0, 10.0,180.0);
1096   gMC->Matrix(matrix[2],  0.0,  0.0, 90.0, 90.0, 90.0,  0.0);
1097
1098   AliTRDCommonParam* commonParam = AliTRDCommonParam::Instance();
1099   if (!commonParam)
1100   {
1101     printf("<AliTRDgeometryFull::CreateServices> ");
1102     printf("Could not get common params\n");
1103     return;
1104   }
1105     
1106   //
1107   // The cooling arterias
1108   //
1109
1110   // Width of the cooling arterias
1111   const Float_t kCOLwid  =  0.5; 
1112   // Height of the cooling arterias
1113   const Float_t kCOLhgt  =  5.5;
1114   // Positioning of the cooling 
1115   const Float_t kCOLposx =  1.6;
1116   const Float_t kCOLposz = -0.2;
1117   // Thickness of the walls of the cooling arterias
1118   const Float_t kCOLthk  =  0.1;
1119   const Int_t   kNparCOL = 3;
1120   Float_t parCOL[kNparCOL];
1121   parCOL[0]  = kCOLwid/2.;
1122   parCOL[1]  = fgkSlenTR1/2.;
1123   parCOL[2]  = kCOLhgt/2.;
1124   gMC->Gsvolu("UTCL","BOX ",idtmed[1324-1],parCOL,kNparCOL);
1125   parCOL[0] -= kCOLthk;
1126   parCOL[1]  = fgkSlenTR1/2.;
1127   parCOL[2] -= kCOLthk;
1128   gMC->Gsvolu("UTCW","BOX ",idtmed[1314-1],parCOL,kNparCOL);
1129
1130   xpos  = 0.0;
1131   ypos  = 0.0;
1132   zpos  = 0.0;
1133   gMC->Gspos("UTCW",1,"UTCL", xpos,ypos,zpos,0,"ONLY");
1134
1135   for (iplan = 1; iplan < kNplan; iplan++) {
1136     
1137     xpos  = fCwidth[iplan]/2. + kCOLwid/2. + kCOLposx;
1138     ypos  = 0.0;
1139     zpos  = kCOLhgt/2. - fgkSheight/2. + kCOLposz + iplan * (fgkCH + fgkVspace);
1140     gMC->Gspos("UTCL",iplan+1         ,"UTI1", xpos,ypos,zpos,matrix[0],"ONLY");
1141     gMC->Gspos("UTCL",iplan+1+  kNplan,"UTI1",-xpos,ypos,zpos,matrix[1],"ONLY");
1142     if (fPHOShole) {
1143       gMC->Gspos("UTCL",iplan+1+2*kNplan,"UTI2", xpos,ypos,zpos,matrix[0],"ONLY");
1144       gMC->Gspos("UTCL",iplan+1+3*kNplan,"UTI2",-xpos,ypos,zpos,matrix[1],"ONLY");
1145     }
1146     if (fRICHhole) {
1147       gMC->Gspos("UTCL",iplan+1+4*kNplan,"UTI3", xpos,ypos,zpos,matrix[0],"ONLY");
1148       gMC->Gspos("UTCL",iplan+1+5*kNplan,"UTI3",-xpos,ypos,zpos,matrix[1],"ONLY");
1149     }
1150
1151   }
1152
1153   //
1154   // The power bars
1155   //
1156
1157   const Float_t kPWRwid  =  0.6;
1158   const Float_t kPWRhgt  =  4.5;
1159   const Float_t kPWRposx =  1.05;
1160   const Float_t kPWRposz =  0.9;
1161   const Int_t   kNparPWR = 3;
1162   Float_t parPWR[kNparPWR];
1163   parPWR[0] = kPWRwid/2.;
1164   parPWR[1] = fgkSlenTR1/2.;
1165   parPWR[2] = kPWRhgt/2.;
1166   gMC->Gsvolu("UTPW","BOX ",idtmed[1325-1],parPWR,kNparPWR);
1167
1168   for (iplan = 1; iplan < kNplan; iplan++) {
1169     
1170     xpos  = fCwidth[iplan]/2. + kPWRwid/2. + kPWRposx;
1171     ypos  = 0.0;
1172     zpos  = kPWRhgt/2. - fgkSheight/2. + kPWRposz + iplan * (fgkCH + fgkVspace);
1173     gMC->Gspos("UTPW",iplan+1         ,"UTI1", xpos,ypos,zpos,matrix[0],"ONLY");
1174     gMC->Gspos("UTPW",iplan+1+  kNplan,"UTI1",-xpos,ypos,zpos,matrix[1],"ONLY");
1175     if (fPHOShole) {
1176       gMC->Gspos("UTPW",iplan+1+2*kNplan,"UTI2", xpos,ypos,zpos,matrix[0],"ONLY");
1177       gMC->Gspos("UTPW",iplan+1+3*kNplan,"UTI2",-xpos,ypos,zpos,matrix[1],"ONLY");
1178     }
1179     if (fRICHhole) {
1180       gMC->Gspos("UTPW",iplan+1+4*kNplan,"UTI3", xpos,ypos,zpos,matrix[0],"ONLY");
1181       gMC->Gspos("UTPW",iplan+1+5*kNplan,"UTI3",-xpos,ypos,zpos,matrix[1],"ONLY");
1182     }
1183
1184   }
1185
1186   //
1187   // The volumes for the services at the chambers
1188   //
1189
1190   const Int_t kNparServ = 3;
1191   Float_t parServ[kNparServ];
1192
1193   for (icham = 0; icham < kNcham; icham++) {
1194     //for (iplan = 0; iplan < kNplan; iplan++) {
1195     // Take out upper plane until TRD mothervolume is adjusted
1196     for (iplan = 0; iplan < kNplan-1; iplan++) {
1197
1198       Int_t iDet = GetDetectorSec(iplan,icham);
1199
1200       sprintf(cTagV,"UU%02d",iDet);
1201       parServ[0] = fCwidth[iplan]/2.;
1202       parServ[1] = fClength[iplan][icham]/2. - fgkHspace/2.;
1203       parServ[2] = fgkVspace/2. - 0.742/2.;
1204       
1205       fChamberUUboxd[iDet][0] = parServ[0];
1206       fChamberUUboxd[iDet][1] = parServ[1];
1207       fChamberUUboxd[iDet][2] = parServ[2];
1208       
1209       gMC->Gsvolu(cTagV,"BOX",idtmed[1302-1],parServ,kNparServ);
1210       xpos  = 0.;
1211       ypos  = - fClength[iplan][0] - fClength[iplan][1] - fClength[iplan][2]/2.;
1212       for (Int_t ic = 0; ic < icham; ic++) {
1213         ypos += fClength[iplan][ic];        
1214       }
1215       ypos += fClength[iplan][icham]/2.;
1216       zpos  = fgkCH + fgkVspace/2. - fgkSheight/2. + iplan * (fgkCH + fgkVspace);
1217       zpos -= 0.742/2.;
1218       
1219       fChamberUUorig[iDet][0] = xpos;
1220       fChamberUUorig[iDet][1] = ypos;
1221       fChamberUUorig[iDet][2] = zpos;
1222
1223       //gMC->Gspos(cTagV,1,"UTI1",xposs,yposs,zposs,0,"ONLY");
1224
1225       if (fPHOShole) {
1226         if (fClengthPH[iplan][icham] > 0.0) {
1227           sprintf(cTagV,"UU%02d",iDet+kNdets);
1228           parServ[0] = fCwidth[iplan]/2.;
1229           parServ[1] = fClengthPH[iplan][icham]/2. - fgkHspace/2.;
1230           parServ[2] = fgkVspace/2.;
1231
1232           fChamberUUboxd[iDet+kNdets][0] = parServ[0];
1233           fChamberUUboxd[iDet+kNdets][1] = parServ[1];
1234           fChamberUUboxd[iDet+kNdets][2] = parServ[2];
1235       
1236           gMC->Gsvolu(cTagV,"BOX",idtmed[1302-1],parServ,kNparServ);
1237           xpos  = 0.;
1238           ypos  = - fClength[iplan][0] - fClength[iplan][1] - fClength[iplan][2]/2.;
1239           for (Int_t ic = 0; ic < icham; ic++) {
1240             ypos += fClength[iplan][ic];        
1241           }
1242           if (icham > 2) {
1243             ypos += fClength[iplan][icham];
1244             ypos -= fClengthPH[iplan][icham]/2.;
1245           }
1246           else {
1247             ypos += fClengthPH[iplan][icham]/2.;
1248           }
1249           zpos  = fgkCH + fgkVspace/2. - fgkSheight/2. + iplan * (fgkCH + fgkVspace);
1250
1251           fChamberUUorig[iDet+kNdets][0] = xpos;
1252           fChamberUUorig[iDet+kNdets][1] = ypos;
1253           fChamberUUorig[iDet+kNdets][2] = zpos;
1254
1255           //gMC->Gspos(cTagV,1,"UTI2",xpos,ypos,zpos,0,"ONLY");
1256
1257         }
1258       }
1259
1260       if (fRICHhole) {
1261         if (fClengthRH[iplan][icham] > 0.0) {
1262           sprintf(cTagV,"UU%02d",iDet+2*kNdets);
1263           parServ[0] = fCwidth[iplan]/2.;
1264           parServ[1] = fClengthRH[iplan][icham]/2. - fgkHspace/2.;
1265           parServ[2] = fgkVspace/2.;
1266
1267           fChamberUUboxd[iDet+2*kNdets][0] = parServ[0];
1268           fChamberUUboxd[iDet+2*kNdets][1] = parServ[1];
1269           fChamberUUboxd[iDet+2*kNdets][2] = parServ[2];
1270       
1271           gMC->Gsvolu(cTagV,"BOX",idtmed[1302-1],parServ,kNparServ);
1272           xpos  = 0.;
1273           ypos  = - fClength[iplan][0] - fClength[iplan][1] - fClength[iplan][2]/2.;
1274           for (Int_t ic = 0; ic < icham; ic++) {
1275             ypos += fClength[iplan][ic];        
1276           }
1277           if (icham > 2) {
1278             ypos += fClength[iplan][icham];
1279             ypos -= fClengthRH[iplan][icham]/2.;
1280           }
1281           else {
1282             ypos += fClengthRH[iplan][icham]/2.;
1283           }
1284           zpos  = fgkCH + fgkVspace/2. - fgkSheight/2. + iplan * (fgkCH + fgkVspace);
1285
1286           fChamberUUorig[iDet+2*kNdets][0] = xpos;
1287           fChamberUUorig[iDet+2*kNdets][1] = ypos;
1288           fChamberUUorig[iDet+2*kNdets][2] = zpos;
1289
1290           //gMC->Gspos(cTagV,1,"UTI3",xpos,ypos,zpos,0,"ONLY");
1291
1292         }
1293       }
1294
1295     }
1296   }
1297
1298   //
1299   // The cooling pipes inside the service volumes
1300   //
1301
1302   const Int_t kNparTube = 3;
1303   Float_t parTube[kNparTube];
1304   // The aluminum pipe for the cooling
1305   parTube[0] = 0.0;
1306   parTube[1] = 0.0;
1307   parTube[2] = 0.0;
1308   gMC->Gsvolu("UTCP","TUBE",idtmed[1324-1],parTube,0);
1309   // The cooling water
1310   parTube[0] =  0.0;
1311   parTube[1] =  0.2/2.;
1312   parTube[2] = -1.;
1313   gMC->Gsvolu("UTCH","TUBE",idtmed[1314-1],parTube,kNparTube);
1314   // Water inside the cooling pipe
1315   xpos = 0.0;
1316   ypos = 0.0;
1317   zpos = 0.0;
1318   gMC->Gspos("UTCH",1,"UTCP",xpos,ypos,zpos,0,"ONLY");
1319
1320   // Position the cooling pipes in the mother volume
1321   const Int_t kNpar = 3;
1322   Float_t par[kNpar];
1323   for (icham = 0; icham < kNcham;   icham++) {
1324     //for (iplan = 0; iplan < kNplan; iplan++) {
1325     // Take out upper plane until TRD mothervolume is adjusted
1326     for (iplan = 0; iplan < kNplan-1; iplan++) { 
1327       Int_t   iDet    = GetDetectorSec(iplan,icham);
1328       Int_t   iCopy   = GetDetector(iplan,icham,0) * 100;
1329       Int_t   nMCMrow = commonParam->GetRowMax(iplan,icham,0);
1330       Float_t ySize   = (GetChamberLength(iplan,icham) - 2.*fgkRpadW) 
1331                       / ((Float_t) nMCMrow);
1332       sprintf(cTagV,"UU%02d",iDet);
1333       for (Int_t iMCMrow = 0; iMCMrow < nMCMrow; iMCMrow++) {
1334         xpos   = 0.0;
1335         ypos   = (0.5 + iMCMrow) * ySize - 1.9 
1336                - fClength[iplan][icham]/2. + fgkHspace/2.;
1337         zpos   = 0.0 + 0.742/2.;                 
1338         par[0] = 0.0;
1339         par[1] = 0.3/2.; // Thickness of the cooling pipes
1340         par[2] = fCwidth[iplan]/2.;
1341         gMC->Gsposp("UTCP",iCopy+iMCMrow,cTagV,xpos,ypos,zpos
1342                           ,matrix[2],"ONLY",par,kNpar);
1343       }
1344       if (fPHOShole) {
1345         sprintf(cTagV,"UU%02d",iDet+kNdets);
1346         for (Int_t iMCMrow = 0; iMCMrow < nMCMrow; iMCMrow++) {
1347           xpos   = 0.0;
1348           ypos   = (0.5 + iMCMrow) * ySize - 1.9 
1349                  - fClengthPH[iplan][icham]/2. + fgkHspace/2.;
1350           zpos   = 0.0;                 
1351           if (ypos < (fClengthPH[iplan][icham]/2. - fgkHspace/2.)) {
1352             par[0] = 0.0;
1353             par[1] = 0.3/2.; // Thickness of the cooling pipes
1354             par[2] = fCwidth[iplan]/2.;
1355             gMC->Gsposp("UTCP",iCopy+iMCMrow+nMCMrow,cTagV,xpos,ypos,zpos
1356                               ,matrix[2],"ONLY",par,kNpar);
1357           }
1358         }
1359       }
1360       if (fRICHhole) {
1361         sprintf(cTagV,"UU%02d",iDet+2*kNdets);
1362         for (Int_t iMCMrow = 0; iMCMrow < nMCMrow; iMCMrow++) {
1363           xpos   = 0.0;
1364           ypos   = (0.5 + iMCMrow) * ySize - 1.9 
1365                  - fClengthRH[iplan][icham]/2. + fgkHspace/2.;
1366           zpos   = 0.0;                 
1367           if (ypos < (fClengthRH[iplan][icham]/2. - fgkHspace/2.)) {
1368             par[0] = 0.0;
1369             par[1] = 0.3/2.; // Thickness of the cooling pipes
1370             par[2] = fCwidth[iplan]/2.;
1371             gMC->Gsposp("UTCP",iCopy+iMCMrow+2*nMCMrow,cTagV,xpos,ypos,zpos
1372                               ,matrix[2],"ONLY",par,kNpar);
1373           }
1374         }
1375       }
1376     }
1377   }
1378
1379   //
1380   // The power lines
1381   //
1382
1383   // The copper power lines
1384   parTube[0] = 0.0;
1385   parTube[1] = 0.0;
1386   parTube[2] = 0.0;
1387   gMC->Gsvolu("UTPL","TUBE",idtmed[1305-1],parTube,0);
1388
1389   // Position the power lines in the mother volume
1390   for (icham = 0; icham < kNcham;   icham++) {
1391     //for (iplan = 0; iplan < kNplan; iplan++) {
1392     // Take out upper plane until TRD mothervolume is adjusted
1393     for (iplan = 0; iplan < kNplan-1; iplan++) { 
1394       Int_t   iDet    = GetDetectorSec(iplan,icham);
1395       Int_t   iCopy   = GetDetector(iplan,icham,0) * 100;
1396       Int_t   nMCMrow = commonParam->GetRowMax(iplan,icham,0);
1397       Float_t ySize   = (GetChamberLength(iplan,icham) - 2.*fgkRpadW) 
1398                       / ((Float_t) nMCMrow);
1399       sprintf(cTagV,"UU%02d",iDet);
1400       for (Int_t iMCMrow = 0; iMCMrow < nMCMrow; iMCMrow++) {
1401         xpos   = 0.0;
1402         ypos   = (0.5 + iMCMrow) * ySize - 1.0 
1403                - fClength[iplan][icham]/2. + fgkHspace/2.;
1404         zpos   = -0.4 + 0.742/2.;
1405         par[0] = 0.0;
1406         par[1] = 0.2/2.; // Thickness of the power lines
1407         par[2] = fCwidth[iplan]/2.;
1408         gMC->Gsposp("UTPL",iCopy+iMCMrow,cTagV,xpos,ypos,zpos
1409                           ,matrix[2],"ONLY",par,kNpar);
1410       }
1411       if (fPHOShole) {
1412         sprintf(cTagV,"UU%02d",iDet+kNdets);
1413         for (Int_t iMCMrow = 0; iMCMrow < nMCMrow; iMCMrow++) {
1414           xpos   = 0.0;
1415           ypos   = (0.5 + iMCMrow) * ySize - 1.0 
1416                  - fClengthPH[iplan][icham]/2. + fgkHspace/2.;
1417           zpos   = -0.4;                 
1418           if (ypos < (fClengthPH[iplan][icham]/2. - fgkHspace/2.)) {
1419             par[0] = 0.0;
1420             par[1] = 0.2/2.; // Thickness of the power lines
1421             par[2] = fCwidth[iplan]/2.;
1422             gMC->Gsposp("UTPL",iCopy+iMCMrow+nMCMrow,cTagV,xpos,ypos,zpos
1423                               ,matrix[2],"ONLY",par,kNpar);
1424           }
1425         }
1426       }
1427       if (fRICHhole) {
1428         sprintf(cTagV,"UU%02d",iDet+2*kNdets);
1429         for (Int_t iMCMrow = 0; iMCMrow < nMCMrow; iMCMrow++) {
1430           xpos   = 0.0;
1431           ypos   = (0.5 + iMCMrow) * ySize - 1.0 
1432                  - fClengthRH[iplan][icham]/2. + fgkHspace/2.;
1433           zpos   = -0.4;                 
1434           if (ypos < (fClengthRH[iplan][icham]/2. - fgkHspace/2.)) {
1435             par[0] = 0.0;
1436             par[1] = 0.2/2.; // Thickness of the power lines
1437             par[2] = fCwidth[iplan]/2.;
1438             gMC->Gsposp("UTPL",iCopy+iMCMrow+2*nMCMrow,cTagV,xpos,ypos,zpos
1439                               ,matrix[2],"ONLY",par,kNpar);
1440           }
1441         }
1442       }
1443     }
1444   }
1445
1446   //
1447   // The MCMs
1448   //
1449
1450   // The mother volume for the MCMs (air)
1451   const Int_t kNparMCM = 3;
1452   Float_t parMCM[kNparMCM];
1453   parMCM[0] = 3.0/2.;
1454   parMCM[1] = 3.0/2.;
1455   parMCM[2] = 0.14/2.;
1456   gMC->Gsvolu("UMCM","BOX",idtmed[1302-1],parMCM,kNparMCM);
1457
1458   // The MCM carrier G10 layer
1459   parMCM[0] = 3.0/2.;
1460   parMCM[1] = 3.0/2.;
1461   parMCM[2] = 0.1/2.;
1462   gMC->Gsvolu("UMC1","BOX",idtmed[1319-1],parMCM,kNparMCM);
1463   // The MCM carrier Cu layer
1464   parMCM[0] = 3.0/2.;
1465   parMCM[1] = 3.0/2.;
1466   parMCM[2] = 0.0162/2.;
1467   gMC->Gsvolu("UMC2","BOX",idtmed[1318-1],parMCM,kNparMCM);
1468   // The silicon of the chips
1469   parMCM[0] = 3.0/2.;
1470   parMCM[1] = 3.0/2.;
1471   parMCM[2] = 0.003/2.;
1472   gMC->Gsvolu("UMC3","BOX",idtmed[1320-1],parMCM,kNparMCM);
1473
1474   // Put the MCM material inside the MCM mother volume
1475   xpos  =  0.0;
1476   ypos  =  0.0;
1477   zpos  = -0.07      + 0.1/2.;
1478   gMC->Gspos("UMC1",1,"UMCM",xpos,ypos,zpos,0,"ONLY");
1479   zpos +=  0.1/2.    + 0.0162/2.;
1480   gMC->Gspos("UMC2",1,"UMCM",xpos,ypos,zpos,0,"ONLY");
1481   zpos +=  0.00162/2 + 0.003/2.;
1482   gMC->Gspos("UMC3",1,"UMCM",xpos,ypos,zpos,0,"ONLY");
1483
1484   // Position the MCMs in the mother volume
1485   for (icham = 0; icham < kNcham;   icham++) {
1486     //for (iplan = 0; iplan < kNplan; iplan++) {
1487     // Take out upper plane until TRD mothervolume is adjusted
1488     for (iplan = 0; iplan < kNplan-1; iplan++) { 
1489       Int_t   iDet    = GetDetectorSec(iplan,icham);
1490       Int_t   iCopy   = GetDetector(iplan,icham,0) * 1000;
1491       Int_t   nMCMrow = commonParam->GetRowMax(iplan,icham,0);
1492       Float_t ySize   = (GetChamberLength(iplan,icham) - 2.*fgkRpadW) 
1493                       / ((Float_t) nMCMrow);
1494       Int_t   nMCMcol = 8;
1495       Float_t xSize   = (GetChamberWidth(iplan) - 2.* fgkCpadW)
1496                       / ((Float_t) nMCMcol);
1497       sprintf(cTagV,"UU%02d",iDet);
1498       for (Int_t iMCMrow = 0; iMCMrow < nMCMrow; iMCMrow++) {
1499         for (Int_t iMCMcol = 0; iMCMcol < nMCMcol; iMCMcol++) {
1500           xpos   = (0.5 + iMCMcol) * xSize + 1.0 
1501                  - fCwidth[iplan]/2.;
1502           ypos   = (0.5 + iMCMrow) * ySize + 1.0 
1503                  - fClength[iplan][icham]/2. + fgkHspace/2.;
1504           zpos   = -0.4 + 0.742/2.;
1505           par[0] = 0.0;
1506           par[1] = 0.2/2.; // Thickness of the power lines
1507           par[2] = fCwidth[iplan]/2.;
1508           gMC->Gspos("UMCM",iCopy+iMCMrow*10+iMCMcol,cTagV
1509                            ,xpos,ypos,zpos,0,"ONLY");
1510         }
1511       }
1512       if (fPHOShole) {
1513         sprintf(cTagV,"UU%02d",iDet+kNdets);
1514         for (Int_t iMCMrow = 0; iMCMrow < nMCMrow; iMCMrow++) {
1515           for (Int_t iMCMcol = 0; iMCMcol < nMCMcol; iMCMcol++) {
1516             xpos   = (0.5 + iMCMcol) * xSize + 1.0 
1517                    - fCwidth[iplan]/2.;
1518             ypos   = (0.5 + iMCMrow) * ySize + 1.0 
1519                    - fClengthPH[iplan][icham]/2. + fgkHspace/2.;
1520             zpos   = -0.4;
1521             if (ypos < (fClengthPH[iplan][icham]/2. - fgkHspace/2.)) {
1522               par[0] = 0.0;
1523               par[1] = 0.2/2.; // Thickness of the power lines
1524               par[2] = fCwidth[iplan]/2.;
1525               gMC->Gspos("UMCM",iCopy+iMCMrow*10+iMCMcol+10*nMCMrow,cTagV
1526                                ,xpos,ypos,zpos,0,"ONLY");
1527             }
1528           }
1529         }
1530       }
1531       if (fRICHhole) {
1532         sprintf(cTagV,"UU%02d",iDet+2*kNdets);
1533         for (Int_t iMCMrow = 0; iMCMrow < nMCMrow; iMCMrow++) {
1534           for (Int_t iMCMcol = 0; iMCMcol < nMCMcol; iMCMcol++) {
1535             xpos   = (0.5 + iMCMcol) * xSize + 1.0 
1536                    - fCwidth[iplan]/2.;
1537             ypos   = (0.5 + iMCMrow) * ySize + 1.0 
1538                    - fClengthRH[iplan][icham]/2. + fgkHspace/2.;
1539             zpos   = -0.4;
1540             if (ypos < (fClengthRH[iplan][icham]/2. - fgkHspace/2.)) {
1541               par[0] = 0.0;
1542               par[1] = 0.2/2.; // Thickness of the power lines
1543               par[2] = fCwidth[iplan]/2.;
1544               gMC->Gspos("UMCM",iCopy+iMCMrow*10+iMCMcol+20*nMCMrow,cTagV
1545                                ,xpos,ypos,zpos,0,"ONLY");
1546             }
1547           }
1548         }
1549       }
1550
1551     }
1552   }
1553 }
1554
1555 //_____________________________________________________________________________
1556 void AliTRDgeometryFull::GroupChamber(Int_t iplan, Int_t icham, Int_t *idtmed, Bool_t PHOShole, Bool_t RICHhole)
1557 {
1558   //
1559   // Group volumes UA, UD, UF, UU in a single chamber (Air)
1560   // UA, UD, UF, UU are boxes
1561   // UT will be a box
1562   //
1563   // ... for the moment there are no services (UU) for the upper plane !
1564
1565   const Int_t kNparCha = 3;
1566
1567   Int_t iDet = GetDetectorSec(iplan,icham);
1568
1569   if (PHOShole) iDet +=   kNdets;
1570   if (RICHhole) iDet += 2*kNdets;
1571
1572   Float_t xyzMin[3], xyzMax[3];
1573   Float_t xyzOrig[3], xyzBoxd[3];
1574
1575   Char_t  cTagV[5];
1576   Char_t  cTagM[5];
1577
1578   for (Int_t i = 0; i < 3; i++) {
1579     xyzMin[i] = +9999; xyzMax[i] = -9999;
1580   }
1581
1582   for (Int_t i = 0; i < 3; i++) {
1583
1584     xyzMin[i] = TMath::Min(xyzMin[i],fChamberUAorig[iDet][i]-fChamberUAboxd[iDet][i]);
1585     xyzMax[i] = TMath::Max(xyzMax[i],fChamberUAorig[iDet][i]+fChamberUAboxd[iDet][i]);
1586
1587     xyzMin[i] = TMath::Min(xyzMin[i],fChamberUDorig[iDet][i]-fChamberUDboxd[iDet][i]);
1588     xyzMax[i] = TMath::Max(xyzMax[i],fChamberUDorig[iDet][i]+fChamberUDboxd[iDet][i]);
1589
1590     xyzMin[i] = TMath::Min(xyzMin[i],fChamberUForig[iDet][i]-fChamberUFboxd[iDet][i]);
1591     xyzMax[i] = TMath::Max(xyzMax[i],fChamberUForig[iDet][i]+fChamberUFboxd[iDet][i]);
1592
1593     if (iplan < (kNplan-1)) {
1594       xyzMin[i] = TMath::Min(xyzMin[i],fChamberUUorig[iDet][i]-fChamberUUboxd[iDet][i]);
1595       xyzMax[i] = TMath::Max(xyzMax[i],fChamberUUorig[iDet][i]+fChamberUUboxd[iDet][i]);
1596     }
1597
1598     xyzOrig[i] = 0.5*(xyzMax[i]+xyzMin[i]);
1599     xyzBoxd[i] = 0.5*(xyzMax[i]-xyzMin[i]);
1600
1601   }
1602   
1603   sprintf(cTagM,"UT%02d",iDet);
1604
1605   gMC->Gsvolu(cTagM,"BOX ",idtmed[1302-1],xyzBoxd,kNparCha);
1606
1607   sprintf(cTagV,"UA%02d",iDet);
1608   gMC->Gspos(cTagV,1,cTagM,
1609              fChamberUAorig[iDet][0]-xyzOrig[0],
1610              fChamberUAorig[iDet][1]-xyzOrig[1],
1611              fChamberUAorig[iDet][2]-xyzOrig[2],
1612              0,"ONLY");
1613
1614   sprintf(cTagV,"UD%02d",iDet);
1615   gMC->Gspos(cTagV,1,cTagM,
1616              fChamberUDorig[iDet][0]-xyzOrig[0],
1617              fChamberUDorig[iDet][1]-xyzOrig[1],
1618              fChamberUDorig[iDet][2]-xyzOrig[2],
1619              0,"ONLY");
1620
1621   sprintf(cTagV,"UF%02d",iDet);
1622   gMC->Gspos(cTagV,1,cTagM,
1623              fChamberUForig[iDet][0]-xyzOrig[0],
1624              fChamberUForig[iDet][1]-xyzOrig[1],
1625              fChamberUForig[iDet][2]-xyzOrig[2],
1626              0,"ONLY");
1627   
1628   if (iplan < (kNplan-1)) {
1629     sprintf(cTagV,"UU%02d",iDet);
1630     gMC->Gspos(cTagV,1,cTagM,
1631                fChamberUUorig[iDet][0]-xyzOrig[0],
1632                fChamberUUorig[iDet][1]-xyzOrig[1],
1633                fChamberUUorig[iDet][2]-xyzOrig[2],
1634                0,"ONLY");
1635
1636   }
1637
1638   sprintf(cTagV,"UT%02d",iDet);
1639
1640   if (!PHOShole && !RICHhole) {
1641     gMC->Gspos(cTagV,1,"UTI1",xyzOrig[0],xyzOrig[1],xyzOrig[2],0,"ONLY");
1642   }
1643
1644   if (PHOShole) {
1645     gMC->Gspos(cTagV,1,"UTI2",xyzOrig[0],xyzOrig[1],xyzOrig[2],0,"ONLY");
1646   }
1647
1648   if (RICHhole) {
1649     gMC->Gspos(cTagV,1,"UTI3",xyzOrig[0],xyzOrig[1],xyzOrig[2],0,"ONLY");
1650   }
1651
1652 }
1653
1654