]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSv11.cxx
Fixes in order to eliminate compilation warnings
[u/mrichter/AliRoot.git] / ITS / AliITSv11.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //////////////////////////////////////////////////////////////////////////////
19 //                                                                          //
20 //  Inner Traking System version 11                                         //
21 //  This class contains the base procedures for the Inner Tracking System   //
22 //                                                                          //
23 // Authors: R. Barbera                                                      //
24 // version 6.                                                               //
25 // Created  2000.                                                           //
26 //                                                                          //
27 //  NOTE: THIS IS THE  SYMMETRIC PPR geometry of the ITS.                   //
28 // THIS WILL NOT WORK                                                       //
29 // with the geometry or module classes or any analysis classes. You are     //
30 // strongly encouraged to uses AliITSv5.                                    //
31 //                                                                          //
32 //////////////////////////////////////////////////////////////////////////////
33 // See AliITSv11::StepManager().
34 // General C/C++ includes
35 #include <stdio.h>
36 #include <stdlib.h>
37 // General Root includes
38 #include <Riostream.h>
39 #include <TMath.h>
40 #include <TFile.h>    // only required for Tracking function?
41 #include <TObjArray.h>
42 #include <TClonesArray.h>
43 #include <TLorentzVector.h>
44 #include <TObjString.h>
45 // Root Geometry includes
46 #include <TGeoManager.h>
47 #include <TGeoPcon.h>
48 #include <TGeoTube.h>
49 #include <TGeoNode.h>
50 #include <TGeoMaterial.h>
51 // General AliRoot includes
52 #include "AliRun.h"
53 #include "AliMagF.h"
54 #include "AliConst.h"
55 // ITS specific includes
56 #include "AliITShit.h"
57 #include "AliITSgeom.h"
58 #include "AliITSgeomSPD.h"
59 #include "AliITSgeomSDD.h"
60 #include "AliITSgeomSSD.h"
61 #include "AliITSDetType.h"
62 #include "AliITSresponseSPD.h"
63 #include "AliITSresponseSDD.h"
64 #include "AliITSresponseSSD.h"
65 #include "AliITSsegmentationSPD.h"
66 #include "AliITSsegmentationSDD.h"
67 #include "AliITSsegmentationSSD.h"
68 #include "AliITSsimulationSPD.h"
69 #include "AliITSsimulationSDD.h"
70 #include "AliITSsimulationSSD.h"
71 #include "AliITSClusterFinderSPD.h"
72 #include "AliITSClusterFinderSDD.h"
73 #include "AliITSClusterFinderSSD.h"
74 #include "AliITSBaseGeometry.h"
75 #include "AliITSv11.h"
76
77 // Units, Convert from k?? to cm,degree,GeV,seconds,
78 const Double_t kmm = 0.10; // Convert mm to TGeom's cm.
79 const Double_t kcm = 1.00; // Convert cv to TGeom's cm.
80
81 ClassImp(AliITSv11)
82
83 /*
84   Some temparary #define's used untill ROOT has addoppted the proper
85   Getter in it's classes.
86   These Below are for TGeoPcon functions.
87 */
88
89 //______________________________________________________________________
90 AliITSv11::AliITSv11() : AliITS() {
91     // Standard default constructor for the ITS version 11.
92     // Inputs:
93     //   none.
94     // Outputs:
95     //   none.
96     // Return
97     //   A default constructed AliITSv11 class.
98
99     //fITSV = 0;
100     //fcS = 0;
101 //   fcD = 0;
102 }
103 //______________________________________________________________________
104 AliITSv11::AliITSv11(const char *title) : AliITS("ITS", title){
105     // Standard constructor for the ITS version 11.
106     // Inputs:
107     //   const char *title  The title of for this geometry.
108     // Outputs:
109     //   none.
110     // Return
111     //   A Standard constructed AliITSv11 class.
112
113     //fITSV = 0;
114     //fcS = 0;
115 //    fcD = 0;
116 }
117 //______________________________________________________________________
118 AliITSv11::~AliITSv11() {
119     // Standard destructor for the ITS version 11.
120     // Inputs:
121     //   none.
122     // Outputs:
123     //   none.
124     // Return
125     //   none.
126
127 //    if(fITSV!=0) delete fITSV;
128 //    if(fcS!=0) delete fcS;
129 //    if(fcD!=0) delete fcD;
130 }
131 //______________________________________________________________________
132 AliITSv11::AliITSv11(const AliITSv11 &source) : AliITS(source){
133     //     Copy Constructor for ITS version 11.
134     // Inputs:
135     //   AliITSv11 &source  class to be copied from.
136     // Outputs:
137     //   none.
138     // Return
139     //   none.
140
141     if(&source == this) return;
142     Error("Copy Constructor","Not allowed to copy AliITSv11");
143     return;
144 }
145 //______________________________________________________________________
146 AliITSv11& AliITSv11::operator=(const AliITSv11 &source){
147     //    Assignment operator for the ITS version 11.
148     // Inputs:
149     //   AliITSv11 &source  class to be copied from.
150     // Outputs:
151     //   none.
152     // Return
153     //   none.
154
155     if(&source == this) return *this;
156     Error("= operator","Not allowed to copy AliITSv11");
157     return *this;
158 }
159 //______________________________________________________________________
160 void AliITSv11::BuildGeometry(){
161     // This routine defines and Creates the geometry for version 11 of 
162     // the ITS for use in the simulation display routines. This is a 
163     // very simplified geometry for speed of viewing.
164     // Inputs:
165     //   none.
166     // Outputs:
167     //   none.
168     // Return
169     //   none.
170     TVector3 t(0.0,0.0,0.0);
171
172     //if(fITSV==0) fITSV = new AliITSGeometryITSV(this,"ALIC");
173     //if(fcS==0) fcS = new AliITSGeometrySSDCone(this,t,"TSV",1);
174
175     //fcS->BuildDisplayGeometry();
176 }
177 //______________________________________________________________________
178 void AliITSv11::CreateGeometry(){
179     // This routine defines and Creates the geometry for version 11 of 
180     // the ITS. The geometry is used by the particle trasport routines,
181     // and therefore, is very detailed.
182     // Inputs:
183     //   none.
184     // Outputs:
185     //   none.
186     // Return
187     //   none.
188     TVector3 t(0.0,0.0,0.0);
189
190     TGeoManager *mgr = gGeoManager;
191     TGeoVolume *ALIC = mgr->GetTopVolume();
192
193     TGeoPcon *itsv = new TGeoPcon("ITS Top Volume, Daughter of ALIC",0.0,360.0,2);
194     // DefineSection(section number, Z, Rmin, Rmax).
195     itsv->DefineSection(0,-100.0*kcm,0.01*kcm,50.0*kcm);
196     itsv->DefineSection(1,+100.0*kcm,0.01*kcm,50.0*kcm);
197     TGeoVolume *ITSV = new TGeoVolume("ITSV",itsv,0);
198     //mgr->AddVolume(ITSV);
199     ITSV->SetVisibility(kFALSE);
200     ALIC->AddNode(ITSV,1,0);
201     //
202     SSDCone(ITSV);
203 }
204 //______________________________________________________________________
205 Double_t AliITSv11::RmaxFrom2Points(TGeoPcon *p,Int_t i1,Int_t i2,Double_t z){
206     // functions Require at parts of Volume A to be already defined.
207     // Retruns the value of Rmax corresponding to point z alone the line
208     // defined by the two points p.Rmax(i1),p-GetZ(i1) and p->GetRmax(i2),
209     // p->GetZ(i2).
210
211     return p->GetRmax(i2)+(p->GetRmax(i1)-p->GetRmax(i2))*(z-p->GetZ(i2))/
212         (p->GetZ(i1)-p->GetZ(i2));
213 }
214 //______________________________________________________________________
215 Double_t AliITSv11::RminFrom2Points(TGeoPcon *p,Int_t i1,Int_t i2,Double_t z){
216     // Retruns the value of Rmin corresponding to point z alone the line
217     // defined by the two points p->GetRmin(i1),p->GetZ(i1) and p->GetRmin(i2),
218     // p->GetZ(i2).
219
220     return p->GetRmin(i2)+(p->GetRmin(i1)-p->GetRmin(i2))*(z-p->GetZ(i2))/
221         (p->GetZ(i1)-p->GetZ(i2));
222 }
223 //______________________________________________________________________
224 Double_t AliITSv11::RFrom2Points(Double_t *p,Double_t *Z,Int_t i1,Int_t i2,Double_t z){
225     // Retruns the value of Rmin corresponding to point z alone the line
226     // defined by the two points p->GetRmin(i1),p->GetZ(i1) and p->GetRmin(i2),
227     // p->GetZ(i2).
228
229     return p[i2]+(p[i1]-p[i2])*(z-Z[i2])/(Z[i1]-Z[i2]);
230 }
231 //______________________________________________________________________
232 Double_t AliITSv11::Zfrom2MinPoints(TGeoPcon *p,Int_t i1,Int_t i2,Double_t r){
233     // Retruns the value of Z corresponding to point R alone the line
234     // defined by the two points p->GetRmin(i1),p->GetZ(i1) and 
235     // p->GetRmin(i2),p->GetZ(i2)
236
237     return p->GetZ(i2)+(p->GetZ(i1)-p->GetZ(i2))*(r-p->GetRmin(i2))/
238         (p->GetRmin(i1)-p->GetRmin(i2));
239 }
240 //______________________________________________________________________
241 Double_t AliITSv11::Zfrom2MaxPoints(TGeoPcon *p,Int_t i1,Int_t i2,Double_t r){
242     // Retruns the value of Z corresponding to point R alone the line
243     // defined by the two points p->GetRmax(i1),p->GetZ(i1) and 
244     // p->GetRmax(i2),p->GetZ(i2)
245
246     return p->GetZ(i2)+(p->GetZ(i1)-p->GetZ(i2))*(r-p->GetRmax(i2))/
247         (p->GetRmax(i1)-p->GetRmax(i2));
248 }
249 //______________________________________________________________________
250 Double_t AliITSv11::Zfrom2Points(Double_t *Z,Double_t *p,Int_t i1,Int_t i2,Double_t r){
251     // Retruns the value of Z corresponding to point R alone the line
252     // defined by the two points p->GetRmax(i1),p->GetZ(i1) and 
253     // p->GetRmax(i2),p->GetZ(i2)
254
255     return Z[i2]+(Z[i1]-Z[i2])*(r-p[i2])/(p[i1]-p[i2]);
256 }
257 //______________________________________________________________________
258 Double_t AliITSv11::RmaxFromZpCone(TGeoPcon *p,Double_t tc,Double_t z,Double_t th){
259     // General SSD Outer Cone surface equation Rmax.
260     Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
261     Double_t costc = TMath::Cos(tc*TMath::DegToRad());
262
263     return -tantc*(z-p->GetZ(4))+p->GetRmax(4)+th/costc;
264 }
265 //______________________________________________________________________
266 Double_t AliITSv11::RmaxFromZpCone(Double_t *GetRmax,Double_t *GetZ,Double_t tc,Double_t z,Double_t th){
267     // General SSD Outer Cone surface equation Rmax.
268     Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
269     Double_t costc = TMath::Cos(tc*TMath::DegToRad());
270
271     return -tantc*(z-GetZ[4])+GetRmax[4]+th/costc;
272 }
273 //______________________________________________________________________
274 Double_t AliITSv11::RminFromZpCone(TGeoPcon *p,Double_t tc,Double_t z,Double_t th){
275     // General SSD Inner Cone surface equation Rmin.
276     Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
277     Double_t costc = TMath::Cos(tc*TMath::DegToRad());
278
279     return -tantc*(z-p->GetZ(3))+p->GetRmin(3)+th/costc;
280 }
281 //______________________________________________________________________
282 Double_t AliITSv11::RminFromZpCone(Double_t *GetRmin,Double_t *GetZ,Double_t tc,Double_t z,Double_t th){
283     // General SSD Inner Cone surface equation Rmin.
284     Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
285     Double_t costc = TMath::Cos(tc*TMath::DegToRad());
286
287     return -tantc*(z-GetZ[3])+GetRmin[3]+th/costc;
288 }
289 //______________________________________________________________________
290 Double_t AliITSv11::ZFromRmaxpCone(TGeoPcon *p,Double_t tc,Double_t r,Double_t th){
291     // General SSD Outer cone Surface equation for z.
292     Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
293     Double_t costc = TMath::Cos(tc*TMath::DegToRad());
294
295     return p->GetZ(4)+(p->GetRmax(4)+th/costc-r)/tantc;
296 }
297 //______________________________________________________________________
298 Double_t AliITSv11::ZFromRmaxpCone(Double_t *GetRmax,Double_t *GetZ,Double_t tc,Double_t r,Double_t th){
299     // General SSD Outer cone Surface equation for z.
300     Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
301     Double_t costc = TMath::Cos(tc*TMath::DegToRad());
302
303     return GetZ[4]+(GetRmax[4]+th/costc-r)/tantc;
304 }
305 //______________________________________________________________________
306 Double_t AliITSv11::ZFromRminpCone(TGeoPcon *p,Double_t tc,Double_t r,Double_t th){
307     // General SSD Inner cone Surface equation for z.
308     Double_t tantc = TMath::Tan(tc*TMath::DegToRad());
309     Double_t costc = TMath::Cos(tc*TMath::DegToRad());
310
311     return p->GetZ(3)+(p->GetRmin(3)+th/costc-r)/tantc;
312 }
313 //______________________________________________________________________
314 void AliITSv11::RadiusOfCurvature(Double_t rc,Double_t theta0,Double_t z0,
315                        Double_t r0,Double_t theta1,Double_t &z1,
316                        Double_t &r1){
317     // Given a initial point z0,r0, the initial angle theta0, and the radius
318     // of curvature, returns the point z1, r1 at the angle theta1. Theta
319     // measured from the r axis in the clock wise direction [degrees].
320     Double_t sin0 = TMath::Sin(theta0*TMath::DegToRad());
321     Double_t cos0 = TMath::Cos(theta0*TMath::DegToRad());
322     Double_t sin1 = TMath::Sin(theta1*TMath::DegToRad());
323     Double_t cos1 = TMath::Cos(theta1*TMath::DegToRad());
324
325     z1 = rc*(sin1-sin0)+z0;
326     r1 = rc*(cos1-cos0)+r0;
327     return;
328 }
329 //______________________________________________________________________
330 void AliITSv11::SPDCone(TGeoVolume *Moth){
331     // Define the detail SPD support cone geometry.
332     // Inputs:
333     //   none.
334     // Outputs:
335     //  none.
336     // Return:
337     //  none.
338 }
339 //______________________________________________________________________
340 void AliITSv11::SDDCone(TGeoVolume *Moth){
341     // Define the detail SDD support cone geometry.
342     // Inputs:
343     //   none.
344     // Outputs:
345     //  none.
346     // Return:
347     //  none.
348
349 //______________________________________________________________________
350 void AliITSv11::SSDCone(TGeoVolume *Moth){
351     // Define the detail SSD support cone geometry.
352     // Inputs:
353     //   none.
354     // Outputs:
355     //  none.
356     // Return:
357     //  none.
358     const Double_t Thickness = 13.0*kmm; // Thickness of Rohacell+carbon fiber
359     const Double_t Cthick    = 1.5*kmm; // Carbon finber thickness
360     const Double_t Rcurv     = 15.0*kmm; // Radius of curvature.
361     const Double_t Tc        = 51.0; // angle of SSD cone [degrees].
362     const Double_t Sintc = TMath::Sin(Tc*TMath::DegToRad());
363     const Double_t Costc = TMath::Cos(Tc*TMath::DegToRad());
364     const Double_t Tantc = TMath::Tan(Tc*TMath::DegToRad());
365     const Double_t ZouterMilled = (13.5-5.0)*kmm;
366     const Double_t Zcylinder    = 170.0*kmm;
367     const Double_t Z0           = Zcylinder + 100.0*kmm;
368     const Int_t Nspoaks         = 12;
369     const Int_t Nmounts         = 4;
370     const Double_t DmountAngle  = 9.0; // degrees
371     const Double_t RoutMax      = 0.5*985.0*kmm;
372     const Double_t RoutHole     = 0.5*965.0*kmm;
373     const Double_t RoutMin      = 0.5*945.0*kmm;
374     const Double_t RholeMax     = 0.5*890.0*kmm;
375     const Double_t RholeMin     = 0.5*740.0*kmm;
376     const Double_t RpostMin     = 316.0*kmm;
377     const Double_t ZpostMax     = 196.0*kmm;
378     const Int_t Nposts          = 6;
379     const Double_t Phi0Post     = 0.0; // degree
380     const Double_t dRpost       = 23.0*kmm;
381     const Double_t RinMax       = 0.5*590.0*kmm;
382     const Double_t RinCylinder  = 0.5*597.0*kmm;
383     const Double_t RinHole      = 0.5*575.0*kmm;
384     const Double_t RinMin       = 0.5*562.0*kmm;
385     const Double_t dZin         = 15.0*kmm;
386     // SSD-SDD Thermal/Mechanical cylinder mounts
387     const Int_t NinScrews          = 40;
388     const Double_t Phi0Screws      = 0.5*360.0/((const Double_t)NinScrews);//d
389     const Double_t RcylinderScrews = 0.5*570.0*kmm;//from older drawing????
390     const Double_t DscrewHead      = 8.0*kmm;
391     const Double_t DscrewShaft     = 4.6*kmm;
392     const Double_t ThScrewHeadHole = 8.5*kmm;
393     // SDD mounting bracket, SSD part
394     const Double_t NssdSupports      = 3;// mounting of U and T
395     const Double_t DssdsddBracketAngle = 9.0; // degrees
396     const Double_t Phi0SDDsupports   = 0.0; // degree
397     const Double_t RsddSupportPlate  = 0.5*585.0*kmm;
398     const Double_t ThSDDsupportPlate = 4.0*kmm;
399     const Double_t WsddSupportPlate  = 70.0*kmm;
400     TGeoMedium *SSDcf  = 0; // SSD support cone Carbon Fiber materal number.
401     TGeoMedium *SSDfs  = 0; // SSD support cone inserto stesalite 4411w.
402     TGeoMedium *SSDfo  = 0; // SSD support cone foam, Rohacell 50A.
403     TGeoMedium *SSDss  = 0; // SSD support cone screw material,Stainless steal
404     TGeoMedium *SSDair = 0; // SSD support cone Air
405     TGeoMedium *SSDal  = 0; // SSD support cone SDD mounting bracket Al
406
407     // Lets start with the upper left outer carbon fiber surface.
408     // Between za[2],rmaxa[2] and za[4],rmaxa[4] there is a curved section
409     // given by rmaxa = rmaxa[2]-r*Sind(t) for 0<=t<=Tc and 
410     // za = za[2] + r*Cosd(t) for 0<=t<=Tc. Simularly between za[1],rmina[1
411     // and za[3],rmina[3] there is a curve section given by
412     // rmina = rmina[1]-r*Sind(t) for 0<=t<=Tc and za = za[1]+r&Sind(t)
413     // for t<=0<=Tc. These curves have been replaced by straight lines
414     // between the equivelent points for simplicity.
415     Double_t dza = Thickness/Sintc-(RoutMax-RoutMin)/Tantc;
416     Int_t i,j;
417     Double_t z[9],rn[9],rx[9],phi,dphi;
418     Double_t t,t0,Z,Rmin,Rmax; // Temp variables.
419     if(dza<=0){ // The number or order of the points are in error for a proper
420         // call to pcons!
421         Error("SSDcone","The definition of the points for a call to PCONS is"
422               " in error. abort.");
423         return;
424     } // end if
425     // Poly-cone Volume A. Top part of SSD cone Carbon Fiber.
426     phi   = 0.0;
427     dphi  = 360.0;
428     z[0]  = 0.0;
429     rn[0] = RoutMin;
430     rx[0] = RoutMax;
431     z[1]  = z[0]+ZouterMilled - dza; // za[2] - dza.
432     rn[1] = rn[0];
433     rx[1] = rx[0];
434     z[2]  = z[0]+ZouterMilled;//From Drawing ALR-0767 and ALR-0767/3
435     rx[2] = rx[0];
436     RadiusOfCurvature(Rcurv,0.,z[1],rn[1],Tc,z[3],rn[3]);
437     rn[2] = RFrom2Points(rn,z,3,1,z[2]);
438     RadiusOfCurvature(Rcurv,0.,z[2],rx[2],Tc,z[4],rx[4]);
439     rn[4] = RminFromZpCone(rn,z,Tc,z[4]);
440     rx[3] = RFrom2Points(rx,z,4,2,z[3]);
441     rn[5] = RholeMax;
442     z[5]  = Zfrom2Points(z,rn,4,3,rn[5]);
443     rx[5] = RmaxFromZpCone(rx,z,Tc,z[5]);
444     rn[6] = RholeMax;
445     rx[6] = rn[6];
446     z[6]  = ZFromRmaxpCone(rx,z,Tc,rx[6]);
447     TGeoPcon *A = new TGeoPcon("ITS SSD Suport cone Carbon Fiber "
448                                    "Surface outer left",phi,dphi,7);
449     for(i=0;i<A->GetNz();i++){
450         if(fDebug) cout<<i<<"A: z="<<z[i]<<" Rmin="<<rn[i]<<" Rmax="<<rx[i]<<endl;
451         A->DefineSection(i,z[i],rn[i],rx[i]);
452     } // end for i
453     //
454     // Poly-cone Volume B. Stesalite inside volume A.
455     // Now lets define the Inserto Stesalite 4411w material volume.
456     phi   = 0.0;
457     dphi  = 360.0;
458     z[0]  = A->GetZ(0);
459     rn[0] = A->GetRmin(0)+Cthick;
460     rx[0] = A->GetRmax(0)-Cthick;
461     z[1]  = A->GetZ(1);
462     rn[1] = rn[0];
463     rx[1] = rx[0];
464     z[2]  = A->GetZ(2);
465     rx[2] = rx[1];
466     RadiusOfCurvature(Rcurv-Cthick,0.,z[2],rx[2],Tc,z[3],rx[3]);
467     RadiusOfCurvature(Rcurv+Cthick,0.,z[1],rn[1],Tc,z[4],rn[4]);
468     rn[2] = RFrom2Points(rn,z,4,1,z[2]);
469     rn[3] = RFrom2Points(rn,z,4,1,z[3]);
470     z[5]  = z[4]+(Thickness-2.0*Cthick)/Sintc;
471     rn[5] = RmaxFromZpCone(A,Tc,z[5],-Cthick);
472     rx[5] = rn[5];
473     rx[4] = RFrom2Points(rx,z,5,3,z[4]);
474     TGeoPcon *B = new TGeoPcon("ITS SSD Suport cone Inserto Stesalite "
475                                    "left edge",phi,dphi,6);
476     for(i=0;i<B->GetNz();i++){
477         if(fDebug) cout<<i<<"B: z="<<z[i]<<" Rmin="<<rn[i]<<" Rmax="<<rx[i]<<endl;
478         B->DefineSection(i,z[i],rn[i],rx[i]);
479     } // end for i
480     //
481     // Poly-cone Volume C. Foam inside volume A.
482     // Now lets define the Rohacell foam material volume.
483     phi   = 0.0;
484     dphi  = 360.0;
485     z[0]  = B->GetZ(4);
486     rn[0] = B->GetRmin(4);
487     rx[0] = rn[0];
488     z[1]  = B->GetZ(5);
489     rx[1] = B->GetRmin(5);
490     rn[2] = A->GetRmin(5)+Cthick;//space for carbon fiber covering hole
491     z[2]  = ZFromRminpCone(A,Tc,rn[2],+Cthick);
492     rn[1] = RFrom2Points(rn,z,2,0,z[1]);
493     rx[3] = A->GetRmin(6)+Cthick;
494     rn[3] = rx[3];
495     z[3]  = ZFromRmaxpCone(A,Tc,rx[3],-Cthick);
496     rx[2] = RFrom2Points(rx,z,3,1,z[2]);
497     TGeoPcon *C = new TGeoPcon("ITS SSD Suport cone Rohacell foam "
498                                    "left edge",phi,dphi,4);
499     for(i=0;i<C->GetNz();i++){
500         if(fDebug) cout<<i<<"C: z="<<z[i]<<" Rmin="<<rn[i]<<" Rmax="<<rx[i]<<endl;
501         C->DefineSection(i,z[i],rn[i],rx[i]);
502     } // end for i
503     //
504     // In volume SCB, th Inserto Stesalite 4411w material volume, there
505     // are a number of Stainless steel screw and pin studs which will be
506     // filled with screws/studs.
507     rn[0] = 0.0*kmm,rx[0] = 6.0*kmm,z[0] = 0.5*10.0*kmm; // mm
508     TGeoTube *D = new TGeoTube("ITS Screw+stud used to mount things to "
509                                    "the SSD support cone",rn[0],rx[0],z[0]);
510     rn[0] = 0.0*kmm;rx[0] = 6.0*kmm;z[0] = 0.5*12.0*kmm; // mm
511     TGeoTube *E = new TGeoTube("ITS pin used to mount things to the "
512                                    "SSD support cone",rn[0],rx[0],z[0]);
513     //
514     // Poly-cone Volume F. Foam in spoak reagion, inside volume A.
515     // There is no carbon fiber between this upper left section and the
516     // SSD spoaks. We remove it by replacing it with Rohacell foam.
517     t = Cthick/(0.5*(RholeMax+RholeMin));// It is not posible to get
518     // the carbon fiber thickness uniform in this phi direction. We can only
519     // make it a fixed angular thickness.
520     t *= 180.0/TMath::Pi();
521     phi  = 12.5+t; // degrees see drawing ALR-0767.
522     dphi  = 5.0 - 2.0*t; // degrees
523     z[0]  = C->GetZ(2);
524     rn[0] = C->GetRmin(3);
525     rx[0] = rn[0];
526     rn[1] = A->GetRmin(5);
527     rx[1] = rn[0];
528     z[1]  = ZFromRminpCone(A,Tc,rn[1],+Cthick);
529     z[2]  = C->GetZ(3);
530     rn[2] = rn[1];
531     rx[2] = rx[1];
532     rn[3] = A->GetRmin(6);
533     rx[3] = rn[3];
534     z[3]  = ZFromRmaxpCone(A,Tc,rx[3],-Cthick);
535     TGeoPcon *F = new TGeoPcon("ITS SSD Top Suport cone Rohacell foam "
536                                    "Spoak",phi,dphi,4);
537     for(i=0;i<F->GetNz();i++){
538         if(fDebug) cout<<i<<"F: z="<<z[i]<<" Rmin="<<rn[i]<<" Rmax="<<rx[i]<<endl;
539         F->DefineSection(i,z[i],rn[i],rx[i]);
540     } // end for i
541     //=================================================================
542      // Poly-cone Volume G.
543     // Now for the spoak part of the SSD cone.
544     // It is not posible to inclue the radius of curvature between
545     // the spoak part and the upper left part of the SSD cone or lowwer right
546     // part. This would be discribed by the following curves.
547     // R = Rmax - (5mm)*Sin(t) phi = phi0+(5mm*180/(Pi*RoutHole))*Sin(t) 
548     // where 0<=t<=90 For the inner curve a simular equiation holds.
549     phi   = 12.5; // degrees see drawing ALR-0767.
550     dphi  = 5.0; // degrees
551     z[0]  = A->GetZ(5);
552     rn[0] = A->GetRmin(5);
553     rx[0] = rn[0];
554     z[1]  = A->GetZ(6);
555     rn[1] = RminFromZpCone(A,Tc,z[1]);
556     rx[1] = rx[0];
557     rn[2] = RholeMin;
558     z[2]  = ZFromRminpCone(A,Tc,rn[2]);
559     rx[2] = RmaxFromZpCone(A,Tc,z[2]);
560     rn[3] = rn[2];
561     rx[3] = rn[3];
562     z[3]  = ZFromRmaxpCone(A,Tc,rx[3]);
563     TGeoPcon *G = new TGeoPcon("ITS SSD spoak carbon fiber surfaces",
564                                    phi,dphi,4);
565     for(i=0;i<G->GetNz();i++){
566         if(fDebug) cout<<i<<"G: z="<<z[i]<<" Rmin="<<rn[i]<<" Rmax="<<rx[i]<<endl;
567         G->DefineSection(i,z[i],rn[i],rx[i]);
568     } // end for i
569     // For the foam core.
570     // Poly-cone Volume H.
571     t = Cthick/(0.5*(RholeMax+RholeMin));// It is not posible to get the
572     // carbon fiber thickness uniform in this phi direction. We can only
573     // make it a fixed angular thickness.
574     t *= 180.0/TMath::Pi();
575     phi   = 12.5+t; // degrees
576     dphi  = 5.0 - 2.0*t; // degrees see drawing ALR-0767.
577     z[0]  = F->GetZ(1);
578     rn[0] = G->GetRmin(0);
579     rx[0] = rn[0];
580     z[1]  = F->GetZ(3);
581     rn[1] = RminFromZpCone(A,Tc,z[1],+Cthick);
582     rx[1] = rx[0];
583     z[2]  = ZFromRminpCone(A,Tc,G->GetRmin(2),+Cthick);
584     rn[2] = G->GetRmin(2);
585     rx[2] = RmaxFromZpCone(A,Tc,z[2],-Cthick);
586     z[3]  = ZFromRmaxpCone(A,Tc,G->GetRmin(3),-Cthick);
587     rn[3] = G->GetRmin(3);
588     rx[3] = rn[3];
589     TGeoPcon *H = new TGeoPcon("ITS SSD support cone Rohacell foam Spoak",
590                                    phi,dphi,4); 
591     for(i=0;i<H->GetNz();i++){
592         if(fDebug) cout<<i<<"H: z="<<z[i]<<" Rmin="<<rn[i]<<" Rmax="<<rx[i]<<endl;
593         H->DefineSection(i,z[i],rn[i],rx[i]);
594     } // end for i
595     //
596     //==================================================================
597     // Now for the Inner most part of the SSD cone.
598     //Poly-cone Volume I.
599     phi   = 0.0;
600     dphi  = 360.0;
601     z[0]  = G->GetZ(2);
602     rn[0] = G->GetRmin(2);
603     rx[0] = rn[0];
604     z[1]  = G->GetZ(3);
605     rn[1] = RminFromZpCone(A,Tc,z[1]);
606     rx[1] = rx[0];
607     rn[4] = RinMin;
608     rn[5] = RinMin;
609     RadiusOfCurvature(Rcurv,90.0,0.0,RinMax,90.0-Tc,Z,rx[5]); // z dummy
610     z[5]  = ZFromRmaxpCone(A,Tc,rx[5]);
611     z[6]  = Zcylinder;
612     rn[6] = RinMin;
613     z[7]  = z[6];
614     rn[7] = RinCylinder;
615     rn[8] = RinCylinder;
616     rx[8] = rn[8];
617     Rmin   = rn[5];
618     RadiusOfCurvature(Rcurv,90.0-Tc,z[5],rx[5],90.0,Z,Rmax);
619     Rmax   = RinMax;
620     z[8]  = Z+(z[5]-Z)*(rx[8]-Rmax)/(rx[5]-Rmax);
621     rx[6] = RFrom2Points(rx,z,8,5,z[6]);
622     rx[7] = rx[6];
623     z[3]  = Z-dZin;
624     z[4]  = z[3];
625     rx[3] = RmaxFromZpCone(A,Tc,z[3]);
626     rx[4] = rx[3];
627     //rmin dummy
628     RadiusOfCurvature(Rcurv,90.,z[3],0.,90.-Tc,z[2],Rmin);
629     rn[2] = RminFromZpCone(A,Tc,z[2]);
630     rx[2] = RmaxFromZpCone(A,Tc,z[2]);
631     // z dummy
632     RadiusOfCurvature(Rcurv,90.-Tc,0.0,rn[2],90.0,Z,rn[3]);
633     TGeoPcon *I = new TGeoPcon("ITS SSD lower/inner right part of SSD "
634                                    "cone",phi,dphi,9);
635     for(i=0;i<I->GetNz();i++){
636         if(fDebug) cout<<i<<"I: z="<<z[i]<<" Rmin="<<rn[i]<<" Rmax="<<rx[i]<<endl;
637         I->DefineSection(i,z[i],rn[i],rx[i]);
638     } // end for i
639     // Now for Inserto volume at the inner most radius.
640     // Poly-cone Volume K.
641     phi   = 0.0;
642     dphi  = 360.0;
643     z[1]  = I->GetZ(3)+Cthick;
644     rn[1] = I->GetRmin(3);
645     z[2]  = z[1];
646     rn[2] = I->GetRmin(4);
647     rn[3] = rn[2];
648     rn[4] = rn[2];
649     rx[4] = I->GetRmax(5)-Cthick*Sintc;
650     RadiusOfCurvature(Rcurv+Cthick,90.0,z[1],rn[1],90.0-Tc,z[0],rn[0]);
651     rx[0] = rn[0];
652     z[3]  = z[0]+(Thickness-2.0*Cthick)*Costc;;
653     rx[3] = rx[0]+(Thickness-2.0*Cthick)*Sintc;
654     rx[1] = RFrom2Points(rx,z,3,0,z[1]);
655     rx[2] = rx[1];
656     z[4]  = ZFromRmaxpCone(A,Tc,rx[4],-Cthick);
657     rn[5] = rn[2];
658     z[5]  = I->GetZ(6);
659     rx[5] = (I->GetRmax(5)-I->GetRmax(8))/(I->GetZ(5)-I->GetZ(8))*(z[5]-z[4])+
660              rx[4];
661     TGeoPcon *K = new TGeoPcon("ITS SSD inner most inserto material",
662                                    phi,dphi,6);
663     for(i=0;i<K->GetNz();i++){
664         if(fDebug) cout<<i<<"K: z="<<z[i]<<" Rmin="<<rn[i]<<" Rmax="<<rx[i]<<endl;
665         K->DefineSection(i,z[i],rn[i],rx[i]);
666     } // end for i
667     // Now for foam core at the inner most radius.
668     // Poly-cone Volume J.
669     phi   = 0.0;
670     dphi  = 360.0;
671     rn[0] = I->GetRmin(0)-Cthick;
672     z[0]  = ZFromRminpCone(A,Tc,rn[0],+Cthick);
673     rx[0] = rn[0];
674     rx[1] = rx[0];
675     z[1]  = ZFromRmaxpCone(A,Tc,rx[1],-Cthick);
676     rn[1] = RminFromZpCone(A,Tc,z[1],+Cthick);
677     z[2]  = K->GetZ(0);
678     rn[2] = K->GetRmin(0);
679     rx[2] = RmaxFromZpCone(A,Tc,z[2],-Cthick);
680     z[3]  = K->GetZ(3);
681     rn[3] = K->GetRmax(3);
682     rx[3] = rn[3];
683     TGeoPcon *J = new TGeoPcon("ITS SSD inner most foam core",phi,dphi,4); 
684     for(i=0;i<J->GetNz();i++){
685         if(fDebug) cout<<i<<"J: z="<<z[i]<<" Rmin="<<rn[i]<<" Rmax="<<rx[i]<<endl;
686         J->DefineSection(i,z[i],rn[i],rx[i]);
687     } // end for i
688     // Now for foam core at the top of the inner most radius where 
689     // the spoaks are.
690     t = Cthick/(0.5*(RholeMax+RholeMin));// It is not posible to get the
691     // carbon fiber thickness uniform in this phi direction. We can only
692     // make it a fixed angular thickness.
693     // Poly-cone Volume L.
694     t *= 180.0/TMath::Pi();
695     phi   = 12.5+t; // degrees
696     dphi  = 5.0 - 2.0*t; // degrees see drawing ALR-0767.
697     z[0]  = H->GetZ(2);
698     rn[0] = H->GetRmin(2);
699     rx[0] = rn[0];
700     z[1]  = J->GetZ(0);
701     rn[1] = J->GetRmin(0);
702     rx[1] = I->GetRmax(1);
703     z[2]  = H->GetZ(3);
704     rn[2] = rn[1];
705     rx[2] = rx[1];
706     z[3]  = J->GetZ(1);
707     rn[3] = rn[2];
708     rx[3] = rn[3];
709     TGeoPcon *L = new TGeoPcon("ITS SSD Bottom cone Rohacell foam Spoak",
710                                    phi,dphi,4);
711     for(i=0;i<L->GetNz();i++){
712         if(fDebug) cout<<i<<"L: z="<<z[i]<<" Rmin="<<rn[i]<<" Rmax="<<rx[i]<<endl;
713         L->DefineSection(i,z[i],rn[i],rx[i]);
714     } // end for i
715     // Now for the SSD mounting posts
716     // Poly-cone Volume O.
717     dphi  = 180.0*dRpost/(RpostMin+0.5*dRpost)/TMath::Pi(); //
718     phi   = Phi0Post-0.5*dphi; // degrees
719     rn[0] = RpostMin+dRpost;
720     rx[0] = rn[0];
721     z[0]  = ZFromRmaxpCone(A,Tc,rx[0]);
722     rn[1] = RpostMin;
723     z[1]  = ZFromRmaxpCone(A,Tc,rn[1]);
724     rx[1] = rx[0];
725     z[2]  = ZpostMax;
726     rn[2] = RpostMin;
727     rx[2] = rn[2]+dRpost;
728     TGeoPcon *O = new TGeoPcon("ITS SSD mounting post, carbon fiber",
729                                    phi,dphi,3);
730     for(i=0;i<O->GetNz();i++){
731         if(fDebug) cout<<i<<"O: z="<<z[i]<<" Rmin="<<rn[i]<<" Rmax="<<rx[i]<<endl;
732         O->DefineSection(i,z[i],rn[i],rx[i]);
733     } // end for i
734     // Now for the SSD mounting posts
735     // Poly-cone Volume P.
736     t = 180.0*Cthick/(RpostMin+0.5*dRpost)/TMath::Pi();
737     dphi  = O->GetDphi()-2.0*t; // degrees
738     phi   = O->GetPhi1()+t; //
739     rn[0] = O->GetRmin(0)-Cthick;
740     rx[0] = rn[0];
741     z[0]  = ZFromRmaxpCone(A,Tc,rx[0]);
742     rn[1] = O->GetRmin(1)+Cthick;
743     rx[1] = O->GetRmin(0)-Cthick;
744     z[1]  = ZFromRmaxpCone(A,Tc,rn[1]);
745     rn[2] = rn[1];
746     rx[2] = rx[1];
747     z[2]  = ZpostMax;
748     TGeoPcon *P = new TGeoPcon("ITS SSD mounting post, Inserto",
749                                    phi,dphi,3);
750     for(i=0;i<P->GetNz();i++){
751         if(fDebug) cout<<i<<"P: z="<<z[i]<<" Rmin="<<rn[i]<<" Rmax="<<rx[i]<<endl;
752         P->DefineSection(i,z[i],rn[i],rx[i]);
753     } // end for i
754     // This insrto continues into the SSD cone displacing the foam
755     // and the carbon fiber surface at those points where the posts are.
756     //Poly-cone Vol. M
757     phi   = P->GetPhi1();
758     dphi  = P->GetDphi();
759     rn[0] = RpostMin+dRpost-Cthick;
760     rx[0] = rn[0];
761     z[0]  = ZFromRminpCone(A,Tc,rn[0],+Cthick);
762     rx[1] = rx[0];
763     z[1]  = ZFromRmaxpCone(A,Tc,rx[1],-Cthick);
764     rn[1] = RminFromZpCone(A,Tc,z[1],+Cthick);
765     rn[2] = RpostMin+Cthick;
766     z[2]  = ZFromRminpCone(A,Tc,rn[2],+Cthick);
767     rx[2] = RmaxFromZpCone(A,Tc,z[2],-Cthick);
768     rn[3] = rn[2];
769     rx[3] = rn[3];
770     z[3]  = ZFromRmaxpCone(A,Tc,rx[3],-Cthick);
771     TGeoPcon *M = new TGeoPcon("ITS SSD mounting post foam substitute, "
772                                    "Inserto",phi,dphi,4);
773     for(i=0;i<M->GetNz();i++){
774         if(fDebug) cout<<i<<"M: z="<<z[i]<<" Rmin="<<rn[i]<<" Rmax="<<rx[i]<<endl;
775         M->DefineSection(i,z[i],rn[i],rx[i]);
776     } // end for i
777     //
778     //Poly-cone Vol. N
779     phi   = P->GetPhi1();
780     dphi  = P->GetDphi();
781     z[0]  = M->GetZ(1);
782     rn[0] = M->GetRmax(1);
783     rx[0] = rn[0];
784     rx[1] = rx[0];
785     z[1]  = ZFromRmaxpCone(A,Tc,rx[1]);
786     rn[1] = RmaxFromZpCone(A,Tc,z[1],-Cthick);
787     z[2]  = M->GetZ(3);
788     rn[2] = M->GetRmin(3);
789     rx[2] = RmaxFromZpCone(A,Tc,z[2]);
790     rn[3] = rn[2];
791     rx[3] = rn[3];
792     z[3]  = ZFromRmaxpCone(A,Tc,rx[3]);
793     TGeoPcon *N = new TGeoPcon("ITS SSD mounting post CF subsititute, "
794                                    "Inserto",phi,dphi,4);
795     for(i=0;i<N->GetNz();i++){ 
796         if(fDebug) cout<<i<<"N: z="<<z[i]<<" Rmin="<<rn[i]<<" Rmax="<<rx[i]<<endl;
797         N->DefineSection(i,z[i],rn[i],rx[i]);
798     } // end for i
799     // Bolt heads holding the SSD-SDD tube to the SSD cone.
800     // Bolt -- PolyCone
801     //Poly-cone Volume Q.
802     phi   = 0.0;
803     dphi  = 360.0;
804     z[0]  = I->GetZ(4)-ThSDDsupportPlate;
805     rn[0] = 0.0;
806     rx[0] = 0.5*DscrewHead;
807     z[1]  = I->GetZ(4)-ThScrewHeadHole;
808     rn[1] = 0.0;
809     rx[1] = 0.5*DscrewHead;
810     z[2]  = z[1];
811     rn[2] = 0.0;
812     rx[2] = 0.5*DscrewShaft;
813     z[3]  = z[2];
814     rn[3] = 0.0;
815     rx[3] = rx[2];
816     TGeoPcon *Q = new TGeoPcon("ITS SSD Thermal sheal stainless steel "
817                                    "bolts",phi,dphi,4);
818     for(i=0;i<Q->GetNz();i++){
819         if(fDebug) cout<<i<<"Q: z="<<z[i]<<" Rmin="<<rn[i]<<" Rmax="<<rx[i]<<endl;
820         Q->DefineSection(i,z[i],rn[i],rx[i]);
821     } // end for i
822     // air infront of bolt (stasolit Volume K) -- Tube
823     z[0]  = 0.5*(Thickness-ThScrewHeadHole);
824     rn[0] = 0.0*kmm;
825     rx[0] = 0.5*DscrewHead;
826     TGeoTube *R = new TGeoTube("ITS Air in front of bolt (in stasolit)",
827                                    rn[0],rx[0],z[0]);
828     // air infront of bolt (carbon fiber volume I) -- Tube
829     z[0]  = 0.5*Thickness;
830     rn[0] = 0.0*kmm;
831     rx[0] = R->GetRmax();
832     TGeoTube *S = new TGeoTube("ITS Air in front of Stainless Steal "
833                                    "Screw end, N6",rn[0],rx[0],z[0]);
834     // SDD support plate, SSD side.
835     //Poly-cone Volume T.
836     dphi  = TMath::RadToDeg()*TMath::ATan2(0.5*WsddSupportPlate,RsddSupportPlate);
837     phi   = Phi0SDDsupports-0.5*dphi;
838     z[0]  = K->GetZ(2);
839     rn[0] = I->GetRmin(4);
840     rx[0] = RsddSupportPlate;
841     z[1]  = I->GetZ(4) - ThSDDsupportPlate;
842     rn[1] = rn[0];
843     rx[1] = rx[0];
844     TGeoPcon *T = new TGeoPcon("ITS SSD-SDD mounting bracket Inserto->Al.",
845                                    phi,dphi,2);
846     for(i=0;i<T->GetNz();i++){
847         if(fDebug) cout<<i<<"T: z="<<z[i]<<" Rmin="<<rn[i]<<" Rmax="<<rx[i]<<endl;
848         T->DefineSection(i,z[i],rn[i],rx[i]);
849     } // end for i
850     //
851     // Poly-cone Volume U.
852     TGeoPcon *U;
853     if(I->GetRmin(3)<T->GetRmax(0)){
854         dphi  = T->GetDphi();
855         phi   = T->GetPhi1();
856         z[2]  = I->GetZ(4);
857         rn[2] = T->GetRmin(0);
858         rx[2] = T->GetRmax(0);
859         z[3]  = K->GetZ(2);
860         rn[3] = rn[2];
861         rx[3] = rx[2];
862         z[1]  = z[2];
863         rn[1] = I->GetRmin(3);
864         rx[1] = rx[3];
865         rx[0] = T->GetRmax(0);
866         rn[0] = rx[0];
867         z[0]  = Zfrom2MinPoints(I,2,3,rn[0]);
868         U = new TGeoPcon("ITS SSD-SDD mounting bracket CF->Al.",phi,dphi,4);
869     }else{
870         dphi  = T->GetDphi();
871         phi   = T->GetPhi1();
872         z[0]  = I->GetZ(4);
873         rn[0] = T->GetRmin(0);
874         rx[0] = T->GetRmax(0);
875         z[1]  = K->GetZ(2);
876         rn[1] = rn[0];
877         rx[1] = rx[0];
878         U = new TGeoPcon("ITS SSD-SDD mounting bracket CF->Al.",phi,dphi,2);
879     }// end if
880     for(i=0;i<U->GetNz();i++){
881         if(fDebug) cout<<i<<"U: z="<<z[i]<<" Rmin="<<rn[i]<<" Rmax="<<rx[i]<<endl;
882         U->DefineSection(i,z[i],rn[i],rx[i]);
883     } // end for i
884     //
885     TGeoManager *mgr = gGeoManager;
886     SSDcf = mgr->GetMedium("ITSssdCarbonFiber");
887     SSDfs = mgr->GetMedium("ITSssdStaselite4411w");
888     SSDfo = mgr->GetMedium("ITSssdRohacell50A");
889     SSDss = mgr->GetMedium("ITSssdStainlessSteal");
890     SSDair= mgr->GetMedium("ITSssdAir");
891     SSDal = mgr->GetMedium("ITSssdAl");
892     TGeoVolume *Av,*Bv,*Cv,*Dv,*Ev,*Fv,*Gv,*Hv,*Iv,*Jv,*Kv,*Lv,*Mv,*Nv,
893                *Ov,*Pv,*Qv,*Rv,*Sv,*Tv,*Uv;
894     Av = new TGeoVolume("ITSssdConeA",A,SSDcf);
895     //mgr->AddVolume(Av);
896     Av->SetVisibility(kTRUE);
897     Av->SetLineColor(1);
898     Av->SetLineWidth(1);
899     Bv = new TGeoVolume("ITSssdConeB",B,SSDfs);
900     //mgr->AddVolume(Bv);
901     Bv->SetVisibility(kTRUE);
902     Cv = new TGeoVolume("ITSssdConeC",C,SSDfo);
903     Cv->SetVisibility(kTRUE);
904     //mgr->AddVolume(Cv);
905     Dv = new TGeoVolume("ITSssdConeD",D,SSDss);
906     Dv->SetVisibility(kTRUE);
907     //mgr->AddVolume(Dv);
908     Ev = new TGeoVolume("ITSssdConeE",E,SSDss);
909     Ev->SetVisibility(kTRUE);
910     //mgr->AddVolume(Ev);
911     Fv = new TGeoVolume("ITSssdConeF",F,SSDfo);
912     Fv->SetVisibility(kTRUE);
913     //mgr->AddVolume(Fv);
914     Gv = new TGeoVolume("ITSssdConeG",G,SSDcf);
915     Gv->SetVisibility(kTRUE);
916     //mgr->AddVolume(Gv);
917     Gv->SetLineColor(2);
918     Gv->SetLineWidth(2);
919     Hv = new TGeoVolume("ITSssdConeH",H,SSDfo);
920     Hv->SetVisibility(kTRUE);
921     //mgr->AddVolume(Hv);
922     Iv = new TGeoVolume("ITSssdConeI",I,SSDcf);
923     Iv->SetVisibility(kTRUE);
924     //mgr->AddVolume(Iv);
925     Iv->SetLineColor(3);
926     Iv->SetLineWidth(3);
927     Jv = new TGeoVolume("ITSssdConeJ",J,SSDfo);
928     Jv->SetVisibility(kTRUE);
929     //mgr->AddVolume(Jv);
930     Kv = new TGeoVolume("ITSssdConeK",K,SSDfs);
931     Kv->SetVisibility(kTRUE);
932     //mgr->AddVolume(Kv);
933     Lv = new TGeoVolume("ITSssdConeL",L,SSDfo);
934     Lv->SetVisibility(kTRUE);
935     //mgr->AddVolume(Lv);
936     Mv = new TGeoVolume("ITSssdConeM",M,SSDfs);
937     Mv->SetVisibility(kTRUE);
938     //mgr->AddVolume(Mv);
939     Nv = new TGeoVolume("ITSssdConeN",N,SSDfs);
940     Nv->SetVisibility(kTRUE);
941     //mgr->AddVolume(Nv);
942     Ov = new TGeoVolume("ITSssdConeO",O,SSDcf);
943     Ov->SetVisibility(kTRUE);
944     //mgr->AddVolume(Ov);
945     Ov->SetLineColor(4);
946     Ov->SetLineWidth(4);
947     Pv = new TGeoVolume("ITSssdConeP",P,SSDfs);
948     Pv->SetVisibility(kTRUE);
949     //mgr->AddVolume(Pv);
950     Qv = new TGeoVolume("ITSssdConeQ",Q,SSDss);
951     Qv->SetVisibility(kTRUE);
952     //mgr->AddVolume(Qv);
953     Rv = new TGeoVolume("ITSssdConeR",R,SSDair);
954     Rv->SetVisibility(kTRUE);
955     //mgr->AddVolume(Rv);
956     Sv = new TGeoVolume("ITSssdConeS",S,SSDair);
957     Sv->SetVisibility(kTRUE);
958     //mgr->AddVolume(Sv);
959     Tv = new TGeoVolume("ITSssdConeT",T,SSDal);
960     Tv->SetVisibility(kTRUE);
961     //mgr->AddVolume(Tv);
962     Uv = new TGeoVolume("ITSssdConeU",U,SSDal);
963     Uv->SetVisibility(kTRUE);
964     //mgr->AddVolume(Uv);
965     //
966     TGeoTranslation *tran = new TGeoTranslation("ITSssdConeTrans",0.0,0.0,-Z0);
967     TGeoRotation *rot180  = new TGeoRotation("ITSssdConeRot180",0.0,180.0,0.0);
968     TGeoCombiTrans *flip  = new TGeoCombiTrans("ITSssdConeFlip",0.0,0.0,Z0,rot180);
969     TGeoTranslation *tranR,*tranS;
970     TGeoCombiTrans *fliptran,*rottran;
971     TGeoRotation *rot,*zspoaks,*zspoaks180;
972     Av->AddNode(Bv,1,0);
973     Av->AddNode(Cv,1,0);
974     Moth->AddNode(Av,1,tran); // RB24 side
975     Moth->AddNode(Av,2,flip); // RB26 side (Absorber)
976     Moth->AddNode(Iv,1,tran); // RB24 side
977     Moth->AddNode(Iv,2,flip); // RB26 side (Absorber)
978     Gv->AddNode(Hv,1,0);
979     for(i=0;i<Nspoaks;i++){ // SSD Cone Spoaks
980         zspoaks = new TGeoRotation("",0.0,0.0,
981                                    ((Double_t)i*360.)/((Double_t)Nspoaks));
982         rottran = new TGeoCombiTrans("",0.0,0.0,-Z0,zspoaks);
983         Moth->AddNode(Gv,i+1,rottran); // RB24 side
984         Av->AddNode(Fv,i+1,zspoaks);
985         Iv->AddNode(Lv,i+1,zspoaks);
986         zspoaks180 =  new TGeoRotation("",0.0,180.0,
987                                        ((Double_t)i*360.)/((Double_t)Nspoaks));
988         fliptran = new TGeoCombiTrans("",0.0,0.0,Z0,zspoaks180);
989         Moth->AddNode(Gv,Nspoaks+i+1,fliptran); // RB26 side
990     } // end for i
991     Iv->AddNode(Jv,1,0);
992     Iv->AddNode(Kv,1,0);
993     Ov->AddNode(Pv,1,0);
994     //Pv->AddNode(Qv,2,?); // Screw head
995     //Pv->AddNode(Qv,3,?); // Screw head
996     //Pv->AddNode(Vv,1,?); // Air hole in Posts
997     //Pv->AddNode(Vv,2,?); // Air hole in Posts
998     //Mv->AddNode(Wv,1,?); // Air hole in Posts
999     //Mv->AddNode(Wv,2,?); // Air hole in Posts
1000     //Nv->AddNode(Xv,1,?); // Air hole in Posts
1001     //Nv->AddNode(Xv,2,?); // Air hole in Posts
1002     TGeoRotation *zposts,*zposts180;
1003     for(i=0;i<Nposts;i++){ // SSD Cone mounting posts
1004         zposts = new TGeoRotation("",0.0,0.0,
1005                                   ((Double_t)i*360.)/((Double_t)Nposts));
1006         rottran = new TGeoCombiTrans("",0.0,0.0,-Z0,zposts);
1007         Moth->AddNode(Ov,i+1,rottran); // RB24 side
1008         Jv->AddNode(Mv,i+1,zposts);
1009         Iv->AddNode(Nv,i+1,zposts);
1010         //Jv->AddNode(Xv,2*i+3,?); // Air hole in Posts
1011         //Jv->AddNode(Xv,2*i+4,?); // Air hole in Posts
1012         zposts180 = new TGeoRotation("",0.0,180.0,
1013                                   ((Double_t)i*360.)/((Double_t)Nposts));
1014         fliptran = new TGeoCombiTrans("",0.0,0.0,Z0,zposts180);
1015         Moth->AddNode(Ov,Nposts+i+1,fliptran); // RB26 side
1016     } // end for i
1017     //
1018     for(i=0;i<NinScrews;i++){
1019         t = Phi0Screws+360.*((Double_t)i)/((Double_t)NinScrews);
1020         t *= TMath::DegToRad();
1021         tran= new TGeoTranslation("",RcylinderScrews*TMath::Cos(t),
1022                                   RcylinderScrews*TMath::Sin(t),0.0);
1023         Kv->AddNode(Qv,i+4,rottran);
1024         if(/*not where volumes U and T are*/kTRUE){
1025             tranR = new TGeoTranslation("",RinHole*TMath::Cos(t),
1026                                         RinHole*TMath::Sin(t),
1027                                         K->GetZ(2)+R->GetDz());
1028             tranS = new TGeoTranslation("",RinHole*TMath::Cos(t),
1029                                         RinHole*TMath::Sin(t),
1030                                         I->GetZ(4)+S->GetDz());
1031             Kv->AddNode(Rv,i,tranR);
1032             Iv->AddNode(Sv,i,tranS);
1033         } // end if
1034     } // end for i
1035     Int_t NcD=1,NcE=1,NcR=1,NcS=1;
1036     const Int_t Nbscrew=2,Nbpins=3,Nrailsc=4,Nrailp=2;
1037     Double_t da[] = {-3.5,-1.5,1.5,3.5};
1038     for(i=0;i<2;i++){ // Mounting for ITS-TPC bracket or ITS-Rails
1039         t0 = TMath::Pi()*((Double_t)i);
1040         for(j=-Nbscrew/2;j<=Nbscrew/2;j++)if(j!=0){//screws per ITS-TPC bracket
1041             t = t0 + 5.0*((Double_t)j)*TMath::DegToRad();
1042             tran = new TGeoTranslation("",RoutHole*TMath::Cos(t),
1043                                       RoutHole*TMath::Sin(t),
1044                                       B->GetZ(0)-D->GetDz());
1045             Bv->AddNode(Dv,NcD,tran);
1046             if(fDebug) cout << "D: NcD="<<NcD<<endl;
1047             NcD++;
1048         } // end or j
1049         for(j=-Nbpins/2;j<=Nbpins/2;j++){ // pins per ITS-TPC bracket
1050             t = t0 + 3.0*((Double_t)j)*TMath::DegToRad();
1051             tran = new TGeoTranslation("",RoutHole*TMath::Cos(t),
1052                                       RoutHole*TMath::Sin(t),
1053                                       B->GetZ(0)-D->GetDz());
1054             Bv->AddNode(Ev,NcE,tran);
1055             if(fDebug) cout << "E: NcE="<<NcE<<endl;
1056             NcE++;
1057         } // end or j
1058         t0 = (96.5+187.*((Double_t)i))*TMath::DegToRad();
1059         for(j=0;j<Nrailsc;j++){ // screws per ITS-rail bracket
1060             t = t0+da[j]*TMath::DegToRad();
1061             tran = new TGeoTranslation("",RoutHole*TMath::Cos(t),
1062                                       RoutHole*TMath::Sin(t),
1063                                       B->GetZ(0)-D->GetDz());
1064             Bv->AddNode(Dv,NcD,tran);
1065             if(fDebug) cout << "D2: NcD="<<NcD<<endl;
1066             NcD++;
1067         } // end or j
1068         t0 = (91.5+184.*((Double_t)i))*TMath::DegToRad();
1069         for(j=-Nrailp/2;j<=Nrailp/2;j++)if(j!=0){ // pins per ITS-rail bracket
1070             t = t0+(7.0*((Double_t)j))*TMath::DegToRad();
1071             tran = new TGeoTranslation("",RoutHole*TMath::Cos(t),
1072                                       RoutHole*TMath::Sin(t),
1073                                       B->GetZ(0)-D->GetDz());
1074             Bv->AddNode(Ev,NcE,tran);
1075             if(fDebug) cout << "E2: NcE="<<NcE<<endl;
1076             NcE++;
1077         } // end or j
1078     } // end for i
1079     for(i=0;i<Nmounts;i++){ // mounting points for SPD-cone+Beam-pipe support
1080         t0 = (45.0+((Double_t)i)*360./((Double_t)Nmounts))*TMath::DegToRad();
1081         for(j=-1;j<=1;j++)if(j!=0){ // 2 screws per bracket
1082             t = t0+((Double_t)j)*0.5*DmountAngle;
1083             tran = new TGeoTranslation("",RoutHole*TMath::Cos(t),
1084                                       RoutHole*TMath::Sin(t),
1085                                       B->GetZ(0)-D->GetDz());
1086             Bv->AddNode(Dv,NcD,tran);
1087             if(fDebug) cout << "D3: NcD="<<NcD<<endl;
1088             NcD++;
1089         } // end for j
1090         for(j=0;j<1;j++){ // 1 pin per bracket
1091             t = t0;
1092             tran = new TGeoTranslation("",RoutHole*TMath::Cos(t),
1093                                       RoutHole*TMath::Sin(t),
1094                                       B->GetZ(0)-D->GetDz());
1095             Bv->AddNode(Ev,NcE,tran);
1096             if(fDebug) cout << "E3: NcE="<<NcE<<endl;
1097             NcE++;
1098         } // end for j
1099     } // end for i
1100     tran = new TGeoTranslation("",TMath::Cos(T->GetPhi1()+0.5*T->GetDphi()),
1101                               TMath::Sin(T->GetPhi1()+0.5*T->GetDphi()),
1102                               T->GetZ(T->GetNz()-1)+R->GetDz());
1103     Tv->AddNode(Rv,NcR++,tran);
1104     tran = new TGeoTranslation("",TMath::Cos(U->GetPhi1()+0.5*U->GetDphi()),
1105                               TMath::Sin(U->GetPhi1()+0.5*U->GetDphi()),
1106                               U->GetZ(U->GetNz()-1)+S->GetDz());
1107     Uv->AddNode(Sv,NcS++,tran);
1108     for(i=0;i<NssdSupports;i++){ // mounting braclets for SSD/SDD 
1109         t0 = ((Double_t)i*360./((Double_t)NssdSupports));
1110         rot = new TGeoRotation("",0.0,0.0,t0);
1111         Kv->AddNode(Tv,i+1,rot);
1112         Iv->AddNode(Uv,i+1,rot);
1113         if(fDebug) cout << "T/U: copy number="<<i+1<<endl;
1114         //for(j=0;j<1;j++){ // 1 screws per bracket
1115         //    t = t0;
1116         //} // end for j
1117         for(j=0;j<2;j++)if(j!=0){ // 2 pin per bracket
1118             t = t0 + ((Double_t)j)*0.5*DssdsddBracketAngle;
1119             tran = new TGeoTranslation("",RinHole*TMath::Cos(t),
1120                               RinHole*TMath::Sin(t),
1121                               T->GetZ(T->GetNz()-1)-E->GetDz());
1122             Kv->AddNode(Ev,NcE++,tran);
1123         } // end for j
1124     } // end for i
1125 }
1126 //______________________________________________________________________
1127 void AliITSv11::CreateMaterials(){
1128     // Create ITS materials
1129     //     This function defines the default materials used in the Geant
1130     // Monte Carlo simulations for the geometries AliITSv11.
1131     // In general it is automatically replaced by
1132     // Inputs:
1133     //   none.
1134     // Outputs:
1135     //   none.
1136     // Return
1137     //   none.
1138
1139     //TGeoMaterial *C  = new TGeoMaterial("ITSCarbon",12.0,6.0,2.265);
1140     TGeoMaterial *Al = new TGeoMaterial("ITSAluminum",26.981539,13.0,2.07);
1141     TGeoMixture *Cfiber = new TGeoMixture("ITSCarbonFiber",6,1.930);
1142     TGeoMixture *Rohacell = new TGeoMixture("ITSRohacell",6,1.930);
1143     TGeoMixture *Staselite = new TGeoMixture("ITSStaselite4411w",6,1.930);
1144     TGeoMixture *Air = new TGeoMixture("ITSAir",6,1.205*1.E-3);
1145     TGeoMixture *Stainless = new TGeoMixture("ITSStainless",6,1.930);
1146     //
1147     Double_t SSDcone[20];
1148     SSDcone[0] = 1.0; // imat
1149     SSDcone[1] = 0.0; // isvol
1150     SSDcone[2] = gAlice->Field()->Integ(); // ifield
1151     SSDcone[3] = gAlice->Field()->Max(); // fieldm
1152     SSDcone[4] = 1.0; // tmaxfd [degrees]
1153     SSDcone[5] = 1.0; // stemax [cm]
1154     SSDcone[6] = 0.5; // deemax [fraction]
1155     SSDcone[7] = 1.0E-3; // epsil [cm]
1156     SSDcone[8] = 0.0; // stmin [cm]
1157     new TGeoMedium("ITSssdCarbonFiber",1,Cfiber,SSDcone);
1158     SSDcone[0] += 1.0;
1159     new TGeoMedium("ITSssdStaselite4411w",2,Staselite,SSDcone);
1160     SSDcone[0] += 1.0;
1161     new TGeoMedium("ITSssdRohacell50A",3,Rohacell,SSDcone);
1162     SSDcone[0] += 1.0;
1163     new TGeoMedium("ITSssdStainlesSteal",4,Stainless,SSDcone);
1164     SSDcone[0] += 1.0;
1165     new TGeoMedium("ITSssdAir",5,Air,SSDcone);
1166     SSDcone[0] += 1.0;
1167     new TGeoMedium("ITSssdAl",6,Al,SSDcone);
1168 }
1169 //______________________________________________________________________
1170 void AliITSv11::InitAliITSgeom(){
1171     // Based on the geometry tree defined in Geant 3.21, this
1172     // routine initilizes the Class AliITSgeom from the Geant 3.21 ITS 
1173     // geometry sturture.
1174     // Inputs:
1175     //   none.
1176     // Outputs:
1177     //   none.
1178     // Return
1179     //   none.
1180 }
1181 //______________________________________________________________________
1182 void AliITSv11::Init(){
1183     // Initialise the ITS after it has been created.
1184     // Inputs:
1185     //   none.
1186     // Outputs:
1187     //   none.
1188     // Return
1189     //   none.
1190 }
1191 //______________________________________________________________________
1192 void AliITSv11::SetDefaults(){
1193     // Sets the default segmentation, response, digit and raw cluster 
1194     // classes to be used. These defaults can be overwritten in the
1195     // macros that do these later steps. Defaults are give hear for the
1196     // general user.
1197     // Inputs:
1198     //   none.
1199     // Outputs:
1200     //   none.
1201     // Return
1202     //   none.
1203 }
1204 //______________________________________________________________________
1205 void AliITSv11::DrawModule(){
1206     // Draw a standard set of shaded view of the ITS version 11.
1207     // Inputs:
1208     //   none.
1209     // Outputs:
1210     //   none.
1211     // Return
1212     //   none.
1213 }
1214 //______________________________________________________________________
1215 void AliITSv11::StepManager(){
1216     // Called for every step in the ITS, then calles the AliITShit class
1217     // creator with the information to be recoreded about that hit.
1218     //  The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
1219     // printing of information to a file which can be used to create a .det
1220     // file read in by the routine CreateGeometry(). If set to 0 or any other
1221     // value except 1, the default behavior, then no such file is created nor
1222     // is the extra variables and the like used in the printing allocated.
1223 }
1224