- Adapted comments for Doxygen
[u/mrichter/AliRoot.git] / MUON / AliMUONSt2GeometryBuilderV2.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 // $Id$
17 //
18 // Class AliMUONSt2GeometryBuilderV2
19 // -------------------------------
20 // MUON Station2 coarse geometry construction class.
21 //********************************************************************
22 // Author: SANJOY PAL ,Prof. SUKALYAN CHATTOPADHAYAY  [SINP, KOLKATA]
23 //         &  Dr.SHAKEEL AHMAD (AMU), INDIA
24 //********************************************************************
25
26
27 #include <TVirtualMC.h>
28 #include <TGeoMatrix.h>
29 #include <Riostream.h>
30
31 #include "AliRun.h"
32 #include "AliLog.h"
33
34 #include "AliMUONSt2GeometryBuilderV2.h"
35 #include "AliMUON.h"
36 #include "AliMUONConstants.h"
37 #include "AliMUONGeometryModule.h"
38 #include "AliMUONGeometryEnvelopeStore.h"
39 #include "AliMUONConstants.h"
40
41 #define PI 3.14159
42
43 /// \cond CLASSIMP
44 ClassImp(AliMUONSt2GeometryBuilderV2)
45 /// \endcond
46
47 //______________________________________________________________________________
48 AliMUONSt2GeometryBuilderV2::AliMUONSt2GeometryBuilderV2(AliMUON* muon)
49  : AliMUONVGeometryBuilder(2, 3),
50    fMUON(muon)
51 {
52 // Standard constructor
53
54 }
55
56 //______________________________________________________________________________
57 AliMUONSt2GeometryBuilderV2::AliMUONSt2GeometryBuilderV2()
58  : AliMUONVGeometryBuilder(),
59    fMUON(0)
60 {
61 // Default constructor
62 }
63
64
65 //______________________________________________________________________________
66 AliMUONSt2GeometryBuilderV2::AliMUONSt2GeometryBuilderV2(const AliMUONSt2GeometryBuilderV2& rhs)
67   : AliMUONVGeometryBuilder(rhs)
68 {
69 // Protected copy constructor
70
71   AliFatal("Copy constructor is not implemented.");
72 }
73
74 //______________________________________________________________________________
75 AliMUONSt2GeometryBuilderV2::~AliMUONSt2GeometryBuilderV2() {
76 //
77 }
78
79 //______________________________________________________________________________
80 AliMUONSt2GeometryBuilderV2&
81 AliMUONSt2GeometryBuilderV2::operator = (const AliMUONSt2GeometryBuilderV2& rhs)
82 {
83 // Protected assignement operator
84
85   // check assignement to self
86   if (this == &rhs) return *this;
87
88   AliFatal("Assignment operator is not implemented.");
89
90   return *this;
91 }
92
93 //
94 // public methods
95 //
96
97 //______________________________________________________________________________
98 void AliMUONSt2GeometryBuilderV2::CreateGeometry()
99 {
100
101 //
102 //********************************************************************
103 //                            Station 2                             **
104 //********************************************************************
105      // indices 1 and 2 for first and second chambers in the station
106      // iChamber (first chamber) kept for other quanties than Z,
107      // assumed to be the same in both chambers
108
109      // Get tracking medias Ids
110      Int_t *idtmed = fMUON->GetIdtmed()->GetArray()-1099;
111      Int_t idAir  = idtmed[1100]; // medium 1
112      Int_t idGas  = idtmed[1108]; // medium Ar-CO2 gas (80%+20%)
113      Int_t idPCB  = idtmed[1122]; // medium FR4
114      Int_t idCU   = idtmed[1110]; // medium copper
115      Int_t idRoha = idtmed[1113]; // medium roha cell
116      Int_t idPGF30= idtmed[1123]; // medium for Frame Eq.to Bakelite
117      //Int_t idScru = idtmed[1128]; // screw material - Stainless Steel(18%Cr,9%Ni,Fe)
118
119
120
121 /*########################################################################################
122     Create volume for one Quadrant
123 ##########################################################################################*/
124      Float_t tpar1[5];
125      tpar1[0] = 20.55;
126      tpar1[1] = 123.5;
127      tpar1[2] = 6.8/2;
128      tpar1[3] = -12.0;
129      tpar1[4] = 102.0;
130
131
132      gMC->Gsvolu("SQM3","TUBS", idAir, tpar1, 5);
133      gMC->Gsvolu("SQM4","TUBS", idAir, tpar1, 5);
134
135
136
137 //==================================================================================
138 //                                 Plane      
139 //==================================================================================
140
141 //Thickness of variour parts
142        Float_t zCbb  = 0.04;       //cathode pcb
143        Float_t zCu   = 0.004;      // eff. cu in cathode pcb
144        Float_t zRoha = 2.5;        // Rhocell
145        Float_t zMeb = 0.08;      //Mech. exit board
146        Float_t zEeb = 0.02;     //Effective electronic exit board
147     //Z-positions of various parts--- in Plane-1
148
149        Float_t zposCbb   = 0.25;   // 2.5 mm => gap between anode & chatode plane
150        Float_t zposCu    =zposCbb + zCbb;
151        Float_t zposRoha  =zposCu + zCu;
152        Float_t zposMeb   =zposRoha + zRoha;
153        Float_t zposEeb   =zposMeb + zMeb;
154
155        Float_t zposCbbBar  = zposCbb + zCbb/2.;  //for segment 0 & 6
156        Float_t zposCuBar   = zCbb/2. + zCu/2.;
157        Float_t zposRohaBar = zCu/2. + zRoha/2.;
158        Float_t zposMebBar  =  zRoha/2. + zMeb/2.;
159        Float_t zposEebBar  = zMeb/2. + zEeb/2.;
160
161
162  //Cathode PCB + Copper sheet + Rohacell + mech exit board + eff. electronic exit board
163
164  //Segment-0 ~~~Horizantal box  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
165        Float_t bparH[3];
166        bparH[0] = 94.5/2.; // extension beyond 0 deg in x direction
167        bparH[1] = 1.2/2.;  // extension beyond 0 deg in y direction (3.7[total extn] - 2.5[frame dim])
168        bparH[2] = zCbb/2.; // thickness of cathode sheet in z direction
169        gMC->Gsvolu("CB0L", "BOX", idPCB, bparH, 3);
170        
171        bparH[2] = zCu/2.;     //Thickness of Copper sheet
172        gMC->Gsvolu("CU0L", "BOX", idCU, bparH, 3);
173
174        bparH[2] = zRoha/2.;     //Thickness of Roha cell
175        gMC->Gsvolu("RH0L", "BOX", idRoha, bparH, 3);
176
177        bparH[2] = zMeb/2;       //Thickness of mechanical exit board
178        gMC->Gsvolu("MB0L", "BOX", idPCB, bparH, 3);
179
180        bparH[2] = zEeb/2;          //Thickness of effective electronic  exit board
181        gMC->Gsvolu("EB0L", "BOX", idCU, bparH, 3);
182
183  //Segment-1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
184        Float_t pgpar[10]; // polygon
185        pgpar[0] = 0.;  // initial angle
186        pgpar[1] = 90.; // increment in angle starting from initial angle 
187        pgpar[2] = 5;   // number of side
188        pgpar[3] = 2.; // number of plane
189        pgpar[4] = 0.; // z-position of the first plane
190        pgpar[5] = 23.1; // innner radius first plane
191        pgpar[6] = 117.6;  // outer radious first plane
192        pgpar[7] = pgpar[4] + zCbb; // z-position of the second plane
193        pgpar[8] = pgpar[5];  // innner radius of second plane
194        pgpar[9] = pgpar[6];  // outer radious of second plane
195        gMC->Gsvolu("CB1L", "PGON", idPCB, pgpar, 10);
196
197        pgpar[7] = pgpar[4] + zCu;  // Thickness of copper-sheet
198        gMC->Gsvolu("CU1L", "PGON", idCU, pgpar, 10);
199        
200        pgpar[7] = pgpar[4] + zRoha;  // Thickness of Roha cell
201        gMC->Gsvolu("RH1L", "PGON", idRoha, pgpar, 10);
202        
203        pgpar[7] = pgpar[4] + zMeb;  // Thickness of mechanical exit board
204        gMC->Gsvolu("MB1L", "PGON", idPCB, pgpar, 10);
205        
206        pgpar[7] = pgpar[4] + zEeb;  // Thickness of electronic exit board
207        gMC->Gsvolu("EB1L", "PGON", idCU, pgpar, 10);
208        
209
210 //Segment-2 - vertical box (simalar to horizontal bar as in Segment 0)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
211        
212        Float_t bparV[3];
213        
214        bparV[0] = 1.0/2.;
215        bparV[1] = 94.5/2.;
216        bparV[2] = zCbb/2.;
217        gMC->Gsvolu("CB2L", "BOX", idPCB, bparV, 3);
218        
219        bparV[2] = zCu/2.;
220        gMC->Gsvolu("CU2L", "BOX", idCU, bparV, 3);
221
222        bparV[2] = zRoha/2.;
223        gMC->Gsvolu("RH2L", "BOX", idRoha, bparV, 3);
224        
225        bparV[2] = zMeb/2;
226        gMC->Gsvolu("MB2L", "BOX", idPCB, bparV, 3);
227        
228        bparV[2] = zEeb/2;
229        gMC->Gsvolu("EB2L", "BOX", idCU, bparV, 3);
230        
231 //....(Setting posion of Segment 0,1,2)..................................................................
232        
233        Float_t xposHorBox =  bparH[0] + 23.1; // 23.1 = 20.6(inner radius of qrd) + 2.5 (width of frame)
234        Float_t yposHorBox = -bparH[1];  
235        
236        Float_t xposVerBox = -bparV[0];
237        Float_t yposVerBox =  bparV[1] + 23.1;
238
239
240
241 //Positioning the PCB
242 //
243
244       // chamber 3
245      gMC->Gspos("CB0L",1, "SQM3",xposHorBox,yposHorBox,zposCbbBar,0, "ONLY");// box horizontal
246      gMC->Gspos("CB1L",1, "SQM3", 0.0,0.0,zposCbb,0, "ONLY");
247      gMC->Gspos("CB2L",1, "SQM3",xposVerBox,yposVerBox,zposCbbBar,0, "ONLY");// box vertical
248
249      gMC->Gspos("CB0L",2, "SQM3",xposHorBox,yposHorBox,-zposCbbBar,0, "ONLY");// box horizontal
250      gMC->Gspos("CB1L",2, "SQM3", 0.0,0.0,-(zposCbb+ zCbb),0, "ONLY");
251      gMC->Gspos("CB2L",2, "SQM3",xposVerBox,yposVerBox,zposCbbBar,0, "ONLY");// box vertical
252
253       // chamber 4
254      gMC->Gspos("CB0L",3, "SQM4",xposHorBox,yposHorBox,zposCbbBar,0, "ONLY");
255      gMC->Gspos("CB1L",3, "SQM4", 0.0,0.0,zposCbb,0, "ONLY");
256      gMC->Gspos("CB2L",3, "SQM4",xposVerBox,yposVerBox,zposCbbBar,0, "ONLY");
257
258      gMC->Gspos("CB0L",4, "SQM4",xposHorBox,yposHorBox,-zposCbbBar,0, "ONLY");
259      gMC->Gspos("CB1L",4, "SQM4", 0.0,0.0,-(zposCbb+ zCbb),0, "ONLY");
260      gMC->Gspos("CB2L",4, "SQM4",xposVerBox,yposVerBox,zposCbbBar,0, "ONLY");
261
262
263 //Positioning Copper sheet
264
265       // chamber 3
266
267      gMC->Gspos("CU0L",1, "SQM3",xposHorBox,yposHorBox,zposCuBar,0, "ONLY");
268      gMC->Gspos("CU1L",1, "SQM3", 0.0,0.0,zposCu,0, "ONLY");
269      gMC->Gspos("CU2L",1, "SQM3",xposVerBox,yposVerBox,zposCuBar,0, "ONLY");
270
271      gMC->Gspos("CU0L",2, "SQM3",xposHorBox,yposHorBox,-zposCuBar,0, "ONLY");
272      gMC->Gspos("CU1L",2, "SQM3", 0.0,0.0,-(zposCu+ zCu),0, "ONLY");
273      gMC->Gspos("CU2L",2, "SQM3",xposVerBox,yposVerBox,zposCuBar,0, "ONLY");
274       // chamber 4
275
276      gMC->Gspos("CU0L",3, "SQM4",xposHorBox,yposHorBox,zposCuBar,0, "ONLY");
277      gMC->Gspos("CU1L",3, "SQM4", 0.0,0.0,zposCu,0, "ONLY");
278      gMC->Gspos("CU2L",3, "SQM4",xposVerBox,yposVerBox,zposCuBar,0, "ONLY");
279
280      gMC->Gspos("CU0L",4, "SQM4",xposHorBox,yposHorBox,-zposCuBar,0, "ONLY");
281      gMC->Gspos("CU1L",4, "SQM4", 0.0,0.0,-(zposCu+ zCu),0, "ONLY");
282      gMC->Gspos("CU2L",4, "SQM4",xposVerBox,yposVerBox,zposCuBar,0, "ONLY");
283
284 //Positioning Roha cell 
285
286       // chamber 3
287
288      gMC->Gspos("RH0L",1, "SQM3",xposHorBox,yposHorBox,zposRohaBar,0, "ONLY");
289      gMC->Gspos("RH1L",1, "SQM3", 0.0,0.0,zposRoha,0, "ONLY");
290      gMC->Gspos("RH2L",1, "SQM3",xposVerBox,yposVerBox,zposRohaBar,0, "ONLY");
291
292      gMC->Gspos("RH0L",2, "SQM3",xposHorBox,yposHorBox,-zposRohaBar,0, "ONLY");
293      gMC->Gspos("RH1L",2, "SQM3", 0.0,0.0,-(zposRoha+ zRoha),0, "ONLY");
294      gMC->Gspos("RH2L",2, "SQM3",xposVerBox,yposVerBox,zposRohaBar,0, "ONLY");
295
296       // chamber 4
297
298      gMC->Gspos("RH0L",3, "SQM4",xposHorBox,yposHorBox,zposRohaBar,0, "ONLY");
299      gMC->Gspos("RH1L",3, "SQM4", 0.0,0.0,zposRoha,0, "ONLY");
300      gMC->Gspos("RH2L",3, "SQM4",xposVerBox,yposVerBox,zposRohaBar,0, "ONLY");
301
302      gMC->Gspos("RH0L",4, "SQM4",xposHorBox,yposHorBox,-zposRohaBar,0, "ONLY");
303      gMC->Gspos("RH1L",4, "SQM4", 0.0,0.0,-(zposRoha+ zRoha),0, "ONLY");
304      gMC->Gspos("RH2L",4, "SQM4",xposVerBox,yposVerBox,zposRohaBar,0, "ONLY");
305
306 //Positioning of Mech. exit board
307
308       // chamber 3
309
310      gMC->Gspos("MB0L",1, "SQM3",xposHorBox,yposHorBox,zposMebBar,0, "ONLY");
311      gMC->Gspos("MB1L",1, "SQM3", 0.0,0.0,zposMeb,0, "ONLY");
312      gMC->Gspos("MB2L",1, "SQM3",xposVerBox,yposVerBox,zposMebBar,0, "ONLY");
313
314      gMC->Gspos("MB0L",2, "SQM3",xposHorBox,yposHorBox,-zposMebBar,0, "ONLY");
315      gMC->Gspos("MB1L",2, "SQM3", 0.0,0.0,-(zposMeb+ zMeb),0, "ONLY");
316      gMC->Gspos("MB2L",2, "SQM3",xposVerBox,yposVerBox,zposMebBar,0, "ONLY");
317       // chamber 4
318
319      gMC->Gspos("MB0L",3, "SQM4",xposHorBox,yposHorBox,zposMebBar,0, "ONLY");
320      gMC->Gspos("MB1L",3, "SQM4", 0.0,0.0,zposMeb,0, "ONLY");
321      gMC->Gspos("MB2L",3, "SQM4",xposVerBox,yposVerBox,zposMebBar,0, "ONLY");
322
323      gMC->Gspos("MB0L",4, "SQM4",xposHorBox,yposHorBox,-zposMebBar,0, "ONLY");
324      gMC->Gspos("MB1L",4, "SQM4", 0.0,0.0,-(zposMeb+ zMeb),0, "ONLY");
325      gMC->Gspos("MB2L",4, "SQM4",xposVerBox,yposVerBox,zposMebBar,0, "ONLY");
326
327 //Positioning of Electronic exit board
328
329
330       // chamber 3
331
332      gMC->Gspos("EB0L",1, "SQM3",xposHorBox,yposHorBox,zposEebBar,0, "ONLY");
333      gMC->Gspos("EB1L",1, "SQM3", 0.0,0.0,zposEeb,0, "ONLY");
334      gMC->Gspos("EB2L",1, "SQM3",xposVerBox,yposVerBox,zposEebBar,0, "ONLY");
335
336      gMC->Gspos("EB0L",2, "SQM3",xposHorBox,yposHorBox,-zposEebBar,0, "ONLY");
337      gMC->Gspos("EB1L",2, "SQM3", 0.0,0.0,-(zposEeb+ zEeb),0, "ONLY");
338      gMC->Gspos("EB2L",2, "SQM3",xposVerBox,yposVerBox,zposEebBar,0, "ONLY");
339       // chamber 4
340
341      gMC->Gspos("EB0L",3, "SQM4",xposHorBox,yposHorBox,zposEebBar,0, "ONLY");
342      gMC->Gspos("EB1L",3, "SQM4", 0.0,0.0,zposEeb,0, "ONLY");
343      gMC->Gspos("EB2L",3, "SQM4",xposVerBox,yposVerBox,zposEebBar,0, "ONLY");
344
345      gMC->Gspos("EB0L",4, "SQM4",xposHorBox,yposHorBox,-zposEebBar,0, "ONLY");
346      gMC->Gspos("EB1L",4, "SQM4", 0.0,0.0,-(zposEeb+ zEeb),0, "ONLY");
347      gMC->Gspos("EB2L",4, "SQM4",xposVerBox,yposVerBox,zposEebBar,0, "ONLY");
348
349  
350 //----------------------------------------------------------------------
351 //                          Frames
352 //----------------------------------------------------------------------
353 //Frame-1
354      Float_t frame1[3] ;                
355      frame1[0] = 101.0/2.;             //100.6 = 94.5 + 2.5 + 3.6 
356      frame1[1] = 2.5/2.;               
357      frame1[2] = 5.0/2.;
358
359      gMC->Gsvolu("FRM1", "BOX", idPGF30, frame1, 3); //Frame - 1 // fill with pkk GF30
360      
361      Float_t arib1[3];
362      arib1[0] = frame1[0];
363      arib1[1] = 0.9/2.;
364      arib1[2] =(frame1[2]-0.95)/2.0;
365      
366      gMC->Gsvolu("FRA1", "BOX", idAir, arib1, 3); // fill with air
367      
368      Float_t xposarib1 = 0;
369      Float_t yposarib1 = -frame1[1] + arib1[1];
370      Float_t zposarib1 = frame1[2] - arib1[2];
371      
372      gMC->Gspos("FRA1",1, "FRM1", xposarib1, yposarib1, zposarib1,0, "ONLY");  //replace pkk GF30 with air(b)
373      gMC->Gspos("FRA1",2, "FRM1", xposarib1, yposarib1, -zposarib1,0, "ONLY"); //replace pkk GF30 with air(nb)
374      
375      Float_t rrib1[3];
376      rrib1[0] = frame1[0];
377      rrib1[1] = 0.6/2.;
378      rrib1[2] =(frame1[2]-0.95)/2.0;
379      
380      gMC->Gsvolu("FRR1", "BOX", idRoha, rrib1, 3); // fill with rohacell
381      
382      Float_t xposrrib1 = 0.0;
383      Float_t yposrrib1 = frame1[1] - rrib1[1];
384      Float_t zposrrib1 = frame1[2] - rrib1[2];
385      
386      gMC->Gspos("FRR1",1, "FRM1", xposrrib1, yposrrib1, zposrrib1,0, "ONLY");//replace pkk GF30 with rohacell
387      gMC->Gspos("FRR1",2, "FRM1", xposrrib1, yposrrib1, -zposrrib1,0, "ONLY");//replace pkk GF30 with rohacell
388
389      
390      Float_t xposFr1 = frame1[0] + 20.6;
391      Float_t yposFr1 = -3.7 + frame1[1] ;
392      Float_t zposFr1 = 0.0;
393      
394      gMC->Gspos("FRM1",1, "SQM3", xposFr1, yposFr1, zposFr1,0, "ONLY");// frame -1
395      gMC->Gspos("FRM1",2, "SQM4", xposFr1, yposFr1, zposFr1,0, "ONLY");// frame -1
396      
397
398 //......................................................................................
399 //Frame-2
400
401       Float_t frame2[3]; 
402       frame2[0] = 4.0/2.;
403       frame2[1] = 1.2/2.;
404       frame2[2] = 5.0/2;
405
406       gMC->Gsvolu("FRM2", "BOX", idPGF30, frame2, 3); //Frame - 2
407
408       Float_t rrib2[3];
409       rrib2[0] = frame2[0]-1.0/2.0;
410       rrib2[1] = frame2[1];
411       rrib2[2] =(frame2[2]-0.95)/2.0;
412
413       gMC->Gsvolu("FRR2", "BOX", idRoha, rrib2, 3);
414       
415       Float_t xposrrib2 = -1.0/2.0;
416       Float_t yposrrib2 = 0.0;
417       Float_t zposrrib2 = frame2[2] - rrib2[2];
418
419       gMC->Gspos("FRR2",1, "FRM2", xposrrib2, yposrrib2, zposrrib2,0, "ONLY");//replace pkk GF30 with rohacell
420       gMC->Gspos("FRR2",2, "FRM2", xposrrib2, yposrrib2, -zposrrib2,0, "ONLY");//replace pkk GF30 with roha
421
422
423
424       Float_t xposFr2 = frame2[0] + 117.6;
425       Float_t yposFr2 = -frame2[1];
426       Float_t zposFr2 = 0.0;
427
428       gMC->Gspos("FRM2",1, "SQM3", xposFr2, yposFr2, zposFr2,0, "ONLY");//global positing of frame in SQM3
429       gMC->Gspos("FRM2",2, "SQM4", xposFr2, yposFr2, zposFr2,0, "ONLY");//global positing of frame in SQM4
430       
431   
432 //......................................................................................
433 //Frame-3
434
435       Float_t pgparFr3[10];
436       pgparFr3[0] = 0.;
437       pgparFr3[1] = 90.;
438       pgparFr3[2] = 5;
439       pgparFr3[3] = 2.;
440       pgparFr3[4] = 0.;
441       pgparFr3[5] = 117.6;
442       pgparFr3[6] = 121.6;
443       pgparFr3[7] = pgparFr3[4] + 5.0;
444       pgparFr3[8] = pgparFr3[5];
445       pgparFr3[9] = pgparFr3[6];
446       
447       gMC->Gsvolu("FRM3", "PGON", idPGF30, pgparFr3, 10);
448       
449       Float_t pgparRrib3[10];
450       pgparRrib3[0] = 0.;
451       pgparRrib3[1] = 90.;
452       pgparRrib3[2] = 5;
453       pgparRrib3[3] = 2.;
454       pgparRrib3[4] = 0.;
455       pgparRrib3[5] = 117.6;
456       pgparRrib3[6] = 120.6;
457       pgparRrib3[7] = pgparRrib3[4] +1.55 ;
458       pgparRrib3[8] = pgparRrib3[5];
459       pgparRrib3[9] = pgparRrib3[6];
460       
461       gMC->Gsvolu("FRR3", "PGON", idRoha, pgparRrib3, 10);
462       
463       Float_t xposrrib3 = 0.0;
464       Float_t yposrrib3 = 0.0;
465       Float_t zposrrib3 = 0.0;
466
467       gMC->Gspos("FRR3",1, "FRM3", xposrrib3, yposrrib3, zposrrib3,0, "ONLY");
468
469       zposrrib3 = 3.45;
470       
471       gMC->Gspos("FRR3",2, "FRM3", xposrrib3, yposrrib3, zposrrib3,0, "ONLY");
472       
473       
474       
475       Float_t xposFr3 = 0.0;
476       Float_t yposFr3 = 0.0;
477       Float_t zposFr3 = -frame1[2];
478       
479       gMC->Gspos("FRM3",1, "SQM3", xposFr3, yposFr3, zposFr3,0, "ONLY");// frame -1
480       gMC->Gspos("FRM3",2, "SQM4", xposFr3, yposFr3, zposFr3,0, "ONLY");// frame -1
481       
482
483 //......................................................................................
484 //Frame-4
485  
486       Float_t frame4[3]; 
487       frame4[0] = 1.0/2.;
488       frame4[1] = 4.0/2.;
489       frame4[2] = frame1[2];
490
491       gMC->Gsvolu("FRM4", "BOX", idPGF30, frame4, 3); 
492
493       Float_t rrib4[3];
494       rrib4[0] = frame4[0];
495       rrib4[1] = frame4[1]-1.0/2;
496       rrib4[2] =(frame4[2]-0.95)/2.0;
497
498       gMC->Gsvolu("FRR4", "BOX", idRoha, rrib4, 3);
499       
500       Float_t xposrrib4 = 0.0;
501       Float_t yposrrib4 = -1.0/2;
502       Float_t zposrrib4 = frame4[2] - rrib4[2];
503
504       gMC->Gspos("FRR4",1, "FRM4", xposrrib4, yposrrib4, zposrrib4,0, "ONLY");
505       gMC->Gspos("FRR4",2, "FRM4", xposrrib4, yposrrib4, -zposrrib4,0, "ONLY");
506
507
508
509       Float_t xposFr4 = -frame4[0];
510       Float_t yposFr4 = -frame4[1] + 117.6;
511       Float_t zposFr4 = 0.0;
512
513       gMC->Gspos("FRM4",1, "SQM3", xposFr4, yposFr4, zposFr4,0, "ONLY");
514       gMC->Gspos("FRM4",2, "SQM4", xposFr4, yposFr4, zposFr4,0, "ONLY");
515       
516
517 //......................................................................................
518 //Frame-5
519       Float_t frame5[3] ;               
520       frame5[0] = 2.7/2.;            
521       frame5[1] = 101.0/2.;              
522       frame5[2] = 5.0/2.;
523
524       gMC->Gsvolu("FRM5", "BOX", idPGF30, frame5, 3); //Frame - 1
525       
526       Float_t arib5[3];
527       arib5[0] = 0.9/2.0;
528       arib5[1] = frame5[1];
529       arib5[2] = (frame5[2]-0.95)/2.0;
530
531       gMC->Gsvolu("FRA5", "BOX", idAir, arib5, 3);
532
533       Float_t xposarib5 = -frame5[0] + arib5[0];
534       Float_t yposarib5 = 0.0;
535       Float_t zposarib5 = frame5[2] - arib5[2];
536
537       gMC->Gspos("FRA5",1, "FRM5", xposarib5, yposarib5, zposarib5,0, "ONLY");
538       gMC->Gspos("FRA5",2, "FRM5", xposarib5, yposarib5, -zposarib5,0, "ONLY");
539
540       Float_t rrib5[3];
541       rrib5[0] = 0.8/2.0;
542       rrib5[1] = frame5[1];
543       rrib5[2] = (frame5[2]-0.95)/2.0;
544
545       gMC->Gsvolu("FRR5", "BOX", idRoha, rrib5, 3);
546
547       Float_t xposrrib5 = frame5[0] - rrib5[0];
548       Float_t yposrrib5 = 0.0;
549       Float_t zposrrib5 = frame5[2] - rrib5[2];
550
551       gMC->Gspos("FRR5",1, "FRM5", xposrrib5, yposrrib5, zposrrib5,0, "ONLY");
552       gMC->Gspos("FRR5",2, "FRM5", xposrrib5, yposrrib5, -zposrrib5,0, "ONLY");
553
554       Float_t xposFr5 = -3.7 + frame5[0];
555       Float_t yposFr5 = frame5[1] + 20.6;
556       Float_t zposFr5 = 0.0;
557
558       gMC->Gspos("FRM5",1, "SQM3", xposFr5, yposFr5, zposFr5,0, "ONLY");
559       gMC->Gspos("FRM5",2, "SQM4", xposFr5, yposFr5, zposFr5,0, "ONLY");
560
561 //......................................................................................
562 //Frame -6 
563  
564       Float_t frame6[3]; 
565       frame6[0] = 1.0/2.;
566       frame6[1] = 2.5/2.;
567       frame6[2] = frame1[2];
568
569       gMC->Gsvolu("FRM6", "BOX", idPGF30, frame6, 3); 
570
571       Float_t rrib6[3];
572       rrib6[0] = frame6[0];
573       rrib6[1] = 1.5/2.;
574       rrib6[2] =(frame2[2]-0.95)/2.0;
575
576       gMC->Gsvolu("FRR6", "BOX", idRoha, rrib6, 3);
577       
578       Float_t xposrrib6 = 0.0;
579       Float_t yposrrib6 = 1.0/2.0;
580       Float_t zposrrib6 = frame6[2] - rrib6[2];
581
582       gMC->Gspos("FRR6",1, "FRM6", xposrrib6, yposrrib6, zposrrib6,0, "ONLY");
583       gMC->Gspos("FRR6",2, "FRM6", xposrrib6, yposrrib6, -zposrrib6,0, "ONLY");
584
585
586
587       Float_t xposFr6 = -frame6[0];
588       Float_t yposFr6 = frame6[1] + 20.6;
589       Float_t zposFr6 = 0.0;
590
591       gMC->Gspos("FRM6",1, "SQM3", xposFr6, yposFr6, zposFr6,0, "ONLY");
592       gMC->Gspos("FRM6",2, "SQM4", xposFr6, yposFr6, zposFr6,0, "ONLY");
593       
594
595 //......................................................................................
596 //Frame - 7 inner pgon
597
598         Float_t pgparFr7[10];
599         pgparFr7[0] = 0.;
600         pgparFr7[1] = 90.;
601         pgparFr7[2] = 5;
602         pgparFr7[3] = 2.;
603         pgparFr7[4] = 0.;
604         pgparFr7[5] = 20.6;
605         pgparFr7[6] = 23.1;
606         pgparFr7[7] = pgparFr7[4] + 5.0;
607         pgparFr7[8] = pgparFr7[5];
608         pgparFr7[9] = pgparFr7[6];
609
610         gMC->Gsvolu("FRM7", "PGON", idPGF30, pgparFr7, 10);
611
612         Float_t pgparRrib7[10];
613         pgparRrib7[0] = 0.;
614         pgparRrib7[1] = 90.;
615         pgparRrib7[2] = 5;
616         pgparRrib7[3] = 2.;
617         pgparRrib7[4] = 0.;
618         pgparRrib7[5] = 21.6;
619         pgparRrib7[6] = 23.1;
620         pgparRrib7[7] = pgparRrib7[4] + 1.55;
621         pgparRrib7[8] = pgparRrib7[5];
622         pgparRrib7[9] = pgparRrib7[6];
623
624         gMC->Gsvolu("FRR7", "PGON", idRoha, pgparRrib7, 10);
625       
626         Float_t xposrrib7 = 0.0;
627         Float_t yposrrib7 = 0.0;
628         Float_t zposrrib7 = 0.0;
629
630         gMC->Gspos("FRR7",1, "FRM7", xposrrib7, yposrrib7, zposrrib7,0, "ONLY");
631
632         zposrrib7 = 3.45;
633
634         gMC->Gspos("FRR7",2, "FRM7", xposrrib7, yposrrib7, zposrrib7,0, "ONLY");
635
636         Float_t xposFr7 = 0.0;
637         Float_t yposFr7 = 0.0;
638         Float_t zposFr7 = -frame1[2];
639
640         gMC->Gspos("FRM7",1, "SQM3", xposFr7, yposFr7, zposFr7,0, "ONLY");
641         gMC->Gspos("FRM7",2, "SQM4", xposFr7, yposFr7, zposFr7,0, "ONLY");
642       
643
644 //......................................................................................
645 //Frame - 8 
646
647
648       Float_t frame8[3] ;
649       frame8[0] = 2.5/2.0;
650       frame8[1] = 1.2/2.0;
651       frame8[2] = frame1[2];
652
653       gMC->Gsvolu("FRM8", "BOX", idPGF30, frame8, 3); //Frame - 2
654
655       Float_t rrib8[3];
656       rrib8[0] = frame8[0]-1.0/2;
657       rrib8[1] = frame8[1];
658       rrib8[2] =(frame8[2]-0.95)/2.0;
659
660       gMC->Gsvolu("FRR8", "BOX", idRoha, rrib8, 3);
661       
662       Float_t xposrrib8 = -1.0/2;
663       Float_t yposrrib8 = 0.0;
664       Float_t zposrrib8 = frame8[2] - rrib8[2];
665
666       gMC->Gspos("FRR8",1, "FRM8", xposrrib8, yposrrib8, zposrrib8,0, "ONLY");
667       gMC->Gspos("FRR8",2, "FRM8", xposrrib8, yposrrib8, -zposrrib8,0, "ONLY");
668
669
670
671       Float_t xposFr8 = frame8[0] + 20.6;
672       Float_t yposFr8 = -frame8[1];
673       Float_t zposFr8 = 0.0;
674
675       gMC->Gspos("FRM8",1, "SQM3", xposFr8, yposFr8, zposFr8,0, "ONLY");
676       gMC->Gspos("FRM8",2, "SQM4", xposFr8, yposFr8, zposFr8,0, "ONLY");
677       
678  
679
680
681 //^^^^^^^^^^^^^^^^^^^^^^^^^ Sensitive volumes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
682
683        Float_t zsenv = 0.5; // distance between two cathode plane
684
685  //Segment-0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
686        bparH[0] = 94.5/2.;
687        bparH[1] = 1.2/2.;
688        bparH[2] = zsenv/2.;
689        gMC->Gsvolu("C3G0", "BOX", idGas, bparH, 3);
690        gMC->Gsvolu("C4G0", "BOX", idGas, bparH, 3);
691
692  //Segment-1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
693         pgpar[0] = 0.;
694         pgpar[1] = 90.;
695         pgpar[2] = 5;
696         pgpar[3] = 2.;
697         pgpar[4] = -zsenv/2.;
698         pgpar[5] = 23.1;
699         pgpar[6] = 117.6;
700         pgpar[7] = zsenv/2.;
701         pgpar[8] = pgpar[5];
702         pgpar[9] = pgpar[6];
703         gMC->Gsvolu("C3G1", "PGON", idGas, pgpar, 10);
704         gMC->Gsvolu("C4G1", "PGON", idGas, pgpar, 10);
705
706
707 //Segment-2 - vertical box ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
708
709         bparV[0] = 1.0/2.;
710         bparV[1] = 95.5/2.;
711         bparV[2] = zsenv/2.;
712         gMC->Gsvolu("C3G2", "BOX", idGas, bparV, 3);
713         gMC->Gsvolu("C4G2", "BOX", idGas, bparV, 3);
714
715 //...........................................................................................
716
717      xposHorBox =  bparH[0] + 23.1;
718      yposHorBox = -bparH[1];
719
720      xposVerBox = -bparV[0];
721      yposVerBox = bparV[1] + 23.1;
722
723      gMC->Gspos("C3G0",1, "SQM3", xposHorBox,yposHorBox,0.,0, "ONLY");
724      gMC->Gspos("C3G1",1, "SQM3", 0.,0.,0.,0, "ONLY");
725      gMC->Gspos("C3G2",1, "SQM3", xposVerBox,yposVerBox,0.,0, "ONLY");
726
727
728      gMC->Gspos("C4G0",1, "SQM4", xposHorBox,yposHorBox,0.,0, "ONLY");
729      gMC->Gspos("C4G1",1, "SQM4", 0.,0.,0.,0, "ONLY");
730      gMC->Gspos("C4G2",1, "SQM4", xposVerBox,yposVerBox,0.,0, "ONLY");
731
732
733 //^^^^^^^^^^^^^^^^^^^^^^^^^ Sensitive volumes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
734
735
736 //##################################################################################################
737 //   Positioning Quadrant  in chamber#3 and chamber#4
738 //##################################################################################################
739 /******Transformations for  Quadrant**********************************************
740       ||        I  => Quadrant I:   no rotation
741       ||
742   II. || I.    II  => Quadrant II:  Reflaction of Quadrant I in XZ plane
743       ||           => TGeoRotation("Qrot2",90.,180.,90.,90.,180.,0.);
744 =============
745       ||       III => Quadrant III: 180 degree rotation of Quadrant I in XY plane
746  III. || IV.       => TGeoRotation("Qrot3",90.,180.,90.,90.,180.,0.);
747       ||        IV => Quadrant IV:-180 degree rotation of Quadrant II in XY plane
748                    => TGeoRotation("Qrot4",90.,0.,90.,-90.,180.,0.);
749 **********************************************************************************************/
750
751  Int_t detElemId1 =  1;  // quadrant I
752  Int_t detElemId2 =  0;  // quadrant II
753  Int_t detElemId3 =  3;  // quadrant III
754  Int_t detElemId4 =  2;  // quadrant IV
755
756  //Float_t halfChamber = zCbb + zCu + zRoha + zMeb + zEeb + zsenv/2;
757 //   cout<<  "\n half_chamber \t" << half_chamber << endl;
758
759  Float_t halfChamber = tpar1[2];// tpar1[2] = 6.8/2;
760
761 // ------------------------------St2 Chamber3------------------------------------------------
762
763  //    GetEnvelopes(2)->AddEnvelope("S3M0", 300, true,TGeoTranslation(0.,0.,0.));
764     GetEnvelopes(2)->AddEnvelope("SQM3", 300+detElemId1, 1, TGeoTranslation( 0., 0., - halfChamber));
765     GetEnvelopes(2)->AddEnvelope("SQM3", 300+detElemId2, 2, TGeoTranslation( 0., 0., + halfChamber),
766                                  TGeoRotation("Qrot3",90.,180.,90.,90.,180.,0.));
767     GetEnvelopes(2)->AddEnvelope("SQM3", 300+detElemId3, 3, TGeoTranslation( 0., 0., - halfChamber),
768                                   TGeoRotation("Qrot3",90.,180.,90.,270.,0.,0.));
769     GetEnvelopes(2)->AddEnvelope("SQM3", 300+detElemId4, 4, TGeoTranslation( 0., 0., + halfChamber),
770                                   TGeoRotation("Qrot4",90.,0.,90.,-90.,180.,0.));
771
772 //--------------------------------St2 Chamber4-------------------------------------------------
773
774     GetEnvelopes(3)->AddEnvelope("SQM4", 400+detElemId1, 1, TGeoTranslation( 0., 0., - halfChamber));
775     GetEnvelopes(3)->AddEnvelope("SQM4", 400+detElemId2, 2, TGeoTranslation( 0., 0., + halfChamber),
776                                  TGeoRotation("Qrot2",90.,180.,90.,90.,180.,0.));
777     GetEnvelopes(3)->AddEnvelope("SQM4", 400+detElemId3, 3, TGeoTranslation( 0., 0., - halfChamber),
778                                   TGeoRotation("Qrot3",90.,180.,90.,270.,0.,0.));
779     GetEnvelopes(3)->AddEnvelope("SQM4", 400+detElemId4, 4, TGeoTranslation( 0., 0., + halfChamber),
780                                   TGeoRotation("Qrot4",90.,0.,90.,-90.,180.,0.));
781
782 //**********************************************************************************************
783
784 }
785 //______________________________________________________________________________
786 void AliMUONSt2GeometryBuilderV2::SetTransformations()
787 {
788 // Defines the transformations for the station2 chambers.
789 // ---
790
791   if (gAlice->GetModule("SHIL")) {
792     SetMotherVolume(2, "YOUT1");
793     SetMotherVolume(3, "YOUT1");
794   }  
795
796   // Define chamber volumes as virtual
797   SetVolume(2, "SC03", true);
798   SetVolume(3, "SC04", true);
799
800   Double_t zpos1 = - AliMUONConstants::DefaultChamberZ(2); 
801   SetTranslation(2, TGeoTranslation(0., 0., zpos1));
802
803   Double_t zpos2 = - AliMUONConstants::DefaultChamberZ(3); 
804   SetTranslation(3, TGeoTranslation(0., 0., zpos2));
805 }
806
807 //______________________________________________________________________________
808 void AliMUONSt2GeometryBuilderV2::SetSensitiveVolumes()
809 {
810 // Defines the sensitive volumes for station2 chambers.
811 // ---
812
813   GetGeometry(2)->SetSensitiveVolume("C3G0");
814   GetGeometry(2)->SetSensitiveVolume("C3G1");
815   GetGeometry(2)->SetSensitiveVolume("C3G2");
816
817   GetGeometry(3)->SetSensitiveVolume("C4G0");
818   GetGeometry(3)->SetSensitiveVolume("C4G1");
819   GetGeometry(3)->SetSensitiveVolume("C4G2");
820 }
821