AliRoot Core  a565103 (a565103)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONSlatGeometryBuilder.cxx
Go to the documentation of this file.
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 
19 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
34 
36 #include "AliMUON.h"
37 #include "AliMUONConstants.h"
38 #include "AliMUONGeometryModule.h"
40 #include "AliMUONConstants.h"
41 
42 #include "AliMpDEManager.h"
43 
44 #include "AliRun.h"
45 #include "AliLog.h"
46 
47 #include <TVirtualMC.h>
48 #include <TGeoBBox.h>
49 #include <TGeoVolume.h>
50 #include <TGeoManager.h>
51 #include <TGeoMatrix.h>
52 #include <TGeoCompositeShape.h>
53 #include <TGeoTube.h>
54 #include <Riostream.h>
55 
56 using std::endl;
57 using std::cout;
61 
62 //______________________________________________________________________________
64  : AliMUONVGeometryBuilder(4, 12),
65  fMUON(muon)
66 {
68 
69 }
70 
71 //______________________________________________________________________________
74  fMUON(0)
75 {
77 }
78 
79 //______________________________________________________________________________
81 {
83 }
84 
85 //
86 // public methods
87 //
88 
89 //______________________________________________________________________________
91 {
99 
100  Int_t *idtmed = fMUON->GetIdtmed()->GetArray()-1099;
101 
102  Float_t angle;
103  Float_t *dum=0;
104 
105  // define the id of tracking media:
106  // Int_t idAir = idtmed[1100]; // medium 1
107  Int_t idGas = idtmed[1108]; // medium 9 = Ar-CO2 gas (80%+20%)
108  Int_t idCopper = idtmed[1110];
109  Int_t idG10 = idtmed[1111];
110  Int_t idCarbon = idtmed[1112];
111  Int_t idRoha = idtmed[1113];
112  Int_t idNomex = idtmed[1114]; // honey comb
113  Int_t idNoryl = idtmed[1115];
114  Int_t idNomexB = idtmed[1116]; // bulk material
115 
116  // Getting mediums for pannel support geometry
117  TGeoMedium* kMedNomex = gGeoManager->GetMedium("MUON_Nomex");
118  TGeoMedium* kMedCarbon = gGeoManager->GetMedium("MUON_CARBON");
119 
120  // sensitive area: 40*40 cm**2
121  const Float_t kSensLength = 40.;
122  const Float_t kSensHeight = 40.;
123  const Float_t kSensWidth = AliMUONConstants::Pitch()*2;// 0.5 cm, according to TDR fig 2.120
124  const Int_t kSensMaterial = idGas;
125  // const Float_t kYoverlap = 1.5;
126 
127  // PCB dimensions in cm; width: 30 mum copper
128  const Float_t kPcbLength = kSensLength;
129  const Float_t kPcbHeight = 58.; // updated Ch. Finck
130  const Float_t kPcbWidth = 0.003;
131  const Int_t kPcbMaterial = idCopper;
132 
133  // Insulating material: 220 mum G10 fiber glued to pcb
134  const Float_t kInsuLength = kPcbLength;
135  const Float_t kInsuHeight = kPcbHeight;
136  const Float_t kInsuWidth = 0.022; // updated Ch. Finck
137  const Int_t kInsuMaterial = idG10;
138 
139  // Carbon fiber panels: 200mum carbon/epoxy skin
140  const Float_t kCarbonWidth = 0.020;
141  const Int_t kCarbonMaterial = idCarbon;
142 
143  // Nomex (honey comb) between the two panel carbon skins
144  const Float_t kNomexLength = kSensLength;
145  const Float_t kNomexHeight = kSensHeight;
146  const Float_t kNomexWidth = 0.8; // updated Ch. Finck
147  const Int_t kNomexMaterial = idNomex;
148 
149  // Bulk Nomex under panel sandwich Ch. Finck
150  const Float_t kNomexBWidth = 0.025;
151  const Int_t kNomexBMaterial = idNomexB;
152 
153  // Panel sandwich 0.02 carbon*2 + 0.8 nomex
154  const Float_t kPanelLength = kSensLength;
155  const Float_t kPanelHeight = kSensHeight;
156  const Float_t kPanelWidth = 2 * kCarbonWidth + kNomexWidth;
157 
158  // Frame along the rounded (spacers) slats
159  const Float_t kRframeHeight = 2.00;
160 
161  // spacer around the slat: 2 sticks along length,2 along height
162  // H: the horizontal ones
163  const Float_t kHframeLength = kPcbLength;
164  const Float_t kHframeHeight = 1.95; // updated Ch. Finck
165  const Float_t kHframeWidth = kSensWidth;
166  const Int_t kHframeMaterial = idNoryl;
167 
168  // V: the vertical ones; vertical spacers
169  const Float_t kVframeLength = 2.5;
170  const Float_t kVframeHeight = kSensHeight + kHframeHeight;
171  const Float_t kVframeWidth = kSensWidth;
172  const Int_t kVframeMaterial = idNoryl;
173 
174  // R: rounded part of vertical spacers
175  const Float_t kRframeLength = 2.0;
176  const Float_t kRframeWidth = kSensWidth;
177  const Int_t kRframeMaterial = idNoryl;
178 
179  // B: the horizontal border filled with rohacell: ok Ch. Finck
180  const Float_t kBframeLength = kHframeLength;
181  const Float_t kBframeHeight = (kPcbHeight - kSensHeight)/2. - kHframeHeight;
182  const Float_t kBframeWidth = kHframeWidth;
183  const Int_t kBframeMaterial = idRoha;
184 
185  // NULOC: 30 mum copper + 200 mum vetronite (same radiation length as 14mum copper) for electronics
186  const Float_t kNulocLength = 2.5;
187  const Float_t kNulocHeight = kBframeHeight;
188  const Float_t kNulocWidth = 0.0030 + 0.0014; // equivalent copper width of vetronite;
189  const Int_t kNulocMaterial = idCopper;
190 
191  // Readout cables: Equivalent to 260 mum copper
192  const Float_t kCableHeight = 2.6;
193  const Float_t kCableWidth = 0.026;
194  const Int_t kCableMaterial = idCopper;
195 
196  // Slat parameters
197  const Float_t kSlatHeight = kPcbHeight;
198  const Float_t kSlatWidth = kSensWidth + 2.*(kPcbWidth + kInsuWidth + kPanelWidth
199  + kNomexBWidth); //replaced rohacell with Nomex Ch. Finck
200  // const Int_t kSlatMaterial = idAir;
201  const Float_t kDslatLength = -1.25; // position of the slat respect to the beam plane (half vertical spacer) Ch. Finck
202  Float_t zSlat = AliMUONConstants::DzSlat();// implemented Ch. Finck
203  Float_t dzCh = AliMUONConstants::DzCh();
204 
205  Float_t spar[3];
206  Int_t i, j;
207  Int_t detElemId;
208  Int_t moduleId;
209 
210  // the panel volume contains the nomex
211  Float_t panelpar[3] = { static_cast<Float_t>(kPanelLength/2.), static_cast<Float_t>(kPanelHeight/2.), static_cast<Float_t>(kPanelWidth/2.) };
212  Float_t nomexpar[3] = { static_cast<Float_t>(kNomexLength/2.), static_cast<Float_t>(kNomexHeight/2.), static_cast<Float_t>(kNomexWidth/2.) };
213  Float_t twidth = kPanelWidth + kNomexBWidth;
214  Float_t nomexbpar[3] = {static_cast<Float_t>(kNomexLength/2.), static_cast<Float_t>(kNomexHeight/2.),static_cast<Float_t>(twidth/2.) };// bulk nomex
215 
216  // insulating material contains PCB-> gas
217  twidth = 2*(kInsuWidth + kPcbWidth) + kSensWidth ;
218  Float_t insupar[3] = {static_cast<Float_t>(kInsuLength/2.), static_cast<Float_t>(kInsuHeight/2.), static_cast<Float_t>(twidth/2.) };
219  twidth -= 2 * kInsuWidth;
220  Float_t pcbpar[3] = {static_cast<Float_t>(kPcbLength/2.), static_cast<Float_t>(kPcbHeight/2.), static_cast<Float_t>(twidth/2.) };
221  Float_t senspar[3] = {static_cast<Float_t>(kSensLength/2.), static_cast<Float_t>(kSensHeight/2.), static_cast<Float_t>(kSensWidth/2.) };
222  Float_t theight = 2 * kHframeHeight + kSensHeight;
223  Float_t hFramepar[3] = {static_cast<Float_t>(kHframeLength/2.), static_cast<Float_t>(theight/2.), static_cast<Float_t>(kHframeWidth/2.)};
224  Float_t bFramepar[3] = {static_cast<Float_t>(kBframeLength/2.), static_cast<Float_t>(kBframeHeight/2.), static_cast<Float_t>(kBframeWidth/2.)};
225  Float_t vFramepar[3] = {static_cast<Float_t>(kVframeLength/2.), static_cast<Float_t>(kVframeHeight/2.), static_cast<Float_t>(kVframeWidth/2.)};
226  Float_t nulocpar[3] = {static_cast<Float_t>(kNulocLength/2.), static_cast<Float_t>(kNulocHeight/2.), static_cast<Float_t>(kNulocWidth/2.)};
227 
228  Float_t xx;
229  Float_t xxmax = (kBframeLength - kNulocLength)/2.;
230  Int_t index=0;
231  Int_t* fStations = new Int_t[5];
232  for (Int_t iSt=0; iSt<5; iSt++) fStations[iSt] = 1;
233  fStations[2] = 1;
234 
235  if (fStations[2])
236  {
237  //********************************************************************
238  // Station 3 **
239  //********************************************************************
240  // Mother volume for each chamber in St3 is an envelop (or assembly)
241  // There is one assembly mother per half a chamber
242  // Mother volume for each chamber in St3 is an envelop (or assembly)
243  // There is one assembly mother per half a chamber called SC05I, SC05O, SC06I and SC06O
244  // volumes for slat geometry (xx=5,..,10 chamber id):
245  // Sxx0 Sxx1 Sxx2 Sxx3 --> Slat Mother volumes
246  // SxxG --> Sensitive volume (gas)
247  // SxxP --> PCB (copper)
248  // SxxI --> Insulator (G10)
249  // SxxC --> Carbon panel
250  // SxxN --> Nomex comb
251  // SxxX --> Nomex bulk
252  // SxxH, SxxV --> Horizontal and Vertical frames (Noryl)
253  // SB5x --> Volumes for the 35 cm long PCB
254  // slat dimensions: slat is a MOTHER volume!!! made of air
255  // Only for chamber 5: slat 1 has a PCB shorter by 5cm!
256 
257  Float_t tlength = 35.;
258  Float_t panelpar2[3] = { static_cast<Float_t>(tlength/2.), panelpar[1], panelpar[2]};
259  Float_t nomexpar2[3] = { static_cast<Float_t>(tlength/2.), nomexpar[1], nomexpar[2]};
260  Float_t nomexbpar2[3] = { static_cast<Float_t>(tlength/2.), nomexbpar[1], nomexbpar[2]};
261  Float_t insupar2[3] = { static_cast<Float_t>(tlength/2.), insupar[1], insupar[2]};
262  Float_t pcbpar2[3] = { static_cast<Float_t>(tlength/2.), pcbpar[1], pcbpar[2]};
263  Float_t senspar2[3] = { static_cast<Float_t>(tlength/2.), senspar[1], senspar[2]};
264  Float_t hFramepar2[3] = { static_cast<Float_t>(tlength/2.), hFramepar[1], hFramepar[2]};
265  Float_t bFramepar2[3] = { static_cast<Float_t>(tlength/2.), bFramepar[1], bFramepar[2]};
266  Float_t pcbDLength3 = (kPcbLength - tlength);
267 
268  // For rounded pcb of central slat
269  Float_t csvPcbLength = 59.25-40.; // PQ-LAT-SR1
270  Float_t panelpar3[3] = { static_cast<Float_t>(csvPcbLength/2.), panelpar[1], panelpar[2]};
271  Float_t nomexpar3[3] = { static_cast<Float_t>(csvPcbLength/2.), nomexpar[1], nomexpar[2]};
272  Float_t nomexbpar3[3] = {static_cast<Float_t>( csvPcbLength/2.), nomexbpar[1], nomexbpar[2]};
273  Float_t insupar3[3] = { static_cast<Float_t>(csvPcbLength/2.), insupar[1], insupar[2]};
274  Float_t pcbpar3[3] = { static_cast<Float_t>(csvPcbLength/2.), pcbpar[1], pcbpar[2]};
275  Float_t senspar3[3] = { static_cast<Float_t>(csvPcbLength/2.), senspar[1], senspar[2]};
276  Float_t hFramepar3[3] = { static_cast<Float_t>(csvPcbLength/2.), hFramepar[1], hFramepar[2]};
277  Float_t bFramepar3[3] = { static_cast<Float_t>(csvPcbLength/2.), bFramepar[1], bFramepar[2]};
278  Float_t cPhi = TMath::RadToDeg()*(TMath::Pi()/2.-TMath::ACos(hFramepar3[1]/(AliMUONConstants::Rmin(2)-kRframeLength)));
279  Float_t cFramepar3[5] = { AliMUONConstants::Rmin(2)-kRframeLength, AliMUONConstants::Rmin(2), kRframeWidth, -cPhi, cPhi};
280 
281  const Int_t kNslats3 = 5; // number of slats per quadrant
282  const Int_t kNPCB3[kNslats3] = {4, 4, 4, 3, 2}; // n PCB per slat
283  const Float_t kXpos3[kNslats3] = {0., 0., 0., 0., 0.};//{31., 0., 0., 0., 0.};
284  const Float_t kYpos3[kNslats3] = {0, 37.8, 37.7, 37.3, 33.7};
285  Float_t slatLength3[kNslats3];
286 
287  Float_t rPhi1 = TMath::RadToDeg()*(TMath::ASin((kYpos3[1]-hFramepar3[1])/(AliMUONConstants::Rmin(2))));
288  Float_t rPhi2 = TMath::RadToDeg()*(TMath::ACos(-vFramepar[0]/(AliMUONConstants::Rmin(2)-kRframeLength)));
289  Float_t rFramepar3[5] = { AliMUONConstants::Rmin(2)-kRframeLength, AliMUONConstants::Rmin(2), kRframeWidth, rPhi1, rPhi2};
290  Float_t vrFrameHeight = hFramepar3[1]+kYpos3[1]-AliMUONConstants::Rmin(2)+kRframeLength;
291 
292  // create and position the slat (mother) volumes
293 
294  char idSlatCh5[6];
295  char idSlatCh6[6];
296  Float_t xSlat3;
297  Float_t ySlat3 = 0;
298  angle = 0.;
299 
300  Float_t spar2[3];
301  for (i = 0; i < kNslats3; i++){
302 
303  slatLength3[i] = kPcbLength * kNPCB3[i] + 2.* kVframeLength;
304  xSlat3 = slatLength3[i]/2. + kDslatLength + kXpos3[i];
305  ySlat3 += kYpos3[i];
306 
307  spar[0] = slatLength3[i]/2.;
308  spar[1] = kSlatHeight/2.;
309  spar[2] = kSlatWidth/2.;
310  // take away 5 cm from the first slat in chamber 5
311  if (i == 0 || i == 1 || i == 2) { // 1 pcb is shortened by 5cm
312  spar2[0] = spar[0] - pcbDLength3/2.;
313  } else {
314  spar2[0] = spar[0];
315  }
316  spar2[1] = spar[1];
317  spar2[2] = spar[2];
318  Float_t dzCh3 = dzCh;
319  Float_t dzSlat3 = -0.25; // see drawing PQ7EN345-6 (Delta_slat=80mm instead 85mm)
320  Float_t zSlat3 = (i%2 ==0)? -(zSlat+dzSlat3) : (zSlat+dzSlat3); // seems not that zSlat3 = zSlat4 & 5 refering to plan PQ7EN345-6 ? -> Indeed, fixed J.C.
321 
322  sprintf(idSlatCh5,"SLA%d",i+kNslats3-1);
323  detElemId = 509 - (i + kNslats3-1-4);
324  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
325  if (detElemId == 508 || detElemId == 509) // Round slat, new rotation due to mapping convention
326  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(xSlat3, ySlat3, -zSlat3 + dzCh3),
327  TGeoRotation("rot1",90,180+angle,90,90+angle,180,0) );
328  else {
329  if (detElemId % 2 == 0)
330  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(xSlat3, ySlat3, -zSlat3 + dzCh3),
331  TGeoRotation("rot1",90,angle,90,90+angle,0,0) );
332  else
333  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(xSlat3, ySlat3, -zSlat3 + dzCh3),
334  TGeoRotation("rot1",90,angle,90,270+angle,180,0) );
335  }
336 
337  sprintf(idSlatCh5,"SLA%d",3*kNslats3-2+i);
338  detElemId = 500 + (i + kNslats3-1-4);
339  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
340  if (detElemId == 500 || detElemId == 501) // Round slat, new rotation due to mapping convention
341  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(-xSlat3, ySlat3, zSlat3 - dzCh3),
342  TGeoRotation("rot2",90,angle,90,90+angle,0,0) );
343  else {
344  if (detElemId % 2 == 1)
345  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(-xSlat3, ySlat3, zSlat3 - dzCh3),
346  TGeoRotation("rot2",90,180+angle,90,90+angle,180,0) );
347  else
348  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(-xSlat3, ySlat3, zSlat3 - dzCh3),
349  TGeoRotation("rot2",90,180+angle,90,270+angle,0,0) );
350  }
351 
352  if (i > 0) {
353  sprintf(idSlatCh5,"SLA%d",kNslats3-1-i);
354  detElemId = 509 + (i + kNslats3-1-4);
355  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
356  if (detElemId % 2 == 0 ) {
357  if (detElemId == 510) // Round slat, new rotation due to mapping convention
358  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(xSlat3, -ySlat3, -zSlat3 + dzCh3),
359  TGeoRotation("rot3",90,180+angle,90,270+angle,0,0) );
360  else
361  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(xSlat3, -ySlat3, -zSlat3 + dzCh3),
362  TGeoRotation("rot3",90,angle,90,90+angle,0,0) );
363  }
364  else
365  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(xSlat3, -ySlat3, -zSlat3 + dzCh3),
366  TGeoRotation("rot3",90,angle,90,270+angle,180,0) );
367 
368  sprintf(idSlatCh5,"SLA%d",3*kNslats3-2-i);
369  detElemId = 518 - (i + kNslats3-1-4);
370  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
371  if (detElemId % 2 == 1) {
372  if (detElemId == 517) // Round slat, new rotation due to mapping convention
373  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(-xSlat3, -ySlat3, zSlat3 - dzCh3),
374  TGeoRotation("rot4",90,angle,90,270+angle,180,0) );
375  else
376  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(-xSlat3, -ySlat3, zSlat3 - dzCh3),
377  TGeoRotation("rot4",90,180+angle,90,90+angle,180,0) );
378  }
379  else
380  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh5, detElemId, true, TGeoTranslation(-xSlat3, -ySlat3, zSlat3 - dzCh3),
381  TGeoRotation("rot4",90,180+angle,90,270+angle,0,0) );
382  }
383 
384  sprintf(idSlatCh6,"SLB%d",kNslats3-1+i);
385  detElemId = 609 - (i + kNslats3-1-4);
386  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
387  if (detElemId == 608 || detElemId == 609) // Round slat, new rotation due to mapping convention
388  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(xSlat3, ySlat3, -zSlat3 + dzCh3),
389  TGeoRotation("rot5",90,180+angle,90,90+angle,180,0));
390  else {
391  if (detElemId % 2 == 0)
392  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(xSlat3, ySlat3, -zSlat3 + dzCh3),
393  TGeoRotation("rot5",90,angle,90,90+angle,0,0));
394  else
395  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(xSlat3, ySlat3, -zSlat3 + dzCh3),
396  TGeoRotation("rot5",90,angle,90,270+angle,180,0));
397  }
398 
399  sprintf(idSlatCh6,"SLB%d",3*kNslats3-2+i);
400  detElemId = 600 + (i + kNslats3-1-4);
401  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
402  if (detElemId == 600 || detElemId == 601) // Round slat, new rotation due to mapping convention
403  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(-xSlat3, ySlat3, zSlat3 - dzCh3),
404  TGeoRotation("rot6",90,angle,90,90+angle,0,0) );
405  else {
406  if (detElemId % 2 == 1)
407  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(-xSlat3, ySlat3, zSlat3 - dzCh3),
408  TGeoRotation("rot6",90,180+angle,90,90+angle,180,0) );
409  else
410  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(-xSlat3, ySlat3, zSlat3 - dzCh3),
411  TGeoRotation("rot6",90,180+angle,90,270+angle,0,0) );
412  }
413 
414  if (i > 0) {
415  sprintf(idSlatCh6,"SLB%d",kNslats3-1-i);
416  detElemId = 609 + (i + kNslats3-1-4);
417  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
418  if (detElemId % 2 == 0 ) {
419  if (detElemId == 610) // Round slat, new rotation due to mapping convention
420  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(xSlat3, -ySlat3, -zSlat3 + dzCh3),
421  TGeoRotation("rot7",90,180+angle,90,270+angle,0,0) );
422  else
423  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(xSlat3, -ySlat3, -zSlat3 + dzCh3),
424  TGeoRotation("rot7",90,angle,90,90+angle,0,0) );
425  }
426  else
427  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(xSlat3, -ySlat3, -zSlat3 + dzCh3),
428  TGeoRotation("rot7",90,angle,90,270+angle,180,0) );
429 
430  sprintf(idSlatCh6,"SLB%d",3*kNslats3-2-i);
431  detElemId = 618 - (i + kNslats3-1-4);
432  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
433  if (detElemId % 2 == 1) {
434  if (detElemId == 617) // Round slat, new rotation due to mapping convention
435  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(-xSlat3, -ySlat3, zSlat3 - dzCh3),
436  TGeoRotation("rot8",90,angle,90,270+angle,180,0) );
437  else
438  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(-xSlat3, -ySlat3, zSlat3 - dzCh3),
439  TGeoRotation("rot8",90,180+angle,90,90+angle,180,0) );
440  }
441  else
442  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh6, detElemId, true, TGeoTranslation(-xSlat3, -ySlat3, zSlat3 - dzCh3),
443  TGeoRotation("rot8",90,180+angle,90,270+angle,0,0) );
444  }
445  }
446 
447  // create the panel volume
448 
449  TVirtualMC::GetMC()->Gsvolu("S05C","BOX",kCarbonMaterial,panelpar,3);
450  TVirtualMC::GetMC()->Gsvolu("SB5C","BOX",kCarbonMaterial,panelpar2,3);
451  TVirtualMC::GetMC()->Gsvolu("SC5C","BOX",kCarbonMaterial,panelpar3,3);
452  TVirtualMC::GetMC()->Gsvolu("SD5C","BOX",kCarbonMaterial,panelpar,3);
453  TVirtualMC::GetMC()->Gsvolu("S06C","BOX",kCarbonMaterial,panelpar,3);
454  TVirtualMC::GetMC()->Gsvolu("SC6C","BOX",kCarbonMaterial,panelpar3,3);
455  TVirtualMC::GetMC()->Gsvolu("SD6C","BOX",kCarbonMaterial,panelpar,3);
456 
457  // create the nomex volume (honey comb)
458 
459  TVirtualMC::GetMC()->Gsvolu("S05N","BOX",kNomexMaterial,nomexpar,3);
460  TVirtualMC::GetMC()->Gsvolu("SB5N","BOX",kNomexMaterial,nomexpar2,3);
461  TVirtualMC::GetMC()->Gsvolu("SC5N","BOX",kNomexMaterial,nomexpar3,3);
462  TVirtualMC::GetMC()->Gsvolu("SD5N","BOX",kNomexMaterial,nomexpar,3);
463  TVirtualMC::GetMC()->Gsvolu("S06N","BOX",kNomexMaterial,nomexpar,3);
464  TVirtualMC::GetMC()->Gsvolu("SC6N","BOX",kNomexMaterial,nomexpar3,3);
465  TVirtualMC::GetMC()->Gsvolu("SD6N","BOX",kNomexMaterial,nomexpar,3);
466 
467  // create the nomex volume (bulk)
468 
469  TVirtualMC::GetMC()->Gsvolu("S05X","BOX",kNomexBMaterial,nomexbpar,3);
470  TVirtualMC::GetMC()->Gsvolu("SB5X","BOX",kNomexBMaterial,nomexbpar2,3);
471  TVirtualMC::GetMC()->Gsvolu("SC5X","BOX",kNomexBMaterial,nomexbpar3,3);
472  TVirtualMC::GetMC()->Gsvolu("SD5X","BOX",kNomexBMaterial,nomexbpar,3);
473  TVirtualMC::GetMC()->Gsvolu("S06X","BOX",kNomexBMaterial,nomexbpar,3);
474  TVirtualMC::GetMC()->Gsvolu("SC6X","BOX",kNomexBMaterial,nomexbpar3,3);
475  TVirtualMC::GetMC()->Gsvolu("SD6X","BOX",kNomexBMaterial,nomexbpar,3);
476 
477  // create the insulating material volume
478 
479  TVirtualMC::GetMC()->Gsvolu("S05I","BOX",kInsuMaterial,insupar,3);
480  TVirtualMC::GetMC()->Gsvolu("SB5I","BOX",kInsuMaterial,insupar2,3);
481  TVirtualMC::GetMC()->Gsvolu("SC5I","BOX",kInsuMaterial,insupar3,3);
482  TVirtualMC::GetMC()->Gsvolu("SD5I","BOX",kInsuMaterial,insupar,3);
483  TVirtualMC::GetMC()->Gsvolu("S06I","BOX",kInsuMaterial,insupar,3);
484  TVirtualMC::GetMC()->Gsvolu("SC6I","BOX",kInsuMaterial,insupar3,3);
485  TVirtualMC::GetMC()->Gsvolu("SD6I","BOX",kInsuMaterial,insupar,3);
486 
487  // create the PCB volume
488 
489  TVirtualMC::GetMC()->Gsvolu("S05P","BOX",kPcbMaterial,pcbpar,3);
490  TVirtualMC::GetMC()->Gsvolu("SB5P","BOX",kPcbMaterial,pcbpar2,3);
491  TVirtualMC::GetMC()->Gsvolu("SC5P","BOX",kPcbMaterial,pcbpar3,3);
492  TVirtualMC::GetMC()->Gsvolu("SD5P","BOX",kPcbMaterial,pcbpar,3);
493  TVirtualMC::GetMC()->Gsvolu("S06P","BOX",kPcbMaterial,pcbpar,3);
494  TVirtualMC::GetMC()->Gsvolu("SC6P","BOX",kPcbMaterial,pcbpar3,3);
495  TVirtualMC::GetMC()->Gsvolu("SD6P","BOX",kPcbMaterial,pcbpar,3);
496 
497  // create the sensitive volumes,
498 
499  TVirtualMC::GetMC()->Gsvolu("S05G","BOX",kSensMaterial,dum,0);
500  TVirtualMC::GetMC()->Gsvolu("SC5G","BOX",kSensMaterial,senspar3,3);
501  TVirtualMC::GetMC()->Gsvolu("SD5G","BOX",kSensMaterial,senspar,3);
502  TVirtualMC::GetMC()->Gsvolu("S06G","BOX",kSensMaterial,dum,0);
503  TVirtualMC::GetMC()->Gsvolu("SC6G","BOX",kSensMaterial,senspar3,3);
504  TVirtualMC::GetMC()->Gsvolu("SD6G","BOX",kSensMaterial,senspar,3);
505 
506  // create the vertical frame volume
507 
508  TVirtualMC::GetMC()->Gsvolu("S05V","BOX",kVframeMaterial,vFramepar,3);
509  TVirtualMC::GetMC()->Gsvolu("S06V","BOX",kVframeMaterial,vFramepar,3);
510 
511  // create the rounded vertical frame volume
512 
513  TVirtualMC::GetMC()->Gsvolu("SC5D","TUBS",kRframeMaterial,cFramepar3,5);
514  TVirtualMC::GetMC()->Gsvolu("SD5D","TUBS",kRframeMaterial,rFramepar3,5);
515  TVirtualMC::GetMC()->Gsvolu("SC6D","TUBS",kRframeMaterial,cFramepar3,5);
516  TVirtualMC::GetMC()->Gsvolu("SD6D","TUBS",kRframeMaterial,rFramepar3,5);
517 
518  // create the horizontal frame volume
519 
520  TVirtualMC::GetMC()->Gsvolu("S05H","BOX",kHframeMaterial,hFramepar,3);
521  TVirtualMC::GetMC()->Gsvolu("SB5H","BOX",kHframeMaterial,hFramepar2,3);
522  TVirtualMC::GetMC()->Gsvolu("SC5H","BOX",kHframeMaterial,hFramepar3,3);
523  TVirtualMC::GetMC()->Gsvolu("SD5H","BOX",kHframeMaterial,hFramepar,3);
524  TVirtualMC::GetMC()->Gsvolu("S06H","BOX",kHframeMaterial,hFramepar,3);
525  TVirtualMC::GetMC()->Gsvolu("SC6H","BOX",kHframeMaterial,hFramepar3,3);
526  TVirtualMC::GetMC()->Gsvolu("SD6H","BOX",kHframeMaterial,hFramepar,3);
527 
528  // create the horizontal border volume
529 
530  TVirtualMC::GetMC()->Gsvolu("S05B","BOX",kBframeMaterial,bFramepar,3);
531  TVirtualMC::GetMC()->Gsvolu("SB5B","BOX",kBframeMaterial,bFramepar2,3);
532  TVirtualMC::GetMC()->Gsvolu("SC5B","BOX",kBframeMaterial,bFramepar3,3);
533  TVirtualMC::GetMC()->Gsvolu("SD5B","BOX",kBframeMaterial,bFramepar,3);
534  TVirtualMC::GetMC()->Gsvolu("S06B","BOX",kBframeMaterial,bFramepar,3);
535  TVirtualMC::GetMC()->Gsvolu("SC6B","BOX",kBframeMaterial,bFramepar3,3);
536  TVirtualMC::GetMC()->Gsvolu("SD6B","BOX",kBframeMaterial,bFramepar,3);
537 
538  // Replace the volume shape with a composite shape
539  // with substracted overlap with beam shield
540  if ( TVirtualMC::GetMC()->IsRootGeometrySupported() ) {
541 
542  // Get shape
543  Int_t nSlatType = 2;
544  Int_t nVol = 8;
545  const char* slatType = "CD"; // C: central slat; D: rounded slat
546  const char* volLetter = "CNXIPHBG";
547  TString volName;
548  TString compName;
549  TString csName;
550  TGeoVolume *mVol = 0x0;
551  TObjArray centerSlat(nSlatType*((nVol+1)*2));
552  TObjArray composite(nSlatType*((nVol+1)*2));
553 
554  // Beam shield recess
555  new TGeoTube("tubeCut", 0., AliMUONConstants::Rmin(2), kSlatWidth/2.+0.001);
556  // Displacement
557  TGeoTranslation* trCTube = new TGeoTranslation("trCTube", -(kPcbLength-csvPcbLength/2.+kVframeLength/2.), 0., 0.);
558  trCTube->RegisterYourself();
559  TGeoTranslation* trDTube = new TGeoTranslation("trDTube", -(kPcbLength+kVframeLength)/2., -kYpos3[1], 0.);
560  trDTube->RegisterYourself();
561  TGeoTranslation* trCBTube = new TGeoTranslation("trCBTube", 0., ( kPcbHeight - kBframeHeight ) / 2., 0.);
562  trCBTube->Add(trCTube);
563  trCBTube->RegisterYourself();
564  TGeoTranslation* trDBTube = new TGeoTranslation("trDBTube", 0., ( kPcbHeight - kBframeHeight ) / 2., 0.);
565  trDBTube->Add(trDTube);
566  trDBTube->RegisterYourself();
567 
568  Float_t cPhi2 = (TMath::Pi()/2.-TMath::ACos((kSensHeight/2.)/(AliMUONConstants::Rmin(2)-kRframeLength)));
569  TGeoBBox *boxCCut = new TGeoBBox("boxCCut",(cFramepar3[1]-cFramepar3[0]*TMath::Cos(cPhi2))/2., hFramepar3[1], cFramepar3[2]+0.001);
570  // Displacement
571  TGeoTranslation* trCBox = new TGeoTranslation("trCBox",cFramepar3[0]*TMath::Cos(cPhi2)+boxCCut->GetDX(), 0., 0.);
572  trCBox->RegisterYourself();
573  new TGeoBBox("boxDCut",(kPcbLength+kVframeLength)/2., hFramepar3[1], vFramepar[2]+0.001);
574  // Displacement
575  TGeoTranslation* trDBox = new TGeoTranslation("trDBox",kPcbLength/2., kYpos3[1], 0.);
576  trDBox->RegisterYourself();
577 
578  TGeoBBox *boxVframe = new TGeoBBox("boxVframe",vFramepar[0],vrFrameHeight/2., vFramepar[2]);
579  TGeoTranslation* trVBox = new TGeoTranslation("trVBox", 0., AliMUONConstants::Rmin(2)-kRframeLength + boxVframe->GetDY(), 0.);
580  trVBox->RegisterYourself();
581 
582  for(int iCh=5; iCh<=6; iCh++){
583  for (int iSlatType = 0; iSlatType<nSlatType; iSlatType++) {
584  for (int iVol = 0; iVol<nVol; iVol++){
585  Int_t lIndex = (iCh-5)*(nSlatType*(nVol+1))+iSlatType*(nVol+1)+iVol;
586  volName=Form("S%c%d%c",slatType[iSlatType],iCh,volLetter[iVol]);
587  mVol = gGeoManager->FindVolumeFast(volName);
588  if ( !mVol ) {
589  AliErrorStream()
590  << "Slat volume " << volName << " not found" << endl;
591  }
592  else {
593  centerSlat[lIndex] = mVol->GetShape();
594  csName=Form("centerSlat%c%d%c",slatType[iSlatType],iCh,volLetter[iVol]);
595  ((TGeoShape*)centerSlat[lIndex])->SetName(csName);
596 
597  // Composite shape
598  TString compOperation(csName);
599  compOperation+="-tubeCut:tr";
600  compOperation+=slatType[iSlatType];
601  if (strstr(volName,"B")){
602  compOperation+="B";
603  }
604  compOperation+="Tube";
605  compName=Form("composite%c%d%c",slatType[iSlatType],iCh,volLetter[iVol]);
606  composite[lIndex] = new TGeoCompositeShape(compName, compOperation.Data());
607  // Reset shape to volume
608  mVol->SetShape((TGeoShape*)composite[lIndex]);
609  }
610  }
611 
612  // For rounded spacer
613  Int_t lIndex = (iCh-5)*(nSlatType*(nVol+1))+iSlatType*(nVol+1)+nVol;
614  volName=Form("S%c%dD",slatType[iSlatType],iCh);
615  mVol = gGeoManager->FindVolumeFast(volName);
616  if ( !mVol ) {
617  AliErrorStream()
618  << "Slat volume " << volName << " not found" << endl;
619  }
620  else {
621  centerSlat[lIndex] = mVol->GetShape();
622  csName=Form("centerSlat%c%dD",slatType[iSlatType],iCh);
623  ((TGeoShape*)centerSlat[lIndex])->SetName(csName);
624 
625  // Composite shape
626  TString compOperation(csName);
627  if (strstr(volName,"SC")){
628  compOperation+="*boxCCut:trCBox";
629  }
630  if (strstr(volName,"SD")){
631  compOperation.Prepend("(");
632  compOperation+="+boxVframe:trVBox)*boxDCut:trDBox";
633  }
634  compName=Form("composite%c%dD",slatType[iSlatType],iCh);
635  composite[lIndex] = new TGeoCompositeShape(compName, compOperation.Data());
636  // Reset shape to volume
637  mVol->SetShape((TGeoShape*)composite[lIndex]);
638  }
639  }
640  }
641  }
642 
643  index = 0;
644  for (i = 0; i<kNslats3; i++){
645  for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
646 
647  if (i == 0 && quadrant == 2) continue;
648  if (i == 0 && quadrant == 4) continue;
649 
650  sprintf(idSlatCh5,"SLA%d",ConvertSlatNum(i,quadrant,kNslats3-1));
651  sprintf(idSlatCh6,"SLB%d",ConvertSlatNum(i,quadrant,kNslats3-1));
652  Int_t moduleSlatCh5 = GetModuleId(idSlatCh5);
653  Int_t moduleSlatCh6 = GetModuleId(idSlatCh6);
654  Float_t xvFrame = (slatLength3[i] - kVframeLength)/2.;
655  Float_t xvFrame2 = xvFrame;
656 
657  if (i == 0 || i == 1 || i == 2) xvFrame2 -= pcbDLength3; // Correct position (J.C.)
658 
659  // position the vertical frames
660  if ( i > 2) {
661  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05V", idSlatCh5,
662  (2*i+1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
663  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05V", idSlatCh5,
664  (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
665  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06V", idSlatCh6,
666  (2*i+1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
667  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06V", idSlatCh6,
668  (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
669  }
670 
671  if (i == 2) {
672  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05V", idSlatCh5,
673  (2*i+1)*10+quadrant,TGeoTranslation(xvFrame2,0.,0.));
674  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05V", idSlatCh5,
675  (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
676  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06V", idSlatCh6,
677  (2*i+1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
678  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06V", idSlatCh6,
679  (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
680  }
681 
682  // Different rotation due to new mapping convention
683  if (i == 0 || i == 1) { // first vertical spacers
684  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05V", idSlatCh5,
685  (2*i+1)*10+quadrant,TGeoTranslation(-xvFrame2,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
686  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06V", idSlatCh6,
687  (2*i+1)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
688  if (i == 0) { // rounded spacer for central slat (J.C.)
689  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("SC5D", idSlatCh5,
690  (2*i)*10+quadrant,TGeoTranslation(xvFrame,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
691  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("SC6D", idSlatCh6,
692  (2*i)*10+quadrant,TGeoTranslation(xvFrame,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
693 
694  }
695  if (i == 1) { // rounded + vertical spacer for rounded slat (J.C.)
696  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("SD5D", idSlatCh5,
697  (2*i)*10+quadrant,TGeoTranslation(xvFrame,-kYpos3[1],0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
698  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("SD6D", idSlatCh6,
699  (2*i)*10+quadrant,TGeoTranslation(xvFrame,-kYpos3[1],0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
700  }
701  }
702 
703  // position the panels and the insulating material
704  for (j = 0; j < kNPCB3[i]; j++){
705  index++;
706  xx = kSensLength * (-kNPCB3[i]/2. + j + 0.5);
707  Float_t xx2 = xx - pcbDLength3/2.;
708  Float_t xx3 = xx + (kSensLength-csvPcbLength)/2.;
709 
710  Float_t zPanel = spar[2] - nomexbpar[2];
711 
712  if (i==0 || i==1) { // Different rotation due to new mapping convention
713  if (i==0 && j==0) { // Rounded pcb of central slat (SR1, NR1)
714  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("SC5X", idSlatCh5, 2*index-1,TGeoTranslation(-xx3,0.,zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
715  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("SC5X", idSlatCh5, 2*index,TGeoTranslation(-xx3,0.,-zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
716  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("SC5I", idSlatCh5, index,TGeoTranslation(-xx3,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
717  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("SC6X", idSlatCh6, 2*index-1,TGeoTranslation(-xx3,0.,zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
718  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("SC6X", idSlatCh6, 2*index,TGeoTranslation(-xx3,0.,-zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
719  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("SC6I", idSlatCh6, index,TGeoTranslation(-xx3,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
720  }
721  else {
722  if (i==1 && j==0){ // Rounded pcb of rounded slats (SR2. NR2)
723  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("SD5X", idSlatCh5, 2*index-1,TGeoTranslation(-xx,0.,zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
724  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("SD5X", idSlatCh5, 2*index,TGeoTranslation(-xx,0.,-zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
725  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("SD5I", idSlatCh5, index,TGeoTranslation(-xx,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
726  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("SD6X", idSlatCh6, 2*index-1,TGeoTranslation(-xx,0.,zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
727  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("SD6X", idSlatCh6, 2*index,TGeoTranslation(-xx,0.,-zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
728  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("SD6I", idSlatCh6, index,TGeoTranslation(-xx,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
729  }
730  else {
731  if (j == kNPCB3[i]-1) { // 1 pcb is shortened by 5cm
732  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("SB5X", idSlatCh5, 2*index-1,TGeoTranslation(-xx2,0.,zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
733  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("SB5X", idSlatCh5, 2*index,TGeoTranslation(-xx2,0.,-zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
734  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("SB5I", idSlatCh5, index,TGeoTranslation(-xx2,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
735  }
736  else {
737  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05X", idSlatCh5, 2*index-1,TGeoTranslation(-xx,0.,zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
738  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05X", idSlatCh5, 2*index,TGeoTranslation(-xx,0.,-zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
739  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05I", idSlatCh5, index,TGeoTranslation(-xx,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
740  }
741  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06X", idSlatCh6, 2*index-1,TGeoTranslation(-xx,0.,zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
742  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06X", idSlatCh6, 2*index,TGeoTranslation(-xx,0.,-zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
743  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06I", idSlatCh6, index,TGeoTranslation(-xx,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
744  }
745  }
746  }
747  else {
748  if (i==2 && j == kNPCB3[i]-1) { // 1 pcb is shortened by 5cm
749  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("SB5X", idSlatCh5, 2*index-1,TGeoTranslation(xx2,0.,zPanel));
750  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("SB5X", idSlatCh5, 2*index,TGeoTranslation(xx2,0.,-zPanel));
751  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("SB5I", idSlatCh5, index,TGeoTranslation(xx2,0.,0.));
752  } else {
753  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05X", idSlatCh5, 2*index-1,TGeoTranslation(xx,0.,zPanel));
754  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05X", idSlatCh5, 2*index,TGeoTranslation(xx,0.,-zPanel));
755  GetEnvelopes(moduleSlatCh5)->AddEnvelopeConstituent("S05I", idSlatCh5, index,TGeoTranslation(xx,0.,0.));
756  }
757  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06X", idSlatCh6, 2*index-1,TGeoTranslation(xx,0.,zPanel));
758  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06X", idSlatCh6, 2*index,TGeoTranslation(xx,0.,-zPanel));
759  GetEnvelopes(moduleSlatCh6)->AddEnvelopeConstituent("S06I", idSlatCh6, index,TGeoTranslation(xx,0.,0.));
760  }
761  }
762  }
763  }
764 
765 
766  // position the nomex volume inside the panel volume
767  TVirtualMC::GetMC()->Gspos("S05N",1,"S05C",0.,0.,0.,0,"ONLY");
768  TVirtualMC::GetMC()->Gspos("SB5N",1,"SB5C",0.,0.,0.,0,"ONLY");
769  TVirtualMC::GetMC()->Gspos("SC5N",1,"SC5C",0.,0.,0.,0,"ONLY");
770  TVirtualMC::GetMC()->Gspos("SD5N",1,"SD5C",0.,0.,0.,0,"ONLY");
771  TVirtualMC::GetMC()->Gspos("S06N",1,"S06C",0.,0.,0.,0,"ONLY");
772  TVirtualMC::GetMC()->Gspos("SC6N",1,"SC6C",0.,0.,0.,0,"ONLY");
773  TVirtualMC::GetMC()->Gspos("SD6N",1,"SD6C",0.,0.,0.,0,"ONLY");
774 
775  // position panel volume inside the bulk nomex material volume
776  TVirtualMC::GetMC()->Gspos("S05C",1,"S05X",0.,0.,kNomexBWidth/2.,0,"ONLY");
777  TVirtualMC::GetMC()->Gspos("SB5C",1,"SB5X",0.,0.,kNomexBWidth/2.,0,"ONLY");
778  TVirtualMC::GetMC()->Gspos("SC5C",1,"SC5X",0.,0.,kNomexBWidth/2.,0,"ONLY");
779  TVirtualMC::GetMC()->Gspos("SD5C",1,"SD5X",0.,0.,kNomexBWidth/2.,0,"ONLY");
780  TVirtualMC::GetMC()->Gspos("S06C",1,"S06X",0.,0.,kNomexBWidth/2.,0,"ONLY");
781  TVirtualMC::GetMC()->Gspos("SC6C",1,"SC6X",0.,0.,kNomexBWidth/2.,0,"ONLY");
782  TVirtualMC::GetMC()->Gspos("SD6C",1,"SD6X",0.,0.,kNomexBWidth/2.,0,"ONLY");
783 
784  // position the PCB volume inside the insulating material volume
785  TVirtualMC::GetMC()->Gspos("S05P",1,"S05I",0.,0.,0.,0,"ONLY");
786  TVirtualMC::GetMC()->Gspos("SB5P",1,"SB5I",0.,0.,0.,0,"ONLY");
787  TVirtualMC::GetMC()->Gspos("SC5P",1,"SC5I",0.,0.,0.,0,"ONLY");
788  TVirtualMC::GetMC()->Gspos("SD5P",1,"SD5I",0.,0.,0.,0,"ONLY");
789  TVirtualMC::GetMC()->Gspos("S06P",1,"S06I",0.,0.,0.,0,"ONLY");
790  TVirtualMC::GetMC()->Gspos("SC6P",1,"SC6I",0.,0.,0.,0,"ONLY");
791  TVirtualMC::GetMC()->Gspos("SD6P",1,"SD6I",0.,0.,0.,0,"ONLY");
792 
793  // position the horizontal frame volume inside the PCB volume
794  TVirtualMC::GetMC()->Gspos("S05H",1,"S05P",0.,0.,0.,0,"ONLY");
795  TVirtualMC::GetMC()->Gspos("SB5H",1,"SB5P",0.,0.,0.,0,"ONLY");
796  TVirtualMC::GetMC()->Gspos("SC5H",1,"SC5P",0.,0.,0.,0,"ONLY");
797  TVirtualMC::GetMC()->Gspos("SD5H",1,"SD5P",0.,0.,0.,0,"ONLY");
798  TVirtualMC::GetMC()->Gspos("S06H",1,"S06P",0.,0.,0.,0,"ONLY");
799  TVirtualMC::GetMC()->Gspos("SC6H",1,"SC6P",0.,0.,0.,0,"ONLY");
800  TVirtualMC::GetMC()->Gspos("SD6H",1,"SD6P",0.,0.,0.,0,"ONLY");
801 
802  // position the sensitive volume inside the horizontal frame volume
803  TVirtualMC::GetMC()->Gsposp("S05G",1,"S05H",0.,0.,0.,0,"ONLY",senspar,3);
804  TVirtualMC::GetMC()->Gsposp("S05G",1,"SB5H",0.,0.,0.,0,"ONLY",senspar2,3);
805  TVirtualMC::GetMC()->Gspos("SC5G",1,"SC5H",0.,0.,0.,0,"ONLY");
806  TVirtualMC::GetMC()->Gspos("SD5G",1,"SD5H",0.,0.,0.,0,"ONLY");
807  TVirtualMC::GetMC()->Gsposp("S06G",1,"S06H",0.,0.,0.,0,"ONLY",senspar,3);
808  TVirtualMC::GetMC()->Gspos("SC6G",1,"SC6H",0.,0.,0.,0,"ONLY");
809  TVirtualMC::GetMC()->Gspos("SD6G",1,"SD6H",0.,0.,0.,0,"ONLY");
810 
811 
812  // position the border volumes inside the PCB volume
813  Float_t yborder = ( kPcbHeight - kBframeHeight ) / 2.;
814  Int_t rotB = 0;
815  TVirtualMC::GetMC()->Matrix(rotB,90,0,90,270,180,0); // rotation around x for second border
816 
817  TVirtualMC::GetMC()->Gspos("S05B",1,"S05P",0., yborder,0.,0,"ONLY");
818  TVirtualMC::GetMC()->Gspos("S05B",2,"S05P",0.,-yborder,0.,0,"ONLY");
819  TVirtualMC::GetMC()->Gspos("SB5B",1,"SB5P",0., yborder,0.,0,"ONLY");
820  TVirtualMC::GetMC()->Gspos("SB5B",2,"SB5P",0.,-yborder,0.,0,"ONLY");
821  TVirtualMC::GetMC()->Gspos("SC5B",1,"SC5P",0., yborder,0.,rotB,"ONLY");
822  TVirtualMC::GetMC()->Gspos("SC5B",2,"SC5P",0.,-yborder,0.,0,"ONLY");
823  TVirtualMC::GetMC()->Gspos("S05B",1,"SD5P",0., yborder,0.,0,"ONLY");
824  TVirtualMC::GetMC()->Gspos("SD5B",1,"SD5P",0.,-yborder,0.,0,"ONLY");
825 
826  TVirtualMC::GetMC()->Gspos("S06B",1,"S06P",0., yborder,0.,0,"ONLY");
827  TVirtualMC::GetMC()->Gspos("S06B",2,"S06P",0.,-yborder,0.,0,"ONLY");
828  TVirtualMC::GetMC()->Gspos("SC6B",1,"SC6P",0., yborder,0.,rotB,"ONLY");
829  TVirtualMC::GetMC()->Gspos("SC6B",2,"SC6P",0.,-yborder,0.,0,"ONLY");
830  TVirtualMC::GetMC()->Gspos("S06B",1,"SD6P",0., yborder,0.,0,"ONLY");
831  TVirtualMC::GetMC()->Gspos("SD6B",1,"SD6P",0.,-yborder,0.,0,"ONLY");
832 
833  // create the NULOC volume and position it in the horizontal frame
834  TVirtualMC::GetMC()->Gsvolu("S05E","BOX",kNulocMaterial,nulocpar,3);
835  TVirtualMC::GetMC()->Gsvolu("S06E","BOX",kNulocMaterial,nulocpar,3);
836  index = 0;
837  Float_t xxmax2 = xxmax - pcbDLength3/2.;
838  Float_t xxmax3 = xxmax - (kPcbLength-csvPcbLength)/2.;
839  Float_t rPhi3 = TMath::ASin((kYpos3[1]-kPcbHeight/2.)/AliMUONConstants::Rmin(2));
840  Float_t xxmax4 = (AliMUONConstants::Rmin(2)*TMath::Cos(rPhi3)-kVframeLength/2.) - (kBframeLength - kNulocLength)/2.;
841  for (xx = -xxmax; xx <= xxmax; xx += 2*kNulocLength) {
842  index++;
843  TVirtualMC::GetMC()->Gspos("S05E",2*index-1,"S05B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
844  TVirtualMC::GetMC()->Gspos("S05E",2*index ,"S05B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
845  TVirtualMC::GetMC()->Gspos("S06E",2*index-1,"S06B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
846  TVirtualMC::GetMC()->Gspos("S06E",2*index ,"S06B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
847  if (xx > -xxmax2 && xx< xxmax2) {
848  TVirtualMC::GetMC()->Gspos("S05E",2*index-1,"SB5B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
849  TVirtualMC::GetMC()->Gspos("S05E",2*index ,"SB5B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
850  }
851  if (xx > -xxmax3 && xx< xxmax3) {
852  TVirtualMC::GetMC()->Gspos("S05E",2*index-1,"SC5B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2., 0, "ONLY");
853  TVirtualMC::GetMC()->Gspos("S05E",2*index ,"SC5B", xx, 0., kBframeWidth/2.- kNulocWidth/2., 0, "ONLY");
854  TVirtualMC::GetMC()->Gspos("S06E",2*index-1,"SC6B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
855  TVirtualMC::GetMC()->Gspos("S06E",2*index ,"SC6B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
856  }
857  if (xx > xxmax4 && xx< xxmax) {
858  TVirtualMC::GetMC()->Gspos("S05E",2*index-1,"SD5B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
859  TVirtualMC::GetMC()->Gspos("S05E",2*index ,"SD5B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
860  TVirtualMC::GetMC()->Gspos("S06E",2*index-1,"SD6B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
861  TVirtualMC::GetMC()->Gspos("S06E",2*index ,"SD6B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
862  }
863  }
864 
865  //
866  //Geometry of the support pannel Verticla length 3.62m, horizontal length 1.62m, internal radius dMotherInner of SC05 and SC06 (F. Orsini, Saclay)
867  //Carbon fiber of 0.3 mm thick (2 layers) and a central layer of Nomex of 15mm thick.
868  // Outer excess and inner recess for mother volume radius
869  // with respect to ROuter and RInner
870  Float_t dMotherInner = AliMUONConstants::Rmin(2)-kRframeHeight;
871  Float_t nomexthickness = 1.5;
872  Float_t carbonthickness = 0.03;
873  Float_t supporthlength = 162.; // chamber 5
874  Float_t supporthlengthCh6 = 167.; // chamber 6
875  Float_t supportvlength = 362.;
876 
877  // Generating the composite shape of the carbon and nomex pannels
878  new TGeoBBox("shNomexBoxSt3",supporthlength/2., supportvlength/2. ,nomexthickness/2.+carbonthickness+3*kCableWidth);
879  new TGeoBBox("shCarbonBoxSt3",supporthlength/2., supportvlength/2. ,carbonthickness/2.);
880  new TGeoBBox("shNomexBoxSt3Ch6",(supporthlengthCh6)/2., supportvlength/2. ,nomexthickness/2.+carbonthickness+3*kCableWidth);
881  new TGeoBBox("shCarbonBoxSt3Ch6",(supporthlengthCh6)/2., supportvlength/2. ,carbonthickness/2.);
882  new TGeoTubeSeg("shNomexHoleSt3",0., dMotherInner, nomexthickness/2.+carbonthickness+3*kCableWidth+0.001, -90. ,90.);
883  new TGeoTubeSeg("shCarbonHoleSt3",0., dMotherInner, carbonthickness/2.+0.001, -90. ,90.);
884  TGeoTranslation* trHoleSt3 = new TGeoTranslation("trHoleSt3",-supporthlength/2.,0.,0.);
885  trHoleSt3->RegisterYourself();
886  TGeoTranslation* trHoleSt3Ch6 = new TGeoTranslation("trHoleSt3Ch6",-(supporthlengthCh6)/2.,0.,0.);
887  trHoleSt3Ch6->RegisterYourself();
888  TGeoCompositeShape* shNomexSupportSt3 = new TGeoCompositeShape("shNomexSupportSt3","shNomexBoxSt3-shNomexHoleSt3:trHoleSt3");
889  TGeoCompositeShape* shCarbonSupportSt3 = new TGeoCompositeShape("shCarbonSupportSt3","shCarbonBoxSt3-shCarbonHoleSt3:trHoleSt3");
890  TGeoCompositeShape* shNomexSupportSt3Ch6 = new TGeoCompositeShape("shNomexSupportSt3Ch6","shNomexBoxSt3Ch6-shNomexHoleSt3:trHoleSt3Ch6");
891  TGeoCompositeShape* shCarbonSupportSt3Ch6 = new TGeoCompositeShape("shCarbonSupportSt3Ch6","shCarbonBoxSt3Ch6-shCarbonHoleSt3:trHoleSt3Ch6");
892 
893  // Generating Nomex and Carbon pannel volumes
894  TGeoVolume * voNomexSupportSt3 = new TGeoVolume("S05S", shNomexSupportSt3, kMedNomex);
895  TGeoVolume * voCarbonSupportSt3 = new TGeoVolume("S05K", shCarbonSupportSt3, kMedCarbon);
896  TGeoVolume * voNomexSupportSt3Ch6 = new TGeoVolume("S06S", shNomexSupportSt3Ch6, kMedNomex);
897  TGeoVolume * voCarbonSupportSt3Ch6 = new TGeoVolume("S06K", shCarbonSupportSt3Ch6, kMedCarbon);
898 
899  TGeoTranslation *trCarbon1St3 = new TGeoTranslation("trCarbon1St3",0.,0., -(nomexthickness+carbonthickness)/2.);
900  TGeoTranslation *trCarbon2St3 = new TGeoTranslation("trCarbon2St3",0.,0., (nomexthickness+carbonthickness)/2.);
901  voNomexSupportSt3->AddNode(voCarbonSupportSt3,1,trCarbon1St3);
902  voNomexSupportSt3->AddNode(voCarbonSupportSt3,2,trCarbon2St3);
903  voNomexSupportSt3Ch6->AddNode(voCarbonSupportSt3Ch6,1,trCarbon1St3);
904  voNomexSupportSt3Ch6->AddNode(voCarbonSupportSt3Ch6,2,trCarbon2St3);
905 
906 
907  // Add readout cables
908  TVirtualMC::GetMC()->Gsvolu("S05L","BOX",kCableMaterial,dum,0);
909  TVirtualMC::GetMC()->Gsvolu("S06L","BOX",kCableMaterial,dum,0);
910 
911  ySlat3 = 0.;
912  Float_t lCableX = 0.;
913  Float_t lCableX6 = 0.;
914  Float_t lCableY = 0.;
915  Float_t lCableZ = 0.;
916  Float_t cablepar[3] = {static_cast<Float_t>(supporthlength/2.), static_cast<Float_t>(kCableHeight/2.), static_cast<Float_t>(kCableWidth/2.)};
917  Float_t cablepar6[3] = {static_cast<Float_t>(supporthlengthCh6/2.), static_cast<Float_t>(kCableHeight/2.), static_cast<Float_t>(kCableWidth/2.)};
918  Float_t lCableDY = 0.;
919  Int_t cIndex = 0;
920  Int_t cIndex6 = 0;
921  for (i = 0; i<kNslats3; i++){
922  Int_t iCable = 1;
923  cIndex = 0;
924  cIndex6 = 0;
925  ySlat3 += kYpos3[i];
926  lCableY = ySlat3;
927 
928  // Cables going out from the start of slat
929  if(kNPCB3[i]>=4 && i<kNslats3-2){ // Only if 4 or more pcb
930  // First top cables
931  cablepar[0] = supporthlength/2.;
932  lCableX = 0.;
933  cablepar6[0] = supporthlengthCh6/2.;
934  lCableX6 = 0.;
935  lCableDY = (kYpos3[i+1]+kYpos3[i+2])/2.-cablepar[1]; // half way between 2 slats on same side
936  lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);
937  if(i==0){ // central slat is shorter (rounded)
938  cablepar[0] -= (kPcbLength-csvPcbLength)/2.;
939  lCableX = (kPcbLength-csvPcbLength)/2.;
940  cablepar6[0] -= (kPcbLength-csvPcbLength)/2.;
941  lCableX6 = (kPcbLength-csvPcbLength)/2.;
942  }
943  TVirtualMC::GetMC()->Gsposp("S05L",100*i+cIndex++,"S05S",lCableX,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar,3);
944  TVirtualMC::GetMC()->Gsposp("S05L",100*i+cIndex++,"S05S",lCableX,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar,3);
945  TVirtualMC::GetMC()->Gsposp("S06L",100*i+cIndex6++,"S06S",lCableX6,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar6,3);
946  TVirtualMC::GetMC()->Gsposp("S06L",100*i+cIndex6++,"S06S",lCableX6,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar6,3);
947 
948  // Then bottom cables
949  if(i>0){
950  if(i==1){ // Rounded slat. Bottom cable starts at dMotherInner (beam pipe)
951  cablepar[0] -= dMotherInner/2.;
952  lCableX += dMotherInner/2.;
953  cablepar6[0] -= dMotherInner/2.;
954  lCableX6 += dMotherInner/2.;
955  lCableDY = (kYpos3[i]+kYpos3[i])/2.-cablepar[1];
956  }
957  if(i>=2){
958  lCableDY = (kYpos3[i]+kYpos3[i-1])/2.-cablepar[1]; // half way between 2 slats on same side
959  if ((lCableY-lCableDY)<(dMotherInner+cablepar[1])){
960  lCableDY = lCableY - dMotherInner - cablepar[1];
961  }
962  }
963  TVirtualMC::GetMC()->Gsposp("S05L",100*i+cIndex++,"S05S",lCableX,lCableY-lCableDY,lCableZ,0,"ONLY",cablepar,3);
964  TVirtualMC::GetMC()->Gsposp("S05L",100*i+cIndex++,"S05S",lCableX,-(lCableY-lCableDY),lCableZ,0,"ONLY",cablepar,3);
965  TVirtualMC::GetMC()->Gsposp("S06L",100*i+cIndex6++,"S06S",lCableX6,lCableY-lCableDY,lCableZ,0,"ONLY",cablepar6,3);
966  TVirtualMC::GetMC()->Gsposp("S06L",100*i+cIndex6++,"S06S",lCableX6,-(lCableY-lCableDY),lCableZ,0,"ONLY",cablepar6,3);
967  }
968  }
969 
970  // Rounded slats have an extra cable starting at second pcb
971  if(i==1){
972  // First top cables
973  cablepar[0] = (supporthlength-kPcbLength-kVframeLength)/2.;
974  lCableX = (kPcbLength+kVframeLength)/2.;
975  cablepar6[0] = (supporthlengthCh6-kPcbLength-kVframeLength)/2.;
976  lCableX6 = (kPcbLength+kVframeLength)/2.;
977  lCableDY = (kYpos3[i+1]+kYpos3[i+2])/2.-cablepar[1]; // half way between 2 slats on same side
978  lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);
979  TVirtualMC::GetMC()->Gsposp("S05L",100*i+cIndex++,"S05S",lCableX,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar,3);
980  TVirtualMC::GetMC()->Gsposp("S05L",100*i+cIndex++,"S05S",lCableX,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar,3);
981  TVirtualMC::GetMC()->Gsposp("S06L",100*i+cIndex6++,"S06S",lCableX6,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar6,3);
982  TVirtualMC::GetMC()->Gsposp("S06L",100*i+cIndex6++,"S06S",lCableX6,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar6,3);
983  // Then bottom cables
984  lCableDY = (kYpos3[i]+kYpos3[i])/2.-cablepar[1];
985  TVirtualMC::GetMC()->Gsposp("S05L",100*i+cIndex++,"S05S",lCableX,lCableY-lCableDY,lCableZ,0,"ONLY",cablepar,3);
986  TVirtualMC::GetMC()->Gsposp("S05L",100*i+cIndex++,"S05S",lCableX,-(lCableY-lCableDY),lCableZ,0,"ONLY",cablepar,3);
987  TVirtualMC::GetMC()->Gsposp("S06L",100*i+cIndex6++,"S06S",lCableX6,lCableY-lCableDY,lCableZ,0,"ONLY",cablepar6,3);
988  TVirtualMC::GetMC()->Gsposp("S06L",100*i+cIndex6++,"S06S",lCableX6,-(lCableY-lCableDY),lCableZ,0,"ONLY",cablepar6,3);
989  }
990 
991  // Cables going out from the end of the slats
992  // First top cables
993  cablepar[0] = (supporthlength-(slatLength3[i]+kDslatLength)+kVframeLength)/2.;
994  lCableX = slatLength3[i]-kVframeLength+kDslatLength+cablepar[0]-supporthlength/2.;
995  cablepar6[0] = (supporthlengthCh6-(slatLength3[i]+kDslatLength)+kVframeLength)/2.;
996  lCableX6 = slatLength3[i]-kVframeLength+kDslatLength+cablepar6[0]-supporthlengthCh6/2.;
997  if(i+1>=kNslats3 || i+2>=kNslats3){ // If no more higher slats, then use distance to lower slat
998  lCableDY = kPcbHeight/2.+cablepar[1];
999  }
1000  else {
1001  lCableDY = (kYpos3[i+1]+kYpos3[i+2])/2.-cablepar[1];
1002  }
1003  lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);
1004 
1005  if (i<=2){ // shortened pcb
1006  cablepar[0] += pcbDLength3/2.;
1007  lCableX -= pcbDLength3/2.;
1008  }
1009  TVirtualMC::GetMC()->Gsposp("S05L",100*i+cIndex++,"S05S",lCableX,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar,3);
1010  TVirtualMC::GetMC()->Gsposp("S05L",100*i+cIndex++,"S05S",lCableX,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar,3);
1011  TVirtualMC::GetMC()->Gsposp("S06L",100*i+cIndex6++,"S06S",lCableX6,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar6,3);
1012  TVirtualMC::GetMC()->Gsposp("S06L",100*i+cIndex6++,"S06S",lCableX6,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar6,3);
1013  // Then bottom cables
1014  if(i>0){ // Loop is over top half of slats, lower half are symmetric
1015  if (i==1) {
1016  lCableDY = (kYpos3[i]+kYpos3[i])/2.-cablepar[1];
1017  }
1018  else{
1019  lCableDY = (kYpos3[i]+kYpos3[i-1])/2.-cablepar[1]; // half way between 2 slats on same side
1020  }
1021  TVirtualMC::GetMC()->Gsposp("S05L",100*i+cIndex++,"S05S",lCableX,lCableY-lCableDY,lCableZ,0,"ONLY",cablepar,3);
1022  TVirtualMC::GetMC()->Gsposp("S05L",100*i+cIndex++,"S05S",lCableX,-(lCableY-lCableDY),lCableZ,0,"ONLY",cablepar,3);
1023  TVirtualMC::GetMC()->Gsposp("S06L",100*i+cIndex6++,"S06S",lCableX6,lCableY-lCableDY,lCableZ,0,"ONLY",cablepar6,3);
1024  TVirtualMC::GetMC()->Gsposp("S06L",100*i+cIndex6++,"S06S",lCableX6,-(lCableY-lCableDY),lCableZ,0,"ONLY",cablepar6,3);
1025  }
1026  }
1027 
1028  Float_t dzCh5 = dzCh;
1029  TGeoTranslation* trSupport1St3 = new TGeoTranslation("trSupport1St3", supporthlength/2., 0. , dzCh5);
1030  TGeoRotation* roSupportSt3 = new TGeoRotation("roSupportSt3",90.,180.,-90.);
1031  TGeoCombiTrans* coSupport2St3 = new TGeoCombiTrans(-supporthlength/2., 0., -dzCh5, roSupportSt3);
1032  TGeoTranslation* trSupport1St3Ch6 = new TGeoTranslation("trSupport1St3Ch6", supporthlengthCh6/2., 0. , dzCh5);
1033  TGeoCombiTrans* coSupport2St3Ch6 = new TGeoCombiTrans(-supporthlengthCh6/2., 0., -dzCh5, roSupportSt3);
1034  GetEnvelopes(5)->AddEnvelope("S05S", 0, 1, *trSupport1St3);
1035  GetEnvelopes(4)->AddEnvelope("S05S", 0, 2, *coSupport2St3);
1036  GetEnvelopes(7)->AddEnvelope("S06S", 0, 1, *trSupport1St3Ch6);
1037  GetEnvelopes(6)->AddEnvelope("S06S", 0, 2, *coSupport2St3Ch6);
1038  // End of pannel support geometry
1039 
1040  // cout << "Geometry for Station 3...... done" << endl;
1041  }
1042  if (fStations[3]) {
1043 
1044 
1045  // //********************************************************************
1046  // // Station 4 **
1047  // //********************************************************************
1048  // Mother volume for each chamber in St4 is an envelop (or assembly)
1049  // There is one assembly mother per half a chamber called SC07I, SC07O, SC08I and SC08O
1050  // Same volume name definitions as in St3
1051  const Int_t kNslats4 = 7; // number of slats per quadrant
1052  const Int_t kNPCB4[kNslats4] = {5, 6, 5, 5, 4, 3, 2}; // n PCB per slat
1053  const Float_t kXpos4[kNslats4] = {38.75, 0., 0., 0., 0., 0., 0.}; // J.C. Correct value
1054  const Float_t kYpos41[kNslats4] = {0., 38.2, 34.40, 36.60, 29.3, 37.0, 28.6};
1055  const Float_t kYpos42[kNslats4] = {0., 38.2, 37.85, 37.55, 29.4, 37.0, 28.6};
1056  Float_t slatLength4[kNslats4];
1057 
1058  Float_t rPhi1 = TMath::RadToDeg()*(TMath::ASin((kYpos41[1]-hFramepar[1])/(AliMUONConstants::Rmin(3))));
1059  Float_t rPhi2 = TMath::RadToDeg()*(TMath::ACos(-vFramepar[0]/(AliMUONConstants::Rmin(3)-kRframeLength)));
1060  Float_t rFramepar4[5] = { AliMUONConstants::Rmin(3)-kRframeLength, AliMUONConstants::Rmin(3), kRframeWidth, rPhi1, rPhi2};
1061  Float_t vrFrameHeight = hFramepar[1]+kYpos41[1]-AliMUONConstants::Rmin(3)+kRframeLength;
1062 
1063  char idSlatCh7[6];
1064  char idSlatCh8[6];
1065  Float_t xSlat4;
1066  Float_t ySlat41 = 0;
1067  Float_t ySlat42 = 0;
1068  angle = 0.;
1069 
1070  for (i = 0; i<kNslats4; i++){
1071  slatLength4[i] = kPcbLength * kNPCB4[i] + 2. * kVframeLength;
1072  xSlat4 = slatLength4[i]/2. + kDslatLength + kXpos4[i];
1073  ySlat41 += kYpos41[i];
1074  ySlat42 += kYpos42[i];
1075 
1076  spar[0] = slatLength4[i]/2.;
1077  spar[1] = kSlatHeight/2.;
1078  spar[2] = kSlatWidth/2.;
1079  Float_t dzCh4 = dzCh;
1080  Float_t zSlat4 = (i%2 ==0)? -zSlat : zSlat;
1081 
1082  sprintf(idSlatCh7,"SLC%d",kNslats4-1+i);
1083  detElemId = 713 - (i + kNslats4-1-6);
1084  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
1085  if (detElemId % 2 == 0) {
1086  if (detElemId == 712) // Round slat, new rotation due to mapping convention
1087  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(xSlat4, ySlat41, -zSlat4 + dzCh4),
1088  TGeoRotation("rot1",90,180+angle,90,90+angle,180,0) );
1089  else
1090  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(xSlat4, ySlat41, -zSlat4 + dzCh4),
1091  TGeoRotation("rot1",90,angle,90,90+angle,0,0) );
1092  }
1093  else
1094  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(xSlat4, ySlat41, -zSlat4 + dzCh4),
1095  TGeoRotation("rot1",90,angle,90,270+angle,180,0) );
1096 
1097  sprintf(idSlatCh7,"SLC%d",3*kNslats4-2+i);
1098  detElemId = 700 + (i + kNslats4-1-6);
1099  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
1100  if (detElemId % 2 == 1) {
1101  if (detElemId == 701) // Round slat, new rotation due to mapping convention
1102  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(-xSlat4, ySlat41, zSlat4 - dzCh4),
1103  TGeoRotation("rot2",90,angle,90,90+angle,0,0) );
1104  else
1105  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(-xSlat4, ySlat41, zSlat4 - dzCh4),
1106  TGeoRotation("rot2",90,180+angle,90,90+angle,180,0) );
1107  }
1108  else
1109  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(-xSlat4, ySlat41, zSlat4 - dzCh4),
1110  TGeoRotation("rot2",90,180+angle,90,270+angle,0,0) );
1111 
1112  if (i > 0) {
1113  sprintf(idSlatCh7,"SLC%d",kNslats4-1-i);
1114  detElemId = 713 + (i + kNslats4-1-6);
1115  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
1116  if (detElemId % 2 == 0) {
1117  if (detElemId == 714) // Round slat, new rotation due to mapping convention
1118  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(xSlat4, -ySlat41, -zSlat4 + dzCh4),
1119  TGeoRotation("rot3",90,180+angle,90,270+angle,0,0) );
1120  else
1121  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(xSlat4, -ySlat41, -zSlat4 + dzCh4),
1122  TGeoRotation("rot3",90,angle,90,90+angle,0,0) );
1123  }
1124  else
1125  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(xSlat4, -ySlat41, -zSlat4 + dzCh4),
1126  TGeoRotation("rot3",90,angle,90,270+angle,180,0) );
1127 
1128  sprintf(idSlatCh7,"SLC%d",3*kNslats4-2-i);
1129  detElemId = 726 - (i + kNslats4-1-6);
1130  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
1131  if (detElemId % 2 == 1) {
1132  if (detElemId == 725) // Round slat, new rotation due to mapping convention
1133  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(-xSlat4, -ySlat41, zSlat4 - dzCh4),
1134  TGeoRotation("rot4",90,angle,90,270+angle,180,0) );
1135  else
1136  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(-xSlat4, -ySlat41, zSlat4 - dzCh4),
1137  TGeoRotation("rot4",90,180+angle,90,90+angle,180,0) );
1138  }
1139  else
1140  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh7, detElemId, true, TGeoTranslation(-xSlat4, -ySlat41, zSlat4 - dzCh4),
1141  TGeoRotation("rot4",90,180+angle,90,270+angle,0,0) );
1142  }
1143 
1144  sprintf(idSlatCh8,"SLD%d",kNslats4-1+i);
1145  detElemId = 813 - (i + kNslats4-1-6);
1146  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
1147  if (detElemId % 2 == 0) {
1148  if (detElemId == 812) // Round slat, new rotation due to mapping convention
1149  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(xSlat4, ySlat42, -zSlat4 + dzCh4),
1150  TGeoRotation("rot5",90,180+angle,90,90+angle,180,0) );
1151  else
1152  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(xSlat4, ySlat42, -zSlat4 + dzCh4),
1153  TGeoRotation("rot5",90,angle,90,90+angle,0,0) );
1154  }
1155  else
1156  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(xSlat4, ySlat42, -zSlat4 + dzCh4),
1157  TGeoRotation("rot5",90,angle,90,270+angle,180,0) );
1158 
1159  sprintf(idSlatCh8,"SLD%d",3*kNslats4-2+i);
1160  detElemId = 800 + (i + kNslats4-1-6);
1161  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
1162  if (detElemId % 2 == 1) {
1163  if (detElemId == 801) // Round slat, new rotation due to mapping convention
1164  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(-xSlat4, ySlat42, zSlat4 - dzCh4),
1165  TGeoRotation("rot6",90,angle,90,90+angle,0,0) );
1166  else
1167  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(-xSlat4, ySlat42, zSlat4 - dzCh4),
1168  TGeoRotation("rot6",90,180+angle,90,90+angle,180,0) );
1169  }
1170  else
1171  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(-xSlat4, ySlat42, zSlat4 - dzCh4),
1172  TGeoRotation("rot6",90,180+angle,90,270+angle,0,0) );
1173  if (i > 0) {
1174  sprintf(idSlatCh8,"SLD%d",kNslats4-1-i);
1175  detElemId = 813 + (i + kNslats4-1-6);
1176  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
1177  if (detElemId % 2 == 0) {
1178  if (detElemId == 814) // Round slat, new rotation due to mapping convention
1179  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(xSlat4, -ySlat42, -zSlat4 + dzCh4),
1180  TGeoRotation("rot7",90,180+angle,90,270+angle,0,0) );
1181  else
1182  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(xSlat4, -ySlat42, -zSlat4 + dzCh4),
1183  TGeoRotation("rot7",90,angle,90,90+angle,0,0) );
1184  }
1185  else
1186  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(xSlat4, -ySlat42, -zSlat4 + dzCh4),
1187  TGeoRotation("rot7",90,angle,90,270+angle,180,0) );
1188 
1189  sprintf(idSlatCh8,"SLD%d",3*kNslats4-2-i);
1190  detElemId = 826 - (i + kNslats4-1-6);
1191  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
1192  if (detElemId % 2 == 1) {
1193  if (detElemId == 825 ) // Round slat, new rotation due to mapping convention
1194  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(-xSlat4, -ySlat42, zSlat4 - dzCh4),
1195  TGeoRotation("rot8",90,angle,90,270+angle,180,0) );
1196  else
1197  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(-xSlat4, -ySlat42, zSlat4 - dzCh4),
1198  TGeoRotation("rot8",90,180+angle,90,90+angle,180,0) );
1199  }
1200  else
1201  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh8, detElemId, true, TGeoTranslation(-xSlat4, -ySlat42, zSlat4 - dzCh4),
1202  TGeoRotation("rot8",90,180+angle,90,270+angle,0,0) );
1203 
1204  }
1205  }
1206 
1207  // create the panel volume
1208 
1209  TVirtualMC::GetMC()->Gsvolu("S07C","BOX",kCarbonMaterial,panelpar,3);
1210  TVirtualMC::GetMC()->Gsvolu("SD7C","BOX",kCarbonMaterial,panelpar,3);
1211  TVirtualMC::GetMC()->Gsvolu("S08C","BOX",kCarbonMaterial,panelpar,3);
1212  TVirtualMC::GetMC()->Gsvolu("SD8C","BOX",kCarbonMaterial,panelpar,3);
1213 
1214  // create the nomex volume
1215 
1216  TVirtualMC::GetMC()->Gsvolu("S07N","BOX",kNomexMaterial,nomexpar,3);
1217  TVirtualMC::GetMC()->Gsvolu("SD7N","BOX",kNomexMaterial,nomexpar,3);
1218  TVirtualMC::GetMC()->Gsvolu("S08N","BOX",kNomexMaterial,nomexpar,3);
1219  TVirtualMC::GetMC()->Gsvolu("SD8N","BOX",kNomexMaterial,nomexpar,3);
1220 
1221 
1222  // create the nomex volume (bulk)
1223 
1224  TVirtualMC::GetMC()->Gsvolu("S07X","BOX",kNomexBMaterial,nomexbpar,3);
1225  TVirtualMC::GetMC()->Gsvolu("SD7X","BOX",kNomexBMaterial,nomexbpar,3);
1226  TVirtualMC::GetMC()->Gsvolu("S08X","BOX",kNomexBMaterial,nomexbpar,3);
1227  TVirtualMC::GetMC()->Gsvolu("SD8X","BOX",kNomexBMaterial,nomexbpar,3);
1228 
1229  // create the insulating material volume
1230 
1231  TVirtualMC::GetMC()->Gsvolu("S07I","BOX",kInsuMaterial,insupar,3);
1232  TVirtualMC::GetMC()->Gsvolu("SD7I","BOX",kInsuMaterial,insupar,3);
1233  TVirtualMC::GetMC()->Gsvolu("S08I","BOX",kInsuMaterial,insupar,3);
1234  TVirtualMC::GetMC()->Gsvolu("SD8I","BOX",kInsuMaterial,insupar,3);
1235 
1236  // create the PCB volume
1237 
1238  TVirtualMC::GetMC()->Gsvolu("S07P","BOX",kPcbMaterial,pcbpar,3);
1239  TVirtualMC::GetMC()->Gsvolu("SD7P","BOX",kPcbMaterial,pcbpar,3);
1240  TVirtualMC::GetMC()->Gsvolu("S08P","BOX",kPcbMaterial,pcbpar,3);
1241  TVirtualMC::GetMC()->Gsvolu("SD8P","BOX",kPcbMaterial,pcbpar,3);
1242 
1243  // create the sensitive volumes,
1244 
1245  TVirtualMC::GetMC()->Gsvolu("S07G","BOX",kSensMaterial,dum,0);
1246  TVirtualMC::GetMC()->Gsvolu("SD7G","BOX",kSensMaterial,senspar,3);
1247  TVirtualMC::GetMC()->Gsvolu("S08G","BOX",kSensMaterial,dum,0);
1248  TVirtualMC::GetMC()->Gsvolu("SD8G","BOX",kSensMaterial,senspar,3);
1249 
1250  // create the vertical frame volume
1251 
1252  TVirtualMC::GetMC()->Gsvolu("S07V","BOX",kVframeMaterial,vFramepar,3);
1253  TVirtualMC::GetMC()->Gsvolu("S08V","BOX",kVframeMaterial,vFramepar,3);
1254 
1255  // create the rounded vertical frame volume
1256 
1257  TVirtualMC::GetMC()->Gsvolu("SD7D","TUBS",kRframeMaterial,rFramepar4,5);
1258  TVirtualMC::GetMC()->Gsvolu("SD8D","TUBS",kRframeMaterial,rFramepar4,5);
1259 
1260  // create the horizontal frame volume
1261 
1262  TVirtualMC::GetMC()->Gsvolu("S07H","BOX",kHframeMaterial,hFramepar,3);
1263  TVirtualMC::GetMC()->Gsvolu("SD7H","BOX",kHframeMaterial,hFramepar,3);
1264  TVirtualMC::GetMC()->Gsvolu("S08H","BOX",kHframeMaterial,hFramepar,3);
1265  TVirtualMC::GetMC()->Gsvolu("SD8H","BOX",kHframeMaterial,hFramepar,3);
1266 
1267  // create the horizontal border volume
1268 
1269  TVirtualMC::GetMC()->Gsvolu("S07B","BOX",kBframeMaterial,bFramepar,3);
1270  TVirtualMC::GetMC()->Gsvolu("SD7B","BOX",kBframeMaterial,bFramepar,3);
1271  TVirtualMC::GetMC()->Gsvolu("S08B","BOX",kBframeMaterial,bFramepar,3);
1272  TVirtualMC::GetMC()->Gsvolu("SD8B","BOX",kBframeMaterial,bFramepar,3);
1273 
1274  // Replace the volume shape with a composite shape
1275  // with substracted overlap with beam shield
1276  if ( TVirtualMC::GetMC()->IsRootGeometrySupported() ) {
1277 
1278  // Get shape
1279  Int_t nSlatType = 1;
1280  Int_t nVol = 8;
1281  const char* slatType = "D"; // D: Rounded slat
1282  const char* volLetter = "CNXIPHBG";
1283  TString volName;
1284  TString compName;
1285  TString csName;
1286  TGeoVolume *mVol = 0x0;
1287  // Beam shield recess
1288  new TGeoTube("tube4Cut", 0., AliMUONConstants::Rmin(3), kSlatWidth/2.+0.001);
1289  TObjArray rounded4Slat(nSlatType*((nVol+1)*2));
1290  // Displacement
1291  TGeoTranslation* trDTube4 = new TGeoTranslation("trDTube4", -(kPcbLength+kVframeLength)/2., -kYpos41[1], 0.);
1292  trDTube4->RegisterYourself();
1293  TGeoTranslation* trDBTube4 = new TGeoTranslation("trDBTube4", 0., ( kPcbHeight - kBframeHeight ) / 2., 0.);
1294  trDBTube4->Add(trDTube4);
1295  trDBTube4->RegisterYourself();
1296 
1297  TObjArray composite4(nSlatType*((nVol+1)*2));
1298  new TGeoBBox("box4DCut",(kPcbLength+kVframeLength)/2., hFramepar[1], vFramepar[2]+0.001);
1299  // Displacement
1300  TGeoTranslation* trDBox4 = new TGeoTranslation("trDBox4",kPcbLength/2., kYpos41[1], 0.);
1301  trDBox4->RegisterYourself();
1302 
1303  TGeoBBox *box4Vframe = new TGeoBBox("box4Vframe",vFramepar[0],vrFrameHeight/2., vFramepar[2]);
1304  TGeoTranslation* trVBox4 = new TGeoTranslation("trVBox4", 0., AliMUONConstants::Rmin(3)-kRframeLength + box4Vframe->GetDY(), 0.);
1305  trVBox4->RegisterYourself();
1306 
1307  for(int iCh=7; iCh<=8; iCh++){
1308  for (int iSlatType = 0; iSlatType<nSlatType; iSlatType++) {
1309  for (int iVol = 0; iVol<nVol; iVol++){
1310  Int_t lIndex = (iCh-7)*(nSlatType*(nVol+1))+iSlatType*(nVol+1)+iVol;
1311  volName=Form("S%c%d%c",slatType[iSlatType],iCh,volLetter[iVol]);
1312  mVol = gGeoManager->FindVolumeFast(volName);
1313  if ( !mVol ) {
1314  AliErrorStream()
1315  << "Slat volume " << volName << " not found" << endl;
1316  }
1317  else {
1318  rounded4Slat[lIndex] = mVol->GetShape();
1319  csName=Form("rounded4Slat%c%d%c",slatType[iSlatType],iCh,volLetter[iVol]);
1320  ((TGeoShape*)rounded4Slat[lIndex])->SetName(csName);
1321 
1322  // Composite shape
1323  TString compOperation(csName);
1324  compOperation+="-tube4Cut:tr";
1325  compOperation+=slatType[iSlatType];
1326  if (strstr(volName,"B")){
1327  compOperation+="B";
1328  }
1329  compOperation+="Tube4";
1330  compName=Form("composite4%c%d%c",slatType[iSlatType],iCh,volLetter[iVol]);
1331  composite4[lIndex] = new TGeoCompositeShape(compName, compOperation.Data());
1332 
1333  // Reset shape to volume
1334  mVol->SetShape((TGeoShape*)composite4[lIndex]);
1335  }
1336  }
1337 
1338  // For rounded spacer
1339  Int_t lIndex = (iCh-7)*(nSlatType*(nVol+1))+iSlatType*(nVol+1)+nVol;
1340  volName=Form("S%c%dD",slatType[iSlatType],iCh);
1341  mVol = gGeoManager->FindVolumeFast(volName);
1342  if ( !mVol ) {
1343  AliErrorStream()
1344  << "Slat volume " << volName << " not found" << endl;
1345  }
1346  else {
1347  rounded4Slat[lIndex] = mVol->GetShape();
1348  csName=Form("rounded4Slat%c%dD",slatType[iSlatType],iCh);
1349  ((TGeoShape*)rounded4Slat[lIndex])->SetName(csName);
1350 
1351  // Composite shape
1352  TString compOperation(csName);
1353  if (strstr(volName,"SD")){
1354  compOperation.Prepend("(");
1355  compOperation+="+box4Vframe:trVBox4)*box4DCut:trDBox4";
1356  }
1357  compName=Form("composite4%c%dD",slatType[iSlatType],iCh);
1358  composite4[lIndex] = new TGeoCompositeShape(compName, compOperation.Data());
1359  // Reset shape to volume
1360  mVol->SetShape((TGeoShape*)composite4[lIndex]);
1361  }
1362  }
1363  }
1364  }
1365 
1366 
1367  index = 0;
1368  for (i = 0; i < kNslats4; i++){
1369  for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
1370 
1371  if (i == 0 && quadrant == 2) continue;
1372  if (i == 0 && quadrant == 4) continue;
1373 
1374  sprintf(idSlatCh7,"SLC%d",ConvertSlatNum(i,quadrant,kNslats4-1));
1375  sprintf(idSlatCh8,"SLD%d",ConvertSlatNum(i,quadrant,kNslats4-1));
1376  Int_t moduleSlatCh7 = GetModuleId(idSlatCh7);
1377  Int_t moduleSlatCh8 = GetModuleId(idSlatCh8);
1378 
1379  Float_t xvFrame = (slatLength4[i] - kVframeLength)/2.;
1380 
1381  // position the vertical frames
1382  if (i != 1) {
1383  GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i+1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
1384  GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
1385  GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i+1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
1386  GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
1387  } else { // Vertical and Rounded+Vertical spacer - Different rotation due to new mapping convention
1388  GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("S07V", idSlatCh7, (2*i+1)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1389  GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("SD7D", idSlatCh7, (2*i)*10+quadrant,TGeoTranslation(xvFrame,-kYpos41[1],0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1390  GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("S08V", idSlatCh8, (2*i+1)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1391  GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("SD8D", idSlatCh8, (2*i)*10+quadrant,TGeoTranslation(+xvFrame,-kYpos42[1],0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1392  }
1393  // position the panels and the insulating material
1394  for (j = 0; j < kNPCB4[i]; j++){
1395  index++;
1396  xx = kSensLength * (-kNPCB4[i]/2.+j+.5);
1397  Float_t zPanel = spar[2] - nomexbpar[2];
1398  if (i==1) { // Different rotation due to new mapping convention
1399  if (j==0){ // Rounded pcb of rounded slat
1400  GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("SD7X", idSlatCh7, 2*index-1,TGeoTranslation(-xx,0.,zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1401  GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("SD7X", idSlatCh7, 2*index,TGeoTranslation(-xx,0.,-zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1402  GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("SD7I", idSlatCh7, index,TGeoTranslation(-xx,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1403  GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("SD8X", idSlatCh8, 2*index-1,TGeoTranslation(-xx,0.,zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1404  GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("SD8X", idSlatCh8, 2*index,TGeoTranslation(-xx,0.,-zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1405  GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("SD8I", idSlatCh8, index,TGeoTranslation(-xx,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1406  } else {
1407  GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("S07X", idSlatCh7, 2*index-1,TGeoTranslation(-xx,0.,zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1408  GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("S07X", idSlatCh7, 2*index,TGeoTranslation(-xx,0.,-zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1409  GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("S07I", idSlatCh7, index,TGeoTranslation(-xx,0.,0.));
1410  GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("S08X", idSlatCh8, 2*index-1,TGeoTranslation(-xx,0.,zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1411  GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("S08X", idSlatCh8, 2*index,TGeoTranslation(-xx,0.,-zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1412  GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("S08I", idSlatCh8, index,TGeoTranslation(-xx,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1413  }
1414  } else {
1415  GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("S07X", idSlatCh7, 2*index-1,TGeoTranslation(xx,0.,zPanel));
1416  GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("S07X", idSlatCh7, 2*index,TGeoTranslation(xx,0.,-zPanel));
1417  GetEnvelopes(moduleSlatCh7)->AddEnvelopeConstituent("S07I", idSlatCh7, index,TGeoTranslation(xx,0.,0.));
1418  GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("S08X", idSlatCh8, 2*index-1,TGeoTranslation(xx,0.,zPanel));
1419  GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("S08X", idSlatCh8, 2*index,TGeoTranslation(xx,0.,-zPanel));
1420  GetEnvelopes(moduleSlatCh8)->AddEnvelopeConstituent("S08I", idSlatCh8, index,TGeoTranslation(xx,0.,0.));
1421  }
1422  }
1423  }
1424  }
1425 
1426  // position the nomex volume inside the panel volume
1427  TVirtualMC::GetMC()->Gspos("S07N",1,"S07C",0.,0.,0.,0,"ONLY");
1428  TVirtualMC::GetMC()->Gspos("SD7N",1,"SD7C",0.,0.,0.,0,"ONLY");
1429  TVirtualMC::GetMC()->Gspos("S08N",1,"S08C",0.,0.,0.,0,"ONLY");
1430  TVirtualMC::GetMC()->Gspos("SD8N",1,"SD8C",0.,0.,0.,0,"ONLY");
1431 
1432  // position panel volume inside the bulk nomex material volume
1433  TVirtualMC::GetMC()->Gspos("S07C",1,"S07X",0.,0.,kNomexBWidth/2.,0,"ONLY");
1434  TVirtualMC::GetMC()->Gspos("SD7C",1,"SD7X",0.,0.,kNomexBWidth/2.,0,"ONLY");
1435  TVirtualMC::GetMC()->Gspos("S08C",1,"S08X",0.,0.,kNomexBWidth/2.,0,"ONLY");
1436  TVirtualMC::GetMC()->Gspos("SD8C",1,"SD8X",0.,0.,kNomexBWidth/2.,0,"ONLY");
1437 
1438  // position the PCB volume inside the insulating material volume
1439  TVirtualMC::GetMC()->Gspos("S07P",1,"S07I",0.,0.,0.,0,"ONLY");
1440  TVirtualMC::GetMC()->Gspos("SD7P",1,"SD7I",0.,0.,0.,0,"ONLY");
1441  TVirtualMC::GetMC()->Gspos("S08P",1,"S08I",0.,0.,0.,0,"ONLY");
1442  TVirtualMC::GetMC()->Gspos("SD8P",1,"SD8I",0.,0.,0.,0,"ONLY");
1443 
1444  // position the horizontal frame volume inside the PCB volume
1445  TVirtualMC::GetMC()->Gspos("S07H",1,"S07P",0.,0.,0.,0,"ONLY");
1446  TVirtualMC::GetMC()->Gspos("SD7H",1,"SD7P",0.,0.,0.,0,"ONLY");
1447  TVirtualMC::GetMC()->Gspos("S08H",1,"S08P",0.,0.,0.,0,"ONLY");
1448  TVirtualMC::GetMC()->Gspos("SD8H",1,"SD8P",0.,0.,0.,0,"ONLY");
1449 
1450  // position the sensitive volume inside the horizontal frame volume
1451  TVirtualMC::GetMC()->Gsposp("S07G",1,"S07H",0.,0.,0.,0,"ONLY",senspar,3);
1452  TVirtualMC::GetMC()->Gspos("SD7G",1,"SD7H",0.,0.,0.,0,"ONLY");
1453  TVirtualMC::GetMC()->Gsposp("S08G",1,"S08H",0.,0.,0.,0,"ONLY",senspar,3);
1454  TVirtualMC::GetMC()->Gspos("SD8G",1,"SD8H",0.,0.,0.,0,"ONLY");
1455 
1456  // position the border volumes inside the PCB volume
1457  Float_t yborder = ( kPcbHeight - kBframeHeight ) / 2.;
1458  TVirtualMC::GetMC()->Gspos("S07B",1,"S07P",0., yborder,0.,0,"ONLY");
1459  TVirtualMC::GetMC()->Gspos("S07B",2,"S07P",0.,-yborder,0.,0,"ONLY");
1460  TVirtualMC::GetMC()->Gspos("S07B",1,"SD7P",0., yborder,0.,0,"ONLY");
1461  TVirtualMC::GetMC()->Gspos("SD7B",1,"SD7P",0.,-yborder,0.,0,"ONLY");
1462  TVirtualMC::GetMC()->Gspos("S08B",1,"S08P",0., yborder,0.,0,"ONLY");
1463  TVirtualMC::GetMC()->Gspos("S08B",2,"S08P",0.,-yborder,0.,0,"ONLY");
1464  TVirtualMC::GetMC()->Gspos("S08B",1,"SD8P",0., yborder,0.,0,"ONLY");
1465  TVirtualMC::GetMC()->Gspos("SD8B",1,"SD8P",0.,-yborder,0.,0,"ONLY");
1466 
1467  // create the NULOC volume and position it in the horizontal frame
1468 
1469  TVirtualMC::GetMC()->Gsvolu("S07E","BOX",kNulocMaterial,nulocpar,3);
1470  TVirtualMC::GetMC()->Gsvolu("S08E","BOX",kNulocMaterial,nulocpar,3);
1471  index = 0;
1472  Float_t rPhi3 = TMath::ASin((kYpos41[1]-kPcbHeight/2.)/AliMUONConstants::Rmin(3));
1473  Float_t xxmax4 = (AliMUONConstants::Rmin(3)*TMath::Cos(rPhi3)-kVframeLength/2.) - (kBframeLength - kNulocLength)/2.;
1474  for (xx = -xxmax; xx <= xxmax; xx += 2*kNulocLength) {
1475  index++;
1476  TVirtualMC::GetMC()->Gspos("S07E",2*index-1,"S07B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
1477  TVirtualMC::GetMC()->Gspos("S07E",2*index ,"S07B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
1478  TVirtualMC::GetMC()->Gspos("S08E",2*index-1,"S08B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
1479  TVirtualMC::GetMC()->Gspos("S08E",2*index ,"S08B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
1480  }
1481  if (xx > xxmax4 && xx< xxmax) {
1482  TVirtualMC::GetMC()->Gspos("S07E",2*index-1,"SD7B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
1483  TVirtualMC::GetMC()->Gspos("S07E",2*index ,"SD7B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
1484  TVirtualMC::GetMC()->Gspos("S08E",2*index-1,"SD8B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
1485  TVirtualMC::GetMC()->Gspos("S08E",2*index ,"SD8B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
1486  }
1487 
1488  //
1489  //Geometry of the support pannel Verticla length 5.3m, horizontal length 2.6m, internal radius dMotherInner o SC07 and SC08 (F. Orsini, Saclay)
1490  //Carbon fiber of 0.3 mm thick (2 layers) and a central layer of Nomex of 15mm thick.
1491  Float_t dMotherInner = AliMUONConstants::Rmin(3)-kRframeHeight;
1492  Float_t nomexthickness = 1.5;
1493  Float_t carbonthickness = 0.03;
1494  Float_t supporthlength = 260.;
1495  Float_t supportvlength = 530.;
1496  // Generating the composite shape of the carbon and nomex pannels
1497  new TGeoBBox("shNomexBoxSt4",supporthlength/2., supportvlength/2. ,nomexthickness/2.+carbonthickness+3*kCableWidth);
1498  new TGeoBBox("shCarbonBoxSt4",supporthlength/2., supportvlength/2. ,carbonthickness/2.);
1499  new TGeoTubeSeg("shNomexHoleSt4",0., dMotherInner, nomexthickness/2.+carbonthickness+3*kCableWidth+0.001, -90. ,90.);
1500  new TGeoTubeSeg("shCarbonHoleSt4",0., dMotherInner, carbonthickness/2.+0.001, -90. ,90.);
1501  TGeoTranslation* trHoleSt4 = new TGeoTranslation("trHoleSt4",-supporthlength/2.,0.,0.);
1502  trHoleSt4->RegisterYourself();
1503  TGeoCompositeShape* shNomexSupportSt4 = new TGeoCompositeShape("shNomexSupportSt4","shNomexBoxSt4-shNomexHoleSt4:trHoleSt4");
1504  TGeoCompositeShape* shCarbonSupportSt4 = new TGeoCompositeShape("shCarbonSupportSt4","shCarbonBoxSt4-shCarbonHoleSt4:trHoleSt4");
1505 
1506  // Generating Nomex and Carbon pannel volumes
1507  TGeoVolume* voNomexSupportSt4 = new TGeoVolume("S07S", shNomexSupportSt4, kMedNomex);
1508  TGeoVolume* voCarbonSupportSt4 = new TGeoVolume("S07K", shCarbonSupportSt4, kMedCarbon);
1509  TGeoVolume* voNomexSupportSt4Ch8 = new TGeoVolume("S08S", shNomexSupportSt4, kMedNomex);
1510  TGeoVolume* voCarbonSupportSt4Ch8 = new TGeoVolume("S08K", shCarbonSupportSt4, kMedCarbon);
1511  TGeoTranslation* trCarbon1St4 = new TGeoTranslation("trCarbon1St4",0.,0., -(nomexthickness+carbonthickness)/2.);
1512  TGeoTranslation* trCarbon2St4 = new TGeoTranslation("trCarbon2St4",0.,0., (nomexthickness+carbonthickness)/2.);
1513  voNomexSupportSt4->AddNode(voCarbonSupportSt4,1,trCarbon1St4);
1514  voNomexSupportSt4->AddNode(voCarbonSupportSt4,2,trCarbon2St4);
1515  voNomexSupportSt4Ch8->AddNode(voCarbonSupportSt4Ch8,1,trCarbon1St4);
1516  voNomexSupportSt4Ch8->AddNode(voCarbonSupportSt4Ch8,2,trCarbon2St4);
1517 
1518  // Add readout cables
1519  TVirtualMC::GetMC()->Gsvolu("S07L","BOX",kCableMaterial,dum,0);
1520  TVirtualMC::GetMC()->Gsvolu("S08L","BOX",kCableMaterial,dum,0);
1521 
1522  ySlat41 = 0.;
1523  ySlat42 = 0.;
1524  Float_t lCableX = 0.;
1525  Float_t lCableY = 0.;
1526  Float_t lCableY8 = 0.;
1527  Float_t lCableZ = 0.;
1528  Float_t cablepar[3] = {static_cast<Float_t>(supporthlength/2.), static_cast<Float_t>(kCableHeight/2.), static_cast<Float_t>(kCableWidth/2.)};
1529  Float_t lCableDY = 0.;
1530  Float_t lCableDY8 = 0.;
1531  for (i = 0; i<kNslats4; i++){
1532  Int_t iCable = 1;
1533  Int_t cIndex = 0;
1534  Int_t cIndex8 = 0;
1535  ySlat41 += kYpos41[i];
1536  ySlat42 += kYpos42[i];
1537 
1538  lCableY = ySlat41;
1539  lCableY8 = ySlat42;
1540 
1541  // Cables going out from the start of slat
1542  if(kNPCB4[i]>=4 && i<kNslats4-2){ // Only if 4 or more pcb
1543  // First top cables
1544  cablepar[0] = (supporthlength-kXpos4[i])/2.;
1545  lCableX = kXpos4[i]/2.;
1546  lCableDY = (kYpos41[i+1]+kYpos41[i+2])/2.-cablepar[1];
1547  lCableDY8 = (kYpos42[i+1]+kYpos42[i+2])/2.-cablepar[1];
1548  lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);
1549  TVirtualMC::GetMC()->Gsposp("S07L",10*i+cIndex++,"S07S",lCableX,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar,3);
1550  TVirtualMC::GetMC()->Gsposp("S07L",10*i+cIndex++,"S07S",lCableX,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar,3);
1551  TVirtualMC::GetMC()->Gsposp("S08L",10*i+cIndex8++,"S08S",lCableX,lCableY8+lCableDY8,lCableZ,0,"ONLY",cablepar,3);
1552  TVirtualMC::GetMC()->Gsposp("S08L",10*i+cIndex8++,"S08S",lCableX,-(lCableY8+lCableDY8),lCableZ,0,"ONLY",cablepar,3);
1553  // Then bottom cables
1554  if (i>0){
1555  if (i==1) { // Rounded slat. Bottom cable starts at dMotherInner (beam pipe)
1556  cablepar[0] = (supporthlength-kXpos4[i]-dMotherInner)/2.;
1557  lCableX = (kXpos4[i]+dMotherInner)/2.;
1558  lCableDY = (kYpos41[i]+kYpos41[i])/2.-cablepar[1];
1559  lCableDY8 = (kYpos42[i]+kYpos42[i])/2.-cablepar[1];
1560  }
1561  if (i>=2) {
1562  lCableDY = (kYpos41[i]+kYpos41[i-1])/2.-cablepar[1];
1563  if ((lCableY-lCableDY)<(dMotherInner+cablepar[1])){
1564  lCableDY = lCableY - dMotherInner - cablepar[1];
1565  }
1566  lCableDY8 = (kYpos42[i]+kYpos42[i-1])/2.-cablepar[1];
1567  if ((lCableY8-lCableDY8)<(dMotherInner+cablepar[1])){
1568  lCableDY8 = lCableY8 - dMotherInner - cablepar[1];
1569  }
1570  }
1571  TVirtualMC::GetMC()->Gsposp("S07L",10*i+cIndex++,"S07S",lCableX,lCableY-lCableDY,lCableZ,0,"ONLY",cablepar,3);
1572  TVirtualMC::GetMC()->Gsposp("S07L",10*i+cIndex++,"S07S",lCableX,-(lCableY-lCableDY),lCableZ,0,"ONLY",cablepar,3);
1573  TVirtualMC::GetMC()->Gsposp("S08L",10*i+cIndex8++,"S08S",lCableX,lCableY8-lCableDY8,lCableZ,0,"ONLY",cablepar,3);
1574  TVirtualMC::GetMC()->Gsposp("S08L",10*i+cIndex8++,"S08S",lCableX,-(lCableY8-lCableDY8),lCableZ,0,"ONLY",cablepar,3);
1575  }
1576  }
1577 
1578  // Rounded slats have an extra cable starting at second pcb
1579  if(i==1){
1580  // Only on top
1581  cablepar[0] = (supporthlength-kPcbLength-kVframeLength)/2.;
1582  lCableX = (kPcbLength+kVframeLength)/2.;
1583  lCableDY = (kYpos41[i+1]+kYpos41[i+2])/2.-cablepar[1]; // half way between 2 slats on same side
1584  lCableDY8 = (kYpos42[i+1]+kYpos42[i+2])/2.-cablepar[1]; // half way between 2 slats on same side
1585  lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);
1586  TVirtualMC::GetMC()->Gsposp("S07L",10*i+cIndex++,"S07S",lCableX,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar,3);
1587  TVirtualMC::GetMC()->Gsposp("S07L",10*i+cIndex++,"S07S",lCableX,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar,3);
1588  TVirtualMC::GetMC()->Gsposp("S08L",10*i+cIndex8++,"S08S",lCableX,lCableY8+lCableDY8,lCableZ,0,"ONLY",cablepar,3);
1589  TVirtualMC::GetMC()->Gsposp("S08L",10*i+cIndex8++,"S08S",lCableX,-(lCableY8+lCableDY8),lCableZ,0,"ONLY",cablepar,3);
1590  }
1591 
1592  // Cables going out from the end of the slats
1593  cablepar[0] = (supporthlength-(slatLength4[i]+kXpos4[i]+kDslatLength)+kVframeLength)/2.;
1594  lCableX = slatLength4[i]+kXpos4[i]-kVframeLength+kDslatLength+cablepar[0]-supporthlength/2.;
1595  if(i+1>=kNslats4 || i+2>=kNslats4){ // If no more higher slats, then use distance to lower slat
1596  lCableDY = kPcbHeight/2.+cablepar[1];
1597  lCableDY8 = lCableDY;
1598  }
1599  else {
1600  lCableDY = (kYpos41[i+1]+kYpos41[i+2])/2.-cablepar[1];
1601  lCableDY8 = (kYpos42[i+1]+kYpos42[i+2])/2.-cablepar[1];
1602  }
1603  lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);
1604  TVirtualMC::GetMC()->Gsposp("S07L",10*i+cIndex++,"S07S",lCableX,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar,3);
1605  TVirtualMC::GetMC()->Gsposp("S07L",10*i+cIndex++,"S07S",lCableX,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar,3);
1606  TVirtualMC::GetMC()->Gsposp("S08L",10*i+cIndex8++,"S08S",lCableX,lCableY8+lCableDY8,lCableZ,0,"ONLY",cablepar,3);
1607  TVirtualMC::GetMC()->Gsposp("S08L",10*i+cIndex8++,"S08S",lCableX,-(lCableY8+lCableDY8),lCableZ,0,"ONLY",cablepar,3);
1608  // Then bottom cables
1609  if(i>0){
1610  if (i==1) {
1611  lCableDY = (kYpos41[i]+kYpos41[i])/2.-cablepar[1];
1612  lCableDY8 = (kYpos42[i]+kYpos42[i])/2.-cablepar[1];
1613  }
1614  else{
1615  lCableDY = (kYpos41[i]+kYpos41[i-1])/2.-cablepar[1]; // half way between 2 slats on same side
1616  if ((lCableY-lCableDY)<(dMotherInner+cablepar[1])){
1617  lCableDY = lCableY - dMotherInner - cablepar[1];
1618  }
1619  lCableDY8 = (kYpos42[i]+kYpos42[i-1])/2.-cablepar[1]; // half way between 2 slats on same side
1620  if ((lCableY8-lCableDY8)<(dMotherInner+cablepar[1])){
1621  lCableDY8 = lCableY8 - dMotherInner - cablepar[1];
1622  }
1623  }
1624  TVirtualMC::GetMC()->Gsposp("S07L",10*i+cIndex++,"S07S",lCableX,lCableY-lCableDY,lCableZ,0,"ONLY",cablepar,3);
1625  TVirtualMC::GetMC()->Gsposp("S07L",10*i+cIndex++,"S07S",lCableX,-(lCableY-lCableDY),lCableZ,0,"ONLY",cablepar,3);
1626  TVirtualMC::GetMC()->Gsposp("S08L",10*i+cIndex8++,"S08S",lCableX,lCableY8-lCableDY8,lCableZ,0,"ONLY",cablepar,3);
1627  TVirtualMC::GetMC()->Gsposp("S08L",10*i+cIndex8++,"S08S",lCableX,-(lCableY8-lCableDY8),lCableZ,0,"ONLY",cablepar,3);
1628  }
1629  }
1630 
1631  Float_t dzCh7 = dzCh;
1632  TGeoTranslation* trSupport1St4 = new TGeoTranslation("trSupport1St4", supporthlength/2., 0. , dzCh7);
1633  TGeoRotation* roSupportSt4 = new TGeoRotation("roSupportSt4",90.,180.,-90.);
1634  TGeoCombiTrans* coSupport2St4 = new TGeoCombiTrans(-supporthlength/2., 0., -dzCh7, roSupportSt4);
1635  GetEnvelopes(9)->AddEnvelope("S07S", 0, 1, *trSupport1St4);
1636  GetEnvelopes(8)->AddEnvelope("S07S", 0, 2, *coSupport2St4);
1637  GetEnvelopes(11)->AddEnvelope("S08S", 0, 1, *trSupport1St4);
1638  GetEnvelopes(10)->AddEnvelope("S08S", 0, 2, *coSupport2St4);
1639 
1640  // End of pannel support geometry
1641 
1642  // cout << "Geometry for Station 4...... done" << endl;
1643 
1644  }
1645 
1646  if (fStations[4]) {
1647 
1648 
1649  // //********************************************************************
1650  // // Station 5 **
1651  // //********************************************************************
1652  // Mother volume for each chamber in St4 is an envelop (or assembly)
1653  // There is one assembly mother per half a chamber called SC09I, SC09O, SC10I and SC10O
1654  // Same volume name definitions as in St3
1655 
1656  const Int_t kNslats5 = 7; // number of slats per quadrant
1657  const Int_t kNPCB5[kNslats5] = {5, 6, 6, 6, 5, 4, 3}; // n PCB per slat
1658  const Float_t kXpos5[kNslats5] = {38.75, 0., 0., 0., 0., 0., 0.}; // J.C. Correct value
1659  const Float_t kYpos5[kNslats5] = {0., 38.2, 37.9, 37.6, 37.3, 37.05, 36.75};
1660  Float_t slatLength5[kNslats5];
1661 
1662  Float_t rPhi1 = TMath::RadToDeg()*(TMath::ASin((kYpos5[1]-hFramepar[1])/(AliMUONConstants::Rmin(4))));
1663  Float_t rPhi2 = TMath::RadToDeg()*(TMath::ACos(-vFramepar[0]/(AliMUONConstants::Rmin(4)-kRframeLength)));
1664  Float_t rFramepar5[5] = { AliMUONConstants::Rmin(4)-kRframeLength, AliMUONConstants::Rmin(4), kRframeWidth, rPhi1, rPhi2};
1665  Float_t vrFrameHeight = hFramepar[1]+kYpos5[1]-AliMUONConstants::Rmin(4)+kRframeLength;
1666 
1667  char idSlatCh9[6];
1668  char idSlatCh10[6];
1669  Float_t xSlat5;
1670  Float_t ySlat5 = 0;
1671  angle = 0.;
1672 
1673  for (i = 0; i < kNslats5; i++){
1674 
1675  slatLength5[i] = kPcbLength * kNPCB5[i] + 2.* kVframeLength;
1676  xSlat5 = slatLength5[i]/2. + kDslatLength + kXpos5[i];
1677  ySlat5 += kYpos5[i];
1678 
1679  spar[0] = slatLength5[i]/2.;
1680  spar[1] = kSlatHeight/2.;
1681  spar[2] = kSlatWidth/2.;
1682 
1683  Float_t dzCh5 = dzCh;
1684  Float_t zSlat5 = (i%2 ==0)? -zSlat : zSlat;
1685 
1686  sprintf(idSlatCh9,"SLE%d",kNslats5-1+i);
1687  detElemId = 913 - (i + kNslats5-1-6);
1688  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
1689  if (detElemId % 2 == 0) {
1690  if (detElemId == 912) // Round slat, new rotation due to mapping convention
1691  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(xSlat5, ySlat5, -zSlat5 + dzCh5),
1692  TGeoRotation("rot1",90,180+angle,90,90+angle,180,0) );
1693  else
1694  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(xSlat5, ySlat5, -zSlat5 + dzCh5),
1695  TGeoRotation("rot1",90,angle,90,90+angle,0,0) );
1696  }
1697  else
1698  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(xSlat5, ySlat5, -zSlat5 + dzCh5),
1699  TGeoRotation("rot1",90,angle,90,270+angle,180,0) );
1700  sprintf(idSlatCh9,"SLE%d",3*kNslats5-2+i);
1701  detElemId = 900 + (i + kNslats5-1-6);
1702  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
1703  if (detElemId % 2 == 1) {
1704  if (detElemId == 901) // Round slat, new rotation due to mapping convention
1705  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(-xSlat5, ySlat5, zSlat5 - dzCh5),
1706  TGeoRotation("rot2",90,angle,90,90+angle,0,0) );
1707  else
1708  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(-xSlat5, ySlat5, zSlat5 - dzCh5),
1709  TGeoRotation("rot2",90,180+angle,90,90+angle,180,0) );
1710  }
1711  else
1712  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(-xSlat5, ySlat5, zSlat5 - dzCh5),
1713  TGeoRotation("rot2",90,180+angle,90,270+angle,0,0) );
1714 
1715  if (i > 0) {
1716  sprintf(idSlatCh9,"SLE%d",kNslats5-1-i);
1717  detElemId = 913 + (i + kNslats5-1-6);
1718  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
1719  if (detElemId % 2 == 0) {
1720  if (detElemId == 914) // Round slat, new rotation due to mapping convention
1721  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(xSlat5, -ySlat5, -zSlat5 + dzCh5),
1722  TGeoRotation("rot3",90,180+angle,90,270+angle,0,0) );
1723  else
1724  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(xSlat5, -ySlat5, -zSlat5 + dzCh5),
1725  TGeoRotation("rot3",90,angle,90,90+angle,0,0) );
1726  }
1727  else
1728  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(xSlat5, -ySlat5, -zSlat5 + dzCh5),
1729  TGeoRotation("rot3",90,angle,90,270+angle,180,0) );
1730 
1731  sprintf(idSlatCh9,"SLE%d",3*kNslats5-2-i);
1732  detElemId = 926 - (i + kNslats5-1-6);
1733  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
1734  if (detElemId % 2 == 1) {
1735  if (detElemId == 925) // Round slat, new rotation due to mapping convention
1736  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat5 - dzCh5),
1737  TGeoRotation("rot4",90,angle,90,270+angle,180,0) );
1738  else
1739  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat5 - dzCh5),
1740  TGeoRotation("rot4",90,180+angle,90,90+angle,180,0) );
1741  }
1742  else
1743  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh9, detElemId, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat5 - dzCh5),
1744  TGeoRotation("rot4",90,180+angle,90,270+angle,0,0) );
1745  }
1746 
1747  sprintf(idSlatCh10,"SLF%d",kNslats5-1+i);
1748  detElemId = 1013 - (i + kNslats5-1-6);
1749  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
1750  if (detElemId % 2 == 0) {
1751  if (detElemId == 1012) // Round slat, new rotation due to mapping convention
1752  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(xSlat5, ySlat5, -zSlat5 + dzCh5),
1753  TGeoRotation("rot5",90,180+angle,90,90+angle,180,0) );
1754  else
1755  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(xSlat5, ySlat5, -zSlat5 + dzCh5),
1756  TGeoRotation("rot5",90,angle,90,90+angle,0,0) );
1757  }
1758  else
1759  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(xSlat5, ySlat5, -zSlat5 + dzCh5),
1760  TGeoRotation("rot5",90,angle,90,270+angle,180,0) );
1761 
1762  sprintf(idSlatCh10,"SLF%d",3*kNslats5-2+i);
1763  detElemId = 1000 + (i + kNslats5-1-6);
1764  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
1765  if (detElemId % 2 == 1) {
1766  if (detElemId == 1001) // Round slat, new rotation due to mapping convention
1767  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(-xSlat5, ySlat5, zSlat5 - dzCh5),
1768  TGeoRotation("rot6",90,angle,90,90+angle,0,0) );
1769  else
1770  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(-xSlat5, ySlat5, zSlat5 - dzCh5),
1771  TGeoRotation("rot6",90,180+angle,90,90+angle,180,0) );
1772  }
1773  else
1774  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(-xSlat5, ySlat5, zSlat5 - dzCh5),
1775  TGeoRotation("rot6",90,180+angle,90,270+angle,0,0) );
1776 
1777  if (i > 0) {
1778  sprintf(idSlatCh10,"SLF%d",kNslats5-1-i);
1779  detElemId = 1013 + (i + kNslats5-1-6);
1780  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
1781  if (detElemId % 2 == 0) {
1782  if (detElemId == 1014) // Round slat, new rotation due to mapping convention
1783  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(xSlat5, -ySlat5, -zSlat5 + dzCh5),
1784  TGeoRotation("rot7",90,180+angle,90,270+angle,0,0) );
1785  else
1786  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(xSlat5, -ySlat5, -zSlat5 + dzCh5),
1787  TGeoRotation("rot7",90,angle,90,90+angle,0,0) );
1788  }
1789  else
1790  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(xSlat5, -ySlat5, -zSlat5 + dzCh5),
1791  TGeoRotation("rot7",90,angle,90,270+angle,180,0) );
1792 
1793  sprintf(idSlatCh10,"SLF%d",3*kNslats5-2-i);
1794  detElemId = 1026 - (i + kNslats5-1-6);
1795  moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
1796  if (detElemId % 2 == 1) {
1797  if (detElemId == 1025) // Round slat, new rotation due to mapping convention
1798  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat5 - dzCh5),
1799  TGeoRotation("rot8",90,angle,90,270+angle,180,0) );
1800  else
1801  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat5 - dzCh5),
1802  TGeoRotation("rot8",90,180+angle,90,90+angle,180,0) );
1803  }
1804  else
1805  GetEnvelopes(moduleId)->AddEnvelope(idSlatCh10, detElemId, true, TGeoTranslation(-xSlat5, -ySlat5, zSlat5 - dzCh5),
1806  TGeoRotation("rot8",90,180+angle,90,270+angle,0,0) );
1807  }
1808  }
1809 
1810  // create the panel volume
1811 
1812  TVirtualMC::GetMC()->Gsvolu("S09C","BOX",kCarbonMaterial,panelpar,3);
1813  TVirtualMC::GetMC()->Gsvolu("SD9C","BOX",kCarbonMaterial,panelpar,3);
1814  TVirtualMC::GetMC()->Gsvolu("S10C","BOX",kCarbonMaterial,panelpar,3);
1815  TVirtualMC::GetMC()->Gsvolu("SD0C","BOX",kCarbonMaterial,panelpar,3);
1816 
1817  // create the nomex volume
1818 
1819  TVirtualMC::GetMC()->Gsvolu("S09N","BOX",kNomexMaterial,nomexpar,3);
1820  TVirtualMC::GetMC()->Gsvolu("SD9N","BOX",kNomexMaterial,nomexpar,3);
1821  TVirtualMC::GetMC()->Gsvolu("S10N","BOX",kNomexMaterial,nomexpar,3);
1822  TVirtualMC::GetMC()->Gsvolu("SD0N","BOX",kNomexMaterial,nomexpar,3);
1823 
1824 
1825  // create the nomex volume (bulk)
1826 
1827  TVirtualMC::GetMC()->Gsvolu("S09X","BOX",kNomexBMaterial,nomexbpar,3);
1828  TVirtualMC::GetMC()->Gsvolu("SD9X","BOX",kNomexBMaterial,nomexbpar,3);
1829  TVirtualMC::GetMC()->Gsvolu("S10X","BOX",kNomexBMaterial,nomexbpar,3);
1830  TVirtualMC::GetMC()->Gsvolu("SD0X","BOX",kNomexBMaterial,nomexbpar,3);
1831 
1832  // create the insulating material volume
1833 
1834  TVirtualMC::GetMC()->Gsvolu("S09I","BOX",kInsuMaterial,insupar,3);
1835  TVirtualMC::GetMC()->Gsvolu("SD9I","BOX",kInsuMaterial,insupar,3);
1836  TVirtualMC::GetMC()->Gsvolu("S10I","BOX",kInsuMaterial,insupar,3);
1837  TVirtualMC::GetMC()->Gsvolu("SD0I","BOX",kInsuMaterial,insupar,3);
1838 
1839  // create the PCB volume
1840 
1841  TVirtualMC::GetMC()->Gsvolu("S09P","BOX",kPcbMaterial,pcbpar,3);
1842  TVirtualMC::GetMC()->Gsvolu("SD9P","BOX",kPcbMaterial,pcbpar,3);
1843  TVirtualMC::GetMC()->Gsvolu("S10P","BOX",kPcbMaterial,pcbpar,3);
1844  TVirtualMC::GetMC()->Gsvolu("SD0P","BOX",kPcbMaterial,pcbpar,3);
1845 
1846  // create the sensitive volumes,
1847 
1848  TVirtualMC::GetMC()->Gsvolu("S09G","BOX",kSensMaterial,dum,0);
1849  TVirtualMC::GetMC()->Gsvolu("SD9G","BOX",kSensMaterial,senspar,3);
1850  TVirtualMC::GetMC()->Gsvolu("S10G","BOX",kSensMaterial,dum,0);
1851  TVirtualMC::GetMC()->Gsvolu("SD0G","BOX",kSensMaterial,senspar,3);
1852 
1853  // create the vertical frame volume
1854 
1855  TVirtualMC::GetMC()->Gsvolu("S09V","BOX",kVframeMaterial,vFramepar,3);
1856  TVirtualMC::GetMC()->Gsvolu("S10V","BOX",kVframeMaterial,vFramepar,3);
1857 
1858  // create the rounded vertical frame volume
1859 
1860  TVirtualMC::GetMC()->Gsvolu("SD9D","TUBS",kRframeMaterial,rFramepar5,5);
1861  TVirtualMC::GetMC()->Gsvolu("SD0D","TUBS",kRframeMaterial,rFramepar5,5);
1862 
1863  // create the horizontal frame volume
1864 
1865  TVirtualMC::GetMC()->Gsvolu("S09H","BOX",kHframeMaterial,hFramepar,3);
1866  TVirtualMC::GetMC()->Gsvolu("SD9H","BOX",kHframeMaterial,hFramepar,3);
1867  TVirtualMC::GetMC()->Gsvolu("S10H","BOX",kHframeMaterial,hFramepar,3);
1868  TVirtualMC::GetMC()->Gsvolu("SD0H","BOX",kHframeMaterial,hFramepar,3);
1869 
1870  // create the horizontal border volume
1871 
1872  TVirtualMC::GetMC()->Gsvolu("S09B","BOX",kBframeMaterial,bFramepar,3);
1873  TVirtualMC::GetMC()->Gsvolu("SD9B","BOX",kBframeMaterial,bFramepar,3);
1874  TVirtualMC::GetMC()->Gsvolu("S10B","BOX",kBframeMaterial,bFramepar,3);
1875  TVirtualMC::GetMC()->Gsvolu("SD0B","BOX",kBframeMaterial,bFramepar,3);
1876 
1877  // Replace the volume shape with a composite shape
1878  // with substracted overlap with beam shield
1879  if ( TVirtualMC::GetMC()->IsRootGeometrySupported() ) {
1880 
1881  // Get shape
1882  Int_t nSlatType = 1;
1883  Int_t nVol = 8;
1884  const char* slatType = "D"; // D: Rounde slat
1885  const char* volLetter = "CNXIPHBG";
1886  TString volName;
1887  TString compName;
1888  TString csName;
1889  TGeoVolume *mVol = 0x0;
1890  // Beam shield recess
1891  new TGeoTube("tube5Cut", 0., AliMUONConstants::Rmin(4), kSlatWidth/2.+0.001);
1892  TObjArray rounded5Slat(nSlatType*((nVol+1)*2));
1893  // Displacement
1894  TGeoTranslation* trDTube5 = new TGeoTranslation("trDTube5", -(kPcbLength+kVframeLength)/2., -kYpos5[1], 0.);
1895  trDTube5->RegisterYourself();
1896  TGeoTranslation* trDBTube5 = new TGeoTranslation("trDBTube5", 0., ( kPcbHeight - kBframeHeight ) / 2., 0.);
1897  trDBTube5->Add(trDTube5);
1898  trDBTube5->RegisterYourself();
1899 
1900  TObjArray composite5(nSlatType*((nVol+1)*2));
1901  new TGeoBBox("box5DCut",(kPcbLength+kVframeLength)/2., hFramepar[1], vFramepar[2]+0.001);
1902  // Displacement
1903  TGeoTranslation* trDBox5 = new TGeoTranslation("trDBox5",kPcbLength/2., kYpos5[1], 0.);
1904  trDBox5->RegisterYourself();
1905 
1906  TGeoBBox *box5Vframe = new TGeoBBox("box5Vframe",vFramepar[0],vrFrameHeight/2., vFramepar[2]);
1907  TGeoTranslation* trVBox5 = new TGeoTranslation("trVBox5", 0., AliMUONConstants::Rmin(4)-kRframeLength + box5Vframe->GetDY(), 0.);
1908  trVBox5->RegisterYourself();
1909 
1910  for(int iCh=9; iCh<=10; iCh++){
1911  for (int iSlatType = 0; iSlatType<nSlatType; iSlatType++) {
1912  for (int iVol = 0; iVol<nVol; iVol++){
1913  Int_t lIndex = (iCh-9)*(nSlatType*(nVol+1))+iSlatType*(nVol+1)+iVol;
1914  volName=Form("S%c%d%c",slatType[iSlatType],iCh%10,volLetter[iVol]);
1915  mVol = gGeoManager->FindVolumeFast(volName);
1916  if ( !mVol ) {
1917  AliErrorStream()
1918  << "Slat volume " << volName << " not found" << endl;
1919  }
1920  else {
1921  rounded5Slat[lIndex] = mVol->GetShape();
1922  csName=Form("rounded5Slat%c%d%c",slatType[iSlatType],iCh%10,volLetter[iVol]);
1923  ((TGeoShape*)rounded5Slat[lIndex])->SetName(csName);
1924 
1925  // Composite shape
1926  TString compOperation(csName);
1927  compOperation+="-tube5Cut:tr";
1928  compOperation+=slatType[iSlatType];
1929  if (strstr(volName,"B")){
1930  compOperation+="B";
1931  }
1932  compOperation+="Tube5";
1933  compName=Form("composite5%c%d%c",slatType[iSlatType],iCh,volLetter[iVol]);
1934  composite5[lIndex] = new TGeoCompositeShape(compName, compOperation.Data());
1935 
1936  // Reset shape to volume
1937  mVol->SetShape((TGeoShape*)composite5[lIndex]);
1938  }
1939  }
1940 
1941  // For rounded spacer
1942  Int_t lIndex = (iCh-9)*(nSlatType*(nVol+1))+iSlatType*(nVol+1)+nVol;
1943  volName=Form("S%c%dD",slatType[iSlatType],iCh%10);
1944  mVol = gGeoManager->FindVolumeFast(volName);
1945  if ( !mVol ) {
1946  AliErrorStream()
1947  << "Slat volume " << volName << " not found" << endl;
1948  }
1949  else {
1950  rounded5Slat[lIndex] = mVol->GetShape();
1951  csName=Form("rounded5Slat%c%dD",slatType[iSlatType],iCh%10);
1952  ((TGeoShape*)rounded5Slat[lIndex])->SetName(csName);
1953 
1954  // Composite shape
1955  TString compOperation(csName);
1956  if (strstr(volName,"SD")){
1957  compOperation.Prepend("(");
1958  compOperation+="+box5Vframe:trVBox5)*box5DCut:trDBox5";
1959  }
1960  compName=Form("composite5%c%dD",slatType[iSlatType],iCh%10);
1961  composite5[lIndex] = new TGeoCompositeShape(compName, compOperation.Data());
1962  // Reset shape to volume
1963  mVol->SetShape((TGeoShape*)composite5[lIndex]);
1964  }
1965  }
1966  }
1967  }
1968 
1969  index = 0;
1970  for (i = 0; i < kNslats5; i++){
1971  for (Int_t quadrant = 1; quadrant <= 4; quadrant++) {
1972 
1973  if (i == 0 && quadrant == 2) continue;
1974  if (i == 0 && quadrant == 4) continue;
1975 
1976  sprintf(idSlatCh9,"SLE%d",ConvertSlatNum(i,quadrant,kNslats5-1));
1977  sprintf(idSlatCh10,"SLF%d",ConvertSlatNum(i,quadrant,kNslats5-1));
1978  Int_t moduleSlatCh9 = GetModuleId(idSlatCh9);
1979  Int_t moduleSlatCh10 = GetModuleId(idSlatCh10);
1980  Float_t xvFrame = (slatLength5[i] - kVframeLength)/2.; // ok
1981 
1982  // position the vertical frames (spacers)
1983  if (i != 1) {
1984  GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i+1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
1985  GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
1986  GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i+1)*10+quadrant,TGeoTranslation(xvFrame,0.,0.));
1987  GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.));
1988  } else { // Vertical and Rounded+Vertical spacer - Different rotation due to new mapping convention
1989  GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("S09V", idSlatCh9, (2*i+1)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1990  GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("SD9D", idSlatCh9, (2*i)*10+quadrant,TGeoTranslation(xvFrame,-kYpos5[1],0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1991  GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("S10V", idSlatCh10, (2*i+1)*10+quadrant,TGeoTranslation(-xvFrame,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1992  GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("SD0D", idSlatCh10, (2*i)*10+quadrant,TGeoTranslation(xvFrame,-kYpos5[1],0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
1993  }
1994 
1995  // position the panels and the insulating material
1996  for (j = 0; j < kNPCB5[i]; j++){
1997  index++;
1998  xx = kSensLength * (-kNPCB5[i]/2.+j+.5);
1999 
2000  Float_t zPanel = spar[2] - nomexbpar[2];
2001  if (i==1) { // Different rotation due to new mapping convention
2002  if (j==0) { // Rounded pcb of rounded slat
2003  GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("SD9X", idSlatCh9, 2*index-1,TGeoTranslation(-xx,0.,zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
2004  GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("SD9X", idSlatCh9, 2*index,TGeoTranslation(-xx,0.,-zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
2005  GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("SD9I", idSlatCh9, index,TGeoTranslation(-xx,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
2006  GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("SD0X", idSlatCh10, 2*index-1,TGeoTranslation(-xx,0.,zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
2007  GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("SD0X", idSlatCh10, 2*index,TGeoTranslation(-xx,0.,-zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
2008  GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("SD0I", idSlatCh10, index,TGeoTranslation(-xx,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
2009  } else {
2010  GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("S09X", idSlatCh9, 2*index-1,TGeoTranslation(-xx,0.,zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
2011  GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("S09X", idSlatCh9, 2*index,TGeoTranslation(-xx,0.,-zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
2012  GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("S09I", idSlatCh9, index,TGeoTranslation(-xx,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
2013  GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("S10X", idSlatCh10, 2*index-1,TGeoTranslation(-xx,0.,zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
2014  GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("S10X", idSlatCh10, 2*index,TGeoTranslation(-xx,0.,-zPanel),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
2015  GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("S10I", idSlatCh10, index,TGeoTranslation(-xx,0.,0.),TGeoRotation("rotAbX",90,180+angle,90,90+angle,180,0));
2016  }
2017  } else {
2018  GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("S09X", idSlatCh9, 2*index-1,TGeoTranslation(xx,0.,zPanel));
2019  GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("S09X", idSlatCh9, 2*index,TGeoTranslation(xx,0.,-zPanel));
2020  GetEnvelopes(moduleSlatCh9)->AddEnvelopeConstituent("S09I", idSlatCh9, index,TGeoTranslation(xx,0.,0.));
2021  GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("S10X", idSlatCh10, 2*index-1,TGeoTranslation(xx,0.,zPanel));
2022  GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("S10X", idSlatCh10, 2*index,TGeoTranslation(xx,0.,-zPanel));
2023  GetEnvelopes(moduleSlatCh10)->AddEnvelopeConstituent("S10I", idSlatCh10, index,TGeoTranslation(xx,0.,0.));
2024  }
2025  }
2026  }
2027  }
2028 
2029  // position the nomex volume inside the panel volume
2030  TVirtualMC::GetMC()->Gspos("S09N",1,"S09C",0.,0.,0.,0,"ONLY");
2031  TVirtualMC::GetMC()->Gspos("SD9N",1,"SD9C",0.,0.,0.,0,"ONLY");
2032  TVirtualMC::GetMC()->Gspos("S10N",1,"S10C",0.,0.,0.,0,"ONLY");
2033  TVirtualMC::GetMC()->Gspos("SD0N",1,"SD0C",0.,0.,0.,0,"ONLY");
2034 
2035  // position panel volume inside the bulk nomex material volume
2036  TVirtualMC::GetMC()->Gspos("S09C",1,"S09X",0.,0.,kNomexBWidth/2.,0,"ONLY");
2037  TVirtualMC::GetMC()->Gspos("SD9C",1,"SD9X",0.,0.,kNomexBWidth/2.,0,"ONLY");
2038  TVirtualMC::GetMC()->Gspos("S10C",1,"S10X",0.,0.,kNomexBWidth/2.,0,"ONLY");
2039  TVirtualMC::GetMC()->Gspos("SD0C",1,"SD0X",0.,0.,kNomexBWidth/2.,0,"ONLY");
2040 
2041  // position the PCB volume inside the insulating material volume
2042  TVirtualMC::GetMC()->Gspos("S09P",1,"S09I",0.,0.,0.,0,"ONLY");
2043  TVirtualMC::GetMC()->Gspos("SD9P",1,"SD9I",0.,0.,0.,0,"ONLY");
2044  TVirtualMC::GetMC()->Gspos("S10P",1,"S10I",0.,0.,0.,0,"ONLY");
2045  TVirtualMC::GetMC()->Gspos("SD0P",1,"SD0I",0.,0.,0.,0,"ONLY");
2046 
2047  // position the horizontal frame volume inside the PCB volume
2048  TVirtualMC::GetMC()->Gspos("S09H",1,"S09P",0.,0.,0.,0,"ONLY");
2049  TVirtualMC::GetMC()->Gspos("SD9H",1,"SD9P",0.,0.,0.,0,"ONLY");
2050  TVirtualMC::GetMC()->Gspos("S10H",1,"S10P",0.,0.,0.,0,"ONLY");
2051  TVirtualMC::GetMC()->Gspos("SD0H",1,"SD0P",0.,0.,0.,0,"ONLY");
2052 
2053  // position the sensitive volume inside the horizontal frame volume
2054  TVirtualMC::GetMC()->Gsposp("S09G",1,"S09H",0.,0.,0.,0,"ONLY",senspar,3);
2055  TVirtualMC::GetMC()->Gspos("SD9G",1,"SD9H",0.,0.,0.,0,"ONLY");
2056  TVirtualMC::GetMC()->Gsposp("S10G",1,"S10H",0.,0.,0.,0,"ONLY",senspar,3);
2057  TVirtualMC::GetMC()->Gspos("SD0G",1,"SD0H",0.,0.,0.,0,"ONLY");
2058 
2059  // position the border volumes inside the PCB volume
2060  Float_t yborder = ( kPcbHeight - kBframeHeight ) / 2.;
2061  TVirtualMC::GetMC()->Gspos("S09B",1,"S09P",0., yborder,0.,0,"ONLY");
2062  TVirtualMC::GetMC()->Gspos("S09B",2,"S09P",0.,-yborder,0.,0,"ONLY");
2063  TVirtualMC::GetMC()->Gspos("S09B",1,"SD9P",0., yborder,0.,0,"ONLY");
2064  TVirtualMC::GetMC()->Gspos("SD9B",1,"SD9P",0.,-yborder,0.,0,"ONLY");
2065  TVirtualMC::GetMC()->Gspos("S10B",1,"S10P",0., yborder,0.,0,"ONLY");
2066  TVirtualMC::GetMC()->Gspos("S10B",2,"S10P",0.,-yborder,0.,0,"ONLY");
2067  TVirtualMC::GetMC()->Gspos("S10B",1,"SD0P",0., yborder,0.,0,"ONLY");
2068  TVirtualMC::GetMC()->Gspos("SD0B",1,"SD0P",0.,-yborder,0.,0,"ONLY");
2069 
2070  // // create the NULOC volume and position it in the horizontal frame
2071 
2072  TVirtualMC::GetMC()->Gsvolu("S09E","BOX",kNulocMaterial,nulocpar,3);
2073  TVirtualMC::GetMC()->Gsvolu("S10E","BOX",kNulocMaterial,nulocpar,3);
2074  index = 0;
2075  Float_t rPhi3 = TMath::ASin((kYpos5[1]-kPcbHeight/2.)/AliMUONConstants::Rmin(4));
2076  Float_t xxmax4 = (AliMUONConstants::Rmin(4)*TMath::Cos(rPhi3)-kVframeLength/2.) - (kBframeLength - kNulocLength)/2.;
2077  for (xx = -xxmax; xx <= xxmax; xx += 2*kNulocLength) {
2078  index++;
2079  TVirtualMC::GetMC()->Gspos("S09E",2*index-1,"S09B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
2080  TVirtualMC::GetMC()->Gspos("S09E",2*index ,"S09B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
2081  TVirtualMC::GetMC()->Gspos("S10E",2*index-1,"S10B", xx, 0.,-kBframeWidth/2. + kNulocWidth/2, 0, "ONLY");
2082  TVirtualMC::GetMC()->Gspos("S10E",2*index ,"S10B", xx, 0., kBframeWidth/2. - kNulocWidth/2, 0, "ONLY");
2083  }
2084  if (xx > xxmax4 && xx< xxmax) {
2085  TVirtualMC::GetMC()->Gspos("S09E",2*index-1,"SD9B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
2086  TVirtualMC::GetMC()->Gspos("S09E",2*index ,"SD9B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
2087  TVirtualMC::GetMC()->Gspos("S10E",2*index-1,"SD0B", xx, 0.,-kBframeWidth/2.+ kNulocWidth/2, 0, "ONLY");
2088  TVirtualMC::GetMC()->Gspos("S10E",2*index ,"SD0B", xx, 0., kBframeWidth/2.- kNulocWidth/2, 0, "ONLY");
2089  }
2090 
2091  //
2092  //Geometry of the support pannel Verticla length 5.7m, horizontal length 2.6m, internal radius dMotherInner o SC09 and SC10 (F. Orsini, Saclay)
2093  //Carbon fiber of 0.3 mm thick (2 layers) and a central layer of Nomex of 15mm thick.
2094  Float_t dMotherInner = AliMUONConstants::Rmin(4)-kRframeHeight;
2095  Float_t nomexthickness = 1.5;
2096  Float_t carbonthickness = 0.03;
2097  Float_t supporthlength = 260.;
2098  Float_t supportvlength = 570.;
2099  // Generating the composite shape of the carbon and nomex pannels
2100  new TGeoBBox("shNomexBoxSt5",supporthlength/2., supportvlength/2. ,nomexthickness/2.+carbonthickness+3*kCableWidth);
2101  new TGeoBBox("shCarbonBoxSt5",supporthlength/2., supportvlength/2. ,carbonthickness/2.);
2102  new TGeoTubeSeg("shNomexHoleSt5",0., dMotherInner, nomexthickness/2.+carbonthickness+3*kCableWidth+0.001, -90. ,90.);
2103  new TGeoTubeSeg("shCarbonHoleSt5",0., dMotherInner, carbonthickness/2.+0.001, -90. ,90.);
2104  TGeoTranslation* trHoleSt5 = new TGeoTranslation("trHoleSt5",-supporthlength/2.,0.,0.);
2105  trHoleSt5->RegisterYourself();
2106  TGeoCompositeShape* shNomexSupportSt5 = new TGeoCompositeShape("shNomexSupportSt5","shNomexBoxSt5-shNomexHoleSt5:trHoleSt5");
2107  TGeoCompositeShape* shCarbonSupportSt5 = new TGeoCompositeShape("shCarbonSupportSt5","shCarbonBoxSt5-shCarbonHoleSt5:trHoleSt5");
2108 
2109  // Generating Nomex and Carbon pannel volumes
2110  TGeoVolume* voNomexSupportSt5 = new TGeoVolume("S09S", shNomexSupportSt5, kMedNomex);
2111  TGeoVolume* voCarbonSupportSt5 = new TGeoVolume("S09K", shCarbonSupportSt5, kMedCarbon);
2112  TGeoTranslation* trCarbon1St5 = new TGeoTranslation("trCarbon1St5",0.,0., -(nomexthickness+carbonthickness)/2.);
2113  TGeoTranslation* trCarbon2St5 = new TGeoTranslation("trCarbon2St5",0.,0., (nomexthickness+carbonthickness)/2.);
2114  voNomexSupportSt5->AddNode(voCarbonSupportSt5,1,trCarbon1St5);
2115  voNomexSupportSt5->AddNode(voCarbonSupportSt5,2,trCarbon2St5);
2116 
2117  // Add readout cables
2118  TVirtualMC::GetMC()->Gsvolu("S09L","BOX",kCableMaterial,dum,0);
2119 
2120  ySlat5 = 0.;
2121  Float_t lCableX = 0.;
2122  Float_t lCableY = 0.;
2123  Float_t lCableZ = 0.;
2124  Float_t cablepar[3] = {static_cast<Float_t>(supporthlength/2.), static_cast<Float_t>(kCableHeight/2.), static_cast<Float_t>(kCableWidth/2.)};
2125  Float_t lCableDY = 0.;
2126  for (i = 0; i<kNslats5; i++){
2127  Int_t iCable = 1;
2128  Int_t cIndex = 0;
2129  ySlat5 += kYpos5[i];
2130 
2131  lCableY = ySlat5;
2132 
2133  // Cables going out from the start of slat
2134  if(kNPCB5[i]>=4){ // Only if 4 or more pcb
2135  // First top cables
2136  cablepar[0] = (supporthlength-kXpos5[i])/2.;
2137  lCableX = kXpos5[i]/2.;
2138  if(i+1>=kNslats5 || i+2>=kNslats5){ // If no more higher slats, then use distance to lower slat
2139  lCableDY = (kYpos5[i]+kYpos5[i-1])/2.-cablepar[1];
2140  }
2141  else {
2142  lCableDY = (kYpos5[i+1]+kYpos5[i+2])/2.-cablepar[1];
2143  }
2144  lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);
2145  TVirtualMC::GetMC()->Gsposp("S09L",10*i+cIndex++,"S09S",lCableX,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar,3);
2146  TVirtualMC::GetMC()->Gsposp("S09L",10*i+cIndex++,"S09S",lCableX,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar,3);
2147  // Then bottom cables
2148  if (i>0) {
2149  if (i==1) { // Rounded slat. Bottom cable starts at dMotherInner (beam pipe)
2150  cablepar[0] = (supporthlength-kXpos5[i]-dMotherInner)/2.;
2151  lCableX = (kXpos5[i]+dMotherInner)/2.;
2152  lCableDY = (kYpos5[i]+kYpos5[i])/2.-cablepar[1];
2153  }
2154  else {
2155  lCableDY = (kYpos5[i]+kYpos5[i-1])/2.-cablepar[1];
2156  if ((lCableY-lCableDY)<(dMotherInner+cablepar[1])){
2157  lCableDY = lCableY - dMotherInner - cablepar[1];
2158  }
2159  }
2160  TVirtualMC::GetMC()->Gsposp("S09L",10*i+cIndex++,"S09S",lCableX,lCableY-lCableDY,lCableZ,0,"ONLY",cablepar,3);
2161  TVirtualMC::GetMC()->Gsposp("S09L",10*i+cIndex++,"S09S",lCableX,-(lCableY-lCableDY),lCableZ,0,"ONLY",cablepar,3);
2162  }
2163  }
2164 
2165  // Rounded slats have an extra cable starting at second pcb
2166  if(i==1){
2167  // Only on top
2168  cablepar[0] = (supporthlength-kPcbLength-kVframeLength)/2.;
2169  lCableX = (kPcbLength+kVframeLength)/2.;
2170  lCableDY = (kYpos5[i+1]+kYpos5[i+2])/2.-cablepar[1]; // half way between 2 slats on same side
2171  lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);
2172  TVirtualMC::GetMC()->Gsposp("S09L",10*i+cIndex++,"S09S",lCableX,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar,3);
2173  TVirtualMC::GetMC()->Gsposp("S09L",10*i+cIndex++,"S09S",lCableX,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar,3);
2174  }
2175 
2176  // Cables going out from the end of the slats
2177  // First top cables
2178  cablepar[0] = (supporthlength-(slatLength5[i]+kXpos5[i]+kDslatLength)+kVframeLength)/2.;
2179  lCableX = slatLength5[i]+kXpos5[i]-kVframeLength+kDslatLength+cablepar[0]-supporthlength/2.;
2180  if(i+1>=kNslats5 || i+2>=kNslats5){ // If no more higher slats, then use distance to lower slat
2181  lCableDY = (kYpos5[i]+kYpos5[i-1])/2.-cablepar[1];
2182  }
2183  else {
2184  lCableDY = (kYpos5[i+1]+kYpos5[i+2])/2.-cablepar[1];
2185  }
2186  lCableZ = TMath::Power(-1,i)*(nomexthickness/2.+carbonthickness+(-1+iCable++)*kCableWidth+kCableWidth/2.);
2187  TVirtualMC::GetMC()->Gsposp("S09L",10*i+cIndex++,"S09S",lCableX,lCableY+lCableDY,lCableZ,0,"ONLY",cablepar,3);
2188  TVirtualMC::GetMC()->Gsposp("S09L",10*i+cIndex++,"S09S",lCableX,-(lCableY+lCableDY),lCableZ,0,"ONLY",cablepar,3);
2189  if(i>0){
2190  if (i==1) { // Rounded slat. Bottom cable starts at dMotherInner (beam pipe)
2191  lCableDY = (kYpos5[i]+kYpos5[i])/2.-cablepar[1];
2192  }
2193  else {
2194  lCableDY = (kYpos5[i]+kYpos5[i-1])/2.-cablepar[1];
2195  if ((lCableY-lCableDY)<(dMotherInner+cablepar[1])){
2196  lCableDY = lCableY - dMotherInner - cablepar[1];
2197  }
2198  }
2199  TVirtualMC::GetMC()->Gsposp("S09L",10*i+cIndex++,"S09S",lCableX,lCableY-lCableDY,lCableZ,0,"ONLY",cablepar,3);
2200  TVirtualMC::GetMC()->Gsposp("S09L",10*i+cIndex++,"S09S",lCableX,-(lCableY-lCableDY),lCableZ,0,"ONLY",cablepar,3);
2201  }
2202  }
2203 
2204  Float_t dzCh9 = dzCh;
2205  TGeoTranslation* trSupport1St5 = new TGeoTranslation("trSupport1St5", supporthlength/2., 0. , dzCh9);
2206  TGeoRotation* roSupportSt5 = new TGeoRotation("roSupportSt5",90.,180.,-90.);
2207  TGeoCombiTrans* coSupport2St5 = new TGeoCombiTrans(-supporthlength/2., 0., -dzCh9, roSupportSt5);
2208  GetEnvelopes(13)->AddEnvelope("S09S", 0, 1, *trSupport1St5);
2209  GetEnvelopes(12)->AddEnvelope("S09S", 0, 2, *coSupport2St5);
2210  GetEnvelopes(15)->AddEnvelope("S09S", 0, 3, *trSupport1St5);
2211  GetEnvelopes(14)->AddEnvelope("S09S", 0, 4, *coSupport2St5);
2212 
2213 
2214  // End of pannel support geometry
2215 
2216  // cout << "Geometry for Station 5...... done" << endl;
2217 
2218  }
2219 
2220  delete [] fStations;
2221 
2222 }
2223 
2224 //______________________________________________________________________________
2226 {
2228 
2229  if (gAlice->GetModule("DIPO")) {
2230  // if DIPO is preset, the whole station will be placed in DDIP volume
2231  SetMotherVolume(4, "DDIP");
2232  SetMotherVolume(5, "DDIP");
2233  SetMotherVolume(6, "DDIP");
2234  SetMotherVolume(7, "DDIP");
2235  }
2236  SetVolume(4, "SC05I", true);
2237  SetVolume(5, "SC05O", true);
2238  SetVolume(6, "SC06I", true);
2239  SetVolume(7, "SC06O", true);
2240 
2241  if (gAlice->GetModule("SHIL")) {
2242  SetMotherVolume(8, "YOUT2");
2243  SetMotherVolume(9, "YOUT2");
2244  SetMotherVolume(10, "YOUT2");
2245  SetMotherVolume(11, "YOUT2");
2246  SetMotherVolume(12, "YOUT2");
2247  SetMotherVolume(13, "YOUT2");
2248  SetMotherVolume(14, "YOUT2");
2249  SetMotherVolume(15, "YOUT2");
2250  }
2251 
2252  SetVolume( 8, "SC07I", true);
2253  SetVolume( 9, "SC07O", true);
2254  SetVolume(10, "SC08I", true);
2255  SetVolume(11, "SC08O", true);
2256  SetVolume(12, "SC09I", true);
2257  SetVolume(13, "SC09O", true);
2258  SetVolume(14, "SC10I", true);
2259  SetVolume(15, "SC10O", true);
2260 }
2261 
2262 
2263 //______________________________________________________________________________
2265 {
2267 
2268 // Stations 345 are not perpendicular to the beam axis
2269 // See AliMUONConstants class
2270  TGeoRotation st345inclination("rot99");
2271  st345inclination.RotateX(AliMUONConstants::St345Inclination());
2272 
2273 // The rotation of the half-chamber is done with respect the center of the chamber.
2274 // the distance beween the roation axis and the chamber position is
2275 // AliMUONConstants::DzCh()+AliMUONConstants::DzSlat()
2276 // Therefore the position of the half-chamber has to be corrected by a traslation in Z and Y axis
2277  Double_t deltaY = (AliMUONConstants::DzCh()+AliMUONConstants::DzSlat())*
2278  TMath::Sin(AliMUONConstants::St345Inclination() * TMath::Pi()/180.);
2279  Double_t deltaZ = (AliMUONConstants::DzCh()+AliMUONConstants::DzSlat())*
2280  (1.-TMath::Cos(AliMUONConstants::St345Inclination() * TMath::Pi()/180.));
2281 
2282 
2283  Double_t zpos1= - AliMUONConstants::DefaultChamberZ(4);
2284  SetTransformation(4, TGeoTranslation(0., -deltaY, -deltaZ+zpos1), st345inclination);
2285  SetTransformation(5, TGeoTranslation(0., deltaY, deltaZ+zpos1), st345inclination);
2286 
2287  zpos1= - AliMUONConstants::DefaultChamberZ(5);
2288  SetTransformation(6, TGeoTranslation(0., -deltaY, -deltaZ+zpos1), st345inclination);
2289  SetTransformation(7, TGeoTranslation(0., deltaY, deltaZ+zpos1), st345inclination);
2290 
2291  zpos1 = - AliMUONConstants::DefaultChamberZ(6);
2292  SetTransformation(8, TGeoTranslation(0., -deltaY, -deltaZ+zpos1), st345inclination);
2293  SetTransformation(9, TGeoTranslation(0., deltaY, deltaZ+zpos1), st345inclination);
2294 
2295  zpos1 = - AliMUONConstants::DefaultChamberZ(7);
2296  SetTransformation(10, TGeoTranslation(0., -deltaY, -deltaZ+zpos1), st345inclination );
2297  SetTransformation(11, TGeoTranslation(0., deltaY, deltaZ+zpos1), st345inclination );
2298 
2299  zpos1 = - AliMUONConstants::DefaultChamberZ(8);
2300  SetTransformation(12, TGeoTranslation(0., -deltaY, -deltaZ+zpos1), st345inclination);
2301  SetTransformation(13, TGeoTranslation(0., deltaY, deltaZ+zpos1), st345inclination);
2302 
2303  zpos1 = - AliMUONConstants::DefaultChamberZ(9);
2304  SetTransformation(14, TGeoTranslation(0., -deltaY, -deltaZ+zpos1), st345inclination);
2305  SetTransformation(15, TGeoTranslation(0., deltaY, deltaZ+zpos1), st345inclination);
2306 
2307 }
2308 
2309 //______________________________________________________________________________
2311 {
2313 
2314  GetGeometry( 4)->SetSensitiveVolume("S05G");
2315  GetGeometry( 4)->SetSensitiveVolume("SC5G");
2316  GetGeometry( 4)->SetSensitiveVolume("SD5G");
2317  GetGeometry( 5)->SetSensitiveVolume("S05G");
2318  GetGeometry( 5)->SetSensitiveVolume("SC5G");
2319  GetGeometry( 5)->SetSensitiveVolume("SD5G");
2320  GetGeometry( 6)->SetSensitiveVolume("S06G");
2321  GetGeometry( 6)->SetSensitiveVolume("SC6G");
2322  GetGeometry( 6)->SetSensitiveVolume("SD6G");
2323  GetGeometry( 7)->SetSensitiveVolume("S06G");
2324  GetGeometry( 7)->SetSensitiveVolume("SC6G");
2325  GetGeometry( 7)->SetSensitiveVolume("SD6G");
2326  GetGeometry( 8)->SetSensitiveVolume("S07G");
2327  GetGeometry( 8)->SetSensitiveVolume("SD7G");
2328  GetGeometry( 9)->SetSensitiveVolume("S07G");
2329  GetGeometry( 9)->SetSensitiveVolume("SD7G");
2330  GetGeometry(10)->SetSensitiveVolume("S08G");
2331  GetGeometry(10)->SetSensitiveVolume("SD8G");
2332  GetGeometry(11)->SetSensitiveVolume("S08G");
2333  GetGeometry(11)->SetSensitiveVolume("SD8G");
2334  GetGeometry(12)->SetSensitiveVolume("S09G");
2335  GetGeometry(12)->SetSensitiveVolume("SD9G");
2336  GetGeometry(13)->SetSensitiveVolume("S09G");
2337  GetGeometry(13)->SetSensitiveVolume("SD9G");
2338  GetGeometry(14)->SetSensitiveVolume("S10G");
2339  GetGeometry(14)->SetSensitiveVolume("SD0G");
2340  GetGeometry(15)->SetSensitiveVolume("S10G");
2341  GetGeometry(15)->SetSensitiveVolume("SD0G");
2342 }
2343 
2344 //______________________________________________________________________________
2345 Int_t AliMUONSlatGeometryBuilder::ConvertSlatNum(Int_t numslat, Int_t quadnum, Int_t fspq) const
2346 {
2349  numslat += 1;
2350  if (quadnum==2 || quadnum==3)
2351  numslat += fspq;
2352  else
2353  numslat = fspq + 2-numslat;
2354  numslat -= 1;
2355 
2356  if (quadnum==3 || quadnum==4) numslat += 2*fspq+1;
2357 
2358  return numslat;
2359 }
Abstract base class for geometry construction per module(s)
static Float_t Pitch()
Return wire pitch.
#define TObjArray
static Float_t St345Inclination()
Return Inclination with respect the vertical axis of stations 345.
void SetMotherVolume(Int_t moduleId, const TString &volumeName)
Int_t GetModuleId(const TString &envName) const
void SetTransformation(Int_t moduleId, const TGeoTranslation &translation, const TGeoRotation &rotation)
static Int_t GetGeomModuleId(Int_t detElemId, Bool_t warn=true)
AliDetector class for MUON subsystem providing simulation data management.
Definition: AliMUON.h:37
void SetSensitiveVolume(Int_t volId)
void AddEnvelope(const TString &name, Int_t id, Bool_t isVirtual, const char *only="ONLY")
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
static Float_t DzCh()
Return half-distance between two half-chambers.
virtual void SetVolumes()
and eventually the mother volume name should be defined
AliMUON * fMUON
the MUON detector class
AliMUONGeometryModule * GetGeometry(Int_t moduleId) const
void AddEnvelopeConstituent(const TString &name, const TString &envName, Int_t copyNo)
AliRun * gAlice
static Float_t Rmin(Int_t i)
Return chamber i inner radius.
AliMUONGeometryEnvelopeStore * GetEnvelopes(Int_t moduleId) const
AliMUON * muon()
void SetVolume(Int_t moduleId, const TString &volumeName, Bool_t isVirtual=false)
static Float_t * DefaultChamberZ()
Return pointer to array of positions.
static Float_t DzSlat()
Return half-distance between two slats.
Int_t ConvertSlatNum(Int_t numslat, Int_t quadnum, Int_t fspq) const
MUON Station3 geometry construction class.