]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONSlatGeometryBuilder.cxx
49382dc969e80ebb3f93c7224ff6286e51f58faa
[u/mrichter/AliRoot.git] / MUON / AliMUONSlatGeometryBuilder.cxx
1 // $Id$
2 //
3 // Class AliMUONSlatGeometryBuilder
4 // -------------------------------
5 // Abstract base class for geometry construction per chamber.
6 //
7 // Author: Eric Dumonteil
8
9 #include <TVirtualMC.h>
10 #include <TArrayI.h>
11 #include <TGeoMatrix.h>
12 #include "AliRun.h"
13
14 #include "AliMUONSlatGeometryBuilder.h"
15 #include "AliMUON.h"
16 #include "AliMUONChamber.h"
17 #include "AliMUONChamberGeometry.h"
18
19 ClassImp(AliMUONSlatGeometryBuilder)
20
21     Int_t   ConvertSlatNum(Int_t numslat, Int_t quadnum, Int_t fspq);
22
23
24
25 //______________________________________________________________________________
26 AliMUONSlatGeometryBuilder::AliMUONSlatGeometryBuilder(AliMUON* muon)
27  : AliMUONVGeometryBuilder(&muon->Chamber(4), &muon->Chamber(5), &muon->Chamber(6), &muon->Chamber(7), &muon->Chamber(8), &muon->Chamber(9)),
28 //  : AliMUONVGeometryBuilder(&muon->Chamber(4), &muon->Chamber(5)),
29    fMUON(muon)
30 {
31 // Standard constructor
32
33 }
34
35 //______________________________________________________________________________
36 AliMUONSlatGeometryBuilder::AliMUONSlatGeometryBuilder() 
37  : AliMUONVGeometryBuilder(),
38    fMUON(0)
39 {
40 // Default constructor
41 }
42
43
44 //______________________________________________________________________________
45 AliMUONSlatGeometryBuilder::AliMUONSlatGeometryBuilder(const AliMUONSlatGeometryBuilder& rhs)
46   : AliMUONVGeometryBuilder(rhs)
47 {
48   Fatal("Copy constructor", 
49         "Copy constructor is not implemented.");
50 }
51
52 //______________________________________________________________________________
53 AliMUONSlatGeometryBuilder::~AliMUONSlatGeometryBuilder() {
54 //
55 }
56
57 //______________________________________________________________________________
58 AliMUONSlatGeometryBuilder& 
59 AliMUONSlatGeometryBuilder::operator = (const AliMUONSlatGeometryBuilder& rhs) 
60 {
61   // check assignement to self
62   if (this == &rhs) return *this;
63
64   Fatal("operator=", 
65         "Assignment operator is not implemented.");
66     
67   return *this;  
68 }
69
70 //
71 // public methods
72 //
73
74 //______________________________________________________________________________
75 void AliMUONSlatGeometryBuilder::CreateGeometry()
76 {
77  
78      Int_t *idtmed = fMUON->GetIdtmed()->GetArray()-1099;
79
80      Float_t angle;
81      Float_t *dum=0;
82
83       // define the id of tracking media:
84      Int_t idCopper = idtmed[1110];
85      Int_t idGlass  = idtmed[1111];
86      Int_t idCarbon = idtmed[1112];
87      Int_t idRoha   = idtmed[1113];
88      Int_t idGas=idtmed[1108]; // medium 9 = Ar-CO2 gas (80%+20%)
89      Int_t idAir= idtmed[1100]; // medium 1
90
91       // sensitive area: 40*40 cm**2
92      const Float_t sensLength = 40.; 
93      const Float_t sensHeight = 40.; 
94      const Float_t sensWidth  = 0.5; // according to TDR fig 2.120 
95      const Int_t sensMaterial = idGas;
96      const Float_t yOverlap   = 1.5; 
97
98      // PCB dimensions in cm; width: 30 mum copper   
99      const Float_t pcbLength  = sensLength; 
100      const Float_t pcbHeight  = 60.; 
101      const Float_t pcbWidth   = 0.003;   
102      const Int_t pcbMaterial  = idCopper;
103
104      // Insulating material: 200 mum glass fiber glued to pcb  
105      const Float_t insuLength = pcbLength; 
106      const Float_t insuHeight = pcbHeight; 
107      const Float_t insuWidth  = 0.020;   
108      const Int_t insuMaterial = idGlass;
109
110      // Carbon fiber panels: 200mum carbon/epoxy skin   
111      const Float_t panelLength = sensLength; 
112      const Float_t panelHeight = sensHeight; 
113      const Float_t panelWidth  = 0.020;      
114      const Int_t panelMaterial = idCarbon;
115
116      // rohacell between the two carbon panels   
117      const Float_t rohaLength = sensLength; 
118      const Float_t rohaHeight = sensHeight; 
119      const Float_t rohaWidth  = 0.5;
120      const Int_t rohaMaterial = idRoha;
121
122      // Frame around the slat: 2 sticks along length,2 along height  
123      // H: the horizontal ones 
124      const Float_t hFrameLength = pcbLength; 
125      const Float_t hFrameHeight = 1.5; 
126      const Float_t hFrameWidth  = sensWidth; 
127      const Int_t hFrameMaterial = idGlass;
128
129      // V: the vertical ones 
130      const Float_t vFrameLength = 4.0; 
131      const Float_t vFrameHeight = sensHeight + hFrameHeight; 
132      const Float_t vFrameWidth  = sensWidth;
133      const Int_t vFrameMaterial = idGlass;
134
135      // B: the horizontal border filled with rohacell 
136      const Float_t bFrameLength = hFrameLength; 
137      const Float_t bFrameHeight = (pcbHeight - sensHeight)/2. - hFrameHeight; 
138      const Float_t bFrameWidth  = hFrameWidth;
139      const Int_t bFrameMaterial = idRoha;
140
141      // NULOC: 30 mum copper + 200 mum vetronite (same radiation length as 14mum copper)
142      const Float_t nulocLength = 2.5; 
143      const Float_t nulocHeight = 7.5; 
144      const Float_t nulocWidth  = 0.0030 + 0.0014; // equivalent copper width of vetronite; 
145      const Int_t   nulocMaterial = idCopper;
146
147      const Float_t slatHeight = pcbHeight; 
148      const Float_t slatWidth = sensWidth + 2.*(pcbWidth + insuWidth + 
149                                                2.* panelWidth + rohaWidth);
150      const Int_t slatMaterial = idAir;
151      const Float_t dSlatLength = vFrameLength; // border on left and right 
152
153      Float_t spar[3];  
154      Int_t i, j;
155
156      // the panel volume contains the rohacell
157
158      Float_t twidth = 2 * panelWidth + rohaWidth; 
159      Float_t panelpar[3] = { panelLength/2., panelHeight/2., twidth/2. }; 
160      Float_t rohapar[3] = { rohaLength/2., rohaHeight/2., rohaWidth/2. }; 
161
162      // insulating material contains PCB-> gas-> 2 borders filled with rohacell
163
164      twidth = 2*(insuWidth + pcbWidth) + sensWidth;  
165      Float_t insupar[3] = { insuLength/2., insuHeight/2., twidth/2. }; 
166      twidth -= 2 * insuWidth; 
167      Float_t pcbpar[3] = { pcbLength/2., pcbHeight/2., twidth/2. }; 
168      Float_t senspar[3] = { sensLength/2., sensHeight/2., sensWidth/2. }; 
169      Float_t theight = 2*hFrameHeight + sensHeight;
170      Float_t hFramepar[3]={hFrameLength/2., theight/2., hFrameWidth/2.}; 
171      Float_t bFramepar[3]={bFrameLength/2., bFrameHeight/2., bFrameWidth/2.}; 
172      Float_t vFramepar[3]={vFrameLength/2., vFrameHeight/2., vFrameWidth/2.};
173      Float_t nulocpar[3]={nulocLength/2., nulocHeight/2., nulocWidth/2.}; 
174      Float_t xx;
175      Float_t xxmax = (bFrameLength - nulocLength)/2.; 
176      Int_t index=0;
177       
178     AliMUONChamber *iChamber, *iChamber1, *iChamber2;
179
180     Int_t* fStations = new Int_t[5];
181     for (Int_t i=0; i<5; i++) fStations[i] = 1;
182
183     if (fStations[2])
184     {
185         
186 //********************************************************************
187 //                            Station 3                             **
188 //********************************************************************
189      // indices 1 and 2 for first and second chambers in the station
190      // iChamber (first chamber) kept for other quanties than Z,
191      // assumed to be the same in both chambers
192
193      iChamber = GetChamber(4);
194      iChamber1 = iChamber;
195      iChamber2 = GetChamber(5);
196      
197      iChamber1->GetGeometry()->SetDebug(kTRUE);
198      //iChamber2->GetGeometry()->SetDebug(kTRUE);
199
200      if (gAlice->GetModule("DIPO")) {
201        // if DIPO is preset, the whole station will be placed in DDIP volume
202        iChamber1->GetGeometry()->SetMotherVolume("DDIP");
203        iChamber2->GetGeometry()->SetMotherVolume("DDIP");
204      }
205
206 //      if (gAlice->GetModule("DIPO")) {
207 //        slats5Mother="DDIP";
208 //        slats6Mother="DDIP";
209
210 //        zoffs5 = zpos1;
211 //        zoffs6 = zpos2;
212 //      }
213 //      else {
214 //        gMC->Gsvolu("S05M", "TUBE", idAir, tpar, 3);
215 //        gMC->Gsvolu("S06M", "TUBE", idAir, tpar, 3);
216 //        gMC->Gspos("S05M", 1, "ALIC", 0., 0., zpos1 , 0, "ONLY");
217
218 //        gMC->Gspos("S06M", 1, "ALIC", 0., 0., zpos2 , 0, "ONLY");
219 //      }
220
221      // volumes for slat geometry (xx=5,..,10 chamber id): 
222      // Sxx0 Sxx1 Sxx2 Sxx3  -->   Slat Mother volumes 
223      // SxxG                          -->   Sensitive volume (gas)
224      // SxxP                          -->   PCB (copper) 
225      // SxxI                          -->   Insulator (vetronite) 
226      // SxxC                          -->   Carbon panel 
227      // SxxR                          -->   Rohacell
228      // SxxH, SxxV                    -->   Horizontal and Vertical frames (vetronite)
229      // SB5x                          -->   Volumes for the 35 cm long PCB
230      // slat dimensions: slat is a MOTHER volume!!! made of air
231
232      // only for chamber 5: slat 1 has a PCB shorter by 5cm!
233
234      Float_t tlength = 35.;
235      Float_t panelpar2[3]  = { tlength/2., panelpar[1],  panelpar[2]}; 
236      Float_t rohapar2[3]   = { tlength/2., rohapar[1],   rohapar[2]}; 
237      Float_t insupar2[3]   = { tlength/2., insupar[1],   insupar[2]}; 
238      Float_t pcbpar2[3]    = { tlength/2., pcbpar[1],    pcbpar[2]}; 
239      Float_t senspar2[3]   = { tlength/2., senspar[1],   senspar[2]}; 
240      Float_t hFramepar2[3] = { tlength/2., hFramepar[1], hFramepar[2]}; 
241      Float_t bFramepar2[3] = { tlength/2., bFramepar[1], bFramepar[2]}; 
242      Float_t *dum=0;
243
244      const Int_t nSlats3 = 5;  // number of slats per quadrant
245      const Int_t nPCB3[nSlats3] = {3,4,4,3,2}; // n PCB per slat
246      const Float_t xpos3[nSlats3] = {31., 0., 0., 0., 0.};
247      Float_t slatLength3[nSlats3]; 
248
249      // create and position the slat (mother) volumes 
250
251 //      char volNam5[5];
252 //      char volNam6[5];
253      char idSlatCh5[5];
254      char idSlatCh6[5];
255      Float_t xSlat3;
256      Float_t angle = 0.;
257      
258      Float_t spar2[3];
259      for (i = 0; i<nSlats3; i++){
260        slatLength3[i] = pcbLength * nPCB3[i] + 2. * dSlatLength; 
261        xSlat3 = slatLength3[i]/2. - vFrameLength/2. + xpos3[i]; 
262        if (i==1 || i==0) slatLength3[i] -=  2. *dSlatLength; // frame out in PCB with circular border 
263        Float_t ySlat31 =  sensHeight * i - yOverlap * i; 
264        Float_t ySlat32 = -sensHeight * i + yOverlap * i; 
265        spar[0] = slatLength3[i]/2.; 
266        spar[1] = slatHeight/2.;
267        spar[2] = slatWidth/2. * 1.01; 
268        // take away 5 cm from the first slat in chamber 5
269        Float_t xSlat32 = 0;
270        if (i==1 || i==2) { // 1 pcb is shortened by 5cm
271          spar2[0] = spar[0]-5./2.;
272          xSlat32 = xSlat3 - 5/2.;
273        }
274        else {
275          spar2[0] = spar[0];
276          xSlat32 = xSlat3;
277        }
278        spar2[1] = spar[1];
279        spar2[2] = spar[2]; 
280        Float_t dzCh3=spar[2] * 1.01;
281        // zSlat to be checked (odd downstream or upstream?)
282        Float_t zSlat = (i%2 ==0)? -spar[2] : spar[2]; 
283 //        sprintf(volNam5,"S05%d",i);
284 //        gMC->Gsvolu(volNam5,"BOX",slatMaterial,spar2,3);
285 //        gMC->Gspos(volNam5, i*4+1,slats5Mother, xSlat32, ySlat31, zoffs5+zSlat+2.*dzCh3, 0, "ONLY");
286 //        gMC->Gspos(volNam5, i*4+2,slats5Mother,-xSlat32, ySlat31, zoffs5+zSlat-2.*dzCh3, 0, "ONLY");
287
288        sprintf(idSlatCh5,"LA%d",nSlats3-1+i);
289        gMC->Gsvolu(idSlatCh5,"BOX",slatMaterial,spar2,3);
290        GetChamber(4)->GetGeometry()->AddEnvelope(idSlatCh5, true, TGeoTranslation(xSlat32, ySlat31, zSlat+2.*dzCh3) ,TGeoRotation("rot1",90,angle,90,90+angle,0,0)
291            );
292
293        sprintf(idSlatCh5,"LA%d",3*nSlats3-2+i);
294        gMC->Gsvolu(idSlatCh5,"BOX",slatMaterial,spar2,3);
295        GetChamber(4)->GetGeometry()->AddEnvelope(idSlatCh5, true, TGeoTranslation(-xSlat32, ySlat31, zSlat-2.*dzCh3) ,TGeoRotation("rot2",90,180+angle,90,90+angle,180,0)
296            );
297
298        if (i>0) { 
299
300        sprintf(idSlatCh5,"LA%d",nSlats3-1-i);
301        gMC->Gsvolu(idSlatCh5,"BOX",slatMaterial,spar2,3);
302        GetChamber(4)->GetGeometry()->AddEnvelope(idSlatCh5, true, TGeoTranslation(xSlat32, ySlat32, zSlat+2.*dzCh3) ,TGeoRotation("rot3",90,angle,90,270+angle,180,0)
303            );
304
305        sprintf(idSlatCh5,"LA%d",3*nSlats3-2-i);
306        gMC->Gsvolu(idSlatCh5,"BOX",slatMaterial,spar2,3);
307        GetChamber(4)->GetGeometry()->AddEnvelope(idSlatCh5, true, TGeoTranslation(-xSlat32, ySlat32, zSlat-2.*dzCh3) ,TGeoRotation("rot4",90,180+angle,90,270+angle,0,0)
308            );
309        }
310
311        sprintf(idSlatCh6,"LB%d",nSlats3-1+i);       
312        gMC->Gsvolu(idSlatCh6,"BOX",slatMaterial,spar2,3);
313        GetChamber(5)->GetGeometry()->AddEnvelope(idSlatCh6, true, TGeoTranslation(xSlat3, ySlat31, zSlat+2.*dzCh3) ,TGeoRotation("rot5",90,angle,90,90+angle,0,0)
314            );
315        sprintf(idSlatCh6,"LB%d",3*nSlats3-2+i);
316        gMC->Gsvolu(idSlatCh6,"BOX",slatMaterial,spar2,3);
317        GetChamber(5)->GetGeometry()->AddEnvelope(idSlatCh6, true, TGeoTranslation(-xSlat3, ySlat31, zSlat-2.*dzCh3) ,TGeoRotation("rot6",90,180+angle,90,90+angle,180,0)
318            );
319
320      if (i>0) { 
321        sprintf(idSlatCh6,"LB%d",nSlats3-1-i);
322        gMC->Gsvolu(idSlatCh6,"BOX",slatMaterial,spar2,3);
323        GetChamber(5)->GetGeometry()->AddEnvelope(idSlatCh6, true, TGeoTranslation(xSlat3, ySlat32, zSlat+2.*dzCh3) ,TGeoRotation("rot7",90,angle,90,270+angle,180,0)
324            );
325
326        sprintf(idSlatCh6,"LB%d",3*nSlats3-2-i);
327        gMC->Gsvolu(idSlatCh6,"BOX",slatMaterial,spar2,3);
328        GetChamber(5)->GetGeometry()->AddEnvelope(idSlatCh6, true, TGeoTranslation(-xSlat3, ySlat32, zSlat-2.*dzCh3) ,TGeoRotation("rot8",90,180+angle,90,270+angle,0,0)
329            );
330       }
331          }
332      
333      // create the panel volume 
334  
335      gMC->Gsvolu("S05C","BOX",panelMaterial,panelpar,3);
336      gMC->Gsvolu("SB5C","BOX",panelMaterial,panelpar2,3);
337      gMC->Gsvolu("S06C","BOX",panelMaterial,panelpar,3);
338
339      // create the rohacell volume 
340
341      gMC->Gsvolu("S05R","BOX",rohaMaterial,rohapar,3);
342      gMC->Gsvolu("SB5R","BOX",rohaMaterial,rohapar2,3);
343      gMC->Gsvolu("S06R","BOX",rohaMaterial,rohapar,3);
344
345      // create the insulating material volume 
346
347      gMC->Gsvolu("S05I","BOX",insuMaterial,insupar,3);
348      gMC->Gsvolu("SB5I","BOX",insuMaterial,insupar2,3);
349      gMC->Gsvolu("S06I","BOX",insuMaterial,insupar,3);
350
351      // create the PCB volume 
352
353      gMC->Gsvolu("S05P","BOX",pcbMaterial,pcbpar,3);
354      gMC->Gsvolu("SB5P","BOX",pcbMaterial,pcbpar2,3);
355      gMC->Gsvolu("S06P","BOX",pcbMaterial,pcbpar,3);
356  
357      // create the sensitive volumes,
358      gMC->Gsvolu("S05G","BOX",sensMaterial,dum,0);
359      gMC->Gsvolu("S06G","BOX",sensMaterial,dum,0);
360
361
362      // create the vertical frame volume 
363
364      gMC->Gsvolu("S05V","BOX",vFrameMaterial,vFramepar,3);
365      gMC->Gsvolu("S06V","BOX",vFrameMaterial,vFramepar,3);
366
367      // create the horizontal frame volume 
368
369
370      gMC->Gsvolu("S05H","BOX",hFrameMaterial,hFramepar,3);
371      gMC->Gsvolu("SB5H","BOX",hFrameMaterial,hFramepar2,3);
372      gMC->Gsvolu("S06H","BOX",hFrameMaterial,hFramepar,3);
373
374      // create the horizontal border volume 
375
376      gMC->Gsvolu("S05B","BOX",bFrameMaterial,bFramepar,3);
377      gMC->Gsvolu("SB5B","BOX",bFrameMaterial,bFramepar2,3);
378      gMC->Gsvolu("S06B","BOX",bFrameMaterial,bFramepar,3);
379
380      index=0; 
381      for (i = 0; i<nSlats3; i++){
382          for (Int_t quadrant=1; quadrant<=4; quadrant++) {
383
384              if (i==0&&quadrant==2) continue;
385              if (i==0&&quadrant==4) continue;
386
387        sprintf(idSlatCh5,"LA%d",ConvertSlatNum(i,quadrant,4));
388        sprintf(idSlatCh6,"LB%d",ConvertSlatNum(i,quadrant,4));
389        Float_t xvFrame  = (slatLength3[i] - vFrameLength)/2.;
390        Float_t xvFrame2  = xvFrame;
391
392        if ( i==1 || i ==2 ) xvFrame2 -= 5./2.;
393
394        // position the vertical frames 
395        if (i!=1 && i!=0) { 
396        GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("S05V", idSlatCh5, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame2,0.,0.));
397        GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("S05V", idSlatCh5, (2*i)*10+quadrant,TGeoTranslation(-xvFrame2,0.,0.));
398        GetChamber(5)->GetGeometry()->AddEnvelopeConstituent("S06V", idSlatCh6, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
399        GetChamber(5)->GetGeometry()->AddEnvelopeConstituent("S06V", idSlatCh6, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
400
401        }       
402        // position the panels and the insulating material 
403        for (j=0; j<nPCB3[i]; j++){
404          if (i==1&&j==0) continue;
405          index++;
406          Float_t xx = sensLength * (-nPCB3[i]/2.+j+.5); 
407          Float_t xx2 = xx + 5/2.; 
408          
409          Float_t zPanel = spar[2] - panelpar[2]; 
410          if ( (i==1 || i==2) && j == nPCB3[i]-1) { // 1 pcb is shortened by 5cm 
411        GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("SB5C", idSlatCh5, 2*index-1,TGeoTranslation(xx,0.,zPanel));
412        GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("SB5C", idSlatCh5, 2*index,TGeoTranslation(xx,0.,-zPanel));
413        GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("SB5I", idSlatCh5, index,TGeoTranslation(xx,0.,0.));
414          }
415          else if ( (i==1 || i==2) && j < nPCB3[i]-1) {
416        GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("S05C", idSlatCh5, 2*index-1,TGeoTranslation(xx2,0.,zPanel));
417        GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("S05C", idSlatCh5, 2*index,TGeoTranslation(xx2,0.,-zPanel));
418        GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("S05I", idSlatCh5, index,TGeoTranslation(xx2,0.,0.));
419          }
420          else {
421        GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("S05C", idSlatCh5, 2*index-1,TGeoTranslation(xx,0.,zPanel));
422        GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("S05C", idSlatCh5, 2*index,TGeoTranslation(xx,0.,-zPanel));
423        GetChamber(4)->GetGeometry()->AddEnvelopeConstituent("S05I", idSlatCh5, index,TGeoTranslation(xx,0.,0.));
424          }
425        GetChamber(5)->GetGeometry()->AddEnvelopeConstituent("S06C", idSlatCh6, 2*index-1,TGeoTranslation(xx,0.,zPanel));
426        GetChamber(5)->GetGeometry()->AddEnvelopeConstituent("S06C", idSlatCh6, 2*index,TGeoTranslation(xx,0.,-zPanel));
427        GetChamber(5)->GetGeometry()->AddEnvelopeConstituent("S06I", idSlatCh6, index,TGeoTranslation(xx,0.,0.));
428  
429        } 
430          }
431      }
432      
433      // position the rohacell volume inside the panel volume
434      gMC->Gspos("S05R",1,"S05C",0.,0.,0.,0,"ONLY"); 
435      gMC->Gspos("SB5R",1,"SB5C",0.,0.,0.,0,"ONLY"); 
436      gMC->Gspos("S06R",1,"S06C",0.,0.,0.,0,"ONLY"); 
437
438      // position the PCB volume inside the insulating material volume
439      gMC->Gspos("S05P",1,"S05I",0.,0.,0.,0,"ONLY"); 
440      gMC->Gspos("SB5P",1,"SB5I",0.,0.,0.,0,"ONLY"); 
441      gMC->Gspos("S06P",1,"S06I",0.,0.,0.,0,"ONLY"); 
442      // position the horizontal frame volume inside the PCB volume
443      gMC->Gspos("S05H",1,"S05P",0.,0.,0.,0,"ONLY"); 
444      gMC->Gspos("SB5H",1,"SB5P",0.,0.,0.,0,"ONLY"); 
445      gMC->Gspos("S06H",1,"S06P",0.,0.,0.,0,"ONLY"); 
446      // position the sensitive volume inside the horizontal frame volume
447      gMC->Gsposp("S05G",1,"S05H",0.,0.,0.,0,"ONLY",senspar,3); 
448      gMC->Gsposp("S05G",1,"SB5H",0.,0.,0.,0,"ONLY",senspar2,3); 
449      gMC->Gsposp("S06G",1,"S06H",0.,0.,0.,0,"ONLY",senspar,3); 
450      // position the border volumes inside the PCB volume
451      Float_t yborder = ( pcbHeight - bFrameHeight ) / 2.; 
452      gMC->Gspos("S05B",1,"S05P",0., yborder,0.,0,"ONLY"); 
453      gMC->Gspos("S05B",2,"S05P",0.,-yborder,0.,0,"ONLY"); 
454      gMC->Gspos("SB5B",1,"SB5P",0., yborder,0.,0,"ONLY"); 
455      gMC->Gspos("SB5B",2,"SB5P",0.,-yborder,0.,0,"ONLY"); 
456      gMC->Gspos("S06B",1,"S06P",0., yborder,0.,0,"ONLY"); 
457      gMC->Gspos("S06B",2,"S06P",0.,-yborder,0.,0,"ONLY"); 
458
459      // create the NULOC volume and position it in the horizontal frame
460
461      gMC->Gsvolu("S05N","BOX",nulocMaterial,nulocpar,3);
462      gMC->Gsvolu("S06N","BOX",nulocMaterial,nulocpar,3);
463      index = 0;
464      Float_t xxmax2 = xxmax - 5./2.;
465      for (xx = -xxmax; xx<=xxmax; xx+=2*nulocLength) { 
466        index++; 
467        gMC->Gspos("S05N",2*index-1,"S05B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
468        gMC->Gspos("S05N",2*index  ,"S05B", xx, 0., bFrameWidth/4., 0, "ONLY");
469        if (xx > -xxmax2 && xx< xxmax2) {
470          gMC->Gspos("S05N",2*index-1,"SB5B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
471          gMC->Gspos("S05N",2*index  ,"SB5B", xx, 0., bFrameWidth/4., 0, "ONLY");
472        }
473        gMC->Gspos("S06N",2*index-1,"S06B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
474        gMC->Gspos("S06N",2*index  ,"S06B", xx, 0., bFrameWidth/4., 0, "ONLY");
475      }
476
477      // position the volumes approximating the circular section of the pipe
478      Float_t yoffs = sensHeight/2.-yOverlap; 
479      Float_t epsilon = 0.001; 
480      Int_t ndiv=6;
481      Double_t divpar[3];
482      Double_t dydiv= sensHeight/ndiv;
483      Double_t ydiv = yoffs -dydiv;
484      Int_t imax=0; 
485      imax = 1; 
486      Float_t rmin = 33.; 
487      for (Int_t idiv=0;idiv<ndiv; idiv++){ 
488        ydiv+= dydiv;
489        Float_t xdiv = 0.; 
490        if (ydiv<rmin) xdiv= rmin * TMath::Sin( TMath::ACos(ydiv/rmin) );
491        divpar[0] = (pcbLength-xdiv)/2.; 
492        divpar[1] = dydiv/2. - epsilon;
493        divpar[2] = sensWidth/2.; 
494        Float_t xvol=(pcbLength+xdiv)/2.;
495        Float_t yvol=ydiv + dydiv/2.; 
496
497        for (Int_t quadrant=1; quadrant<=4; quadrant++)
498        {
499            sprintf(idSlatCh5,"LA%d",ConvertSlatNum(1,quadrant,4));
500            sprintf(idSlatCh6,"LB%d",ConvertSlatNum(1,quadrant,4));
501            
502        GetChamber(4)->GetGeometry()->AddEnvelopeConstituentParam("S05G", idSlatCh5, quadrant*100+imax+4*idiv+1,TGeoTranslation(xvol-(pcbLength * (nPCB3[1]-1)/2. + 35./2.),yvol-pcbLength+yOverlap,0.),3,divpar);
503        GetChamber(5)->GetGeometry()->AddEnvelopeConstituentParam("S06G", idSlatCh6,  quadrant*100+imax+4*idiv+1,TGeoTranslation(xvol-pcbLength * nPCB3[1]/2.,yvol-pcbLength+yOverlap,0.),3,divpar);
504        }
505        
506      }
507      cout << "Geometry for Station 3...... done" << endl;
508     }
509     
510     if (fStations[3]) {
511
512
513 // //********************************************************************
514 // //                            Station 4                             **
515 // //********************************************************************
516 //      // indices 1 and 2 for first and second chambers in the station
517 //      // iChamber (first chamber) kept for other quanties than Z,
518 //      // assumed to be the same in both chambers
519  
520      iChamber = GetChamber(6);
521      iChamber1 = iChamber;
522      iChamber2 = GetChamber(7);
523
524      const Int_t nSlats4 = 6;  // number of slats per quadrant
525      const Int_t nPCB4[nSlats4] = {4,4,5,5,4,3}; // n PCB per slat
526      const Float_t xpos4[nSlats4] = {38.5, 40., 0., 0., 0., 0.};
527      Float_t slatLength4[nSlats4];     
528
529 //      // create and position the slat (mother) volumes 
530
531      char idSlatCh7[5];
532      char idSlatCh8[5];
533      Float_t xSlat4;
534      Float_t ySlat4;
535      angle = 0.;
536
537      for (i = 0; i<nSlats4; i++){
538        slatLength4[i] = pcbLength * nPCB4[i] + 2. * dSlatLength; 
539        xSlat4 = slatLength4[i]/2. - vFrameLength/2. + xpos4[i]; 
540        if (i==1) slatLength4[i] -=  2. *dSlatLength; // frame out in PCB with circular border 
541        ySlat4 =  sensHeight * i - yOverlap *i;
542        
543        spar[0] = slatLength4[i]/2.; 
544        spar[1] = slatHeight/2.;
545        spar[2] = slatWidth/2.*1.01; 
546        Float_t dzCh4=spar[2]*1.01;
547        // zSlat to be checked (odd downstream or upstream?)
548        Float_t zSlat = (i%2 ==0)? spar[2] : -spar[2]; 
549
550        sprintf(idSlatCh7,"LC%d",nSlats4-1+i);
551        gMC->Gsvolu(idSlatCh7,"BOX",slatMaterial,spar,3);
552        GetChamber(6)->GetGeometry()->AddEnvelope(idSlatCh7, true, TGeoTranslation(xSlat4, ySlat4, zSlat+2.*dzCh4));
553
554        sprintf(idSlatCh7,"LC%d",3*nSlats4-2+i);
555        gMC->Gsvolu(idSlatCh7,"BOX",slatMaterial,spar,3);
556        GetChamber(6)->GetGeometry()->AddEnvelope(idSlatCh7, true, TGeoTranslation(-xSlat4, ySlat4, zSlat-2.*dzCh4));
557  
558        if (i>0) { 
559
560        sprintf(idSlatCh7,"LC%d",nSlats4-1-i);
561        gMC->Gsvolu(idSlatCh7,"BOX",slatMaterial,spar,3);
562        GetChamber(6)->GetGeometry()->AddEnvelope(idSlatCh7, true, TGeoTranslation(xSlat4, -ySlat4, zSlat+2.*dzCh4) ,TGeoRotation("rot3",90,angle,90,270+angle,180,0)
563            );
564
565        sprintf(idSlatCh7,"LC%d",3*nSlats4-2-i);
566        gMC->Gsvolu(idSlatCh7,"BOX",slatMaterial,spar,3);
567        GetChamber(6)->GetGeometry()->AddEnvelope(idSlatCh7, true, TGeoTranslation(-xSlat4, -ySlat4, zSlat-2.*dzCh4) ,TGeoRotation("rot3",90,angle,90,270+angle,180,0)
568            );
569        }
570
571        sprintf(idSlatCh8,"LD%d",nSlats4-1+i);
572        gMC->Gsvolu(idSlatCh8,"BOX",slatMaterial,spar,3);
573        GetChamber(7)->GetGeometry()->AddEnvelope(idSlatCh8, true, TGeoTranslation(xSlat4, ySlat4, zSlat+2.*dzCh4) ,TGeoRotation("rot5",90,angle,90,90+angle,0,0)
574            );
575        sprintf(idSlatCh8,"LD%d",3*nSlats4-2+i);
576        gMC->Gsvolu(idSlatCh8,"BOX",slatMaterial,spar,3);
577        GetChamber(7)->GetGeometry()->AddEnvelope(idSlatCh8, true, TGeoTranslation(-xSlat4, ySlat4, zSlat-2.*dzCh4) ,TGeoRotation("rot6",90,180+angle,90,90+angle,180,0)
578            );
579        if (i>0) { 
580        sprintf(idSlatCh8,"LD%d",nSlats4-1-i);
581        gMC->Gsvolu(idSlatCh8,"BOX",slatMaterial,spar,3);
582        GetChamber(7)->GetGeometry()->AddEnvelope(idSlatCh8, true, TGeoTranslation(xSlat4, -ySlat4, zSlat+2.*dzCh4) ,TGeoRotation("rot7",90,angle,90,270+angle,180,0)
583            );
584        sprintf(idSlatCh8,"LD%d",3*nSlats4-2-i);
585        gMC->Gsvolu(idSlatCh8,"BOX",slatMaterial,spar,3);
586        GetChamber(7)->GetGeometry()->AddEnvelope(idSlatCh8, true, TGeoTranslation(-xSlat4, -ySlat4, zSlat-2.*dzCh4) ,TGeoRotation("rot8",90,180+angle,90,270+angle,0,0)
587                                                  );
588        }
589      }
590      
591
592      // create the panel volume 
593  
594      gMC->Gsvolu("S07C","BOX",panelMaterial,panelpar,3);
595      gMC->Gsvolu("S08C","BOX",panelMaterial,panelpar,3);
596
597      // create the rohacell volume 
598
599      gMC->Gsvolu("S07R","BOX",rohaMaterial,rohapar,3);
600      gMC->Gsvolu("S08R","BOX",rohaMaterial,rohapar,3);
601
602      // create the insulating material volume 
603
604      gMC->Gsvolu("S07I","BOX",insuMaterial,insupar,3);
605      gMC->Gsvolu("S08I","BOX",insuMaterial,insupar,3);
606
607      // create the PCB volume 
608
609      gMC->Gsvolu("S07P","BOX",pcbMaterial,pcbpar,3);
610      gMC->Gsvolu("S08P","BOX",pcbMaterial,pcbpar,3);
611  
612      // create the sensitive volumes,
613
614      gMC->Gsvolu("S07G","BOX",sensMaterial,dum,0);
615      gMC->Gsvolu("S08G","BOX",sensMaterial,dum,0);
616
617      // create the vertical frame volume 
618
619      gMC->Gsvolu("S07V","BOX",vFrameMaterial,vFramepar,3);
620      gMC->Gsvolu("S08V","BOX",vFrameMaterial,vFramepar,3);
621
622      // create the horizontal frame volume 
623
624      gMC->Gsvolu("S07H","BOX",hFrameMaterial,hFramepar,3);
625      gMC->Gsvolu("S08H","BOX",hFrameMaterial,hFramepar,3);
626
627      // create the horizontal border volume 
628
629      gMC->Gsvolu("S07B","BOX",bFrameMaterial,bFramepar,3);
630      gMC->Gsvolu("S08B","BOX",bFrameMaterial,bFramepar,3);
631
632      index=0; 
633      for (i = 0; i<nSlats4; i++){
634          for (Int_t quadrant=1; quadrant<=4; quadrant++) {
635
636              if (i==0&&quadrant==2) continue;
637              if (i==0&&quadrant==4) continue;
638
639        sprintf(idSlatCh7,"LC%d",ConvertSlatNum(i,quadrant,5));
640        sprintf(idSlatCh8,"LD%d",ConvertSlatNum(i,quadrant,5));
641        Float_t xvFrame  = (slatLength4[i] - vFrameLength)/2.;
642
643        // position the vertical frames 
644        if (i!=1 && i!=0) { 
645        GetChamber(6)->GetGeometry()->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
646        GetChamber(6)->GetGeometry()->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
647        GetChamber(7)->GetGeometry()->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
648        GetChamber(7)->GetGeometry()->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
649        }
650        // position the panels and the insulating material 
651        for (j=0; j<nPCB4[i]; j++){
652          index++;
653          Float_t xx = sensLength * (-nPCB4[i]/2.+j+.5); 
654
655          Float_t zPanel = spar[2] - panelpar[2]; 
656        GetChamber(6)->GetGeometry()->AddEnvelopeConstituent("S07C", idSlatCh7, 2*index-1,TGeoTranslation(xx,0.,zPanel));
657        GetChamber(6)->GetGeometry()->AddEnvelopeConstituent("S07C", idSlatCh7, 2*index,TGeoTranslation(xx,0.,-zPanel));
658        GetChamber(6)->GetGeometry()->AddEnvelopeConstituent("S07I", idSlatCh7, index,TGeoTranslation(xx,0.,0.));
659        GetChamber(7)->GetGeometry()->AddEnvelopeConstituent("S08C", idSlatCh8, 2*index-1,TGeoTranslation(xx,0.,zPanel));
660        GetChamber(7)->GetGeometry()->AddEnvelopeConstituent("S08C", idSlatCh8, 2*index,TGeoTranslation(xx,0.,-zPanel));
661        GetChamber(7)->GetGeometry()->AddEnvelopeConstituent("S08I", idSlatCh8, index,TGeoTranslation(xx,0.,0.));
662        }
663          } 
664      }
665
666      // position the rohacell volume inside the panel volume
667      gMC->Gspos("S07R",1,"S07C",0.,0.,0.,0,"ONLY"); 
668      gMC->Gspos("S08R",1,"S08C",0.,0.,0.,0,"ONLY"); 
669
670      // position the PCB volume inside the insulating material volume
671      gMC->Gspos("S07P",1,"S07I",0.,0.,0.,0,"ONLY"); 
672      gMC->Gspos("S08P",1,"S08I",0.,0.,0.,0,"ONLY"); 
673      // position the horizontal frame volume inside the PCB volume
674      gMC->Gspos("S07H",1,"S07P",0.,0.,0.,0,"ONLY"); 
675      gMC->Gspos("S08H",1,"S08P",0.,0.,0.,0,"ONLY"); 
676      // position the sensitive volume inside the horizontal frame volume
677      gMC->Gsposp("S07G",1,"S07H",0.,0.,0.,0,"ONLY",senspar,3); 
678      gMC->Gsposp("S08G",1,"S08H",0.,0.,0.,0,"ONLY",senspar,3); 
679      // position the border volumes inside the PCB volume
680      Float_t yborder = ( pcbHeight - bFrameHeight ) / 2.; 
681      gMC->Gspos("S07B",1,"S07P",0., yborder,0.,0,"ONLY"); 
682      gMC->Gspos("S07B",2,"S07P",0.,-yborder,0.,0,"ONLY"); 
683      gMC->Gspos("S08B",1,"S08P",0., yborder,0.,0,"ONLY"); 
684      gMC->Gspos("S08B",2,"S08P",0.,-yborder,0.,0,"ONLY"); 
685
686 //      // create the NULOC volume and position it in the horizontal frame
687
688      gMC->Gsvolu("S07N","BOX",nulocMaterial,nulocpar,3);
689      gMC->Gsvolu("S08N","BOX",nulocMaterial,nulocpar,3);
690      index = 0;
691      for (xx = -xxmax; xx<=xxmax; xx+=2*nulocLength) { 
692        index++; 
693        gMC->Gspos("S07N",2*index-1,"S07B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
694        gMC->Gspos("S07N",2*index  ,"S07B", xx, 0., bFrameWidth/4., 0, "ONLY");
695        gMC->Gspos("S08N",2*index-1,"S08B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
696        gMC->Gspos("S08N",2*index  ,"S08B", xx, 0., bFrameWidth/4., 0, "ONLY");
697      }
698
699 //      // position the volumes approximating the circular section of the pipe
700      Float_t yoffs = sensHeight/2. - yOverlap; 
701      Float_t epsilon = 0.001; 
702      Int_t ndiv=6;
703      Double_t divpar[3];
704      Double_t dydiv= sensHeight/ndiv;
705      Double_t ydiv = yoffs -dydiv;
706      Int_t imax=0; 
707      imax = 1; 
708      Float_t rmin = 40.;
709      for (Int_t idiv=0;idiv<ndiv; idiv++){ 
710        ydiv+= dydiv;
711        Float_t xdiv = 0.; 
712        if (ydiv<rmin) xdiv= rmin * TMath::Sin( TMath::ACos(ydiv/rmin) );
713        divpar[0] = (pcbLength-xdiv)/2.; 
714        divpar[1] = dydiv/2. - epsilon;
715        divpar[2] = sensWidth/2.; 
716        Float_t xvol=(pcbLength+xdiv)/2.+1.999;
717        Float_t yvol=ydiv + dydiv/2.;
718
719        for (Int_t quadrant=1; quadrant<=4; quadrant++)
720        {
721            sprintf(idSlatCh7,"LC%d",ConvertSlatNum(1,quadrant,5));
722            sprintf(idSlatCh8,"LD%d",ConvertSlatNum(1,quadrant,5));
723
724        GetChamber(6)->GetGeometry()->AddEnvelopeConstituentParam("S07G", idSlatCh7, quadrant*100+imax+4*idiv+1,TGeoTranslation(xvol-pcbLength * nPCB4[1]/2.,yvol-pcbLength+yOverlap,0.),3,divpar);
725        GetChamber(7)->GetGeometry()->AddEnvelopeConstituentParam("S08G", idSlatCh8,  quadrant*100+imax+4*idiv+1,TGeoTranslation(xvol-pcbLength * nPCB4[1]/2.,yvol-pcbLength+yOverlap,0.),3,divpar);
726        }
727      }
728      cout << "Geometry for Station 4...... done" << endl;
729
730     }
731     
732     if (fStations[4]) {
733         
734
735 // //********************************************************************
736 // //                            Station 5                             **
737 // //********************************************************************
738 //      // indices 1 and 2 for first and second chambers in the station
739 //      // iChamber (first chamber) kept for other quanties than Z,
740 //      // assumed to be the same in both chambers
741
742      iChamber = GetChamber(8);
743      iChamber1 = iChamber;
744      iChamber2 = GetChamber(9);
745  
746      const Int_t nSlats5 = 7;  // number of slats per quadrant
747      const Int_t nPCB5[nSlats5] = {5,5,6,6,5,4,3}; // n PCB per slat
748      const Float_t xpos5[nSlats5] = {38.5, 40., 0., 0., 0., 0., 0.};
749      Float_t slatLength5[nSlats5]; 
750
751 //      // create and position the slat (mother) volumes 
752
753      char idSlatCh9[5];
754      char idSlatCh10[5];
755      Float_t xSlat5;
756      Float_t ySlat5;
757      angle = 0.;
758
759      for (i = 0; i<nSlats5; i++){
760        slatLength5[i] = pcbLength * nPCB5[i] + 2. * dSlatLength; 
761        xSlat5 = slatLength5[i]/2. - vFrameLength/2. +xpos5[i]; 
762        if (i==1 || i==0) slatLength5[i] -=  2. *dSlatLength; // frame out in PCB with circular border 
763        ySlat5 = sensHeight * i - yOverlap * i;
764  
765        spar[0] = slatLength5[i]/2.; 
766        spar[1] = slatHeight/2.;
767        spar[2] = slatWidth/2. * 1.01; 
768        Float_t dzCh5=spar[2]*1.01;
769        // zSlat to be checked (odd downstream or upstream?)
770        Float_t zSlat = (i%2 ==0)? -spar[2] : spar[2]; 
771
772        sprintf(idSlatCh9,"LE%d",nSlats5-1+i);
773        gMC->Gsvolu(idSlatCh9,"BOX",slatMaterial,spar,3);
774        GetChamber(8)->GetGeometry()->AddEnvelope(idSlatCh9, true, TGeoTranslation(xSlat5, ySlat5, zSlat+2.*dzCh5));
775
776        sprintf(idSlatCh9,"LE%d",3*nSlats5-2+i);
777        gMC->Gsvolu(idSlatCh9,"BOX",slatMaterial,spar,3);
778        GetChamber(8)->GetGeometry()->AddEnvelope(idSlatCh9, true, TGeoTranslation(-xSlat5, ySlat5, zSlat-2.*dzCh5));
779  
780        if (i>0) { 
781
782        sprintf(idSlatCh9,"LE%d",nSlats5-1-i);
783        gMC->Gsvolu(idSlatCh9,"BOX",slatMaterial,spar,3);
784        GetChamber(8)->GetGeometry()->AddEnvelope(idSlatCh9, true, TGeoTranslation(xSlat5, -ySlat5, zSlat+2.*dzCh5) ,TGeoRotation("rot3",90,angle,90,270+angle,180,0)
785            );
786
787        sprintf(idSlatCh9,"LE%d",3*nSlats5-2-i);
788        gMC->Gsvolu(idSlatCh9,"BOX",slatMaterial,spar,3);
789        GetChamber(8)->GetGeometry()->AddEnvelope(idSlatCh9, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat-2.*dzCh5) ,TGeoRotation("rot3",90,angle,90,270+angle,180,0)
790            );
791        }
792
793        sprintf(idSlatCh10,"LF%d",nSlats5-1+i);
794        gMC->Gsvolu(idSlatCh10,"BOX",slatMaterial,spar,3);
795        GetChamber(9)->GetGeometry()->AddEnvelope(idSlatCh10, true, TGeoTranslation(xSlat5, ySlat5, zSlat+2.*dzCh5) ,TGeoRotation("rot5",90,angle,90,90+angle,0,0)
796            );
797
798        sprintf(idSlatCh10,"LF%d",3*nSlats5-2+i);
799        gMC->Gsvolu(idSlatCh10,"BOX",slatMaterial,spar,3);
800        GetChamber(9)->GetGeometry()->AddEnvelope(idSlatCh10, true, TGeoTranslation(-xSlat5, ySlat5, zSlat-2.*dzCh5) ,TGeoRotation("rot6",90,180+angle,90,90+angle,180,0)
801            );
802
803              if (i>0) { 
804
805        sprintf(idSlatCh10,"LF%d",nSlats5-1-i);
806        gMC->Gsvolu(idSlatCh10,"BOX",slatMaterial,spar,3);
807        GetChamber(9)->GetGeometry()->AddEnvelope(idSlatCh10, true, TGeoTranslation(xSlat5, -ySlat5, zSlat+2.*dzCh5) ,TGeoRotation("rot7",90,angle,90,270+angle,180,0)
808            );
809        sprintf(idSlatCh10,"LF%d",3*nSlats5-2-i);
810        gMC->Gsvolu(idSlatCh10,"BOX",slatMaterial,spar,3);
811        GetChamber(9)->GetGeometry()->AddEnvelope(idSlatCh10, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat-2.*dzCh5) ,TGeoRotation("rot8",90,180+angle,90,270+angle,0,0)
812            );
813              }
814      }
815 //      // create the panel volume 
816  
817      gMC->Gsvolu("S09C","BOX",panelMaterial,panelpar,3);
818      gMC->Gsvolu("S10C","BOX",panelMaterial,panelpar,3);
819
820      // create the rohacell volume 
821
822      gMC->Gsvolu("S09R","BOX",rohaMaterial,rohapar,3);
823      gMC->Gsvolu("S10R","BOX",rohaMaterial,rohapar,3);
824
825      // create the insulating material volume 
826
827      gMC->Gsvolu("S09I","BOX",insuMaterial,insupar,3);
828      gMC->Gsvolu("S10I","BOX",insuMaterial,insupar,3);
829
830      // create the PCB volume 
831
832      gMC->Gsvolu("S09P","BOX",pcbMaterial,pcbpar,3);
833      gMC->Gsvolu("S10P","BOX",pcbMaterial,pcbpar,3);
834  
835      // create the sensitive volumes,
836
837      gMC->Gsvolu("S09G","BOX",sensMaterial,dum,0);
838      gMC->Gsvolu("S10G","BOX",sensMaterial,dum,0);
839
840      // create the vertical frame volume 
841
842      gMC->Gsvolu("S09V","BOX",vFrameMaterial,vFramepar,3);
843      gMC->Gsvolu("S10V","BOX",vFrameMaterial,vFramepar,3);
844
845      // create the horizontal frame volume 
846
847      gMC->Gsvolu("S09H","BOX",hFrameMaterial,hFramepar,3);
848      gMC->Gsvolu("S10H","BOX",hFrameMaterial,hFramepar,3);
849
850      // create the horizontal border volume 
851
852      gMC->Gsvolu("S09B","BOX",bFrameMaterial,bFramepar,3);
853      gMC->Gsvolu("S10B","BOX",bFrameMaterial,bFramepar,3);
854
855      index=0; 
856      for (i = 0; i<nSlats5; i++){
857          for (Int_t quadrant=1; quadrant<=4; quadrant++) {
858
859              if (i==0&&quadrant==2) continue;
860              if (i==0&&quadrant==4) continue;
861
862        sprintf(idSlatCh9,"LE%d",ConvertSlatNum(i,quadrant,6));
863        sprintf(idSlatCh10,"LF%d",ConvertSlatNum(i,quadrant,6));
864        Float_t xvFrame  = (slatLength5[i] - vFrameLength)/2.;
865
866        // position the vertical frames 
867        if (i!=1 && i!=0) { 
868        GetChamber(8)->GetGeometry()->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
869        GetChamber(8)->GetGeometry()->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
870        GetChamber(9)->GetGeometry()->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i-1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
871        GetChamber(9)->GetGeometry()->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
872        }
873        
874        // position the panels and the insulating material 
875        for (j=0; j<nPCB5[i]; j++){
876          index++;
877          Float_t xx = sensLength * (-nPCB5[i]/2.+j+.5); 
878
879          Float_t zPanel = spar[2] - panelpar[2]; 
880        GetChamber(8)->GetGeometry()->AddEnvelopeConstituent("S09C", idSlatCh9, 2*index-1,TGeoTranslation(xx,0.,zPanel));
881        GetChamber(8)->GetGeometry()->AddEnvelopeConstituent("S09C", idSlatCh9, 2*index,TGeoTranslation(xx,0.,-zPanel));
882        GetChamber(8)->GetGeometry()->AddEnvelopeConstituent("S09I", idSlatCh9, index,TGeoTranslation(xx,0.,0.));
883        GetChamber(9)->GetGeometry()->AddEnvelopeConstituent("S10C", idSlatCh10, 2*index-1,TGeoTranslation(xx,0.,zPanel));
884        GetChamber(9)->GetGeometry()->AddEnvelopeConstituent("S10C", idSlatCh10, 2*index,TGeoTranslation(xx,0.,-zPanel));
885        GetChamber(9)->GetGeometry()->AddEnvelopeConstituent("S10I", idSlatCh10, index,TGeoTranslation(xx,0.,0.));
886        }
887          } 
888      }
889
890      // position the rohacell volume inside the panel volume
891      gMC->Gspos("S09R",1,"S09C",0.,0.,0.,0,"ONLY"); 
892      gMC->Gspos("S10R",1,"S10C",0.,0.,0.,0,"ONLY"); 
893
894      // position the PCB volume inside the insulating material volume
895      gMC->Gspos("S09P",1,"S09I",0.,0.,0.,0,"ONLY"); 
896      gMC->Gspos("S10P",1,"S10I",0.,0.,0.,0,"ONLY"); 
897      // position the horizontal frame volume inside the PCB volume
898      gMC->Gspos("S09H",1,"S09P",0.,0.,0.,0,"ONLY"); 
899      gMC->Gspos("S10H",1,"S10P",0.,0.,0.,0,"ONLY"); 
900      // position the sensitive volume inside the horizontal frame volume
901      gMC->Gsposp("S09G",1,"S09H",0.,0.,0.,0,"ONLY",senspar,3); 
902      gMC->Gsposp("S10G",1,"S10H",0.,0.,0.,0,"ONLY",senspar,3); 
903      // position the border volumes inside the PCB volume
904      Float_t yborder = ( pcbHeight - bFrameHeight ) / 2.; 
905      gMC->Gspos("S09B",1,"S09P",0., yborder,0.,0,"ONLY"); 
906      gMC->Gspos("S09B",2,"S09P",0.,-yborder,0.,0,"ONLY"); 
907      gMC->Gspos("S10B",1,"S10P",0., yborder,0.,0,"ONLY"); 
908      gMC->Gspos("S10B",2,"S10P",0.,-yborder,0.,0,"ONLY"); 
909
910 //      // create the NULOC volume and position it in the horizontal frame
911
912      gMC->Gsvolu("S09N","BOX",nulocMaterial,nulocpar,3);
913      gMC->Gsvolu("S10N","BOX",nulocMaterial,nulocpar,3);
914      index = 0;
915      for (xx = -xxmax; xx<=xxmax; xx+=2*nulocLength) { 
916        index++; 
917        gMC->Gspos("S09N",2*index-1,"S09B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
918        gMC->Gspos("S09N",2*index  ,"S09B", xx, 0., bFrameWidth/4., 0, "ONLY");
919        gMC->Gspos("S10N",2*index-1,"S10B", xx, 0.,-bFrameWidth/4., 0, "ONLY");
920        gMC->Gspos("S10N",2*index  ,"S10B", xx, 0., bFrameWidth/4., 0, "ONLY");
921      }
922
923 //      // position the volumes approximating the circular section of the pipe
924      Float_t yoffs = sensHeight/2. - yOverlap; 
925      Float_t epsilon = 0.001; 
926      Int_t ndiv=6;
927      Double_t divpar[3];
928      Double_t dydiv= sensHeight/ndiv;
929      Double_t ydiv = yoffs -dydiv;
930      Int_t imax=0; 
931      //     for (Int_t islat=0; islat<nSlats3; islat++) imax += nPCB3[islat]; 
932      imax = 1; 
933      Float_t rmin = 40.; 
934      for (Int_t idiv=0;idiv<ndiv; idiv++){ 
935        ydiv+= dydiv;
936        Float_t xdiv = 0.; 
937        if (ydiv<rmin) xdiv= rmin * TMath::Sin( TMath::ACos(ydiv/rmin) );
938        divpar[0] = (pcbLength-xdiv)/2.; 
939        divpar[1] = dydiv/2. - epsilon;
940        divpar[2] = sensWidth/2.; 
941        Float_t xvol=(pcbLength+xdiv)/2. + 1.999;
942        Float_t yvol=ydiv + dydiv/2.;
943
944        for (Int_t quadrant=1; quadrant<=4; quadrant++)
945        {
946            sprintf(idSlatCh9,"LE%d",ConvertSlatNum(1,quadrant,6));
947            sprintf(idSlatCh10,"LF%d",ConvertSlatNum(1,quadrant,6));
948
949        GetChamber(8)->GetGeometry()->AddEnvelopeConstituentParam("S09G", idSlatCh9, quadrant*100+imax+4*idiv+1,TGeoTranslation(xvol-pcbLength * nPCB5[1]/2.,yvol-pcbLength+yOverlap,0.),3,divpar);
950        GetChamber(9)->GetGeometry()->AddEnvelopeConstituentParam("S10G", idSlatCh10,  quadrant*100+imax+4*idiv+1,TGeoTranslation(xvol-pcbLength * nPCB5[1]/2.,yvol-pcbLength+yOverlap,0.),3,divpar);
951        }
952      }
953      cout << "Geometry for Station 5...... done" << endl;
954
955     }
956 }
957
958
959 //______________________________________________________________________________
960 void AliMUONSlatGeometryBuilder::SetTransformations()
961 {
962 // Defines the transformations for the station2 chambers.
963 // ---
964
965   AliMUONChamber* iChamber1 = GetChamber(4);
966   Double_t zpos1 = - iChamber1->Z(); 
967   iChamber1->GetGeometry()
968     ->SetTranslation(TGeoTranslation(0., 0., zpos1));
969
970   AliMUONChamber* iChamber2 = GetChamber(5);
971   Double_t zpos2 = - iChamber2->Z(); 
972   iChamber2->GetGeometry()
973     ->SetTranslation(TGeoTranslation(0., 0., zpos2));
974
975  iChamber1 = GetChamber(6);
976   zpos1 = - iChamber1->Z(); 
977   iChamber1->GetGeometry()
978     ->SetTranslation(TGeoTranslation(0., 0., zpos1));
979
980   iChamber2 = GetChamber(7);
981   zpos2 = - iChamber2->Z(); 
982   iChamber2->GetGeometry()
983     ->SetTranslation(TGeoTranslation(0., 0., zpos2));
984
985  iChamber1 = GetChamber(8);
986   zpos1 = - iChamber1->Z(); 
987   iChamber1->GetGeometry()
988     ->SetTranslation(TGeoTranslation(0., 0., zpos1));
989
990   iChamber2 = GetChamber(9);
991   zpos2 = - iChamber2->Z(); 
992   iChamber2->GetGeometry()
993     ->SetTranslation(TGeoTranslation(0., 0., zpos2));
994
995 }
996
997 //______________________________________________________________________________
998 void AliMUONSlatGeometryBuilder::SetSensitiveVolumes()
999 {
1000 // Defines the sensitive volumes for slat stations chambers.
1001 // ---
1002
1003   GetChamber(4)->GetGeometry()->SetSensitiveVolume("S05G");
1004   GetChamber(5)->GetGeometry()->SetSensitiveVolume("S06G");
1005   GetChamber(6)->GetGeometry()->SetSensitiveVolume("S07G");
1006   GetChamber(7)->GetGeometry()->SetSensitiveVolume("S08G");
1007   GetChamber(8)->GetGeometry()->SetSensitiveVolume("S09G");
1008   GetChamber(9)->GetGeometry()->SetSensitiveVolume("S10G");
1009 }
1010
1011 //______________________________________________________________________________
1012 Int_t  AliMUONSlatGeometryBuilder::ConvertSlatNum(Int_t numslat, Int_t quadnum, Int_t fspq) const
1013 {
1014               numslat=numslat+1;
1015               if (quadnum==2||quadnum==3) numslat=numslat+fspq;
1016               else numslat=fspq+2-numslat;
1017               numslat=numslat-1;
1018               
1019               if (quadnum==3||quadnum==4) numslat=numslat+2*fspq+1;
1020               return numslat;
1021 }