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