3cc6f45d4b5a02a7fb5b52fba66ca23d531b396a
[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 //************************************************************************
17 //                 Inner Traking System geometry v11
18 //
19 //  Based on ROOT geometrical modeler
20 //
21 // B. Nilsen, L. Gaudichet
22 //************************************************************************
23
24
25 //#include <Riostream.h>
26 #include <TClonesArray.h>
27 #include <TLorentzVector.h>
28
29 #include "AliITS.h"
30 #include "AliITSDetTypeSim.h"
31 #include <TVirtualMC.h>
32
33 #include "AliITSgeom.h"
34 #include "AliITSgeomSDD.h"
35 #include "AliITSgeomSPD.h"
36 #include "AliITSgeomSSD.h"
37 #include "AliITShit.h"
38
39 #include "AliITSCalibrationSDD.h"
40 #include "AliITSCalibrationSPD.h"
41 #include "AliITSCalibrationSSD.h"
42
43 #include "AliITSsegmentationSDD.h"
44 #include "AliITSsegmentationSPD.h"
45 #include "AliITSsegmentationSSD.h"
46 #include "AliMagF.h"
47 #include "AliRun.h"
48 #include "AliTrackReference.h"
49 #include "AliMC.h"
50
51 #include <TGeoManager.h>
52 #include <TGeoVolume.h>
53 #include <TGeoPcon.h>
54 #include "AliITSv11.h"
55 //#include "AliITSv11GeometrySPD.h"
56 #include "AliITSv11GeometrySDD.h"
57 //#include "AliITSv11GeometrySupport.h"
58
59
60
61 ClassImp(AliITSv11)
62  
63
64
65 //______________________________________________________________________
66 AliITSv11::AliITSv11() : AliITS(),
67   fGeomDetOut(kFALSE),
68   fGeomDetIn(kFALSE),
69   fByThick(kTRUE),
70   fMajorVersion(11),
71   fMinorVersion(0),
72   fSDDgeom(0)
73 {
74   //    Standard default constructor for the ITS version 11.
75
76     fIdN          = 0;
77     fIdName       = 0;
78     fIdSens       = 0;
79     fEuclidOut    = kFALSE; // Don't write Euclide file
80     Int_t i;
81     for(i=0;i<60;i++) fRead[i] = '\0';
82     for(i=0;i<60;i++) fWrite[i] = '\0';
83     for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
84     strncpy(fRead,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det",60);
85 }
86
87
88 //______________________________________________________________________
89 AliITSv11::AliITSv11(const char *name, const char *title)
90   : AliITS("ITS", title),
91     fGeomDetOut(kFALSE),
92     fGeomDetIn(kFALSE),
93     fByThick(kTRUE),
94     fMajorVersion(11),
95     fMinorVersion(0),
96     fSDDgeom(0)
97 {
98   //    Standard constructor for the ITS version 11.
99
100   fSDDgeom = new AliITSv11GeometrySDD(0);
101
102   Int_t i;
103   fIdN = 6;
104   fIdName = new TString[fIdN];
105   fIdName[0] = name; // removes warning message
106   fIdName[0] = "ITS1";
107   fIdName[1] = "ITS2";
108   fIdName[2] = fSDDgeom->GetSenstiveVolumeName3();
109   fIdName[3] = fSDDgeom->GetSenstiveVolumeName4();
110   fIdName[4] = "ITS5";
111   fIdName[5] = "ITS6";
112   fIdSens    = new Int_t[fIdN];
113   for(i=0;i<fIdN;i++) fIdSens[i] = 0;
114   fEuclidOut    = kFALSE; // Don't write Euclide file
115   //SetDensityServicesByThickness();
116   // not needed, fByThick set to kTRUE in in the member initialization lis
117   
118
119   fEuclidGeometry="$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.euc";
120   strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det",60);
121   strncpy(fRead,fEuclidGeomDet,60);
122   strncpy(fWrite,fEuclidGeomDet,60);
123   strncpy(fRead,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det",60);
124 }
125
126
127 //______________________________________________________________________
128 AliITSv11::AliITSv11(Int_t debugITS,Int_t debugSPD,Int_t debugSDD,
129                    Int_t debugSSD,Int_t debugSUP) :
130   AliITS("ITS","ITS geometry v11"),
131     fGeomDetOut(kFALSE),
132     fGeomDetIn(kFALSE),
133     fByThick(kTRUE),
134     fMajorVersion(11),
135     fMinorVersion(0),
136     fSDDgeom(0)
137  {
138   // Standard default constructor for the ITS version 11.
139
140
141   //   fSPDgeom = new AliITSv11GeometrySPD(debugSPD);
142   fSDDgeom = new AliITSv11GeometrySDD(debugSDD);
143   fSDDgeom->SetDebug(debugSDD);
144   //   fSupgeom = new AliITSv11GeometrySupport(debugSUP);
145
146   Int_t i;
147   fIdN = 6;
148   fIdName = new TString[fIdN];
149   fIdName[0] = "ITS1";
150   fIdName[1] = "ITS2";
151   fIdName[2] = fSDDgeom->GetSenstiveVolumeName3();
152   fIdName[3] = fSDDgeom->GetSenstiveVolumeName4();
153   fIdName[4] = "ITS5";
154   fIdName[5] = "ITS6";
155   fIdSens    = new Int_t[fIdN];
156   for(i=0;i<fIdN;i++) fIdSens[i] = 0;
157   fEuclidOut    = kFALSE; // Don't write Euclide file
158   //SetDensityServicesByThickness();
159   
160   fEuclidGeometry="$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.euc";
161   strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymm2.det",60);
162   strncpy(fRead,fEuclidGeomDet,60);
163   strncpy(fWrite,fEuclidGeomDet,60);
164   strncpy(fRead,"$ALICE_ROOT/ITS/ITSgeometry_vPPRasymmFMD.det",60);
165
166   debugITS = (debugSPD && debugSSD && debugSUP && debugSDD); //remove temp. warnings
167 }
168
169
170 //______________________________________________________________________
171 AliITSv11::~AliITSv11() {
172   delete fSDDgeom;
173 }
174
175
176 //______________________________________________________________________
177 void AliITSv11::BuildGeometry(){
178
179 }
180
181
182 //______________________________________________________________________
183 void AliITSv11::CreateGeometry(){
184   //
185   // Create ROOT geometry
186   //
187
188   TGeoManager *geoManager = gGeoManager;
189   TGeoVolume *vALIC = geoManager->GetTopVolume();
190
191   TGeoPcon *sITS = new TGeoPcon("ITS Top Volume",0.0,360.0,2);
192
193   // DefineSection(section number, Z, Rmin, Rmax).
194   const Double_t kcm = 1.0;
195   sITS->DefineSection(0,-300.0*kcm,0.01*kcm,50.0*kcm);
196   sITS->DefineSection(1,+300.0*kcm,0.01*kcm,50.0*kcm);
197
198   TGeoMedium *air = gGeoManager->GetMedium("ITS_AIR$");
199   TGeoVolume *vITS = new TGeoVolume("ITSV",sITS,air);
200   vITS->SetVisibility(kFALSE);
201   vALIC->AddNode(vITS,1,0);
202
203 //   fSPDgeom->CenteralSPD(vITS);
204
205   fSDDgeom->Layer3(vITS);
206   fSDDgeom->Layer4(vITS);
207
208 //     fSupgeom->SPDCone(vITS);
209 //     fSupgeom->SPDThermalSheald(vITS);
210 //     fSupgeom->SDDCone(vITS);
211 //     fSupgeom->SSDCone(vITS);
212 //     fSupgeom->ServicesCableSupport(vITS);
213
214 }
215
216
217 //______________________________________________________________________
218 void AliITSv11::CreateMaterials(){
219   //
220   // Create ITS materials
221   // Defined media here should correspond to the one defined in galice.cuts
222   // File which is red in (AliMC*) fMCApp::Init() { ReadTransPar(); }
223   //
224
225 //     Int_t   ifield = gAlice->Field()->Integ();
226 //     Float_t fieldm = gAlice->Field()->Max();
227
228 //     Float_t tmaxfd = 0.1; // 1.0; // Degree
229 //     Float_t stemax = 1.0; // cm
230 //     Float_t deemax = 0.1; // 30.0; // Fraction of particle's energy 0<deemax<=1
231 //     Float_t epsil  = 1.0E-4; // 1.0; // cm
232 //     Float_t stmin  = 0.0; // cm "Default value used"
233
234 //     Float_t tmaxfdSi = 0.1; // .10000E+01; // Degree
235 //     Float_t stemaxSi = 0.0075; //  .10000E+01; // cm
236 //     Float_t deemaxSi = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1
237 //     Float_t epsilSi  = 1.0E-4;// .10000E+01;
238 //     Float_t stminSi  = 0.0; // cm "Default value used"
239
240 //     Float_t tmaxfdAir = 0.1; // .10000E+01; // Degree
241 //     Float_t stemaxAir = .10000E+01; // cm
242 //     Float_t deemaxAir = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1
243 //     Float_t epsilAir  = 1.0E-4;// .10000E+01;
244 //     Float_t stminAir  = 0.0; // cm "Default value used"
245
246 //     Float_t tmaxfdServ = 1.0; // 10.0; // Degree
247 //     Float_t stemaxServ = 1.0; // 0.01; // cm
248 //     Float_t deemaxServ = 0.5; // 0.1; // Fraction of particle's energy 0<deemax<=1
249 //     Float_t epsilServ  = 1.0E-3; // 0.003; // cm
250 //     Float_t stminServ  = 0.0; //0.003; // cm "Default value used"
251
252 //     // Freon PerFluorobuthane C4F10 see 
253 //     // http://st-support-cooling-electronics.web.cern.ch/
254 //     //        st-support-cooling-electronics/default.htm
255 //     Float_t afre[2]  = { 12.011,18.9984032 };
256 //     Float_t zfre[2]  = { 6., 9. };
257 //     Float_t wfre[2]  = { 4.,10. };
258 //     Float_t densfre  = 1.52;
259
260
261 //     //CM55J
262 //     Float_t aCM55J[4]={12.0107,14.0067,15.9994,1.00794};
263 //     Float_t zCM55J[4]={6.,7.,8.,1.};
264 //     Float_t wCM55J[4]={0.908508078,0.010387573,0.055957585,0.025146765};
265 //     Float_t dCM55J = 1.63;
266
267 //     //ALCM55J
268 //     Float_t aALCM55J[5]={12.0107,14.0067,15.9994,1.00794,26.981538};
269 //     Float_t zALCM55J[5]={6.,7.,8.,1.,13.};
270 //     Float_t wALCM55J[5]={0.817657902,0.0093488157,0.0503618265,0.0226320885,0.1};
271 //     Float_t dALCM55J = 1.9866;
272
273 //     //Si Chips
274 //     Float_t aSICHIP[6]={12.0107,14.0067,15.9994,1.00794,28.0855,107.8682};
275 //     Float_t zSICHIP[6]={6.,7.,8.,1.,14., 47.};
276 //     Float_t wSICHIP[6]={0.039730642,0.001396798,0.01169634,
277 //                      0.004367771,0.844665,0.09814344903};
278 //     Float_t dSICHIP = 2.36436;
279
280 //     //Inox
281 //     Float_t aINOX[9]={12.0107,54.9380, 28.0855,30.9738,32.066,
282 //                    58.6928,55.9961,95.94,55.845};
283 //     Float_t zINOX[9]={6.,25.,14.,15.,16., 28.,24.,42.,26.};
284 //     Float_t wINOX[9]={0.0003,0.02,0.01,0.00045,0.0003,0.12,0.17,0.025,0.654};
285 //     Float_t dINOX = 8.03;
286
287 //     //SDD HV microcable
288 //     Float_t aHVm[5]={12.0107,1.00794,14.0067,15.9994,26.981538};
289 //     Float_t zHVm[5]={6.,1.,7.,8.,13.};
290 //     Float_t wHVm[5]={0.520088819984,0.01983871336,0.0551367996,0.157399667056, 0.247536};
291 //     Float_t dHVm = 1.6087;
292
293 //     //SDD LV+signal cable
294 //     Float_t aLVm[5]={12.0107,1.00794,14.0067,15.9994,26.981538};
295 //     Float_t zLVm[5]={6.,1.,7.,8.,13.};
296 //     Float_t wLVm[5]={0.21722436468,0.0082859922,0.023028867,0.06574077612, 0.68572};
297 //     Float_t dLVm = 2.1035;
298
299 //     //SDD hybrid microcab
300 //     Float_t aHLVm[5]={12.0107,1.00794,14.0067,15.9994,26.981538};
301 //     Float_t zHLVm[5]={6.,1.,7.,8.,13.};
302 //     Float_t wHLVm[5]={0.24281879711,0.00926228815,0.02574224025,0.07348667449, 0.64869};
303 //     Float_t dHLVm = 2.0502;
304
305 //     //SDD anode microcab
306 //     Float_t aALVm[5]={12.0107,1.00794,14.0067,15.9994,26.981538};
307 //     Float_t zALVm[5]={6.,1.,7.,8.,13.};
308 //     Float_t wALVm[5]={0.392653705471,0.0128595919215,
309 //                    0.041626868025,0.118832707289, 0.431909};
310 //     Float_t dALVm = 2.0502;
311
312 //     //X7R capacitors
313 //     Float_t aX7R[7]={137.327,47.867,15.9994,58.6928,63.5460,118.710,207.2};
314 //     Float_t zX7R[7]={56.,22.,8.,28.,29.,50.,82.};
315 //     Float_t wX7R[7]={0.251639432,0.084755042,0.085975822,
316 //                   0.038244751,0.009471271,0.321736471,0.2081768};
317 //     Float_t dX7R = 7.14567;
318
319 //     // AIR
320 //     Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
321 //     Float_t zAir[4]={6.,7.,8.,18.};
322 //     Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
323 //     Float_t dAir = 1.20479E-3;
324
325 //     // Water
326 //     Float_t aWater[2]={1.00794,15.9994};
327 //     Float_t zWater[2]={1.,8.};
328 //     Float_t wWater[2]={0.111894,0.888106};
329 //     Float_t dWater   = 1.0;
330
331 //     // CERAMICS
332 //   //     94.4% Al2O3 , 2.8% SiO2 , 2.3% MnO , 0.5% Cr2O3
333 //     Float_t acer[5]  = { 26.981539,15.9994,28.0855,54.93805,51.9961 };
334 //     Float_t zcer[5]  = {       13.,     8.,    14.,     25.,    24. };
335 //     Float_t wcer[5]  = {.4443408,.5213375,.0130872,.0178135,.003421};
336 //     Float_t denscer  = 3.6;
337
338 //     //G10FR4
339 //     Float_t zG10FR4[14] = {14.00,    20.00,  13.00,  12.00,  5.00,
340 //                         22.00,       11.00,  19.00,  26.00,  9.00,
341 //                         8.00,        6.00,   7.00,   1.00};
342 //     Float_t aG10FR4[14] = {28.0855000,40.0780000,26.9815380,24.3050000,
343 //                         10.8110000,47.8670000,22.9897700,39.0983000,
344 //                         55.8450000,18.9984000,15.9994000,12.0107000,
345 //                         14.0067000,1.0079400};
346 //     Float_t wG10FR4[14] = {0.15144894,0.08147477,0.04128158,0.00904554,
347 //                         0.01397570,0.00287685,0.00445114,0.00498089,
348 //                         0.00209828,0.00420000,0.36043788,0.27529426,
349 //                         0.01415852,0.03427566};
350 //     Float_t densG10FR4= 1.8;
351     
352 //      //--- EPOXY  --- C18 H19 O3
353 //       Float_t aEpoxy[3] = {15.9994, 1.00794, 12.0107} ; 
354 //       Float_t zEpoxy[3] = {     8.,      1.,      6.} ; 
355 //       Float_t wEpoxy[3] = {     3.,     19.,     18.} ; 
356 //       Float_t dEpoxy = 1.8 ;
357
358 //       // rohacell: C9 H13 N1 O2
359 //     Float_t arohac[4] = {12.01,  1.01, 14.010, 16.};
360 //     Float_t zrohac[4] = { 6.,    1.,    7.,     8.};
361 //     Float_t wrohac[4] = { 9.,   13.,    1.,     2.};
362 //     Float_t drohac    = 0.05;
363
364 //     // If he/she means stainless steel (inox) + Aluminium and Zeff=15.3383 then
365 // //
366 // // %Al=81.6164 %inox=100-%Al
367
368 //     Float_t aInAl[5] = {27., 55.847,51.9961,58.6934,28.0855 };
369 //     Float_t zInAl[5] = {13., 26.,24.,28.,14. };
370 //     Float_t wInAl[5] = {.816164, .131443,.0330906,.0183836,.000919182};
371 //     Float_t dInAl    = 3.075;
372
373 //     // Kapton
374 //     Float_t aKapton[4]={1.00794,12.0107, 14.010,15.9994};
375 //     Float_t zKapton[4]={1.,6.,7.,8.};
376 //     Float_t wKapton[4]={0.026362,0.69113,0.07327,0.209235};
377 //     Float_t dKapton   = 1.42;
378
379 //     //SDD ruby sph.
380 //     Float_t aAlOxide[2]  = { 26.981539,15.9994};
381 //     Float_t zAlOxide[2]  = {       13.,     8.};
382 //     Float_t wAlOxide[2]  = {0.4707, 0.5293};
383 //     Float_t dAlOxide     = 3.97;
384
385 //     //---------
386 //     AliMaterial(1,"ITSsddSi",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
387 //     AliMedium(1,"ITSsddSi",1,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
388     
389 //     AliMixture(5,"ITSair",aAir,zAir,dAir,4,wAir);
390 //     AliMedium(5,"ITSair",5,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
391     
392 //     AliMixture(7,"ITSsddSiChip",aSICHIP,zSICHIP,dSICHIP,6,wSICHIP);
393 //     AliMedium(7,"ITSsddSiChip",7,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
394
395 //     AliMaterial(79,"SDD SI insensitive$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
396 //     AliMedium(79,"SDD SI insensitive$",79,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
397
398 //     AliMaterial(11,"ITSal",0.26982E+02,0.13000E+02,0.26989E+01,0.89000E+01,0.99900E+03);
399 //     AliMedium(11,"ITSal",11,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
400
401 //     AliMixture(9,"ITSsddCarbonM55J",aCM55J,zCM55J,dCM55J,4,wCM55J);
402 //     AliMedium(9,"ITSsddCarbonM55J",9,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
403
404 //     AliMixture(10,"SDD AIR$",aAir,zAir,dAir,4,wAir);
405 //     AliMedium(10,"SDD AIR$",10,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
406
407 //     AliMixture(12, "WATER",aWater,zWater,dWater,2,wWater);
408 //     AliMedium(12,"WATER",12,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
409
410 //      AliMixture(69,"ITSsddCAlM55J",aALCM55J,zALCM55J,dALCM55J,5,wALCM55J);
411 //     AliMedium(69,"ITSsddCAlM55J",69,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
412   
413 //     AliMixture(70, "ITSsddKAPTON_POLYCH2", aKapton, zKapton, dKapton, 4, wKapton);
414 //     AliMedium(70,"ITSsddKAPTON_POLYCH2",70,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
415
416 //     AliMixture(77,"SDDX7Rcapacitors",aX7R,zX7R,dX7R,7,wX7R);
417 //     AliMedium(77,"SDDX7Rcapacitors",77,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
418
419 //     AliMixture(78,"SDD ruby sph. Al2O3$",aAlOxide,zAlOxide,dAlOxide,2,wAlOxide);
420 //     AliMedium(78,"SDD ruby sph. Al2O3$",78,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
421
422
423 //     AliMaterial(64,"ALUMINUM$",0.26982E+02,0.13000E+02,0.26989E+01,0.89000E+01,0.99900E+03);
424 //     AliMedium(64,"ALUMINUM$",64,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
425
426 //     AliMaterial(14,"COPPER",0.63546E+02,0.29000E+02,0.89600E+01,0.14300E+01,0.99900E+03);
427 //     AliMedium(14,"COPPER",14,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
428
429 //     AliMaterial(2,"SPD SI CHIP$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
430 //     AliMedium(2,"SPD SI CHIP$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
431
432 //     AliMaterial(3,"SPD SI BUS$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
433 //     AliMedium(3,"SPD SI BUS$",3,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
434
435 //     AliMixture(4,"C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
436 //     AliMedium(4,"C (M55J)$",4,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
437
438  
439 //     AliMixture(6,"GEN AIR$",aAir,zAir,dAir,4,wAir);
440 //     AliMedium(6,"GEN AIR$",6,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
441
442 //     AliMixture(13,"Freon$",afre,zfre,densfre,-2,wfre);
443 //     AliMedium(13,"Freon$",13,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
444
445
446 //     AliMixture(15,"CERAMICS$",acer,zcer,denscer,5,wcer);
447 //     AliMedium(15,"CERAMICS$",15,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
448
449 //     AliMixture(20,"SSD C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
450 //     AliMedium(20,"SSD C (M55J)$",20,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
451
452 //     AliMixture(21,"SSD AIR$",aAir,zAir,dAir,4,wAir);
453 //     AliMedium(21,"SSD AIR$",21,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
454
455 //     AliMixture(25,"G10FR4$",aG10FR4,zG10FR4,densG10FR4,14,wG10FR4);
456 //     AliMedium(25,"G10FR4$",25,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
457
458 //      AliMixture(26,"GEN C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
459 //     AliMedium(26,"GEN C (M55J)$",26,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
460
461 //     AliMixture(27,"GEN Air$",aAir,zAir,dAir,4,wAir);
462 //     AliMedium(27,"GEN Air$",27,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
463
464 //     AliMaterial(51,"SPD SI$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
465 //     AliMedium(51,"SPD SI$",51,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
466
467 //     AliMaterial(52,"SPD SI CHIP$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
468 //     AliMedium(52,"SPD SI CHIP$",52,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
469
470 //     AliMaterial(53,"SPD SI BUS$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
471 //     AliMedium(53,"SPD SI BUS$",53,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
472
473 //     AliMixture(54,"SPD C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
474 //     AliMedium(54,"SPD C (M55J)$",54,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
475
476 //     AliMixture(55,"SPD AIR$",aAir,zAir,dAir,4,wAir);
477 //     AliMedium(55,"SPD AIR$",55,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
478
479 //     AliMixture(56, "SPD KAPTON(POLYCH2)", aKapton, zKapton, dKapton, 4, wKapton);
480 //     AliMedium(56,"SPD KAPTON(POLYCH2)$",56,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
481
482 //     AliMixture(61,"EPOXY$",aEpoxy,zEpoxy,dEpoxy,-3,wEpoxy);
483 //     AliMedium(61,"EPOXY$",61,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
484
485 //     AliMaterial(62,"SILICON$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
486 //     AliMedium(62,"SILICON$",62,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
487
488 //     AliMixture(63, "KAPTONH(POLYCH2)", aKapton, zKapton, dKapton, 4, wKapton);
489 //     AliMedium(63,"KAPTONH(POLYCH2)$",63,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
490
491
492 //     AliMixture(65,"INOX$",aINOX,zINOX,dINOX,9,wINOX);
493 //     AliMedium(65,"INOX$",65,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
494
495 //     AliMixture(68,"ROHACELL$",arohac,zrohac,drohac,-4,wrohac);
496 //     AliMedium(68,"ROHACELL$",68,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
497
498
499 //      AliMaterial(71,"ITS SANDW A$",0.12011E+02,0.60000E+01,0.2115E+00,0.17479E+03,0.99900E+03);
500 //     AliMedium(71,"ITS SANDW A$",71,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
501
502 //     AliMaterial(72,"ITS SANDW B$",0.12011E+02,0.60000E+01,0.27000E+00,0.18956E+03,0.99900E+03);
503 //     AliMedium(72,"ITS SANDW B$",72,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
504
505 //     AliMaterial(73,"ITS SANDW C$",0.12011E+02,0.60000E+01,0.41000E+00,0.90868E+02,0.99900E+03);
506 //     AliMedium(73,"ITS SANDW C$",73,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
507
508 //     AliMaterial(74,"HEAT COND GLUE$",0.12011E+02,0.60000E+01,0.1930E+01,0.22100E+02,0.99900E+03);
509 //     AliMedium(74,"HEAT COND GLUE$",74,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
510
511 //     AliMaterial(75,"ELASTO SIL$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
512 //     AliMedium(75,"ELASTO SIL$",75,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
513
514 //     AliMaterial(76,"SPDBUS(AL+KPT+EPOX)$",0.19509E+02,0.96502E+01,0.19060E+01,0.15413E+02,0.99900E+03);
515 //     AliMedium(76,"SPDBUS(AL+KPT+EPOX)$",76,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
516                
517
518 //     AliMixture(80,"SDD HV microcable$",aHVm,zHVm,dHVm,5,wHVm);
519 //     AliMedium(80,"SDD HV microcable$",80,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
520
521 //     AliMixture(81,"SDD LV+signal cable$",aLVm,zLVm,dLVm,5,wLVm);
522 //     AliMedium(81,"SDD LV+signal cable$",81,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
523
524 //     AliMixture(82,"SDD hybrid microcab$",aHLVm, zHLVm,dHLVm,5,wHLVm);
525 //     AliMedium(82,"SDD hybrid microcab$",82,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
526
527 //     AliMixture(83,"SDD anode microcab$",aALVm,zALVm,dALVm,5,wALVm);
528 //     AliMedium(83,"SDD anode microcab$",83,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
529
530 //     AliMaterial(84,"SDD/SSD rings$",0.123565E+02,0.64561E+01,0.18097E+01,0.229570E+02,0.99900E+03);
531 //     AliMedium(84,"SDD/SSD rings$",84,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
532
533 //     AliMixture(85,"inox/alum$",aInAl,zInAl,dInAl,5,wInAl);
534 //     AliMedium(85,"inox/alum$",85,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
535
536
537 //     // special media to take into account services in the SDD and SSD 
538 //     // cones for the FMD
539
540 //        Float_t aA[13],zZ[13],wW[13],den;
541 //     // From Pierluigi Barberis calculations of 2SPD+1SDD October 2 2002.
542 //     zZ[0] = 1.0; aA[0] = 1.00794; // Hydrogen
543 //     zZ[1] = 6.0; aA[1] = 12.011; // Carbon
544 //     zZ[2] = 7.0; aA[2] = 14.00674; // Nitrogen
545 //     zZ[3] = 8.0; aA[3] = 15.9994; // Oxigen
546 //     zZ[4] = 14.0; aA[4] = 28.0855; // Silicon
547 //     zZ[5] = 24.0; aA[5] = 51.9961; //Cromium
548 //     zZ[6] = 25.0; aA[6] = 54.938049; // Manganese
549 //     zZ[7] = 26.0; aA[7] = 55.845; // Iron
550 //     zZ[8] = 28.0; aA[8] = 58.6934; // Nickle
551 //     zZ[9] = 29.0; aA[9] = 63.546; // Copper
552 //     zZ[10] = 13.0; aA[10] = 26.981539; // Alulminum
553 //     zZ[11] = 47.0; aA[11] = 107.8682; // Silver
554 //     zZ[12] = 27.0; aA[12] = 58.9332; // Cobolt
555 //     wW[0] = 0.019965;
556 //     wW[1] = 0.340961;
557 //     wW[2] = 0.041225;
558 //     wW[3] = 0.200352;
559 //     wW[4] = 0.000386;
560 //     wW[5] = 0.001467;
561 //     wW[6] = 0.000155;
562 //     wW[7] = 0.005113;
563 //     wW[8] = 0.000993;
564 //     wW[9] = 0.381262;
565 //     wW[10] = 0.008121;
566 //     wW[11] = 0.000000;
567 //     wW[12] = 0.000000;
568 //     if(fByThick){// New values seeITS_MatBudget_4B.xls
569 //      den = 1.5253276; // g/cm^3  Cell O370
570 //     }else{
571 //      den = 2.58423412; // g/cm^3 Cell L370
572 //     } // end if fByThick
573 //     //den = 6161.7/(3671.58978);//g/cm^3 Volume does not exclude holes
574 //     AliMixture(86,"AIRFMDSDD$",aA,zZ,den,+11,wW);
575 //     AliMedium(86,"AIRFMDSDD$",86,0,ifield,fieldm,tmaxfdAir,stemaxAir,
576 //            deemaxAir,epsilAir,stminAir);
577
578
579 //     wW[0] = 0.019777;
580 //     wW[1] = 0.325901;
581 //     wW[2] = 0.031848;
582 //     wW[3] = 0.147668;
583 //     wW[4] = 0.030609;
584 //     wW[5] = 0.013993;
585 //     wW[6] = 0.001479;
586 //     wW[7] = 0.048792;
587 //     wW[8] = 0.009477;
588 //     wW[9] = 0.350697;
589 //     wW[10] = 0.014546;
590 //     wW[11] = 0.005213;
591 //     wW[12] = 0.000000;
592 //     if(fByThick){// New values seeITS_MatBudget_4B.xls
593 //      den = 1.2464275; // g/cm^3   Cell O403
594 //     }else{
595 //      den = 1.28134409; // g/cm^3  Cell L403
596 //     } // end if fByThick
597 //     //den = 7666.3/(9753.553259); // volume does not exclude holes
598 //     AliMixture(87,"AIRFMDSSD$",aA,zZ,den,+12,wW); 
599 //     AliMedium(87,"AIRFMDSSD$",87,0,ifield,fieldm,tmaxfdAir,stemaxAir,
600 //            deemaxAir,epsilAir,stminAir);
601
602 //     wW[0] = 0.016302;
603 //     wW[1] = 0.461870;
604 //     wW[2] = 0.033662;
605 //     wW[3] = 0.163595;
606 //     wW[4] = 0.000315;
607 //     wW[5] = 0.001197;
608 //     wW[6] = 0.000127;
609 //     wW[7] = 0.004175;
610 //     wW[8] = 0.000811;
611 //     wW[9] = 0.311315;
612 //     wW[10] = 0.006631;
613 //     wW[11] = 0.000000;
614 //     wW[12] = 0.000000;
615 //     if(fByThick){// New values seeITS_MatBudget_4B.xls
616 //      den = 1.9353276; // g/cm^3  Cell N370
617 //     }else{
618 //      den = 3.2788626; // g/cm^3 Cell F370
619 //     } // end if fByThick
620 //     //den = 7667.1/(3671.58978); // Volume does not excludeholes
621 //     AliMixture(88,"ITS SANDW CFMDSDD$",aA,zZ,den,+11,wW); 
622 //     AliMedium(88,"ITS SANDW CFMDSDD$",88,0,ifield,fieldm,tmaxfd,stemax,
623 //            deemax,epsil,stmin);
624
625 //     wW[0] = 0.014065;
626 //     wW[1] = 0.520598;
627 //     wW[2] = 0.022650;
628 //     wW[3] = 0.105018;
629 //     wW[4] = 0.021768;
630 //     wW[5] = 0.009952;
631 //     wW[6] = 0.001051;
632 //     wW[7] = 0.034700;
633 //     wW[8] = 0.006740;
634 //     wW[9] = 0.249406;
635 //     wW[10] = 0.010345;
636 //     wW[11] = 0.0003707;
637 //     wW[12] = 0.000000;
638 //     if(fByThick){// New values seeITS_MatBudget_4B.xls
639 //      den = 1.6564275; // g/cm^3  Cell N304
640 //     }else{
641 //      den = 1.7028296; // g/cm^3  Cell F304
642 //     } // end if fByThick
643 //     //den = 1166.5/(3671.58978); // Volume does not exclude holes
644 //     AliMixture(89,"ITS SANDW CFMDSSD$",aA,zZ,den,+12,wW); 
645 //     AliMedium(89,"ITS SANDW CFMDSSD$",89,0,ifield,fieldm,tmaxfd,stemax,
646 //            deemax,epsil,stmin);
647
648 //     wW[0] = 0.005970;
649 //     wW[1] = 0.304704;
650 //     wW[2] = 0.042510;
651 //     wW[3] = 0.121715;
652 //     wW[4] = 0.001118;
653 //     wW[5] = 0.030948;
654 //     wW[6] = 0.003270;
655 //     wW[7] = 0.107910;
656 //     wW[8] = 0.020960;
657 //     wW[9] = 0.360895;
658 //     wW[10] = 0.000000;
659 //     wW[11] = 0.000000;
660 //     wW[12] = 0.000000;
661 //     if(fByThick){// New values seeITS_MatBudget_4B.xls
662 //      den = 80.31136576; // g/cm^3 Cell H329
663 //     }else{
664 //      den = 87.13062; // g/cm^3  Cell G329
665 //     } // end if fByThick
666 //     //den = 1251.3/(0.05*2.0*TMath::Pi()*(7.75*7.75 - 3.7*3.7)); // g/cm^3
667 //     AliMixture(97,"SPD SERVICES$",aA,zZ,den,+10,wW); 
668 //     AliMedium(97,"SPD SERVICES$",97,0,ifield,fieldm,tmaxfd,stemax,
669 //            deemax,epsil,stmin);
670
671 //     // Special media
672
673 //     AliMaterial(90,"SPD shield$", 12.011, 6., 1.93/10. , 22.1*10., 999);
674 //     AliMedium(90,"SPD shield$",90,0,ifield,fieldm,tmaxfdServ,stemaxServ,
675 //            deemaxServ,epsilServ,stminServ);
676
677 //     AliMaterial(91, "SPD End ladder$", 47.0447, 21.7963, 3.6374, 4.4711, 999); 
678 //     AliMedium(91,"SPD End ladder$",91,0,ifield,fieldm,tmaxfdServ,stemaxServ,
679 //            deemaxServ,epsilServ,stminServ);
680
681 //     AliMaterial(92, "SPD cone$",28.0855, 14., 2.33, 9.36, 999);    
682 //     AliMedium(92,"SPD cone$",92,0,ifield,fieldm,tmaxfdServ,stemaxServ,
683 //            deemaxServ,epsilServ,stminServ);
684
685 // //     Material with fractional Z not actually used
686 // //     AliMaterial(93, "SDD End ladder$", 69.9298, 29.8246, 0.3824, 36.5103, 999);
687 // //     AliMedium(93,"SDD End ladder$",93,0,ifield,fieldm,tmaxfdServ,stemaxServ,
688 // //               deemaxServ,epsilServ,stminServ);
689
690 //     AliMaterial(94, "SDD cone$",63.546, 29., 1.15, 1.265, 999);
691 //     AliMedium(94,"SDD cone$",94,0,ifield,fieldm,tmaxfdServ,stemaxServ,
692 //            deemaxServ,epsilServ,stminServ);
693
694 // //     Material with fractional Z not actually used
695 // //     AliMaterial(95, "SSD End ladder$", 32.0988, 15.4021, 0.68, 35.3238, 999); 
696 // //     AliMedium(95,"SSD End ladder$",95,0,ifield,fieldm,tmaxfdServ,stemaxServ,
697 // //     deemaxServ,epsilServ,stminServ);
698
699 //     AliMaterial(96, "SSD cone$",63.546, 29., 1.15, 1.265, 999);
700 //     AliMedium(96,"SSD cone$",96,0,ifield,fieldm,tmaxfdServ,stemaxServ,
701 //            deemaxServ,epsilServ,stminServ);
702
703
704     Int_t   ifield = gAlice->Field()->Integ();
705     Float_t fieldm = gAlice->Field()->Max();
706
707     Float_t tmaxfd = 0.1; // 1.0; // Degree
708     Float_t stemax = 1.0; // cm
709     Float_t deemax = 0.1; // 30.0; // Fraction of particle's energy 0<deemax<=1
710     Float_t epsil  = 1.0E-4; // 1.0; // cm
711     Float_t stmin  = 0.0; // cm "Default value used"
712
713     Float_t tmaxfdSi = 0.1; // .10000E+01; // Degree
714     Float_t stemaxSi = 0.0075; //  .10000E+01; // cm
715     Float_t deemaxSi = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1
716     Float_t epsilSi  = 1.0E-4;// .10000E+01;
717     Float_t stminSi  = 0.0; // cm "Default value used"
718
719     Float_t tmaxfdAir = 0.1; // .10000E+01; // Degree
720     Float_t stemaxAir = .10000E+01; // cm
721     Float_t deemaxAir = 0.1; // 0.30000E-02; // Fraction of particle's energy 0<deemax<=1
722     Float_t epsilAir  = 1.0E-4;// .10000E+01;
723     Float_t stminAir  = 0.0; // cm "Default value used"
724
725     Float_t tmaxfdServ = 1.0; // 10.0; // Degree
726     Float_t stemaxServ = 1.0; // 0.01; // cm
727     Float_t deemaxServ = 0.5; // 0.1; // Fraction of particle's energy 0<deemax<=1
728     Float_t epsilServ  = 1.0E-3; // 0.003; // cm
729     Float_t stminServ  = 0.0; //0.003; // cm "Default value used"
730
731     // Freon PerFluorobuthane C4F10 see 
732     // http://st-support-cooling-electronics.web.cern.ch/
733     //        st-support-cooling-electronics/default.htm
734     Float_t afre[2]  = { 12.011,18.9984032 };
735     Float_t zfre[2]  = { 6., 9. };
736     Float_t wfre[2]  = { 4.,10. };
737     Float_t densfre  = 1.52;
738
739
740     //CM55J
741
742     Float_t aCM55J[4]={12.0107,14.0067,15.9994,1.00794};
743     Float_t zCM55J[4]={6.,7.,8.,1.};
744     Float_t wCM55J[4]={0.908508078,0.010387573,0.055957585,0.025146765};
745     Float_t dCM55J = 1.63;
746
747     //ALCM55J
748
749     Float_t aALCM55J[5]={12.0107,14.0067,15.9994,1.00794,26.981538};
750     Float_t zALCM55J[5]={6.,7.,8.,1.,13.};
751     Float_t wALCM55J[5]={0.817657902,0.0093488157,0.0503618265,0.0226320885,0.1};
752     Float_t dALCM55J = 1.9866;
753
754     //Si Chips
755
756     Float_t aSICHIP[6]={12.0107,14.0067,15.9994,1.00794,28.0855,107.8682};
757     Float_t zSICHIP[6]={6.,7.,8.,1.,14., 47.};
758     Float_t wSICHIP[6]={0.039730642,0.001396798,0.01169634,0.004367771,0.844665,0.09814344903};
759     Float_t dSICHIP = 2.36436;
760
761     //Inox
762     
763     Float_t aINOX[9]={12.0107,54.9380, 28.0855,30.9738,32.066,58.6928,55.9961,95.94,55.845};
764     Float_t zINOX[9]={6.,25.,14.,15.,16., 28.,24.,42.,26.};
765     Float_t wINOX[9]={0.0003,0.02,0.01,0.00045,0.0003,0.12,0.17,0.025,0.654};
766     Float_t dINOX = 8.03;
767
768     //SDD HV microcable
769
770     Float_t aHVm[5]={12.0107,1.00794,14.0067,15.9994,26.981538};
771     Float_t zHVm[5]={6.,1.,7.,8.,13.};
772     Float_t wHVm[5]={0.520088819984,0.01983871336,0.0551367996,0.157399667056, 0.247536};
773     Float_t dHVm = 1.6087;
774
775     //SDD LV+signal cable
776
777     Float_t aLVm[5]={12.0107,1.00794,14.0067,15.9994,26.981538};
778     Float_t zLVm[5]={6.,1.,7.,8.,13.};
779     Float_t wLVm[5]={0.21722436468,0.0082859922,0.023028867,0.06574077612, 0.68572};
780     Float_t dLVm = 2.1035;
781
782     //SDD hybrid microcab
783
784     Float_t aHLVm[5]={12.0107,1.00794,14.0067,15.9994,26.981538};
785     Float_t zHLVm[5]={6.,1.,7.,8.,13.};
786     Float_t wHLVm[5]={0.24281879711,0.00926228815,0.02574224025,0.07348667449, 0.64869};
787     Float_t dHLVm = 2.0502;
788
789     //SDD anode microcab
790
791     Float_t aALVm[5]={12.0107,1.00794,14.0067,15.9994,26.981538};
792     Float_t zALVm[5]={6.,1.,7.,8.,13.};
793     Float_t wALVm[5]={0.392653705471,0.0128595919215,0.041626868025,0.118832707289, 0.431909};
794     Float_t dALVm = 2.0502;
795
796     //X7R capacitors
797
798     Float_t aX7R[7]={137.327,47.867,15.9994,58.6928,63.5460,118.710,207.2};
799     Float_t zX7R[7]={56.,22.,8.,28.,29.,50.,82.};
800     Float_t wX7R[7]={0.251639432,0.084755042,0.085975822,0.038244751,0.009471271,0.321736471,0.2081768};
801     Float_t dX7R = 7.14567;
802
803     // AIR
804
805     Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
806     Float_t zAir[4]={6.,7.,8.,18.};
807     Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
808     Float_t dAir = 1.20479E-3;
809
810     // Water
811
812     Float_t aWater[2]={1.00794,15.9994};
813     Float_t zWater[2]={1.,8.};
814     Float_t wWater[2]={0.111894,0.888106};
815     Float_t dWater   = 1.0;
816
817     // CERAMICS
818   //     94.4% Al2O3 , 2.8% SiO2 , 2.3% MnO , 0.5% Cr2O3
819     Float_t acer[5]  = { 26.981539,15.9994,28.0855,54.93805,51.9961 };
820     Float_t zcer[5]  = {       13.,     8.,    14.,     25.,    24. };
821     Float_t wcer[5]  = {.4443408,.5213375,.0130872,.0178135,.003421};
822     Float_t denscer  = 3.6;
823
824     //G10FR4
825
826     Float_t zG10FR4[14] = {14.00,       20.00,  13.00,  12.00,  5.00,   22.00,  11.00,  19.00,  26.00,  9.00,   8.00,   6.00,   7.00,   1.00};
827     Float_t aG10FR4[14] = {28.0855000,40.0780000,26.9815380,24.3050000,10.8110000,47.8670000,22.9897700,39.0983000,55.8450000,18.9984000,15.9994000,12.0107000,14.0067000,1.0079400};
828     Float_t wG10FR4[14] = {0.15144894,0.08147477,0.04128158,0.00904554,0.01397570,0.00287685,0.00445114,0.00498089,0.00209828,0.00420000,0.36043788,0.27529426,0.01415852,0.03427566};
829     Float_t densG10FR4= 1.8;
830     
831      //--- EPOXY  --- C18 H19 O3
832       Float_t aEpoxy[3] = {15.9994, 1.00794, 12.0107} ; 
833       Float_t zEpoxy[3] = {     8.,      1.,      6.} ; 
834       Float_t wEpoxy[3] = {     3.,     19.,     18.} ; 
835       Float_t dEpoxy = 1.8 ;
836
837       // rohacell: C9 H13 N1 O2
838     Float_t arohac[4] = {12.01,  1.01, 14.010, 16.};
839     Float_t zrohac[4] = { 6.,    1.,    7.,     8.};
840     Float_t wrohac[4] = { 9.,   13.,    1.,     2.};
841     Float_t drohac    = 0.05;
842
843     // If he/she means stainless steel (inox) + Aluminium and Zeff=15.3383 then
844 //
845 // %Al=81.6164 %inox=100-%Al
846
847     Float_t aInAl[5] = {27., 55.847,51.9961,58.6934,28.0855 };
848     Float_t zInAl[5] = {13., 26.,24.,28.,14. };
849     Float_t wInAl[5] = {.816164, .131443,.0330906,.0183836,.000919182};
850     Float_t dInAl    = 3.075;
851
852     // Kapton
853
854     Float_t aKapton[4]={1.00794,12.0107, 14.010,15.9994};
855     Float_t zKapton[4]={1.,6.,7.,8.};
856     Float_t wKapton[4]={0.026362,0.69113,0.07327,0.209235};
857     Float_t dKapton   = 1.42;
858
859     //SDD ruby sph.
860     Float_t aAlOxide[2]  = { 26.981539,15.9994};
861     Float_t zAlOxide[2]  = {       13.,     8.};
862     Float_t wAlOxide[2]  = {0.4707, 0.5293};
863     Float_t dAlOxide     = 3.97;
864
865
866     AliMaterial(1,"SI$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
867     AliMedium(1,"SI$",1,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
868
869     AliMaterial(2,"SPD SI CHIP$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
870     AliMedium(2,"SPD SI CHIP$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
871
872     AliMaterial(3,"SPD SI BUS$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
873     AliMedium(3,"SPD SI BUS$",3,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
874
875     AliMixture(4,"C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
876     AliMedium(4,"C (M55J)$",4,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
877
878     AliMixture(5,"AIR$",aAir,zAir,dAir,4,wAir);
879     AliMedium(5,"AIR$",5,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
880
881     AliMixture(6,"GEN AIR$",aAir,zAir,dAir,4,wAir);
882     AliMedium(6,"GEN AIR$",6,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
883
884     AliMixture(7,"SDD SI CHIP$",aSICHIP,zSICHIP,dSICHIP,6,wSICHIP);
885     AliMedium(7,"SDD SI CHIP$",7,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
886
887     AliMixture(9,"SDD C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
888     AliMedium(9,"SDD C (M55J)$",9,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
889
890     AliMixture(10,"SDD AIR$",aAir,zAir,dAir,4,wAir);
891     AliMedium(10,"SDD AIR$",10,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
892
893     AliMaterial(11,"AL$",0.26982E+02,0.13000E+02,0.26989E+01,0.89000E+01,0.99900E+03);
894     AliMedium(11,"AL$",11,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
895
896     AliMixture(12, "Water$",aWater,zWater,dWater,2,wWater);
897     AliMedium(12,"WATER$",12,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
898
899     AliMixture(13,"Freon$",afre,zfre,densfre,-2,wfre);
900     AliMedium(13,"Freon$",13,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
901
902     AliMaterial(14,"COPPER$",0.63546E+02,0.29000E+02,0.89600E+01,0.14300E+01,0.99900E+03);
903     AliMedium(14,"COPPER$",14,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
904     AliMixture(15,"CERAMICS$",acer,zcer,denscer,5,wcer);
905     AliMedium(15,"CERAMICS$",15,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
906
907     AliMixture(20,"SSD C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
908     AliMedium(20,"SSD C (M55J)$",20,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
909
910     AliMixture(21,"SSD AIR$",aAir,zAir,dAir,4,wAir);
911     AliMedium(21,"SSD AIR$",21,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
912
913     AliMixture(25,"G10FR4$",aG10FR4,zG10FR4,densG10FR4,14,wG10FR4);
914     AliMedium(25,"G10FR4$",25,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
915
916      AliMixture(26,"GEN C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
917     AliMedium(26,"GEN C (M55J)$",26,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
918
919     AliMixture(27,"GEN Air$",aAir,zAir,dAir,4,wAir);
920     AliMedium(27,"GEN Air$",27,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
921
922     AliMaterial(51,"SPD SI$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
923     AliMedium(51,"SPD SI$",51,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
924
925     AliMaterial(52,"SPD SI CHIP$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
926     AliMedium(52,"SPD SI CHIP$",52,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
927
928     AliMaterial(53,"SPD SI BUS$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
929     AliMedium(53,"SPD SI BUS$",53,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
930
931     AliMixture(54,"SPD C (M55J)$",aCM55J,zCM55J,dCM55J,4,wCM55J);
932     AliMedium(54,"SPD C (M55J)$",54,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
933
934     AliMixture(55,"SPD AIR$",aAir,zAir,dAir,4,wAir);
935     AliMedium(55,"SPD AIR$",55,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
936
937     AliMixture(56, "SPD KAPTON(POLYCH2)", aKapton, zKapton, dKapton, 4, wKapton);
938     AliMedium(56,"SPD KAPTON(POLYCH2)$",56,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
939
940     AliMixture(61,"EPOXY$",aEpoxy,zEpoxy,dEpoxy,-3,wEpoxy);
941     AliMedium(61,"EPOXY$",61,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
942
943     AliMaterial(62,"SILICON$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
944     AliMedium(62,"SILICON$",62,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
945
946     AliMixture(63, "KAPTONH(POLYCH2)", aKapton, zKapton, dKapton, 4, wKapton);
947     AliMedium(63,"KAPTONH(POLYCH2)$",63,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
948
949     AliMaterial(64,"ALUMINUM$",0.26982E+02,0.13000E+02,0.26989E+01,0.89000E+01,0.99900E+03);
950     AliMedium(64,"ALUMINUM$",64,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
951
952     AliMixture(65,"INOX$",aINOX,zINOX,dINOX,9,wINOX);
953     AliMedium(65,"INOX$",65,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
954
955     AliMixture(68,"ROHACELL$",arohac,zrohac,drohac,-4,wrohac);
956     AliMedium(68,"ROHACELL$",68,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
957
958      AliMixture(69,"SDD C AL (M55J)$",aALCM55J,zALCM55J,dALCM55J,5,wALCM55J);
959     AliMedium(69,"SDD C AL (M55J)$",69,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
960   
961     AliMixture(70, "SDDKAPTON (POLYCH2)", aKapton, zKapton, dKapton, 4, wKapton);
962     AliMedium(70,"SDDKAPTON (POLYCH2)$",70,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
963
964      AliMaterial(71,"ITS SANDW A$",0.12011E+02,0.60000E+01,0.2115E+00,0.17479E+03,0.99900E+03);
965     AliMedium(71,"ITS SANDW A$",71,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
966
967     AliMaterial(72,"ITS SANDW B$",0.12011E+02,0.60000E+01,0.27000E+00,0.18956E+03,0.99900E+03);
968     AliMedium(72,"ITS SANDW B$",72,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
969
970     AliMaterial(73,"ITS SANDW C$",0.12011E+02,0.60000E+01,0.41000E+00,0.90868E+02,0.99900E+03);
971     AliMedium(73,"ITS SANDW C$",73,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
972
973     AliMaterial(74,"HEAT COND GLUE$",0.12011E+02,0.60000E+01,0.1930E+01,0.22100E+02,0.99900E+03);
974     AliMedium(74,"HEAT COND GLUE$",74,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
975
976     AliMaterial(75,"ELASTO SIL$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
977     AliMedium(75,"ELASTO SIL$",75,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
978
979     // SPD bus (data from Petra Riedler)
980     Float_t aSPDbus[5] = {1.00794,12.0107,14.01,15.9994,26.982 };
981     Float_t zSPDbus[5] = {1.,6.,7.,8.,13.};
982     Float_t wSPDbus[5] = {0.023523,0.318053,0.009776,0.078057,0.570591};
983     Float_t dSPDbus    = 2.128505;
984
985     //   AliMaterial(76,"SPDBUS(AL+KPT+EPOX)$",0.19509E+02,0.96502E+01,0.19060E+01,0.15413E+02,0.99900E+03);
986     AliMixture(76,"SPDBUS(AL+KPT+EPOX)$",aSPDbus,zSPDbus,dSPDbus,5,wSPDbus);
987     AliMedium(76,"SPDBUS(AL+KPT+EPOX)$",76,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
988                
989     AliMixture(77,"SDD X7R capacitors$",aX7R,zX7R,dX7R,7,wX7R);
990     AliMedium(77,"SDD X7R capacitors$",77,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
991
992     AliMixture(78,"SDD ruby sph. Al2O3$",aAlOxide,zAlOxide,dAlOxide,2,wAlOxide);
993     AliMedium(78,"SDD ruby sph. Al2O3$",78,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
994
995     AliMaterial(79,"SDD SI insensitive$",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
996     AliMedium(79,"SDD SI insensitive$",79,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
997
998     AliMixture(80,"SDD HV microcable$",aHVm,zHVm,dHVm,5,wHVm);
999     AliMedium(80,"SDD HV microcable$",80,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1000
1001     AliMixture(81,"SDD LV+signal cable$",aLVm,zLVm,dLVm,5,wLVm);
1002     AliMedium(81,"SDD LV+signal cable$",81,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1003
1004     AliMixture(82,"SDD hybrid microcab$",aHLVm, zHLVm,dHLVm,5,wHLVm);
1005     AliMedium(82,"SDD hybrid microcab$",82,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1006
1007     AliMixture(83,"SDD anode microcab$",aALVm,zALVm,dALVm,5,wALVm);
1008     AliMedium(83,"SDD anode microcab$",83,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1009     Float_t aDSring[4]={12.0107,      1.00794,     14.0067,      15.9994};
1010     Float_t zDSring[4]={ 6.,          1.,           7.,           8.};
1011     Float_t wDSring[4]={ 0.854323888, 0.026408778,  0.023050265,  0.096217069};
1012     Float_t dDSring = 0.2875;
1013     AliMixture(84,"SDD/SSD rings$",aDSring,zDSring,dDSring,4,wDSring);
1014     AliMedium(84,"SDD/SSD rings$",84,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1015
1016     AliMixture(85,"inox/alum$",aInAl,zInAl,dInAl,5,wInAl);
1017     AliMedium(85,"inox/alum$",85,0,ifield,fieldm,tmaxfd,stemax,deemax,epsil,stmin);
1018
1019     // special media to take into account services in the SDD and SSD 
1020     // cones for the FMD
1021     //Begin_Html
1022     /*
1023       <A HREF="http://www.Physics.ohio-state.edu/~nilsen/ITS/ITS_MatBudget_4B.xls">
1024       </pre>
1025       <br clear=left>
1026       <font size=+2 color=blue>
1027       <p> The Exel spread sheet from which these density number come from.
1028       </font></A>
1029     */
1030     //End_Html
1031
1032     //  AliMaterial(86,"AIRFMDSDD$",0.14610E+02,0.73000E+01,0.12050E-02,0.30423E+05,0.99900E+03);
1033     Float_t aA[13],zZ[13],wW[13],den;
1034     // From Pierluigi Barberis calculations of 2SPD+1SDD October 2 2002.
1035     zZ[0] = 1.0; aA[0] = 1.00794; // Hydrogen
1036     zZ[1] = 6.0; aA[1] = 12.011; // Carbon
1037     zZ[2] = 7.0; aA[2] = 14.00674; // Nitrogen
1038     zZ[3] = 8.0; aA[3] = 15.9994; // Oxigen
1039     zZ[4] = 14.0; aA[4] = 28.0855; // Silicon
1040     zZ[5] = 24.0; aA[5] = 51.9961; //Cromium
1041     zZ[6] = 25.0; aA[6] = 54.938049; // Manganese
1042     zZ[7] = 26.0; aA[7] = 55.845; // Iron
1043     zZ[8] = 28.0; aA[8] = 58.6934; // Nickle
1044     zZ[9] = 29.0; aA[9] = 63.546; // Copper
1045     zZ[10] = 13.0; aA[10] = 26.981539; // Alulminum
1046     zZ[11] = 47.0; aA[11] = 107.8682; // Silver
1047     zZ[12] = 27.0; aA[12] = 58.9332; // Cobolt
1048     wW[0] = 0.019965;
1049     wW[1] = 0.340961;
1050     wW[2] = 0.041225;
1051     wW[3] = 0.200352;
1052     wW[4] = 0.000386;
1053     wW[5] = 0.001467;
1054     wW[6] = 0.000155;
1055     wW[7] = 0.005113;
1056     wW[8] = 0.000993;
1057     wW[9] = 0.381262;
1058     wW[10] = 0.008121;
1059     wW[11] = 0.000000;
1060     wW[12] = 0.000000;
1061     if(fByThick){// New values seeITS_MatBudget_4B.xls
1062         den = 1.5253276; // g/cm^3  Cell O370
1063     }else{
1064         den = 2.58423412; // g/cm^3 Cell L370
1065     } // end if fByThick
1066     //den = 6161.7/(3671.58978);//g/cm^3 Volume does not exclude holes
1067     AliMixture(86,"AIRFMDSDD$",aA,zZ,den,+11,wW);
1068     AliMedium(86,"AIRFMDSDD$",86,0,ifield,fieldm,tmaxfdAir,stemaxAir,
1069               deemaxAir,epsilAir,stminAir);
1070
1071     //AliMaterial(87,"AIRFMDSSD$",0.14610E+02,0.73000E+01,0.12050E-02,0.30423E+05,0.99900E+03);
1072     // From Pierluigi Barberis calculations of SSD October 2 2002.
1073     wW[0] = 0.019777;
1074     wW[1] = 0.325901;
1075     wW[2] = 0.031848;
1076     wW[3] = 0.147668;
1077     wW[4] = 0.030609;
1078     wW[5] = 0.013993;
1079     wW[6] = 0.001479;
1080     wW[7] = 0.048792;
1081     wW[8] = 0.009477;
1082     wW[9] = 0.350697;
1083     wW[10] = 0.014546;
1084     wW[11] = 0.005213;
1085     wW[12] = 0.000000;
1086     if(fByThick){// New values seeITS_MatBudget_4B.xls
1087         den = 1.2464275; // g/cm^3   Cell O403
1088     }else{
1089         den = 1.28134409; // g/cm^3  Cell L403
1090     } // end if fByThick
1091     //den = 7666.3/(9753.553259); // volume does not exclude holes
1092     AliMixture(87,"AIRFMDSSD$",aA,zZ,den,+12,wW); 
1093     AliMedium(87,"AIRFMDSSD$",87,0,ifield,fieldm,tmaxfdAir,stemaxAir,
1094               deemaxAir,epsilAir,stminAir);
1095
1096     //AliMaterial(88,"ITS SANDW CFMDSDD$",0.12011E+02,0.60000E+01,0.41000E+00,0.90868E+02,0.99900E+03);
1097     // From Pierluigi Barberis calculations of 1SDD+Carbon fiber October 2 2002
1098     wW[0] = 0.016302;
1099     wW[1] = 0.461870;
1100     wW[2] = 0.033662;
1101     wW[3] = 0.163595;
1102     wW[4] = 0.000315;
1103     wW[5] = 0.001197;
1104     wW[6] = 0.000127;
1105     wW[7] = 0.004175;
1106     wW[8] = 0.000811;
1107     wW[9] = 0.311315;
1108     wW[10] = 0.006631;
1109     wW[11] = 0.000000;
1110     wW[12] = 0.000000;
1111     if(fByThick){// New values seeITS_MatBudget_4B.xls
1112         den = 1.9353276; // g/cm^3  Cell N370
1113     }else{
1114         den = 3.2788626; // g/cm^3 Cell F370
1115     } // end if fByThick
1116     //den = 7667.1/(3671.58978); // Volume does not excludeholes
1117     AliMixture(88,"ITS SANDW CFMDSDD$",aA,zZ,den,+11,wW); 
1118     AliMedium(88,"ITS SANDW CFMDSDD$",88,0,ifield,fieldm,tmaxfd,stemax,
1119               deemax,epsil,stmin);
1120
1121     //AliMaterial(89,"ITS SANDW CFMDSSD$",0.12011E+02,0.60000E+01,0.41000E+00,0.90868E+02,0.99900E+03);
1122     // From Pierluigi Barberis calculations of SSD+Carbon fiber October 2 2002.
1123     wW[0] = 0.014065;
1124     wW[1] = 0.520598;
1125     wW[2] = 0.022650;
1126     wW[3] = 0.105018;
1127     wW[4] = 0.021768;
1128     wW[5] = 0.009952;
1129     wW[6] = 0.001051;
1130     wW[7] = 0.034700;
1131     wW[8] = 0.006740;
1132     wW[9] = 0.249406;
1133     wW[10] = 0.010345;
1134     wW[11] = 0.0003707;
1135     wW[12] = 0.000000;
1136     if(fByThick){// New values seeITS_MatBudget_4B.xls
1137         den = 1.6564275; // g/cm^3  Cell N304
1138     }else{
1139         den = 1.7028296; // g/cm^3  Cell F304
1140     } // end if fByThick
1141     //den = 1166.5/(3671.58978); // Volume does not exclude holes
1142     AliMixture(89,"ITS SANDW CFMDSSD$",aA,zZ,den,+12,wW); 
1143     AliMedium(89,"ITS SANDW CFMDSSD$",89,0,ifield,fieldm,tmaxfd,stemax,
1144               deemax,epsil,stmin);
1145
1146     //AliMaterial(97,"SPD SERVICES$",0.12011E+02,0.60000E+01,0.41000E+00,0.90868E+02,0.99900E+03);
1147     // From Pierluigi Barberis calculations of 1SPD October 2 2002.
1148     wW[0] = 0.005970;
1149     wW[1] = 0.304704;
1150     wW[2] = 0.042510;
1151     wW[3] = 0.121715;
1152     wW[4] = 0.001118;
1153     wW[5] = 0.030948;
1154     wW[6] = 0.003270;
1155     wW[7] = 0.107910;
1156     wW[8] = 0.020960;
1157     wW[9] = 0.360895;
1158     wW[10] = 0.000000;
1159     wW[11] = 0.000000;
1160     wW[12] = 0.000000;
1161     if(fByThick){// New values seeITS_MatBudget_4B.xls
1162         den = 80.31136576; // g/cm^3 Cell H329
1163     }else{
1164         den = 87.13062; // g/cm^3  Cell G329
1165     } // end if fByThick
1166     //den = 1251.3/(0.05*2.0*TMath::Pi()*(7.75*7.75 - 3.7*3.7)); // g/cm^3
1167     AliMixture(97,"SPD SERVICES$",aA,zZ,den,+10,wW); 
1168     AliMedium(97,"SPD SERVICES$",97,0,ifield,fieldm,tmaxfd,stemax,
1169               deemax,epsil,stmin);
1170
1171
1172     // Special media
1173
1174     AliMaterial(90,"SPD shield$", 12.011, 6., 1.93/10. , 22.1*10., 999);
1175     AliMedium(90,"SPD shield$",90,0,ifield,fieldm,tmaxfdServ,stemaxServ,deemaxServ,epsilServ,stminServ);
1176
1177     // SPD End Ladder (data from Petra Riedler)
1178     Float_t aSPDel[5] = {1.00794,12.0107,14.01,15.9994,63.54 };
1179     Float_t zSPDel[5] = {1.,6.,7.,8.,29.};
1180     Float_t wSPDel[5] = {0.004092,0.107274,0.011438,0.032476,0.844719};
1181     Float_t dSPDel    = 3.903403;
1182
1183     //   AliMaterial(91, "SPD End ladder$", 47.0447, 21.7963, 3.6374, 4.4711, 999); 
1184     AliMixture(91,"SPD End ladder$",aSPDel,zSPDel,dSPDel,5,wSPDel);
1185     AliMedium(91,"SPD End ladder$",91,0,ifield,fieldm,tmaxfdServ,stemaxServ,deemaxServ,epsilServ,stminServ);
1186
1187     AliMaterial(92, "SPD cone$",28.0855, 14., 2.33, 9.36, 999);    
1188     AliMedium(92,"SPD cone$",92,0,ifield,fieldm,tmaxfdServ,stemaxServ,deemaxServ,epsilServ,stminServ);
1189     /*  Material with fractional Z not actually used
1190     AliMaterial(93, "SDD End ladder$", 69.9298, 29.8246, 0.3824, 36.5103, 999);
1191     AliMedium(93,"SDD End ladder$",93,0,ifield,fieldm,tmaxfdServ,stemaxServ,deemaxServ,epsilServ,stminServ);
1192     */
1193     AliMaterial(94, "SDD cone$",63.546, 29., 1.15, 1.265, 999);
1194     AliMedium(94,"SDD cone$",94,0,ifield,fieldm,tmaxfdServ,stemaxServ,deemaxServ,epsilServ,stminServ);
1195     /* Material with fractional Z not actually used
1196     AliMaterial(95, "SSD End ladder$", 32.0988, 15.4021, 0.68, 35.3238, 999); 
1197     AliMedium(95,"SSD End ladder$",95,0,ifield,fieldm,tmaxfdServ,stemaxServ,deemaxServ,epsilServ,stminServ);
1198     */
1199     AliMaterial(96, "SSD cone$",63.546, 29., 1.15, 1.265, 999);
1200     AliMedium(96,"SSD cone$",96,0,ifield,fieldm,tmaxfdServ,stemaxServ,deemaxServ,epsilServ,stminServ);
1201 }
1202
1203 //______________________________________________________________________
1204 void AliITSv11::InitAliITSgeom(){
1205   //
1206   // Fill fITSgeom with the 3 sub-detector geometries
1207   //
1208
1209   if (gGeoManager) gGeoManager->Export("geometry.root");
1210
1211     const Int_t knlayers = 6;
1212     const Int_t kndeep = 3;
1213     const AliITSDetector kidet[knlayers]={kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
1214     const TString knames[knlayers] = {
1215       "AliITSv11:spd missing",  // lay=1
1216       "AliITSv11:spd missing",  // lay=2
1217       "/ALIC_1/ITSV_1/ITSsddLayer3_1/ITSsddLadd_%d/ITSsddSensor_%d/ITSsddWafer_%d", // lay=3
1218       "/ALIC_1/ITSV_1/ITSsddLayer4_1/ITSsddLadd_%d/ITSsddSensor_%d/ITSsddWafer_%d", // lay=4
1219       "AliITSv11:ssd missing",  // lay=5
1220       "AliITSv11:ssd missing"   // lay=6
1221     };
1222
1223     const Int_t kitsGeomTreeCopys[knlayers][kndeep]= {{10, 2, 4},// lay=1
1224                                                      {10, 4, 4}, // lay=2
1225                                                      {14, 6, 1}, // lay=3
1226                                                      {22, 8, 1}, // lay=4
1227                                                      {34,22, 1}, // lay=5
1228                                                      {38,25, 1}};// lay=6
1229     Int_t       nlad[knlayers],ndet[knlayers];
1230     Int_t       mod,lay,lad=0,det=0,i,j,k,cp0,cp1,cp2;
1231     TString path,shapeName;
1232     TGeoHMatrix materix;
1233     Double_t trans[3]={3*0.0},rot[10]={9*0.0,1.0};
1234     TArrayD shapePar;
1235     TArrayF shapeParF;
1236     Bool_t shapeDefined[3]={kFALSE,kFALSE,kFALSE};
1237
1238     AliDebug(1,"Reading Geometry transformation directly from Modler.");
1239     mod = 0;
1240     for(i=0;i<knlayers;i++){
1241         k = 1;
1242         for(j=0;j<kndeep;j++) if(kitsGeomTreeCopys[i][j]!=0)
1243             k *= TMath::Abs(kitsGeomTreeCopys[i][j]);
1244         mod += k;
1245     } // end for i
1246
1247     SetITSgeom(0);
1248     nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
1249     ndet[0]= 4;ndet[1]= 4;ndet[2]= 6;ndet[3]= 8;ndet[4]=22;ndet[5]=25;
1250     AliITSgeom* geom = new AliITSgeom(0,6,nlad,ndet,mod);
1251     SetITSgeom(geom);
1252     mod = 0;
1253     for(lay=1;lay<=knlayers;lay++){
1254
1255         for(cp0=0; cp0<kitsGeomTreeCopys[lay-1][0]; cp0++){
1256             for(cp1=0; cp1<kitsGeomTreeCopys[lay-1][1]; cp1++){
1257                 for(cp2=1; cp2<=kitsGeomTreeCopys[lay-1][2]; cp2++){
1258
1259                     path.Form(knames[lay-1].Data(),
1260                               cp0,cp1,cp2);
1261                     switch (lay){
1262                     case 1:{
1263                         det = cp2;
1264                         lad = cp1+2*(cp0-1);
1265                     }break;
1266                     case 2:{
1267                         det = cp2;
1268                         lad = cp1+4*(cp0-1);
1269                     } break;
1270                     case 3: case 4: case 5: case 6:{
1271                         det = cp1;
1272                         lad = cp0;
1273                     } break;
1274                     } // end switch
1275                          //AliInfo(Form("path=%s lay=%d lad=%d det=%d",
1276                          //             path.Data(),lay,lad,det));
1277                     gMC->GetTransformation(path.Data(),materix);
1278                     gMC->GetShape(path.Data(),shapeName,shapePar);
1279                     shapeParF.Set(shapePar.GetSize());
1280                     for(i=0;i<shapePar.GetSize();i++) shapeParF[i]=shapePar[i];
1281                     geom->CreateMatrix(mod,lay,lad,det,kidet[lay-1],trans,rot);
1282                     geom->SetTrans(mod,materix.GetTranslation());
1283                     geom->SetRotMatrix(mod,materix.GetRotationMatrix());
1284                     geom->GetGeomMatrix(mod)->SetPath(path.Data());
1285                     switch (lay){
1286                     case 1: case 2:
1287                         if(!shapeDefined[kSPD]){
1288                         geom->ReSetShape(kSPD,new AliITSgeomSPD425Short(
1289                                 shapeParF.GetSize(),shapeParF.GetArray()));
1290                         shapeDefined[kSPD] = kTRUE;
1291                     }break;
1292                     case 3: case 4:
1293                         if(!shapeDefined[kSDD]){
1294                         geom->ReSetShape(kSDD,new AliITSgeomSDD256(
1295                                 shapeParF.GetSize(),shapeParF.GetArray()));
1296                         shapeDefined[kSDD] = kTRUE;
1297                     }break;
1298                     case 5: case 6:
1299                         if(!shapeDefined[kSSD]){
1300                         geom->ReSetShape(kSSD,new AliITSgeomSSD75and275(
1301                                 shapeParF.GetSize(),shapeParF.GetArray()));
1302                         shapeDefined[kSSD] = kTRUE;
1303                     }break;
1304                     default:{
1305                     }break;
1306                     } // end switch
1307                     mod++;
1308                 } /// end for cp2
1309             } // end for cp1
1310         } // end for cp0
1311     } // end for lay
1312
1313 //   fSDDgeom->ExportSensorGeometry(GetITSgeom(), +3, 0);  //SDD
1314 }
1315
1316 //______________________________________________________________________
1317 void AliITSv11::Init(){
1318   //
1319   //     Initialise the ITS after it has been created.
1320   //
1321
1322   //AliInfo(Form("Minor version %d",fMinorVersion));
1323     //
1324     if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
1325     if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
1326     if(GetITSgeom()!=0) SetITSgeom(0x0);
1327     AliITSgeom* geom = new AliITSgeom();
1328     SetITSgeom(geom);
1329     if(fGeomDetIn) GetITSgeom()->ReadNewFile(fRead);
1330     else this->InitAliITSgeom();
1331     if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
1332     AliITS::Init();
1333     //
1334 }
1335
1336 // //______________________________________________________________________
1337 // void AliITSv11::SetDefaults(){
1338 //   //
1339 //   // Set response ans segmentation models for SPD, SDD and SSD
1340 //   //
1341 //      const Float_t kconv = 1.0e+04; // convert cm to microns
1342 //     AliInfo("Called");    
1343
1344 //     if(!fDetTypeSim) fDetTypeSim = new AliITSDetTypeSim();
1345 //     fDetTypeSim->SetITSgeom(GetITSgeom());
1346   
1347 //     AliITSgeomSPD  *s0;
1348 //     AliITSgeomSDD  *s1;
1349 //     AliITSgeomSSD  *s2;
1350 //     Int_t i;
1351 //     Float_t bx[256],bz[280];
1352    
1353 //     fDetTypeSim->ResetCalibrationArray();
1354 //     fDetTypeSim->ResetSegmentation();
1355 //     fDetTypeSim->SetDefaults();
1356     
1357 //     //SPD
1358 //     s0 = (AliITSgeomSPD*) GetITSgeom()->GetShape(kSPD);// Get shape info. Do it this way for now.
1359 //     AliITSsegmentationSPD* seg0 = (AliITSsegmentationSPD*)fDetTypeSim->GetSegmentationModel(0);
1360 //     seg0->SetDetSize(s0->GetDx()*2.*kconv, // base this on AliITSgeomSPD
1361 //                   s0->GetDz()*2.*kconv, // for now.
1362 //                   s0->GetDy()*2.*kconv); // x,z,y full width in microns.
1363 //     seg0->SetNPads(256,160);// Number of Bins in x and z
1364 //     for(i=000;i<256;i++) bx[i] =  50.0; // in x all are 50 microns.
1365 //     for(i=000;i<160;i++) bz[i] = 425.0; // most are 425 microns except below
1366 //     for(i=160;i<280;i++) bz[i] =   0.0; // Outside of detector.
1367 //     bz[ 31] = bz[ 32] = 625.0; // first chip boundry
1368 //     bz[ 63] = bz[ 64] = 625.0; // first chip boundry
1369 //     bz[ 95] = bz[ 96] = 625.0; // first chip boundry
1370 //     bz[127] = bz[128] = 625.0; // first chip boundry
1371 //     bz[160] = 425.0; // Set so that there is no zero pixel size for fNz.
1372 //     seg0->SetBinSize(bx,bz); // Based on AliITSgeomSPD for now.
1373 //     SetSegmentationModel(kSPD,seg0);
1374 //     // set digit and raw cluster classes to be used
1375 //     const char *kData0=(fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSPD()))->DataType();
1376 //     if (strstr(kData0,"real")) fDetTypeSim->SetDigitClassName(kSPD,"AliITSdigit");
1377 //     else fDetTypeSim->SetDigitClassName(kSPD,"AliITSdigitSPD");
1378
1379
1380
1381 //     // SDD
1382 //     s1 = (AliITSgeomSDD*) GetITSgeom()->GetShape(kSDD);// Get shape info. Do it this way for now.
1383 //     AliITSsegmentationSDD* seg1 = (AliITSsegmentationSDD*)fDetTypeSim->GetSegmentationModel(1);
1384 //     seg1->SetDetSize(s1->GetDx()*kconv, // base this on AliITSgeomSDD
1385 //                   s1->GetDz()*2.*kconv, // for now.
1386 //                   s1->GetDy()*2.*kconv); // x,z,y full width in microns.
1387 //     seg1->SetNPads(256,256);// Use AliITSgeomSDD for now
1388 //     SetSegmentationModel(kSDD,seg1);
1389 //     const char *kData1=(fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSDD()))->DataType();
1390 //     AliITSCalibrationSDD* rsp = (AliITSCalibrationSDD*)fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSDD());
1391 //     const char *kopt=rsp->GetZeroSuppOption();
1392 //     if((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ){
1393 //      fDetTypeSim->SetDigitClassName(kSDD,"AliITSdigit");
1394 //     } else fDetTypeSim->SetDigitClassName(kSDD,"AliITSdigitSDD");
1395
1396
1397 //     // SSD
1398 //     s2 = (AliITSgeomSSD*) GetITSgeom()->GetShape(kSSD);// Get shape info. Do it this way for now.
1399 //     AliITSsegmentationSSD* seg2 = (AliITSsegmentationSSD*)fDetTypeSim->GetSegmentationModel(2);
1400 //     seg2->SetDetSize(s2->GetDx()*2.*kconv, // base this on AliITSgeomSSD
1401 //                   s2->GetDz()*2.*kconv, // for now.
1402 //                   s2->GetDy()*2.*kconv); // x,z,y full width in microns.
1403 //     seg2->SetPadSize(95.,0.); // strip x pitch in microns
1404 //     seg2->SetNPads(768,0); // number of strips on each side.
1405 //     seg2->SetAngles(0.0075,0.0275); // strip angels rad P and N side.
1406 //     seg2->SetAnglesLay5(0.0075,0.0275); // strip angels rad P and N side.
1407 //     seg2->SetAnglesLay6(0.0275,0.0075); // strip angels rad P and N side.
1408 //     SetSegmentationModel(kSSD,seg2); 
1409 //         const char *kData2=(fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSSD()))->DataType();
1410 //     if(strstr(kData2,"real") ) fDetTypeSim->SetDigitClassName(kSSD,"AliITSdigit");
1411 //     else fDetTypeSim->SetDigitClassName(kSSD,"AliITSdigitSSD");
1412 //     if(fgkNTYPES>3){
1413 //      Warning("SetDefaults",
1414 //              "Only the four basic detector types are initialised!");
1415 //     }// end if
1416
1417     
1418 //     return;
1419 // }
1420
1421
1422 //______________________________________________________________________
1423 void AliITSv11::SetDefaults(){
1424   //
1425   // Set response and segmentation models for SPD, SDD and SSD
1426   //
1427      const Float_t kconv = 1.0e+04; // convert cm to microns
1428     AliInfo("Called");    
1429
1430 //     if(!fDetTypeSim) fDetTypeSim = new AliITSDetTypeSim();
1431 //     fDetTypeSim->SetITSgeom(GetITSgeom());
1432     if(!fDetTypeSim) {
1433       Warning("SetDefaults","Error fDetTypeSim not defined");
1434       return;
1435     }
1436   
1437     AliITSgeomSPD  *s0;
1438     AliITSgeomSDD  *s1;
1439     AliITSgeomSSD  *s2;
1440     Int_t i;
1441     Float_t bx[256],bz[280];
1442    
1443     fDetTypeSim->ResetCalibrationArray();
1444     fDetTypeSim->ResetSegmentation();
1445     fDetTypeSim->SetDefaults();
1446     
1447     //SPD
1448     s0 = (AliITSgeomSPD*) GetITSgeom()->GetShape(kSPD);// Get shape info. Do it this way for now.
1449     AliITSsegmentationSPD* seg0 = (AliITSsegmentationSPD*)fDetTypeSim->GetSegmentationModel(0);
1450     seg0->SetDetSize(s0->GetDx()*2.*kconv, // base this on AliITSgeomSPD
1451                      s0->GetDz()*2.*kconv, // for now.
1452                      s0->GetDy()*2.*kconv); // x,z,y full width in microns.
1453     seg0->SetNPads(256,160);// Number of Bins in x and z
1454     for(i=000;i<256;i++) bx[i] =  50.0; // in x all are 50 microns.
1455     for(i=000;i<160;i++) bz[i] = 425.0; // most are 425 microns except below
1456     for(i=160;i<280;i++) bz[i] =   0.0; // Outside of detector.
1457     bz[ 31] = bz[ 32] = 625.0; // first chip boundry
1458     bz[ 63] = bz[ 64] = 625.0; // first chip boundry
1459     bz[ 95] = bz[ 96] = 625.0; // first chip boundry
1460     bz[127] = bz[128] = 625.0; // first chip boundry
1461     bz[160] = 425.0; // Set so that there is no zero pixel size for fNz.
1462     seg0->SetBinSize(bx,bz); // Based on AliITSgeomSPD for now.
1463     SetSegmentationModel(kSPD,seg0);
1464     // set digit and raw cluster classes to be used
1465     const char *kData0=(fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSPD()))->DataType();
1466     if (strstr(kData0,"real")) fDetTypeSim->SetDigitClassName(kSPD,"AliITSdigit");
1467     else fDetTypeSim->SetDigitClassName(kSPD,"AliITSdigitSPD");
1468
1469
1470
1471     // SDD
1472     s1 = (AliITSgeomSDD*) GetITSgeom()->GetShape(kSDD);// Get shape info. Do it this way for now.
1473     AliITSsegmentationSDD* seg1 = (AliITSsegmentationSDD*)fDetTypeSim->GetSegmentationModel(1);
1474     seg1->SetDetSize(s1->GetDx()*kconv, // base this on AliITSgeomSDD
1475                      s1->GetDz()*2.*kconv, // for now.
1476                      s1->GetDy()*2.*kconv); // x,z,y full width in microns.
1477     seg1->SetNPads(256,256);// Use AliITSgeomSDD for now
1478     SetSegmentationModel(kSDD,seg1);
1479     const char *kData1=(fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSDD()))->DataType();
1480     AliITSCalibrationSDD* rsp = (AliITSCalibrationSDD*)fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSDD());
1481     const char *kopt=rsp->GetZeroSuppOption();
1482     if((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ){
1483         fDetTypeSim->SetDigitClassName(kSDD,"AliITSdigit");
1484     } else fDetTypeSim->SetDigitClassName(kSDD,"AliITSdigitSDD");
1485
1486
1487     // SSD
1488     s2 = (AliITSgeomSSD*) GetITSgeom()->GetShape(kSSD);// Get shape info. Do it this way for now.
1489     AliITSsegmentationSSD* seg2 = (AliITSsegmentationSSD*)fDetTypeSim->GetSegmentationModel(2);
1490     seg2->SetDetSize(s2->GetDx()*2.*kconv, // base this on AliITSgeomSSD
1491                      s2->GetDz()*2.*kconv, // for now.
1492                      s2->GetDy()*2.*kconv); // x,z,y full width in microns.
1493     seg2->SetPadSize(95.,0.); // strip x pitch in microns
1494     seg2->SetNPads(768,0); // number of strips on each side.
1495     seg2->SetAngles(0.0075,0.0275); // strip angels rad P and N side.
1496     seg2->SetAnglesLay5(0.0075,0.0275); // strip angels rad P and N side.
1497     seg2->SetAnglesLay6(0.0275,0.0075); // strip angels rad P and N side.
1498     SetSegmentationModel(kSSD,seg2); 
1499         const char *kData2=(fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSSD()))->DataType();
1500     if(strstr(kData2,"real") ) fDetTypeSim->SetDigitClassName(kSSD,"AliITSdigit");
1501     else fDetTypeSim->SetDigitClassName(kSSD,"AliITSdigitSSD");
1502     if(fgkNTYPES>3){
1503         Warning("SetDefaults",
1504                 "Only the four basic detector types are initialised!");
1505     }// end if
1506
1507     
1508     return;
1509 }
1510
1511
1512
1513
1514
1515 //______________________________________________________________________
1516 void AliITSv11::DrawModule() const{
1517
1518 }
1519
1520 // //______________________________________________________________________
1521 // void AliITSv11::StepManager(){
1522 //   //
1523 //   //    Called for every step in the ITS, then calles the AliITShit class
1524 //   // creator with the information to be recoreded about that hit.
1525 //   //
1526 //     Int_t         copy, id;
1527 //     TLorentzVector position, momentum;
1528 //     static TLorentzVector position0;
1529 //     static Int_t stat0=0;
1530
1531 //     if(!(this->IsActive())){
1532 //      return;
1533 //     } // end if !Active volume.
1534
1535 //     if(!(gMC->TrackCharge())) return;
1536
1537 //     id=gMC->CurrentVolID(copy);
1538
1539 //     Bool_t sensvol = kFALSE;
1540 //     for(Int_t kk=0;kk<6;kk++)if(id == fIdSens[kk])sensvol=kTRUE;
1541 //     if(sensvol && (gMC->IsTrackExiting())){
1542 //      copy = fTrackReferences->GetEntriesFast();
1543 //      TClonesArray &lTR = *fTrackReferences;
1544 //      // Fill TrackReference structure with this new TrackReference.
1545 //      new(lTR[copy]) AliTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
1546 //     } // if Outer ITS mother Volume
1547
1548
1549 //     Int_t   copy1,copy2;  
1550 //     Int_t   vol[5];
1551 //     TClonesArray &lhits = *fHits;
1552 //     //
1553 //     // Track status
1554 //     vol[3] = 0;
1555 //     vol[4] = 0;
1556 //     if(gMC->IsTrackInside())      vol[3] +=  1;
1557 //     if(gMC->IsTrackEntering())    vol[3] +=  2;
1558 //     if(gMC->IsTrackExiting())     vol[3] +=  4;
1559 //     if(gMC->IsTrackOut())         vol[3] +=  8;
1560 //     if(gMC->IsTrackDisappeared()) vol[3] += 16;
1561 //     if(gMC->IsTrackStop())        vol[3] += 32;
1562 //     if(gMC->IsTrackAlive())       vol[3] += 64;
1563 //     //
1564 //     // Fill hit structure.
1565 //     if(!(gMC->TrackCharge())) return;
1566 //     //
1567 //     // Only entering charged tracks
1568 //     if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
1569 //      vol[0] = 1;
1570 //      id = gMC->CurrentVolOffID(2,copy);
1571 //      //detector copy in the ladder = 1<->4  (ITS1 < I101 < I103 < I10A)
1572 //      vol[1] = copy;
1573 //      gMC->CurrentVolOffID(3,copy1);
1574 //      //ladder copy in the module   = 1<->2  (I10A < I12A)
1575 //      gMC->CurrentVolOffID(4,copy2);
1576 //      //module copy in the layer    = 1<->10 (I12A < IT12)
1577 //      vol[2] = copy1+(copy2-1)*2;//# of ladders in one module  = 2
1578 //     } else if(id == fIdSens[1]){
1579 //      vol[0] = 2;
1580 //      id = gMC->CurrentVolOffID(2,copy);
1581 //      //detector copy in the ladder = 1<->4  (ITS2 < I1D1 < I1D3 < I20A)
1582 //      vol[1] = copy;
1583 //      gMC->CurrentVolOffID(3,copy1);
1584 //      //ladder copy in the module   = 1<->4  (I20A < I12A)
1585 //      gMC->CurrentVolOffID(4,copy2);
1586 //      //module copy in the layer    = 1<->10 (I12A < IT12)
1587 //      vol[2] = copy1+(copy2-1)*4;//# of ladders in one module  = 4
1588 //     } else if(id == fIdSens[2]){
1589 //      vol[0] = 3;
1590 //      id = gMC->CurrentVolOffID(1,copy);
1591 //      //detector copy in the ladder = 1<->6  (ITS3 < I302 < I004)
1592 //      vol[1] = copy;
1593 //      id = gMC->CurrentVolOffID(2,copy);
1594 //      //ladder copy in the layer    = 1<->14 (I004 < IT34)
1595 //      vol[2] = copy;
1596 //     } else if(id == fIdSens[3]){
1597 //      vol[0] = 4;
1598 //      id = gMC->CurrentVolOffID(1,copy);
1599 //      //detector copy in the ladder = 1<->8  (ITS4 < I402 < I005)
1600 //      vol[1] = copy;
1601 //      id = gMC->CurrentVolOffID(2,copy);
1602 //      //ladder copy in the layer    = 1<->22 (I005 < IT34))
1603 //      vol[2] = copy;
1604 //     }else if(id == fIdSens[4]){
1605 //      vol[0] = 5;
1606 //      id = gMC->CurrentVolOffID(1,copy);
1607 //      //detector copy in the ladder = 1<->22  (ITS5 < I562 < I565)
1608 //      vol[1] = copy;
1609 //      id = gMC->CurrentVolOffID(2,copy);
1610 //      //ladder copy in the layer    = 1<->34 (I565 < IT56)
1611 //      vol[2] = copy;
1612 //     }else if(id == fIdSens[5]){
1613 //      vol[0] = 6;
1614 //      id = gMC->CurrentVolOffID(1,copy);
1615 //      //detector copy in the ladder = 1<->25  (ITS6 < I566 < I569)
1616 //      vol[1] = copy;
1617 //      id = gMC->CurrentVolOffID(2,copy);
1618 //      //ladder copy in the layer = 1<->38 (I569 < IT56)
1619 //      vol[2] = copy;
1620 //     } else {
1621 //      return; // not an ITS volume?
1622 //     } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
1623 //     //
1624 //     gMC->TrackPosition(position);
1625 //     gMC->TrackMomentum(momentum);
1626 //     vol[4] = stat0;
1627 //     if(gMC->IsTrackEntering()){
1628 //      position0 = position;
1629 //      stat0 = vol[3];
1630 //      return;
1631 //     } // end if IsEntering
1632 //     // Fill hit structure with this new hit.
1633     
1634 //     new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
1635 //                                 gMC->Edep(),gMC->TrackTime(),position,
1636 //                                 position0,momentum);
1637
1638 //     position0 = position;
1639 //     stat0 = vol[3];
1640
1641 //     return;
1642 // }
1643
1644
1645 //______________________________________________________________________
1646 void AliITSv11::StepManager(){
1647   //
1648   //    Called for every step in the ITS, then calles the AliITShit class
1649   // creator with the information to be recoreded about that hit.
1650   //
1651     Int_t         copy, id;
1652     TLorentzVector position, momentum;
1653     static TLorentzVector position0;
1654     static Int_t stat0=0;
1655
1656     if(!(this->IsActive())){
1657         return;
1658     } // end if !Active volume.
1659
1660     if(!(gMC->TrackCharge())) return;
1661
1662     id=gMC->CurrentVolID(copy);
1663
1664     Bool_t sensvol = kFALSE;
1665     for(Int_t kk=0;kk<6;kk++)if(id == fIdSens[kk])sensvol=kTRUE;
1666     if(sensvol && (gMC->IsTrackExiting())){
1667         copy = fTrackReferences->GetEntriesFast();
1668         TClonesArray &lTR = *fTrackReferences;
1669         // Fill TrackReference structure with this new TrackReference.
1670         new(lTR[copy]) AliTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
1671     } // if Outer ITS mother Volume
1672
1673
1674     Int_t   copy1,copy2;  
1675     Int_t   vol[5];
1676     TClonesArray &lhits = *fHits;
1677     //
1678     // Track status
1679     vol[3] = 0;
1680     vol[4] = 0;
1681     if(gMC->IsTrackInside())      vol[3] +=  1;
1682     if(gMC->IsTrackEntering())    vol[3] +=  2;
1683     if(gMC->IsTrackExiting())     vol[3] +=  4;
1684     if(gMC->IsTrackOut())         vol[3] +=  8;
1685     if(gMC->IsTrackDisappeared()) vol[3] += 16;
1686     if(gMC->IsTrackStop())        vol[3] += 32;
1687     if(gMC->IsTrackAlive())       vol[3] += 64;
1688     //
1689     // Fill hit structure.
1690     if(!(gMC->TrackCharge())) return;
1691
1692     // Only entering charged tracks
1693     if((id = gMC->CurrentVolID(copy)) == fIdSens[0]) {
1694         vol[0] = 1;
1695         id = gMC->CurrentVolOffID(2,copy);
1696         //detector copy in the ladder = 1<->4  (ITS1 < I101 < I103 < I10A)
1697         vol[1] = copy;
1698         gMC->CurrentVolOffID(3,copy1);
1699         //ladder copy in the module   = 1<->2  (I10A < I12A)
1700         gMC->CurrentVolOffID(4,copy2);
1701         //module copy in the layer    = 1<->10 (I12A < IT12)
1702         vol[2] = copy1+(copy2-1)*2;//# of ladders in one module  = 2
1703
1704     } else if(id == fIdSens[1]){
1705         vol[0] = 2;
1706         id = gMC->CurrentVolOffID(2,copy);
1707         //detector copy in the ladder = 1<->4  (ITS2 < I1D1 < I1D3 < I20A)
1708         vol[1] = copy;
1709         gMC->CurrentVolOffID(3,copy1);
1710         //ladder copy in the module   = 1<->4  (I20A < I12A)
1711         gMC->CurrentVolOffID(4,copy2);
1712         //module copy in the layer    = 1<->10 (I12A < IT12)
1713         vol[2] = copy1+(copy2-1)*4;//# of ladders in one module  = 4
1714
1715     } else if(id == fIdSens[2]){
1716         vol[0] = 3;
1717         id = gMC->CurrentVolOffID(1,copy);
1718         //detector copy in the ladder = 1<->6  (ITS3 < I302 < I004)
1719         vol[1] = copy;
1720         id = gMC->CurrentVolOffID(2,copy);
1721         //ladder copy in the layer    = 1<->14 (I004 < IT34)
1722         vol[2] = copy;
1723
1724     } else if(id == fIdSens[3]){
1725         vol[0] = 4;
1726         id = gMC->CurrentVolOffID(1,copy);
1727         //detector copy in the ladder = 1<->8  (ITS4 < I402 < I005)
1728         vol[1] = copy;
1729         id = gMC->CurrentVolOffID(2,copy);
1730         //ladder copy in the layer    = 1<->22 (I005 < IT34))
1731         vol[2] = copy;
1732
1733     }else if(id == fIdSens[4]){
1734         vol[0] = 5;
1735         id = gMC->CurrentVolOffID(1,copy);
1736         //detector copy in the ladder = 1<->22  (ITS5 < I562 < I565)
1737         vol[1] = copy;
1738         id = gMC->CurrentVolOffID(2,copy);
1739         //ladder copy in the layer    = 1<->34 (I565 < IT56)
1740         vol[2] = copy;
1741
1742     }else if(id == fIdSens[5]){
1743         vol[0] = 6;
1744         id = gMC->CurrentVolOffID(1,copy);
1745         //detector copy in the ladder = 1<->25  (ITS6 < I566 < I569)
1746         vol[1] = copy;
1747         id = gMC->CurrentVolOffID(2,copy);
1748         //ladder copy in the layer = 1<->38 (I569 < IT56)
1749         vol[2] = copy;
1750     } else {
1751         return; // not an ITS volume?
1752     } // end if/else if (gMC->CurentVolID(copy) == fIdSens[i])
1753     //
1754     gMC->TrackPosition(position);
1755     gMC->TrackMomentum(momentum);
1756     vol[4] = stat0;
1757     if(gMC->IsTrackEntering()){
1758         position0 = position;
1759         stat0 = vol[3];
1760         return;
1761     } // end if IsEntering
1762     // Fill hit structure with this new hit.
1763     
1764     new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->GetMCApp()->GetCurrentTrackNumber(),vol,
1765                                    gMC->Edep(),gMC->TrackTime(),position,
1766                                    position0,momentum);
1767
1768     position0 = position;
1769     stat0 = vol[3];
1770
1771     return;
1772 }
1773