]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSvSDD03.cxx
New classes for finding multiple vertices (in case of pile-up). They will be used...
[u/mrichter/AliRoot.git] / ITS / AliITSvSDD03.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  $Id$ 
18 */
19 /////////////////////////////////////////////////////////////////
20 //  Class for the SDD beam test August2004                     //
21 //                                                             //
22 //                                                             //
23 /////////////////////////////////////////////////////////////////
24
25 #include <TGeoManager.h>
26 #include <TLorentzVector.h>
27 #include <TVirtualMC.h>
28 #include <TGeoMatrix.h>
29
30 #include "AliMC.h"
31 #include "AliRun.h"
32 #include "AliMagF.h"
33 #include "AliTrackReference.h"
34 #include "AliITShit.h"
35 #include "AliITSgeom.h"
36 #include "AliITSgeomSDD.h"
37 #include "AliITSgeomSSD.h"
38 #include "AliITSDetTypeSim.h"
39 #include "AliITSCalibrationSPD.h"
40 #include "AliITSCalibrationSDD.h"
41 #include "AliITSCalibrationSSD.h"
42 #include "AliITSsegmentationSPD.h"
43 #include "AliITSsegmentationSDD.h"
44 #include "AliITSsegmentationSSD.h"
45 #include "AliITSsimulationSPD.h"
46 #include "AliITSsimulationSDD.h"
47 #include "AliITSsimulationSSD.h"
48
49 #include "AliITSvSDD03.h"
50
51 ClassImp(AliITSvSDD03)
52
53 //______________________________________________________________________
54 AliITSvSDD03::AliITSvSDD03() :
55 AliITS(),
56 fMajorVersion(IsVersion()),
57 fMinorVersion(2),
58 fIDMother(0),
59 fYear(2003),
60 fTarg(kNoTarg),
61 fTargThick(0.0),
62 fIgm(kvSDD03){
63     ////////////////////////////////////////////////////////////////////////
64     // Standard default constructor for the ITS SDD test beam 2002 version 1.
65     // Inputs:
66     //    none.
67     // Outputs:
68     //    none.
69     // Return:
70     //    A default created class.
71     ////////////////////////////////////////////////////////////////////////
72
73     fIdN          = 0;
74     fIdName       = 0;
75     fIdSens       = 0;
76 }
77 //______________________________________________________________________
78 AliITSvSDD03::AliITSvSDD03(const char *title,Int_t year):
79 AliITS("ITS", title),
80 fMajorVersion(IsVersion()),
81 fMinorVersion(2),
82 fIDMother(0),
83 fYear(year),
84 fTarg(kNoTarg),
85 fTargThick(0.0),
86 fIgm(kvSDD03){
87     ////////////////////////////////////////////////////////////////////////
88     //    Standard constructor for the ITS SDD testbeam 2002 version 1.
89     // Inputs:
90     //    const char *title    title for this ITS geometry.
91     // Outputs:
92     //    none.
93     // Return:
94     //    A standard created class.
95     ////////////////////////////////////////////////////////////////////////
96     Int_t i;
97
98     fIdN = 3;
99     fIdName = new TString[fIdN];
100     fIdName[0] = "IMBS";
101     fIdName[1] = "ITST";
102     fIdName[2] = "ISNT";
103     fIdSens    = new Int_t[fIdN];
104     for(i=0;i<fIdN;i++) fIdSens[i] = 0;
105
106 }
107 //______________________________________________________________________
108 AliITSvSDD03::~AliITSvSDD03() {
109     ////////////////////////////////////////////////////////////////////////
110     //    Standard destructor for the ITS SDD test beam 2002 version 1.
111     // Inputs:
112     //    none.
113     // Outputs:
114     //    none.
115     // Return:
116     //    none.
117     ////////////////////////////////////////////////////////////////////////
118 }
119 /*
120 //______________________________________________________________________
121 Int_t AliITSvSDD03::DecodeDetector(Int_t id,Int_t cpy,Int_t &lay,
122                                    Int_t &det,Int_t &lad) const{
123     // Given the Geant id and copy volume number, returns the layer, ladder,
124     // and detector number, allong with the module number of the detector
125     // involved. Returns -1 and lay=0, lad=0, and det=0 if not a sensitive 
126     // volume.
127     // Inputs:
128     //    Int_t id    Geometry volume id number
129     //    Int_t cpy   Geometry copy number
130     // Outputs:
131     //    Int_t lay   ITS layer number
132     //    Int_t lad   ITS ladder number
133     //    Int_t det   ITS detector number
134     // Return:
135     //    Int_t module number.
136     Int_t mod;
137
138     lay = 0; lad = 0; det = 0; mod = -1;
139     if(id==fIdSens[0]){ // Volume name is IMBS (ITEL)
140         lad = 1; det = 1;
141         lay = cpy;
142         if(cpy>4) lay+=2;
143         mod = lay-1;
144         return mod;
145     }// end if
146     if(id==fIdSens[1]){ // Volume name is ITST (IDet)
147         lad = 1; det = 1;lay = cpy+4; 
148         mod = lay-1;
149         return mod;
150     }// end if
151     return mod;
152 }
153 */
154 //______________________________________________________________________
155 void AliITSvSDD03::CreateGeometry(){
156     ////////////////////////////////////////////////////////////////////////
157     //  This routine defines and Creates the geometry for version 1 of the ITS.
158     //    ALIC    ALICE Mother Volume
159     //     |- ITSV     ITS Mother Volume
160     //         |- IDET *2    Detector under Test (boxcontaining SDD)
161     //         |   |-IDAI        Air inside box
162     //         |       |- ITS0       SDD Si Chip
163     //         |          |- ITST      SDD Sensitivve Volume
164     //         |- ITEL *10   SSD Telescope (plastic box containting SSD's)
165     //         |   |- ITAI       Air inside box
166     //         |       |- IMB0       SDD Si Chip
167     //         |           |- IMBS     SDD Sensitive volume
168     //         |-ISNT*4    Sintilator triggers
169     //
170     //      ITEL ITEL ITEL ITEL IDET IDET ITEL ITEL ITEL ITEL ITEL ITEL
171     // Z->  -584 -574 -504 -494  000 +052 +601 +610 +684 +694 +877 +887
172     //        |    |    |    |    |    |    |    |    |    |    |    |
173     // cpn1   1    2    3    4    1    2    5    6    7    8    9   10
174     //
175     // Inputs:
176     //    none.
177     // Outputs:
178     //    none.
179     // Return:
180     //    none.
181     ////////////////////////////////////////////////////////////////////////
182     Float_t data[49];
183     // Define media off-set
184     Int_t *idtmed = fIdtmed->GetArray()+1; // array of media indexes
185     Int_t idrotm[4]; // Array of rotation matrix indexes
186     //Float_t ddettest=200.0E-4,ddettelescope=300.0E-4;
187     //Float_t dchipMiniBus=750.0E-4,dchiptest=300.0E-4;
188     //Float_t yposition= 0.0;
189     const Float_t kmm=0.1,kcm=1.0,kmicm=kmm/1000.;
190     // These constant character strings are set by cvs during commit
191     // do not change them unless you know what you are doing!
192     const Char_t *cvsDate="$Date$";
193     const Char_t *cvsRevision="$Revision$";
194     // Define Rotation-reflextion Matrixes needed
195     // 0 is the unit matrix
196     AliMatrix(idrotm[0], 90.0,0.0, 0.0,0.0, 90.0,270.0); // SDD and SSD X
197     AliMatrix(idrotm[1], 90.0,90.0, 0.0,180.0, 90.0,270.0); // SSD Y
198     AliMatrix(idrotm[2],90.0,90.0,90.0,180.0,0.0,0.0);  //Rotate about Z 90 degree
199     /*
200     data[0] = 150.0*kmm;
201     data[1] = 150.0*kmm;
202     data[2] = 1100.0*kmm;
203     gMC->Gsvolu("ITSV","BOX ",idtmed[0],data,3);
204     gMC->Gspos("ITSV",1,"ALIC",0.0,0.0,0.0,0,"ONLY");
205     */
206     TGeoVolumeAssembly *itsV = gGeoManager->MakeVolumeAssembly("ITSV");
207     const Int_t kLength=100;
208     Char_t vstrng[kLength];
209     if(fIgm.WriteVersionString(vstrng,kLength,(AliITSVersion_t)IsVersion(),
210                                fMinorVersion,cvsDate,cvsRevision))
211         itsV->SetTitle(vstrng);
212     else Error("CreateGeometry","Error writing/setting version string");
213     //printf("Title set to %s\n",vstrng);
214     TGeoVolume *alic = gGeoManager->GetVolume("ALIC");
215     if(alic==0) {
216         Error("CreateGeometry","alic=0");
217         return;
218     } // end if
219     alic->AddNode(itsV,1,0);
220
221     // Crossed sintilator triggers (2 in front 2 in back)
222     data[0] = 10.0*kcm;
223     data[1] = 2.0*kcm;
224     data[2] = 2.0*kmm;
225     gMC->Gsvolu("ISNT","BOX ",idtmed[2],data,3);
226     gMC->Gspos("ISNT",1,"ITSV",0.0,0.0,-950.0*kmm,0,"ONLY");
227     gMC->Gspos("ISNT",2,"ITSV",0.0,0.0,-950.0*kmm-data[2],idrotm[2],"ONLY");
228     gMC->Gspos("ISNT",3,"ITSV",0.0,0.0,950.0*kmm+data[2],0,"ONLY");
229     gMC->Gspos("ISNT",4,"ITSV",0.0,0.0,950.0*kmm,idrotm[2],"ONLY");
230
231
232 ////Create Volumes
233
234     // SSD part of telescope (MiniBuS)
235     Float_t detMiniBusX,detMiniBusY,detMiniBusZ;
236     data[0] = detMiniBusX = 10600.0*kmicm;
237     data[1] = detMiniBusY = 0.150*kmm;
238     data[2] = detMiniBusZ = 1.1*kcm;
239     gMC->Gsvolu("IMB0", "BOX ", idtmed[1], data, 3);   // contains detector
240     data[0] = 0.5*384*50*kmicm;
241     data[1] = 0.1499*kmm;
242     data[2] = 1.0*kcm;
243     gMC->Gsvolu("IMBS","BOX ",idtmed[1],data,3); // sensitive detector volume
244     gMC->Gspos("IMBS",1,"IMB0",0.0,0.0,0.0,0,"ONLY"); // place IMBS inside
245     // Box containing SSD's
246     data[0] = 11600.0*kmicm;
247     data[1] = 0.450*kcm;
248     data[2] = 1.16*kcm;
249     gMC->Gsvolu("ITAI","BOX ",idtmed[0],data,3);
250     // Plastic box size = insize + thickness.
251     data[0] = data[0] + 2.0*kmm;
252     data[1] = data[1] + 200.0*kmicm;
253     data[2] = data[2] + 2.0*kmm;
254     gMC->Gsvolu("ITEL","BOX ",idtmed[3],data,3);
255     gMC->Gspos("ITAI",1,"ITEL",0.0,0.0,0.0,0,"ONLY");
256     gMC->Gspos("IMB0",1,"ITAI",0.0,0.0,0.0,0,"ONLY");
257
258     // SDD under test
259     Float_t sddX,sddY,sddZ;
260     data[0] = sddX = 3.62500*kcm;
261     data[1] = sddY = 0.1500*kmm;
262     data[2] = sddZ = 4.37940*kcm;
263     gMC->Gsvolu("ITS0", "BOX ", idtmed[1], data, 3);   // contains detector
264     data[0] = 3.50860*kcm;
265     data[1] = 0.1499*kmm;
266     data[2] = 3.76320*kcm;
267     gMC->Gsvolu("ITST","BOX ",idtmed[1],data,3);// sensitive detecor volume
268     gMC->Gspos("ITST",1,"ITS0",0.0,0.0,0.0,0,"ONLY"); // place ITST inside
269     // Box containing SDD under test
270     data[0] = 4.0*kcm;
271     data[1] = 0.5*kcm;
272     data[2] = 5.0*kcm;
273     gMC->Gsvolu("IDAI","BOX ",idtmed[0],data,3);
274     data[0] = data[0] + 2.0*kmm;
275     data[1] = data[1] + 200.0*kmicm;
276     data[2] = data[2] + 2.0*kmm;
277     gMC->Gsvolu("IDET","BOX ",idtmed[3],data,3);
278     gMC->Gspos("IDAI",1,"IDET",0.0,0.0,0.0,0,"ONLY");
279     gMC->Gspos("ITS0",1,"IDAI",0.0,0.0,0.0,0,"ONLY");
280
281
282 //// Position detectors, Beam Axis Z, X to the right, Y up to the sky.
283     // Upsteram planes of the telescope    
284     Float_t p00X,p00Y,p00Z,p01X,p01Y,p01Z,p10X,p10Y,p10Z,p11X,p11Y,p11Z;
285     p00X = 0.0*kcm;
286     p00Y = 0.0*kcm;
287     p00Z = -584*kmm;
288     gMC->Gspos("ITEL",1,"ITSV",p00X,p00Y,p00Z,idrotm[0],"ONLY");//SSD X
289     p01X = 0.0*kcm;
290     p01Y = 0.0*kcm;
291     p01Z = -574*kmm;
292     gMC->Gspos("ITEL",2,"ITSV",p01X,p01Y,p01Z,idrotm[1],"ONLY");//SSD Y
293     p01X = 0.0*kcm;
294     p01Y = 0.0*kcm;
295     p01Z = -504*kmm;
296     gMC->Gspos("ITEL",3,"ITSV",p01X,p01Y,p01Z,idrotm[0],"ONLY");//SSD X
297     p01X = 0.0*kcm;
298     p01Y = 0.0*kcm;
299     p01Z = -494*kmm;
300     gMC->Gspos("ITEL",4,"ITSV",p01X,p01Y,p01Z,idrotm[1],"ONLY");//SSD Y
301
302     // Downstream planes of the telescope
303     p10X = 0.0*kcm;
304     p10Y = 0.0*kcm;
305     p10Z = +601.0*kmm; 
306     gMC->Gspos("ITEL",5,"ITSV",p10X,p10Y,p10Z,idrotm[0],"ONLY");//SSD X
307     p11X = 0.0*kcm;
308     p11Y = 0.0*kcm;
309     p11Z = +610.0*kmm; //611.0
310     gMC->Gspos("ITEL",6,"ITSV",p11X,p11Y,p11Z,idrotm[1],"ONLY");//SSD Y
311     p11X = 0.0*kcm;
312     p11Y = 0.0*kcm;
313     p11Z = +684.0*kmm;
314     gMC->Gspos("ITEL",7,"ITSV",p11X,p11Y,p11Z,idrotm[0],"ONLY");//SSD X
315     p11X = 0.0*kcm;
316     p11Y = 0.0*kcm;
317     p11Z = +694.0*kmm;
318     gMC->Gspos("ITEL",8,"ITSV",p11X,p11Y,p11Z,idrotm[1],"ONLY");//SSD Y
319     p11X = 0.0*kcm;
320     p11Y = 0.0*kcm;
321     p11Z = +877.0*kmm;
322     gMC->Gspos("ITEL",9,"ITSV",p11X,p11Y,p11Z,idrotm[0],"ONLY");//SSD X
323     p11X = 0.0*kcm;
324     p11Y = 0.0*kcm;
325     p11Z = +887.0*kmm;
326     gMC->Gspos("ITEL",10,"ITSV",p11X,p11Y,p11Z,idrotm[1],"ONLY");//SSD Y
327
328     // SDDs 
329     Float_t pdet1X,pdet1Y,pdet1Z;
330     Float_t pdet2X,pdet2Y,pdet2Z;
331     pdet1X = 0.0*kcm;
332     pdet1Y = 0.0*kcm;
333     pdet1Z = 0.0*kcm;
334     gMC->Gspos("IDET",1,"ITSV",pdet1X,pdet1Y,pdet1Z,idrotm[0],"ONLY");// Detector1
335     pdet2X = 0.0*kcm;
336     pdet2Y = 0.0*kcm;
337     pdet2Z = 52*kmm; //52
338     gMC->Gspos("IDET",2,"ITSV",pdet2X,pdet2Y,pdet2Z,idrotm[0],"ONLY");// Detector2
339
340 // Target definition and placement
341     if(fTarg){
342       data[0] = 30*kmm;
343       data[1] = fTargThick*kmm;  // Target thickness
344       data[2] = 30*kmm;
345       gMC->Gsvolu("ITGT","BOX ",idtmed[fTarg],data,3);
346
347       Float_t a,z,dens,radl,absl;
348       Float_t* ubuf=0; Int_t nbuf;
349       char* ssss=0;
350       gMC->Gfmate(idtmed[fTarg],ssss,a,z,dens,radl,absl,ubuf,nbuf);
351
352       Info("CreateGeometry","Target A=%f,  Z=%f,  dens=%f",a,z,dens);
353       Info("Creategeometry","Target thickness=%f mm",fTargThick);
354
355       Float_t ptgtX,ptgtY,ptgtZ;
356       ptgtX = 0.0*kcm;
357       ptgtY = 0.0*kcm;
358       ptgtZ = -50*kmm;
359       gMC->Gspos("ITGT",1,"ITSV",ptgtX,ptgtY,ptgtZ,idrotm[0],"ONLY");// Target
360     }else{
361       Info("CreateGeometry","No target defined");
362     }
363 }
364 //______________________________________________________________________
365 void AliITSvSDD03::CreateMaterials(){
366     ////////////////////////////////////////////////////////////////////////
367     //
368     // Create ITS SDD test beam materials
369     //     This function defines the default materials used in the Geant
370     // Monte Carlo simulations for the geometries AliITSv1, AliITSv3,
371     // AliITSvSDD03.
372     // In general it is automatically replaced by
373     // the CreateMaterials routine defined in AliITSv?. Should the function
374     // CreateMaterials not exist for the geometry version you are using this
375     // one is used. See the definition found in AliITSv5 or the other routine
376     // for a complete definition.
377     //
378     // Inputs:
379     //    none.
380     // Outputs:
381     //    none.
382     // Return:
383     //    none.
384     /////////////////////////////////////////////////////////////////////////
385     Float_t tmaxfdSi = 0.1; // Degree
386     Float_t stemaxSi = 0.0075; // cm //0.0075
387     Float_t deemaxSi = 0.1; // Fraction of particle's energy 0<deemax<=1
388     Float_t epsilSi  = 1.0E-4;//
389     Float_t stminSi  = 0.0; // cm "Default value used"
390
391     Float_t tmaxfdAir = 0.1; // Degree
392     Float_t stemaxAir = .10000E+01; // 1 cm  //cm
393     Float_t deemaxAir = 0.1; // Fraction of particle's energy 0<deemax<=1
394     Float_t epsilAir  = 1.0E-4;//
395     Float_t stminAir  = 0.0; // cm "Default value used"
396     Int_t   ifield = gAlice->Field()->Integ();
397     Float_t fieldm = gAlice->Field()->Max();
398     //
399
400     // AIR
401     Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
402     Float_t zAir[4]={6.,7.,8.,18.};
403     Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
404     Float_t dAir = 1.20479E-3;
405     // Lucite/Plexiglass
406     Float_t aLuc[3] = {1.,12.,16.};
407     Float_t zLuc[3] = {1.,6.,8.};
408     Float_t wLuc[3] = {8.,5.,2.};
409     Float_t dLuc = 1.19;
410     // stainless steel
411     Float_t asteel[4] = { 55.847,51.9961,58.6934,28.0855 };
412     Float_t zsteel[4] = { 26.,24.,28.,14. };
413     Float_t wsteel[4] = { .715,.18,.1,.005 };
414     Float_t dsteel = 7.88;
415
416     AliMixture(1, "AIR$",aAir,zAir,dAir,4,wAir);
417     AliMaterial(2,"SI$",28.086,14.0,2.3300,9.3600,999.00);
418     AliMixture(3,"Sintilator$",aLuc,zLuc,dLuc,-3,wLuc);
419     AliMixture(4,"PlasticBox$",aLuc,zLuc,dLuc,-3,wLuc);
420     AliMaterial(5, "IRON$", 55.85, 26., 7.87, 1.76, 999.00);
421     AliMaterial(6, "LEAD$", 207.19, 82., 11.35, .56, 999.00);
422     AliMixture(7, "STAINLESS STEEL$", asteel, zsteel,dsteel, 4, wsteel);
423     AliMaterial(9, "C$", 12.011, 6., 2.265, 18.8, 999.00);
424     AliMaterial(10, "Al$", 26.98, 13., 2.70, 8.9, 999.00);
425     AliMaterial(11, "Be$", 9.012, 4., 1.848, 35.3, 999.00);
426     AliMaterial(12, "Ti$", 47.88, 22., 4.54, 3.56, 999.00);
427     AliMaterial(13, "Sn$", 118.69, 50., 7.31, 1.21, 999.00); 
428     AliMaterial(14, "Cu$", 63.55, 29., 8.96, 1.43, 999.00);
429     AliMaterial(15, "Ge$", 72.59, 32., 5.323, 2.30, 999.00);
430     AliMaterial(20, "W$", 183.85, 74., 19.3, 0.35, 999.00);
431  
432     AliMedium(1,"AIR$",1,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,
433               epsilAir,stminAir);
434     AliMedium(2,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
435               epsilSi,stminSi);
436     AliMedium(3,"Scintillator$",3,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
437               epsilSi,stminSi);
438     AliMedium(4,"PlasticBox$",4,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
439               epsilSi,stminSi);
440     AliMedium(5,"IRON$",5,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
441               epsilSi,stminSi);
442     AliMedium(6,"LEAD$",6,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
443               epsilSi,stminSi);
444     AliMedium(7,"StainlessSteel$",7,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
445               epsilSi,stminSi);
446
447     AliMedium(9,"C$",9,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
448     AliMedium(10,"Al$",10,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
449     AliMedium(11,"Be$",11,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
450     AliMedium(12,"Ti$",12,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
451     AliMedium(13,"Sn$",13,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
452     AliMedium(14,"Cu$",14,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
453     AliMedium(15,"Ge$",15,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
454     AliMedium(20,"W$",20,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
455     //dummy materials to avoid warning during simulation (galice.cuts)
456
457    AliMedium(21,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
458               epsilSi,stminSi);
459    AliMedium(25,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
460               epsilSi,stminSi);
461    AliMedium(26,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
462               epsilSi,stminSi);
463    AliMedium(27,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
464               epsilSi,stminSi);
465    AliMedium(51,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
466               epsilSi,stminSi);
467    AliMedium(52,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
468               epsilSi,stminSi);
469    AliMedium(53,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
470               epsilSi,stminSi);
471    AliMedium(54,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
472               epsilSi,stminSi);
473    AliMedium(55,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
474               epsilSi,stminSi);
475    AliMedium(56,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
476               epsilSi,stminSi);
477    AliMedium(61,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
478               epsilSi,stminSi);
479    AliMedium(62,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
480               epsilSi,stminSi);
481    AliMedium(63,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
482               epsilSi,stminSi);
483    AliMedium(64,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
484               epsilSi,stminSi);
485    AliMedium(65,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
486               epsilSi,stminSi);
487    AliMedium(68,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
488               epsilSi,stminSi);
489    AliMedium(69,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
490               epsilSi,stminSi);
491    AliMedium(70,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
492               epsilSi,stminSi);
493    AliMedium(71,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
494               epsilSi,stminSi);
495    AliMedium(72,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
496               epsilSi,stminSi);
497    AliMedium(73,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
498               epsilSi,stminSi);
499    AliMedium(74,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
500               epsilSi,stminSi);
501    AliMedium(75,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
502               epsilSi,stminSi);
503    AliMedium(76,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
504               epsilSi,stminSi);
505    AliMedium(77,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
506               epsilSi,stminSi);
507    AliMedium(78,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
508               epsilSi,stminSi);
509    AliMedium(79,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
510               epsilSi,stminSi);
511    AliMedium(80,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
512               epsilSi,stminSi);
513    AliMedium(81,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
514               epsilSi,stminSi);
515    AliMedium(82,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
516               epsilSi,stminSi);
517    AliMedium(83,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
518               epsilSi,stminSi);
519    AliMedium(84,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
520               epsilSi,stminSi);
521    AliMedium(85,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
522               epsilSi,stminSi);
523    AliMedium(90,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
524               epsilSi,stminSi);
525    AliMedium(91,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
526               epsilSi,stminSi);
527    AliMedium(92,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
528               epsilSi,stminSi);
529    AliMedium(93,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
530               epsilSi,stminSi);
531    AliMedium(94,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
532               epsilSi,stminSi);
533    AliMedium(95,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
534               epsilSi,stminSi);
535    AliMedium(96,"SI$",2,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,
536               epsilSi,stminSi);
537
538 }/*
539 //______________________________________________________________________
540 void AliITSvSDD03::InitAliITSgeom(){
541     //     Based on the geometry tree defined in Geant 3.21, this
542     // routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry
543     // sturture.
544     // Inputs:
545     //    none.
546     // Outputs:
547     //    none.
548     // Return:
549     //    none.
550     const Int_t knlayers=12;
551     //   const Int_t kndeep=6;
552     const Int_t kltypess=2;
553     const AliITSDetector kidet[knlayers]={kSSD,kSDD};
554     const TString knames[kltypess]={
555         "/ALIC_1/ITSV_1/ITEL_%d/ITAI_1/IMB0_1/IMBS_1",
556         "/ALIC_1/ITSV_1/IDET_%d/IDAI_1/ITS0_1/ITST_1"};
557     const Int_t kitsGeomTreeCopys[kltypess]={10,2};
558     const Int_t knp=384;
559     const Float_t kpitch=50.E-4;//cm
560     Float_t box[3]={0.5*kpitch*(Float_t)knp,150.E-4,1.0},p[knp+1],n[knp+1];
561     Int_t nlad[knlayers]={knlayers*1};
562     Int_t ndet[knlayers]={knlayers*1};
563     Int_t mod=knlayers,lay=0,lad=0,det=0,i,j,cp0;
564     TString path,shapeName;
565     TGeoHMatrix matrix;
566     Double_t trans[3]={3*0.0},rot[10]={10*0.0};
567     TArrayD shapePar;
568     TArrayF shapeParF;
569     Bool_t isShapeDefined[kltypess]={kltypess*kFALSE};
570     AliITSgeom *geom = new AliITSgeom(0,knlayers,nlad,ndet,mod);
571     if(GetITSgeom()!=0) SetITSgeom(0x0);// delet existing if there.
572     SetITSgeom(geom);
573
574     p[0]=-box[0];
575     n[0]=box[0];
576     // Fill in anode and cathode strip locations (lower edge)
577     for(i=1;i<knp;i++){
578         p[i] =p[i-1]+kpitch;
579         n[i] =n[i-1]-kpitch;
580     } // end for i
581     p[knp]=box[0];
582     n[knp]=-box[0];
583     for(i=0;i<kltypess;i++)for(cp0=1;cp0<=kitsGeomTreeCopys[i];cp0++){
584         mod = DecodeDetector(fIdSens[i],cp0,lay,lad,det);
585         path.Form(knames[i].Data(),cp0);
586         gMC->GetTransformation(path.Data(),matrix);
587         gMC->GetShape(path.Data(),shapeName,shapePar);
588         shapeParF.Set(shapePar.GetSize());
589         for(j=0;j<shapePar.GetSize();j++)shapeParF[j]=shapePar[j];
590         geom->CreateMatrix(mod,lay,lad,det,kidet[i],trans,rot);
591         geom->SetTrans(mod,matrix.GetTranslation());
592         geom->SetRotMatrix(mod,matrix.GetRotationMatrix());
593         geom->GetGeomMatrix(mod)->SetPath(path.Data());
594         switch (kidet[i]){
595         case kSDD: if(!(GetITSgeom()->IsShapeDefined((Int_t)kSDD))){
596             geom->ReSetShape(kSDD,new AliITSgeomSDD256(shapeParF.GetSize(),
597                                                        shapeParF.GetArray()));
598             isShapeDefined[i]=kTRUE;
599         } break;
600         case kSSD:if(!(GetITSgeom()->IsShapeDefined((Int_t)kSSD))){
601             geom->ReSetShape(kSSD,new AliITSgeomSSD(box,0.0,0.0,
602                                                     knp+1,p,knp+1,n));
603             isShapeDefined[i]=kTRUE;
604         } break;
605         default:{} break;
606         } // end switch
607     } // end for i,cp0
608     return;
609 }*/
610 //______________________________________________________________________
611 void AliITSvSDD03::Init(){
612     ////////////////////////////////////////////////////////////////////////
613     //     Initialise the ITS after it has been created.
614     // Inputs:
615     //    none.
616     // Outputs:
617     //    none.
618     // Return:
619     //    none.
620     ////////////////////////////////////////////////////////////////////////
621
622
623     Info("Init","**********AliITSvSDD03 %d _Init *************",fMinorVersion);
624
625     AliDebug(1,Form("Init: Major version %d Minor version %d",fMajorVersion,
626                  fMinorVersion));
627     //
628     UpdateInternalGeometry();
629     AliITS::Init();
630     //
631     fIDMother = gMC->VolId("ITSV"); // ITS Mother Volume ID.
632
633 }/*
634 //______________________________________________________________________
635 void AliITSvSDD03::SetDefaults(){
636     // sets the default segmentation, response, digit and raw cluster classes
637     // Inputs:
638     //    none.
639     // Outputs:
640     //    none.
641     // Return:
642     //    none.
643
644   //    const Float_t kconv = 1.0e+04; // convert cm to microns
645
646     if(!fDetTypeSim) fDetTypeSim = new AliITSDetTypeSim();
647     fDetTypeSim->SetITSgeom(GetITSgeom());
648     fDetTypeSim->ResetCalibrationArray();
649     fDetTypeSim->ResetSegmentation();
650  
651     AliITSgeomSDD *s1;
652     AliITSgeomSSD *s2;
653     SetCalibrationModel(GetITSgeom()->GetStartSPD(),new AliITSCalibrationSPD());
654     SetSegmentationModel(kSPD,(AliITSsegmentationSPD*)
655                          (GetITSgeom()->GetShape(kSPD)));
656     fDetTypeSim->SetDigitClassName(kSPD,"AliITSdigitSPD");
657
658     // SDD
659     s1 = (AliITSgeomSDD*) GetITSgeom()->GetShape(kSDD);// Get shape info. Do it this way for now.
660     AliITSCalibrationSDD *resp1=new AliITSCalibrationSDD("simulated");
661     SetCalibrationModel(GetITSgeom()->GetStartSDD(),resp1);
662
663     AliITSsegmentationSDD *seg1 = (AliITSsegmentationSDD*)
664                          (GetITSgeom()->GetShape(kSDD));
665     seg1->SetDriftSpeed(AliITSDriftSpeedSDD::DefaultDriftSpeed());
666     seg1->SetNPads(256,256);// Use AliITSgeomSDD for now
667     SetSegmentationModel(kSDD,seg1);
668     const char *kData1=(fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSDD()))->DataType();
669
670     // SSD  Layer 5
671
672     s2 = (AliITSgeomSSD*) GetITSgeom()->GetShape(kSSD);// Get shape info. Do it this way for now.
673    
674     AliITSCalibration *resp2= new AliITSCalibrationSSD("simulated");
675     SetCalibrationModel(GetITSgeom()->GetStartSSD(),resp2);
676
677     AliITSsegmentationSSD *seg2 = (AliITSsegmentationSSD*)
678                          (GetITSgeom()->GetShape(kSSD));
679     seg2->SetPadSize(50.,0.); // strip x pitch in microns
680     seg2->SetNPads(384,0); // number of strips on each side.
681     seg2->SetLayer(5);
682     seg2->SetAngles(0.,0.); // strip angles rad P and N side.
683     seg2->SetAnglesLay5(0.,0.); // strip angles rad P and N side.
684     seg2->SetAnglesLay6(0.,0.); // strip angles rad P and N side.
685
686     SetSegmentationModel(kSSD,seg2); 
687     const char *kData2=(fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSSD()))->DataType();
688     if(strstr(kData2,"real") ) fDetTypeSim->SetDigitClassName(kSSD,"AliITSdigit");
689     else fDetTypeSim->SetDigitClassName(kSSD,"AliITSdigitSSD");
690
691     if(fgkNTYPES>3){
692         Warning("SetDefaults",
693                 "Only the four basic detector types are initialised!");
694     }// end if
695     return;
696 }
697 //______________________________________________________________________
698 void AliITSvSDD03::SetDefaultSimulation(){
699     // sets the default simulation.
700     // Inputs:
701     //      none.
702     // Outputs:
703     //      none.
704     // Return:
705     //      none.
706
707   if(!fDetTypeSim) fDetTypeSim = new AliITSDetTypeSim();
708   AliITSsimulation *sim;
709   //AliITSsegmentation *seg;
710   //AliITSCalibration *res;
711   //SPD
712   if(fDetTypeSim){
713     sim = fDetTypeSim->GetSimulationModel(kSPD);
714     if (!sim) {
715       //seg =(AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSPD);
716       //if(seg==0) seg = new AliITSsegmentationSPD();
717       //res = (AliITSCalibration*)fDetTypeSim->GetResponseModel(GetITSgeom()->GetStartSPD());
718       //if(res==0) res = new AliITSCalibrationSPD();
719       sim = new AliITSsimulationSPD(fDetTypeSim);
720       SetSimulationModel(kSPD,sim);
721     }else{ // simulation exists, make sure it is set up properly.
722       sim->SetSegmentationModel(kSPD,(AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSPD));
723       sim->SetCalibrationModel(GetITSgeom()->GetStartSPD(),(AliITSCalibration*)fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSPD()));
724       sim->Init();
725     } // end if
726   } // end if iDetType
727   //SDD
728   if(fDetTypeSim){
729     sim = fDetTypeSim->GetSimulationModel(kSDD);
730     if (!sim) {
731       //      seg = (AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSDD);
732       //res = (AliITSCalibration*)fDetTypeSim->GetResponseModel(GetITSgeom()->GetStartSDD());
733       sim = new AliITSsimulationSDD(fDetTypeSim);
734       SetSimulationModel(kSDD,sim);
735     }else{ // simulation exists, make sure it is set up properly.
736       sim->SetSegmentationModel(kSDD,(AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSDD));
737       sim->SetCalibrationModel(GetITSgeom()->GetStartSDD(),(AliITSCalibration*)fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSDD()));
738       
739       sim->Init();
740     } //end if
741   } // end if iDetType
742   //SSD
743   if(fDetTypeSim){
744     sim = fDetTypeSim->GetSimulationModel(kSSD);
745     if (!sim) {
746       //      seg = (AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSSD);
747       // res = (AliITSCalibration*)fDetTypeSim->GetResponseModel(GetITSgeom()->GetStartSSD());
748       sim = new AliITSsimulationSSD(fDetTypeSim);
749       SetSimulationModel(kSSD,sim);
750     }else{ // simulation exists, make sure it is set up properly.
751       sim->SetSegmentationModel(kSSD,(AliITSsegmentation*)fDetTypeSim->GetSegmentationModel(kSSD));
752       sim->SetCalibrationModel(GetITSgeom()->GetStartSSD(),(AliITSCalibration*)fDetTypeSim->GetCalibrationModel(GetITSgeom()->GetStartSSD()));
753       sim->Init();
754     } // end if
755   } // end if iDetType
756   }*/
757 //______________________________________________________________________
758 void AliITSvSDD03::DrawModule() const{
759     ////////////////////////////////////////////////////////////////////////
760     //     Draw a shaded view of the ITS SDD test beam version 1.
761     // Inputs:
762     //    none.
763     // Outputs:
764     //    none.
765     // Return:
766     //    none.
767     ////////////////////////////////////////////////////////////////////////
768     // Set everything unseen
769     gMC->Gsatt("*", "seen", -1);
770     // Set ALIC mother visible
771     gMC->Gsatt("ALIC","SEEN",0);
772     // Set ALIC ITS visible
773     gMC->Gsatt("ITSV","SEEN",1);
774     // Set ALIC Telescopes visible
775     gMC->Gsatt("ITEL","SEEN",1);
776     gMC->Gsatt("ITEL","colo",2);
777     // Set ALIC detetcor visible
778     gMC->Gsatt("IDET","SEEN",1);
779     gMC->Gsatt("IDET","colo",4);
780     // Set ALIC Scintillator visible
781     gMC->Gsatt("ISNT","SEEN",1);
782     gMC->Gsatt("ISNT","colo",3);
783     // Set Detector mother visible and drawn
784 //    gMC->Gsatt("ITS0","SEEN",1);
785     // Set minibus mother visible and drawn
786 //    gMC->Gsatt("IMB0","SEEN",1);
787
788     // Draw
789     gMC->Gdraw("alic", 60, 30, 180, 10,10, .12, .12);
790 }
791 //______________________________________________________________________
792 void AliITSvSDD03::StepManager(){
793     ////////////////////////////////////////////////////////////////////////
794     //    Called for every step in the ITS SDD test beam, then calles the 
795     // AliITShit class  creator with the information to be recoreded about
796     //  that hit.
797     //     The value of the macro ALIITSPRINTGEOM if set to 1 will allow the
798     // printing of information to a file which can be used to create a .det
799     // file read in by the routine CreateGeometry(). If set to 0 or any other
800     // value except 1, the default behavior, then no such file is created nor
801     // it the extra variables and the like used in the printing allocated.
802     // Inputs:
803     //    none.
804     // Outputs:
805     //    none.
806     // Return:
807     //    none.
808     ////////////////////////////////////////////////////////////////////////
809     if(!(this->IsActive())) return;
810     if(!(gMC->TrackCharge())) return;
811
812     Int_t  cpy0,cpy1,ncpys=0,status,id,mod;
813     TLorentzVector position, momentum;
814     static AliITShit hit;// Saves on calls to construtors
815     //TClonesArray &lhits = *(GetDetTypeSim()->GetHits());
816     TClonesArray &lhits = *(Hits());
817     //
818     // Track status
819     // Track status
820     status = 0;
821     if(gMC->IsTrackInside())      status +=  1;
822     if(gMC->IsTrackEntering())    status +=  2;
823     if(gMC->IsTrackExiting())     status +=  4;
824     if(gMC->IsTrackOut())         status +=  8;
825     if(gMC->IsTrackDisappeared()) status += 16;
826     if(gMC->IsTrackStop())        status += 32;
827     if(gMC->IsTrackAlive())       status += 64;
828     //
829     // Fill hit structure.
830     gMC->TrackPosition(position);
831     gMC->TrackMomentum(momentum);
832     id   = gMC->CurrentVolID(cpy0);
833     gMC->CurrentVolOffID(3,cpy1);
834     if(id==fIdSens[0])ncpys=10;
835     if(id==fIdSens[1])ncpys=2;
836     fIgm.DecodeDetector(mod,ncpys,cpy0,cpy1,1);
837     //
838     // Fill hit structure.
839     //
840     hit.SetModule(mod);
841     hit.SetTrack(gAlice->GetMCApp()->GetCurrentTrackNumber());
842     gMC->TrackPosition(position);
843     gMC->TrackMomentum(momentum);
844     hit.SetPosition(position);
845     hit.SetTime(gMC->TrackTime());
846     hit.SetMomentum(momentum);
847     hit.SetStatus(status);
848     hit.SetEdep(gMC->Edep());
849     hit.SetShunt(GetIshunt());
850     if(gMC->IsTrackEntering()){
851         hit.SetStartPosition(position);
852         hit.SetStartTime(gMC->TrackTime());
853         hit.SetStartStatus(status);
854         return; // don't save entering hit.
855     } // end if IsEntering
856     // Fill hit structure with this new hit.
857     //Info("StepManager","Calling Copy Constructor");
858     new(lhits[fNhits++]) AliITShit(hit); // Use Copy Construtor.
859     // Save old position... for next hit.
860     hit.SetStartPosition(position);
861     hit.SetStartTime(gMC->TrackTime());
862     hit.SetStartStatus(status);
863     return;
864 }
865