]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUv1Layer.cxx
Reducing the number of 1 mm overlaps in the space frame
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUv1Layer.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 //*************************************************************************
17 // This class Defines the Geometry for the ITS Upgrade using TGeo
18 // This is a work class used to study different configurations
19 // during the development of the new ITS structure.
20 //
21 //  Mario Sitta <sitta@to.infn.it>
22 //  Chinorat Kobdaj (kobdaj@g.sut.ac.th)
23 //*************************************************************************
24
25
26 /* $Id: AliITSUv1Layer.cxx  */
27 // General Root includes
28 #include <TMath.h>
29 // Root Geometry includes
30 //#include <AliLog.h>
31 #include <TGeoManager.h>
32 #include <TGeoVolume.h>
33 #include <TGeoPcon.h>
34 #include <TGeoCone.h>
35 #include <TGeoTube.h> // contaings TGeoTubeSeg
36 #include <TGeoArb8.h>
37 #include <TGeoXtru.h>
38 #include <TGeoCompositeShape.h>
39 #include <TGeoMatrix.h>
40 #include "AliITSUv1Layer.h"
41 #include "AliITSUGeomTGeo.h"
42 #include <TGeoBBox.h>
43 #include <TGeoShape.h>
44 #include <TGeoTrd1.h>
45 using namespace TMath;
46
47 const Double_t AliITSUv1Layer::fgkDefaultSensorThick = 300*fgkmicron;
48 const Double_t AliITSUv1Layer::fgkDefaultLadderThick =   1*fgkcm;
49
50 const Double_t AliITSUv1Layer::fgkOBHalfStaveWidth   =   3.01 *fgkcm;
51 const Double_t AliITSUv1Layer::fgkOBModuleGap        =   0.01 *fgkcm;
52 const Double_t AliITSUv1Layer::fgkOBFlexCable1Thick  =   0.005*fgkcm;
53 const Double_t AliITSUv1Layer::fgkOBFlexCable2Thick  =   0.01 *fgkcm;
54 const Double_t AliITSUv1Layer::fgkOBBusCable1Thick   =   0.02 *fgkcm;
55 const Double_t AliITSUv1Layer::fgkOBBusCable2Thick   =   0.02 *fgkcm;
56 const Double_t AliITSUv1Layer::fgkOBColdPlateThick   =   0.012*fgkcm;
57 const Double_t AliITSUv1Layer::fgkOBCarbonPlateThick =   0.012*fgkcm;
58 const Double_t AliITSUv1Layer::fgkOBGlueThick        =   0.03 *fgkcm;
59 const Double_t AliITSUv1Layer::fgkOBModuleZLength    =  21.06 *fgkcm;
60
61
62 ClassImp(AliITSUv1Layer)
63
64 #define SQ(A) (A)*(A)
65
66 //________________________________________________________________________
67 AliITSUv1Layer::AliITSUv1Layer(): 
68   AliITSv11Geometry(),
69   fLayerNumber(0),
70   fPhi0(0),
71   fLayRadius(0),
72   fZLength(0),
73   fSensorThick(0),
74   fLadderThick(0),
75   fLadderWidth(0),
76   fLadderTilt(0),
77   fNLadders(0),
78   fNModules(0),
79   fDetTypeID(0),
80   fIsTurbo(0),
81   fBuildLevel(0),
82   fStaveModel(AliITSUv1::kIBModelDummy)
83 {
84   //
85   // Standard constructor
86   //
87 }
88
89 //________________________________________________________________________
90 AliITSUv1Layer::AliITSUv1Layer(Int_t debug): 
91   AliITSv11Geometry(debug),
92   fLayerNumber(0),
93   fPhi0(0),
94   fLayRadius(0),
95   fZLength(0),
96   fSensorThick(0),
97   fLadderThick(0),
98   fLadderWidth(0),
99   fLadderTilt(0),
100   fNLadders(0),
101   fNModules(0),
102   fDetTypeID(0),
103   fIsTurbo(0),
104   fBuildLevel(0),
105   fStaveModel(AliITSUv1::kIBModelDummy)
106 {
107   //
108   // Constructor setting debugging level
109   //
110 }
111
112 //________________________________________________________________________
113 AliITSUv1Layer::AliITSUv1Layer(Int_t lay, Int_t debug): 
114   AliITSv11Geometry(debug),
115   fLayerNumber(lay),
116   fPhi0(0),
117   fLayRadius(0),
118   fZLength(0),
119   fSensorThick(0),
120   fLadderThick(0),
121   fLadderWidth(0),
122   fLadderTilt(0),
123   fNLadders(0),
124   fNModules(0),
125   fDetTypeID(0),
126   fIsTurbo(0),
127   fBuildLevel(0),
128   fStaveModel(AliITSUv1::kIBModelDummy)
129 {
130   //
131   // Constructor setting layer number and debugging level
132   //
133 }
134
135 //________________________________________________________________________
136 AliITSUv1Layer::AliITSUv1Layer(Int_t lay, Bool_t turbo, Int_t debug): 
137   AliITSv11Geometry(debug),
138   fLayerNumber(lay),
139   fPhi0(0),
140   fLayRadius(0),
141   fZLength(0),
142   fSensorThick(0),
143   fLadderThick(0),
144   fLadderWidth(0),
145   fLadderTilt(0),
146   fNLadders(0),
147   fNModules(0),
148   fDetTypeID(0),
149   fIsTurbo(turbo),
150   fBuildLevel(0),
151   fStaveModel(AliITSUv1::kIBModelDummy)
152 {
153   //
154   // Constructor setting layer number and debugging level
155   // for a "turbo" layer (i.e. where ladders overlap in phi)
156   //
157 }
158
159 //________________________________________________________________________
160 AliITSUv1Layer::AliITSUv1Layer(const AliITSUv1Layer &s):
161   AliITSv11Geometry(s.GetDebug()),
162   fLayerNumber(s.fLayerNumber),
163   fPhi0(s.fPhi0),
164   fLayRadius(s.fLayRadius),
165   fZLength(s.fZLength),
166   fSensorThick(s.fSensorThick),
167   fLadderThick(s.fLadderThick),
168   fLadderWidth(s.fLadderWidth),
169   fLadderTilt(s.fLadderTilt),
170   fNLadders(s.fNLadders),
171   fNModules(s.fNModules),
172   fDetTypeID(s.fDetTypeID),
173   fIsTurbo(s.fIsTurbo),
174   fBuildLevel(s.fBuildLevel),
175   fStaveModel(s.fStaveModel)
176 {
177   //
178   // Copy constructor
179   //
180 }
181
182 //________________________________________________________________________
183 AliITSUv1Layer& AliITSUv1Layer::operator=(const AliITSUv1Layer &s)
184 {
185   //
186   // Assignment operator 
187   //
188   if(&s == this) return *this;
189
190   fLayerNumber = s.fLayerNumber;
191   fPhi0        = s.fPhi0;
192   fLayRadius   = s.fLayRadius;
193   fZLength     = s.fZLength;
194   fSensorThick = s.fSensorThick;
195   fLadderThick = s.fLadderThick;
196   fLadderWidth = s.fLadderWidth;
197   fLadderTilt  = s.fLadderTilt;
198   fNLadders    = s.fNLadders;
199   fNModules    = s.fNModules;
200   fIsTurbo     = s.fIsTurbo;
201   fDetTypeID   = s.fDetTypeID;
202   fBuildLevel  = s.fBuildLevel;
203   fStaveModel  = s.fStaveModel;
204
205   return *this;
206 }
207
208 //________________________________________________________________________
209 AliITSUv1Layer::~AliITSUv1Layer() {
210   //
211   // Destructor
212   //
213 }
214
215 //________________________________________________________________________
216 void AliITSUv1Layer::CreateLayer(TGeoVolume *moth){
217 //
218 // Creates the actual Layer and places inside its mother volume
219 //
220 // Input:
221 //         moth : the TGeoVolume owing the volume structure
222 //
223 // Output:
224 //
225 // Return:
226 //
227 // Created:      17 Jun 2011  Mario Sitta
228 // Updated:      08 Jul 2011  Mario Sitta
229 // Updated:      20 May 2013  Mario Sitta  Layer is Assembly instead of Tube
230 //
231   // Local variables
232   char volname[30];
233   Double_t xpos, ypos, zpos;
234   Double_t alpha;
235
236
237   // Check if the user set the proper parameters
238   if (fLayRadius <= 0) AliFatal(Form("Wrong layer radius (%f)",fLayRadius));
239   if (fZLength   <= 0) AliFatal(Form("Wrong layer length (%f)",fZLength));
240   if (fNLadders  <= 0) AliFatal(Form("Wrong number of ladders (%d)",fNLadders));
241   if (fNModules  <= 0) AliFatal(Form("Wrong number of modules (%d)",fNModules));
242
243   if (fLadderThick <= 0) {
244     AliInfo(Form("Ladder thickness wrong or not set (%f), using default (%f)",
245                  fLadderThick,fgkDefaultLadderThick));
246     fLadderThick = fgkDefaultLadderThick;
247   }
248
249   if (fSensorThick <= 0) {
250     AliInfo(Form("Sensor thickness wrong or not set (%f), using default (%f)",
251                  fSensorThick,fgkDefaultSensorThick));
252     fSensorThick = fgkDefaultSensorThick;
253   }
254
255   if (fSensorThick > fLadderThick) {
256     AliWarning(Form("Sensor thickness (%f) is greater than ladder thickness (%f), fixing",
257                  fSensorThick,fLadderThick));
258     fSensorThick = fLadderThick;
259   }
260
261
262   // If a Turbo layer is requested, do it and exit
263   if (fIsTurbo) {
264     CreateLayerTurbo(moth);
265     return;
266   }
267
268
269   // First create the ladder container
270   alpha = (360./(2*fNLadders))*DegToRad();
271
272   //  fLadderWidth = fLayRadius*Tan(alpha);
273
274   snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(),fLayerNumber);
275   TGeoVolume *layVol = new TGeoVolumeAssembly(volname);
276   layVol->SetUniqueID(fDetTypeID);
277
278 //  layVol->SetVisibility(kFALSE);
279   layVol->SetVisibility(kTRUE);
280   layVol->SetLineColor(1);
281
282   TGeoVolume *laddVol = CreateLadder();
283
284
285   // Now build up the layer
286   alpha = 360./fNLadders;
287   Double_t r = fLayRadius + ((TGeoBBox*)laddVol->GetShape())->GetDY();
288   for (Int_t j=0; j<fNLadders; j++) {
289     Double_t phi = j*alpha + fPhi0;
290     xpos = r*CosD(phi);// r*SinD(-phi);
291     ypos = r*SinD(phi);// r*CosD(-phi);
292     zpos = 0.;
293     phi += 90;
294     layVol->AddNode(laddVol, j, new TGeoCombiTrans( xpos, ypos, zpos,
295                                                     new TGeoRotation("",phi,0,0)));
296   }
297
298
299   // Finally put everything in the mother volume
300   moth->AddNode(layVol, 1, 0);
301
302
303   // Upgrade geometry is served
304   return;
305 }
306
307 //________________________________________________________________________
308 void AliITSUv1Layer::CreateLayerTurbo(TGeoVolume *moth){
309 //
310 // Creates the actual Layer and places inside its mother volume
311 // A so-called "turbo" layer is a layer where ladders overlap in phi
312 // User can set width and tilt angle, no check is performed here
313 // to avoid volume overlaps
314 //
315 // Input:
316 //         moth : the TGeoVolume owing the volume structure
317 //
318 // Output:
319 //
320 // Return:
321 //
322 // Created:      08 Jul 2011  Mario Sitta
323 // Updated:      08 Mar 2012  Mario Sitta  Correct way to compute container R
324 // Updated:      20 May 2013  Mario Sitta  Layer is Assemgbly instead of Tube
325 //
326
327
328   // Local variables
329   char volname[30];
330   Double_t xpos, ypos, zpos;
331   Double_t alpha;
332
333
334   // Check if the user set the proper (remaining) parameters
335   if (fLadderWidth <= 0)
336     AliFatal(Form("Wrong ladder width (%f)",fLadderWidth));
337   if (Abs(fLadderTilt) > 45)
338     AliWarning(Form("Ladder tilt angle (%f) greater than 45deg",fLadderTilt));
339
340
341   snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(), fLayerNumber);
342   TGeoVolume *layVol = new TGeoVolumeAssembly(volname);
343   layVol->SetUniqueID(fDetTypeID);
344   layVol->SetVisibility(kTRUE);
345   layVol->SetLineColor(1);
346   TGeoVolume *laddVol = CreateLadder();
347
348
349   // Now build up the layer
350   alpha = 360./fNLadders;
351   Double_t r = fLayRadius /* +module thick ?! */;
352   for (Int_t j=0; j<fNLadders; j++) {
353     Double_t phi = j*alpha + fPhi0;
354     xpos = r*CosD(phi);// r*SinD(-phi);
355     ypos = r*SinD(phi);// r*CosD(-phi);
356     zpos = 0.;
357     phi += 90;
358     layVol->AddNode(laddVol, j, new TGeoCombiTrans( xpos, ypos, zpos,
359                                                     new TGeoRotation("", phi-fLadderTilt,0,0)));
360   }
361
362
363   // Finally put everything in the mother volume
364   moth->AddNode(layVol, 1, 0);
365
366   return;
367 }
368
369 //________________________________________________________________________
370 TGeoVolume* AliITSUv1Layer::CreateLadder(const TGeoManager * /*mgr*/){
371 //
372 // Creates the actual Ladder
373 //
374 // Input:
375 //         mgr  : the GeoManager (used only to get the proper material)
376 //
377 // Output:
378 //
379 // Return:
380 //
381 // Created:      22 Jun 2011  Mario Sitta
382 // Updated:      18 Dec 2013  Mario Sitta  Handle IB and OB
383 //
384
385   char volname[30];
386   Double_t xLenO = 5.79/2;
387  
388   Double_t xlenI, ylen, zlen;
389   Double_t xpos, ypos, zpos, zmod;
390   Double_t alpha;
391
392
393   // First create all needed shapes
394   alpha = (360./(2*fNLadders))*DegToRad();
395
396   // The ladder
397   xlenI = fLayRadius*Tan(alpha);
398   if (fIsTurbo) xlenI = 0.5*fLadderWidth;
399   ylen = 0.5*fLadderThick;
400   zlen = 0.5*fZLength;
401
402   Double_t yplus = 0.46;
403   TGeoXtru *ladder = new TGeoXtru(2); //z sections
404   Double_t xv[5] = {xlenI,xlenI,0,-xlenI,-xlenI};
405   Double_t yv[5] = {ylen+0.09,-0.15,-yplus-fSensorThick,-0.15,ylen+0.09};    
406   ladder->DefinePolygon(5,xv,yv);
407   ladder->DefineSection(0,-zlen,0,0,1.);
408   ladder->DefineSection(1,+zlen,0,0,1.);
409
410   // We have all shapes: now create the real volumes
411
412   snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSLadderPattern(), fLayerNumber);
413 //  TGeoVolume *laddVol = new TGeoVolume(volname, ladder, medAir);
414   TGeoVolume *laddVol = new TGeoVolumeAssembly(volname);
415
416   //  laddVol->SetVisibility(kFALSE);
417   laddVol->SetVisibility(kTRUE);
418   laddVol->SetLineColor(2);
419   TGeoVolume *modVol = 0;
420   TGeoVolume *mechLaddVol = 0;
421
422   // Now build up the ladder
423   if (fLayerNumber<3) {
424     modVol = CreateModuleInnerB(xlenI,ylen,zlen);
425     zmod = ((TGeoBBox*)modVol->GetShape())->GetDZ();
426     for (Int_t j=0; j<fNModules; j++) {
427       xpos = 0.;
428       ypos = 0.021;  // Remove small overlap - M.S: 21may13
429       zpos = -ladder->GetDZ() + j*2*zmod + zmod;
430       laddVol->AddNode(modVol, j, new TGeoTranslation(xpos, ypos, zpos));
431     }
432  
433   // put mechanical stave structure, only inner barrel up to now
434     mechLaddVol = CreateStaveStructInnerB(xlenI,zlen); 
435     if (mechLaddVol)
436       laddVol->AddNode(mechLaddVol, fNModules, new TGeoCombiTrans(0, -0.15-ylen, 0, new TGeoRotation("",0, 0, 180)));
437   }
438
439   else{
440     if (fStaveModel == AliITSUv1::kOBModel0) { // Create simplified stave struct as in v0
441       modVol = CreateModuleInnerB(xlenI,ylen,zlen);
442   printf("?????? %f %f %f\n",xlenI,ylen,zlen);
443       zmod = ((TGeoBBox*)modVol->GetShape())->GetDZ();
444       for (Int_t j=0; j<fNModules; j++) {
445         xpos = 0.;
446         ypos = 0.021;  // Remove small overlap - M.S: 21may13
447         zpos = -ladder->GetDZ() + j*2*zmod + zmod;
448         laddVol->AddNode(modVol, j, new TGeoTranslation(xpos, ypos, zpos));
449       }
450     } else { // (if fStaveModel) Create new stave struct as in TDR
451       modVol = CreateStaveOuterB(xLenO);
452       laddVol->AddNode(modVol, 1, new TGeoTranslation(0, 2.5, 0));
453
454       mechLaddVol = CreateSpaceFrameOuterB(xLenO); 
455       if (mechLaddVol)
456         laddVol->AddNode(mechLaddVol, 1,
457                          new TGeoCombiTrans(0, 0, 0,
458                                             new TGeoRotation("", 180, 0, 0)));
459     } // if (fStaveModel)
460   }
461   
462
463   // Done, return the ladder
464   return laddVol;
465 }
466
467 //________________________________________________________________________
468 TGeoVolume* AliITSUv1Layer::CreateStaveStructInnerB(const Double_t xlad,
469                                                     const Double_t zlad,
470                                                     const TGeoManager *mgr){
471 //
472 // Create the mechanical stave structure
473 //
474 // Input:
475 //         xlad : X length
476 //         zlad : Z length
477 //         mgr  : the GeoManager (used only to get the proper material)
478 //
479 // Output:
480 //
481 // Return:
482 //
483 // Created:      22 Mar 2013  Chinorat Kobdaj
484 // Updated:      26 Apr 2013  Mario Sitta
485 //
486
487   TGeoVolume *mechLaddVol = 0;
488
489   switch (fStaveModel) {
490     case AliITSUv1::kIBModelDummy:
491       mechLaddVol = CreateStaveModelInnerBDummy(xlad,zlad,mgr);
492       break;
493     case AliITSUv1::kIBModel0:
494       mechLaddVol = CreateStaveModelInnerB0(xlad,zlad,mgr);
495       break;
496     case AliITSUv1::kIBModel1:
497       mechLaddVol = CreateStaveModelInnerB1(xlad,zlad,mgr);
498       break;
499     case AliITSUv1::kIBModel21:
500       mechLaddVol = CreateStaveModelInnerB21(xlad,zlad,mgr);
501       break;
502     case AliITSUv1::kIBModel22:
503       mechLaddVol = CreateStaveModelInnerB22(xlad,zlad,mgr);
504       break;
505     case AliITSUv1::kIBModel3:
506       mechLaddVol = CreateStaveModelInnerB3(xlad,zlad,mgr);
507       break;
508     default:
509       AliFatal(Form("Unknown stave model %d",fStaveModel));
510       break;
511   }
512
513   return mechLaddVol; 
514 }
515
516
517 //________________________________________________________________________
518 TGeoVolume* AliITSUv1Layer::CreateStaveModelInnerBDummy(const Double_t ,
519                                                         const Double_t ,
520                                                         const TGeoManager *) const {
521 //
522 // Create dummy stave
523 //
524 // Input:
525 //         xlad : X length
526 //         zlad : Z length
527 //         mgr  : the GeoManager (used only to get the proper material)
528 //
529 // Output:
530 //
531 // Return:
532 //
533 // Created:      22 Mar 2013  Chinorat Kobdaj
534 // Updated:      26 Apr 2013  Mario Sitta
535 //
536
537   // Done, return the stave structur
538   return 0;
539 }
540
541 //________________________________________________________________________
542 TGeoVolume* AliITSUv1Layer::CreateStaveModelInnerB0(const Double_t xlad,
543                                                     const Double_t zlad,
544                                                     const TGeoManager *mgr){
545 //
546 // Create the mechanical stave structure for Model 0 of TDR
547 //
548 // Input:
549 //         xlad : X length
550 //         zlad : Z length
551 //         mgr  : the GeoManager (used only to get the proper material)
552 //
553 // Output:
554 //
555 // Return:
556 //
557 // Created:      22 Mar 2013  Chinorat Kobdaj
558 // Updated:      26 Apr 2013  Mario Sitta
559 //
560   
561   // Materials defined in AliITSUv1
562   TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
563   TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
564
565   TGeoMedium *medM60J3K    = mgr->GetMedium("ITS_M60J3K$"); 
566   TGeoMedium *medKapton    = mgr->GetMedium("ITS_KAPTON(POLYCH2)$");
567   TGeoMedium *medGlue      = mgr->GetMedium("ITS_GLUE$");
568   TGeoMedium *medFlexCable = mgr->GetMedium("ITS_FLEXCABLE$");
569
570   // Local parameters
571   Double_t kConeOutRadius = 0.15/2;
572   Double_t kConeInRadius = 0.1430/2;
573   Double_t kStaveLength = zlad*2;
574   Double_t kStaveWidth = xlad*2-kConeOutRadius*2;
575   Double_t kWidth = kStaveWidth/4;//1/2 of kWidth
576   Double_t kStaveHeight = 0.3;
577   Double_t kHeight = kStaveHeight/2;
578   Double_t kAlpha = 90-67;//90-33.69;
579   Double_t kTheta = kAlpha*TMath::DegToRad();
580   Double_t kS1 = kWidth/TMath::Sin(kTheta);
581   Double_t kL1 = kWidth/TMath::Tan(kTheta);
582   Double_t kS2 = TMath::Sqrt(kHeight*kHeight + kS1*kS1);//TMath::Sin(the2);
583   Double_t kThe2 = TMath::ATan(kHeight/kS1);
584   Double_t kBeta = kThe2*TMath::RadToDeg();
585   // Int_t  loop = kStaveLength/(kL1);
586   // Double_t s3 = kWidth/(2*TMath::Sin(kTheta));
587   // Double_t s4 = 3*kWidth/(2*TMath::Sin(kTheta));
588
589   AliDebug(1, Form("BuildLevel %d\n",fBuildLevel));
590
591   char volname[30];
592   snprintf(volname, 30, "%s%d_StaveStruct", AliITSUGeomTGeo::GetITSLadderPattern(), fLayerNumber);
593
594   Double_t z=0, y=-0.011+0.0150, x=0;
595
596    TGeoVolume *mechLaddVol = 0;
597
598   if (fBuildLevel < 5) {
599
600     // world (trapezoid)
601     TGeoXtru *mechStruct = new TGeoXtru(2); //z sections
602     Double_t xv[5] = {kStaveWidth/2+0.1,kStaveWidth/2+0.1,0,-kStaveWidth/2-0.1,-kStaveWidth/2-0.1};
603     Double_t yv[5] = {-kConeOutRadius*2-0.07,0,kStaveHeight,0,-kConeOutRadius*2-0.07};    
604     mechStruct->DefinePolygon(5,xv,yv);
605     mechStruct->DefineSection(0,-kStaveLength-0.1,0,0,1.);
606     mechStruct->DefineSection(1,kStaveLength+0.1,0,0,1.);
607
608     mechLaddVol = new TGeoVolume(volname, mechStruct, medAir);
609     mechLaddVol->SetLineColor(12);
610     mechLaddVol->SetFillColor(12); 
611     mechLaddVol->SetVisibility(kTRUE);
612       
613     // detailed structure ++++++++++++++
614     //Pipe Kapton grey-35
615     TGeoTube *coolTube = new TGeoTube(kConeInRadius,kConeOutRadius,kStaveLength/2);
616     TGeoVolume *volCoolTube= new TGeoVolume("pipe", coolTube, medKapton);
617     volCoolTube->SetFillColor(35);
618     volCoolTube->SetLineColor(35);
619     mechLaddVol->AddNode(volCoolTube,0,new TGeoTranslation(x+(kStaveWidth/2),y-(kHeight-kConeOutRadius),0));
620     mechLaddVol->AddNode(volCoolTube,1,new TGeoTranslation(x-(kStaveWidth/2),y-(kHeight-kConeOutRadius),0));
621   }
622
623   if (fBuildLevel < 4) {
624     TGeoTube *coolTubeW = new TGeoTube(0.,kConeInRadius,kStaveLength/2);
625     TGeoVolume *volCoolTubeW= new TGeoVolume("pipeWater", coolTubeW, medWater);
626     volCoolTubeW->SetFillColor(4);
627     volCoolTubeW->SetLineColor(4);
628     mechLaddVol->AddNode(volCoolTubeW,0,new TGeoTranslation(x+(kStaveWidth/2),y-(kHeight-kConeOutRadius),0));
629     mechLaddVol->AddNode(volCoolTubeW,1,new TGeoTranslation(x-(kStaveWidth/2),y-(kHeight-kConeOutRadius),0));
630   }
631
632   //frequency of filament
633   //n = 4 means very dense(4 filaments per interval)
634   //n = 2 means dense(2 filaments per interval)
635   Int_t n =4;
636   Int_t loop = (Int_t)(kStaveLength/(4*kL1/n) + 2/n)-1;
637   if (fBuildLevel < 3) {
638     //Top CFRP Filament black-12 Carbon structure TGeoBBox (length,thickness,width)
639     TGeoBBox *t2=new TGeoBBox(kS2,0.007/2,0.15/2);//(kS2,0.002,0.02);
640     TGeoVolume *volT2=new TGeoVolume("TopFilament", t2, medM60J3K);
641     volT2->SetLineColor(12);
642     volT2->SetFillColor(12); 
643
644     for(int i=1;i<loop;i++){  //i<60;i++){
645       mechLaddVol->AddNode(volT2,4*i+0,
646                                   new TGeoCombiTrans(x+kWidth,y+(2*kConeOutRadius),z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2,//z-14.25+(i*2*kL1),
647                                                      new TGeoRotation("volT2",90,90-kAlpha,90-kBeta)));
648       mechLaddVol->AddNode(volT2,4*i+1,
649                                   new TGeoCombiTrans(x-kWidth,y+(2*kConeOutRadius),z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2,//z-14.25+(i*2*kL1),
650                                                      new TGeoRotation("volT2",90,-90+kAlpha,-90+kBeta)));
651       mechLaddVol->AddNode(volT2,4*i+2,
652                                   new TGeoCombiTrans(x+kWidth,y+(2*kConeOutRadius),z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2,//z-14.25+(i*2*kL1),
653                                                      new TGeoRotation("volT2",90,-90+kAlpha,90-kBeta)));
654       mechLaddVol->AddNode(volT2,4*i+3,
655                                   new TGeoCombiTrans(x-kWidth,y+(2*kConeOutRadius),z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2,//z-14.25+(i*2*kL1),  
656                                                      new TGeoRotation("volT2",90,90-kAlpha,-90+kBeta)));
657     }
658
659
660     //Bottom CFRP Filament black-12 Carbon structure  TGeoBBox (thickness,width,length)
661     TGeoBBox *t1=new TGeoBBox(0.007/2,0.15/2,kS1);//(0.002,0.02,kS1);
662     TGeoVolume *volT1=new TGeoVolume("CFRPBottom", t1, medM60J3K);
663     volT1->SetLineColor(12);
664     volT1->SetFillColor(12); 
665
666     for(int i=1;i<loop;i++){
667       mechLaddVol->AddNode(volT1,4*i+0,
668                                   new TGeoCombiTrans(x+kWidth,y-kHeight,z-kStaveLength/2+((4/n)*kL1*i)+kS1/2, //z-14.25+(i*2*kL1),  
669                                                      new TGeoRotation("volT1",-90,kAlpha,0)));
670       mechLaddVol->AddNode(volT1,4*i+1,
671                                   new TGeoCombiTrans(x-kWidth,y-kHeight,z-kStaveLength/2+((4/n)*kL1*i)+kS1/2,  //z-14.25+(i*2*kL1), 
672                                                      new TGeoRotation("volT1",90,kAlpha,0)));
673       mechLaddVol->AddNode(volT1,4*i+2,
674                                   new TGeoCombiTrans(x+kWidth,y-kHeight,z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2, //z-14.25+(i*2*kL1), 
675                                                      new TGeoRotation("volT1",-90,-kAlpha,0)));
676       mechLaddVol->AddNode(volT1,4*i+3,
677                                   new TGeoCombiTrans(x-kWidth,y-kHeight,z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2, //z-14.25+(i*2*kL1), 
678                                                      new TGeoRotation("volT1",-90,+kAlpha,0)));
679     }
680   }
681    
682   if (fBuildLevel < 2) {
683     // Glue CFRP-Silicon layers TGeoBBox(thickness,width,kS1);
684     TGeoBBox *tG=new TGeoBBox(0.0075/2,0.18/2,kS1);
685     TGeoVolume *volTG=new TGeoVolume("Glue1", tG, medGlue);
686     volTG->SetLineColor(5);
687     volTG->SetFillColor(5); 
688
689     for(int i=1;i<loop;i++){ //i<60;i++){
690       mechLaddVol->AddNode(volTG,4*i+0,
691                                   new TGeoCombiTrans(x+kWidth,y-0.16,z-kStaveLength/2+((4/n)*kL1*i)+kS1/2, //z-14.25+(2*kL1*i), 
692                                                      new TGeoRotation("volTG",-90,kAlpha,0)));
693       mechLaddVol->AddNode(volTG,4*i+1,
694                                   new TGeoCombiTrans(x-kWidth,y-0.16,z-kStaveLength/2+((4/n)*kL1*i)+kS1/2, //z-14.25+(2*kL1*i), 
695                                                      new TGeoRotation("volTG",90,kAlpha,0)));
696       mechLaddVol->AddNode(volTG,4*i+2,
697                                   new TGeoCombiTrans(x+kWidth,y-0.16,z-kStaveLength/2+((4/n)*i*kL1)+kS1/2, //z-14.25+(i*2*kL1), 
698                                                      new TGeoRotation("volTG",-90,-kAlpha,0)));
699       mechLaddVol->AddNode(volTG,4*i+3,
700                                   new TGeoCombiTrans(x-kWidth,y-0.16,z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2, //z-14.25+(i*2*kL1), 
701                                                      new TGeoRotation("volTG",-90,+kAlpha,0)));
702     }
703
704     TGeoBBox *glue = new TGeoBBox(xlad, 0.005/2, zlad);
705     TGeoVolume *volGlue=new TGeoVolume("Glue2", glue, medGlue);
706     volGlue->SetLineColor(5);
707     volGlue->SetFillColor(5); 
708     //mechLaddVol->AddNode(volGlue, 0, new TGeoCombiTrans(x, y-0.16, z, new TGeoRotation("",0, 0, 0)));
709     mechLaddVol->AddNode(volGlue, 1, new TGeoCombiTrans(x, y-0.165-fSensorThick-0.005, z, new TGeoRotation("",0, 0, 0)));
710   }
711
712   if (fBuildLevel < 1) {
713     //Flex cable brown-28 TGeoBBox(width,thickness,length); 
714     TGeoBBox *kapCable = new TGeoBBox(xlad, 0.01/2, zlad);
715     TGeoVolume *volCable=new TGeoVolume("FlexCable", kapCable, medFlexCable);
716     volCable->SetLineColor(28);
717     volCable->SetFillColor(28); 
718     mechLaddVol->AddNode(volCable, 0, new TGeoCombiTrans(x, y-0.165-fSensorThick-0.005-0.01, z, new TGeoRotation("",0, 0, 0)));
719  }
720
721   // Done, return the stave structur
722   return mechLaddVol;
723 }
724
725
726 //________________________________________________________________________
727 TGeoVolume* AliITSUv1Layer::CreateStaveModelInnerB1(const Double_t xlad,
728                                                     const Double_t zlad,
729                                                     const TGeoManager *mgr){
730 //
731 // Create the mechanical stave structure for Model 1 of TDR
732 //
733 // Input:
734 //         xlad : X length
735 //         zlad : Z length
736 //         mgr  : the GeoManager (used only to get the proper material)
737 //
738 // Output:
739 //
740 // Return:
741 //
742 // Created:      22 Mar 2013  Chinorat Kobdaj
743 // Updated:      26 Apr 2013  Mario Sitta
744 //
745   
746   // Materials defined in AliITSUv1
747   TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
748   TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
749
750   TGeoMedium *medM60J3K    = mgr->GetMedium("ITS_M60J3K$"); 
751   TGeoMedium *medKapton    = mgr->GetMedium("ITS_KAPTON(POLYCH2)$");
752   TGeoMedium *medGlue      = mgr->GetMedium("ITS_GLUE$");
753   TGeoMedium *medFlexCable = mgr->GetMedium("ITS_FLEXCABLE$");
754
755   // Local parameters
756   Double_t kConeOutRadius = 0.15/2;
757   //    Double_t kConeInRadius = 0.1430/2;
758   Double_t kStaveLength = zlad*2;
759   //    Double_t kStaveWidth = xlad*2-kConeOutRadius*2;
760   Double_t kStaveWidth = xlad*2;
761   Double_t kWidth = kStaveWidth/4;//1/2 of kWidth
762   Double_t kStaveHeight = 0.3;
763   Double_t kHeight = kStaveHeight/2;
764   Double_t kAlpha = 90-33.;//90-30;
765   Double_t kTheta = kAlpha*TMath::DegToRad();
766   Double_t kS1 = kWidth/TMath::Sin(kTheta);
767   Double_t kL1 = kWidth/TMath::Tan(kTheta);
768   Double_t kS2 = TMath::Sqrt(kHeight*kHeight + kS1*kS1);//TMath::Sin(the2);
769   Double_t kThe2 = TMath::ATan(kHeight/kS1);
770   Double_t kBeta = kThe2*TMath::RadToDeg();
771   Int_t  loop = (Int_t)((kStaveLength/(2*kL1))/2);
772   
773
774   TGeoVolume *mechLaddVol = 0;
775
776   char volname[30];
777   snprintf(volname, 30, "%s%d_StaveStruct", AliITSUGeomTGeo::GetITSLadderPattern(), fLayerNumber);
778     
779
780   // detailed structure ++++++++++++++
781   Double_t z=0, y=-0.011+0.0150, x=0;
782
783   // Polimide micro channels numbers
784   Double_t yMC = y-kHeight+0.01;
785   Int_t nb = (Int_t)(kStaveWidth/0.1)+1;
786   Double_t xladMC = (nb*0.1-0.08)/2;
787
788
789   if (fBuildLevel < 5) {
790     // world (trapezoid)
791     TGeoXtru *mechStruct = new TGeoXtru(2); //z sections
792     Double_t xv[5] = {kStaveWidth/2+0.1,kStaveWidth/2+0.1,0,-kStaveWidth/2-0.1,-kStaveWidth/2-0.1};
793     Double_t yv[5] = {-kConeOutRadius*2-0.07,0,kStaveHeight,0,-kConeOutRadius*2-0.07};    
794     mechStruct->DefinePolygon(5,xv,yv);
795     mechStruct->DefineSection(0,-kStaveLength-0.1,0,0,1.);
796     mechStruct->DefineSection(1,kStaveLength+0.1,0,0,1.);
797
798     mechLaddVol = new TGeoVolume(volname, mechStruct, medAir);
799     mechLaddVol->SetLineColor(12);
800     mechLaddVol->SetFillColor(12); 
801     mechLaddVol->SetVisibility(kTRUE);
802       
803     // Polimide micro channels numbers
804     TGeoBBox *tM0=new TGeoBBox(xladMC, 0.005/2, zlad);
805     TGeoVolume *volTM0=new TGeoVolume("MicroChanCover", tM0, medKapton);
806     volTM0->SetLineColor(35);
807     volTM0->SetFillColor(35); 
808     mechLaddVol->AddNode(volTM0, 0, new TGeoCombiTrans(x,-0.0125+yMC, z, new TGeoRotation("",0, 0, 0)));
809     mechLaddVol->AddNode(volTM0, 1, new TGeoCombiTrans(x,+0.0125+yMC, z, new TGeoRotation("",0, 0, 0)));
810       
811     TGeoBBox *tM0b=new TGeoBBox(0.02/2, 0.02/2, zlad);
812     TGeoVolume *volTM0b=new TGeoVolume("MicroChanWalls", tM0b, medKapton);
813     volTM0b->SetLineColor(35);
814     volTM0b->SetFillColor(35); 
815     for (Int_t ib=0;ib<nb;ib++) {
816       mechLaddVol->AddNode(volTM0b, ib, new TGeoCombiTrans(x+ib*0.1-xladMC+0.01,yMC, z, new TGeoRotation("",0, 0, 0)));
817     }
818       
819   }
820     
821   if (fBuildLevel < 4) {
822     // Water in Polimide micro channels
823     TGeoBBox *water=new TGeoBBox(0.08/2, 0.02/2, zlad+0.1);
824     TGeoVolume *volWater=new TGeoVolume("Water", water, medWater);
825     volWater->SetLineColor(4);
826     volWater->SetFillColor(4); 
827     for (Int_t ib=0;ib<(nb-1);ib++) {
828       mechLaddVol->AddNode(volWater, ib, new TGeoCombiTrans(x+ib*0.1-xladMC+0.06,yMC, z, new TGeoRotation("",0, 0, 0)));
829     }
830   }
831     
832   if (fBuildLevel < 3) {
833     //Bottom filament CFRP black-12 Carbon structure TGeoBBox (thickness,width,length)
834     Double_t filWidth = 0.04;
835     Double_t filHeight= 0.02;
836     TGeoBBox *t1=new TGeoBBox(filHeight/2,filWidth/2,kS1);
837     TGeoVolume *volT1=new TGeoVolume("CFRPBottom", t1, medM60J3K);
838     volT1->SetLineColor(12);
839     volT1->SetFillColor(12); 
840     for(int i=0;i<loop;i++){//i<30;i++){
841       mechLaddVol->AddNode(volT1,4*i+0,
842                                   new TGeoCombiTrans(x+kWidth,y-kHeight+0.04+filHeight/2,z-kStaveLength/2+(4*kL1)+kS1/2, 
843                                                      new TGeoRotation("volT1",-90,kAlpha,0)));
844       mechLaddVol->AddNode(volT1,4*i+1,
845                                   new TGeoCombiTrans(x-kWidth,y-kHeight+0.04+filHeight/2,z-kStaveLength/2+(4*kL1*i)+kS1/2, 
846                                                      new TGeoRotation("volT1",90,kAlpha,0)));
847       mechLaddVol->AddNode(volT1,4*i+2,
848                                   new TGeoCombiTrans(x+kWidth,y-kHeight+0.04+filHeight/2,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2, 
849                                                      new TGeoRotation("volT1",-90,-kAlpha,0)));
850       mechLaddVol->AddNode(volT1,4*i+3,
851                                   new TGeoCombiTrans(x-kWidth,y-kHeight+0.04+filHeight/2,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2, 
852                                                      new TGeoRotation("volT1",-90,+kAlpha,0)));
853     }
854
855       // Top filament CFRP black-12 Carbon structure TGeoBBox (length,thickness,width)
856     TGeoBBox *t2=new TGeoBBox(kS2,filHeight/2,filWidth/2);
857     TGeoVolume *volT2=new TGeoVolume("CFRPTop", t2, medM60J3K);
858     volT2->SetLineColor(12);
859     volT2->SetFillColor(12); 
860     for(int i=0;i<loop;i++){ //i<30;i++){
861       mechLaddVol->AddNode(volT2,4*i+0,
862                                   new TGeoCombiTrans(x+kWidth,y+0.04+filHeight/2,z-kStaveLength/2+(i*4*kL1)+kS1/2,
863                                                      new TGeoRotation("volT2",90,90-kAlpha,90-kBeta)));
864       mechLaddVol->AddNode(volT2,4*i+1,
865                                   new TGeoCombiTrans(x-kWidth,y+0.04+filHeight/2,z-kStaveLength/2+(i*4*kL1)+kS1/2,
866                                                      new TGeoRotation("volT2",90,-90+kAlpha,-90+kBeta)));
867       mechLaddVol->AddNode(volT2,4*i+2,
868                                   new TGeoCombiTrans(x+kWidth,y+0.04+filHeight/2,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2,
869                                                      new TGeoRotation("volT2",90,-90+kAlpha,90-kBeta)));
870       mechLaddVol->AddNode(volT2,4*i+3,
871                                   new TGeoCombiTrans(x-kWidth,y+0.04+filHeight/2,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2, 
872                                                      new TGeoRotation("volT2",90,90-kAlpha,-90+kBeta)));
873     }
874   }
875
876   if (fBuildLevel < 2) {
877     // Glue between filament and polimide micro channel
878     TGeoBBox *t3=new TGeoBBox(0.01/2,0.04,kS1);
879     TGeoVolume *volT3=new TGeoVolume("FilamentGlue", t3, medGlue);
880     volT3->SetLineColor(5);
881     volT3->SetFillColor(5); 
882     for(int i=0;i<loop;i++){//i<30;i++){
883       mechLaddVol->AddNode(volT3,4*i+0,
884                                   new TGeoCombiTrans(x+kWidth,y-kHeight+0.0325,z-kStaveLength/2+(4*kL1*i)+kS1/2, 
885                                                      new TGeoRotation("volT1",-90,kAlpha,0)));
886       mechLaddVol->AddNode(volT3,4*i+1,
887                                   new TGeoCombiTrans(x-kWidth,y-kHeight+0.0325,z-kStaveLength/2+(4*kL1*i)+kS1/2, 
888                                                      new TGeoRotation("volT1",90,kAlpha,0)));
889       mechLaddVol->AddNode(volT3,4*i+2,
890                                   new TGeoCombiTrans(x+kWidth,y-kHeight+0.0325,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2, 
891                                                      new TGeoRotation("volT1",-90,-kAlpha,0)));
892       mechLaddVol->AddNode(volT3,4*i+3,
893                                   new TGeoCombiTrans(x-kWidth,y-kHeight+0.0325,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2, 
894                                                      new TGeoRotation("volT1",-90,+kAlpha,0)));
895     }
896       
897     // Glue microchannel and sensor
898     TGeoBBox *glueM = new TGeoBBox(xlad, 0.01/2, zlad);
899     TGeoVolume *volGlueM=new TGeoVolume("MicroChanGlue", glueM, medGlue);
900     volGlueM->SetLineColor(5);
901     volGlueM->SetFillColor(5); 
902     mechLaddVol->AddNode(volGlueM, 0, new TGeoCombiTrans(x, y-0.16, z, new TGeoRotation("",0, 0, 0)));
903
904     // Glue sensor and kapton
905     TGeoBBox *glue = new TGeoBBox(xlad, 0.005/2, zlad);
906     TGeoVolume *volGlue=new TGeoVolume("SensorGlue", glue, medGlue);
907     volGlue->SetLineColor(5);
908     volGlue->SetFillColor(5); 
909     mechLaddVol->AddNode(volGlue, 1, new TGeoCombiTrans(x, y-0.165-fSensorThick-0.005, z, new TGeoRotation("",0, 0, 0)));
910   }
911
912   if (fBuildLevel < 1) {
913     TGeoBBox *kapCable = new TGeoBBox(xlad, 0.01/2, zlad);
914     TGeoVolume *volCable=new TGeoVolume("FlexCable", kapCable, medFlexCable);
915     volCable->SetLineColor(28);
916     volCable->SetFillColor(28); 
917     mechLaddVol->AddNode(volCable, 0, new TGeoCombiTrans(x, y-0.165-fSensorThick-0.005-0.01, z, new TGeoRotation("",0, 0, 0)));
918   }
919     
920   // Done, return the stave structur
921   return mechLaddVol;
922
923 }
924
925 //________________________________________________________________________
926 TGeoVolume* AliITSUv1Layer::CreateStaveModelInnerB21(const Double_t xlad,
927                                                      const Double_t zlad,
928                                                      const TGeoManager *mgr){
929 //
930 // Create the mechanical stave structure for Model 2.1 of TDR
931 //
932 // Input:
933 //         xlad : X length
934 //         zlad : Z length
935 //         mgr  : the GeoManager (used only to get the proper material)
936 //
937 // Output:
938 //
939 // Return:
940 //
941 // Created:      22 Mar 2013  Chinorat Kobdaj
942 // Updated:      26 Apr 2013  Mario Sitta
943 //
944   
945   // Materials defined in AliITSUv1
946   TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
947   TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
948
949   TGeoMedium *medM60J3K    = mgr->GetMedium("ITS_M60J3K$"); 
950   TGeoMedium *medKapton    = mgr->GetMedium("ITS_KAPTON(POLYCH2)$");
951   TGeoMedium *medGlue      = mgr->GetMedium("ITS_GLUE$");
952   TGeoMedium *medFlexCable = mgr->GetMedium("ITS_FLEXCABLE$");
953   TGeoMedium *medK13D2U2k  = mgr->GetMedium("ITS_K13D2U2k$");
954   TGeoMedium *medFGS003    = mgr->GetMedium("ITS_FGS003$"); 
955   TGeoMedium *medCarbonFleece = mgr->GetMedium("ITS_CarbonFleece$"); 
956
957   // Local parameters
958   Double_t kConeOutRadius =0.151384/2;
959   Double_t kConeInRadius = 0.145034/2;
960   Double_t kStaveLength = zlad;
961   Double_t kStaveWidth = xlad*2;
962   Double_t kWidth = (kStaveWidth+0.005)/4;
963   Double_t kStaveHeigth = 0.33;//0.33;
964   Double_t kHeight = (kStaveHeigth+0.025)/2;
965   Double_t kAlpha = 57; //56.31;
966   Double_t kTheta = kAlpha*TMath::DegToRad();
967   Double_t kS1 = (kStaveWidth/4)/TMath::Sin(kTheta);
968   Double_t kL1 = (kStaveWidth/4)/TMath::Tan(kTheta);
969   Double_t kS2 = sqrt(kHeight*kHeight + kS1*kS1);//TMath::Sin(the2);
970   Double_t kThe2 = TMath::ATan(kHeight/kS1);
971   Double_t kBeta = kThe2*TMath::RadToDeg();
972   // Double_t lay1 = 0.003157;
973   Double_t kLay1 = 0.003;//Amec carbon
974   // Double_t lay2 = 0.0043215;//C Fleece carbon
975   Double_t kLay2 = 0.002;//C Fleece carbon
976   Double_t kLay3 = 0.007;//K13D2U carbon
977   Int_t  loop = (Int_t)(kStaveLength/(2*kL1));
978
979
980   char volname[30];
981   snprintf(volname, 30, "%s%d_StaveStruct", AliITSUGeomTGeo::GetITSLadderPattern(), fLayerNumber);
982
983   Double_t z=0, y=-(kConeOutRadius+0.03)+0.0385, x=0;
984
985   TGeoVolume *mechLaddVol = 0;
986
987   if (fBuildLevel < 5) {
988     // world (trapezoid)
989     TGeoXtru *mechStruct = new TGeoXtru(2); //z sections
990     Double_t xv[5] = {kStaveWidth/2+0.1,kStaveWidth/2+0.1,0,-kStaveWidth/2-0.1,-kStaveWidth/2-0.1};
991     Double_t yv[5] = {-kConeOutRadius*2-0.07,0,kStaveHeigth,0,-kConeOutRadius*2-0.07};    
992     mechStruct->DefinePolygon(5,xv,yv);
993     mechStruct->DefineSection(0,-kStaveLength-0.1,0,0,1.);
994     mechStruct->DefineSection(1,kStaveLength+0.1,0,0,1.);
995
996     mechLaddVol = new TGeoVolume(volname, mechStruct, medAir);
997     mechLaddVol->SetLineColor(12);
998     mechLaddVol->SetFillColor(12); 
999     mechLaddVol->SetVisibility(kTRUE);  
1000       
1001     //Pipe Kapton grey-35 
1002     TGeoCone *cone1 = new TGeoCone(kStaveLength,kConeInRadius,kConeOutRadius,kConeInRadius,kConeOutRadius);
1003     TGeoVolume *volCone1= new TGeoVolume("PolyimidePipe", cone1, medKapton);
1004     volCone1->SetFillColor(35);
1005     volCone1->SetLineColor(35);
1006     mechLaddVol->AddNode(volCone1,1,new TGeoTranslation(x+0.25,y,z));
1007     mechLaddVol->AddNode(volCone1,2,new TGeoTranslation(x-0.25,y,z));
1008   }
1009
1010   if (fBuildLevel < 4) {
1011     
1012     TGeoTube *coolTubeW = new TGeoTube(0.,kConeInRadius,kStaveLength);
1013     TGeoVolume *volCoolTubeW= new TGeoVolume("Water", coolTubeW, medWater);
1014     volCoolTubeW->SetFillColor(4);
1015     volCoolTubeW->SetLineColor(4);
1016     mechLaddVol->AddNode(volCoolTubeW,0,new TGeoTranslation(x-0.25,y,z));
1017     mechLaddVol->AddNode(volCoolTubeW,1,new TGeoTranslation(x+0.25,y,z));
1018   }
1019
1020   if (fBuildLevel < 3) {
1021     //top fillament
1022     // Top filament M60J black-12 Carbon structure TGeoBBox (length,thickness,width)
1023     TGeoBBox *t2=new TGeoBBox(kS2,0.02/2,0.04/2); //TGeoBBox *t2=new TGeoBBox(kS2,0.01,0.02);
1024     TGeoVolume *volT2=new TGeoVolume("TopFilament", t2, medM60J3K);
1025     volT2->SetLineColor(12);
1026     volT2->SetFillColor(12); 
1027     for(int i=0;i<loop;i++){// i<28;i++){
1028       mechLaddVol->AddNode(volT2,i*4+1,new TGeoCombiTrans(x+kWidth,y+kHeight+(0.12/2)-0.014+0.007,z-kStaveLength+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,90-kAlpha,90-kBeta)));
1029       mechLaddVol->AddNode(volT2,i*4+2,new TGeoCombiTrans(x-kWidth,y+kHeight+(0.12/2)-0.014+0.007,z-kStaveLength+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,-90+kAlpha,-90+kBeta)));
1030       mechLaddVol->AddNode(volT2,i*4+3,new TGeoCombiTrans(x+kWidth,y+kHeight+(0.12/2)-0.014+0.007,z-kStaveLength+2*kL1+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,-90+kAlpha,90-kBeta)));
1031       mechLaddVol->AddNode(volT2,i*4+4,new TGeoCombiTrans(x-kWidth,y+kHeight+(0.12/2)-0.014+0.007,z-kStaveLength+2*kL1+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,90-kAlpha,-90+kBeta)));
1032 //    mechLaddVol->AddNode(volT2,i*4+1,new TGeoCombiTrans(x+kWidth+0.0036,y+kHeight-(0.12/2)+0.072,z+kStaveLength+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,90-kAlpha,90-kBeta)));
1033
1034  }
1035  
1036     //wall side structure out
1037     TGeoBBox *box4 = new TGeoBBox(0.03/2,0.12/2,kStaveLength-0.50);
1038     TGeoVolume *plate4 = new TGeoVolume("WallOut",box4,medM60J3K);
1039     plate4->SetFillColor(35);
1040     plate4->SetLineColor(35);
1041     mechLaddVol->AddNode(plate4,1,new TGeoCombiTrans(x+(2*kStaveWidth/4)-(0.03/2),y-0.0022-kConeOutRadius+0.12/2+0.007,z,new TGeoRotation("plate4",0,0,0)));
1042     mechLaddVol->AddNode(plate4,2,new TGeoCombiTrans(x-(2*kStaveWidth/4)+(0.03/2),y-0.0022-kConeOutRadius+0.12/2+0.007,z,new TGeoRotation("plate4",0,0,0)));
1043     //wall side in
1044     TGeoBBox *box5 = new TGeoBBox(0.015/2,0.12/2,kStaveLength-0.50);
1045     TGeoVolume *plate5 = new TGeoVolume("WallIn",box5,medM60J3K);
1046     plate5->SetFillColor(12);
1047     plate5->SetLineColor(12);
1048     mechLaddVol->AddNode(plate5,1,new TGeoCombiTrans(x+(2*kStaveWidth/4)-0.03-0.015/2,y-0.0022-kConeOutRadius+0.12/2+0.007,z,new TGeoRotation("plate5",0,0,0)));
1049     mechLaddVol->AddNode(plate5,2,new TGeoCombiTrans(x-(2*kStaveWidth/4)+0.03+0.015/2,y-0.0022-kConeOutRadius+0.12/2+0.007,z,new TGeoRotation("plate5",0,0,0)));
1050
1051      //Amec Thermasol red-2 cover tube FGS300
1052     TGeoConeSeg *cons1 = new TGeoConeSeg(kStaveLength-0.50,kConeOutRadius,kConeOutRadius+kLay1,kConeOutRadius,kConeOutRadius+kLay1,0,180);
1053     TGeoVolume *cone11 = new TGeoVolume("ThermasolPipeCover",cons1,medFGS003);
1054     cone11->SetFillColor(2);
1055     cone11->SetLineColor(2);
1056     mechLaddVol->AddNode(cone11,1,new TGeoCombiTrans(x+0.25,y,z,new TGeoRotation("Cone11",0,0,0)));
1057     mechLaddVol->AddNode(cone11,2,new TGeoCombiTrans(x-0.25,y,z,new TGeoRotation("Cone11",0,0,0)));
1058
1059     TGeoBBox *box2 = new TGeoBBox((0.50-(2*kConeOutRadius))/2,kLay1/2,kStaveLength-0.50);
1060     TGeoVolume *plate2 = new TGeoVolume("ThermasolMiddle",box2,medFGS003);
1061     plate2->SetFillColor(2);
1062     plate2->SetLineColor(2);
1063     mechLaddVol->AddNode(plate2,1,new TGeoCombiTrans(x,y-kConeOutRadius+(kLay1/2),z,new TGeoRotation("plate2",0,0,0)));
1064
1065     TGeoBBox *box21 = new TGeoBBox((0.75-0.25-kConeOutRadius-kLay1)/2,kLay1/2,kStaveLength-0.50);
1066     TGeoVolume *plate21 = new TGeoVolume("ThermasolLeftRight",box21,medFGS003);
1067     plate21->SetFillColor(2);
1068     plate21->SetLineColor(2);
1069     mechLaddVol->AddNode(plate21,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+(0.75-0.25-kConeOutRadius)/2-(kLay1/2),y-kConeOutRadius+(kLay1/2),z,new TGeoRotation("plate21",0,0,0)));
1070     mechLaddVol->AddNode(plate21,2,new TGeoCombiTrans(x-0.25-kConeOutRadius-(0.75-0.25-kConeOutRadius)/2+(kLay1/2),y-kConeOutRadius+(kLay1/2),z,new TGeoRotation("plate21",0,0,0)));
1071
1072     TGeoBBox *box22 = new TGeoBBox((kLay1/2),kConeOutRadius/2,kStaveLength-0.50);
1073     TGeoVolume *plate22 = new TGeoVolume("ThermasolVertical",box22,medFGS003);
1074     plate22->SetFillColor(2);
1075     plate22->SetLineColor(2);
1076     mechLaddVol->AddNode(plate22,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+(kLay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
1077     mechLaddVol->AddNode(plate22,2,new TGeoCombiTrans(x+0.25-kConeOutRadius-(kLay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
1078     mechLaddVol->AddNode(plate22,3,new TGeoCombiTrans(x-0.25+kConeOutRadius+(kLay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
1079     mechLaddVol->AddNode(plate22,4,new TGeoCombiTrans(x-0.25-kConeOutRadius-(kLay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
1080
1081     //C Fleece
1082     TGeoConeSeg *cons2 = new TGeoConeSeg(kStaveLength-0.50,kConeOutRadius+kLay1,kConeOutRadius+kLay1+kLay2,kConeOutRadius+kLay1,kConeOutRadius+kLay1+kLay2,0,180); 
1083     TGeoVolume *cone12 = new TGeoVolume("CFleecePipeCover",cons2,medCarbonFleece);
1084     cone12->SetFillColor(28);
1085     cone12->SetLineColor(28);
1086     mechLaddVol->AddNode(cone12,1,new TGeoCombiTrans(x+0.25,y,z,new TGeoRotation("Cone12",0,0,0)));
1087     mechLaddVol->AddNode(cone12,2,new TGeoCombiTrans(x-0.25,y,z,new TGeoRotation("Cone12",0,0,0)));
1088
1089     TGeoBBox *box3 = new TGeoBBox((0.50-(2*(kConeOutRadius+kLay1)))/2,kLay2/2,kStaveLength-0.50);
1090     TGeoVolume *plate3 = new TGeoVolume("CFleeceMiddle",box3,medCarbonFleece);
1091     plate3->SetFillColor(28);
1092     plate3->SetLineColor(28);
1093     mechLaddVol->AddNode(plate3,1,new TGeoCombiTrans(x,y-kConeOutRadius+kLay1+(kLay2/2),z,new TGeoRotation("plate3",0,0,0)));
1094
1095     TGeoBBox *box31 = new TGeoBBox((0.75-0.25-kConeOutRadius-kLay1)/2,kLay2/2,kStaveLength-0.50);
1096     TGeoVolume *plate31 = new TGeoVolume("CFleeceLeftRight",box31,medCarbonFleece);
1097     plate31->SetFillColor(28);
1098     plate31->SetLineColor(28);
1099     mechLaddVol->AddNode(plate31,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+kLay1+(0.75-0.25-kConeOutRadius-kLay1)/2,y-kConeOutRadius+kLay1+(kLay2/2),z,new TGeoRotation("plate31",0,0,0)));
1100     mechLaddVol->AddNode(plate31,2,new TGeoCombiTrans(x-0.25-kConeOutRadius-kLay1-(0.75-0.25-kConeOutRadius-kLay1)/2,y-kConeOutRadius+kLay1+(kLay2/2),z,new TGeoRotation("plate31",0,0,0)));
1101
1102     TGeoBBox *box32 = new TGeoBBox((kLay2/2),(kConeOutRadius-kLay1)/2,kStaveLength-0.50);
1103     TGeoVolume *plate32 = new TGeoVolume("CFleeceVertical",box32,medCarbonFleece);
1104     plate32->SetFillColor(28);
1105     plate32->SetLineColor(28);
1106     mechLaddVol->AddNode(plate32,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+kLay1+(kLay2/2),y+(kLay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
1107     mechLaddVol->AddNode(plate32,2,new TGeoCombiTrans(x+0.25-kConeOutRadius-kLay1-(kLay2/2),y+(kLay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
1108     mechLaddVol->AddNode(plate32,3,new TGeoCombiTrans(x-0.25+kConeOutRadius+kLay1+(kLay2/2),y+(kLay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
1109     mechLaddVol->AddNode(plate32,4,new TGeoCombiTrans(x-0.25-kConeOutRadius-kLay1-(kLay2/2),y+(kLay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
1110
1111
1112     //K13D2U carbon plate
1113     TGeoBBox *box1 = new TGeoBBox(2*kWidth,kLay3/2,kStaveLength-0.50);
1114     TGeoVolume *plate1 = new TGeoVolume("CarbonPlate",box1,medK13D2U2k);
1115     plate1->SetFillColor(5);
1116     plate1->SetLineColor(5);
1117     mechLaddVol->AddNode(plate1,1,new TGeoCombiTrans(x,y-(kConeOutRadius+(kLay3/2)),z,new TGeoRotation("plate1",0,0,0)));
1118
1119     //C Fleece bottom plate 
1120     TGeoBBox *box6 = new TGeoBBox(2*kWidth,kLay2/2,kStaveLength-0.50);
1121     TGeoVolume *plate6 = new TGeoVolume("CFleeceBottom",box6,medCarbonFleece);
1122     plate6->SetFillColor(2);
1123     plate6->SetLineColor(2);
1124     mechLaddVol->AddNode(plate6,1,new TGeoCombiTrans(x,y-(kConeOutRadius+kLay3+(kLay2/2)),z,new TGeoRotation("plate1",0,0,0)));
1125       
1126       
1127   }
1128
1129   if (fBuildLevel < 2) {
1130     //Glue layers and kapton
1131     TGeoBBox *glue = new TGeoBBox(kStaveWidth/2, 0.005/2, zlad);
1132     TGeoVolume *volGlue=new TGeoVolume("Glue", glue, medGlue);
1133     volGlue->SetLineColor(5);
1134     volGlue->SetFillColor(5); 
1135     mechLaddVol->AddNode(volGlue, 0, new TGeoCombiTrans(x,y-(kConeOutRadius+kLay3+(kLay2/2)+(0.01/2)), z, new TGeoRotation("",0, 0, 0)));
1136     mechLaddVol->AddNode(volGlue, 1, new TGeoCombiTrans(x,y-(kConeOutRadius+kLay3+(kLay2/2)+0.01+fSensorThick+(0.01/2)), z, new TGeoRotation("",0, 0, 0)));
1137   }
1138
1139   if (fBuildLevel < 1) {
1140     TGeoBBox *kapCable = new TGeoBBox(kStaveWidth/2, 0.01/2, zlad);
1141     TGeoVolume *volCable=new TGeoVolume("FlexCable", kapCable, medFlexCable);
1142     volCable->SetLineColor(28);
1143     volCable->SetFillColor(28); 
1144     mechLaddVol->AddNode(volCable, 0, new TGeoCombiTrans(x, y-(kConeOutRadius+kLay3+(kLay2/2)+0.01+fSensorThick+0.01+(0.01/2)), z, new TGeoRotation("",0, 0, 0)));
1145   }
1146     
1147
1148   // Done, return the stave structure
1149   return mechLaddVol;
1150   
1151 }
1152 // new model22
1153 //________________________________________________________________________
1154 TGeoVolume* AliITSUv1Layer::CreateStaveModelInnerB22(const Double_t xlad,
1155                                                      const Double_t zlad,
1156                                                      const TGeoManager *mgr){
1157 //
1158 // Create the mechanical stave structure for Model 2.2 of TDR
1159 //
1160 // Input:
1161 //         xlad : X length
1162 //         zlad : Z length
1163 //         mgr  : the GeoManager (used only to get the proper material)
1164 //
1165 // Output:
1166 //
1167 // Return:
1168 //
1169 // Created:      22 Mar 2013  Chinorat Kobdaj
1170 // Updated:      26 Apr 2013  Mario Sitta
1171 // Updated:      30 Apr 2013  Wanchaloem Poonsawat 
1172 //
1173   
1174   // Materials defined in AliITSUv1
1175   TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
1176   TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
1177
1178   TGeoMedium *medM60J3K    = mgr->GetMedium("ITS_M60J3K$"); 
1179   TGeoMedium *medKapton    = mgr->GetMedium("ITS_KAPTON(POLYCH2)$");
1180   TGeoMedium *medGlue      = mgr->GetMedium("ITS_GLUE$");
1181   TGeoMedium *medFlexCable = mgr->GetMedium("ITS_FLEXCABLE$");
1182   TGeoMedium *medK13D2U2k  = mgr->GetMedium("ITS_K13D2U2k$");
1183   TGeoMedium *medFGS003    = mgr->GetMedium("ITS_FGS003$"); 
1184   TGeoMedium *medCarbonFleece = mgr->GetMedium("ITS_CarbonFleece$"); 
1185
1186   // Local parameters
1187   Double_t kConeOutRadius =0.107/2;//0.107/2;
1188   Double_t kConeInRadius = 0.1015/2;//0.10105/2
1189   Double_t kStaveLength = zlad;
1190   Double_t kStaveWidth = xlad*2;
1191   Double_t kWidth = (kStaveWidth)/4;
1192   Double_t kStaveHeight = 0.283;//0.33;
1193   Double_t kHeight = (kStaveHeight)/2;
1194   Double_t kAlpha = 57;//56.31;
1195   Double_t kTheta = kAlpha*TMath::DegToRad();
1196   Double_t kS1 = ((kStaveWidth)/4)/TMath::Sin(kTheta);
1197   Double_t kL1 = (kStaveWidth/4)/TMath::Tan(kTheta);
1198   Double_t kS2 = sqrt(kHeight*kHeight + kS1*kS1);//TMath::Sin(kThe2);
1199   Double_t kThe2 = TMath::ATan(kHeight/(0.375-0.036));
1200   Double_t kBeta = kThe2*TMath::RadToDeg();
1201   Double_t klay1 = 0.003;//Amec carbon
1202   Double_t klay2 = 0.002;//C Fleece carbon
1203   Double_t klay3 = 0.007;//CFplate K13D2U carbon
1204   Double_t klay4 = 0.007;//GluekStaveLength/2
1205   Double_t klay5 = 0.01;//Flex cable
1206   Double_t kTopVertexMaxWidth = 0.072;
1207   Double_t kTopVertexHeight = 0.04;
1208   Double_t kSideVertexMWidth = 0.052;
1209   Double_t kSideVertexHeight = 0.11; 
1210
1211  
1212   Int_t  loop = (Int_t)(kStaveLength/(2*kL1));
1213
1214   char volname[30];
1215   snprintf(volname, 30, "%s%d_StaveStruct", AliITSUGeomTGeo::GetITSLadderPattern(), fLayerNumber);
1216
1217   Double_t z=0, y=-(2*kConeOutRadius)+klay1+klay2+fSensorThick/2-0.0004, x=0;
1218
1219   TGeoVolume *mechLaddVol = 0;
1220
1221   if (fBuildLevel < 5) {
1222     // world (trapezoid)
1223     TGeoXtru *mechStruct = new TGeoXtru(2); //z sections
1224     Double_t xv[6] = {kStaveWidth/2,kStaveWidth/2,0.012,-0.012,-kStaveWidth/2,-kStaveWidth/2}; 
1225     /* Double_t yv[6] = {-2*(kConeOutRadius+klay1+1.5*klay2+klay3+klay4+fSensorThick+klay5),
1226                         0-0.02,kStaveHeight+0.01,kStaveHeight+0.01,0-0.02,
1227                         -2*(kConeOutRadius+klay1+1.5*klay2+klay3+klay4+fSensorThick+klay5)};  // (kConeOutRadius*2)-0.0635 */
1228     Double_t yv[6] = {-(kConeOutRadius*2)-0.06395,0-0.02,kStaveHeight+0.01,kStaveHeight+0.01,0-0.02,-(kConeOutRadius*2)-0.06395};  // (kConeOutRadius*2)-0.064
1229     mechStruct->DefinePolygon(6,xv,yv);
1230     mechStruct->DefineSection(0,-kStaveLength,0,0,1.);
1231     mechStruct->DefineSection(1,kStaveLength,0,0,1.);
1232
1233     mechLaddVol = new TGeoVolume(volname, mechStruct, medAir);
1234     mechLaddVol->SetLineColor(12);
1235     mechLaddVol->SetFillColor(12); 
1236     mechLaddVol->SetVisibility(kTRUE);  
1237       
1238     //Polyimide Pipe Kapton grey-35 
1239     TGeoCone *cone1 = new TGeoCone(kStaveLength,kConeInRadius,kConeOutRadius-0.0001,kConeInRadius,kConeOutRadius-0.0001);
1240     TGeoVolume *volCone1= new TGeoVolume("PolyimidePipe", cone1, medKapton);
1241     volCone1->SetFillColor(35);
1242     volCone1->SetLineColor(35);
1243     mechLaddVol->AddNode(volCone1,1,new TGeoTranslation(x+0.25,y,z));
1244     mechLaddVol->AddNode(volCone1,2,new TGeoTranslation(x-0.25,y,z));
1245     }
1246
1247   if (fBuildLevel < 4) {
1248     TGeoTube *coolTubeW = new TGeoTube(0.,kConeInRadius-0.0001,kStaveLength);
1249     TGeoVolume *volCoolTubeW= new TGeoVolume("Water", coolTubeW, medWater);
1250     volCoolTubeW->SetFillColor(4);
1251     volCoolTubeW->SetLineColor(4);
1252     mechLaddVol->AddNode(volCoolTubeW,0,new TGeoTranslation(x-0.25,y,z));
1253     mechLaddVol->AddNode(volCoolTubeW,1,new TGeoTranslation(x+0.25,y,z));
1254   }
1255
1256   if (fBuildLevel < 3) {
1257     //top fillament
1258     // Top filament M60J black-12 Carbon structure TGeoBBox (length,thickness,width)
1259     TGeoBBox *t2=new TGeoBBox(kS2-0.028,0.02/2,0.02/2); //0.04/2//TGeoBBox *t2=new TGeoBBox(kS2,0.01,0.02);//kS2-0.03 old Config.C
1260     TGeoVolume *volT2=new TGeoVolume("TopFilament", t2, medM60J3K);
1261     volT2->SetLineColor(12);
1262     volT2->SetFillColor(12); 
1263     for(int i=0;i<loop;i++){// i<28;i++){
1264       // 1) Front Left Top Filament
1265        mechLaddVol->AddNode(volT2,i*4+1,new TGeoCombiTrans(x+kWidth+0.0036,y+kHeight+0.01,z-kStaveLength+0.1+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,90-kAlpha,90-kBeta)));
1266       // 2) Front Right Top Filament
1267       mechLaddVol->AddNode(volT2,i*4+2,new TGeoCombiTrans(x-kWidth-0.0036,y+kHeight+0.01,z-kStaveLength+0.1+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,-90+kAlpha,-90+kBeta)));
1268       // 3) Back Left  Top Filament
1269       mechLaddVol->AddNode(volT2,i*4+3,new TGeoCombiTrans(x+kWidth+0.0036,y+kHeight+0.01,z-kStaveLength+0.1+2*kL1+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,-90+kAlpha,90-kBeta)));
1270       // 4) Back Right Top Filament
1271       mechLaddVol->AddNode(volT2,i*4+4,new TGeoCombiTrans(x-kWidth-0.0036,y+kHeight+0.01,z-kStaveLength+0.1+2*kL1+(i*4*kL1)+kS1/2, new TGeoRotation("volT2",90,90-kAlpha,-90+kBeta)));
1272    }
1273  
1274      //Vertex  structure 
1275
1276       //top ver trd1
1277       TGeoTrd1 *trd1 = new TGeoTrd1(0,kTopVertexMaxWidth/2,kStaveLength,kTopVertexHeight/2);
1278       TGeoVolume *ibdv = new TGeoVolume("TopVertex",trd1,medM60J3K);
1279       ibdv->SetFillColor(12);
1280       ibdv->SetLineColor(12);
1281       mechLaddVol->AddNode(ibdv,1,new TGeoCombiTrans(x,y+kStaveHeight+0.03,z,new TGeoRotation("ibdv",0.,-90,0)));//y+kStaveHeight+0.056
1282
1283       //left trd2
1284       TGeoTrd1 *trd2 = new TGeoTrd1(0,kSideVertexMWidth/2,kStaveLength, kSideVertexHeight/2);
1285       TGeoVolume *ibdv2 = new TGeoVolume("LeftVertex",trd2,medM60J3K);
1286       ibdv2->SetFillColor(12);
1287       ibdv2->SetLineColor(12);
1288       mechLaddVol->AddNode(ibdv2,1,new TGeoCombiTrans(x+kStaveWidth/2-0.06,y-0.0355,z,new TGeoRotation("ibdv2",-103.3,90,0))); //x-kStaveWidth/2-0.09 old Config.C y-0.0355,
1289
1290       //right trd3
1291       TGeoTrd1 *trd3 = new TGeoTrd1(0,kSideVertexMWidth/2,kStaveLength, kSideVertexHeight/2);
1292       TGeoVolume *ibdv3 = new TGeoVolume("RightVertex",trd3,medM60J3K);
1293       ibdv3->SetFillColor(12);
1294       ibdv3->SetLineColor(12);
1295       mechLaddVol->AddNode(ibdv3,1,new TGeoCombiTrans(x-kStaveWidth/2+0.06,y-0.0355,z,new TGeoRotation("ibdv3",103.3,90,0))); //x-kStaveWidth/2+0.09 old Config.C
1296       
1297      //Carbon Fleece
1298       TGeoConeSeg *cons2 = new TGeoConeSeg(zlad,kConeOutRadius+klay1,kConeOutRadius+klay1+klay2,kConeOutRadius+klay1,kConeOutRadius+klay1+klay2,0,180); 
1299       TGeoVolume *cone12 = new TGeoVolume("CarbonFleecePipeCover",cons2,medCarbonFleece);
1300       cone12->SetFillColor(28);
1301       cone12->SetLineColor(28);
1302       mechLaddVol->AddNode(cone12,1,new TGeoCombiTrans(x+0.25,y,z,new TGeoRotation("cone12",0,0,0)));
1303       mechLaddVol->AddNode(cone12,2,new TGeoCombiTrans(x-0.25,y,z,new TGeoRotation("cone12",0,0,0)));
1304
1305       TGeoBBox *box3 = new TGeoBBox((0.50-(2*(kConeOutRadius+klay1)))/2,klay2/2,zlad);//kStaveLength-0.50);
1306       TGeoVolume *plate3 = new TGeoVolume("CarbonFleeceMiddle",box3,medCarbonFleece);
1307       plate3->SetFillColor(28);
1308       plate3->SetLineColor(28);
1309       mechLaddVol->AddNode(plate3,1,new TGeoCombiTrans(x,y-kConeOutRadius+klay1+(klay2/2),z,new TGeoRotation("plate3",0,0,0)));
1310
1311       TGeoBBox *box31 = new TGeoBBox((0.75-0.25-kConeOutRadius-klay1)/2+0.0025,klay2/2,zlad);
1312       TGeoVolume *plate31 = new TGeoVolume("CarbonFleeceLeftRight",box31,medCarbonFleece);
1313       plate31->SetFillColor(28);
1314       plate31->SetLineColor(28);
1315       mechLaddVol->AddNode(plate31,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+klay1+(0.75-0.25-kConeOutRadius-klay1)/2,y-kConeOutRadius+klay1+(klay2/2),z,new TGeoRotation("plate31",0,0,0)));
1316       mechLaddVol->AddNode(plate31,2,new TGeoCombiTrans(x-0.25-kConeOutRadius-klay1-(0.75-0.25-kConeOutRadius-klay1)/2,y-kConeOutRadius+klay1+(klay2/2),z,new TGeoRotation("plate31",0,0,0)));
1317
1318       TGeoBBox *box32 = new TGeoBBox((klay2/2),(kConeOutRadius-klay1)/2,zlad);
1319       TGeoVolume *plate32 = new TGeoVolume("CarbonFleeceVertical",box32,medCarbonFleece);
1320       plate32->SetFillColor(28);
1321       plate32->SetLineColor(28);
1322       mechLaddVol->AddNode(plate32,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+klay1+(klay2/2),y+(klay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
1323       mechLaddVol->AddNode(plate32,2,new TGeoCombiTrans(x+0.25-kConeOutRadius-klay1-(klay2/2),y+(klay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
1324       mechLaddVol->AddNode(plate32,3,new TGeoCombiTrans(x-0.25+kConeOutRadius+klay1+(klay2/2),y+(klay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
1325       mechLaddVol->AddNode(plate32,4,new TGeoCombiTrans(x-0.25-kConeOutRadius-klay1-(klay2/2),y+(klay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
1326
1327      //Amec Thermasol red-2 cover tube FGS300 or Carbon Paper
1328       TGeoConeSeg *cons1 = new TGeoConeSeg(zlad,kConeOutRadius,kConeOutRadius+klay1-0.0001,kConeOutRadius,kConeOutRadius+klay1-0.0001,0,180);//kConeOutRadius+klay1-0.0001
1329       TGeoVolume *cone11 = new TGeoVolume("ThermasolPipeCover",cons1,medFGS003);
1330       cone11->SetFillColor(2);
1331       cone11->SetLineColor(2);
1332       mechLaddVol->AddNode(cone11,1,new TGeoCombiTrans(x+0.25,y,z,new TGeoRotation("cone11",0,0,0)));
1333       mechLaddVol->AddNode(cone11,2,new TGeoCombiTrans(x-0.25,y,z,new TGeoRotation("cone11",0,0,0)));
1334
1335       TGeoBBox *box2 = new TGeoBBox((0.50-(2*kConeOutRadius))/2,(klay1/2),zlad);//kStaveLength-0.50);
1336       TGeoVolume *plate2 = new TGeoVolume("ThermasolMiddle",box2,medFGS003);
1337       plate2->SetFillColor(2);
1338       plate2->SetLineColor(2);
1339       mechLaddVol->AddNode(plate2,1,new TGeoCombiTrans(x,y-kConeOutRadius+(klay1/2),z,new TGeoRotation("plate2",0,0,0)));
1340
1341       TGeoBBox *box21 = new TGeoBBox((0.75-0.25-kConeOutRadius-klay1)/2+0.0025,(klay1/2),zlad);
1342       TGeoVolume *plate21 = new TGeoVolume("ThermasolLeftRight",box21,medFGS003);
1343       plate21->SetFillColor(2);
1344       plate21->SetLineColor(2);
1345       mechLaddVol->AddNode(plate21,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+(0.75-0.25-kConeOutRadius)/2-(klay1/2)+0.0025,y-kConeOutRadius+(klay1/2),z,new TGeoRotation("plate21",0,0,0)));
1346       mechLaddVol->AddNode(plate21,2,new TGeoCombiTrans(x-0.25-kConeOutRadius-(0.75-0.25-kConeOutRadius)/2+(klay1/2)-0.0025,y-kConeOutRadius+(klay1/2),z,new TGeoRotation("plate21",0,0,0)));
1347
1348       TGeoBBox *box22 = new TGeoBBox((klay1/2),kConeOutRadius/2,zlad);
1349       TGeoVolume *plate22 = new TGeoVolume("ThermasolVertical",box22,medFGS003);
1350       plate22->SetFillColor(2);
1351       plate22->SetLineColor(2);
1352       mechLaddVol->AddNode(plate22,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+(klay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
1353       mechLaddVol->AddNode(plate22,2,new TGeoCombiTrans(x+0.25-kConeOutRadius-(klay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
1354       mechLaddVol->AddNode(plate22,3,new TGeoCombiTrans(x-0.25+kConeOutRadius+(klay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
1355       mechLaddVol->AddNode(plate22,4,new TGeoCombiTrans(x-0.25-kConeOutRadius-(klay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
1356
1357      //K13D2U CF plate
1358       TGeoBBox *box1 = new TGeoBBox(2*kWidth,(klay3)/2,zlad);
1359       TGeoVolume *plate1 = new TGeoVolume("CFPlate",box1,medK13D2U2k);
1360       plate1->SetFillColor(5);
1361       plate1->SetLineColor(5);
1362       mechLaddVol->AddNode(plate1,1,new TGeoCombiTrans(x,y-(kConeOutRadius+(klay3/2)),z,new TGeoRotation("plate1",0,0,0)));
1363
1364      //C Fleece bottom plate 
1365       TGeoBBox *box6 = new TGeoBBox(2*kWidth,(klay2)/2,zlad);
1366       TGeoVolume *plate6 = new TGeoVolume("CarbonFleeceBottom",box6,medCarbonFleece);
1367       plate6->SetFillColor(2);
1368       plate6->SetLineColor(2);
1369       mechLaddVol->AddNode(plate6,1,new TGeoCombiTrans(x,y-(kConeOutRadius+klay3+(klay2/2)),z,new TGeoRotation("plate6",0,0,0)));
1370
1371     }
1372    if (fBuildLevel < 2) {
1373       //Glue klayers and kapton
1374      TGeoBBox *glue = new TGeoBBox(kStaveWidth/2, (klay4)/2, zlad);
1375       TGeoVolume *volGlue=new TGeoVolume("Glue", glue, medGlue);
1376       volGlue->SetLineColor(5);
1377       volGlue->SetFillColor(5); 
1378       // mechLaddVol->AddNode(volGlue, 0, new TGeoCombiTrans(x,y-(kConeOutRadius+klay3+klay2+(klay4/2)), z, new TGeoRotation("",0, 0, 0)));
1379       mechLaddVol->AddNode(volGlue, 0, new TGeoCombiTrans(x,y-(kConeOutRadius+klay3+klay2+(klay4)/2)+0.00005, z, new TGeoRotation("",0, 0, 0)));
1380     }
1381
1382      if (fBuildLevel < 1) {
1383      //Flex Cable or Bus
1384       TGeoBBox *kapCable = new TGeoBBox(kStaveWidth/2, klay5/2, zlad);//klay5/2
1385       TGeoVolume *volCable=new TGeoVolume("FlexCable", kapCable, medFlexCable);
1386       volCable->SetLineColor(28);
1387       volCable->SetFillColor(28); 
1388       //      mechLaddVol->AddNode(volCable, 0, new TGeoCombiTrans(x, y-(kConeOutRadius+klay3+klay2+klay4+fSensorThick+(klay5)/2)+0.0002, z, new TGeoRotation("",0, 0, 0)));
1389       mechLaddVol->AddNode(volCable, 0, new TGeoCombiTrans(x, y-(kConeOutRadius+klay3+klay2+klay4+fSensorThick+(klay5)/2)+0.01185, z, new TGeoRotation("",0, 0, 0)));
1390       }
1391     // Done, return the stave structe
1392     return mechLaddVol;
1393 }
1394
1395 // model3
1396 //________________________________________________________________________
1397 TGeoVolume* AliITSUv1Layer::CreateStaveModelInnerB3(const Double_t xlad,
1398                                                     const Double_t zlad,
1399                                                     const TGeoManager *mgr){
1400 //
1401 // Create the mechanical stave structure for Model 3 of TDR
1402 //
1403 // Input:
1404 //         xlad : X length
1405 //         zlad : Z length
1406 //         mgr  : the GeoManager (used only to get the proper material)
1407 //
1408 // Output:
1409 //
1410 // Return:
1411 //
1412 // Created:      28 May 2013  Chinorat Kobdaj
1413 // Updated:                   Mario Sitta
1414 // Updated:                   Wanchaloem Poonsawat 
1415 //
1416   
1417   // Materials defined in AliITSUv1
1418   TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
1419   TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
1420
1421   TGeoMedium *medM60J3K    = mgr->GetMedium("ITS_M60J3K$"); 
1422   TGeoMedium *medKapton    = mgr->GetMedium("ITS_KAPTON(POLYCH2)$");
1423   TGeoMedium *medGlue      = mgr->GetMedium("ITS_GLUE$");
1424   TGeoMedium *medFlexCable = mgr->GetMedium("ITS_FLEXCABLE$");
1425   //TGeoMedium *medK13D2U2k  = mgr->GetMedium("ITS_K13D2U2k$");
1426   //TGeoMedium *medFGS003    = mgr->GetMedium("ITS_FGS003$"); 
1427   //TGeoMedium *medCarbonFleece = mgr->GetMedium("ITS_CarbonFleece$"); 
1428
1429   // Local parameters
1430     Double_t kConeOutRadius = 0.15/2;
1431     Double_t kStaveLength = zlad*2;
1432     Double_t kStaveWidth = xlad*2;
1433     Double_t w = kStaveWidth/4;//1/2 of W
1434     Double_t staveHeight = 0.3;
1435     Double_t h = staveHeight/2;
1436     Double_t alpha = 90-33.;//90-30;
1437     Double_t the1 = alpha*TMath::DegToRad();
1438     Double_t s1 = w/TMath::Sin(the1);
1439     Double_t l = w/TMath::Tan(the1);
1440     Double_t s2 = TMath::Sqrt(h*h + s1*s1);//TMath::Sin(the2);
1441     Double_t the2 = TMath::ATan(h/s1);
1442     Double_t beta = the2*TMath::RadToDeg();
1443     Double_t klay4 = 0.007; //Glue
1444     Double_t klay5 = 0.01; //Flexcable
1445     Int_t  loop = (Int_t)((kStaveLength/(2*l))/2);
1446     Double_t hh = 0.01;
1447        Double_t ang1 = 0*TMath::DegToRad();
1448        Double_t ang2 = 0*TMath::DegToRad();
1449        Double_t ang3 = 0*TMath::DegToRad();
1450        Int_t modules = 4;
1451        Double_t headWidth=0.25;
1452        Double_t smcLength=kStaveLength/modules-2*headWidth;//6.25;
1453        Double_t smcWidth=kStaveWidth;
1454        Double_t smcSide1Thick=0.03;
1455        Double_t vaporThick=0.032;
1456        Double_t liquidThick=0.028;
1457        Double_t smcSide2Thick=0.01;
1458        Double_t smcSide3Thick=0.0055;
1459        Double_t smcSide4Thick=0.0095;
1460        Double_t smcSide5Thick=0.0075;
1461        Double_t smcSpace=0.01;
1462
1463
1464     char volname[30];
1465     snprintf(volname, 30, "%s%d_StaveStruct", AliITSUGeomTGeo::GetITSLadderPattern(), fLayerNumber);
1466     
1467     // detailed structure ++++++++++++++
1468     Double_t z=0, y=0-0.007, x=0;
1469
1470     // Polimide micro channels numbers
1471     Double_t yMC = y-h+0.01;
1472     Int_t nb = (Int_t)(kStaveWidth/0.1)+1;
1473     Double_t xladMC = (nb*0.1-0.08)/2;
1474
1475
1476     TGeoVolume *mechLaddVol = 0;
1477     if (fBuildLevel < 5) {
1478       // world (trapezoid)
1479       TGeoXtru *mechStruct = new TGeoXtru(2); //z sections
1480       Double_t xv[5] = {kStaveWidth/2+0.1,kStaveWidth/2+0.1,0,-kStaveWidth/2-0.1,-kStaveWidth/2-0.1};
1481       Double_t yv[5] = {-kConeOutRadius*2-0.07,0,staveHeight,0,-kConeOutRadius*2-0.07};    
1482       mechStruct->DefinePolygon(5,xv,yv);
1483       mechStruct->DefineSection(0,-kStaveLength-0.1,0,0,1.);
1484       mechStruct->DefineSection(1,kStaveLength+0.1,0,0,1.);
1485       mechLaddVol = new TGeoVolume(volname, mechStruct, medAir);
1486       mechLaddVol->SetLineColor(12);
1487       mechLaddVol->SetFillColor(12); 
1488       mechLaddVol->SetVisibility(kTRUE);
1489
1490        // Silicon micro channels numbers
1491       
1492       TGeoBBox *tM0a=new TGeoBBox(smcWidth/2, 0.003/2, headWidth/2);
1493       TGeoVolume *volTM0a=new TGeoVolume("microChanTop1", tM0a, medKapton);
1494       volTM0a->SetLineColor(35);
1495       volTM0a->SetFillColor(35); 
1496
1497       for(Int_t  mo=1; mo<=modules; mo++) {
1498       mechLaddVol->AddNode(volTM0a, 0, new TGeoCombiTrans(x,yMC+0.03, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth+smcLength/2+(headWidth/2), new TGeoRotation("",ang1, ang2, ang3)));
1499       mechLaddVol->AddNode(volTM0a, 1, new TGeoCombiTrans(x,yMC+0.03, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth-smcLength/2-(headWidth/2), new TGeoRotation("",ang1, ang2, ang3)));
1500       }
1501       TGeoBBox *tM0c=new TGeoBBox(0.3/2, 0.003/2,smcLength/2);
1502       TGeoVolume *volTM0c=new TGeoVolume("microChanTop2", tM0c, medKapton);
1503       volTM0c->SetLineColor(35);
1504       volTM0c->SetFillColor(35); 
1505       for(Int_t  mo=1; mo<=modules; mo++) {
1506       mechLaddVol->AddNode(volTM0c, 0, new TGeoCombiTrans(x+(smcWidth/2)-(0.3/2),yMC+0.03, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));
1507       mechLaddVol->AddNode(volTM0c, 1, new TGeoCombiTrans(x-(smcWidth/2)+(0.3/2),yMC+0.03, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1508       }
1509       TGeoBBox *tM0c1=new TGeoBBox(0.2225/2, 0.003/2,smcLength/2);
1510       TGeoVolume *volTM0c1=new TGeoVolume("microChanBot1", tM0c1, medKapton);
1511       volTM0c1->SetLineColor(6);
1512       volTM0c1->SetFillColor(6); 
1513       for(Int_t  mo=1; mo<=modules; mo++) {
1514       mechLaddVol->AddNode(volTM0c1, 0, new TGeoCombiTrans(x+smcWidth/2-(smcSide1Thick)-(vaporThick)-(smcSide2Thick)-(smcSide3Thick)-(0.2225/2),yMC+0.03-hh-(0.003), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1515       mechLaddVol->AddNode(volTM0c1, 1, new TGeoCombiTrans(x-smcWidth/2+(smcSide1Thick)+(liquidThick)+(smcSide2Thick)+(smcSide4Thick)+(0.2225/2),yMC+0.03-hh-(0.003), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1516       }
1517       TGeoBBox *tM0c2=new TGeoBBox(0.072/2, 0.003/2,smcLength/2);
1518       TGeoVolume *volTM0c2=new TGeoVolume("microChanBot2", tM0c2, medKapton);
1519       volTM0c2->SetLineColor(35);
1520       volTM0c2->SetFillColor(35); 
1521       for(Int_t  mo=1; mo<=modules; mo++) {
1522       mechLaddVol->AddNode(volTM0c2, 0, new TGeoCombiTrans(x+smcWidth/2-(0.072/2),yMC+0.03-(0.035+0.0015)-(0.003)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1523       }
1524       TGeoBBox *tM0c2r=new TGeoBBox(0.068/2, 0.003/2,smcLength/2);
1525       TGeoVolume *volTM0c2r=new TGeoVolume("microChanBot3", tM0c2r, medKapton);
1526       volTM0c2r->SetLineColor(35);
1527       volTM0c2r->SetFillColor(35); 
1528       for(Int_t  mo=1; mo<=modules; mo++) {      
1529       mechLaddVol->AddNode(volTM0c2r, 0, new TGeoCombiTrans(x-smcWidth/2+(0.068/2),yMC+0.03-(0.035+0.0015)-(0.003)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1530       }
1531       TGeoBBox *tM0d=new TGeoBBox(smcSide1Thick/2, 0.035/2,smcLength/2);
1532       TGeoVolume *volTM0d=new TGeoVolume("microChanSide1", tM0d, medKapton);
1533       volTM0d->SetLineColor(12);
1534       volTM0d->SetFillColor(12); 
1535       for(Int_t  mo=1; mo<=modules; mo++) {
1536       mechLaddVol->AddNode(volTM0d, 0, new TGeoCombiTrans(x+smcWidth/2-(smcSide1Thick/2),yMC+0.03-0.0015-(0.035)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1537       mechLaddVol->AddNode(volTM0d, 1, new TGeoCombiTrans(x-smcWidth/2+(smcSide1Thick/2),yMC+0.03-0.0015-(0.035)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1538       }
1539
1540       TGeoBBox *tM0d1=new TGeoBBox(smcSide2Thick/2, 0.035/2,smcLength/2);
1541       TGeoVolume *volTM0d1=new TGeoVolume("microChanSide2", tM0d1, medKapton);
1542       volTM0d1->SetLineColor(12);
1543       volTM0d1->SetFillColor(12); 
1544       for(Int_t  mo=1; mo<=modules; mo++) {
1545       mechLaddVol->AddNode(volTM0d1, 0, new TGeoCombiTrans(x+smcWidth/2-(smcSide1Thick)-(vaporThick)-(smcSide2Thick/2),yMC+0.03-(0.003+0.035)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1546       mechLaddVol->AddNode(volTM0d1, 1, new TGeoCombiTrans(x-smcWidth/2+(smcSide1Thick)+(liquidThick)+(smcSide2Thick/2),yMC+0.03-(0.003+0.035)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1547       }
1548       TGeoBBox *tM0d2=new TGeoBBox(smcSide3Thick/2, (hh+0.003)/2, smcLength/2);
1549       TGeoVolume *volTM0d2=new TGeoVolume("microChanSide3", tM0d2, medKapton);
1550       volTM0d2->SetLineColor(12);
1551       volTM0d2->SetFillColor(12); 
1552       for(Int_t  mo=1; mo<=modules; mo++) {
1553       mechLaddVol->AddNode(volTM0d2, 0, new TGeoCombiTrans(x+smcWidth/2-(smcSide1Thick)-(vaporThick)-(smcSide2Thick)-(smcSide3Thick/2),yMC+0.03-(0.003+hh+0.003)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1554       }
1555       TGeoBBox *tM0d2r=new TGeoBBox(smcSide4Thick/2, (hh+0.003)/2, smcLength/2);
1556       TGeoVolume *volTM0d2r=new TGeoVolume("microChanSide4", tM0d2r, medKapton);
1557       volTM0d2r->SetLineColor(12);
1558       volTM0d2r->SetFillColor(12); 
1559       for(Int_t  mo=1; mo<=modules; mo++) {
1560       mechLaddVol->AddNode(volTM0d2r, 0, new TGeoCombiTrans(x-smcWidth/2+(smcSide1Thick)+(liquidThick)+(smcSide2Thick)+(smcSide4Thick/2),yMC+0.03-(0.003+hh+0.003)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1561       }
1562       TGeoBBox *tM0e=new TGeoBBox(smcSide5Thick/2, hh/2,smcLength/2);
1563       TGeoVolume *volTM0e=new TGeoVolume("microChanSide5", tM0e, medKapton);    
1564       volTM0e->SetLineColor(12);
1565       volTM0e->SetFillColor(12); 
1566       for(Int_t  mo=1; mo<=modules; mo++) {
1567       for (Int_t ie=0;ie<11;ie++) {
1568         mechLaddVol->AddNode(volTM0e, 0, new TGeoCombiTrans(x-(ie*(smcSpace+smcSide5Thick))+smcWidth/2-(smcSide1Thick)-(vaporThick)-(smcSide2Thick)-(smcSide3Thick)-smcSpace-(smcSide5Thick/2),yMC+0.03-(0.003+hh)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1569         mechLaddVol->AddNode(volTM0e, 1, new TGeoCombiTrans(x+(ie*(smcSpace+smcSide5Thick))-smcWidth/2+(smcSide1Thick)+(liquidThick)+(smcSide2Thick)+(smcSide4Thick)+smcSpace+(smcSide5Thick/2),yMC+0.03-(0.003+hh)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1570          }
1571       }
1572       
1573       TGeoBBox *tM0f=new TGeoBBox(0.02/2, hh/2, smcLength/2);
1574       TGeoVolume *volTM0f=new TGeoVolume("microChanTop3", tM0f, medKapton);
1575       //Double_t smcChannels=12;
1576       Double_t smcCloseWallvapor=smcWidth/2-smcSide1Thick-vaporThick-smcSide2Thick-smcSide3Thick-12*smcSpace-11*smcSide5Thick;
1577       Double_t smcCloseWallliquid=smcWidth/2-smcSide1Thick-liquidThick-smcSide2Thick-smcSide4Thick-12*smcSpace-11*smcSide5Thick;
1578       volTM0f->SetLineColor(12);
1579       volTM0f->SetFillColor(12); 
1580       for(Int_t  mo=1; mo<=modules; mo++) {
1581        mechLaddVol->AddNode(volTM0f, 0, new TGeoCombiTrans(x+smcCloseWallvapor-(0.02)/2,yMC+0.03-(0.003+hh)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1582        mechLaddVol->AddNode(volTM0f, 1, new TGeoCombiTrans(x-smcCloseWallliquid+(0.02)/2,yMC+0.03-(0.003+hh)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1583       }
1584       //Head(back) microchannel
1585
1586       TGeoBBox *tM0hb=new TGeoBBox(smcWidth/2, 0.025/2, headWidth/2);
1587       TGeoVolume *volTM0hb=new TGeoVolume("microChanHeadBackBottom1", tM0hb, medKapton);
1588       volTM0hb->SetLineColor(4);
1589       volTM0hb->SetFillColor(4); 
1590       for(Int_t  mo=1; mo<=modules; mo++) {
1591       mechLaddVol->AddNode(volTM0hb, 0, new TGeoCombiTrans(x,yMC+0.03-0.0145-(0.025/2), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth+smcLength/2+(headWidth/2), new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1592       mechLaddVol->AddNode(volTM0hb, 1, new TGeoCombiTrans(x,yMC+0.03-0.0145-(0.025)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth-smcLength/2-(headWidth/2), new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1593       }
1594       TGeoBBox *tM0h1=new TGeoBBox(smcWidth/2, 0.013/2, 0.05/2);
1595       TGeoVolume *volTM0h1=new TGeoVolume("microChanHeadBackBottom2", tM0h1, medKapton);
1596       volTM0h1->SetLineColor(5);
1597       volTM0h1->SetFillColor(5); 
1598       for(Int_t  mo=1; mo<=modules; mo++) {
1599       mechLaddVol->AddNode(volTM0h1, 0, new TGeoCombiTrans(x,yMC+0.03-0.0015-(0.013/2), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth-smcLength/2-headWidth+(0.05/2), new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1600       }
1601       TGeoBBox *tM0h2=new TGeoBBox(smcWidth/2, 0.003/2, 0.18/2);
1602       TGeoVolume *volTM0h2=new TGeoVolume("microChanHeadBackBottom7", tM0h2, medKapton);
1603       volTM0h2->SetLineColor(6);
1604       volTM0h2->SetFillColor(6);
1605       for(Int_t  mo=1; mo<=modules; mo++) {
1606       mechLaddVol->AddNode(volTM0h2, 0, new TGeoCombiTrans(x,yMC+0.03-0.0015-0.01-(0.003/2), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth-smcLength/2-0.02-(0.18/2), new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1607       }
1608       TGeoBBox *tM0h3=new TGeoBBox(smcWidth/2, 0.013/2, 0.02/2);
1609       TGeoVolume *volTM0h3=new TGeoVolume("microChanHeadBackBottom3", tM0h3, medKapton);
1610       volTM0h3->SetLineColor(5);
1611       volTM0h3->SetFillColor(5); 
1612       for(Int_t  mo=1; mo<=modules; mo++) {
1613       mechLaddVol->AddNode(volTM0h3, 0, new TGeoCombiTrans(x,yMC+0.03-0.0015-(0.013/2), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth-smcLength/2-(0.02/2), new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1614       }
1615       TGeoBBox *tM0b1=new TGeoBBox(smcWidth/2, 0.013/2, 0.03/2);
1616       TGeoVolume *volTM0b1=new TGeoVolume("microChanHeadBackBottom4", tM0b1, medKapton);
1617       volTM0b1->SetLineColor(5);
1618       volTM0b1->SetFillColor(5); 
1619       for(Int_t  mo=1; mo<=modules; mo++) {
1620       mechLaddVol->AddNode(volTM0b1, 0, new TGeoCombiTrans(x,yMC+0.03-0.0015-(0.013/2), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth+smcLength/2+headWidth-(0.03/2), new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1621       }
1622       TGeoBBox *tM0b2=new TGeoBBox(smcWidth/2, 0.003/2, 0.2/2);
1623       TGeoVolume *volTM0b2=new TGeoVolume("microChanHeadBackBottom5", tM0b2, medKapton);
1624       volTM0b2->SetLineColor(6);
1625       volTM0b2->SetFillColor(6); 
1626       for(Int_t  mo=1; mo<=modules; mo++) {
1627       mechLaddVol->AddNode(volTM0b2, 0, new TGeoCombiTrans(x,yMC+0.03-0.0015-0.01-(0.003/2), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth+smcLength/2+0.02+(0.2/2), new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1628       }
1629       TGeoBBox *tM0b3=new TGeoBBox(smcWidth/2, 0.013/2, 0.02/2);
1630       TGeoVolume *volTM0b3=new TGeoVolume("microChanHeadBackBottom6", tM0b3, medKapton);
1631       volTM0b3->SetLineColor(5);
1632       volTM0b3->SetFillColor(5); 
1633       for(Int_t  mo=1; mo<=modules; mo++) {
1634       mechLaddVol->AddNode(volTM0b3, 0, new TGeoCombiTrans(x,yMC+0.03-0.0015-(0.013/2), z+(mo-3)*kStaveLength/4+smcLength/2+headWidth+smcLength/2+(0.02/2), new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1635       }
1636      
1637       TGeoBBox *tM0b=new TGeoBBox(0.02/2, 0.02/2, zlad);
1638       TGeoVolume *volTM0b=new TGeoVolume("microChanWalls", tM0b, medKapton);
1639       volTM0b->SetLineColor(35);
1640       volTM0b->SetFillColor(35); 
1641       for (Int_t ib=0;ib<nb;ib++) {
1642         //mechLaddVol->AddNode(volTM0b, ib, new TGeoCombiTrans(x+ib*0.1-xladMC+0.01,yMC, z, new TGeoRotation("",0, 0, 0)));
1643       }
1644       
1645       } 
1646     
1647     if (fBuildLevel < 4) {
1648
1649       //**********cooling  inlet outlet
1650
1651       TGeoBBox *tM0dv=new TGeoBBox(vaporThick/2, 0.035/2,smcLength/2);
1652       TGeoVolume *volTM0dv=new TGeoVolume("microChanVapor", tM0dv, medWater);
1653       volTM0dv->SetLineColor(2);
1654       volTM0dv->SetFillColor(2);
1655       for(Int_t  mo=1; mo<=modules; mo++) {
1656       mechLaddVol->AddNode(volTM0dv, 0, new TGeoCombiTrans(x+smcWidth/2-(smcSide1Thick)-(vaporThick/2),yMC+0.03-0.0015-(0.035)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1657       }
1658       TGeoBBox *tM0dl=new TGeoBBox(liquidThick/2, 0.035/2,smcLength/2);
1659       TGeoVolume *volTM0dl=new TGeoVolume("microChanLiquid", tM0dl, medWater);
1660       volTM0dl->SetLineColor(3);
1661       volTM0dl->SetFillColor(3); 
1662       for(Int_t  mo=1; mo<=modules; mo++) {
1663       mechLaddVol->AddNode(volTM0dl, 0, new TGeoCombiTrans(x-smcWidth/2+(smcSide1Thick)+(liquidThick/2),yMC+0.03-0.0015-(0.035)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1664       }
1665       // small cooling fluid now using water wait for freeon value  
1666       TGeoBBox *tM0dlq=new TGeoBBox(smcSpace/2, hh/2,smcLength/2);
1667       TGeoVolume *volTM0dlq=new TGeoVolume("smallLiquid", tM0dlq, medWater);
1668       volTM0dlq->SetLineColor(3);
1669       volTM0dlq->SetFillColor(3); 
1670       TGeoBBox *tM0dvp=new TGeoBBox(smcSpace/2, hh/2,smcLength/2);
1671       TGeoVolume *volTM0dvp=new TGeoVolume("microChanVapor", tM0dvp, medWater);
1672       volTM0dvp->SetLineColor(2);
1673       volTM0dvp->SetFillColor(2); 
1674       for(Int_t  mo=1; mo<=modules; mo++) {
1675       for (Int_t is=0;is<12;is++) {
1676         mechLaddVol->AddNode(volTM0dlq, 0, new TGeoCombiTrans(x+(is*(smcSpace+smcSide5Thick))-smcWidth/2+(smcSide1Thick)+(vaporThick)+(smcSide2Thick)+(smcSide3Thick)+smcSpace/2,yMC+0.03-(0.003+hh)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1677         mechLaddVol->AddNode(volTM0dvp, 1, new TGeoCombiTrans(x-(is*(smcSpace+smcSide5Thick))+smcWidth/2-(smcSide1Thick)-(vaporThick)-(smcSide2Thick)-(smcSide3Thick)-smcSpace/2,yMC+0.03-(0.003+hh)/2, z+(mo-3)*kStaveLength/4+smcLength/2+headWidth, new TGeoRotation("",ang1, ang2, ang3)));//("",0, 0, 0)));
1678       }
1679       }
1680
1681       //*************
1682
1683     }
1684     
1685     if (fBuildLevel < 3) {
1686
1687       //Bottom filament CFRP black-12 Carbon structure TGeoBBox (thickness,width,length)
1688  
1689       Double_t filWidth = 0.04;
1690       Double_t filHeight= 0.02;
1691       TGeoBBox *t1=new TGeoBBox(filHeight/2,filWidth/2,s1);
1692       TGeoVolume *volT1=new TGeoVolume("bottomFilament", t1, medM60J3K);
1693       volT1->SetLineColor(12);
1694       volT1->SetFillColor(12); 
1695       for(int i=0;i<loop;i++){//i<30;i++){
1696         mechLaddVol->AddNode(volT1,4*i+0,
1697                                     new TGeoCombiTrans(x+w,y-h+0.04+filHeight/2,z-kStaveLength/2+(4*l*i)+s1/2, 
1698                                                        new TGeoRotation("volT1",-90,alpha,0)));
1699         mechLaddVol->AddNode(volT1,4*i+1,
1700                                     new TGeoCombiTrans(x-w,y-h+0.04+filHeight/2,z-kStaveLength/2+(4*l*i)+s1/2, 
1701                                                        new TGeoRotation("volT1",90,alpha,0)));
1702         mechLaddVol->AddNode(volT1,4*i+2,
1703                                     new TGeoCombiTrans(x+w,y-h+0.04+filHeight/2,z-kStaveLength/2+2*l+(i*4*l)+s1/2, 
1704                                                        new TGeoRotation("volT1",-90,-alpha,0)));
1705         mechLaddVol->AddNode(volT1,4*i+3,
1706                                     new TGeoCombiTrans(x-w,y-h+0.04+filHeight/2,z-kStaveLength/2+2*l+(i*4*l)+s1/2, 
1707                                                        new TGeoRotation("volT1",-90,+alpha,0)));
1708         }
1709  
1710      // Top filament CERP black-12 Carbon structure TGeoBBox (length,thickness,width)
1711
1712       TGeoBBox *t2=new TGeoBBox(s2,filHeight/2,filWidth/2);
1713       TGeoVolume *volT2=new TGeoVolume("topFilament", t2, medM60J3K);
1714       volT2->SetLineColor(12);
1715       volT2->SetFillColor(12); 
1716       for(int i=0;i<loop;i++){ //i<30;i++){
1717         mechLaddVol->AddNode(volT2,4*i+0,
1718                                     new TGeoCombiTrans(x+w,y+0.04+filHeight/2,z-kStaveLength/2+(i*4*l)+s1/2,
1719                                                        new TGeoRotation("volT2",90,90-alpha,90-beta)));
1720         mechLaddVol->AddNode(volT2,4*i+1,
1721                                     new TGeoCombiTrans(x-w,y+0.04+filHeight/2,z-kStaveLength/2+(i*4*l)+s1/2,
1722                                                        new TGeoRotation("volT2",90,-90+alpha,-90+beta)));
1723         mechLaddVol->AddNode(volT2,4*i+2,
1724                                     new TGeoCombiTrans(x+w,y+0.04+filHeight/2,z-kStaveLength/2+2*l+(i*4*l)+s1/2,
1725                                                        new TGeoRotation("volT2",90,-90+alpha,90-beta)));
1726         mechLaddVol->AddNode(volT2,4*i+3,
1727                                     new TGeoCombiTrans(x-w,y+0.04+filHeight/2,z-kStaveLength/2+2*l+(i*4*l)+s1/2, 
1728                                                        new TGeoRotation("volT2",90,90-alpha,-90+beta)));
1729         }
1730     }
1731
1732     if (fBuildLevel < 2) {
1733
1734       // Glue Filament and Silicon MicroChannel
1735       TGeoBBox *tM0=new TGeoBBox(xladMC/5, klay4/2, zlad);
1736       TGeoVolume *volTM0=new TGeoVolume("glueFM", tM0,medGlue );
1737       volTM0->SetLineColor(5);
1738       volTM0->SetFillColor(5); 
1739       mechLaddVol->AddNode(volTM0, 0, new TGeoCombiTrans(x-xlad/2-0.25,0.03+yMC, z, new TGeoRotation("",0, 0, 0)));
1740       mechLaddVol->AddNode(volTM0, 1, new TGeoCombiTrans(x+xlad/2+0.25,0.03+yMC, z, new TGeoRotation("",0, 0, 0)));
1741
1742             
1743       // Glue microchannel and sensor
1744       TGeoBBox *glueM = new TGeoBBox(xladMC/5, klay4/2, zlad);
1745       TGeoVolume *volGlueM=new TGeoVolume("glueMS", glueM, medGlue);
1746       volGlueM->SetLineColor(5);
1747       volGlueM->SetFillColor(5); 
1748       mechLaddVol->AddNode(volGlueM, 0, new TGeoCombiTrans(x-xlad/2-0.25,yMC-0.01, z, new TGeoRotation("",0, 0, 0)));
1749       mechLaddVol->AddNode(volGlueM, 1, new TGeoCombiTrans(x+xlad/2+0.25,yMC-0.01, z, new TGeoRotation("",0, 0, 0)));
1750      
1751        // Glue sensor and kapton
1752       TGeoBBox *glue = new TGeoBBox(xlad, klay4/2, zlad);
1753       TGeoVolume *volGlue=new TGeoVolume("glueSensorBus", glue, medGlue);
1754       volGlue->SetLineColor(5);
1755       volGlue->SetFillColor(5); 
1756        mechLaddVol->AddNode(volGlue, 1, new TGeoCombiTrans(x, y-0.154-fSensorThick-klay4/2, z, new TGeoRotation("",0, 0, 0)));
1757     }      
1758
1759     if (fBuildLevel < 1) {
1760       TGeoBBox *kapCable = new TGeoBBox(xlad, klay5/2, zlad);
1761       TGeoVolume *volCable=new TGeoVolume("Flexcable", kapCable, medFlexCable);
1762       volCable->SetLineColor(28);
1763       volCable->SetFillColor(28); 
1764       mechLaddVol->AddNode(volCable, 0, new TGeoCombiTrans(x, y-0.154-fSensorThick-klay4-klay5/2, z, new TGeoRotation("",0, 0, 0)));
1765     }
1766
1767   // Done, return the stave structur
1768     return mechLaddVol;
1769  }
1770
1771 //________________________________________________________________________
1772 TGeoVolume* AliITSUv1Layer::CreateStaveOuterB(const Double_t xlad,
1773                                               const TGeoManager *mgr){
1774 //
1775 // Create the module stave for the Outer Barrel
1776 //
1777 // Input:
1778 //         xlad : X length
1779 //         mgr  : the GeoManager (used only to get the proper material)
1780 //
1781 // Output:
1782 //
1783 // Return:
1784 //
1785 // Created:      20 Dec 2013  Mario Sitta
1786 //
1787
1788   TGeoVolume *mechLaddVol = 0;
1789
1790   switch (fStaveModel) {
1791     case AliITSUv1::kOBModelDummy:
1792       mechLaddVol = CreateStaveModelOuterBDummy(xlad,mgr);
1793       break;
1794     case AliITSUv1::kOBModel0:
1795       mechLaddVol = CreateStaveModelOuterB0(xlad,mgr);
1796       break;
1797     case AliITSUv1::kOBModel1:
1798       mechLaddVol = CreateStaveModelOuterB1(xlad,mgr);
1799       break;
1800     default:
1801       AliFatal(Form("Unknown stave model %d",fStaveModel));
1802       break;
1803   }
1804
1805   return mechLaddVol; 
1806 }
1807
1808 //________________________________________________________________________
1809 TGeoVolume* AliITSUv1Layer::CreateStaveModelOuterBDummy(const Double_t ,
1810                                                         const TGeoManager *) const {
1811 //
1812 // Create dummy stave
1813 //
1814 // Input:
1815 //         xlad : X length
1816 //         mgr  : the GeoManager (used only to get the proper material)
1817 //
1818 // Output:
1819 //
1820 // Return:
1821 //
1822 // Created:      20 Dec 2013  Mario Sitta
1823 //
1824
1825
1826   // Done, return the stave structure
1827   return 0;
1828 }
1829
1830 //________________________________________________________________________
1831 TGeoVolume* AliITSUv1Layer::CreateStaveModelOuterB0(const Double_t ,
1832                                                     const TGeoManager *) const {
1833 //
1834 // Creation of the mechanical stave structure for the Outer Barrel as in v0
1835 // is done directly in CreateLadder, so this method does nothing
1836 // (doing it there is simpler, since all needed dimensions are known)
1837 //
1838 // Input:
1839 //         xlad : X length
1840 //         mgr  : the GeoManager (used only to get the proper material)
1841 //
1842 // Output:
1843 //
1844 // Return:
1845 //
1846 // Created:      20 Dec 2013  Mario Sitta
1847 //
1848
1849   // Done, return the stave structure
1850   return 0;
1851 }
1852
1853 //________________________________________________________________________
1854 TGeoVolume* AliITSUv1Layer::CreateStaveModelOuterB1(const Double_t xlad,
1855                                                     const TGeoManager *mgr){
1856 //
1857 // Create the mechanical stave structure for the Outer Barrel as in TDR
1858 //
1859 // Input:
1860 //         xlad : X length
1861 //         mgr  : the GeoManager (used only to get the proper material)
1862 //
1863 // Output:
1864 //
1865 // Return:
1866 //
1867 // Created:      20 Nov 2013  Anastasia Barbano
1868 // Updated:      16 Jan 2014  Mario Sitta
1869 //
1870
1871   // Materials defined in AliITSUv0
1872   TGeoMedium *medAluminum     = mgr->GetMedium("ITS_ALUMINUM$");
1873   TGeoMedium *medCarbon       = mgr->GetMedium("ITS_CARBON$");
1874   TGeoMedium *medKapton       = mgr->GetMedium("ITS_KAPTON(POLYCH2)$");
1875   TGeoMedium *medGlue         = mgr->GetMedium("ITS_GLUE$");
1876   TGeoMedium *medWater        = mgr->GetMedium("ITS_WATER$");
1877   TGeoMedium *medCarbonFleece = mgr->GetMedium("ITS_CarbonFleece$"); 
1878   TGeoMedium *medFGS003       = mgr->GetMedium("ITS_FGS003$"); //amec thermasol
1879   TGeoMedium *medAir          = mgr->GetMedium("ITS_AIR$");
1880
1881
1882   // Local parameters
1883   Double_t modGap             = fgkOBModuleGap;
1884   Double_t yFlex1             = fgkOBFlexCable1Thick;
1885   Double_t yFlex2             = fgkOBFlexCable2Thick;
1886   Double_t yBus1              = fgkOBBusCable1Thick;
1887   Double_t yBus2              = fgkOBBusCable2Thick;
1888   Double_t xModPlate          = fgkOBHalfStaveWidth;
1889   Double_t yModPlate          = fgkOBCarbonPlateThick;
1890   Double_t xCPlate            = fgkOBHalfStaveWidth;
1891   Double_t yCPlate            = fgkOBColdPlateThick;
1892   Double_t yGlue              = fgkOBGlueThick;
1893   Double_t flexOverlap        = 5;
1894   Double_t deltaY             = 0.176;
1895   Double_t xOverlap           = 0.23;       //overlapping of the halfStaves to cover the dead zone of sensors
1896   Double_t zMod               = fgkOBModuleZLength;
1897   Double_t xHalfSt            = fgkOBHalfStaveWidth/2;
1898   Double_t xPos               = xOverlap/2 - xHalfSt;
1899   Double_t xlen               = xlad;
1900   Double_t rMin               = 0.267/2;
1901   Double_t rMax               = rMin + 0.0065;
1902   Double_t kLay1              = 0.004;      //carbon fleece
1903   Double_t kLay2              = 0.003;      //carbon paper
1904   Double_t yPos               = kLay1+kLay2;
1905   Double_t ylen,zact;
1906   Double_t zpos, zpos5cm;
1907   Double_t ymod;
1908   Double_t zbus;
1909   Double_t zlen;
1910
1911
1912   if (fIsTurbo) xlen = 0.5*fLadderWidth;
1913   //ylen    = 0.5*fLadderThick;
1914   ymod    = 0.005/2;//0.5*fSensorThick;
1915   ylen    = 0.5*(2*kLay1+2*kLay2+2*rMax+yCPlate+yGlue+ yModPlate + ymod + 2*yFlex1 + 2*yFlex2 + yBus1 + yBus2 + deltaY);
1916   zact    = fNModules*zMod; //active area 
1917   zbus    = zact + (fNModules-1)*modGap; 
1918   zlen    = zbus/2;
1919
1920
1921   // First create all needed shapes
1922
1923   TGeoTube *coolTube   = new TGeoTube("CoolingTube",rMin,rMax,zbus/2);
1924   TGeoTube *coolTubeW  = new TGeoTube("CoolingTubeWater",0,rMin,zbus/2);
1925   TGeoBBox *coldPlate  = new TGeoBBox("ColdPlate",xCPlate/2,yCPlate/2,zbus/2);
1926   TGeoBBox *glue       = new TGeoBBox("Glue",xCPlate/2,yGlue/2,zbus/2);
1927   TGeoBBox *modPlate   = new TGeoBBox("CarbonPlate",xModPlate/2,yModPlate/2,zbus/2);
1928   TGeoBBox *flex1      = new TGeoBBox("Flex1MV",xHalfSt,yFlex1/2,zMod/2);
1929   TGeoBBox *flex2      = new TGeoBBox("Flex2MV",xHalfSt,yFlex2/2,zMod/2);
1930   TGeoBBox *flex1_5cm  = new TGeoBBox("Flex1MV_5cm",xHalfSt,yFlex1/2,flexOverlap/2);
1931   TGeoBBox *flex2_5cm  = new TGeoBBox("Flex2MV_5cm",xHalfSt,yFlex2/2,flexOverlap/2);
1932   TGeoBBox *bus1       = new TGeoBBox("Bus1HV",xHalfSt,yBus1/2,zbus/2);
1933   TGeoBBox *bus2       = new TGeoBBox("Bus2HV",xHalfSt,yBus2/2,zbus/2); 
1934   TGeoTubeSeg *cone1   = new TGeoTubeSeg(rMax +kLay2,rMax+kLay1+kLay2,zlen,180.,360.);  //Carbon Fleece 
1935   TGeoTubeSeg *cone2   = new TGeoTubeSeg(rMax ,rMax+kLay2,zlen,180.,360.);  //Graphite paper 
1936   TGeoBBox *box11      = new TGeoBBox((0.95-kLay2-rMax)/2,kLay1/2,zlen);
1937   TGeoBBox *box12      = new TGeoBBox((1.11-2*kLay2-2*rMax)/2,kLay1/2,zlen);
1938   TGeoBBox *box13      = new TGeoBBox(kLay1/2,(rMax-(kLay1+kLay2))/2,zlen);
1939   TGeoBBox *box21      = new TGeoBBox((0.95-rMax)/2,kLay2/2,zlen);
1940   TGeoBBox *box22      = new TGeoBBox((1.11-2*rMax)/2,kLay2/2,zlen);
1941   TGeoBBox *box23      = new TGeoBBox(kLay2/2,(rMax-kLay2)/2,zlen);
1942   TGeoBBox *mechStruct = new TGeoBBox("mechanicalStructure",xlen, ylen, 0.5*fZLength); 
1943
1944
1945   TGeoVolume *modVol       = CreateModuleOuterB(xHalfSt, ymod, zMod);
1946  
1947   TGeoVolume *coolTubeVol  = new TGeoVolume("CoolingTubeVol",coolTube,medKapton);
1948   TGeoVolume *coolTubeWVol = new TGeoVolume("CoolingTubeWaterVol",coolTubeW,medWater);
1949   TGeoVolume *coldPlateVol = new TGeoVolume("ColdPlateVol",coldPlate,medCarbon);
1950   TGeoVolume *glueVol      = new TGeoVolume("GlueVol",glue,medGlue);
1951   TGeoVolume *modPlateVol  = new TGeoVolume("CarbonPlateVol",modPlate,medCarbon);
1952   TGeoVolume *flex1Vol     = new TGeoVolume("Flex1Vol",flex1,medAluminum);
1953   TGeoVolume *flex2Vol     = new TGeoVolume("Flex2Vol",flex2,medKapton);
1954   TGeoVolume *flex1_5cmVol = new TGeoVolume("Flex1Vol5cm",flex1_5cm,medAluminum);
1955   TGeoVolume *flex2_5cmVol = new TGeoVolume("Flex2Vol5cm",flex2_5cm,medKapton);
1956   TGeoVolume *bus1Vol      = new TGeoVolume("Bus1Vol",bus1,medAluminum);
1957   TGeoVolume *bus2Vol      = new TGeoVolume("Bus2Vol",bus2,medKapton);
1958   TGeoVolume *cone1Vol     = new TGeoVolume("CarbonFleecePipeCover",cone1,medCarbonFleece);
1959   TGeoVolume *cone2Vol     = new TGeoVolume("GraphitePaperPipeCover",cone2,medFGS003);
1960   TGeoVolume *plate11Vol   = new TGeoVolume("CarbonFleeceLR1",box11,medCarbonFleece);
1961   TGeoVolume *plate12Vol   = new TGeoVolume("CarbonFleeceMiddle1",box12,medCarbonFleece); 
1962   TGeoVolume *plate13Vol   = new TGeoVolume("CarbonFleeceVertical1",box13,medCarbonFleece); 
1963   TGeoVolume *plate21Vol   = new TGeoVolume("CarbonFleeceLR2",box21,medFGS003);
1964   TGeoVolume *plate22Vol   = new TGeoVolume("CarbonFleeceMiddle2",box22,medFGS003);
1965   TGeoVolume *plate23Vol   = new TGeoVolume("CarbonFleeceVertical2",box23,medFGS003);
1966   TGeoVolume *mechLaddVol  = new TGeoVolume("mechLadderVolume",mechStruct,medAir);
1967
1968   mechLaddVol->SetLineColor(12);
1969   mechLaddVol->SetFillColor(12); 
1970   mechLaddVol->SetVisibility(kTRUE);
1971
1972   modVol->SetVisibility(kTRUE);
1973   flex1_5cmVol->SetLineColor(kRed);
1974   flex2_5cmVol->SetLineColor(kGreen);
1975   modPlateVol->SetLineColor(kMagenta-8);
1976   coolTubeVol->SetLineColor(kGray);
1977   coolTubeWVol->SetLineColor(kBlue);
1978   coldPlateVol->SetLineColor(kYellow-3);
1979   glueVol->SetLineColor(kBlack);
1980   flex1Vol->SetLineColor(kRed);
1981   flex2Vol->SetLineColor(kGreen);
1982   bus1Vol->SetLineColor(kCyan);
1983   bus2Vol->SetLineColor(kBlue);
1984   cone1Vol->SetFillColor(kViolet);
1985   plate11Vol->SetFillColor(kViolet);
1986   plate12Vol->SetLineColor(kViolet);
1987   plate13Vol->SetLineColor(kViolet);
1988   cone2Vol->SetLineColor(kGreen);
1989   plate22Vol->SetFillColor(kGreen);
1990   plate21Vol->SetLineColor(kGreen);
1991   plate23Vol->SetLineColor(kGreen);
1992
1993
1994   //Carbon Fleece
1995
1996   mechLaddVol->AddNode(plate11Vol,1,new TGeoTranslation(xPos -(1.11/2+rMax+box11->GetDX()+kLay2),-ylen + yPos +2*rMax-kLay2-kLay1/2,0));
1997   mechLaddVol->AddNode(plate11Vol,2,new TGeoTranslation(xPos +(1.11/2+rMax+box11->GetDX()+kLay2),-ylen + yPos +2*rMax-kLay2-kLay1/2,0));
1998   mechLaddVol->AddNode(plate11Vol,3,new TGeoTranslation(-xPos -(1.11/2+rMax+box11->GetDX()+kLay2),-ylen + yPos +2*rMax-kLay2-kLay1/2 +deltaY,0));
1999   mechLaddVol->AddNode(plate11Vol,4,new TGeoTranslation(-xPos +(1.11/2+rMax+box11->GetDX()+kLay2),-ylen + yPos +2*rMax-kLay2-kLay1/2 +deltaY,0));
2000   mechLaddVol->AddNode(plate12Vol,1,new TGeoTranslation(xPos ,-ylen + yPos +2*rMax-kLay2-kLay1/2,0));
2001   mechLaddVol->AddNode(plate12Vol,2,new TGeoTranslation(-xPos ,-ylen + yPos +2*rMax-kLay2-kLay1/2 + deltaY,0));
2002   mechLaddVol->AddNode(plate13Vol,1,new TGeoTranslation(xPos -(1.11/2+rMax+kLay2+box13->GetDX()),-ylen + yPos +2*rMax-kLay1-kLay2-box13->GetDY(),0));
2003   mechLaddVol->AddNode(plate13Vol,2,new TGeoTranslation(xPos -1.11/2+rMax+kLay2+box13->GetDX(),-ylen + yPos +2*rMax-kLay1-kLay2-box13->GetDY(),0));
2004   mechLaddVol->AddNode(plate13Vol,3,new TGeoTranslation(xPos +(1.11/2+rMax+kLay2+box13->GetDX()),-ylen + yPos +2*rMax-kLay1-kLay2-box13->GetDY(),0));
2005   mechLaddVol->AddNode(plate13Vol,4,new TGeoTranslation(xPos +1.11/2-rMax-kLay2-box13->GetDX(),-ylen + yPos +2*rMax-kLay1-kLay2-box13->GetDY(),0));
2006   mechLaddVol->AddNode(plate13Vol,5,new TGeoTranslation(-xPos -(1.11/2+rMax+kLay2+box13->GetDX()),-ylen + yPos +2*rMax-kLay1-kLay2-box13->GetDY() +deltaY,0));
2007   mechLaddVol->AddNode(plate13Vol,6,new TGeoTranslation(-xPos -1.11/2+rMax+kLay2+box13->GetDX(),-ylen + yPos +2*rMax-kLay1-kLay2-box13->GetDY() +deltaY,0));
2008   mechLaddVol->AddNode(plate13Vol,7,new TGeoTranslation(-xPos +(1.11/2+rMax+kLay2+box13->GetDX()),-ylen + yPos +2*rMax-kLay1-kLay2-box13->GetDY() +deltaY,0));
2009   mechLaddVol->AddNode(plate13Vol,8,new TGeoTranslation(-xPos +1.11/2-rMax-kLay2-box13->GetDX(),-ylen + yPos +2*rMax-kLay1-kLay2-box13->GetDY() +deltaY,0));
2010
2011   mechLaddVol->AddNode(cone1Vol,1,new TGeoTranslation(xPos - 0.555,-ylen + yPos + rMax,0));
2012   mechLaddVol->AddNode(cone1Vol,2,new TGeoTranslation(xPos + 0.555,-ylen + yPos + rMax,0));
2013   mechLaddVol->AddNode(cone1Vol,3,new TGeoTranslation(-xPos - 0.555,-ylen + yPos + rMax + deltaY,0));
2014   mechLaddVol->AddNode(cone1Vol,4,new TGeoTranslation(-xPos + 0.555,-ylen + yPos + rMax + deltaY,0));
2015
2016
2017   //Carbon Paper
2018
2019   mechLaddVol->AddNode(plate21Vol,1,new TGeoTranslation(xPos -(1.11/2+rMax+box21->GetDX()),-ylen + yPos +2*rMax-kLay2/2,0));
2020   mechLaddVol->AddNode(plate21Vol,2,new TGeoTranslation(xPos +(1.11/2+rMax+box21->GetDX()) ,-ylen + yPos +2*rMax-kLay2/2,0));
2021   mechLaddVol->AddNode(plate21Vol,3,new TGeoTranslation(-xPos -(1.11/2+rMax+box21->GetDX()) ,-ylen + yPos +2*rMax-kLay2/2 +deltaY,0));
2022   mechLaddVol->AddNode(plate21Vol,4,new TGeoTranslation(-xPos +(1.11/2+rMax+box21->GetDX()) ,-ylen + yPos +2*rMax-kLay2/2 +deltaY,0));
2023   mechLaddVol->AddNode(plate22Vol,1,new TGeoTranslation(xPos ,-ylen + yPos +2*rMax-kLay2/2,0));
2024   mechLaddVol->AddNode(plate22Vol,2,new TGeoTranslation(-xPos ,-ylen + yPos +2*rMax-kLay2/2 + deltaY,0));
2025   mechLaddVol->AddNode(plate23Vol,1,new TGeoTranslation(xPos -(1.11/2+rMax+box23->GetDX()),-ylen + yPos +2*rMax-kLay2-(rMax-kLay2)/2,0));
2026   mechLaddVol->AddNode(plate23Vol,2,new TGeoTranslation(xPos -1.11/2+rMax+box23->GetDX(),-ylen + yPos +2*rMax-kLay2-(rMax-kLay2)/2,0));
2027   mechLaddVol->AddNode(plate23Vol,3,new TGeoTranslation(xPos +(1.11/2+rMax+box23->GetDX()),-ylen + yPos +2*rMax-kLay2-(rMax-kLay2)/2,0));
2028   mechLaddVol->AddNode(plate23Vol,4,new TGeoTranslation(xPos +1.11/2-rMax-box23->GetDX(),-ylen + yPos +2*rMax-kLay2-(rMax-kLay2)/2,0));
2029   mechLaddVol->AddNode(plate23Vol,5,new TGeoTranslation(-xPos -(1.11/2+rMax+box23->GetDX()),-ylen + yPos +2*rMax-kLay2-(rMax-kLay2)/2+deltaY,0));
2030   mechLaddVol->AddNode(plate23Vol,6,new TGeoTranslation(-xPos -1.11/2+rMax+box23->GetDX(),-ylen + yPos +2*rMax-kLay2-(rMax-kLay2)/2+deltaY,0));
2031   mechLaddVol->AddNode(plate23Vol,7,new TGeoTranslation(-xPos +(1.11/2+rMax+box23->GetDX()),-ylen + yPos +2*rMax-kLay2-(rMax-kLay2)/2+deltaY,0));
2032   mechLaddVol->AddNode(plate23Vol,8,new TGeoTranslation(-xPos +1.11/2-rMax-box23->GetDX(),-ylen + yPos +2*rMax-kLay2-(rMax-kLay2)/2+deltaY,0));
2033
2034   mechLaddVol->AddNode(cone2Vol,1,new TGeoTranslation(xPos - 0.555,-ylen + yPos + rMax,0));
2035   mechLaddVol->AddNode(cone2Vol,2,new TGeoTranslation(xPos + 0.555,-ylen + yPos + rMax,0));
2036   mechLaddVol->AddNode(cone2Vol,3,new TGeoTranslation(-xPos - 0.555,-ylen + yPos + rMax + deltaY,0));
2037   mechLaddVol->AddNode(cone2Vol,4,new TGeoTranslation(-xPos + 0.555,-ylen + yPos + rMax + deltaY,0));
2038
2039   //Cooling Tubes + water
2040
2041   mechLaddVol->AddNode(coolTubeVol,1,new TGeoTranslation(xPos - 0.555,-ylen + yPos + rMax,0));
2042   mechLaddVol->AddNode(coolTubeWVol,1,new TGeoTranslation(xPos - 0.555,-ylen + yPos + rMax,0));
2043   mechLaddVol->AddNode(coolTubeVol,2,new TGeoTranslation(xPos + 0.555,-ylen + yPos + rMax,0));
2044   mechLaddVol->AddNode(coolTubeWVol,2,new TGeoTranslation(xPos + 0.555,-ylen + yPos + rMax,0));
2045   mechLaddVol->AddNode(coolTubeVol,3,new TGeoTranslation(-xPos - 0.555,-ylen + yPos + rMax + deltaY,0));
2046   mechLaddVol->AddNode(coolTubeWVol,3,new TGeoTranslation(-xPos - 0.555,-ylen + yPos + rMax + deltaY,0));
2047   mechLaddVol->AddNode(coolTubeVol,4,new TGeoTranslation(-xPos + 0.555,-ylen + yPos + rMax + deltaY,0));
2048   mechLaddVol->AddNode(coolTubeWVol,4,new TGeoTranslation(-xPos + 0.555,-ylen + yPos + rMax + deltaY,0));
2049
2050   //Cold Plate
2051
2052   mechLaddVol->AddNode(coldPlateVol,1,new TGeoTranslation(xPos,-ylen + yPos + 2*rMax + yCPlate/2,0));
2053   mechLaddVol->AddNode(coldPlateVol,2,new TGeoTranslation(-xPos,-ylen + yPos + 2*rMax + yCPlate/2 + deltaY,0));
2054
2055   //Glue
2056
2057   mechLaddVol->AddNode(glueVol,1,new TGeoTranslation(xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue/2,0));
2058   mechLaddVol->AddNode(glueVol,2,new TGeoTranslation(-xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue/2 + deltaY,0));
2059
2060   //Module Carbon Plate
2061
2062   mechLaddVol->AddNode(modPlateVol,1,new TGeoTranslation(xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate/2,0));
2063   mechLaddVol->AddNode(modPlateVol,2,new TGeoTranslation(-xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate/2 + deltaY,0));
2064
2065   //Bus
2066
2067   mechLaddVol->AddNode(bus1Vol,1,new TGeoTranslation(xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + 2*yFlex1 + 2*yFlex2 + yBus1/2,0));
2068   mechLaddVol->AddNode(bus1Vol,2,new TGeoTranslation(-xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + 2*yFlex1 + 2*yFlex2 + yBus1/2 + deltaY,0));
2069   mechLaddVol->AddNode(bus2Vol,1,new TGeoTranslation(xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + 2*yFlex1 + 2*yFlex2 + yBus1 + yBus2/2,0));
2070   mechLaddVol->AddNode(bus2Vol,2,new TGeoTranslation(-xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + 2*yFlex1 + 2*yFlex2 + yBus1 + yBus2/2 + deltaY,0));
2071   
2072   //FPC + modules
2073
2074   for (Int_t j=0; j<fNModules; j++) {
2075
2076     zpos = -(zact + (fNModules-1)*modGap)/2 + j*(zMod + modGap) + zMod/2;
2077     zpos5cm = -(zact + (fNModules-1)*modGap)/2 + (j+1)*(zMod + modGap) + flexOverlap/2 ;
2078
2079     mechLaddVol->AddNode(modVol, j, new TGeoTranslation(xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + ymod, zpos));
2080     mechLaddVol->AddNode(modVol, fNModules+j, new TGeoTranslation(-xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + ymod +deltaY, zpos));
2081     mechLaddVol->AddNode(flex1Vol,j,new TGeoTranslation(xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + yFlex1/2,zpos));
2082     mechLaddVol->AddNode(flex1Vol,fNModules+j,new TGeoTranslation(-xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + yFlex1/2 + deltaY,zpos));
2083     mechLaddVol->AddNode(flex2Vol,j,new TGeoTranslation(xPos, -ylen + yPos + yModPlate + 2*rMax + yCPlate + yGlue + 2*ymod + yFlex1 + yFlex2/2,zpos));
2084     mechLaddVol->AddNode(flex2Vol,fNModules+j,new TGeoTranslation(-xPos, -ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + yFlex1 + yFlex2/2 + deltaY,zpos));
2085
2086     if((j+1)!=fNModules){
2087       mechLaddVol->AddNode(flex1_5cmVol,j,new TGeoTranslation(xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + yFlex1 + yFlex2 + yFlex1/2,zpos5cm));
2088       mechLaddVol->AddNode(flex1_5cmVol,fNModules+j,new TGeoTranslation(-xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + yFlex1 + yFlex2 + yFlex1/2 +deltaY,zpos5cm));
2089       mechLaddVol->AddNode(flex2_5cmVol,j,new TGeoTranslation(xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + 2*yFlex1 + 3*yFlex2/2,zpos5cm));
2090       mechLaddVol->AddNode(flex2_5cmVol,fNModules+j,new TGeoTranslation(-xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + 2*yFlex1 + 3*yFlex2/2 +deltaY,zpos5cm));
2091     }
2092     else {
2093       mechLaddVol->AddNode(flex1_5cmVol,j,new TGeoTranslation(xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + yFlex1/2,zpos5cm-modGap));
2094       mechLaddVol->AddNode(flex1_5cmVol,fNModules+j,new TGeoTranslation(-xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + yFlex1/2 +deltaY,zpos5cm-modGap));
2095       mechLaddVol->AddNode(flex2_5cmVol,j,new TGeoTranslation(xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate +2*ymod + yFlex1 + yFlex2/2,zpos5cm-modGap));
2096       mechLaddVol->AddNode(flex2_5cmVol,fNModules+j,new TGeoTranslation(-xPos,-ylen + yPos + 2*rMax + yCPlate + yGlue + yModPlate + 2*ymod + yFlex1 + yFlex2/2 +deltaY,zpos5cm-modGap));
2097
2098       }
2099   }
2100   
2101
2102   // Done, return the stave structur
2103   return mechLaddVol;
2104 }
2105
2106 //________________________________________________________________________
2107 TGeoVolume* AliITSUv1Layer::CreateSpaceFrameOuterB(const Double_t xlad,
2108                                                    const TGeoManager *mgr){
2109 //
2110 // Create the space frame for the Outer Barrel
2111 //
2112 // Input:
2113 //         xlad : X length
2114 //         mgr  : the GeoManager (used only to get the proper material)
2115 //
2116 // Output:
2117 //
2118 // Return:
2119 //
2120 //
2121
2122   TGeoVolume *mechLaddVol = 0;
2123
2124   switch (fStaveModel) {
2125     case AliITSUv1::kOBModelDummy:
2126       mechLaddVol = CreateSpaceFrameOuterBDummy(xlad,mgr);
2127       break;
2128     case AliITSUv1::kOBModel1:
2129       mechLaddVol = CreateSpaceFrameOuterB0(xlad,mgr);
2130       break;
2131     default:
2132       AliFatal(Form("Unknown stave model %d",fStaveModel));
2133       break;
2134   }
2135
2136   return mechLaddVol; 
2137 }
2138
2139 //________________________________________________________________________
2140 TGeoVolume* AliITSUv1Layer::CreateSpaceFrameOuterBDummy(const Double_t ,
2141                                                         const TGeoManager *) const {
2142 //
2143 // Create dummy stave
2144 //
2145 // Input:
2146 //         xlad : X length
2147 //         mgr  : the GeoManager (used only to get the proper material)
2148 //
2149 // Output:
2150 //
2151 // Return:
2152 //
2153
2154
2155   // Done, return the stave structur
2156   return 0;
2157 }
2158
2159 //________________________________________________________________________
2160 TGeoVolume* AliITSUv1Layer::CreateSpaceFrameOuterB0(const Double_t xlen,
2161                                                     const TGeoManager *mgr){
2162 //
2163 // Create the space frame for the Outer Barrel (Model 0)
2164 //
2165 // Input:
2166 //         xlen : X length
2167 //         mgr  : the GeoManager (used only to get the proper material)
2168 //
2169 // Output:
2170 //
2171 // Return:
2172 //         a TGeoVolume with the Space Frame of a stave
2173 //
2174 // Created:      20 Dec 2013  Anastasia Barbano
2175 // Updated:      15 Jan 2014  Mario Sitta
2176 //
2177
2178
2179   // Materials defined in AliITSUv0
2180   TGeoMedium *medCarbon       = mgr->GetMedium("ITS_CARBON$");
2181   TGeoMedium *medAir          = mgr->GetMedium("ITS_AIR$");
2182
2183
2184   // Local parameters
2185   Double_t ladderWidth        = 4.2;
2186   Double_t ladderHeight       = 4.2;
2187 //  Double_t ladderSegBoxDW     = 7.5;
2188 //  Double_t ladderSegBoxDH     = 7.1;
2189   Double_t ladderBeamRadius   = 0.06;
2190   Double_t ladderLa           = 0.3;
2191   Double_t ladderHa           = 0.0721979;
2192   Double_t ladderLb           = 0.37;
2193   Double_t ladderHb           = 0.0890428;
2194   Double_t ladderl            = 0.025;
2195   Double_t beamSidePhi        = 65;
2196   Double_t bottomBeamAngle    = 61.5; //56.5;
2197 //  Double_t dy                 = ladderSegBoxDH/2;
2198   Double_t triangleHeight     = ladderHeight - ladderBeamRadius;
2199   Double_t halfTheta          = TMath::ATan( 0.5*ladderWidth/triangleHeight );
2200   Double_t alpha              = TMath::Pi()*3./4. - halfTheta/2.;
2201   Double_t beta               = (TMath::Pi() - 2.*halfTheta)/4.;
2202 //  Double_t dYTranslation      = (ladderHeight/2. -0.5*ladderWidth*TMath::Tan(beta)-ladderBeamRadius);
2203   Double_t distCenterSideDown =  0.5*ladderWidth/TMath::Cos(beta);
2204   Double_t zact;
2205   Double_t zbus;
2206   Double_t zlen;
2207   Double_t seglen;    
2208
2209
2210   zact    = fNModules*fgkOBModuleZLength; //active area 
2211   zbus    = zact + (fNModules-1)*fgkOBModuleGap; 
2212   zlen    = zbus/2;
2213   seglen  = zlen/10;
2214
2215   // First create all needed shapes and volumes
2216
2217   TGeoBBox *spaceFrame = new TGeoBBox("CarbonFrame",xlen, 2.2, zlen);
2218   TGeoBBox *segment    = new TGeoBBox(ladderWidth/2,ladderHeight/2,seglen/2);
2219
2220   TGeoVolume *spaceFrameVol = new TGeoVolume("CarbonFrameVolume",
2221                                              spaceFrame, medAir);
2222   spaceFrameVol->SetVisibility(kTRUE);
2223
2224   TGeoVolume *segmentVol    = new TGeoVolume("segmentVol",segment,medAir);
2225
2226   //SpaceFrame
2227
2228   //--- the top V of the Carbon Fiber Ladder (segment)
2229   TGeoArb8 *cfLaddTop1 = CreateLadderSide("CFladdTopCornerVol1shape", seglen/2., halfTheta, -1, ladderLa, ladderHa, ladderl);
2230   TGeoVolume *cfLaddTopVol1 = new TGeoVolume("ITSsddCFladdTopCornerVol1", cfLaddTop1,medCarbon);
2231   TGeoArb8 *cfLaddTop2 = CreateLadderSide( "CFladdTopCornerVol2shape", seglen/2., halfTheta, 1, ladderLa, ladderHa, ladderl);
2232   TGeoVolume *cfLaddTopVol2 = new TGeoVolume("ITSsddCFladdTopCornerVol2",cfLaddTop2,medCarbon );
2233
2234   //TGeoTranslation *trTop1 = new TGeoTranslation(0, fgkLadderHeight/2-dy, 0);
2235   TGeoTranslation *trTop1 = new TGeoTranslation(0, ladderHeight/2, 0);
2236   
2237   //--- the 2 side V
2238   TGeoArb8 *cfLaddSide1 = CreateLadderSide( "CFladdSideCornerVol1shape", seglen/2., beta, -1,ladderLb, ladderHb, ladderl);
2239   TGeoVolume *cfLaddSideVol1 = new TGeoVolume( "ITSsddCFladdSideCornerVol1", cfLaddSide1,medCarbon);
2240   TGeoArb8 *cfLaddSide2 = CreateLadderSide( "CFladdSideCornerVol2shape", seglen/2., beta, 1, ladderLb, ladderHb, ladderl);
2241   TGeoVolume *cfLaddSideVol2 = new TGeoVolume( "ITSsddCFladdSideCornerVol2", cfLaddSide2,medCarbon );
2242
2243   
2244   TGeoCombiTrans *ctSideR = CreateCombiTrans("", distCenterSideDown, 0,alpha*TMath::RadToDeg());
2245   //AddTranslationToCombiTrans(ctSideR, 0, -dYTranslation-dy, 0);
2246   AddTranslationToCombiTrans(ctSideR, 0, ladderHeight/2-2.85/*2.765250*//*triangleHeight*/, 0);
2247   TGeoCombiTrans *ctSideL = CreateCombiTrans("", distCenterSideDown,0,-alpha*TMath::RadToDeg());
2248   //AddTranslationToCombiTrans(ctSideL, 0, -dYTranslation-dy, 0);
2249   AddTranslationToCombiTrans(ctSideL, 0, ladderHeight/2-2.85/*triangleHeight*/, 0);
2250
2251   segmentVol->AddNode(cfLaddTopVol1,1,trTop1);
2252   segmentVol->AddNode(cfLaddTopVol2,1,trTop1);
2253   segmentVol->AddNode(cfLaddSideVol1,1,ctSideR);
2254   segmentVol->AddNode(cfLaddSideVol1,2,ctSideL);
2255   segmentVol->AddNode(cfLaddSideVol2,1,ctSideR);
2256   segmentVol->AddNode(cfLaddSideVol2,2,ctSideL);
2257
2258
2259   //--- The beams
2260   // Beams on the sides
2261   Double_t beamPhiPrime = TMath::ASin(1./TMath::Sqrt( (1+TMath::Sin(2*beta)*TMath::Sin(2*beta)/(TanD(beamSidePhi)*TanD(beamSidePhi))) ));
2262   Double_t beamLength = TMath::Sqrt( ladderHeight*ladderHeight/( TMath::Sin(beamPhiPrime)*TMath::Sin(beamPhiPrime))+ ladderWidth*ladderWidth/4.)-ladderLa/2-ladderLb/2;
2263   TGeoTubeSeg *sideBeamS = new TGeoTubeSeg(0, ladderBeamRadius,beamLength/2.,0, 180);
2264   TGeoVolume *sideBeam = new TGeoVolume("ITSsddCFSideBeamVol", sideBeamS,medCarbon);
2265
2266   //Euler rotation : about Z, then new X, then new Z
2267   TGeoRotation *beamRot1 = new TGeoRotation("", 90-2.*beta*TMath::RadToDeg(),-beamPhiPrime*TMath::RadToDeg(),-90);
2268   TGeoRotation *beamRot2 = new TGeoRotation("", 90-2.*beta*TMath::RadToDeg(), beamPhiPrime*TMath::RadToDeg(), -90);
2269   TGeoRotation *beamRot3 = new TGeoRotation("", 90+2.*beta*TMath::RadToDeg(), beamPhiPrime*TMath::RadToDeg(), -90);
2270   TGeoRotation *beamRot4 = new TGeoRotation("", 90+2.*beta*TMath::RadToDeg(),-beamPhiPrime*TMath::RadToDeg(),-90);
2271
2272   TGeoCombiTrans *beamTransf[8];
2273   beamTransf[0] = new TGeoCombiTrans( 0.5*triangleHeight*TMath::Tan(halfTheta),ladderBeamRadius/2. ,-3*seglen/8, beamRot1);
2274
2275   beamTransf[1] = new TGeoCombiTrans( 0.5*triangleHeight*TMath::Tan(halfTheta),ladderBeamRadius/2. ,-3*seglen/8, beamRot1);
2276   AddTranslationToCombiTrans(beamTransf[1], 0, 0, seglen/2);
2277
2278   beamTransf[2] = new TGeoCombiTrans(0.5*triangleHeight*TMath::Tan(halfTheta),ladderBeamRadius/2. ,-seglen/8, beamRot2);
2279
2280   beamTransf[3] = new TGeoCombiTrans(0.5*triangleHeight*TMath::Tan(halfTheta),ladderBeamRadius/2. ,-seglen/8, beamRot2);
2281   AddTranslationToCombiTrans(beamTransf[3], 0, 0, seglen/2);
2282
2283   beamTransf[4] = new TGeoCombiTrans(-0.5*triangleHeight*TMath::Tan(halfTheta),ladderBeamRadius/2. ,-3*seglen/8, beamRot3);
2284
2285   beamTransf[5] = new TGeoCombiTrans(-0.5*triangleHeight*TMath::Tan(halfTheta),ladderBeamRadius/2. ,-3*seglen/8, beamRot3);
2286   AddTranslationToCombiTrans(beamTransf[5], 0, 0, seglen/2);
2287
2288   beamTransf[6] = new TGeoCombiTrans(-0.5*triangleHeight* TMath::Tan(halfTheta),ladderBeamRadius/2., -seglen/8,beamRot4);
2289   beamTransf[7] = new TGeoCombiTrans(-0.5*triangleHeight* TMath::Tan(halfTheta),ladderBeamRadius/2.,3*seglen/8,beamRot4);
2290
2291   //--- Beams of the bottom
2292   TGeoTubeSeg *bottomBeam1 = new TGeoTubeSeg(0, ladderBeamRadius,ladderWidth/2.-ladderLb/3, 0, 180);
2293   TGeoVolume *bottomBeam1Vol = new TGeoVolume("ITSsddBottomBeam1Vol", bottomBeam1, medCarbon);
2294   TGeoTubeSeg *bottomBeam2 = new TGeoTubeSeg(0, ladderBeamRadius,ladderWidth/2.-ladderLb/3, 0, 90);
2295   TGeoVolume *bottomBeam2Vol = new TGeoVolume("ITSsddBottomBeam2Vol",bottomBeam2, medCarbon);
2296   TGeoTubeSeg *bottomBeam3 = new TGeoTubeSeg(0, ladderBeamRadius,0.5*ladderWidth/SinD(bottomBeamAngle) - ladderLb/3, 0, 180);
2297   TGeoVolume *bottomBeam3Vol = new TGeoVolume("ITSsddBottomBeam3Vol", bottomBeam3, medCarbon);
2298   TGeoRotation *bottomBeamRot1 = new TGeoRotation("", 90, 90,  90);
2299   TGeoRotation *bottomBeamRot2 = new TGeoRotation("",-90, 90, -90);
2300
2301   TGeoCombiTrans *bottomBeamTransf1 = new TGeoCombiTrans("",0,-(ladderHeight/2-ladderBeamRadius),0, bottomBeamRot1);
2302   TGeoCombiTrans *bottomBeamTransf2 = new TGeoCombiTrans(0,-(ladderHeight/2-ladderBeamRadius),-seglen/2, bottomBeamRot1);
2303   TGeoCombiTrans *bottomBeamTransf3 = new TGeoCombiTrans(0,-(ladderHeight/2-ladderBeamRadius), seglen/2, bottomBeamRot2);
2304   // be careful for beams #3: when "reading" from -z to +z and 
2305   // from the bottom of the ladder, it should draw a Lambda, and not a V
2306   TGeoRotation *bottomBeamRot4 = new TGeoRotation("", -90, bottomBeamAngle, -90);
2307   TGeoRotation *bottomBeamRot5 = new TGeoRotation("" ,-90,-bottomBeamAngle, -90);
2308   TGeoCombiTrans *bottomBeamTransf4 = new TGeoCombiTrans(0,-(ladderHeight/2-ladderBeamRadius),-seglen/4,bottomBeamRot4);
2309   TGeoCombiTrans *bottomBeamTransf5 = new TGeoCombiTrans(0,-(ladderHeight/2-ladderBeamRadius),seglen/4, bottomBeamRot5);
2310
2311   cfLaddTopVol1->SetLineColor(35);
2312   cfLaddTopVol2->SetLineColor(35);
2313   cfLaddSideVol1->SetLineColor(35);
2314   cfLaddSideVol2->SetLineColor(35);
2315   sideBeam->SetLineColor(35);
2316   bottomBeam1Vol->SetLineColor(35);
2317   bottomBeam2Vol->SetLineColor(35);
2318   bottomBeam3Vol->SetLineColor(35);
2319
2320
2321   segmentVol->AddNode(sideBeam,1, beamTransf[0]);
2322   segmentVol->AddNode(sideBeam,2, beamTransf[1]);
2323   segmentVol->AddNode(sideBeam,3, beamTransf[2]);
2324   segmentVol->AddNode(sideBeam,4, beamTransf[3]);
2325   segmentVol->AddNode(sideBeam,5, beamTransf[4]);
2326   segmentVol->AddNode(sideBeam,6, beamTransf[5]);
2327   segmentVol->AddNode(sideBeam,7, beamTransf[6]);
2328   segmentVol->AddNode(sideBeam,8, beamTransf[7]);
2329   segmentVol->AddNode(bottomBeam1Vol,1,bottomBeamTransf1);
2330   segmentVol->AddNode(bottomBeam2Vol,1,bottomBeamTransf2);
2331   segmentVol->AddNode(bottomBeam2Vol,1,bottomBeamTransf3);
2332   segmentVol->AddNode(bottomBeam3Vol,1,bottomBeamTransf4);
2333   segmentVol->AddNode(bottomBeam3Vol,1,bottomBeamTransf5);
2334
2335   for(Int_t i=0;i<10;i++){
2336     spaceFrameVol->AddNode(segmentVol,i,new TGeoTranslation(0,0,seglen*(0.5+i)));
2337     spaceFrameVol->AddNode(segmentVol,11+i,new TGeoTranslation(0,0,-seglen*(0.5+i)));
2338   }
2339
2340
2341   // Done, return the stave structur
2342   return spaceFrameVol;
2343 }
2344
2345 //________________________________________________________________________
2346 TGeoVolume* AliITSUv1Layer::CreateModuleInnerB(const Double_t xlad,
2347                                                const Double_t ylad,   
2348                                                const Double_t zlad,
2349                                                const TGeoManager *mgr){
2350 //
2351 // Creates the actual Module
2352 //
2353 // Input:
2354 //         xlad,zlad : the ladder dimensions
2355 //         mgr  : the GeoManager (used only to get the proper material)
2356 //
2357 // Output:
2358 //
2359 // Return:
2360 //
2361 // Created:      22 Jun 2011  Mario Sitta
2362 //
2363
2364   char volname[30];
2365   Double_t xlen, ylen, zlen;
2366   Double_t xpos, ypos, zpos;
2367
2368
2369   // First create all needed shapes
2370
2371   // The module
2372   TGeoBBox *module = new TGeoBBox(xlad,  ylad, zlad/fNModules);
2373
2374   // The sensor
2375   xlen = module->GetDX();
2376   ylen = 0.5*fSensorThick;
2377   zlen = module->GetDZ();
2378   TGeoBBox *sensor = new TGeoBBox(xlen, ylen, zlen);
2379
2380
2381   // We have all shapes: now create the real volumes
2382   //TGeoMedium *medAir = mgr->GetMedium("ITS_AIR$");
2383   TGeoMedium *medSi  = mgr->GetMedium("ITS_SI$");
2384
2385   snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSModulePattern(), fLayerNumber);
2386   // TGeoVolume *modVol = new TGeoVolume(volname, module, medAir);
2387   TGeoVolume *modVol = new TGeoVolume(volname, module, medSi);
2388   modVol->SetVisibility(kTRUE);
2389   modVol->SetLineColor(1);
2390
2391   snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSSensorPattern(), fLayerNumber);
2392   TGeoVolume *sensVol = new TGeoVolume(volname, sensor, medSi);
2393   sensVol->SetVisibility(kTRUE);
2394   sensVol->SetLineColor(8);
2395   sensVol->SetLineWidth(1);
2396   sensVol->SetFillColor(sensVol->GetLineColor());
2397   sensVol->SetFillStyle(4000); // 0% transparent
2398
2399
2400   // Now build up the module
2401   xpos = 0.;
2402   ypos = -module->GetDY() + sensor->GetDY();
2403   zpos = 0.;
2404
2405   modVol->AddNode(sensVol, 1, new TGeoTranslation(xpos, ypos, zpos));
2406
2407   // Done, return the module
2408   return modVol;
2409 }
2410
2411 //________________________________________________________________________
2412 TGeoVolume* AliITSUv1Layer::CreateModuleOuterB(const Double_t xlad,
2413                                                const Double_t ylad,   
2414                                                const Double_t zmod,
2415                                                const TGeoManager *mgr){
2416 //
2417 // Creates the actual Module
2418 //
2419 // Input:
2420 //         xlad,ylad,zlad : the half stave dimensions
2421 //         mgr  : the GeoManager (used only to get the proper material)
2422 //
2423 // Output:
2424 //
2425 // Return:
2426 //
2427 // Created:      18 Dec 2013  M. Sitta, A. Barbano
2428 //
2429
2430
2431   char volname[30];
2432
2433   Double_t xGap  = 0.01; 
2434   Double_t zGap  = 0.01;
2435
2436   Double_t xlen, ylen, zlen;
2437   Double_t xpos, ypos, zpos;
2438   
2439   // First create all needed shapes
2440
2441   // The module
2442   TGeoBBox *module = new TGeoBBox(xlad,  ylad, zmod/2);
2443
2444   // The sensor
2445   xlen = 0.5*(module->GetDX()-xGap/2);
2446   //xlen = 0.5*1.5;
2447   ylen = ylad;
2448   zlen = (2*module->GetDZ()-6*zGap)/14;
2449   TGeoBBox *sensor = new TGeoBBox(xlen, ylen, zlen);
2450
2451
2452   // We have all shapes: now create the real volumes
2453  
2454   TGeoMedium *medSi  = mgr->GetMedium("ITS_SI$");
2455   snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSModulePattern(), fLayerNumber);
2456   TGeoVolume *modVol = new TGeoVolume(volname, module, medSi);
2457   modVol->SetVisibility(kTRUE);
2458
2459   snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSSensorPattern(), fLayerNumber);
2460   TGeoVolume *sensVol = new TGeoVolume(volname, sensor, medSi);
2461   
2462
2463
2464   // Now build up the module
2465   xpos = -module->GetDX() + sensor->GetDX();
2466   //xpos = -xGap/2 -sensor->GetDX();
2467   ypos = -module->GetDY() + sensor->GetDY();
2468   for(Int_t k=0;k<7;k++)   //put 7x2 chip into one module
2469     {
2470       zpos = -module->GetDZ() + sensor->GetDZ() + k*(2*sensor->GetDZ() + zGap);
2471       modVol->AddNode(sensVol, k+1, new TGeoTranslation(xpos, ypos, zpos));
2472       modVol->AddNode(sensVol, k+2, new TGeoTranslation(-xpos, ypos, zpos));
2473     }
2474   
2475   //sensVol->SetVisibility(kTRUE);
2476   sensVol->SetLineColor(kYellow);
2477   //sensVol->SetLineWidth(1);
2478   //sensVol->SetTransparency(30);
2479   sensVol->SetFillColor(sensVol->GetLineColor());
2480   sensVol->SetFillStyle(4000); // 0% transparent
2481   // Done, return the module
2482   return modVol;
2483 }
2484
2485 //________________________________________________________________________
2486 Double_t AliITSUv1Layer::RadiusOfTurboContainer(){
2487 //
2488 // Computes the inner radius of the air container for the Turbo configuration
2489 // as the radius of either the circle tangent to the ladder or the circle
2490 // passing for the ladder's lower vertex
2491 //
2492 // Input:
2493 //         none (all needed parameters are class members)
2494 //
2495 // Output:
2496 //
2497 // Return:
2498 //        the radius of the container if >0, else flag to use the lower vertex
2499 //
2500 // Created:      08 Mar 2012  Mario Sitta
2501 //
2502
2503   Double_t rr, delta, z, lladd, rladd;
2504
2505   if (fLadderThick > 89.) // Very big angle: avoid overflows since surely
2506     return -1;            // the radius from lower vertex is the right value
2507
2508   rladd = fLayRadius + 0.5*fLadderThick;
2509   delta = (0.5*fLadderThick)/CosD(fLadderTilt);
2510   z     = (0.5*fLadderThick)*TanD(fLadderTilt);
2511
2512   rr = rladd - delta;
2513   lladd = (0.5*fLadderWidth) - z;
2514
2515   if ( (rr*SinD(fLadderTilt) < lladd) )
2516     return (rr*CosD(fLadderTilt));
2517   else
2518     return -1;
2519 }
2520
2521 //________________________________________________________________________
2522 void AliITSUv1Layer::SetLadderTilt(const Double_t t)
2523 {
2524 //
2525 // Sets the Ladder tilt angle (for turbo layers only)
2526 //
2527 // Input:
2528 //         t :  the ladder tilt angle
2529 //
2530 // Output:
2531 //
2532 // Return:
2533 //
2534 // Created:      08 Jul 2011  Mario Sitta
2535 //
2536
2537   if (fIsTurbo)
2538     fLadderTilt = t;
2539   else
2540     AliError("Not a Turbo layer");
2541
2542 }
2543
2544 //________________________________________________________________________
2545 void AliITSUv1Layer::SetLadderWidth(const Double_t w){
2546 //
2547 // Sets the Ladder width (for turbo layers only)
2548 //
2549 // Input:
2550 //         w :  the ladder width
2551 //
2552 // Output:
2553 //
2554 // Return:
2555 //
2556 // Created:      08 Jul 2011  Mario Sitta
2557 //
2558
2559   if (fIsTurbo)
2560     fLadderWidth = w;
2561   else
2562     AliError("Not a Turbo layer");
2563
2564 }
2565
2566 //________________________________________________________________________
2567 TGeoArb8 *AliITSUv1Layer::CreateLadderSide(const char *name,
2568                          Double_t dz, Double_t angle, Double_t xSign,
2569                          Double_t L, Double_t H, Double_t l) {
2570 //
2571 // Creates the V-shaped sides of the OB space frame
2572 // (from a similar method with same name and function
2573 // in AliITSv11GeometrySDD class by L.Gaudichet)
2574 //
2575
2576     // Create one half of the V shape corner of CF ladder
2577   
2578     TGeoArb8 *cfLaddSide = new TGeoArb8(dz);
2579     cfLaddSide->SetName(name);
2580
2581     // Points must be in clockwise order
2582     cfLaddSide->SetVertex(0, 0,  0);
2583     cfLaddSide->SetVertex(2, xSign*(L*TMath::Sin(angle)-l*TMath::Cos(angle)),
2584                           -L*TMath::Cos(angle)-l*TMath::Sin(angle));
2585     cfLaddSide->SetVertex(4, 0,  0);
2586     cfLaddSide->SetVertex(6, xSign*(L*TMath::Sin(angle)-l*TMath::Cos(angle)),
2587                           -L*TMath::Cos(angle)-l*TMath::Sin(angle));
2588     if (xSign < 0) {
2589      cfLaddSide->SetVertex(1, 0, -H);
2590      cfLaddSide->SetVertex(3, xSign*L*TMath::Sin(angle), -L*TMath::Cos(angle));
2591      cfLaddSide->SetVertex(5, 0, -H);
2592      cfLaddSide->SetVertex(7, xSign*L*TMath::Sin(angle), -L*TMath::Cos(angle));
2593     } else {
2594      cfLaddSide->SetVertex(1, xSign*L*TMath::Sin(angle), -L*TMath::Cos(angle));
2595      cfLaddSide->SetVertex(3, 0, -H);
2596      cfLaddSide->SetVertex(5, xSign*L*TMath::Sin(angle), -L*TMath::Cos(angle));
2597      cfLaddSide->SetVertex(7, 0, -H);
2598     }
2599     return cfLaddSide;
2600 }
2601
2602 //________________________________________________________________________
2603 TGeoCombiTrans *AliITSUv1Layer::CreateCombiTrans(const char *name,
2604                                          Double_t dy, Double_t dz,
2605                                          Double_t dphi, Bool_t planeSym) {
2606 //
2607 // Help method to create a TGeoCombiTrans matrix
2608 // (from a similar method with same name and function
2609 // in AliITSv11GeometrySDD class by L.Gaudichet)
2610 //
2611
2612     //
2613     // return the TGeoCombiTrans which make a translation in y and z
2614     // and a rotation in phi in the global coord system
2615     // If planeSym = true, the rotation places the object symetrically
2616     // (with respect to the transverse plane) to its position in the
2617     // case planeSym = false
2618     //
2619
2620     TGeoTranslation t1(dy*CosD(90.+dphi),dy*SinD(90.+dphi), dz);
2621     TGeoRotation r1("",0.,0.,dphi);
2622     TGeoRotation r2("",90, 180, -90-dphi);
2623
2624     TGeoCombiTrans *combiTrans1 = new TGeoCombiTrans(name);
2625     combiTrans1->SetTranslation(t1);
2626     if (planeSym) combiTrans1->SetRotation(r1);
2627     else  combiTrans1->SetRotation(r2);
2628     return combiTrans1;
2629 }
2630
2631 //________________________________________________________________________
2632 void AliITSUv1Layer::AddTranslationToCombiTrans(TGeoCombiTrans* ct,
2633                                                        Double_t dx,
2634                                                        Double_t dy,
2635                                                        Double_t dz) const{
2636 //
2637 // Help method to add a translation to a TGeoCombiTrans matrix
2638 // (from a similar method with same name and function
2639 // in AliITSv11GeometrySDD class by L.Gaudichet)
2640 //
2641
2642   // Add a dx,dy,dz translation to the initial TGeoCombiTrans
2643   const Double_t *vect = ct->GetTranslation();
2644   Double_t newVect[3] = {vect[0]+dx, vect[1]+dy, vect[2]+dz};
2645   ct->SetTranslation(newVect);
2646 }