]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUv0Layer.cxx
optimized mat.budget estimator macro
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUv0Layer.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: AliITSUv0Layer.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 "AliITSUv0Layer.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 AliITSUv0Layer::fgkDefaultSensorThick = 300*fgkmicron;
48 const Double_t AliITSUv0Layer::fgkDefaultStaveThick =   1*fgkcm;
49
50 ClassImp(AliITSUv0Layer)
51
52 #define SQ(A) (A)*(A)
53
54 //________________________________________________________________________
55 AliITSUv0Layer::AliITSUv0Layer(): 
56   AliITSv11Geometry(),
57   fLayerNumber(0),
58   fPhi0(0),
59   fLayRadius(0),
60   fZLength(0),
61   fSensorThick(0),
62   fStaveThick(0),
63   fStaveWidth(0),
64   fStaveTilt(0),
65   fNStaves(0),
66   fNChips(0),
67   fChipTypeID(0),
68   fIsTurbo(0),
69   fBuildLevel(0),
70   fStaveModel(AliITSUv0::kModelDummy)
71 {
72   //
73   // Standard constructor
74   //
75 }
76
77 //________________________________________________________________________
78 AliITSUv0Layer::AliITSUv0Layer(Int_t debug): 
79   AliITSv11Geometry(debug),
80   fLayerNumber(0),
81   fPhi0(0),
82   fLayRadius(0),
83   fZLength(0),
84   fSensorThick(0),
85   fStaveThick(0),
86   fStaveWidth(0),
87   fStaveTilt(0),
88   fNStaves(0),
89   fNChips(0),
90   fChipTypeID(0),
91   fIsTurbo(0),
92   fBuildLevel(0),
93   fStaveModel(AliITSUv0::kModelDummy)
94 {
95   //
96   // Constructor setting debugging level
97   //
98 }
99
100 //________________________________________________________________________
101 AliITSUv0Layer::AliITSUv0Layer(Int_t lay, Int_t debug): 
102   AliITSv11Geometry(debug),
103   fLayerNumber(lay),
104   fPhi0(0),
105   fLayRadius(0),
106   fZLength(0),
107   fSensorThick(0),
108   fStaveThick(0),
109   fStaveWidth(0),
110   fStaveTilt(0),
111   fNStaves(0),
112   fNChips(0),
113   fChipTypeID(0),
114   fIsTurbo(0),
115   fBuildLevel(0),
116   fStaveModel(AliITSUv0::kModelDummy)
117 {
118   //
119   // Constructor setting layer number and debugging level
120   //
121 }
122
123 //________________________________________________________________________
124 AliITSUv0Layer::AliITSUv0Layer(Int_t lay, Bool_t turbo, Int_t debug): 
125   AliITSv11Geometry(debug),
126   fLayerNumber(lay),
127   fPhi0(0),
128   fLayRadius(0),
129   fZLength(0),
130   fSensorThick(0),
131   fStaveThick(0),
132   fStaveWidth(0),
133   fStaveTilt(0),
134   fNStaves(0),
135   fNChips(0),
136   fChipTypeID(0),
137   fIsTurbo(turbo),
138   fBuildLevel(0),
139   fStaveModel(AliITSUv0::kModelDummy)
140 {
141   //
142   // Constructor setting layer number and debugging level
143   // for a "turbo" layer (i.e. where staves overlap in phi)
144   //
145 }
146
147 //________________________________________________________________________
148 AliITSUv0Layer::AliITSUv0Layer(const AliITSUv0Layer &s):
149   AliITSv11Geometry(s.GetDebug()),
150   fLayerNumber(s.fLayerNumber),
151   fPhi0(s.fPhi0),
152   fLayRadius(s.fLayRadius),
153   fZLength(s.fZLength),
154   fSensorThick(s.fSensorThick),
155   fStaveThick(s.fStaveThick),
156   fStaveWidth(s.fStaveWidth),
157   fStaveTilt(s.fStaveTilt),
158   fNStaves(s.fNStaves),
159   fNChips(s.fNChips),
160   fChipTypeID(s.fChipTypeID),
161   fIsTurbo(s.fIsTurbo),
162   fBuildLevel(s.fBuildLevel),
163   fStaveModel(s.fStaveModel)
164 {
165   //
166   // Copy constructor
167   //
168 }
169
170 //________________________________________________________________________
171 AliITSUv0Layer& AliITSUv0Layer::operator=(const AliITSUv0Layer &s)
172 {
173   //
174   // Assignment operator 
175   //
176   if(&s == this) return *this;
177
178   fLayerNumber = s.fLayerNumber;
179   fPhi0        = s.fPhi0;
180   fLayRadius   = s.fLayRadius;
181   fZLength     = s.fZLength;
182   fSensorThick = s.fSensorThick;
183   fStaveThick = s.fStaveThick;
184   fStaveWidth = s.fStaveWidth;
185   fStaveTilt  = s.fStaveTilt;
186   fNStaves    = s.fNStaves;
187   fNChips    = s.fNChips;
188   fIsTurbo     = s.fIsTurbo;
189   fChipTypeID   = s.fChipTypeID;
190   fBuildLevel  = s.fBuildLevel;
191   fStaveModel  = s.fStaveModel;
192
193   return *this;
194 }
195
196 //________________________________________________________________________
197 AliITSUv0Layer::~AliITSUv0Layer() {
198   //
199   // Destructor
200   //
201 }
202
203 //________________________________________________________________________
204 void AliITSUv0Layer::CreateLayer(TGeoVolume *moth){
205 //
206 // Creates the actual Layer and places inside its mother volume
207 //
208 // Input:
209 //         moth : the TGeoVolume owing the volume structure
210 //
211 // Output:
212 //
213 // Return:
214 //
215 // Created:      17 Jun 2011  Mario Sitta
216 // Updated:      08 Jul 2011  Mario Sitta
217 // Updated:      20 May 2013  Mario Sitta  Layer is Assembly instead of Tube
218 //
219   // Local variables
220   char volname[30];
221   Double_t xpos, ypos, zpos;
222   Double_t alpha;
223
224
225   // Check if the user set the proper parameters
226   if (fLayRadius <= 0) AliFatal(Form("Wrong layer radius (%f)",fLayRadius));
227   if (fZLength   <= 0) AliFatal(Form("Wrong layer length (%f)",fZLength));
228   if (fNStaves  <= 0) AliFatal(Form("Wrong number of staves (%d)",fNStaves));
229   if (fNChips  <= 0) AliFatal(Form("Wrong number of chips (%d)",fNChips));
230
231   if (fStaveThick <= 0) {
232     AliInfo(Form("Stave thickness wrong or not set (%f), using default (%f)",
233                  fStaveThick,fgkDefaultStaveThick));
234     fStaveThick = fgkDefaultStaveThick;
235   }
236
237   if (fSensorThick <= 0) {
238     AliInfo(Form("Sensor thickness wrong or not set (%f), using default (%f)",
239                  fSensorThick,fgkDefaultSensorThick));
240     fSensorThick = fgkDefaultSensorThick;
241   }
242
243   if (fSensorThick > fStaveThick) {
244     AliWarning(Form("Sensor thickness (%f) is greater than stave thickness (%f), fixing",
245                  fSensorThick,fStaveThick));
246     fSensorThick = fStaveThick;
247   }
248
249
250   // If a Turbo layer is requested, do it and exit
251   if (fIsTurbo) {
252     CreateLayerTurbo(moth);
253     return;
254   }
255
256
257   // First create the stave container
258   alpha = (360./(2*fNStaves))*DegToRad();
259
260   //  fStaveWidth = fLayRadius*Tan(alpha);
261
262   snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(),fLayerNumber);
263   TGeoVolume *layVol = new TGeoVolumeAssembly(volname);
264   layVol->SetUniqueID(fChipTypeID);
265
266 //  layVol->SetVisibility(kFALSE);
267   layVol->SetVisibility(kTRUE);
268   layVol->SetLineColor(1);
269
270   TGeoVolume *stavVol = CreateStave();
271
272
273   // Now build up the layer
274   alpha = 360./fNStaves;
275   Double_t r = fLayRadius + ((TGeoBBox*)stavVol->GetShape())->GetDY();
276   for (Int_t j=0; j<fNStaves; j++) {
277     Double_t phi = j*alpha + fPhi0;
278     xpos = r*CosD(phi);// r*SinD(-phi);
279     ypos = r*SinD(phi);// r*CosD(-phi);
280     zpos = 0.;
281     phi += 90;
282     layVol->AddNode(stavVol, j, new TGeoCombiTrans( xpos, ypos, zpos,
283                                                     new TGeoRotation("",phi,0,0)));
284   }
285
286
287   // Finally put everything in the mother volume
288   moth->AddNode(layVol, 1, 0);
289
290
291   // Upgrade geometry is served
292   return;
293 }
294
295 //________________________________________________________________________
296 void AliITSUv0Layer::CreateLayerTurbo(TGeoVolume *moth){
297 //
298 // Creates the actual Layer and places inside its mother volume
299 // A so-called "turbo" layer is a layer where staves overlap in phi
300 // User can set width and tilt angle, no check is performed here
301 // to avoid volume overlaps
302 //
303 // Input:
304 //         moth : the TGeoVolume owing the volume structure
305 //
306 // Output:
307 //
308 // Return:
309 //
310 // Created:      08 Jul 2011  Mario Sitta
311 // Updated:      08 Mar 2012  Mario Sitta  Correct way to compute container R
312 // Updated:      20 May 2013  Mario Sitta  Layer is Assemgbly instead of Tube
313 //
314
315
316   // Local variables
317   char volname[30];
318   Double_t xpos, ypos, zpos;
319   Double_t alpha;
320
321
322   // Check if the user set the proper (remaining) parameters
323   if (fStaveWidth <= 0)
324     AliFatal(Form("Wrong stave width (%f)",fStaveWidth));
325   if (Abs(fStaveTilt) > 45)
326     AliWarning(Form("Stave tilt angle (%f) greater than 45deg",fStaveTilt));
327
328
329   snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSLayerPattern(), fLayerNumber);
330   TGeoVolume *layVol = new TGeoVolumeAssembly(volname);
331   layVol->SetUniqueID(fChipTypeID);
332   layVol->SetVisibility(kTRUE);
333   layVol->SetLineColor(1);
334   TGeoVolume *stavVol = CreateStave();
335
336
337   // Now build up the layer
338   alpha = 360./fNStaves;
339   Double_t r = fLayRadius /* +chip thick ?! */;
340   for (Int_t j=0; j<fNStaves; j++) {
341     Double_t phi = j*alpha + fPhi0;
342     xpos = r*CosD(phi);// r*SinD(-phi);
343     ypos = r*SinD(phi);// r*CosD(-phi);
344     zpos = 0.;
345     phi += 90;
346     layVol->AddNode(stavVol, j, new TGeoCombiTrans( xpos, ypos, zpos,
347                                                     new TGeoRotation("", phi-fStaveTilt,0,0)));
348   }
349
350
351   // Finally put everything in the mother volume
352   moth->AddNode(layVol, 1, 0);
353
354   return;
355 }
356
357 //________________________________________________________________________
358 TGeoVolume* AliITSUv0Layer::CreateStave(const TGeoManager * /*mgr*/){
359 //
360 // Creates the actual Stave
361 //
362 // Input:
363 //         mgr  : the GeoManager (used only to get the proper material)
364 //
365 // Output:
366 //
367 // Return:
368 //
369 // Created:      22 Jun 2011  Mario Sitta
370 //
371
372   char volname[30];
373   Double_t xlen, ylen, zlen;
374   Double_t xpos, ypos, zpos, zmod;
375   Double_t alpha;
376
377
378   // First create all needed shapes
379   alpha = (360./(2*fNStaves))*DegToRad();
380
381   // The stave
382   xlen = fLayRadius*Tan(alpha);
383   if (fIsTurbo) xlen = 0.5*fStaveWidth;
384   ylen = 0.5*fStaveThick;
385   zlen = 0.5*fZLength;
386
387   Double_t yplus = 0.46;
388   //  Double_t origin[]={0,-yplus/2,0};
389   //  TGeoBBox *stave = new TGeoBBox(xlen, ylen+yplus/2, zlen, origin);
390   TGeoXtru *stave = new TGeoXtru(2); //z sections
391   Double_t xv[5] = {xlen,xlen,0,-xlen,-xlen};
392   Double_t yv[5] = {ylen+0.09,-0.15,-yplus-fSensorThick,-0.15,ylen+0.09};    
393   stave->DefinePolygon(5,xv,yv);
394   stave->DefineSection(0,-zlen,0,0,1.);
395   stave->DefineSection(1,+zlen,0,0,1.);
396   
397
398   // We have all shapes: now create the real volumes
399 //  TGeoMedium *medAir = mgr->GetMedium("ITS_AIR$");
400
401   snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSStavePattern(), fLayerNumber);
402 //  TGeoVolume *stavVol = new TGeoVolume(volname, stave, medAir);
403   TGeoVolume *stavVol = new TGeoVolumeAssembly(volname);
404
405   //  stavVol->SetVisibility(kFALSE);
406   stavVol->SetVisibility(kTRUE);
407   stavVol->SetLineColor(2);
408   TGeoVolume *modVol = CreateChip(xlen,ylen, zlen);
409
410
411   // Now build up the stave
412   zmod = ((TGeoBBox*)modVol->GetShape())->GetDZ();
413   for (Int_t j=0; j<fNChips; j++) {
414     xpos = 0.;
415     ypos = 0.021;  // Remove small overlap - M.S: 21may13
416     zpos = -stave->GetDZ() + j*2*zmod + zmod;
417     stavVol->AddNode(modVol, j, new TGeoTranslation(xpos, ypos, zpos));
418   }
419  
420
421   // put mechanical stave structure, only inner barrel up to now
422   if (fLayerNumber<3) {
423     TGeoVolume *mechStavVol = CreateStaveStruct(xlen,zlen); 
424     if (mechStavVol)
425       stavVol->AddNode(mechStavVol, fNChips, new TGeoCombiTrans(0, -0.15-ylen, 0, new TGeoRotation("",0, 0, 180)));
426   }
427   
428
429   // Done, return the stave
430   return stavVol;
431 }
432
433 //________________________________________________________________________
434 TGeoVolume* AliITSUv0Layer::CreateStaveStruct(const Double_t xsta,
435                                               const Double_t zsta,
436                                               const TGeoManager *mgr){
437 //
438 // Create the mechanical stave structure
439 //
440 // Input:
441 //         xsta : X length
442 //         zsta : Z length
443 //         mgr  : the GeoManager (used only to get the proper material)
444 //
445 // Output:
446 //
447 // Return:
448 //
449 // Created:      22 Mar 2013  Chinorat Kobdaj
450 // Updated:      26 Apr 2013  Mario Sitta
451 //
452
453   TGeoVolume *mechStavVol = 0;
454
455   switch (fStaveModel) {
456     case AliITSUv0::kModelDummy:
457       mechStavVol = CreateStaveModelDummy(xsta,zsta,mgr);
458       break;
459     case AliITSUv0::kModel0:
460       mechStavVol = CreateStaveModel0(xsta,zsta,mgr);
461       break;
462     case AliITSUv0::kModel1:
463       mechStavVol = CreateStaveModel1(xsta,zsta,mgr);
464       break;
465     case AliITSUv0::kModel21:
466       mechStavVol = CreateStaveModel21(xsta,zsta,mgr);
467       break;
468     case AliITSUv0::kModel22:
469       mechStavVol = CreateStaveModel22(xsta,zsta,mgr);
470       break;
471     case AliITSUv0::kModel3:
472       mechStavVol = CreateStaveModel3(xsta,zsta,mgr);
473       break;
474     default:
475       AliFatal(Form("Unknown stave model %d",fStaveModel));
476       break;
477   }
478
479   return mechStavVol; 
480 }
481
482
483 //________________________________________________________________________
484 TGeoVolume* AliITSUv0Layer::CreateStaveModelDummy(const Double_t ,
485                                               const Double_t ,
486                                               const TGeoManager *) const {
487 //
488 // Create dummy stave
489 //
490 // Input:
491 //         xsta : X length
492 //         zsta : Z length
493 //         mgr  : the GeoManager (used only to get the proper material)
494 //
495 // Output:
496 //
497 // Return:
498 //
499 // Created:      22 Mar 2013  Chinorat Kobdaj
500 // Updated:      26 Apr 2013  Mario Sitta
501 //
502
503   // Done, return the stave structur
504   return 0;
505 }
506
507 //________________________________________________________________________
508 TGeoVolume* AliITSUv0Layer::CreateStaveModel0(const Double_t xsta,
509                                               const Double_t zsta,
510                                               const TGeoManager *mgr){
511 //
512 // Create the mechanical stave structure for Model 0 of TDR
513 //
514 // Input:
515 //         xsta : X length
516 //         zsta : Z length
517 //         mgr  : the GeoManager (used only to get the proper material)
518 //
519 // Output:
520 //
521 // Return:
522 //
523 // Created:      22 Mar 2013  Chinorat Kobdaj
524 // Updated:      26 Apr 2013  Mario Sitta
525 //
526   
527   // Materials defined in AliITSUv0
528   TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
529   TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
530
531   TGeoMedium *medM60J3K    = mgr->GetMedium("ITS_M60J3K$"); 
532   TGeoMedium *medKapton    = mgr->GetMedium("ITS_KAPTON(POLYCH2)$");
533   TGeoMedium *medGlue      = mgr->GetMedium("ITS_GLUE$");
534   TGeoMedium *medFlexCable = mgr->GetMedium("ITS_FLEXCABLE$");
535
536   // Local parameters
537   Double_t kConeOutRadius = 0.15/2;
538   Double_t kConeInRadius = 0.1430/2;
539   Double_t kStaveLength = zsta*2;
540   Double_t kStaveWidth = xsta*2-kConeOutRadius*2;
541   Double_t kWidth = kStaveWidth/4;//1/2 of kWidth
542   Double_t kStaveHeight = 0.3;
543   Double_t kHeight = kStaveHeight/2;
544   Double_t kAlpha = 90-67;//90-33.69;
545   Double_t kTheta = kAlpha*TMath::DegToRad();
546   Double_t kS1 = kWidth/TMath::Sin(kTheta);
547   Double_t kL1 = kWidth/TMath::Tan(kTheta);
548   Double_t kS2 = TMath::Sqrt(kHeight*kHeight + kS1*kS1);//TMath::Sin(the2);
549   Double_t kThe2 = TMath::ATan(kHeight/kS1);
550   Double_t kBeta = kThe2*TMath::RadToDeg();
551   // Int_t  loop = kStaveLength/(kL1);
552   // Double_t s3 = kWidth/(2*TMath::Sin(kTheta));
553   // Double_t s4 = 3*kWidth/(2*TMath::Sin(kTheta));
554
555   AliDebug(1, Form("BuildLevel %d\n",fBuildLevel));
556
557   char volname[30];
558   snprintf(volname, 30, "%s%d_StaveStruct", AliITSUGeomTGeo::GetITSStavePattern(), fLayerNumber);
559
560   Double_t z=0, y=-0.011+0.0150, x=0;
561
562    TGeoVolume *mechStavVol = 0;
563
564   if (fBuildLevel < 5) {
565
566     // world (trapezoid)
567     TGeoXtru *mechStruct = new TGeoXtru(2); //z sections
568     Double_t xv[5] = {kStaveWidth/2+0.1,kStaveWidth/2+0.1,0,-kStaveWidth/2-0.1,-kStaveWidth/2-0.1};
569     Double_t yv[5] = {-kConeOutRadius*2-0.07,0,kStaveHeight,0,-kConeOutRadius*2-0.07};    
570     mechStruct->DefinePolygon(5,xv,yv);
571     mechStruct->DefineSection(0,-kStaveLength-0.1,0,0,1.);
572     mechStruct->DefineSection(1,kStaveLength+0.1,0,0,1.);
573
574     mechStavVol = new TGeoVolume(volname, mechStruct, medAir);
575     mechStavVol->SetLineColor(12);
576     mechStavVol->SetFillColor(12); 
577     mechStavVol->SetVisibility(kTRUE);
578       
579     // detailed structure ++++++++++++++
580     //Pipe Kapton grey-35
581     TGeoTube *coolTube = new TGeoTube(kConeInRadius,kConeOutRadius,kStaveLength/2);
582     TGeoVolume *volCoolTube= new TGeoVolume("pipe", coolTube, medKapton);
583     volCoolTube->SetFillColor(35);
584     volCoolTube->SetLineColor(35);
585     mechStavVol->AddNode(volCoolTube,0,new TGeoTranslation(x+(kStaveWidth/2),y-(kHeight-kConeOutRadius),0));
586     mechStavVol->AddNode(volCoolTube,1,new TGeoTranslation(x-(kStaveWidth/2),y-(kHeight-kConeOutRadius),0));
587   }
588
589   if (fBuildLevel < 4) {
590     TGeoTube *coolTubeW = new TGeoTube(0.,kConeInRadius,kStaveLength/2);
591     TGeoVolume *volCoolTubeW= new TGeoVolume("pipeWater", coolTubeW, medWater);
592     volCoolTubeW->SetFillColor(4);
593     volCoolTubeW->SetLineColor(4);
594     mechStavVol->AddNode(volCoolTubeW,0,new TGeoTranslation(x+(kStaveWidth/2),y-(kHeight-kConeOutRadius),0));
595     mechStavVol->AddNode(volCoolTubeW,1,new TGeoTranslation(x-(kStaveWidth/2),y-(kHeight-kConeOutRadius),0));
596   }
597
598   //frequency of filament
599   //n = 4 means very dense(4 filaments per interval)
600   //n = 2 means dense(2 filaments per interval)
601   Int_t n =4;
602   Int_t loop = (Int_t)(kStaveLength/(4*kL1/n) + 2/n)-1;
603   if (fBuildLevel < 3) {
604     //Top CFRP Filament black-12 Carbon structure TGeoBBox (length,thickness,width)
605     TGeoBBox *t2=new TGeoBBox(kS2,0.007/2,0.15/2);//(kS2,0.002,0.02);
606     TGeoVolume *volT2=new TGeoVolume("TopFilament", t2, medM60J3K);
607     volT2->SetLineColor(12);
608     volT2->SetFillColor(12); 
609
610     for(int i=1;i<loop;i++){  //i<60;i++){
611       mechStavVol->AddNode(volT2,4*i+0,
612                                   new TGeoCombiTrans(x+kWidth,y+(2*kConeOutRadius),z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2,//z-14.25+(i*2*kL1),
613                                                      new TGeoRotation("volT2",90,90-kAlpha,90-kBeta)));
614       mechStavVol->AddNode(volT2,4*i+1,
615                                   new TGeoCombiTrans(x-kWidth,y+(2*kConeOutRadius),z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2,//z-14.25+(i*2*kL1),
616                                                      new TGeoRotation("volT2",90,-90+kAlpha,-90+kBeta)));
617       mechStavVol->AddNode(volT2,4*i+2,
618                                   new TGeoCombiTrans(x+kWidth,y+(2*kConeOutRadius),z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2,//z-14.25+(i*2*kL1),
619                                                      new TGeoRotation("volT2",90,-90+kAlpha,90-kBeta)));
620       mechStavVol->AddNode(volT2,4*i+3,
621                                   new TGeoCombiTrans(x-kWidth,y+(2*kConeOutRadius),z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2,//z-14.25+(i*2*kL1),  
622                                                      new TGeoRotation("volT2",90,90-kAlpha,-90+kBeta)));
623     }
624
625
626     //Bottom CFRP Filament black-12 Carbon structure  TGeoBBox (thickness,width,length)
627     TGeoBBox *t1=new TGeoBBox(0.007/2,0.15/2,kS1);//(0.002,0.02,kS1);
628     TGeoVolume *volT1=new TGeoVolume("CFRPBottom", t1, medM60J3K);
629     volT1->SetLineColor(12);
630     volT1->SetFillColor(12); 
631
632     for(int i=1;i<loop;i++){
633       mechStavVol->AddNode(volT1,4*i+0,
634                                   new TGeoCombiTrans(x+kWidth,y-kHeight,z-kStaveLength/2+((4/n)*kL1*i)+kS1/2, //z-14.25+(i*2*kL1),  
635                                                      new TGeoRotation("volT1",-90,kAlpha,0)));
636       mechStavVol->AddNode(volT1,4*i+1,
637                                   new TGeoCombiTrans(x-kWidth,y-kHeight,z-kStaveLength/2+((4/n)*kL1*i)+kS1/2,  //z-14.25+(i*2*kL1), 
638                                                      new TGeoRotation("volT1",90,kAlpha,0)));
639       mechStavVol->AddNode(volT1,4*i+2,
640                                   new TGeoCombiTrans(x+kWidth,y-kHeight,z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2, //z-14.25+(i*2*kL1), 
641                                                      new TGeoRotation("volT1",-90,-kAlpha,0)));
642       mechStavVol->AddNode(volT1,4*i+3,
643                                   new TGeoCombiTrans(x-kWidth,y-kHeight,z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2, //z-14.25+(i*2*kL1), 
644                                                      new TGeoRotation("volT1",-90,+kAlpha,0)));
645     }
646   }
647    
648   if (fBuildLevel < 2) {
649     // Glue CFRP-Silicon layers TGeoBBox(thickness,width,kS1);
650     TGeoBBox *tG=new TGeoBBox(0.0075/2,0.18/2,kS1);
651     TGeoVolume *volTG=new TGeoVolume("Glue1", tG, medGlue);
652     volTG->SetLineColor(5);
653     volTG->SetFillColor(5); 
654
655     for(int i=1;i<loop;i++){ //i<60;i++){
656       mechStavVol->AddNode(volTG,4*i+0,
657                                   new TGeoCombiTrans(x+kWidth,y-0.16,z-kStaveLength/2+((4/n)*kL1*i)+kS1/2, //z-14.25+(2*kL1*i), 
658                                                      new TGeoRotation("volTG",-90,kAlpha,0)));
659       mechStavVol->AddNode(volTG,4*i+1,
660                                   new TGeoCombiTrans(x-kWidth,y-0.16,z-kStaveLength/2+((4/n)*kL1*i)+kS1/2, //z-14.25+(2*kL1*i), 
661                                                      new TGeoRotation("volTG",90,kAlpha,0)));
662       mechStavVol->AddNode(volTG,4*i+2,
663                                   new TGeoCombiTrans(x+kWidth,y-0.16,z-kStaveLength/2+((4/n)*i*kL1)+kS1/2, //z-14.25+(i*2*kL1), 
664                                                      new TGeoRotation("volTG",-90,-kAlpha,0)));
665       mechStavVol->AddNode(volTG,4*i+3,
666                                   new TGeoCombiTrans(x-kWidth,y-0.16,z-kStaveLength/2+(i*(4/n)*kL1)+kS1/2, //z-14.25+(i*2*kL1), 
667                                                      new TGeoRotation("volTG",-90,+kAlpha,0)));
668     }
669
670     TGeoBBox *glue = new TGeoBBox(xsta, 0.005/2, zsta);
671     TGeoVolume *volGlue=new TGeoVolume("Glue2", glue, medGlue);
672     volGlue->SetLineColor(5);
673     volGlue->SetFillColor(5); 
674     //mechStavVol->AddNode(volGlue, 0, new TGeoCombiTrans(x, y-0.16, z, new TGeoRotation("",0, 0, 0)));
675     mechStavVol->AddNode(volGlue, 1, new TGeoCombiTrans(x, y-0.165-fSensorThick-0.005, z, new TGeoRotation("",0, 0, 0)));
676   }
677
678   if (fBuildLevel < 1) {
679     //Flex cable brown-28 TGeoBBox(width,thickness,length); 
680     TGeoBBox *kapCable = new TGeoBBox(xsta, 0.01/2, zsta);
681     TGeoVolume *volCable=new TGeoVolume("FlexCable", kapCable, medFlexCable);
682     volCable->SetLineColor(28);
683     volCable->SetFillColor(28); 
684     mechStavVol->AddNode(volCable, 0, new TGeoCombiTrans(x, y-0.165-fSensorThick-0.005-0.01, z, new TGeoRotation("",0, 0, 0)));
685  }
686
687   // Done, return the stave structur
688   return mechStavVol;
689 }
690
691
692 //________________________________________________________________________
693 TGeoVolume* AliITSUv0Layer::CreateStaveModel1(const Double_t xsta,
694                                               const Double_t zsta,
695                                               const TGeoManager *mgr){
696 //
697 // Create the mechanical stave structure for Model 1 of TDR
698 //
699 // Input:
700 //         xsta : X length
701 //         zsta : Z length
702 //         mgr  : the GeoManager (used only to get the proper material)
703 //
704 // Output:
705 //
706 // Return:
707 //
708 // Created:      22 Mar 2013  Chinorat Kobdaj
709 // Updated:      26 Apr 2013  Mario Sitta
710 //
711   
712   // Materials defined in AliITSUv0
713   TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
714   TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
715
716   TGeoMedium *medM60J3K    = mgr->GetMedium("ITS_M60J3K$"); 
717   TGeoMedium *medKapton    = mgr->GetMedium("ITS_KAPTON(POLYCH2)$");
718   TGeoMedium *medGlue      = mgr->GetMedium("ITS_GLUE$");
719   TGeoMedium *medFlexCable = mgr->GetMedium("ITS_FLEXCABLE$");
720
721   // Local parameters
722   Double_t kConeOutRadius = 0.15/2;
723   //    Double_t kConeInRadius = 0.1430/2;
724   Double_t kStaveLength = zsta*2;
725   //    Double_t kStaveWidth = xsta*2-kConeOutRadius*2;
726   Double_t kStaveWidth = xsta*2;
727   Double_t kWidth = kStaveWidth/4;//1/2 of kWidth
728   Double_t kStaveHeight = 0.3;
729   Double_t kHeight = kStaveHeight/2;
730   Double_t kAlpha = 90-33.;//90-30;
731   Double_t kTheta = kAlpha*TMath::DegToRad();
732   Double_t kS1 = kWidth/TMath::Sin(kTheta);
733   Double_t kL1 = kWidth/TMath::Tan(kTheta);
734   Double_t kS2 = TMath::Sqrt(kHeight*kHeight + kS1*kS1);//TMath::Sin(the2);
735   Double_t kThe2 = TMath::ATan(kHeight/kS1);
736   Double_t kBeta = kThe2*TMath::RadToDeg();
737   Int_t  loop = (Int_t)((kStaveLength/(2*kL1))/2);
738   
739
740   TGeoVolume *mechStavVol = 0;
741
742   char volname[30];
743   snprintf(volname, 30, "%s%d_StaveStruct", AliITSUGeomTGeo::GetITSStavePattern(), fLayerNumber);
744     
745
746   // detailed structure ++++++++++++++
747   Double_t z=0, y=-0.011+0.0150, x=0;
748
749   // Polimide micro channels numbers
750   Double_t yMC = y-kHeight+0.01;
751   Int_t nb = (Int_t)(kStaveWidth/0.1)+1;
752   Double_t xstaMC = (nb*0.1-0.08)/2;
753
754
755   if (fBuildLevel < 5) {
756     // world (trapezoid)
757     TGeoXtru *mechStruct = new TGeoXtru(2); //z sections
758     Double_t xv[5] = {kStaveWidth/2+0.1,kStaveWidth/2+0.1,0,-kStaveWidth/2-0.1,-kStaveWidth/2-0.1};
759     Double_t yv[5] = {-kConeOutRadius*2-0.07,0,kStaveHeight,0,-kConeOutRadius*2-0.07};    
760     mechStruct->DefinePolygon(5,xv,yv);
761     mechStruct->DefineSection(0,-kStaveLength-0.1,0,0,1.);
762     mechStruct->DefineSection(1,kStaveLength+0.1,0,0,1.);
763
764     mechStavVol = new TGeoVolume(volname, mechStruct, medAir);
765     mechStavVol->SetLineColor(12);
766     mechStavVol->SetFillColor(12); 
767     mechStavVol->SetVisibility(kTRUE);
768       
769     // Polimide micro channels numbers
770     TGeoBBox *tM0=new TGeoBBox(xstaMC, 0.005/2, zsta);
771     TGeoVolume *volTM0=new TGeoVolume("MicroChanCover", tM0, medKapton);
772     volTM0->SetLineColor(35);
773     volTM0->SetFillColor(35); 
774     mechStavVol->AddNode(volTM0, 0, new TGeoCombiTrans(x,-0.0125+yMC, z, new TGeoRotation("",0, 0, 0)));
775     mechStavVol->AddNode(volTM0, 1, new TGeoCombiTrans(x,+0.0125+yMC, z, new TGeoRotation("",0, 0, 0)));
776       
777     TGeoBBox *tM0b=new TGeoBBox(0.02/2, 0.02/2, zsta);
778     TGeoVolume *volTM0b=new TGeoVolume("MicroChanWalls", tM0b, medKapton);
779     volTM0b->SetLineColor(35);
780     volTM0b->SetFillColor(35); 
781     for (Int_t ib=0;ib<nb;ib++) {
782       mechStavVol->AddNode(volTM0b, ib, new TGeoCombiTrans(x+ib*0.1-xstaMC+0.01,yMC, z, new TGeoRotation("",0, 0, 0)));
783     }
784       
785   }
786     
787   if (fBuildLevel < 4) {
788     // Water in Polimide micro channels
789     TGeoBBox *water=new TGeoBBox(0.08/2, 0.02/2, zsta+0.1);
790     TGeoVolume *volWater=new TGeoVolume("Water", water, medWater);
791     volWater->SetLineColor(4);
792     volWater->SetFillColor(4); 
793     for (Int_t ib=0;ib<(nb-1);ib++) {
794       mechStavVol->AddNode(volWater, ib, new TGeoCombiTrans(x+ib*0.1-xstaMC+0.06,yMC, z, new TGeoRotation("",0, 0, 0)));
795     }
796   }
797     
798   if (fBuildLevel < 3) {
799     //Bottom filament CFRP black-12 Carbon structure TGeoBBox (thickness,width,length)
800     Double_t filWidth = 0.04;
801     Double_t filHeight= 0.02;
802     TGeoBBox *t1=new TGeoBBox(filHeight/2,filWidth/2,kS1);
803     TGeoVolume *volT1=new TGeoVolume("CFRPBottom", t1, medM60J3K);
804     volT1->SetLineColor(12);
805     volT1->SetFillColor(12); 
806     for(int i=0;i<loop;i++){//i<30;i++){
807       mechStavVol->AddNode(volT1,4*i+0,
808                                   new TGeoCombiTrans(x+kWidth,y-kHeight+0.04+filHeight/2,z-kStaveLength/2+(4*kL1)+kS1/2, 
809                                                      new TGeoRotation("volT1",-90,kAlpha,0)));
810       mechStavVol->AddNode(volT1,4*i+1,
811                                   new TGeoCombiTrans(x-kWidth,y-kHeight+0.04+filHeight/2,z-kStaveLength/2+(4*kL1*i)+kS1/2, 
812                                                      new TGeoRotation("volT1",90,kAlpha,0)));
813       mechStavVol->AddNode(volT1,4*i+2,
814                                   new TGeoCombiTrans(x+kWidth,y-kHeight+0.04+filHeight/2,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2, 
815                                                      new TGeoRotation("volT1",-90,-kAlpha,0)));
816       mechStavVol->AddNode(volT1,4*i+3,
817                                   new TGeoCombiTrans(x-kWidth,y-kHeight+0.04+filHeight/2,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2, 
818                                                      new TGeoRotation("volT1",-90,+kAlpha,0)));
819     }
820
821       // Top filament CFRP black-12 Carbon structure TGeoBBox (length,thickness,width)
822     TGeoBBox *t2=new TGeoBBox(kS2,filHeight/2,filWidth/2);
823     TGeoVolume *volT2=new TGeoVolume("CFRPTop", t2, medM60J3K);
824     volT2->SetLineColor(12);
825     volT2->SetFillColor(12); 
826     for(int i=0;i<loop;i++){ //i<30;i++){
827       mechStavVol->AddNode(volT2,4*i+0,
828                                   new TGeoCombiTrans(x+kWidth,y+0.04+filHeight/2,z-kStaveLength/2+(i*4*kL1)+kS1/2,
829                                                      new TGeoRotation("volT2",90,90-kAlpha,90-kBeta)));
830       mechStavVol->AddNode(volT2,4*i+1,
831                                   new TGeoCombiTrans(x-kWidth,y+0.04+filHeight/2,z-kStaveLength/2+(i*4*kL1)+kS1/2,
832                                                      new TGeoRotation("volT2",90,-90+kAlpha,-90+kBeta)));
833       mechStavVol->AddNode(volT2,4*i+2,
834                                   new TGeoCombiTrans(x+kWidth,y+0.04+filHeight/2,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2,
835                                                      new TGeoRotation("volT2",90,-90+kAlpha,90-kBeta)));
836       mechStavVol->AddNode(volT2,4*i+3,
837                                   new TGeoCombiTrans(x-kWidth,y+0.04+filHeight/2,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2, 
838                                                      new TGeoRotation("volT2",90,90-kAlpha,-90+kBeta)));
839     }
840   }
841
842   if (fBuildLevel < 2) {
843     // Glue between filament and polimide micro channel
844     TGeoBBox *t3=new TGeoBBox(0.01/2,0.04,kS1);
845     TGeoVolume *volT3=new TGeoVolume("FilamentGlue", t3, medGlue);
846     volT3->SetLineColor(5);
847     volT3->SetFillColor(5); 
848     for(int i=0;i<loop;i++){//i<30;i++){
849       mechStavVol->AddNode(volT3,4*i+0,
850                                   new TGeoCombiTrans(x+kWidth,y-kHeight+0.0325,z-kStaveLength/2+(4*kL1*i)+kS1/2, 
851                                                      new TGeoRotation("volT1",-90,kAlpha,0)));
852       mechStavVol->AddNode(volT3,4*i+1,
853                                   new TGeoCombiTrans(x-kWidth,y-kHeight+0.0325,z-kStaveLength/2+(4*kL1*i)+kS1/2, 
854                                                      new TGeoRotation("volT1",90,kAlpha,0)));
855       mechStavVol->AddNode(volT3,4*i+2,
856                                   new TGeoCombiTrans(x+kWidth,y-kHeight+0.0325,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2, 
857                                                      new TGeoRotation("volT1",-90,-kAlpha,0)));
858       mechStavVol->AddNode(volT3,4*i+3,
859                                   new TGeoCombiTrans(x-kWidth,y-kHeight+0.0325,z-kStaveLength/2+2*kL1+(i*4*kL1)+kS1/2, 
860                                                      new TGeoRotation("volT1",-90,+kAlpha,0)));
861     }
862       
863     // Glue microchannel and sensor
864     TGeoBBox *glueM = new TGeoBBox(xsta, 0.01/2, zsta);
865     TGeoVolume *volGlueM=new TGeoVolume("MicroChanGlue", glueM, medGlue);
866     volGlueM->SetLineColor(5);
867     volGlueM->SetFillColor(5); 
868     mechStavVol->AddNode(volGlueM, 0, new TGeoCombiTrans(x, y-0.16, z, new TGeoRotation("",0, 0, 0)));
869
870     // Glue sensor and kapton
871     TGeoBBox *glue = new TGeoBBox(xsta, 0.005/2, zsta);
872     TGeoVolume *volGlue=new TGeoVolume("SensorGlue", glue, medGlue);
873     volGlue->SetLineColor(5);
874     volGlue->SetFillColor(5); 
875     mechStavVol->AddNode(volGlue, 1, new TGeoCombiTrans(x, y-0.165-fSensorThick-0.005, z, new TGeoRotation("",0, 0, 0)));
876   }
877
878   if (fBuildLevel < 1) {
879     TGeoBBox *kapCable = new TGeoBBox(xsta, 0.01/2, zsta);
880     TGeoVolume *volCable=new TGeoVolume("FlexCable", kapCable, medFlexCable);
881     volCable->SetLineColor(28);
882     volCable->SetFillColor(28); 
883     mechStavVol->AddNode(volCable, 0, new TGeoCombiTrans(x, y-0.165-fSensorThick-0.005-0.01, z, new TGeoRotation("",0, 0, 0)));
884   }
885     
886   // Done, return the stave structur
887   return mechStavVol;
888
889 }
890
891 //________________________________________________________________________
892 TGeoVolume* AliITSUv0Layer::CreateStaveModel21(const Double_t xsta,
893                                                const Double_t zsta,
894                                                const TGeoManager *mgr){
895 //
896 // Create the mechanical stave structure for Model 2.1 of TDR
897 //
898 // Input:
899 //         xsta : X length
900 //         zsta : Z length
901 //         mgr  : the GeoManager (used only to get the proper material)
902 //
903 // Output:
904 //
905 // Return:
906 //
907 // Created:      22 Mar 2013  Chinorat Kobdaj
908 // Updated:      26 Apr 2013  Mario Sitta
909 //
910   
911   // Materials defined in AliITSUv0
912   TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
913   TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
914
915   TGeoMedium *medM60J3K    = mgr->GetMedium("ITS_M60J3K$"); 
916   TGeoMedium *medKapton    = mgr->GetMedium("ITS_KAPTON(POLYCH2)$");
917   TGeoMedium *medGlue      = mgr->GetMedium("ITS_GLUE$");
918   TGeoMedium *medFlexCable = mgr->GetMedium("ITS_FLEXCABLE$");
919   TGeoMedium *medK13D2U2k  = mgr->GetMedium("ITS_K13D2U2k$");
920   TGeoMedium *medFGS003    = mgr->GetMedium("ITS_FGS003$"); 
921   TGeoMedium *medCarbonFleece = mgr->GetMedium("ITS_CarbonFleece$"); 
922
923   // Local parameters
924   Double_t kConeOutRadius =0.151384/2;
925   Double_t kConeInRadius = 0.145034/2;
926   Double_t kStaveLength = zsta;
927   Double_t kStaveWidth = xsta*2;
928   Double_t kWidth = (kStaveWidth+0.005)/4;
929   Double_t kStaveHeigth = 0.33;//0.33;
930   Double_t kHeight = (kStaveHeigth+0.025)/2;
931   Double_t kAlpha = 57; //56.31;
932   Double_t kTheta = kAlpha*TMath::DegToRad();
933   Double_t kS1 = (kStaveWidth/4)/TMath::Sin(kTheta);
934   Double_t kL1 = (kStaveWidth/4)/TMath::Tan(kTheta);
935   Double_t kS2 = sqrt(kHeight*kHeight + kS1*kS1);//TMath::Sin(the2);
936   Double_t kThe2 = TMath::ATan(kHeight/kS1);
937   Double_t kBeta = kThe2*TMath::RadToDeg();
938   // Double_t lay1 = 0.003157;
939   Double_t kLay1 = 0.003;//Amec carbon
940   // Double_t lay2 = 0.0043215;//C Fleece carbon
941   Double_t kLay2 = 0.002;//C Fleece carbon
942   Double_t kLay3 = 0.007;//K13D2U carbon
943   Int_t  loop = (Int_t)(kStaveLength/(2*kL1));
944
945
946   char volname[30];
947   snprintf(volname, 30, "%s%d_StaveStruct", AliITSUGeomTGeo::GetITSStavePattern(), fLayerNumber);
948
949   Double_t z=0, y=-(kConeOutRadius+0.03)+0.0385, x=0;
950
951   TGeoVolume *mechStavVol = 0;
952
953   if (fBuildLevel < 5) {
954     // world (trapezoid)
955     TGeoXtru *mechStruct = new TGeoXtru(2); //z sections
956     Double_t xv[5] = {kStaveWidth/2+0.1,kStaveWidth/2+0.1,0,-kStaveWidth/2-0.1,-kStaveWidth/2-0.1};
957     Double_t yv[5] = {-kConeOutRadius*2-0.07,0,kStaveHeigth,0,-kConeOutRadius*2-0.07};    
958     mechStruct->DefinePolygon(5,xv,yv);
959     mechStruct->DefineSection(0,-kStaveLength-0.1,0,0,1.);
960     mechStruct->DefineSection(1,kStaveLength+0.1,0,0,1.);
961
962     mechStavVol = new TGeoVolume(volname, mechStruct, medAir);
963     mechStavVol->SetLineColor(12);
964     mechStavVol->SetFillColor(12); 
965     mechStavVol->SetVisibility(kTRUE);  
966       
967     //Pipe Kapton grey-35 
968     TGeoCone *cone1 = new TGeoCone(kStaveLength,kConeInRadius,kConeOutRadius,kConeInRadius,kConeOutRadius);
969     TGeoVolume *volCone1= new TGeoVolume("PolyimidePipe", cone1, medKapton);
970     volCone1->SetFillColor(35);
971     volCone1->SetLineColor(35);
972     mechStavVol->AddNode(volCone1,1,new TGeoTranslation(x+0.25,y,z));
973     mechStavVol->AddNode(volCone1,2,new TGeoTranslation(x-0.25,y,z));
974   }
975
976   if (fBuildLevel < 4) {
977     
978     TGeoTube *coolTubeW = new TGeoTube(0.,kConeInRadius,kStaveLength);
979     TGeoVolume *volCoolTubeW= new TGeoVolume("Water", coolTubeW, medWater);
980     volCoolTubeW->SetFillColor(4);
981     volCoolTubeW->SetLineColor(4);
982     mechStavVol->AddNode(volCoolTubeW,0,new TGeoTranslation(x-0.25,y,z));
983     mechStavVol->AddNode(volCoolTubeW,1,new TGeoTranslation(x+0.25,y,z));
984   }
985
986   if (fBuildLevel < 3) {
987     //top fillament
988     // Top filament M60J black-12 Carbon structure TGeoBBox (length,thickness,width)
989     TGeoBBox *t2=new TGeoBBox(kS2,0.02/2,0.04/2); //TGeoBBox *t2=new TGeoBBox(kS2,0.01,0.02);
990     TGeoVolume *volT2=new TGeoVolume("TopFilament", t2, medM60J3K);
991     volT2->SetLineColor(12);
992     volT2->SetFillColor(12); 
993     for(int i=0;i<loop;i++){// i<28;i++){
994       mechStavVol->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)));
995       mechStavVol->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)));
996       mechStavVol->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)));
997       mechStavVol->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)));
998 //    mechStavVol->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)));
999
1000  }
1001  
1002     //wall side structure out
1003     TGeoBBox *box4 = new TGeoBBox(0.03/2,0.12/2,kStaveLength-0.50);
1004     TGeoVolume *plate4 = new TGeoVolume("WallOut",box4,medM60J3K);
1005     plate4->SetFillColor(35);
1006     plate4->SetLineColor(35);
1007     mechStavVol->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)));
1008     mechStavVol->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)));
1009     //wall side in
1010     TGeoBBox *box5 = new TGeoBBox(0.015/2,0.12/2,kStaveLength-0.50);
1011     TGeoVolume *plate5 = new TGeoVolume("WallIn",box5,medM60J3K);
1012     plate5->SetFillColor(12);
1013     plate5->SetLineColor(12);
1014     mechStavVol->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)));
1015     mechStavVol->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)));
1016
1017      //Amec Thermasol red-2 cover tube FGS300
1018     TGeoConeSeg *cons1 = new TGeoConeSeg(kStaveLength-0.50,kConeOutRadius,kConeOutRadius+kLay1,kConeOutRadius,kConeOutRadius+kLay1,0,180);
1019     TGeoVolume *cone11 = new TGeoVolume("ThermasolPipeCover",cons1,medFGS003);
1020     cone11->SetFillColor(2);
1021     cone11->SetLineColor(2);
1022     mechStavVol->AddNode(cone11,1,new TGeoCombiTrans(x+0.25,y,z,new TGeoRotation("Cone11",0,0,0)));
1023     mechStavVol->AddNode(cone11,2,new TGeoCombiTrans(x-0.25,y,z,new TGeoRotation("Cone11",0,0,0)));
1024
1025     TGeoBBox *box2 = new TGeoBBox((0.50-(2*kConeOutRadius))/2,kLay1/2,kStaveLength-0.50);
1026     TGeoVolume *plate2 = new TGeoVolume("ThermasolMiddle",box2,medFGS003);
1027     plate2->SetFillColor(2);
1028     plate2->SetLineColor(2);
1029     mechStavVol->AddNode(plate2,1,new TGeoCombiTrans(x,y-kConeOutRadius+(kLay1/2),z,new TGeoRotation("plate2",0,0,0)));
1030
1031     TGeoBBox *box21 = new TGeoBBox((0.75-0.25-kConeOutRadius-kLay1)/2,kLay1/2,kStaveLength-0.50);
1032     TGeoVolume *plate21 = new TGeoVolume("ThermasolLeftRight",box21,medFGS003);
1033     plate21->SetFillColor(2);
1034     plate21->SetLineColor(2);
1035     mechStavVol->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)));
1036     mechStavVol->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)));
1037
1038     TGeoBBox *box22 = new TGeoBBox((kLay1/2),kConeOutRadius/2,kStaveLength-0.50);
1039     TGeoVolume *plate22 = new TGeoVolume("ThermasolVertical",box22,medFGS003);
1040     plate22->SetFillColor(2);
1041     plate22->SetLineColor(2);
1042     mechStavVol->AddNode(plate22,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+(kLay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
1043     mechStavVol->AddNode(plate22,2,new TGeoCombiTrans(x+0.25-kConeOutRadius-(kLay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
1044     mechStavVol->AddNode(plate22,3,new TGeoCombiTrans(x-0.25+kConeOutRadius+(kLay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
1045     mechStavVol->AddNode(plate22,4,new TGeoCombiTrans(x-0.25-kConeOutRadius-(kLay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
1046
1047     //C Fleece
1048     TGeoConeSeg *cons2 = new TGeoConeSeg(kStaveLength-0.50,kConeOutRadius+kLay1,kConeOutRadius+kLay1+kLay2,kConeOutRadius+kLay1,kConeOutRadius+kLay1+kLay2,0,180); 
1049     TGeoVolume *cone12 = new TGeoVolume("CFleecePipeCover",cons2,medCarbonFleece);
1050     cone12->SetFillColor(28);
1051     cone12->SetLineColor(28);
1052     mechStavVol->AddNode(cone12,1,new TGeoCombiTrans(x+0.25,y,z,new TGeoRotation("Cone12",0,0,0)));
1053     mechStavVol->AddNode(cone12,2,new TGeoCombiTrans(x-0.25,y,z,new TGeoRotation("Cone12",0,0,0)));
1054
1055     TGeoBBox *box3 = new TGeoBBox((0.50-(2*(kConeOutRadius+kLay1)))/2,kLay2/2,kStaveLength-0.50);
1056     TGeoVolume *plate3 = new TGeoVolume("CFleeceMiddle",box3,medCarbonFleece);
1057     plate3->SetFillColor(28);
1058     plate3->SetLineColor(28);
1059     mechStavVol->AddNode(plate3,1,new TGeoCombiTrans(x,y-kConeOutRadius+kLay1+(kLay2/2),z,new TGeoRotation("plate3",0,0,0)));
1060
1061     TGeoBBox *box31 = new TGeoBBox((0.75-0.25-kConeOutRadius-kLay1)/2,kLay2/2,kStaveLength-0.50);
1062     TGeoVolume *plate31 = new TGeoVolume("CFleeceLeftRight",box31,medCarbonFleece);
1063     plate31->SetFillColor(28);
1064     plate31->SetLineColor(28);
1065     mechStavVol->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)));
1066     mechStavVol->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)));
1067
1068     TGeoBBox *box32 = new TGeoBBox((kLay2/2),(kConeOutRadius-kLay1)/2,kStaveLength-0.50);
1069     TGeoVolume *plate32 = new TGeoVolume("CFleeceVertical",box32,medCarbonFleece);
1070     plate32->SetFillColor(28);
1071     plate32->SetLineColor(28);
1072     mechStavVol->AddNode(plate32,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+kLay1+(kLay2/2),y+(kLay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
1073     mechStavVol->AddNode(plate32,2,new TGeoCombiTrans(x+0.25-kConeOutRadius-kLay1-(kLay2/2),y+(kLay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
1074     mechStavVol->AddNode(plate32,3,new TGeoCombiTrans(x-0.25+kConeOutRadius+kLay1+(kLay2/2),y+(kLay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
1075     mechStavVol->AddNode(plate32,4,new TGeoCombiTrans(x-0.25-kConeOutRadius-kLay1-(kLay2/2),y+(kLay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
1076
1077
1078     //K13D2U carbon plate
1079     TGeoBBox *box1 = new TGeoBBox(2*kWidth,kLay3/2,kStaveLength-0.50);
1080     TGeoVolume *plate1 = new TGeoVolume("CarbonPlate",box1,medK13D2U2k);
1081     plate1->SetFillColor(5);
1082     plate1->SetLineColor(5);
1083     mechStavVol->AddNode(plate1,1,new TGeoCombiTrans(x,y-(kConeOutRadius+(kLay3/2)),z,new TGeoRotation("plate1",0,0,0)));
1084
1085     //C Fleece bottom plate 
1086     TGeoBBox *box6 = new TGeoBBox(2*kWidth,kLay2/2,kStaveLength-0.50);
1087     TGeoVolume *plate6 = new TGeoVolume("CFleeceBottom",box6,medCarbonFleece);
1088     plate6->SetFillColor(2);
1089     plate6->SetLineColor(2);
1090     mechStavVol->AddNode(plate6,1,new TGeoCombiTrans(x,y-(kConeOutRadius+kLay3+(kLay2/2)),z,new TGeoRotation("plate1",0,0,0)));
1091       
1092       
1093   }
1094
1095   if (fBuildLevel < 2) {
1096     //Glue layers and kapton
1097     TGeoBBox *glue = new TGeoBBox(kStaveWidth/2, 0.005/2, zsta);
1098     TGeoVolume *volGlue=new TGeoVolume("Glue", glue, medGlue);
1099     volGlue->SetLineColor(5);
1100     volGlue->SetFillColor(5); 
1101     mechStavVol->AddNode(volGlue, 0, new TGeoCombiTrans(x,y-(kConeOutRadius+kLay3+(kLay2/2)+(0.01/2)), z, new TGeoRotation("",0, 0, 0)));
1102     mechStavVol->AddNode(volGlue, 1, new TGeoCombiTrans(x,y-(kConeOutRadius+kLay3+(kLay2/2)+0.01+fSensorThick+(0.01/2)), z, new TGeoRotation("",0, 0, 0)));
1103   }
1104
1105   if (fBuildLevel < 1) {
1106     TGeoBBox *kapCable = new TGeoBBox(kStaveWidth/2, 0.01/2, zsta);
1107     TGeoVolume *volCable=new TGeoVolume("FlexCable", kapCable, medFlexCable);
1108     volCable->SetLineColor(28);
1109     volCable->SetFillColor(28); 
1110     mechStavVol->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)));
1111   }
1112     
1113
1114   // Done, return the stave structure
1115   return mechStavVol;
1116   
1117 }
1118 // new model22
1119 //________________________________________________________________________
1120 TGeoVolume* AliITSUv0Layer::CreateStaveModel22(const Double_t xsta,
1121                                                const Double_t zsta,
1122                                                const TGeoManager *mgr){
1123 //
1124 // Create the mechanical stave structure for Model 2.2 of TDR
1125 //
1126 // Input:
1127 //         xsta : X length
1128 //         zsta : Z length
1129 //         mgr  : the GeoManager (used only to get the proper material)
1130 //
1131 // Output:
1132 //
1133 // Return:
1134 //
1135 // Created:      22 Mar 2013  Chinorat Kobdaj
1136 // Updated:      26 Apr 2013  Mario Sitta
1137 // Updated:      30 Apr 2013  Wanchaloem Poonsawat 
1138 //
1139   
1140   // Materials defined in AliITSUv0
1141   TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
1142   TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
1143
1144   TGeoMedium *medM60J3K    = mgr->GetMedium("ITS_M60J3K$"); 
1145   TGeoMedium *medKapton    = mgr->GetMedium("ITS_KAPTON(POLYCH2)$");
1146   TGeoMedium *medGlue      = mgr->GetMedium("ITS_GLUE$");
1147   TGeoMedium *medFlexCable = mgr->GetMedium("ITS_FLEXCABLE$");
1148   TGeoMedium *medK13D2U2k  = mgr->GetMedium("ITS_K13D2U2k$");
1149   TGeoMedium *medFGS003    = mgr->GetMedium("ITS_FGS003$"); 
1150   TGeoMedium *medCarbonFleece = mgr->GetMedium("ITS_CarbonFleece$"); 
1151
1152   // Local parameters
1153   Double_t kConeOutRadius =0.107/2;//0.107/2;
1154   Double_t kConeInRadius = 0.1015/2;//0.10105/2
1155   Double_t kStaveLength = zsta;
1156   Double_t kStaveWidth = xsta*2;
1157   Double_t kWidth = (kStaveWidth)/4;
1158   Double_t kStaveHeight = 0.283;//0.33;
1159   Double_t kHeight = (kStaveHeight)/2;
1160   Double_t kAlpha = 57;//56.31;
1161   Double_t kTheta = kAlpha*TMath::DegToRad();
1162   Double_t kS1 = ((kStaveWidth)/4)/TMath::Sin(kTheta);
1163   Double_t kL1 = (kStaveWidth/4)/TMath::Tan(kTheta);
1164   Double_t kS2 = sqrt(kHeight*kHeight + kS1*kS1);//TMath::Sin(kThe2);
1165   Double_t kThe2 = TMath::ATan(kHeight/(0.375-0.036));
1166   Double_t kBeta = kThe2*TMath::RadToDeg();
1167   Double_t klay1 = 0.003;//Amec carbon
1168   Double_t klay2 = 0.002;//C Fleece carbon
1169   Double_t klay3 = 0.007;//CFplate K13D2U carbon
1170   Double_t klay4 = 0.007;//GluekStaveLength/2
1171   Double_t klay5 = 0.01;//Flex cable
1172   Double_t kTopVertexMaxWidth = 0.072;
1173   Double_t kTopVertexHeight = 0.04;
1174   Double_t kSideVertexMWidth = 0.052;
1175   Double_t kSideVertexHeight = 0.11; 
1176
1177  
1178   Int_t  loop = (Int_t)(kStaveLength/(2*kL1));
1179
1180   char volname[30];
1181   snprintf(volname, 30, "%s%d_StaveStruct", AliITSUGeomTGeo::GetITSStavePattern(), fLayerNumber);
1182
1183   Double_t z=0, y=-(2*kConeOutRadius)+klay1+klay2+fSensorThick/2-0.0004, x=0;
1184
1185   TGeoVolume *mechStavVol = 0;
1186
1187   if (fBuildLevel < 5) {
1188     // world (trapezoid)
1189     TGeoXtru *mechStruct = new TGeoXtru(2); //z sections
1190     Double_t xv[6] = {kStaveWidth/2,kStaveWidth/2,0.012,-0.012,-kStaveWidth/2,-kStaveWidth/2}; 
1191     /* Double_t yv[6] = {-2*(kConeOutRadius+klay1+1.5*klay2+klay3+klay4+fSensorThick+klay5),
1192                         0-0.02,kStaveHeight+0.01,kStaveHeight+0.01,0-0.02,
1193                         -2*(kConeOutRadius+klay1+1.5*klay2+klay3+klay4+fSensorThick+klay5)};  // (kConeOutRadius*2)-0.0635 */
1194     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
1195     mechStruct->DefinePolygon(6,xv,yv);
1196     mechStruct->DefineSection(0,-kStaveLength,0,0,1.);
1197     mechStruct->DefineSection(1,kStaveLength,0,0,1.);
1198
1199     mechStavVol = new TGeoVolume(volname, mechStruct, medAir);
1200     mechStavVol->SetLineColor(12);
1201     mechStavVol->SetFillColor(12); 
1202     mechStavVol->SetVisibility(kTRUE);  
1203       
1204     //Polyimide Pipe Kapton grey-35 
1205     TGeoCone *cone1 = new TGeoCone(kStaveLength,kConeInRadius,kConeOutRadius-0.0001,kConeInRadius,kConeOutRadius-0.0001);
1206     TGeoVolume *volCone1= new TGeoVolume("PolyimidePipe", cone1, medKapton);
1207     volCone1->SetFillColor(35);
1208     volCone1->SetLineColor(35);
1209     mechStavVol->AddNode(volCone1,1,new TGeoTranslation(x+0.25,y,z));
1210     mechStavVol->AddNode(volCone1,2,new TGeoTranslation(x-0.25,y,z));
1211     }
1212
1213   if (fBuildLevel < 4) {
1214     TGeoTube *coolTubeW = new TGeoTube(0.,kConeInRadius-0.0001,kStaveLength);
1215     TGeoVolume *volCoolTubeW= new TGeoVolume("Water", coolTubeW, medWater);
1216     volCoolTubeW->SetFillColor(4);
1217     volCoolTubeW->SetLineColor(4);
1218     mechStavVol->AddNode(volCoolTubeW,0,new TGeoTranslation(x-0.25,y,z));
1219     mechStavVol->AddNode(volCoolTubeW,1,new TGeoTranslation(x+0.25,y,z));
1220   }
1221
1222   if (fBuildLevel < 3) {
1223     //top fillament
1224     // Top filament M60J black-12 Carbon structure TGeoBBox (length,thickness,width)
1225     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
1226     TGeoVolume *volT2=new TGeoVolume("TopFilament", t2, medM60J3K);
1227     volT2->SetLineColor(12);
1228     volT2->SetFillColor(12); 
1229     for(int i=0;i<loop;i++){// i<28;i++){
1230       // 1) Front Left Top Filament
1231        mechStavVol->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)));
1232       // 2) Front Right Top Filament
1233       mechStavVol->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)));
1234       // 3) Back Left  Top Filament
1235       mechStavVol->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)));
1236       // 4) Back Right Top Filament
1237       mechStavVol->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)));
1238    }
1239  
1240      //Vertex  structure 
1241
1242       //top ver trd1
1243       TGeoTrd1 *trd1 = new TGeoTrd1(0,kTopVertexMaxWidth/2,kStaveLength,kTopVertexHeight/2);
1244       TGeoVolume *ibdv = new TGeoVolume("TopVertex",trd1,medM60J3K);
1245       ibdv->SetFillColor(12);
1246       ibdv->SetLineColor(12);
1247       mechStavVol->AddNode(ibdv,1,new TGeoCombiTrans(x,y+kStaveHeight+0.03,z,new TGeoRotation("ibdv",0.,-90,0)));//y+kStaveHeight+0.056
1248
1249       //left trd2
1250       TGeoTrd1 *trd2 = new TGeoTrd1(0,kSideVertexMWidth/2,kStaveLength, kSideVertexHeight/2);
1251       TGeoVolume *ibdv2 = new TGeoVolume("LeftVertex",trd2,medM60J3K);
1252       ibdv2->SetFillColor(12);
1253       ibdv2->SetLineColor(12);
1254       mechStavVol->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,
1255
1256       //right trd3
1257       TGeoTrd1 *trd3 = new TGeoTrd1(0,kSideVertexMWidth/2,kStaveLength, kSideVertexHeight/2);
1258       TGeoVolume *ibdv3 = new TGeoVolume("RightVertex",trd3,medM60J3K);
1259       ibdv3->SetFillColor(12);
1260       ibdv3->SetLineColor(12);
1261       mechStavVol->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
1262       
1263      //Carbon Fleece
1264       TGeoConeSeg *cons2 = new TGeoConeSeg(zsta,kConeOutRadius+klay1,kConeOutRadius+klay1+klay2,kConeOutRadius+klay1,kConeOutRadius+klay1+klay2,0,180); 
1265       TGeoVolume *cone12 = new TGeoVolume("CarbonFleecePipeCover",cons2,medCarbonFleece);
1266       cone12->SetFillColor(28);
1267       cone12->SetLineColor(28);
1268       mechStavVol->AddNode(cone12,1,new TGeoCombiTrans(x+0.25,y,z,new TGeoRotation("cone12",0,0,0)));
1269       mechStavVol->AddNode(cone12,2,new TGeoCombiTrans(x-0.25,y,z,new TGeoRotation("cone12",0,0,0)));
1270
1271       TGeoBBox *box3 = new TGeoBBox((0.50-(2*(kConeOutRadius+klay1)))/2,klay2/2,zsta);//kStaveLength-0.50);
1272       TGeoVolume *plate3 = new TGeoVolume("CarbonFleeceMiddle",box3,medCarbonFleece);
1273       plate3->SetFillColor(28);
1274       plate3->SetLineColor(28);
1275       mechStavVol->AddNode(plate3,1,new TGeoCombiTrans(x,y-kConeOutRadius+klay1+(klay2/2),z,new TGeoRotation("plate3",0,0,0)));
1276
1277       TGeoBBox *box31 = new TGeoBBox((0.75-0.25-kConeOutRadius-klay1)/2+0.0025,klay2/2,zsta);
1278       TGeoVolume *plate31 = new TGeoVolume("CarbonFleeceLeftRight",box31,medCarbonFleece);
1279       plate31->SetFillColor(28);
1280       plate31->SetLineColor(28);
1281       mechStavVol->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)));
1282       mechStavVol->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)));
1283
1284       TGeoBBox *box32 = new TGeoBBox((klay2/2),(kConeOutRadius-klay1)/2,zsta);
1285       TGeoVolume *plate32 = new TGeoVolume("CarbonFleeceVertical",box32,medCarbonFleece);
1286       plate32->SetFillColor(28);
1287       plate32->SetLineColor(28);
1288       mechStavVol->AddNode(plate32,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+klay1+(klay2/2),y+(klay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
1289       mechStavVol->AddNode(plate32,2,new TGeoCombiTrans(x+0.25-kConeOutRadius-klay1-(klay2/2),y+(klay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
1290       mechStavVol->AddNode(plate32,3,new TGeoCombiTrans(x-0.25+kConeOutRadius+klay1+(klay2/2),y+(klay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
1291       mechStavVol->AddNode(plate32,4,new TGeoCombiTrans(x-0.25-kConeOutRadius-klay1-(klay2/2),y+(klay1-kConeOutRadius)/2,z,new TGeoRotation("plate32",0,0,0)));
1292
1293      //Amec Thermasol red-2 cover tube FGS300 or Carbon Paper
1294       TGeoConeSeg *cons1 = new TGeoConeSeg(zsta,kConeOutRadius,kConeOutRadius+klay1-0.0001,kConeOutRadius,kConeOutRadius+klay1-0.0001,0,180);//kConeOutRadius+klay1-0.0001
1295       TGeoVolume *cone11 = new TGeoVolume("ThermasolPipeCover",cons1,medFGS003);
1296       cone11->SetFillColor(2);
1297       cone11->SetLineColor(2);
1298       mechStavVol->AddNode(cone11,1,new TGeoCombiTrans(x+0.25,y,z,new TGeoRotation("cone11",0,0,0)));
1299       mechStavVol->AddNode(cone11,2,new TGeoCombiTrans(x-0.25,y,z,new TGeoRotation("cone11",0,0,0)));
1300
1301       TGeoBBox *box2 = new TGeoBBox((0.50-(2*kConeOutRadius))/2,(klay1/2),zsta);//kStaveLength-0.50);
1302       TGeoVolume *plate2 = new TGeoVolume("ThermasolMiddle",box2,medFGS003);
1303       plate2->SetFillColor(2);
1304       plate2->SetLineColor(2);
1305       mechStavVol->AddNode(plate2,1,new TGeoCombiTrans(x,y-kConeOutRadius+(klay1/2),z,new TGeoRotation("plate2",0,0,0)));
1306
1307       TGeoBBox *box21 = new TGeoBBox((0.75-0.25-kConeOutRadius-klay1)/2+0.0025,(klay1/2),zsta);
1308       TGeoVolume *plate21 = new TGeoVolume("ThermasolLeftRight",box21,medFGS003);
1309       plate21->SetFillColor(2);
1310       plate21->SetLineColor(2);
1311       mechStavVol->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)));
1312       mechStavVol->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)));
1313
1314       TGeoBBox *box22 = new TGeoBBox((klay1/2),kConeOutRadius/2,zsta);
1315       TGeoVolume *plate22 = new TGeoVolume("ThermasolVertical",box22,medFGS003);
1316       plate22->SetFillColor(2);
1317       plate22->SetLineColor(2);
1318       mechStavVol->AddNode(plate22,1,new TGeoCombiTrans(x+0.25+kConeOutRadius+(klay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
1319       mechStavVol->AddNode(plate22,2,new TGeoCombiTrans(x+0.25-kConeOutRadius-(klay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
1320       mechStavVol->AddNode(plate22,3,new TGeoCombiTrans(x-0.25+kConeOutRadius+(klay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
1321       mechStavVol->AddNode(plate22,4,new TGeoCombiTrans(x-0.25-kConeOutRadius-(klay1/2),y-kConeOutRadius/2,z,new TGeoRotation("plate22",0,0,0)));
1322
1323      //K13D2U CF plate
1324       TGeoBBox *box1 = new TGeoBBox(2*kWidth,(klay3)/2,zsta);
1325       TGeoVolume *plate1 = new TGeoVolume("CFPlate",box1,medK13D2U2k);
1326       plate1->SetFillColor(5);
1327       plate1->SetLineColor(5);
1328       mechStavVol->AddNode(plate1,1,new TGeoCombiTrans(x,y-(kConeOutRadius+(klay3/2)),z,new TGeoRotation("plate1",0,0,0)));
1329
1330      //C Fleece bottom plate 
1331       TGeoBBox *box6 = new TGeoBBox(2*kWidth,(klay2)/2,zsta);
1332       TGeoVolume *plate6 = new TGeoVolume("CarbonFleeceBottom",box6,medCarbonFleece);
1333       plate6->SetFillColor(2);
1334       plate6->SetLineColor(2);
1335       mechStavVol->AddNode(plate6,1,new TGeoCombiTrans(x,y-(kConeOutRadius+klay3+(klay2/2)),z,new TGeoRotation("plate6",0,0,0)));
1336
1337     }
1338    if (fBuildLevel < 2) {
1339       //Glue klayers and kapton
1340      TGeoBBox *glue = new TGeoBBox(kStaveWidth/2, (klay4)/2, zsta);
1341       TGeoVolume *volGlue=new TGeoVolume("Glue", glue, medGlue);
1342       volGlue->SetLineColor(5);
1343       volGlue->SetFillColor(5); 
1344       // mechStavVol->AddNode(volGlue, 0, new TGeoCombiTrans(x,y-(kConeOutRadius+klay3+klay2+(klay4/2)), z, new TGeoRotation("",0, 0, 0)));
1345       mechStavVol->AddNode(volGlue, 0, new TGeoCombiTrans(x,y-(kConeOutRadius+klay3+klay2+(klay4)/2)+0.00005, z, new TGeoRotation("",0, 0, 0)));
1346     }
1347
1348      if (fBuildLevel < 1) {
1349      //Flex Cable or Bus
1350       TGeoBBox *kapCable = new TGeoBBox(kStaveWidth/2, klay5/2, zsta);//klay5/2
1351       TGeoVolume *volCable=new TGeoVolume("FlexCable", kapCable, medFlexCable);
1352       volCable->SetLineColor(28);
1353       volCable->SetFillColor(28); 
1354       //      mechStavVol->AddNode(volCable, 0, new TGeoCombiTrans(x, y-(kConeOutRadius+klay3+klay2+klay4+fSensorThick+(klay5)/2)+0.0002, z, new TGeoRotation("",0, 0, 0)));
1355       mechStavVol->AddNode(volCable, 0, new TGeoCombiTrans(x, y-(kConeOutRadius+klay3+klay2+klay4+fSensorThick+(klay5)/2)+0.01185, z, new TGeoRotation("",0, 0, 0)));
1356       }
1357     // Done, return the stave structe
1358     return mechStavVol;
1359 }
1360
1361 // model3
1362 //________________________________________________________________________
1363 TGeoVolume* AliITSUv0Layer::CreateStaveModel3(const Double_t xsta,
1364                                                const Double_t zsta,
1365                                                const TGeoManager *mgr){
1366 //
1367 // Create the mechanical stave structure for Model 3 of TDR
1368 //
1369 // Input:
1370 //         xsta : X length
1371 //         zsta : Z length
1372 //         mgr  : the GeoManager (used only to get the proper material)
1373 //
1374 // Output:
1375 //
1376 // Return:
1377 //
1378 // Created:      28 May 2013  Chinorat Kobdaj
1379 // Updated:                   Mario Sitta
1380 // Updated:                   Wanchaloem Poonsawat 
1381 //
1382   
1383   // Materials defined in AliITSUv0
1384   TGeoMedium *medAir    = mgr->GetMedium("ITS_AIR$");
1385   TGeoMedium *medWater  = mgr->GetMedium("ITS_WATER$");
1386
1387   TGeoMedium *medM60J3K    = mgr->GetMedium("ITS_M60J3K$"); 
1388   TGeoMedium *medKapton    = mgr->GetMedium("ITS_KAPTON(POLYCH2)$");
1389   TGeoMedium *medGlue      = mgr->GetMedium("ITS_GLUE$");
1390   TGeoMedium *medFlexCable = mgr->GetMedium("ITS_FLEXCABLE$");
1391   //TGeoMedium *medK13D2U2k  = mgr->GetMedium("ITS_K13D2U2k$");
1392   //TGeoMedium *medFGS003    = mgr->GetMedium("ITS_FGS003$"); 
1393   //TGeoMedium *medCarbonFleece = mgr->GetMedium("ITS_CarbonFleece$"); 
1394
1395   // Local parameters
1396     Double_t kConeOutRadius = 0.15/2;
1397     Double_t kStaveLength = zsta*2;
1398     Double_t kStaveWidth = xsta*2;
1399     Double_t w = kStaveWidth/4;//1/2 of W
1400     Double_t staveHeight = 0.3;
1401     Double_t h = staveHeight/2;
1402     Double_t alpha = 90-33.;//90-30;
1403     Double_t the1 = alpha*TMath::DegToRad();
1404     Double_t s1 = w/TMath::Sin(the1);
1405     Double_t l = w/TMath::Tan(the1);
1406     Double_t s2 = TMath::Sqrt(h*h + s1*s1);//TMath::Sin(the2);
1407     Double_t the2 = TMath::ATan(h/s1);
1408     Double_t beta = the2*TMath::RadToDeg();
1409     Double_t klay4 = 0.007; //Glue
1410     Double_t klay5 = 0.01; //Flexcable
1411     Int_t  loop = (kStaveLength/(2*l))/2;
1412     Double_t hh = 0.01;
1413        Double_t ang1 = 0*TMath::DegToRad();
1414        Double_t ang2 = 0*TMath::DegToRad();
1415        Double_t ang3 = 0*TMath::DegToRad();
1416        Int_t chips = 4;
1417        Double_t headWidth=0.25;
1418        Double_t smcLength=kStaveLength/chips-2*headWidth;//6.25;
1419        Double_t smcWidth=kStaveWidth;
1420        Double_t smcSide1Thick=0.03;
1421        Double_t vaporThick=0.032;
1422        Double_t liquidThick=0.028;
1423        Double_t smcSide2Thick=0.01;
1424        Double_t smcSide3Thick=0.0055;
1425        Double_t smcSide4Thick=0.0095;
1426        Double_t smcSide5Thick=0.0075;
1427        Double_t smcSpace=0.01;
1428
1429
1430     char volname[30];
1431     snprintf(volname, 30, "%s%d_StaveStruct", AliITSUGeomTGeo::GetITSStavePattern(), fLayerNumber);
1432     
1433     // detailed structure ++++++++++++++
1434     Double_t z=0, y=0-0.007, x=0;
1435
1436     // Polimide micro channels numbers
1437     Double_t yMC = y-h+0.01;
1438     Int_t nb = (Int_t)(kStaveWidth/0.1)+1;
1439     Double_t xstaMC = (nb*0.1-0.08)/2;
1440
1441
1442     TGeoVolume *mechStavVol = 0;
1443     if (fBuildLevel < 5) {
1444       // world (trapezoid)
1445       TGeoXtru *mechStruct = new TGeoXtru(2); //z sections
1446       Double_t xv[5] = {kStaveWidth/2+0.1,kStaveWidth/2+0.1,0,-kStaveWidth/2-0.1,-kStaveWidth/2-0.1};
1447       Double_t yv[5] = {-kConeOutRadius*2-0.07,0,staveHeight,0,-kConeOutRadius*2-0.07};    
1448       mechStruct->DefinePolygon(5,xv,yv);
1449       mechStruct->DefineSection(0,-kStaveLength-0.1,0,0,1.);
1450       mechStruct->DefineSection(1,kStaveLength+0.1,0,0,1.);
1451       mechStavVol = new TGeoVolume(volname, mechStruct, medAir);
1452       mechStavVol->SetLineColor(12);
1453       mechStavVol->SetFillColor(12); 
1454       mechStavVol->SetVisibility(kTRUE);
1455
1456        // Silicon micro channels numbers
1457       
1458       TGeoBBox *tM0a=new TGeoBBox(smcWidth/2, 0.003/2, headWidth/2);
1459       TGeoVolume *volTM0a=new TGeoVolume("microChanTop1", tM0a, medKapton);
1460       volTM0a->SetLineColor(35);
1461       volTM0a->SetFillColor(35); 
1462
1463       for(Int_t  mo=1; mo<=chips; mo++) {
1464       mechStavVol->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)));
1465       mechStavVol->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)));
1466       }
1467       TGeoBBox *tM0c=new TGeoBBox(0.3/2, 0.003/2,smcLength/2);
1468       TGeoVolume *volTM0c=new TGeoVolume("microChanTop2", tM0c, medKapton);
1469       volTM0c->SetLineColor(35);
1470       volTM0c->SetFillColor(35); 
1471       for(Int_t  mo=1; mo<=chips; mo++) {
1472       mechStavVol->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)));
1473       mechStavVol->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)));
1474       }
1475       TGeoBBox *tM0c1=new TGeoBBox(0.2225/2, 0.003/2,smcLength/2);
1476       TGeoVolume *volTM0c1=new TGeoVolume("microChanBot1", tM0c1, medKapton);
1477       volTM0c1->SetLineColor(6);
1478       volTM0c1->SetFillColor(6); 
1479       for(Int_t  mo=1; mo<=chips; mo++) {
1480       mechStavVol->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)));
1481       mechStavVol->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)));
1482       }
1483       TGeoBBox *tM0c2=new TGeoBBox(0.072/2, 0.003/2,smcLength/2);
1484       TGeoVolume *volTM0c2=new TGeoVolume("microChanBot2", tM0c2, medKapton);
1485       volTM0c2->SetLineColor(35);
1486       volTM0c2->SetFillColor(35); 
1487       for(Int_t  mo=1; mo<=chips; mo++) {
1488       mechStavVol->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)));
1489       }
1490       TGeoBBox *tM0c2r=new TGeoBBox(0.068/2, 0.003/2,smcLength/2);
1491       TGeoVolume *volTM0c2r=new TGeoVolume("microChanBot3", tM0c2r, medKapton);
1492       volTM0c2r->SetLineColor(35);
1493       volTM0c2r->SetFillColor(35); 
1494       for(Int_t  mo=1; mo<=chips; mo++) {      
1495       mechStavVol->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)));
1496       }
1497       TGeoBBox *tM0d=new TGeoBBox(smcSide1Thick/2, 0.035/2,smcLength/2);
1498       TGeoVolume *volTM0d=new TGeoVolume("microChanSide1", tM0d, medKapton);
1499       volTM0d->SetLineColor(12);
1500       volTM0d->SetFillColor(12); 
1501       for(Int_t  mo=1; mo<=chips; mo++) {
1502       mechStavVol->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)));
1503       mechStavVol->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)));
1504       }
1505
1506       TGeoBBox *tM0d1=new TGeoBBox(smcSide2Thick/2, 0.035/2,smcLength/2);
1507       TGeoVolume *volTM0d1=new TGeoVolume("microChanSide2", tM0d1, medKapton);
1508       volTM0d1->SetLineColor(12);
1509       volTM0d1->SetFillColor(12); 
1510       for(Int_t  mo=1; mo<=chips; mo++) {
1511       mechStavVol->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)));
1512       mechStavVol->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)));
1513       }
1514       TGeoBBox *tM0d2=new TGeoBBox(smcSide3Thick/2, (hh+0.003)/2, smcLength/2);
1515       TGeoVolume *volTM0d2=new TGeoVolume("microChanSide3", tM0d2, medKapton);
1516       volTM0d2->SetLineColor(12);
1517       volTM0d2->SetFillColor(12); 
1518       for(Int_t  mo=1; mo<=chips; mo++) {
1519       mechStavVol->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)));
1520       }
1521       TGeoBBox *tM0d2r=new TGeoBBox(smcSide4Thick/2, (hh+0.003)/2, smcLength/2);
1522       TGeoVolume *volTM0d2r=new TGeoVolume("microChanSide4", tM0d2r, medKapton);
1523       volTM0d2r->SetLineColor(12);
1524       volTM0d2r->SetFillColor(12); 
1525       for(Int_t  mo=1; mo<=chips; mo++) {
1526       mechStavVol->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)));
1527       }
1528       TGeoBBox *tM0e=new TGeoBBox(smcSide5Thick/2, hh/2,smcLength/2);
1529       TGeoVolume *volTM0e=new TGeoVolume("microChanSide5", tM0e, medKapton);    
1530       volTM0e->SetLineColor(12);
1531       volTM0e->SetFillColor(12); 
1532       for(Int_t  mo=1; mo<=chips; mo++) {
1533       for (Int_t ie=0;ie<11;ie++) {
1534         mechStavVol->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)));
1535         mechStavVol->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)));
1536          }
1537       }
1538       
1539       TGeoBBox *tM0f=new TGeoBBox(0.02/2, hh/2, smcLength/2);
1540       TGeoVolume *volTM0f=new TGeoVolume("microChanTop3", tM0f, medKapton);
1541       //Double_t smcChannels=12;
1542       Double_t smcCloseWallvapor=smcWidth/2-smcSide1Thick-vaporThick-smcSide2Thick-smcSide3Thick-12*smcSpace-11*smcSide5Thick;
1543       Double_t smcCloseWallliquid=smcWidth/2-smcSide1Thick-liquidThick-smcSide2Thick-smcSide4Thick-12*smcSpace-11*smcSide5Thick;
1544       volTM0f->SetLineColor(12);
1545       volTM0f->SetFillColor(12); 
1546       for(Int_t  mo=1; mo<=chips; mo++) {
1547        mechStavVol->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)));
1548        mechStavVol->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)));
1549       }
1550       //Head(back) microchannel
1551
1552       TGeoBBox *tM0hb=new TGeoBBox(smcWidth/2, 0.025/2, headWidth/2);
1553       TGeoVolume *volTM0hb=new TGeoVolume("microChanHeadBackBottom1", tM0hb, medKapton);
1554       volTM0hb->SetLineColor(4);
1555       volTM0hb->SetFillColor(4); 
1556       for(Int_t  mo=1; mo<=chips; mo++) {
1557       mechStavVol->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)));
1558       mechStavVol->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)));
1559       }
1560       TGeoBBox *tM0h1=new TGeoBBox(smcWidth/2, 0.013/2, 0.05/2);
1561       TGeoVolume *volTM0h1=new TGeoVolume("microChanHeadBackBottom2", tM0h1, medKapton);
1562       volTM0h1->SetLineColor(5);
1563       volTM0h1->SetFillColor(5); 
1564       for(Int_t  mo=1; mo<=chips; mo++) {
1565       mechStavVol->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)));
1566       }
1567       TGeoBBox *tM0h2=new TGeoBBox(smcWidth/2, 0.003/2, 0.18/2);
1568       TGeoVolume *volTM0h2=new TGeoVolume("microChanHeadBackBottom7", tM0h2, medKapton);
1569       volTM0h2->SetLineColor(6);
1570       volTM0h2->SetFillColor(6);
1571       for(Int_t  mo=1; mo<=chips; mo++) {
1572       mechStavVol->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)));
1573       }
1574       TGeoBBox *tM0h3=new TGeoBBox(smcWidth/2, 0.013/2, 0.02/2);
1575       TGeoVolume *volTM0h3=new TGeoVolume("microChanHeadBackBottom3", tM0h3, medKapton);
1576       volTM0h3->SetLineColor(5);
1577       volTM0h3->SetFillColor(5); 
1578       for(Int_t  mo=1; mo<=chips; mo++) {
1579       mechStavVol->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)));
1580       }
1581       TGeoBBox *tM0b1=new TGeoBBox(smcWidth/2, 0.013/2, 0.03/2);
1582       TGeoVolume *volTM0b1=new TGeoVolume("microChanHeadBackBottom4", tM0b1, medKapton);
1583       volTM0b1->SetLineColor(5);
1584       volTM0b1->SetFillColor(5); 
1585       for(Int_t  mo=1; mo<=chips; mo++) {
1586       mechStavVol->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)));
1587       }
1588       TGeoBBox *tM0b2=new TGeoBBox(smcWidth/2, 0.003/2, 0.2/2);
1589       TGeoVolume *volTM0b2=new TGeoVolume("microChanHeadBackBottom5", tM0b2, medKapton);
1590       volTM0b2->SetLineColor(6);
1591       volTM0b2->SetFillColor(6); 
1592       for(Int_t  mo=1; mo<=chips; mo++) {
1593       mechStavVol->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)));
1594       }
1595       TGeoBBox *tM0b3=new TGeoBBox(smcWidth/2, 0.013/2, 0.02/2);
1596       TGeoVolume *volTM0b3=new TGeoVolume("microChanHeadBackBottom6", tM0b3, medKapton);
1597       volTM0b3->SetLineColor(5);
1598       volTM0b3->SetFillColor(5); 
1599       for(Int_t  mo=1; mo<=chips; mo++) {
1600       mechStavVol->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)));
1601       }
1602      
1603       TGeoBBox *tM0b=new TGeoBBox(0.02/2, 0.02/2, zsta);
1604       TGeoVolume *volTM0b=new TGeoVolume("microChanWalls", tM0b, medKapton);
1605       volTM0b->SetLineColor(35);
1606       volTM0b->SetFillColor(35); 
1607       for (Int_t ib=0;ib<nb;ib++) {
1608         //mechStavVol->AddNode(volTM0b, ib, new TGeoCombiTrans(x+ib*0.1-xstaMC+0.01,yMC, z, new TGeoRotation("",0, 0, 0)));
1609       }
1610       
1611       } 
1612     
1613     if (fBuildLevel < 4) {
1614
1615       //**********cooling  inlet outlet
1616
1617       TGeoBBox *tM0dv=new TGeoBBox(vaporThick/2, 0.035/2,smcLength/2);
1618       TGeoVolume *volTM0dv=new TGeoVolume("microChanVapor", tM0dv, medWater);
1619       volTM0dv->SetLineColor(2);
1620       volTM0dv->SetFillColor(2);
1621       for(Int_t  mo=1; mo<=chips; mo++) {
1622       mechStavVol->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)));
1623       }
1624       TGeoBBox *tM0dl=new TGeoBBox(liquidThick/2, 0.035/2,smcLength/2);
1625       TGeoVolume *volTM0dl=new TGeoVolume("microChanLiquid", tM0dl, medWater);
1626       volTM0dl->SetLineColor(3);
1627       volTM0dl->SetFillColor(3); 
1628       for(Int_t  mo=1; mo<=chips; mo++) {
1629       mechStavVol->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)));
1630       }
1631       // small cooling fluid now using water wait for freeon value  
1632       TGeoBBox *tM0dlq=new TGeoBBox(smcSpace/2, hh/2,smcLength/2);
1633       TGeoVolume *volTM0dlq=new TGeoVolume("smallLiquid", tM0dlq, medWater);
1634       volTM0dlq->SetLineColor(3);
1635       volTM0dlq->SetFillColor(3); 
1636       TGeoBBox *tM0dvp=new TGeoBBox(smcSpace/2, hh/2,smcLength/2);
1637       TGeoVolume *volTM0dvp=new TGeoVolume("microChanVapor", tM0dvp, medWater);
1638       volTM0dvp->SetLineColor(2);
1639       volTM0dvp->SetFillColor(2); 
1640       for(Int_t  mo=1; mo<=chips; mo++) {
1641       for (Int_t is=0;is<12;is++) {
1642         mechStavVol->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)));
1643         mechStavVol->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)));
1644       }
1645       }
1646
1647       //*************
1648
1649     }
1650     
1651     if (fBuildLevel < 3) {
1652
1653       //Bottom filament CFRP black-12 Carbon structure TGeoBBox (thickness,width,length)
1654  
1655       Double_t filWidth = 0.04;
1656       Double_t filHeight= 0.02;
1657       TGeoBBox *t1=new TGeoBBox(filHeight/2,filWidth/2,s1);
1658       TGeoVolume *volT1=new TGeoVolume("bottomFilament", t1, medM60J3K);
1659       volT1->SetLineColor(12);
1660       volT1->SetFillColor(12); 
1661       for(int i=0;i<loop;i++){//i<30;i++){
1662         mechStavVol->AddNode(volT1,4*i+0,
1663                                     new TGeoCombiTrans(x+w,y-h+0.04+filHeight/2,z-kStaveLength/2+(4*l*i)+s1/2, 
1664                                                        new TGeoRotation("volT1",-90,alpha,0)));
1665         mechStavVol->AddNode(volT1,4*i+1,
1666                                     new TGeoCombiTrans(x-w,y-h+0.04+filHeight/2,z-kStaveLength/2+(4*l*i)+s1/2, 
1667                                                        new TGeoRotation("volT1",90,alpha,0)));
1668         mechStavVol->AddNode(volT1,4*i+2,
1669                                     new TGeoCombiTrans(x+w,y-h+0.04+filHeight/2,z-kStaveLength/2+2*l+(i*4*l)+s1/2, 
1670                                                        new TGeoRotation("volT1",-90,-alpha,0)));
1671         mechStavVol->AddNode(volT1,4*i+3,
1672                                     new TGeoCombiTrans(x-w,y-h+0.04+filHeight/2,z-kStaveLength/2+2*l+(i*4*l)+s1/2, 
1673                                                        new TGeoRotation("volT1",-90,+alpha,0)));
1674         }
1675  
1676      // Top filament CERP black-12 Carbon structure TGeoBBox (length,thickness,width)
1677
1678       TGeoBBox *t2=new TGeoBBox(s2,filHeight/2,filWidth/2);
1679       TGeoVolume *volT2=new TGeoVolume("topFilament", t2, medM60J3K);
1680       volT2->SetLineColor(12);
1681       volT2->SetFillColor(12); 
1682       for(int i=0;i<loop;i++){ //i<30;i++){
1683         mechStavVol->AddNode(volT2,4*i+0,
1684                                     new TGeoCombiTrans(x+w,y+0.04+filHeight/2,z-kStaveLength/2+(i*4*l)+s1/2,
1685                                                        new TGeoRotation("volT2",90,90-alpha,90-beta)));
1686         mechStavVol->AddNode(volT2,4*i+1,
1687                                     new TGeoCombiTrans(x-w,y+0.04+filHeight/2,z-kStaveLength/2+(i*4*l)+s1/2,
1688                                                        new TGeoRotation("volT2",90,-90+alpha,-90+beta)));
1689         mechStavVol->AddNode(volT2,4*i+2,
1690                                     new TGeoCombiTrans(x+w,y+0.04+filHeight/2,z-kStaveLength/2+2*l+(i*4*l)+s1/2,
1691                                                        new TGeoRotation("volT2",90,-90+alpha,90-beta)));
1692         mechStavVol->AddNode(volT2,4*i+3,
1693                                     new TGeoCombiTrans(x-w,y+0.04+filHeight/2,z-kStaveLength/2+2*l+(i*4*l)+s1/2, 
1694                                                        new TGeoRotation("volT2",90,90-alpha,-90+beta)));
1695         }
1696     }
1697
1698     if (fBuildLevel < 2) {
1699
1700       // Glue Filament and Silicon MicroChannel
1701       TGeoBBox *tM0=new TGeoBBox(xstaMC/5, klay4/2, zsta);
1702       TGeoVolume *volTM0=new TGeoVolume("glueFM", tM0,medGlue );
1703       volTM0->SetLineColor(5);
1704       volTM0->SetFillColor(5); 
1705       mechStavVol->AddNode(volTM0, 0, new TGeoCombiTrans(x-xsta/2-0.25,0.03+yMC, z, new TGeoRotation("",0, 0, 0)));
1706       mechStavVol->AddNode(volTM0, 1, new TGeoCombiTrans(x+xsta/2+0.25,0.03+yMC, z, new TGeoRotation("",0, 0, 0)));
1707
1708             
1709       // Glue microchannel and sensor
1710       TGeoBBox *glueM = new TGeoBBox(xstaMC/5, klay4/2, zsta);
1711       TGeoVolume *volGlueM=new TGeoVolume("glueMS", glueM, medGlue);
1712       volGlueM->SetLineColor(5);
1713       volGlueM->SetFillColor(5); 
1714       mechStavVol->AddNode(volGlueM, 0, new TGeoCombiTrans(x-xsta/2-0.25,yMC-0.01, z, new TGeoRotation("",0, 0, 0)));
1715       mechStavVol->AddNode(volGlueM, 1, new TGeoCombiTrans(x+xsta/2+0.25,yMC-0.01, z, new TGeoRotation("",0, 0, 0)));
1716      
1717        // Glue sensor and kapton
1718       TGeoBBox *glue = new TGeoBBox(xsta, klay4/2, zsta);
1719       TGeoVolume *volGlue=new TGeoVolume("glueSensorBus", glue, medGlue);
1720       volGlue->SetLineColor(5);
1721       volGlue->SetFillColor(5); 
1722        mechStavVol->AddNode(volGlue, 1, new TGeoCombiTrans(x, y-0.154-fSensorThick-klay4/2, z, new TGeoRotation("",0, 0, 0)));
1723     }      
1724
1725     if (fBuildLevel < 1) {
1726       TGeoBBox *kapCable = new TGeoBBox(xsta, klay5/2, zsta);
1727       TGeoVolume *volCable=new TGeoVolume("Flexcable", kapCable, medFlexCable);
1728       volCable->SetLineColor(28);
1729       volCable->SetFillColor(28); 
1730       mechStavVol->AddNode(volCable, 0, new TGeoCombiTrans(x, y-0.154-fSensorThick-klay4-klay5/2, z, new TGeoRotation("",0, 0, 0)));
1731     }
1732
1733   // Done, return the stave structur
1734     return mechStavVol;
1735  }
1736
1737 //________________________________________________________________________
1738 TGeoVolume* AliITSUv0Layer::CreateChip(const Double_t xsta,
1739                                          const Double_t ysta,   
1740                                          const Double_t zsta,
1741                                          const TGeoManager *mgr){
1742 //
1743 // Creates the actual Chip
1744 //
1745 // Input:
1746 //         xsta,zsta : the stave dimensions
1747 //         mgr  : the GeoManager (used only to get the proper material)
1748 //
1749 // Output:
1750 //
1751 // Return:
1752 //
1753 // Created:      22 Jun 2011  Mario Sitta
1754 //
1755
1756   char volname[30];
1757   Double_t xlen, ylen, zlen;
1758   Double_t xpos, ypos, zpos;
1759
1760
1761   // First create all needed shapes
1762
1763   // The chip
1764   TGeoBBox *chip = new TGeoBBox(xsta,  ysta, zsta/fNChips);
1765
1766   // The sensor
1767   xlen = chip->GetDX();
1768   ylen = 0.5*fSensorThick;
1769   zlen = chip->GetDZ();
1770   TGeoBBox *sensor = new TGeoBBox(xlen, ylen, zlen);
1771
1772
1773   // We have all shapes: now create the real volumes
1774   //TGeoMedium *medAir = mgr->GetMedium("ITS_AIR$");
1775   TGeoMedium *medSi  = mgr->GetMedium("ITS_SI$");
1776
1777   snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSChipPattern(), fLayerNumber);
1778   // TGeoVolume *modVol = new TGeoVolume(volname, chip, medAir);
1779   TGeoVolume *modVol = new TGeoVolume(volname, chip, medSi);
1780   modVol->SetVisibility(kTRUE);
1781   modVol->SetLineColor(1);
1782
1783   snprintf(volname, 30, "%s%d", AliITSUGeomTGeo::GetITSSensorPattern(), fLayerNumber);
1784   TGeoVolume *sensVol = new TGeoVolume(volname, sensor, medSi);
1785   sensVol->SetVisibility(kTRUE);
1786   sensVol->SetLineColor(8);
1787   sensVol->SetLineWidth(1);
1788   sensVol->SetFillColor(sensVol->GetLineColor());
1789   sensVol->SetFillStyle(4000); // 0% transparent
1790
1791
1792   // Now build up the chip
1793   xpos = 0.;
1794   ypos = -chip->GetDY() + sensor->GetDY();
1795   zpos = 0.;
1796
1797   modVol->AddNode(sensVol, 1, new TGeoTranslation(xpos, ypos, zpos));
1798
1799   // Done, return the chip
1800   return modVol;
1801 }
1802
1803 //________________________________________________________________________
1804 Double_t AliITSUv0Layer::RadiusOfTurboContainer(){
1805 //
1806 // Computes the inner radius of the air container for the Turbo configuration
1807 // as the radius of either the circle tangent to the stave or the circle
1808 // passing for the stave's lower vertex
1809 //
1810 // Input:
1811 //         none (all needed parameters are class members)
1812 //
1813 // Output:
1814 //
1815 // Return:
1816 //        the radius of the container if >0, else flag to use the lower vertex
1817 //
1818 // Created:      08 Mar 2012  Mario Sitta
1819 //
1820
1821   Double_t rr, delta, z, lstav, rstav;
1822
1823   if (fStaveThick > 89.) // Very big angle: avoid overflows since surely
1824     return -1;            // the radius from lower vertex is the right value
1825
1826   rstav = fLayRadius + 0.5*fStaveThick;
1827   delta = (0.5*fStaveThick)/CosD(fStaveTilt);
1828   z     = (0.5*fStaveThick)*TanD(fStaveTilt);
1829
1830   rr = rstav - delta;
1831   lstav = (0.5*fStaveWidth) - z;
1832
1833   if ( (rr*SinD(fStaveTilt) < lstav) )
1834     return (rr*CosD(fStaveTilt));
1835   else
1836     return -1;
1837 }
1838
1839 //________________________________________________________________________
1840 void AliITSUv0Layer::SetStaveTilt(const Double_t t)
1841 {
1842 //
1843 // Sets the Stave tilt angle (for turbo layers only)
1844 //
1845 // Input:
1846 //         t :  the stave tilt angle
1847 //
1848 // Output:
1849 //
1850 // Return:
1851 //
1852 // Created:      08 Jul 2011  Mario Sitta
1853 //
1854
1855   if (fIsTurbo)
1856     fStaveTilt = t;
1857   else
1858     AliError("Not a Turbo layer");
1859
1860 }
1861
1862 //________________________________________________________________________
1863 void AliITSUv0Layer::SetStaveWidth(const Double_t w){
1864 //
1865 // Sets the Stave width (for turbo layers only)
1866 //
1867 // Input:
1868 //         w :  the stave width
1869 //
1870 // Output:
1871 //
1872 // Return:
1873 //
1874 // Created:      08 Jul 2011  Mario Sitta
1875 //
1876
1877   if (fIsTurbo)
1878     fStaveWidth = w;
1879   else
1880     AliError("Not a Turbo layer");
1881
1882 }