]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONv2.cxx
Additional protection in the destructor
[u/mrichter/AliRoot.git] / MUON / AliMUONv2.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17 $Log$
18 */
19
20 // Authors: David Guez, Ivana Hrivnacova, Marion MacCormick; IPN Orsay
21 //
22 // Class AliMUONv2
23 // ---------------
24 // Inherits from AliMUONv1 but with a more detailed
25 // geometrical description of station 1 
26
27 #include <algorithm>
28 #include <vector>
29
30 #include <string.h>
31
32 #include <TVector2.h>
33 #include <TClonesArray.h>
34 #include <TLorentzVector.h>
35
36
37 #include "AliMUONv2.h"
38 #include "AliMUONConstants.h"
39 #include "AliMUONHit.h"
40 #include "AliRun.h"
41 #include "AliMagF.h"
42 #include "AliConst.h" 
43
44 #include <MReader.h>
45 #include <MSector.h>
46 #include <MRow.h>
47 #include <MVRowSegment.h>
48 #include <MVMotif.h>
49 #include <MMotifMap.h>
50 #include <MMotifPosition.h>
51 #include <MMotifType.h>
52 #include <MIntPair.h>
53
54
55 #include <Riostream.h>
56
57 ClassImp(AliMUONv2)
58
59
60
61 const GReal_t AliMUONv2::fgkHzPadPlane=0.0148/2.; //Pad plane
62 const GReal_t AliMUONv2::fgkHzFoam = 2.083/2.; // Foam of mechanicalplane
63 const GReal_t AliMUONv2::fgkHzFR4 = 0.0031/2.; // FR4 of mechanical plane
64 const GReal_t AliMUONv2::fgkHzSnPb = 0.0091/2.; //Pad/Kapton connection (66 pt)
65 const GReal_t AliMUONv2::fgkHzKapton = 0.0122/2.; //Kapton
66 const GReal_t AliMUONv2::fgkHzBergPlastic = 0.3062/2.; //Berg connector
67 const GReal_t AliMUONv2::fgkHzBergCopper = 0.1882/2.; //Berg connector
68 const GReal_t AliMUONv2::fgkHzDaughter = 0.0156/2.; //Daughter board
69 const GReal_t AliMUONv2::fgkHzGas = 0.2/2.; //Gas
70 const GReal_t AliMUONv2::fgkHxQuadrant = 94.69/2.; //Box surrounding quadrant
71 const GReal_t AliMUONv2::fgkHyQuadrant = 100.31/2.; //Box surrounding quadrant
72 const GReal_t AliMUONv2::fgkMotherIR = 18.3;
73 const GReal_t AliMUONv2::fgkMotherOR = 104.974;   
74 const GReal_t AliMUONv2::fgkMotherThick = 6.5/2; //6.5cm between two quadrants 
75 const GReal_t AliMUONv2::fgkMotherPhiL = 0.; 
76 const GReal_t AliMUONv2::fgkMotherPhiU = 90.;
77
78
79 const GReal_t AliMUONv2::fgkHxHole=1.5/2.;
80 const GReal_t AliMUONv2::fgkHyHole=6./2.;
81 const GReal_t AliMUONv2::fgkHxBergPlastic=0.74/2.;
82 const GReal_t AliMUONv2::fgkHyBergPlastic=5.09/2.;
83 const GReal_t AliMUONv2::fgkHxBergCopper=0.25/2.;
84 const GReal_t AliMUONv2::fgkHyBergCopper=3.6/2.;
85 const GReal_t AliMUONv2::fgkHxKapton=0.8/2.;
86 const GReal_t AliMUONv2::fgkHyKapton=5.7/2.;
87 const GReal_t AliMUONv2::fgkHxDaughter=2.3/2.;
88 const GReal_t AliMUONv2::fgkHyDaughter=6.3/2.;
89 const GReal_t AliMUONv2::fgkOffsetX=1.46;
90 const GReal_t AliMUONv2::fgkOffsetY=0.71;
91 const GReal_t AliMUONv2::fgkDeltaFilleEtamX=0.;
92 const GReal_t AliMUONv2::fgkDeltaFilleEtamY=0.5;
93
94 const char* AliMUONv2::fgkHoleName="MCHL";
95 const char* AliMUONv2::fgkDaughterName="MCDB";
96 const char  AliMUONv2::fgkFoamLayerSuffix='F';
97 const char* AliMUONv2::fgkQuadrantName="QUA";
98
99 //___________________________________________
100 AliMUONv2::AliMUONv2()
101   : AliMUONv1(),
102     fIdSens(0)
103 {
104 // Default Constructor
105 //
106
107    // keep secondaries
108    SetIshunt(0);
109 }
110  
111 //___________________________________________
112 AliMUONv2::AliMUONv2(const char *name, const char *title)
113   : AliMUONv1(name,title),
114     fIdSens(0)
115 {
116    // keep secondaries
117    SetIshunt(0);
118
119    // create hits array
120    fHits     = new TClonesArray("AliMUONHit",1000);
121    gAlice->AddHitList(fHits);
122 }
123  
124 //___________________________________________
125 AliMUONv2::AliMUONv2(const AliMUONv2& rMUON)
126 {
127 // Dummy copy constructor
128 }
129
130 //___________________________________________
131 AliMUONv2::~AliMUONv2()
132 {
133 // Destructor
134     if(fDebug) printf("%s: Calling AliMUONv2 destructor !!!\n",ClassName());
135     
136     if (fHits) {
137       fHits->Delete();
138       delete fHits;
139     }
140 }
141
142 //___________________________________________
143 void AliMUONv2::CreateGeometry()
144 {
145 // Create the GEANT geometry for the dimuon arm.
146 // Use the parent's method for stations 2, 3, 4 and 5.
147 // Use the detailed code for the first station.
148 // --
149   cout << "AliMUONv2::CreateGeometry()" << endl;
150   cout << "_________________________________________" << endl;
151
152   // tracking medias
153   Int_t* idtmed = fIdtmed->GetArray()-1099;
154   Int_t idAir  = idtmed[1100];       // medium 1
155
156
157
158   //create reflexion matrix
159   Int_t reflXZ,reflYZ,reflXY;
160   AliMatrix(reflXZ,  90.,  180., 90., 90., 180., 0.);
161   AliMatrix(reflYZ,  90., 0., 90.,-90., 180., 0.);
162   AliMatrix(reflXY,  90., 180., 90., 270., 0., 0.);
163
164   CreateHole();
165   CreateDaughterBoard();
166
167   //build the quadrant
168   CreateQuadrant(1);
169   CreateQuadrant(2);
170   GReal_t par[5];
171   par[0] = fgkMotherIR;
172   par[1] = fgkMotherOR; 
173   par[2] = fgkHzGas;  
174   par[3] = fgkMotherPhiL; 
175   par[4] = fgkMotherPhiU;
176
177   gMC->Gsvolu("S01G","TUBS",idAir,par,5);
178   gMC->Gspos("S01G",1,QuadrantName(1),0,0,0,0,"ONLY");
179   gMC->Gsvolu("S02G","TUBS",idAir,par,5);
180   gMC->Gspos("S02G",1,QuadrantName(2),0,0,0,0,"ONLY");
181
182   // place the four copies of it
183   
184   //parameters
185   TVector3 pos[4];
186   Int_t rotm[4];
187   
188   Double_t deltaZ = 6.5/2.; 
189   pos[0]=TVector3(-2.6,-2.6,AliMUONConstants::DefaultChamberZ(0)+deltaZ);
190   rotm[0]=0;
191   pos[1]=TVector3(2.6,-2.6,AliMUONConstants::DefaultChamberZ(0)-deltaZ);
192   rotm[1]=reflXZ;
193   pos[2]=TVector3(2.6,2.6,AliMUONConstants::DefaultChamberZ(0)+deltaZ);
194   rotm[2]=reflXY;
195   pos[3]=TVector3(-2.6,2.6,AliMUONConstants::DefaultChamberZ(0)-deltaZ);
196   rotm[3]=reflYZ;
197   
198   //placing
199   GReal_t posX,posY,posZ;
200   for (Int_t i=0;i<4;i++){
201     posX=pos[i].X();
202     posY=pos[i].Y();
203     // the 1st chamber
204     posZ=pos[i].Z();
205     gMC->Gspos(QuadrantName(1),i+1,"ALIC",posX,posY,posZ,rotm[i],"ONLY");
206     // the 2nd chamber
207     posZ=pos[i].Z()+AliMUONConstants::DefaultChamberZ(1)
208          -AliMUONConstants::DefaultChamberZ(0);
209     gMC->Gspos(QuadrantName(2),i+5,"ALIC",posX,posY,posZ,rotm[i],"ONLY");
210   }
211   static Int_t stations[5]={0,1,1,1,1};
212   fStations=stations;
213   AliMUONv1::CreateGeometry();
214 }
215 //___________________________________________
216 void AliMUONv2::CreateQuadrant(Int_t chamber)
217 {
218 // create the quadrant (bending and non-bending planes)
219 // for the given chamber
220 // --
221   CreateFrame(chamber);
222
223   TSpecialMap specialMap;  
224
225   TVector3 where;
226   specialMap[1001] = AliMUONSt1SpecialMotif(TVector2(0.1 ,0.84),90.);
227   specialMap[1002] = AliMUONSt1SpecialMotif(TVector2(0.5 ,0.76));
228   specialMap[1003] = AliMUONSt1SpecialMotif(TVector2(1.01,0.76));
229   MReader reader1(kBendingPlane);
230   MSector* sector1 = reader1.BuildSector();
231   where=TVector3(0.185+2.6,-0.52+2.6,totalHz()+fgkHzGas);
232   PlaceSector(sector1,specialMap,where,chamber);
233   
234
235   specialMap.clear();
236   specialMap[4001] = AliMUONSt1SpecialMotif(TVector2(1.01,0.59),90.);
237   specialMap[4002] = AliMUONSt1SpecialMotif(TVector2(1.96, 0.17));
238   specialMap[4003] = AliMUONSt1SpecialMotif(TVector2(1.61,-1.18));
239   specialMap[4004] = AliMUONSt1SpecialMotif(TVector2(0.2 ,-0.08));
240   specialMap[4005] = AliMUONSt1SpecialMotif(TVector2(0.2 , 0.25));
241   specialMap[4006] = AliMUONSt1SpecialMotif(TVector2(0.28, 0.21));
242
243   MReader reader2(kNonBendingPlane);
244   MSector* sector2 = reader2.BuildSector();
245   where=TVector3(-0.13+2.6,-0.1775+2.6,-totalHz()-fgkHzGas);
246   PlaceSector(sector2,specialMap,where,chamber);
247 }
248
249 //___________________________________________
250 void AliMUONv2::CreateMaterials()
251 {
252 // --- Define the various mixtures for GEANT ---
253   
254   //     Ar-CO2 gas (80%+20%)
255   Float_t ag1[2]   = { 39.95,44.01};
256   Float_t zg1[2]   = { 18.,22.};
257   Float_t dg1      = .001821;
258   Float_t wg1[2]   = { .8,0.2};
259   // use wg1 weighting factors (6th arg > 0)
260   AliMixture(22, "ArCO2 80%$", ag1, zg1, dg1, 2, wg1);  
261
262   //     Ar-buthane-freon gas -- trigger chambers 
263   Float_t atr1[4]  = { 39.95,12.01,1.01,19. };
264   Float_t ztr1[4]  = { 18.,6.,1.,9. };
265   Float_t wtr1[4]  = { .56,.1262857,.2857143,.028 };
266   Float_t dtr1     = .002599;
267   AliMixture(23, "Ar-freon $", atr1, ztr1, dtr1, 4, wtr1);
268
269   // Rohacell 51  - imide methacrylique
270   Float_t aRohacell51[4] = {12.01,1.01,16.00,14.01}; 
271   Float_t zRohacell51[4] = {6.,1.,8.,7.}; 
272   Float_t dRohacell51 = 0.052;
273   Float_t wRohacell51[4] = {9.,13.,2.,1.};  
274   // use relative A (molecular) values (6th arg < 0)
275   AliMixture(32, "FOAM$",aRohacell51,zRohacell51,dRohacell51,-4,wRohacell51);  
276    
277   Float_t aSnPb[2] = {118.69,207.19};
278   Float_t zSnPb[2] = {50,82};
279   Float_t dSnPb = 8.926;
280   Float_t wSnPb[2] = {0.6, 0.4} ;
281   // use wSnPb weighting factors (6th arg > 0)
282   AliMixture(35, "SnPb$", aSnPb,zSnPb,dSnPb,2,wSnPb);
283
284   // plastic definition from K5, Freiburg (found on web)
285   Float_t aPlastic[2]={1.01,12.01};
286   Float_t zPlastic[2]={1,6};
287   Float_t denPlastic=1.107;
288   Float_t wPlastic[2]={1,1};
289   // use relative A (molecular) values (6th arg < 0)...no other info...
290   AliMixture( 33, "Plastic$",aPlastic,zPlastic,denPlastic,-2,wPlastic);
291  
292   // from CERN note NUFACT Note023, Oct.2000 
293   // Inox/Stainless Steel (18%Cr, 9%Ni)
294   Float_t aInox[3] = {55.847,51.9961,58.6934};  
295   Float_t zInox[3] = {26.,24.,28.};
296   Float_t denInox = 7.930;
297   Float_t wInox[3] = {0.73,0.18,0.09}; 
298   // use wInox weighting factors (6th arg > 0) 
299   AliMixture(37, "StainlessSteel$",aInox,zInox,denInox,3,wInox);   
300
301   // bakelite 
302   Float_t abak[3] = {12.01 , 1.01 , 16.};
303   Float_t zbak[3] = {6.     , 1.   , 8.};
304   Float_t wbak[3] = {6.     , 6.   , 1.}; 
305   Float_t dbak = 1.4;
306   AliMixture(19, "Bakelite$", abak, zbak, dbak, -3, wbak);
307   
308   // Ar-Isobutane gas (80%+20%) 
309   Float_t ag[3]    = { 39.95,12.01,1.01 };
310   Float_t zg[3]    = { 18.,6.,1. };
311   Float_t wg[3]    = { .8,.057,.143 };
312   Float_t dg       = .0019596;
313   AliMixture(20, "ArC4H10 GAS$", ag, zg, dg, 3, wg);
314
315   //     Ar-Isobutane-Forane-SF6 gas (49%+7%+40%+4%) -- trigger 
316   Float_t atrig[5] = { 39.95,12.01,1.01,19.,32.066 };
317   Float_t ztrig[5] = { 18.,6.,1.,9.,16. };
318   Float_t wtrig[5] = { .49,1.08,1.5,1.84,0.04 };
319   Float_t dtrig    = .0031463;
320   AliMixture(21, "TRIG GAS$", atrig, ztrig, dtrig, -5, wtrig);
321   
322   //     Ar-CO2 gas 
323   Float_t agas[3]  = { 39.95,12.01,16. };
324   Float_t zgas[3]  = { 18.,6.,8. };
325   Float_t wgas[3]  = { .74,.086684,.173316 };
326   Float_t dgas     = .0018327;
327   AliMixture(24, "ArCO2 GAS$", agas, zgas, dgas, 3, wgas); 
328    
329 // --- Define the various AliMaterials for GEANT ---
330   // from PDG and "The Particle Detector BriefBook", Bock and Vasilescu, P.18  
331   AliMaterial( 9, "Aluminium$", 26.98, 13., 2.7, -8.9, 26.1);
332   AliMaterial(10, "Aluminium$", 26.98, 13., 2.7, -8.9, 26.1);
333   AliMaterial(15, "air$", 14.61, 7.3, .001205, -30423.24, 67500);
334   AliMaterial(30, "Copper$", 63.546,29.,8.96,-1.43,9.6);
335   AliMaterial(31, "FR4$", 17.749, 8.875, 1.7, -19.4, 999.);    // from DPG
336   AliMaterial(34, "Kapton$", 12.01,6,1.42,-28.6,999);          // from DPG
337  // Density of FrameEpoxy only from manufacturer's specifications
338  // Frame composite epoxy , X0 in g/cm**2 (guestimation!)
339   AliMaterial(36, "FrameEpoxy",12.24,6.0,1.85,-19.14,999);
340   
341 // --- Define the tracking medias (AliMediums) for GEANT ---
342   GReal_t epsil  = .001; // Tracking precision,
343   GReal_t stemax = -1.;  // Maximum displacement for multiple scat
344   GReal_t tmaxfd = -20.; // Maximum angle due to field deflection
345   GReal_t deemax = -.3;  // Maximum fractional energy loss, DLS
346   GReal_t stmin  = -.8;
347   GReal_t maxStepAlu = 0.001;  // from AliMUON.cxx
348   GReal_t maxDestepAlu = -1.; // from AliMUON.cxx
349   GReal_t maxStepGas=0.01;  // from AliMUON.cxx
350
351   Int_t iSXFLD   = gAlice->Field()->Integ();
352   Float_t sXMGMX = gAlice->Field()->Max();
353
354   AliMedium(1, "AIR_CH_US$", 15, 1, iSXFLD, sXMGMX, tmaxfd,
355             stemax, deemax, epsil, stmin);
356   AliMedium(4, "ALU_CH_US$", 9, 0, iSXFLD, sXMGMX, tmaxfd,
357             maxStepAlu, maxDestepAlu, epsil, stmin);
358   AliMedium(5, "ALU_CH_US$", 10, 0, iSXFLD, sXMGMX, tmaxfd,
359             maxStepAlu,maxDestepAlu, epsil, stmin);  
360   AliMedium(6, "AR_CH_US          ", 20, 1, iSXFLD, sXMGMX, 
361               tmaxfd, fMaxStepGas,fMaxDestepGas, epsil, stmin);
362               
363   //    Ar-Isobuthane-Forane-SF6 gas 
364   AliMedium(7, "GAS_CH_TRIGGER    ", 21, 1, iSXFLD, sXMGMX, 
365                tmaxfd, stemax, deemax, epsil, stmin);
366   AliMedium(8, "BAKE_CH_TRIGGER   ", 19, 0, iSXFLD, sXMGMX, 
367                tmaxfd, fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
368
369   AliMedium(9, "ARG_CO2$", 22, 1, iSXFLD, sXMGMX, tmaxfd, maxStepGas,
370               maxDestepAlu, epsil, stmin);
371   AliMedium(10, "COPPER_CH$", 30, 0, iSXFLD, sXMGMX, tmaxfd,
372               maxStepAlu, maxDestepAlu, epsil, stmin);
373   AliMedium(11, "PCB_COPPER        ", 31, 0, iSXFLD, sXMGMX, tmaxfd, 
374                 fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
375   AliMedium(12, "VETRONITE         ", 32, 0, iSXFLD, sXMGMX, tmaxfd, 
376                 fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
377   AliMedium(13, "CARBON            ", 33, 0, iSXFLD, sXMGMX, tmaxfd, 
378                 fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
379   AliMedium(14, "Rohacell          ", 34, 0, iSXFLD, sXMGMX, tmaxfd, 
380               fMaxStepAlu, fMaxDestepAlu, epsil, stmin);
381   AliMedium(15, "FR4_CH$",  31, 0,iSXFLD, sXMGMX, 10., .01,.1, .003, .003);
382   AliMedium(16, "FOAM_CH$", 32, 0,
383               iSXFLD, sXMGMX, 10.0, 0.1, 0.1, 0.1, 0.1, 0, 0) ;
384   AliMedium(17, "Plastic$", 33, 0,iSXFLD, sXMGMX,  10., .01, 1., .003, .003);
385   AliMedium(18, "Kapton$", 34, 0,iSXFLD, sXMGMX,  10., .01, 1., .003, .003);
386   AliMedium(19, "SnPb$", 35, 0,iSXFLD, sXMGMX,  10., .01,  1., .003, .003);
387   AliMedium(20, "FrameCH$", 36, 1,iSXFLD, sXMGMX,  10., .001, 0.001, .001, .001);
388   AliMedium(21, "InoxBolts$", 37,1,iSXFLD, sXMGMX,  10., .01, 1., .003, .003);
389 }
390
391 void AliMUONv2::CreateFrame(Int_t chamber)
392 {
393 // Create the non-sensitive elements of the frame for the  <chamber>
394
395
396 // Matrices
397       Int_t idrotm[1199];   
398 // To Be Checked....
399 //   Rotation matrices in the x-y plane  
400 //   phi =   -45 deg
401      AliMatrix(idrotm[1101],  90.,   315., 90.,  45., 0., 0.);
402 //   phi =  -90 deg
403      AliMatrix(idrotm[1102],  90.,  90., 90., 180., 0., 0.);
404 //   theta =  +90 deg
405      AliMatrix(idrotm[1103],  180.,  0., 90., 90.,90., 0.);
406       
407 //   phi =   +45 deg
408      AliMatrix(idrotm[1104],  90.,   45., 90.,  135., 0., 0.);
409 //   phi =  +45 deg + rotation 180° around Y 
410      AliMatrix(idrotm[1105],  90.,  45., 90., 315., 180., 0.);
411
412 //   Translation matrices in the x-y plane  
413 //   X -> X ; Y -> Y; Z -> Z
414      AliMatrix(idrotm[1110],  90.,   0., 90.,  90., 0., 0.);
415 //   X->-X; Y -> Y; Z -> -Z
416      AliMatrix(idrotm[1111],  90.,  180., 90., 90., 180., 0.);
417 //   X->-X; Y ->-Y; Z -> Z
418      AliMatrix(idrotm[1112],  90., 180., 90., 270., 0., 0.);
419 //   X->X; Y ->-Y; Z -> -Z
420      AliMatrix(idrotm[1113],  90., 0., 90., 270., 180., 0.);
421 //   
422  
423   // tracking medias
424   Int_t* idtmed = fIdtmed->GetArray()-1099;
425
426   Int_t idAir  = idtmed[1100];       // medium 1
427   Int_t idSolder = idtmed[1118];     // medium 19
428   Int_t idFrameEpoxy = idtmed[1119]; // medium 20 = Frame Epoxy ME730
429   Int_t idInox = idtmed[1120];       // medium 21 Stainless Steel (18%Cr,9%Ni,Fe)
430
431 //________________________________________________________________
432 // 
433 // Original model:
434 //
435 // Epoxy Frame segments
436 //  
437 //                         OutTopTrapFrame
438 //                              ------------ |
439 //      OutEdgeTrapFrame      /              |
440 //                           /               |  InVFrame
441 //       OutCornerTrapFrame /                |
442 //                          |              --|   
443 //             OutVFrame    |            _-  InArcFrame
444 //                          |___________|
445 //                             InHFrame
446 //                          
447 //
448 // DATE: 27 NOVEMBER 2002 - MODEL UPDATED. THE MOTHER VOLUME IS A TUBS.
449 //__________________________________________________________________
450
451   const Float_t hzFrameThickness = 1.186/2.;   //equivalent thickness
452   const Float_t hzOuterFrameEpoxy = 1.23/2.;   //equivalent thickness
453   const Float_t hzOuterFrameSolder = 0.032/2.; //equivalent thickness
454   const Float_t hzOuterFrameInox = 0.035/2.;   //equivalent thickness
455       
456   // InHFrame parameters
457   const Float_t hxInHFrame  = 75.8/2.;
458   const Float_t hyInHFrame  = 2.5/2.;
459   const Float_t hzInHFrame  = hzFrameThickness;
460  
461   // InVFrame parameters
462   const Float_t hxInVFrame  = 2.5/2.;
463   const Float_t hyInVFrame  = 73.3/2.;
464   const Float_t hzInVFrame  = hzFrameThickness;
465
466   //Flat 1mm vertical section
467   const Float_t hxV1mm  = 0.1/2.;
468   const Float_t hyV1mm  = 2.5/2.;
469   const Float_t hzV1mm  = hzFrameThickness;
470   
471   //Flat 1mm horizontal section
472   const Float_t hxH1mm  = 2.5/2.;
473   const Float_t hyH1mm  = 0.1/2.;
474   const Float_t hzH1mm  = hzFrameThickness;
475    
476   // InArcFrame parameters
477   const Float_t IAF  = 15.70;
478   const Float_t OAF  = 18.20;
479   const Float_t hzAF  = hzFrameThickness;
480   const Float_t AFphi1  = 0.0;
481   const Float_t AFphi2  = 90.0;
482
483   // ScrewsInFrame parameters HEAD
484   const Float_t SCRUHMI  = 0.;
485   const Float_t SCRUHMA  = 0.690/2.;
486   const Float_t SCRUHLE  = 0.4/2.;
487     // ScrewsInFrame parameters MIDDLE
488   const Float_t SCRUMMI  = 0.;
489   const Float_t SCRUMMA  = 0.39/2.;
490   const Float_t SCRUMLE  = hzFrameThickness;
491     // ScrewsInFrame parameters NUT
492   const Float_t SCRUNMI  = 0.;
493   const Float_t SCRUNMA  = 0.78/2.;
494   const Float_t SCRUNLE  = 0.8/2.;
495
496   // OutVFrame parameters
497   const Float_t hxOutVFrame  = 2.5/2.;
498   const Float_t hyOutVFrame  = 43.927/2.;
499   const Float_t hzOutVFrame  = hzFrameThickness;
500   
501 /////////////////////////////////////////////////////// 
502
503 // OutTopCuboidFrame Epoxy parameters
504   const Float_t hxOutHFrame  = 31.9304/2.;
505   const Float_t hyOutHFrame  = 8.4/2.;
506   const Float_t hzOutHFrame  = hzOuterFrameEpoxy;
507   
508 // OutTopTrapFrameA Epoxy parameters
509   const Float_t hzOTTFA = hzOuterFrameEpoxy;
510   const Float_t tetOTTFA = 0.;
511   const Float_t phiOTTFA = 0.;
512   const Float_t h1OTTFA = 9.6716/2.;
513   const Float_t bl1OTTFA = 4.7787/2.;
514   const Float_t tl1OTTFA =  8.4/2.;
515   const Float_t alp1OTTFA = 10.6; 
516   const Float_t h2OTTFA = 9.6716/2.;
517   const Float_t bl2OTTFA = 4.7787/2.;
518   const Float_t tl2OTTFA = 8.4/2.;
519   const Float_t alp2OTTFA = 10.6;  
520   
521 // OutTopTrapFrameB Epoxy parameters
522   const Float_t hzOTTFB = hzOuterFrameEpoxy;
523   const Float_t tetOTTFB = 0.;
524   const Float_t phiOTTFB = 0.;
525   const Float_t h1OTTFB = 9.6716/2.;
526   const Float_t bl1OTTFB = 0.;
527   const Float_t tl1OTTFB =  4.7787/2.;
528   const Float_t alp1OTTFB = 13.88; 
529   const Float_t h2OTTFB = 9.6716/2.;
530   const Float_t bl2OTTFB = 0.;
531   const Float_t tl2OTTFB = 4.7787/2.;
532   const Float_t alp2OTTFB = 13.88;
533
534   // OutTopTrapFrame Solder parameters
535   const Float_t hzOTTFS = hzOuterFrameSolder;
536   
537   // OutTopTrapFrame Inox parameters
538   const Float_t hzOTTFI = hzOuterFrameInox;
539  
540 /////////////////////////////////////////////////////////  
541
542   // OutEdgeTrapFrame parameters 
543   // TRAPEZE 1
544   const Float_t hzOETF = hzOuterFrameEpoxy;   
545   const Float_t tetOETF = 0.;
546   const Float_t phiOETF = 0.;
547   const Float_t h1OETF = 7.129/2.; 
548   const Float_t bl1OETF1 = 3.705/2; 
549   const Float_t tl1OETF1 = 3.9471/2.;
550   const Float_t alp1OETF1 = 0.97;
551   const Float_t h2OETF = 7.129/2.;    
552   const Float_t bl2OETF1 = 3.705/2;
553   const Float_t tl2OETF1 = 3.9471/2.;
554   const Float_t alp2OETF1 = 0.97;
555   
556   // TRAPEZE 2
557   const Float_t bl1OETF2 = 2.9744/2.;
558   const Float_t tl1OETF2 =  3.705/2;
559   const Float_t alp1OETF2 =  2.93;
560       
561   const Float_t bl2OETF2 =  2.9744/2.;
562   const Float_t tl2OETF2 =  3.705/2;
563   const Float_t alp2OETF2 =  2.93; 
564    
565   // TRAPEZE 3
566   const Float_t bl1OETF3 = 1.7455/2.;
567   const Float_t tl1OETF3 =  2.9744/2.;
568   const Float_t alp1OETF3 =  4.93;
569       
570   const Float_t bl2OETF3 = 1.7455/2.;
571   const Float_t tl2OETF3 = 2.9744/2.; 
572   const Float_t alp2OETF3 =  4.93; 
573   
574   // TRAPEZE 4
575   const Float_t bl1OETF4 = 0.;
576   const Float_t tl1OETF4 =  1.7455/2.;
577   const Float_t alp1OETF4 =  6.98;
578       
579   const Float_t bl2OETF4 = 0.;
580   const Float_t tl2OETF4 = 1.7455/2.;
581   const Float_t alp2OETF4 =  6.98;   
582  
583  ///////////////////////////////////////////////////
584     
585   // OutCornerTrapFrame parameters
586   const Float_t hzOCTF = hzFrameThickness;
587   const Float_t tetOCTF = 0.;
588   const Float_t phiOCTF = 0.;
589   const Float_t h1OCTF = 2.5/2.;
590   const Float_t bl1OCTF = 0.;
591   const Float_t tl1OCTF =  4.7469/2.;
592   const Float_t alp1OCTF = 43.51; 
593   const Float_t h2OCTF = 2.5/2.;
594   const Float_t bl2OCTF = 0.;
595   const Float_t tl2OCTF = 4.7469/2.;
596   const Float_t alp2OCTF = 43.51;  
597
598   // Reference point - MIRE (3 per quadrant, only 1 programmed)
599   const Float_t MIREInRad  = 0.6;
600   const Float_t MIREOutRad  = 1.3;
601   const Float_t MIRELen  = hzFrameThickness;
602        
603   Float_t par[11];
604   Float_t posX,posY,posZ;
605        
606 // ___________________Make volumes________________________
607
608 // Quadrant volume
609     par[0] = fgkMotherIR;
610     par[1] = fgkMotherOR; 
611     par[2] = fgkMotherThick;  
612     par[3] = fgkMotherPhiL; 
613     par[4] = fgkMotherPhiU;
614
615     //Quadrant volume.....positionned at the end
616     gMC->Gsvolu(QuadrantName(chamber),"TUBS",idAir,par,5);
617             
618 // _______________________________________________________
619 // InVFrame  
620    if (chamber==1) {   
621       // simple epoxy layer...must be inside sensitive surface for tracking
622       par[0] = hxInVFrame;
623       par[1] = hyInVFrame;
624       par[2] = hzInVFrame;
625       
626       gMC->Gsvolu("IVEF","BOX",idFrameEpoxy,par,3);
627
628   // InHFrame
629       par[0] = hxInHFrame;
630       par[1] = hyInHFrame;
631       par[2] = hzInHFrame;
632
633       gMC->Gsvolu("IHEF","BOX",idFrameEpoxy,par,3);
634
635   //Flat 1mm vertical section
636       par[0] = hxV1mm;
637       par[1] = hyV1mm;
638       par[2] = hzV1mm;
639
640       gMC->Gsvolu("FVMM","BOX",idFrameEpoxy,par,3);
641
642   //Flat 1mm vertical section
643       par[0] = hxH1mm;
644       par[1] = hyH1mm;
645       par[2] = hzH1mm;
646
647       gMC->Gsvolu("FHMM","BOX",idFrameEpoxy,par,3);
648
649   // OutVFrame
650       par[0] = hxOutVFrame;
651       par[1] = hyOutVFrame;
652       par[2] = hzOutVFrame;
653
654       gMC->Gsvolu("OVEF","BOX",idFrameEpoxy,par,3);
655
656   // InArcFrame 
657       par[0] = IAF;
658       par[1] = OAF; 
659       par[2] = hzAF;  
660       par[3] = AFphi1; 
661       par[4] = AFphi2 ;
662
663       gMC->Gsvolu("IAF1","TUBS",idFrameEpoxy,par,5);
664
665   // ScrewsInFrame - 3 sections in order to avoid overlapping volumes
666   // Screw Head, in air
667       par[0] = SCRUHMI;
668       par[1] = SCRUHMA; 
669       par[2] = SCRUHLE;  
670
671       gMC->Gsvolu("SCRH","TUBE",idInox,par,3);
672
673   // Middle part, in the Epoxy
674       par[0] = SCRUMMI;
675       par[1] = SCRUMMA;
676       par[2] = SCRUMLE;
677       
678       gMC->Gsvolu("SCRM","TUBE",idInox,par,3);
679
680   // Screw nut, in air
681       par[0] = SCRUNMI;
682       par[1] = SCRUNMA;
683       par[2] = SCRUNLE; 
684         
685       gMC->Gsvolu("SCRN","TUBE",idInox,par,3);   
686
687   ///////////////////////////////////////////
688
689   // OutTopTrapFrame Epoxy 
690   // - 3 components (cuboid and 2 trapezes) and 3 layers (Epoxy/Inox/Solder)
691
692   // OutTopCuboidFrame Epoxy 
693       par[0] = hxOutHFrame;
694       par[1] = hyOutHFrame;
695       par[2] = hzOutHFrame;
696       
697       gMC->Gsvolu("OHEA","BOX",idFrameEpoxy,par,3);
698
699   // OutTopTrapFrameA Epoxy parameters    
700       par[0] = hzOTTFA;
701       par[1] = tetOTTFA;
702       par[2] = phiOTTFA;
703       par[3] = h1OTTFA;
704       par[4] = bl1OTTFA;
705       par[5] = tl1OTTFA;
706       par[6] = alp1OTTFA;
707       par[7] = h2OTTFA;
708       par[8] = bl2OTTFA;
709       par[9] = tl2OTTFA;
710       par[10] = alp2OTTFA;
711
712       gMC->Gsvolu("OHEB","TRAP",idFrameEpoxy,par,11);    
713
714   // OutTopTrapFrameB Epoxy parameters    
715       par[0] = hzOTTFB;
716       par[1] = tetOTTFB;
717       par[2] = phiOTTFB;
718       par[3] = h1OTTFB;
719       par[4] = bl1OTTFB;
720       par[5] = tl1OTTFB;
721       par[6] = alp1OTTFB;
722       par[7] = h2OTTFB;
723       par[8] = bl2OTTFB;
724       par[9] = tl2OTTFB;
725       par[10] = alp2OTTFB;
726
727       gMC->Gsvolu("OHEC","TRAP",idFrameEpoxy,par,11);    
728
729   // OutTopCuboidFrame Solder 
730       par[0] = hxOutHFrame;
731       par[1] = hyOutHFrame;
732       par[2] = hzOTTFS;
733       gMC->Gsvolu("OHSA","BOX",idSolder,par,3);
734
735   // OutTopTrapFrameA Solder 
736       par[0] = hzOTTFS;
737       par[1] = tetOTTFA;
738       par[2] = phiOTTFA;
739       par[3] = h1OTTFA;
740       par[4] = bl1OTTFA;
741       par[5] = tl1OTTFA;
742       par[6] = alp1OTTFA;
743       par[7] = h2OTTFA;
744       par[8] = bl2OTTFA;
745       par[9] = tl2OTTFA;
746       par[10] = alp2OTTFA;
747
748       gMC->Gsvolu("OHSB","TRAP",idSolder,par,11); 
749
750
751   // OutTopTrapFrameB Solder 
752       par[0] = hzOTTFI;
753       par[1] = tetOTTFB;
754       par[2] = phiOTTFB;
755       par[3] = h1OTTFB;
756       par[4] = bl1OTTFB;
757       par[5] = tl1OTTFB;
758       par[6] = alp1OTTFB;
759       par[7] = h2OTTFB;
760       par[8] = bl2OTTFB;
761       par[9] = tl2OTTFB;
762       par[10] = alp2OTTFB;
763
764       gMC->Gsvolu("OHSC","TRAP",idSolder,par,11);  
765
766   // OutTopCuboidFrame Solder 
767       par[0] = hxOutHFrame;
768       par[1] = hyOutHFrame;
769       par[2] = hzOTTFI;
770       gMC->Gsvolu("OHIA","BOX",idInox,par,3);
771
772   // OutTopTrapFrameA Inox 
773       par[0] = hzOTTFI;
774       par[1] = tetOTTFA;
775       par[2] = phiOTTFA;
776       par[3] = h1OTTFA;
777       par[4] = bl1OTTFA;
778       par[5] = tl1OTTFA;
779       par[6] = alp1OTTFA;
780       par[7] = h2OTTFA;
781       par[8] = bl2OTTFA;
782       par[9] = tl2OTTFA;
783       par[10] = alp2OTTFA;
784
785       gMC->Gsvolu("OHIB","TRAP",idInox,par,11); 
786
787   // OutTopTrapFrameB Inox 
788       par[0] = hzOTTFI;
789       par[1] = tetOTTFB;
790       par[2] = phiOTTFB;
791       par[3] = h1OTTFB;
792       par[4] = bl1OTTFB;
793       par[5] = tl1OTTFB;
794       par[6] = alp1OTTFB;
795       par[7] = h2OTTFB;
796       par[8] = bl2OTTFB;
797       par[9] = tl2OTTFB;
798       par[10] = alp2OTTFB;
799
800       gMC->Gsvolu("OHIC","TRAP",idInox,par,11);
801
802   /////////////////////////////////
803
804   // OutEdgeTrapFrame Epoxy = (4 trapezes)*2 copies*3 layers (Epoxy/Inox/Solder)
805   // TRAPEZE 1
806       par[0] = hzOETF;
807       par[1] = tetOETF;
808       par[2] = phiOETF;
809       par[3] = h1OETF;
810       par[4] = bl1OETF1;
811       par[5] = tl1OETF1;
812       par[6] = alp1OETF1;
813       par[7] = h2OETF;
814       par[8] = bl2OETF1;
815       par[9] = tl2OETF1;
816       par[10] = alp2OETF1;
817
818       gMC->Gsvolu("EDE1","TRAP",idFrameEpoxy,par,11);  
819
820   // TRAPEZE 2
821       par[4] = bl1OETF2;
822       par[5] = tl1OETF2;
823       par[6] = alp1OETF2;
824
825       par[8] = bl2OETF2;
826       par[9] = tl2OETF2;
827       par[10] = alp2OETF2; 
828      gMC->Gsvolu("EDE2","TRAP",idFrameEpoxy,par,11);  
829
830   // TRAPEZE 3
831       par[4] = bl1OETF3;
832       par[5] = tl1OETF3;
833       par[6] = alp1OETF3;
834
835       par[8] = bl2OETF3;
836       par[9] = tl2OETF3;
837       par[10] = alp2OETF3; 
838      gMC->Gsvolu("EDE3","TRAP",idFrameEpoxy,par,11);  
839
840   // TRAPEZE 4
841       par[4] = bl1OETF4;
842       par[5] = tl1OETF4;
843       par[6] = alp1OETF4;
844
845       par[8] = bl2OETF4;
846       par[9] = tl2OETF4;
847       par[10] = alp2OETF4; 
848      gMC->Gsvolu("EDE4","TRAP",idFrameEpoxy,par,11);          
849
850   ////////////////////////////////
851
852     // TRAPEZE 1
853       par[0] = hzOuterFrameInox;
854       par[1] = tetOETF;
855       par[2] = phiOETF;
856       par[3] = h1OETF;
857       par[4] = bl1OETF1;
858       par[5] = tl1OETF1;
859       par[6] = alp1OETF1;
860       par[7] = h2OETF;
861       par[8] = bl2OETF1;
862       par[9] = tl2OETF1;
863       par[10] = alp2OETF1;
864
865       gMC->Gsvolu("EDI1","TRAP",idInox,par,11);  
866
867   // TRAPEZE 2
868       par[4] = bl1OETF2;
869       par[5] = tl1OETF2;
870       par[6] = alp1OETF2;
871
872       par[8] = bl2OETF2;
873       par[9] = tl2OETF2;
874       par[10] = alp2OETF2; 
875      gMC->Gsvolu("EDI2","TRAP",idInox,par,11);  
876
877   // TRAPEZE 3
878       par[4] = bl1OETF3;
879       par[5] = tl1OETF3;
880       par[6] = alp1OETF3;
881
882       par[8] = bl2OETF3;
883       par[9] = tl2OETF3;
884       par[10] = alp2OETF3; 
885      gMC->Gsvolu("EDI3","TRAP",idInox,par,11);  
886
887   // TRAPEZE 4
888       par[4] = bl1OETF4;
889       par[5] = tl1OETF4;
890       par[6] = alp1OETF4;
891
892       par[8] = bl2OETF4;
893       par[9] = tl2OETF4;
894       par[10] = alp2OETF4; 
895      gMC->Gsvolu("EDI4","TRAP",idInox,par,11);          
896
897
898   ////////////////////////////////
899
900     // TRAPEZE 1
901       par[0] = hzOuterFrameSolder;
902       par[1] = tetOETF;
903       par[2] = phiOETF;
904       par[3] = h1OETF;
905       par[4] = bl1OETF1;
906       par[5] = tl1OETF1;
907       par[6] = alp1OETF1;
908       par[7] = h2OETF;
909       par[8] = bl2OETF1;
910       par[9] = tl2OETF1;
911       par[10] = alp2OETF1;
912
913       gMC->Gsvolu("EDS1","TRAP",idSolder,par,11);
914
915   // TRAPEZE 2
916       par[4] = bl1OETF2;
917       par[5] = tl1OETF2;
918       par[6] = alp1OETF2;
919
920       par[8] = bl2OETF2;
921       par[9] = tl2OETF2;
922       par[10] = alp2OETF2; 
923      gMC->Gsvolu("EDS2","TRAP",idSolder,par,11);  
924
925   // TRAPEZE 3
926       par[4] = bl1OETF3;
927       par[5] = tl1OETF3;
928       par[6] = alp1OETF3;
929
930       par[8] = bl2OETF3;
931       par[9] = tl2OETF3;
932       par[10] = alp2OETF3; 
933      gMC->Gsvolu("EDS3","TRAP",idSolder,par,11);  
934
935   // TRAPEZE 4
936       par[4] = bl1OETF4;
937       par[5] = tl1OETF4;
938       par[6] = alp1OETF4;
939
940       par[8] = bl2OETF4;
941       par[9] = tl2OETF4;
942       par[10] = alp2OETF4; 
943      gMC->Gsvolu("EDS4","TRAP",idSolder,par,11);          
944
945   //////////////////////////////////
946
947   // OutCornerTrapFrame  
948       par[0] = hzOCTF;
949       par[1] = tetOCTF;
950       par[2] = phiOCTF;
951       par[3] = h1OCTF;
952       par[4] = bl1OCTF;
953       par[5] = tl1OCTF;
954       par[6] = alp1OCTF;
955       par[7] = h2OCTF;
956       par[8] = bl2OCTF;
957       par[9] = tl2OCTF;
958       par[10] = alp2OCTF;
959
960       gMC->Gsvolu("TCOR","TRAP",idFrameEpoxy,par,11);
961
962   // MIRE
963       par[0] = MIREInRad;
964       par[1] = MIREOutRad;
965       par[2] = MIRELen;    
966
967       gMC->Gsvolu("MIRE","TUBE",idFrameEpoxy,par,3);   
968   }
969              
970 // __________________Place volumes in the quadrant ____________ 
971
972     const Float_t BeamOX = 2.6;
973     const Float_t BeamOY = 2.6;  
974
975  // Coordinates of the frame corner wrt the beam axis defined at (0,0)
976     Float_t QuadOX = 0.;
977     Float_t QuadOY = 0.;
978     
979 // InVFrame  
980     posX = hxInVFrame;
981     posY = 2.0*hyInHFrame+2.*hyH1mm+IAF+hyInVFrame;        
982     posZ = 0.;   
983     gMC->Gspos("IVEF",1,QuadrantName(chamber),posX, posY, posZ, 0, "ONLY"); 
984
985 // InHFrame
986     posX = 2.0*hxInVFrame+2.*hxV1mm+IAF+hxInHFrame;
987     posY = hyInHFrame;
988     posZ = 0.;       
989     gMC->Gspos("IHEF",1,QuadrantName(chamber),posX, posY, posZ, 0, "ONLY"); 
990     
991 // OutVFrame
992     posX = 2.*hxInVFrame+IAF+2.*hxInHFrame-hxOutVFrame+2.*hxV1mm;
993     posY = 2.*hyInHFrame+hyOutVFrame;    
994     posZ = 0.;              
995     gMC->Gspos("OVEF",1,QuadrantName(chamber),posX, posY, posZ, 0, "ONLY"); 
996 //    cout << " Outer vertical frame at " << posX << " " << posY << " "
997 //           << posZ << " and half length " << hyOutVFrame << endl;           
998     const Float_t TOPY = posY+hyOutVFrame;
999     const Float_t OUTX = posX;
1000
1001 //Flat 1mm vertical section
1002     posX = 2.0*hxInVFrame+hxV1mm;
1003     posY = 2.0*hyInHFrame+2.*hyH1mm+IAF+hyV1mm;
1004     posZ = 0.;
1005     gMC->Gspos("FVMM",1,QuadrantName(chamber),posX, posY, posZ,0, "ONLY"); 
1006  
1007 // Flat 1mm horizontal section
1008     posX = 2.0*hxInVFrame+2.*hxV1mm+IAF+hxH1mm;
1009     posY = 2.0*hyInHFrame+hyH1mm;
1010     posZ = 0.;
1011     gMC->Gspos("FHMM",1,QuadrantName(chamber),posX, posY, posZ,0, "ONLY"); 
1012         
1013 // InArcFrame 
1014     posX = 2.0*hxInVFrame+2.*hxV1mm;
1015     posY = 2.0*hyInHFrame+2.*hyH1mm;
1016     posZ = 0.;    
1017     gMC->Gspos("IAF1",1,QuadrantName(chamber),posX, posY, posZ,0, "ONLY"); 
1018
1019     
1020 // ScrewsInFrame  
1021
1022 // Only place screws that are inside the sensitive volume.
1023
1024      Float_t scruX[64];
1025      Float_t scruY[64]; 
1026          
1027 // Screws on IHEpoxyFrame
1028
1029      const Int_t NumberOfScrewsIH = 14;    // no. of screws on the IHEpoxyFrame
1030      const Float_t offX = 5.;              // inter-screw distance 
1031
1032      // first screw coordinates 
1033      scruX[0] = 21.07;                  
1034      scruY[0] = -2.23; 
1035      // other screw coordinates      
1036      for (Int_t i = 1;i<NumberOfScrewsIH;i++){   
1037      scruX[i] = scruX[i-1]+offX; 
1038      scruY[i] = scruY[0];
1039      }    
1040      // Position the volumes on the frames
1041      for (Int_t i = 0;i<NumberOfScrewsIH;i++){
1042      posX = BeamOX + scruX[i];
1043      posY = BeamOY + scruY[i];
1044      posZ = 0.;   
1045      gMC->Gspos("SCRH",i+1,QuadrantName(chamber),posX-QuadOX+0.1, posY-QuadOY+0.1, posZ-hzInHFrame-SCRUHLE, 0, "ONLY");      
1046      gMC->Gspos("SCRM",i+1,QuadrantName(chamber),posX-QuadOX+0.1, posY-QuadOY+0.1, posZ, 0, "ONLY");
1047      gMC->Gspos("SCRN",i+1,QuadrantName(chamber),posX-QuadOX+0.1, posY-QuadOY+0.1, posZ+hzInHFrame+SCRUNLE, 0, "ONLY"); 
1048      }
1049      // special screw coordinates
1050      scruX[63] = 16.3;  
1051      scruY[63] = -2.23; 
1052      posX = BeamOX + scruX[63];
1053      posY = BeamOY + scruY[63];
1054      posZ = 0.;            
1055      gMC->Gspos("SCRH",64,QuadrantName(chamber),posX-QuadOX+0.1, posY-QuadOY+0.1, posZ-hzInHFrame-SCRUHLE, 0, "ONLY");
1056      gMC->Gspos("SCRM",64,QuadrantName(chamber),posX-QuadOX+0.1, posY-QuadOY+0.1, posZ, 0, "ONLY"); 
1057      gMC->Gspos("SCRN",64,QuadrantName(chamber),posX-QuadOX+0.1, posY-QuadOY+0.1, posZ+hzInHFrame+SCRUNLE, 0, "ONLY");  
1058      
1059 // Screws on the IVEpoxyFrame
1060   
1061     const Int_t NumberOfScrewsIV = 15;     // no. of screws on the IVEpoxyFrame
1062     const Float_t offY = 5.;               // inter-screw distance 
1063     Int_t FirstScrew = 58;
1064     Int_t LastScrew = 44;
1065  
1066     // first (special) screw coordinates
1067     scruX[FirstScrew-1] = -2.23; 
1068     scruY[FirstScrew-1] = 16.3; 
1069     // second (repetitive) screw coordinates
1070     scruX[FirstScrew-2] = -2.23; 
1071     scruY[FirstScrew-2] = 21.07;     
1072     // other screw coordinates      
1073     for (Int_t i = FirstScrew-3;i>LastScrew-2;i--){   
1074     scruX[i] = scruX[FirstScrew-2];
1075     scruY[i] = scruY[i+1]+offY;
1076     }
1077     
1078     for (Int_t i = 0;i<NumberOfScrewsIV;i++){
1079     posX = BeamOX + scruX[i+LastScrew-1];
1080     posY = BeamOY + scruY[i+LastScrew-1];
1081     posZ = 0.;       
1082     gMC->Gspos("SCRH",i+LastScrew,QuadrantName(chamber),posX-QuadOX+0.1, posY-QuadOY+0.1, posZ-hzInHFrame-SCRUHLE, 0, "ONLY");     
1083     gMC->Gspos("SCRM",i+LastScrew,QuadrantName(chamber),posX-QuadOX+0.1, posY-QuadOY+0.1, posZ, 0, "ONLY"); 
1084     gMC->Gspos("SCRN",i+LastScrew,QuadrantName(chamber),posX-QuadOX+0.1, posY-QuadOY+0.1, posZ+hzInHFrame+SCRUNLE, 0, "ONLY");
1085     }    
1086     
1087 // Screws on the OVEpoxyFrame
1088   
1089     const Int_t NumberOfScrewsOV = 10;     // no. of screws on the OVEpoxyFrame
1090
1091     FirstScrew = 15;
1092     LastScrew = 25;
1093  
1094     // first (repetitive) screw coordinates
1095     scruX[FirstScrew-1] = 90.9; 
1096     scruY[FirstScrew-1] = -2.23;  // true value
1097  
1098     // other screw coordinates      
1099     for (Int_t i = FirstScrew; i<LastScrew; i++ ){   
1100     scruX[i] = scruX[FirstScrew-1];
1101     scruY[i] = scruY[i-1]+offY;
1102     }
1103     for (Int_t i = 0;i<NumberOfScrewsOV;i++){
1104     posX = BeamOX + scruX[i+FirstScrew-1];
1105     posY = BeamOY + scruY[i+FirstScrew-1];
1106     posZ = 0.;   
1107     gMC->Gspos("SCRH",i+FirstScrew,QuadrantName(chamber),posX-QuadOX+0.1, posY-QuadOY+0.1, posZ-hzInHFrame-SCRUHLE, 0, "ONLY");     
1108     gMC->Gspos("SCRM",i+FirstScrew,QuadrantName(chamber),posX-QuadOX+0.1, posY-QuadOY+0.1, posZ, 0, "ONLY"); 
1109     gMC->Gspos("SCRN",i+FirstScrew,QuadrantName(chamber),posX-QuadOX+0.1, posY-QuadOY+0.1, posZ+hzInHFrame+SCRUNLE, 0, "ONLY"); 
1110     }
1111       
1112 // Inner Arc of Frame, screw positions and numbers-1
1113    scruX[62] = 16.009; scruY[62]  = 1.401;
1114    scruX[61] = 14.564; scruY[61]  = 6.791;
1115    scruX[60] = 11.363; scruY[60]  = 11.363;
1116    scruX[59] = 6.791 ; scruY[59]  = 14.564;
1117    scruX[58] = 1.401 ; scruY[58]  = 16.009;
1118     
1119     for (Int_t i = 0;i<5;i++){
1120     posX = BeamOX + scruX[i+58];
1121     posY = BeamOY + scruY[i+58];
1122     posZ = 0.;   
1123     gMC->Gspos("SCRH",i+58+1,QuadrantName(chamber),posX-QuadOX+0.1, posY-QuadOY+0.1, posZ-hzInHFrame-SCRUHLE, 0, "ONLY");    
1124     gMC->Gspos("SCRM",i+58+1,QuadrantName(chamber),posX-QuadOX+0.1, posY-QuadOY+0.1, posZ, 0, "ONLY");
1125     gMC->Gspos("SCRN",i+58+1,QuadrantName(chamber),posX-QuadOX+0.1, posY-QuadOY+0.1, posZ+hzInHFrame+SCRUNLE, 0, "ONLY");
1126     }  
1127
1128 // OutTopTrapFrame   
1129     posX = hxOutHFrame;
1130     posY = 2.*hyInHFrame+IAF+2.*hyInVFrame+hyOutHFrame+2.*hyH1mm;
1131     posZ = 0.;
1132
1133 // place 3 layers of cuboids    
1134     posZ = posZ-(hzOuterFrameSolder+hzOuterFrameInox);
1135     gMC->Gspos("OHEA",1,QuadrantName(chamber),posX, posY, posZ,0,"ONLY"); 
1136     posZ = posZ+hzOuterFrameInox+hzOuterFrameSolder;
1137     gMC->Gspos("OHSA",1,QuadrantName(chamber),posX, posY, posZ,0,"ONLY");
1138     posZ = posZ+hzOuterFrameSolder+hzOuterFrameInox;
1139     gMC->Gspos("OHIA",1,QuadrantName(chamber),posX, posY, posZ,0,"ONLY");
1140     
1141 // place 3 layers of trapezoid A
1142     posX = 34.1663+2.6;
1143     posY = 92.2946+2.6;
1144     posZ = 0.; 
1145     
1146     posZ = posZ-(hzOuterFrameSolder+hzOuterFrameInox); 
1147     gMC->Gspos("OHEB",1,QuadrantName(chamber),posX, posY, posZ, idrotm[1102],"ONLY"); 
1148     posZ = posZ+hzOuterFrameInox+hzOuterFrameSolder;
1149     gMC->Gspos("OHSB",1,QuadrantName(chamber),posX, posY, posZ, idrotm[1102],"ONLY");
1150     posZ = posZ+hzOuterFrameSolder+hzOuterFrameInox;
1151     gMC->Gspos("OHIB",1,QuadrantName(chamber),posX, posY, posZ, idrotm[1102],"ONLY");
1152     
1153 // place 3 layers of trapezoid B
1154     posX = 43.8379+2.6;
1155     posY = 90.1946+2.6;
1156     posZ = 0.; 
1157     
1158     posZ = posZ-(hzOuterFrameSolder+hzOuterFrameInox); 
1159     gMC->Gspos("OHEC",1,QuadrantName(chamber),posX, posY, posZ, idrotm[1102],"ONLY"); 
1160     posZ = posZ+hzOuterFrameInox+hzOuterFrameSolder;
1161     gMC->Gspos("OHSC",1,QuadrantName(chamber),posX, posY, posZ, idrotm[1102],"ONLY");
1162     posZ = posZ+hzOuterFrameSolder+hzOuterFrameInox;
1163     gMC->Gspos("OHIC",1,QuadrantName(chamber),posX, posY, posZ, idrotm[1102],"ONLY");    
1164               
1165 ///////////////////////////////////////////////////             
1166         
1167 // OutEdgeTrapFrame  
1168  
1169     const Float_t refY = 70.13685;
1170     const Float_t refX = 71.43685;
1171     
1172     posX = refX;
1173     posY = refY;
1174     posZ = 0.; 
1175     
1176     Float_t XCenter[8]; 
1177     Float_t YCenter[8];
1178     
1179     XCenter[0] = 72.7099 + 2.6;
1180     XCenter[1] = 77.5787 + 2.6; 
1181     XCenter[2] = 82.2732 + 2.6;
1182     XCenter[3] = 86.7882 + 2.6; 
1183     
1184     YCenter[0] = 67.6691 + 2.6;
1185     YCenter[1] = 62.4564 + 2.6; 
1186     YCenter[2] = 57.0693 + 2.6;
1187     YCenter[3] = 51.5027 + 2.6; 
1188       
1189     XCenter[4] = 67.6691 + 2.6;
1190     XCenter[5] = 62.4564 + 2.6; 
1191     XCenter[6] = 57.0693 + 2.6;
1192     XCenter[7] = 51.5027 + 2.6; 
1193     
1194     YCenter[4] = 72.7099 + 2.6;
1195     YCenter[5] = 77.5787 + 2.6; 
1196     YCenter[6] = 82.2732 + 2.6;
1197     YCenter[7] = 86.7882 + 2.6; 
1198       
1199     posZ = posZ-(hzOuterFrameSolder+hzOuterFrameInox);     
1200     gMC->Gspos("EDE1",1,QuadrantName(chamber), XCenter[0], YCenter[0], posZ, idrotm[1104],"ONLY");
1201     gMC->Gspos("EDE1",2,QuadrantName(chamber), XCenter[4], YCenter[4],posZ, idrotm[1105],"ONLY");
1202
1203
1204     gMC->Gspos("EDE2",1,QuadrantName(chamber), XCenter[1], YCenter[1], posZ, idrotm[1104],"ONLY");   
1205     gMC->Gspos("EDE2",2,QuadrantName(chamber), XCenter[5], YCenter[5], posZ, idrotm[1105],"ONLY");
1206
1207     gMC->Gspos("EDE3",1,QuadrantName(chamber), XCenter[2], YCenter[2], posZ, idrotm[1104],"ONLY");
1208     gMC->Gspos("EDE3",2,QuadrantName(chamber), XCenter[6], YCenter[6], posZ, idrotm[1105],"ONLY");
1209     
1210     
1211     gMC->Gspos("EDE4",1,QuadrantName(chamber), XCenter[3], YCenter[3], posZ, idrotm[1104],"ONLY");
1212     gMC->Gspos("EDE4",2,QuadrantName(chamber), XCenter[7], YCenter[7], posZ, idrotm[1105],"ONLY");          
1213
1214
1215      
1216     posZ = posZ+hzOuterFrameEpoxy+hzOuterFrameInox;
1217      
1218     gMC->Gspos("EDI1",1,QuadrantName(chamber), XCenter[0], YCenter[0], posZ, idrotm[1104],"ONLY");
1219     gMC->Gspos("EDI1",2,QuadrantName(chamber), XCenter[4], YCenter[4], posZ, idrotm[1105],"ONLY");
1220     
1221     gMC->Gspos("EDI2",1,QuadrantName(chamber), XCenter[1], YCenter[1], posZ, idrotm[1104],"ONLY");   
1222     gMC->Gspos("EDI2",2,QuadrantName(chamber), XCenter[5], YCenter[5], posZ, idrotm[1105],"ONLY");
1223
1224     gMC->Gspos("EDI3",1,QuadrantName(chamber), XCenter[2], YCenter[2], posZ, idrotm[1104],"ONLY");
1225     gMC->Gspos("EDI3",2,QuadrantName(chamber), XCenter[6], YCenter[6], posZ, idrotm[1105],"ONLY");
1226        
1227     gMC->Gspos("EDI4",1,QuadrantName(chamber), XCenter[3], YCenter[3], posZ, idrotm[1104],"ONLY");
1228     gMC->Gspos("EDI4",2,QuadrantName(chamber), XCenter[7], YCenter[7], posZ, idrotm[1105],"ONLY");  
1229            
1230
1231     posZ = posZ+hzOuterFrameInox+hzOuterFrameSolder;
1232        
1233     gMC->Gspos("EDS1",1,QuadrantName(chamber), XCenter[0], YCenter[0], posZ, idrotm[1104],"ONLY");
1234     gMC->Gspos("EDS1",2,QuadrantName(chamber), XCenter[4], YCenter[4], posZ, idrotm[1105],"ONLY");
1235     
1236     gMC->Gspos("EDS2",1,QuadrantName(chamber), XCenter[1], YCenter[1], posZ, idrotm[1104],"ONLY");   
1237     gMC->Gspos("EDS2",2,QuadrantName(chamber), XCenter[5], YCenter[5], posZ, idrotm[1105],"ONLY");
1238
1239     gMC->Gspos("EDS3",1,QuadrantName(chamber), XCenter[2], YCenter[2], posZ, idrotm[1104],"ONLY");
1240     gMC->Gspos("EDS3",2,QuadrantName(chamber), XCenter[6], YCenter[6], posZ, idrotm[1105],"ONLY");
1241        
1242     gMC->Gspos("EDS4",1,QuadrantName(chamber), XCenter[3], YCenter[3], posZ, idrotm[1104],"ONLY");
1243     gMC->Gspos("EDS4",2,QuadrantName(chamber), XCenter[7], YCenter[7], posZ, idrotm[1105],"ONLY");  
1244     
1245   
1246 // OutCornerTrapFrame  
1247     posX = OUTX;
1248     posY = TOPY+((bl1OCTF+tl1OCTF)/2.);
1249     posZ = 0.;     
1250     gMC->Gspos("TCOR",1,QuadrantName(chamber),posX, posY, posZ, idrotm[1102],"ONLY"); 
1251     
1252 // Mire placement
1253     posX = OUTX+hxOutVFrame+1.3;
1254     posY = 8.13+2.6;
1255     posZ = 0.;
1256    gMC->Gspos("MIRE",1,QuadrantName(chamber),posX, posY, posZ, 0,"ONLY");
1257     
1258 }
1259
1260 //___________________________________________
1261 void AliMUONv2::CreateHole()
1262 {
1263 // Create all the element inside a foam hole
1264 // --
1265   Int_t* idtmed = fIdtmed->GetArray()-1099;
1266   Int_t idAir  = idtmed[1100]; // medium 1
1267   Int_t idCopper  = idtmed[1109]; // medium 10 = copper
1268
1269   GReal_t par[3];
1270   GReal_t posX,posY,posZ;
1271   
1272   par[0] = fgkHxHole;
1273   par[1] = fgkHyHole;
1274   par[2] = fgkHzFoam;
1275   gMC->Gsvolu(fgkHoleName,"BOX",idAir,par,3);
1276
1277   par[0] = fgkHxKapton;
1278   par[1] = fgkHyKapton;
1279   par[2] = fgkHzSnPb;
1280   gMC->Gsvolu("SNPB", "BOX", idCopper, par, 3);
1281   posX = 0.;
1282   posY = 0.;
1283   posZ = -fgkHzFoam+fgkHzSnPb;
1284   gMC->Gspos("SNPB",1,fgkHoleName, posX, posY, posZ, 0,"ONLY");
1285
1286   par[0] = fgkHxHole;
1287   par[1] = fgkHyBergPlastic;
1288   par[2] = fgkHzKapton;
1289   gMC->Gsvolu("KAPT", "BOX", idCopper, par, 3);
1290   posX = 0.;
1291   posY = 0.;
1292   posZ = 0.;
1293   gMC->Gspos("KAPT",1,fgkHoleName, posX, posY, posZ, 0,"ONLY");
1294 }
1295
1296 //___________________________________________
1297 void AliMUONv2::CreateDaughterBoard()
1298 {
1299 // Create all the elements in a daughter board
1300 // --
1301   Int_t* idtmed = fIdtmed->GetArray()-1099;
1302   Int_t idAir  = idtmed[1100]; // medium 1
1303   Int_t idCopper  = idtmed[1109]; // medium 10 = copper
1304   Int_t idPlastic  =idtmed[1116]; // medium 17 = Plastic
1305
1306   GReal_t par[3];
1307   GReal_t posX,posY,posZ;
1308
1309   par[0]=fgkHxDaughter;
1310   par[1]=fgkHyDaughter;
1311   par[2]=totalHzDaughter();
1312   gMC->Gsvolu(fgkDaughterName,"BOX",idAir,par,3);
1313   
1314   par[0]=fgkHxBergPlastic;
1315   par[1]=fgkHyBergPlastic;
1316   par[2]=fgkHzBergPlastic;
1317   gMC->Gsvolu("BRGP","BOX",idPlastic,par,3);
1318   posX=0.;
1319   posY=0.;
1320   posZ = -totalHzDaughter() + fgkHzBergPlastic;
1321   gMC->Gspos("BRGP",1,fgkDaughterName,posX,posY,posZ,0,"ONLY");
1322
1323   par[0]=fgkHxBergCopper;
1324   par[1]=fgkHyBergCopper;
1325   par[2]=fgkHzBergCopper;
1326   gMC->Gsvolu("BRGC","BOX",idCopper,par,3);
1327   posX=0.;
1328   posY=0.;
1329   posZ=0.;
1330   gMC->Gspos("BRGC",1,"BRGC",posX,posY,posZ,0,"ONLY");
1331
1332   par[0]=fgkHxDaughter;
1333   par[1]=fgkHyDaughter;
1334   par[2]=fgkHzDaughter;
1335   gMC->Gsvolu("DGHT","BOX",idCopper,par,3);
1336   posX=0.;
1337   posY=0.;
1338   posZ = -totalHzDaughter() + 2.*fgkHzBergPlastic + fgkHzDaughter;
1339   gMC->Gspos("DGHT",1,fgkDaughterName,posX,posY,posZ,0,"ONLY");
1340 }
1341
1342 //___________________________________________
1343 void AliMUONv2::CreatePlaneBox(const char* name,const  TVector2& dimensions)
1344 {
1345 // create all the elements in the copper plane
1346 // --
1347   Int_t* idtmed = fIdtmed->GetArray()-1099;
1348   Int_t idAir  = idtmed[1100]; // medium 1
1349   Int_t idCopper  = idtmed[1109]; // medium 10 = copper
1350   Int_t idFoam = idtmed[1115]; // medium 16 = Foam
1351   Int_t idFR4 =idtmed[1114]; // medium 15 = FR4
1352
1353   GReal_t par[3];
1354   GReal_t posX,posY,posZ;
1355
1356   // mother volume
1357   par[0] = dimensions.X();
1358   par[1] = dimensions.Y();
1359   par[2] = totalHzPlane();
1360   gMC->Gsvolu(name,"BOX",idAir,par,3);
1361   
1362   // pad plane
1363   char* planeName = strdup(name);
1364   planeName[3]='P';
1365   par[0] = dimensions.X();
1366   par[1] = dimensions.Y();
1367   par[2] = fgkHzPadPlane;
1368   gMC->Gsvolu(planeName,"BOX",idCopper,par,3);
1369   posX=0.;
1370   posY=0.;
1371   posZ = -totalHzPlane()+fgkHzPadPlane;
1372   gMC->Gspos(planeName,1,name,posX,posY,posZ,0,"ONLY");
1373   
1374   //foam layer
1375   char* foamName = strdup(name);
1376   foamName[3]=fgkFoamLayerSuffix;
1377   par[0] = dimensions.X();
1378   par[1] = dimensions.Y();
1379   par[2] = fgkHzFoam;
1380   gMC->Gsvolu(foamName,"BOX",idFoam,par,3);
1381   posX=0.;
1382   posY=0.;
1383   posZ = -totalHzPlane()+2.*fgkHzPadPlane+fgkHzFoam;
1384   gMC->Gspos(foamName,1,name,posX,posY,posZ,0,"ONLY");
1385
1386   // mechanical plane FR4 layer
1387   char* fr4Name = strdup(name);
1388   fr4Name[3]='R';
1389   par[0] = dimensions.X();
1390   par[1] = dimensions.Y();
1391   par[2] = fgkHzFR4;
1392   gMC->Gsvolu(fr4Name,"BOX",idFR4,par,3);
1393   posX=0.;
1394   posY=0.;
1395   posZ = -totalHzPlane()+2.*fgkHzPadPlane+2.*fgkHzFoam+fgkHzFR4;
1396   gMC->Gspos(fr4Name,1,name,posX,posY,posZ,0,"ONLY");
1397 }
1398
1399 //___________________________________________
1400 void AliMUONv2::CreatePlaneSegment(const char* name,const  TVector2& dimensions
1401                                   ,Int_t nofHoles)
1402 {
1403 // Create a segment of a plane (this includes a copper layer, foam, hole, 
1404 // and kapton as well as the mother board.)
1405 // --
1406   static Int_t holeNum=1;
1407     
1408   GReal_t posX,posY,posZ;
1409   
1410   CreatePlaneBox(name,dimensions);
1411   char holeName[5];
1412   strcpy(holeName,name);
1413   holeName[3]=fgkFoamLayerSuffix;
1414   // <dname> is a motif on the pad plane
1415   char* dname = strdup(name);
1416   dname[3]='D';
1417   gMC->Gsdvn(dname,holeName,nofHoles,1);
1418   
1419   posX=0.;
1420   posY=0.;
1421   posZ= fgkHzPadPlane;
1422   gMC->Gspos(fgkHoleName,holeNum++,dname,posX,posY,posZ,0,"ONLY");
1423 }
1424
1425 //___________________________________________
1426 void AliMUONv2::CreateDaughterSegment(const char* name,const  TVector2& dimensions,
1427                               Int_t nofHoles)
1428 {
1429 // Create a segment of a daughter board layer
1430 // --
1431   static Int_t holeNum=1;
1432   Int_t* idtmed = fIdtmed->GetArray()-1099;
1433   Int_t idAir  = idtmed[1100]; // medium 1
1434
1435   GReal_t par[3];
1436   GReal_t posX,posY,posZ;
1437   
1438   par[0] = dimensions.X();
1439   par[1] = dimensions.Y();
1440   par[2] = totalHzDaughter();
1441   gMC->Gsvolu(name,"BOX",idAir,par,3);
1442   
1443   // <dname> is a motif on pad plane
1444   char* dname = strdup(name);
1445   dname[3]='D';
1446   gMC->Gsdvn(dname,name,nofHoles,1);
1447   
1448   posX=0.;
1449   posY=0.;
1450   posZ=0.;
1451   gMC->Gspos(fgkDaughterName,holeNum++,dname,posX,posY,posZ,0,"ONLY");
1452 }
1453
1454 //___________________________________________
1455 void AliMUONv2::PlaceSector(MSector* sector,TSpecialMap specialMap
1456                            ,const TVector3& where,Int_t chamber)
1457 {
1458 // Place all the segments in the mother volume, in the position defined
1459 // by the sector's data.
1460 // --
1461   static Int_t segNum=1;
1462   
1463   GReal_t posX,posY,posZ;
1464   
1465   vector<int> already_done;
1466   Int_t rotNum;
1467   AliMatrix(rotNum,  90.,90.,90,180.,0.,0.);
1468   
1469   for (Int_t irow=0;irow<sector->GetNofRows();irow++){
1470     MRow* row = sector->GetRow(irow);
1471     for (Int_t iseg=0;iseg<row->GetNofRowSegments();iseg++){
1472       MVRowSegment* seg = row->GetRowSegment(iseg);
1473       char* segName;
1474       
1475       TSpecialMap::iterator iter 
1476         = specialMap.find(seg->GetMotifPositionId(0));
1477       if ( iter == specialMap.end()){
1478         segName = strdup(Form("%.3dM",segNum*2));
1479         CreatePlaneSegment(segName,seg->Dimensions()/10.,seg->GetNofMotifs());     
1480         posX = where.X()+seg->Position().X()/10.-fgkOffsetX/2.;
1481         posY = where.Y()+seg->Position().Y()/10.-fgkOffsetY/2.;
1482         posZ = where.Z()-totalHz()+totalHzPlane();
1483         gMC->Gspos(segName,1,QuadrantName(chamber),posX,posY,posZ,0,"ONLY");
1484
1485         segName = strdup(Form("%.3dM",segNum*2+1));
1486         CreateDaughterSegment(segName,seg->Dimensions()/10.,seg->GetNofMotifs());     
1487         posX = where.X()+seg->Position().X()/10.+fgkOffsetX/2.;
1488         posY = where.Y()+seg->Position().Y()/10.-+fgkOffsetY/2.;
1489         posZ = where.Z()-totalHz()+2.*totalHzPlane()+totalHzDaughter();
1490         gMC->Gspos(segName,1,QuadrantName(chamber),posX,posY,posZ,0,"ONLY");
1491         segNum++;
1492       } else {
1493         for (Int_t motifNum=0;motifNum<seg->GetNofMotifs();motifNum++) {
1494           Int_t motifPosId = seg->GetMotifPositionId(motifNum);
1495           
1496           if (find(already_done.begin(),already_done.end(),motifPosId)
1497               != already_done.end()) continue;
1498           
1499             AliMUONSt1SpecialMotif spMot = specialMap[motifPosId];
1500
1501           MMotifPosition* motifPos = 
1502             sector->GetMotifMap()->FindMotifPosition(motifPosId);
1503           MMotifType* mType = motifPos->GetMotif()->GetMotifType();
1504           for (Int_t line=0;line<mType->GetNofPadsY();line++) {
1505             Int_t iMin=-1,iMax=-1,col;
1506             for (col=0;col<mType->GetNofPadsX();col++) {
1507               if (mType->HasPad(MIntPair(col,line))) {
1508                 iMin=col;
1509                 break;
1510               }
1511             }
1512             for (col=mType->GetNofPadsX()-1;col>=0;col--) {
1513               if (mType->HasPad(MIntPair(col,line))) {
1514                 iMax=col;
1515                 break;
1516               }
1517             }
1518             if ( (iMin>=0) && (iMax>=0) ) {
1519               TVector2 dim =  
1520                motifPos->GetMotif()->GetPadDimensions(MIntPair(iMin,line))/10.;
1521               TVector2 lineDim(dim.X()*(iMax-iMin+1),dim.Y());
1522               char* boxName = strdup(Form("%.3dM",segNum*2));
1523               CreatePlaneBox(boxName,lineDim);
1524               TVector2 posLLline = TVector2(dim.X()*2.*iMin,dim.Y()*2.*line)
1525                                     +motifPos->Position()/10.-motifPos->Dimensions()/10.;
1526               TVector2 centerLine = posLLline + lineDim;
1527               posX = where.X()+centerLine.X()-fgkOffsetX/2.;
1528               posY = where.Y()+centerLine.Y()-fgkOffsetY/2.;
1529               posZ = where.Z()-totalHz()+totalHzPlane();
1530               gMC->Gspos(boxName,1,QuadrantName(chamber),posX,posY,posZ,0,"ONLY");
1531             }
1532             
1533             segNum++;
1534           }
1535           
1536           Int_t rot = ( spMot.GetRotAngle()<0.1 ) ? 0:rotNum;
1537
1538           posX = where.X()+motifPos->Position().X()/10.-fgkOffsetX/2.+spMot.GetDelta().X();
1539           posY = where.Y()+motifPos->Position().Y()/10.-fgkOffsetY/2.+spMot.GetDelta().Y();
1540           posZ = where.Z()-fgkHzPadPlane;
1541           gMC->Gspos(fgkHoleName,motifPosId,QuadrantName(chamber),posX,posY,posZ,rot,"ONLY");
1542           
1543           posX = where.X()+motifPos->Position().X()/10.+fgkOffsetX/2.-fgkDeltaFilleEtamX+spMot.GetDelta().X();
1544           posY = where.Y()+motifPos->Position().Y()/10.-+fgkOffsetY/2.-fgkDeltaFilleEtamY+spMot.GetDelta().Y();
1545           posZ = where.Z()-totalHz()+2.*totalHzPlane()+totalHzDaughter();
1546           gMC->Gspos(fgkDaughterName,motifPosId,QuadrantName(chamber),posX,posY,posZ,rot,"ONLY");
1547
1548           already_done.push_back(motifPosId);             
1549         }
1550       }
1551     }
1552   } 
1553 }