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