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