]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSvBeamTestITS04.cxx
compilation warnings
[u/mrichter/AliRoot.git] / ITS / AliITSvBeamTestITS04.cxx
1 ////////////////////////////////////////////////////////
2 // ITS geometry class and step manager for the        //
3 //   integrated ITS test beam of Nov. 04              //
4 //  Author: mercedes.lopez.noriega@cern.ch            //
5 ////////////////////////////////////////////////////////
6
7 #include <TLorentzVector.h>
8
9 #include <TGeoManager.h>
10 #include <TGeoVolume.h>
11 #include <TGeoMatrix.h>
12 #include <TGeoPcon.h>
13 #include "AliRun.h"
14 #include "AliITSvBeamTestITS04.h"
15 #include <TClonesArray.h>
16 #include <TString.h>
17 #include "AliITS.h"
18 #include "AliMagF.h"
19 #include "TVirtualMC.h"
20 #include "AliMC.h"
21 #include "AliTrackReference.h"
22 #include "AliITSgeom.h"
23 #include "AliITShit.h"
24
25 const Int_t AliITSvBeamTestITS04::fgkNumberOfSPD = 4;
26 const Int_t AliITSvBeamTestITS04::fgkNumberOfSDD = 2;
27 const Int_t AliITSvBeamTestITS04::fgkNumberOfSSD = 4;
28 // Dimension (thickness:Y (beam direction), width:X, length:Z)
29
30 const char*    AliITSvBeamTestITS04::fgSPDsensitiveVolName = "ITSspdSensitiv";
31 //dimensions (preliminary values from Petra (in cms))
32 const Double_t AliITSvBeamTestITS04::fgkSPDthickness    = 0.02;
33 const Double_t AliITSvBeamTestITS04::fgkSPDwidth        = 1.4; 
34 const Double_t AliITSvBeamTestITS04::fgkSPDlength       = 7.2;
35 const Double_t AliITSvBeamTestITS04::fgkSPDthickSens    = 0.02;
36 const Double_t AliITSvBeamTestITS04::fgkSPDwidthSens    = 1.2; 
37 const Double_t AliITSvBeamTestITS04::fgkSPDlengthSens   = 7.0;
38 //position
39 const Double_t AliITSvBeamTestITS04::fgkSPD0y = 23.7;
40 const Double_t AliITSvBeamTestITS04::fgkSPD1y = 33.7;
41
42 //===
43 const char*    AliITSvBeamTestITS04::fgSDDsensitiveVolName = "ITSsddSensitiv";
44 //dimensions (preliminary values from Ludovic (in cms))
45 const Double_t AliITSvBeamTestITS04::fgkSDDthickness     = 0.03;
46 const Double_t AliITSvBeamTestITS04::fgkSDDwidth         = 7.22;
47 const Double_t AliITSvBeamTestITS04::fgkSDDlength        = 8.76;
48 const Double_t AliITSvBeamTestITS04::fgkSDDthickSens     = 0.02998;
49 const Double_t AliITSvBeamTestITS04::fgkSDDwidthSens     = 7.017;
50 const Double_t AliITSvBeamTestITS04::fgkSDDlengthSens    = 7.497;
51 //position
52 const Double_t AliITSvBeamTestITS04::fgkSDD0y = 51.7;
53 const Double_t AliITSvBeamTestITS04::fgkSDD1y = 57.2;
54
55 //===
56 const char*    AliITSvBeamTestITS04::fgSSDsensitiveVolName = "ITSssdSensitiv";
57 //dimensions (final values from Javier (in cms))
58 const Double_t AliITSvBeamTestITS04::fgkSSDthickness    = 0.03;
59 const Double_t AliITSvBeamTestITS04::fgkSSDwidth        = 7.7;
60 const Double_t AliITSvBeamTestITS04::fgkSSDlength       = 4.4;
61 const Double_t AliITSvBeamTestITS04::fgkSSDthickSens    = 0.03;
62 const Double_t AliITSvBeamTestITS04::fgkSSDwidthSens    = 7.5;
63 const Double_t AliITSvBeamTestITS04::fgkSSDlengthSens   = 4.2;
64 //position
65 const Double_t AliITSvBeamTestITS04::fgkSSD0y = 73.6;
66 const Double_t AliITSvBeamTestITS04::fgkSSD1y = 80.6;
67
68 //===============================================================
69
70
71
72 ClassImp(AliITSvBeamTestITS04)
73     
74 //_____________________________________________________________
75   AliITSvBeamTestITS04::AliITSvBeamTestITS04() : 
76 AliITS(),              // Base class
77 fITSmotherVolume(0),   // Pointer to ITS mother volume.
78 fNspd(fgkNumberOfSPD), //Number of SPD modules
79 fNsdd(fgkNumberOfSDD), //Number of SDD modules
80 fNssd(fgkNumberOfSSD), //Number of SSD modules
81 fGeomDetOut(kFALSE),   // Flag to write .det file out
82 fGeomDetIn(kFALSE),    // Flag to read geometry file (JC)
83 fWrite(),              //! file name to write .det file 
84 fRead(),               // file name to read .det file (JC)
85 fMajorVersion(kvITS04),// Major Version
86 fMinorVersion(1),      // Minor Version
87 fIgm(kvITS04)          //! Init geometry object
88 {
89     //
90     // Constructor
91     //
92
93     fIdN = 3;         
94     fIdName    = new TString[fIdN];
95     fIdName[0] = fgSPDsensitiveVolName;
96     fIdName[1] = fgSDDsensitiveVolName;
97     fIdName[2] = fgSSDsensitiveVolName;
98     fIdSens    = new Int_t[fIdN];
99     for(Int_t i=0; i<fIdN; i++) fIdSens[i] = 0;
100     
101     for(Int_t a=0;a<60;a++) fWrite[a] = '\0';
102 }
103 //_____________________________________________________________
104 AliITSvBeamTestITS04::AliITSvBeamTestITS04(const char* name,const char *title):
105 AliITS(name,title),   // Base class
106 fITSmotherVolume(0),   // Pointer to ITS mother volume.
107 fNspd(fgkNumberOfSPD), //Number of SPD modules
108 fNsdd(fgkNumberOfSDD), //Number of SDD modules
109 fNssd(fgkNumberOfSSD), //Number of SSD modules
110 fGeomDetOut(kFALSE),   // Flag to write .det file out
111 fGeomDetIn(kFALSE),    // Flag to read geometry file (JC)
112 fWrite(),              //! file name to write .det file 
113 fRead(),               // file name to read .det file (JC)
114 fMajorVersion(kvITS04),// Major Version
115 fMinorVersion(1),       // Minor Version
116 fIgm(kvITS04)          //! Init geometry object
117 {
118     //
119     // Constructor
120     //
121
122     fIdN = 3;         
123     fIdName    = new TString[fIdN];
124     fIdName[0] = fgSPDsensitiveVolName;
125     fIdName[1] = fgSDDsensitiveVolName;
126     fIdName[2] = fgSSDsensitiveVolName;
127     fIdSens    = new Int_t[fIdN];
128     for(Int_t i=0; i<fIdN; i++) fIdSens[i] = 0;
129     for(Int_t a=0;a<60;a++) fWrite[a] = '\0';    
130 }
131 //__________________________________________________________________
132 AliITSvBeamTestITS04::~AliITSvBeamTestITS04(){
133     //
134     // Destructor
135     //
136 }
137 //______________________________________________________________________
138 void AliITSvBeamTestITS04::CreateMaterials(){
139     // Media defined here should correspond to the one defined in galice.cuts
140     // This file is read in (AliMC*) fMCApp::Init() { ReadTransPar(); }
141     // Create ITS materials
142     Int_t   ifield = gAlice->Field()->Integ();
143     Float_t fieldm = gAlice->Field()->Max();
144     
145     Float_t tmaxfdSi = 0.1;
146     Float_t stemaxSi = 0.0075;
147     Float_t deemaxSi = 0.1;
148     Float_t epsilSi  = 1.0E-4;
149     Float_t stminSi  = 0.0;
150     
151     Float_t tmaxfdAir = 0.1;
152     Float_t stemaxAir = .10000E+01;
153     Float_t deemaxAir = 0.1;
154     Float_t epsilAir  = 1.0E-4;
155     Float_t stminAir  = 0.0;
156  
157     // AIR
158     Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
159     Float_t zAir[4]={6.,7.,8.,18.};
160     Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
161     Float_t dAir = 1.20479E-3;
162     
163     AliMaterial(51,"ITSspdSi",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
164     AliMedium(51,"ITSspdSi",51,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
165     
166     AliMaterial(1,"ITSsddSi",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
167     AliMedium(1,"ITSsddSi",1,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
168     
169     //AliMaterial(?,"ITSssdSi",0.28086E+02,0.14000E+02,0.23300E+01,0.93600E+01,0.99900E+03);
170     //AliMedium(?,"ITSssdSi",51,0,ifield,fieldm,tmaxfdSi,stemaxSi,deemaxSi,epsilSi,stminSi);
171     
172     AliMixture(5,"ITSair",aAir,zAir,dAir,4,wAir);
173     AliMedium(5,"ITSair",5,0,ifield,fieldm,tmaxfdAir,stemaxAir,deemaxAir,epsilAir,stminAir);
174     
175 //NEED TO ADD PLASTIC OF SCINTILLATORS!!
176
177 }
178
179 //______________________________________________________________________
180 void AliITSvBeamTestITS04::CreateGeometry(){    
181     //Creates geometry
182     // These constant character strings are set by cvs during commit
183     // do not change them unless you know what you are doing!
184     const Char_t *cvsDate="$Date$";
185     const Char_t *cvsRevision="$Revision$";
186     TGeoManager *geoManager = gGeoManager;
187     TGeoVolume *vALIC = geoManager->GetTopVolume();
188     
189     //================================
190     //       ITS mother volume
191     //================================
192     TGeoPcon *sITS = new TGeoPcon("ITS Top Volume",0.0,360.0,2);
193     // DefineSection(section number, Z, Rmin, Rmax).
194     sITS->DefineSection(0,-100.0,0.01,100.0); // Units in cms
195     sITS->DefineSection(1,+100.0,0.01,100.0);
196     
197     TGeoMedium *air = geoManager->GetMedium("ITSair");
198     fITSmotherVolume = new TGeoVolume("ITSV",sITS,air);
199     const Int_t kLength=100;
200     Char_t vstrng[kLength];
201     if(fIgm.WriteVersionString(vstrng,kLength,(AliITSVersion_t)IsVersion(),
202                                fMinorVersion,cvsDate,cvsRevision))
203         fITSmotherVolume->SetTitle(vstrng);
204     else Error("CreateGeometry","Error writing/setting version string");
205     //printf("Title set to %s\n",vstrng);
206     if(vALIC==0) {
207         Error("CreateGeometry","alic=0");
208         return;
209     } // end if
210     fITSmotherVolume->SetVisibility(kFALSE);
211     vALIC->AddNode(fITSmotherVolume,1,0);
212     
213 //     //Scintillators
214 //     TGeoMedium *plasticScint = new TGeoMedium("plasticScint",1,Plastic);
215 //     //First Scintillator
216 //     TGeoBBox *Scint1Shape = new TGeoBBox("Scint1Shape",0.5,0.1,0.5,0); //1x1cm
217 //     TGeoVolume *Scint1 = new TGeoVolume("Scint1",Scint1Shape,plasticScint);
218 //     TGeoTranslation *firstScint = new TGeoTranslation(0,0.7,0);
219 //     vALIC->AddNode(Scint1,2,firstScint);
220 //     //Second Scintillator
221 //     TGeoBBox *Scint2Shape = new TGeoBBox("Scint2Shape",1.,0.1,1.,0); //2x2cm
222 //     TGeoVolume *Scint2 = new TGeoVolume("Scint2",Scint2Shape,plasticScint);
223 //     TGeoTranslation *secondScint = new TGeoTranslation(0,90.,0);
224 //     vALIC->AddNode(Scint2,3,secondScint);
225     
226     AddSPDGeometry(fITSmotherVolume);
227     AddSDDGeometry(fITSmotherVolume);
228     AddSSDGeometry(fITSmotherVolume);
229 }
230
231 //______________________________________________________________________
232 void AliITSvBeamTestITS04::Init()
233 {
234     // Initialize the ITS after it has been created.
235     // Inputs:
236     //   none.
237     // Outputs:
238     //   none.
239     // Return:
240     //   none.
241
242     AliDebug(1,Form("Init: Major version %d Minor version %d",fMajorVersion,
243                  fMinorVersion));
244     //
245     UpdateInternalGeometry();
246     AliITS::Init();
247     if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
248
249     //
250 }
251 /*
252 //______________________________________________________________________
253 void AliITSvBeamTestITS04::InitAliITSgeom()
254 {    
255   //initialisation of ITSgeom
256     const Int_t knlayers = 6;
257     Int_t nlad[knlayers], ndet[knlayers];
258     
259     nlad[0] = 1; ndet[0] = 2;
260     nlad[1] = 1; ndet[1] = 2;
261     nlad[2] = 1; ndet[2] = 1;
262     nlad[3] = 1; ndet[3] = 1;
263     nlad[4] = 1; ndet[4] = 2;
264     nlad[5] = 1; ndet[5] = 2;
265
266     Int_t nModTot = fNspd + fNsdd + fNssd;
267     if (GetITSgeom()) SetITSgeom(0x0);
268     AliITSgeom* geom = new AliITSgeom(0,knlayers,nlad,ndet,nModTot);
269     SetITSgeom(geom);
270     // *** Set default shapes 
271     const Float_t kDxyzSPD[] = {fgkSPDwidthSens/2, fgkSPDthickSens/2,fgkSPDlengthSens/2};  
272     if(!(GetITSgeom()->IsShapeDefined(kSPD)))
273         GetITSgeom()->ReSetShape(kSPD,new AliITSgeomSPD425Short(3,(Float_t *)kDxyzSPD));
274     
275     const Float_t kDxyzSDD[] = {fgkSDDwidthSens/2., fgkSDDthickSens/2.,fgkSDDlengthSens/2.};
276     if(!(GetITSgeom()->IsShapeDefined(kSDD)))
277         GetITSgeom()->ReSetShape(kSDD, new AliITSgeomSDD256(3,(Float_t *)kDxyzSDD));
278     
279     const Float_t kDxyzSSD[] = {fgkSSDlengthSens/2, fgkSSDthickSens/2,fgkSSDwidthSens/2};
280     if(!(GetITSgeom()->IsShapeDefined(kSSD)))
281         GetITSgeom()->ReSetShape(kSSD,new AliITSgeomSSD75and275(3,(Float_t *)kDxyzSSD));
282     
283     // Creating the matrices in AliITSgeom for each sensitive volume
284     // (like in AliITSv11GeometrySDD) mln
285     // Here, each layer is one detector
286     
287     char layerName[30];
288     Int_t startMod = 0;
289     
290     // SPD
291     for (Int_t i=0; i<fNspd;i++) {
292         sprintf(layerName, "ITSspdWafer_%i",i+1);
293         TGeoNode *layNode = fITSmotherVolume->GetNode(layerName);
294         if (layNode) {
295             TGeoHMatrix layMatrix(*layNode->GetMatrix());           
296             Double_t *trans  = layMatrix.GetTranslation();
297             Double_t *r      = layMatrix.GetRotationMatrix();
298             Double_t rot[10] = {r[0],r[1],r[2],
299                                 r[3],r[4],r[5],
300                                 r[6],r[7],r[8], 1.0};
301             Int_t iDet = 1;
302             if ((i+1==2)||(i+1==4)) iDet = 2;
303             Int_t iLad = 1;
304             Int_t iLay = 1;
305             if (i+1>2) iLay = 2;
306             GetITSgeom()->CreateMatrix(startMod,iLay,iLad,iDet,kSPD,trans,rot);
307             startMod++;
308         };
309     };
310     
311     // SDD
312     for (Int_t i=0; i<fNsdd;i++) {
313         sprintf(layerName, "ITSsddWafer_%i",i+fNspd+1);
314         TGeoNode *layNode = fITSmotherVolume->GetNode(layerName);
315         if (layNode) {
316             TGeoHMatrix layMatrix(*layNode->GetMatrix());
317             Double_t *trans  = layMatrix.GetTranslation();
318             Double_t *r      = layMatrix.GetRotationMatrix();
319             Double_t rot[10] = {r[0],r[1],r[2],
320                                 r[3],r[4],r[5],
321                                 r[6],r[7],r[8], 1.0};
322             Int_t iDet = 1;
323             Int_t iLad = 1;
324             Int_t iLay = fNspd-1+i;
325             GetITSgeom()->CreateMatrix(startMod,iLay,iLad,iDet,kSDD,trans,rot);
326             startMod++;
327         };
328     };
329     
330     // SSD
331     for (Int_t i=0; i<fNssd;i++) {
332         sprintf(layerName, "ITSssdWafer_%i",i+fNspd+fNsdd+1);
333         TGeoNode *layNode = fITSmotherVolume->GetNode(layerName);
334         if (layNode) {
335             TGeoHMatrix layMatrix(*layNode->GetMatrix());           
336             Double_t *trans  = layMatrix.GetTranslation();
337             Double_t *r      = layMatrix.GetRotationMatrix();
338             Double_t rot[10] = {r[0],r[1],r[2],
339                                 r[3],r[4],r[5],
340                                 r[6],r[7],r[8], 1.0};
341             Int_t iDet = 1;
342             if ((i+1==2)||(i+1==4)) iDet = 2;
343             Int_t iLad = 1;
344             Int_t iLay = 5;
345             if (i+1>2) iLay = 6;
346             GetITSgeom()->CreateMatrix(startMod,iLay,iLad,iDet,kSSD,trans,rot);
347             startMod++;
348         };
349     };
350     
351     return;
352 }
353 //______________________________________________________________________
354 void AliITSvBeamTestITS04::SetDefaults()
355 {
356     // (from AliITSv11) mln
357     
358     const Float_t kconv = 1.0e+04; // convert cm to microns
359     
360     if(!fDetTypeSim) fDetTypeSim = new AliITSDetTypeSim();
361     fDetTypeSim->SetITSgeom(GetITSgeom());
362     fDetTypeSim->ResetCalibrationArray();
363     fDetTypeSim->ResetSegmentation();
364  
365     AliITSgeomSPD *s0;
366     AliITSgeomSDD *s1;
367     AliITSgeomSSD *s2;
368     Int_t i;
369     Float_t bx[256],bz[280];
370
371     // If fGeomDetIn is set true the geometry will
372     // be initialised from file (JC)
373     if(GetITSgeom()!=0) SetITSgeom(0x0);
374     AliITSgeom* geom = new AliITSgeom();
375     SetITSgeom(geom);
376     if(fGeomDetIn) GetITSgeom()->ReadNewFile(fRead);
377     if(!fGeomDetIn) this->InitAliITSgeom();
378     if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
379
380    
381     // SPD
382
383     s0 = (AliITSgeomSPD*) GetITSgeom()->GetShape(kSPD);// Get shape info.
384     if (s0) {
385         AliITSCalibration *resp0=new AliITSCalibrationSPD();
386         SetCalibrationModel(kSPD,resp0);
387
388         AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD();
389         seg0->SetDetSize(s0->GetDx()*2.*kconv, // base this on AliITSgeomSPD
390                          s0->GetDz()*2.*kconv, // for now.
391                          s0->GetDy()*2.*kconv);// x,z,y full width in microns.
392         seg0->SetNPads(256,160);               // Number of Bins in x and z
393         for(i=000;i<256;i++) bx[i] =  50.0;    // in x all are 50 microns.
394         for(i=000;i<160;i++) bz[i] = 425.0;    // most are 425 microns except below
395         for(i=160;i<280;i++) bz[i] =   0.0;    // Outside of detector.
396         bz[ 31] = bz[ 32] = 625.0;             // first chip boundry
397         bz[ 63] = bz[ 64] = 625.0;             // first chip boundry
398         bz[ 95] = bz[ 96] = 625.0;             // first chip boundry
399         bz[127] = bz[128] = 625.0;             // first chip boundry
400         bz[160] = 425.0;                       // Set so that there is no zero pixel size for fNz.
401         seg0->SetBinSize(bx,bz);               // Based on AliITSgeomSPD for now.
402         SetSegmentationModel(kSPD,seg0);
403         // set digit and raw cluster classes to be used
404         const char *kData0=(fDetTypeSim->GetCalibrationModel(kSPD))->DataType();
405         if (strstr(kData0,"real")) 
406           fDetTypeSim->SetDigitClassName(kSPD,"AliITSdigit");
407         else fDetTypeSim->SetDigitClassName(kSPD,"AliITSdigitSPD");
408     }
409   
410     // SDD
411    
412     s1 = (AliITSgeomSDD*) GetITSgeom()->GetShape(kSDD);// Get shape info.
413     if (s1) {
414       AliITSCalibrationSDD *resp1=new AliITSCalibrationSDD("simulated");
415       SetCalibrationModel(kSDD,resp1);
416       AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD();
417       seg1->SetDetSize(s1->GetDx()*kconv, // base this on AliITSgeomSDD
418                        s1->GetDz()*4.*kconv, // for now.
419                        s1->GetDy()*4.*kconv); // x,z,y full width in microns.
420       seg1->SetDriftSpeed(AliITSresponseSDD::DefaultDriftSpeed());
421       seg1->SetNPads(256,256);// Use AliITSgeomSDD for now
422       SetSegmentationModel(kSDD,seg1);
423       const char *kData1=(fDetTypeSim->GetCalibrationModel(kSDD))->DataType();
424       const char *kopt=resp1->GetZeroSuppOption();
425       if((!strstr(kopt,"2D")) && (!strstr(kopt,"1D")) || strstr(kData1,"real") ){
426         fDetTypeSim->SetDigitClassName(kSDD,"AliITSdigit");
427         } else fDetTypeSim->SetDigitClassName(kSDD,"AliITSdigitSDD");
428     }
429     
430     // SSD
431     
432     s2 = (AliITSgeomSSD*) GetITSgeom()->GetShape(kSSD);// Get shape info. Do it this way for now.
433     if (s2) {
434       AliITSCalibration *resp2=new AliITSCalibrationSSD("simulated");
435       SetCalibrationModel(kSSD,resp2);
436
437       AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD();
438       seg2->SetDetSize(s2->GetDx()*2.*kconv, // base this on AliITSgeomSSD
439                        s2->GetDz()*2.*kconv, // for now.
440                        s2->GetDy()*2.*kconv); // x,z,y full width in microns.
441       seg2->SetPadSize(95.,0.); // strip x pitch in microns
442       seg2->SetNPads(768,0); // number of strips on each side.
443       seg2->SetAngles(0.0075,0.0275); // strip angels rad P and N side.
444       seg2->SetAnglesLay5(0.0075,0.0275); // strip angels rad P and N side.
445       seg2->SetAnglesLay6(0.0275,0.0075); // strip angels rad P and N side.
446       SetSegmentationModel(kSSD,seg2); 
447       const char *kData2=(fDetTypeSim->GetCalibrationModel(kSSD))->DataType();
448       if(strstr(kData2,"real") ) fDetTypeSim->SetDigitClassName(kSSD,"AliITSdigit");
449       else fDetTypeSim->SetDigitClassName(kSSD,"AliITSdigitSSD");
450     }
451     
452   if(fgkNTYPES>3){Warning("SetDefaults","Only the four basic detector types are initialised!");}
453   return;
454 }
455 */
456 //______________________________________________________________________
457 void AliITSvBeamTestITS04::AddSPDGeometry(TGeoVolume *moth) const
458 {
459   //Adds SPD geometry
460     TGeoMedium *siliconSPD = gGeoManager->GetMedium("ITSspdSi");
461     
462     //outer volume
463     TGeoBBox *waferSPDshape = new TGeoBBox("ITSspdWaferShape",fgkSPDwidth/2,fgkSPDthickness/2,fgkSPDlength/2,0);
464     TGeoVolume *waferSPD = new TGeoVolume("ITSspdWafer",waferSPDshape,siliconSPD);
465     //sensitive volume
466     TGeoBBox *sensSPDbox = new TGeoBBox("ITSsddSensorSensBox",fgkSPDwidthSens/2,fgkSPDthickSens/2,fgkSPDlengthSens/2,0);
467     TGeoVolume *sensVolSPD = new TGeoVolume(fgSPDsensitiveVolName,sensSPDbox,siliconSPD);
468     waferSPD->AddNode(sensVolSPD, 1, 0); //added to outer volume
469     
470     //locate them in space (with respect top volume)
471     TGeoTranslation *spd1tr = new TGeoTranslation(0,fgkSPD0y,fgkSPDlength/2);
472     TGeoTranslation *spd2tr = new TGeoTranslation(0,fgkSPD0y,-fgkSPDlength/2);
473
474     TGeoTranslation *spd3tr = new TGeoTranslation(0,fgkSPD1y,fgkSPDlength/2);
475     TGeoTranslation *spd4tr = new TGeoTranslation(0,fgkSPD1y,-fgkSPDlength/2);
476     
477     //add to top volume
478     moth->AddNode(waferSPD, 1, spd1tr);
479     moth->AddNode(waferSPD, 2, spd2tr);
480     moth->AddNode(waferSPD, 3, spd3tr);
481     moth->AddNode(waferSPD, 4, spd4tr);
482     
483     //draw options
484     waferSPD->SetLineColor(4);
485     sensVolSPD->SetLineColor(4);
486 }
487
488
489 //______________________________________________________________________
490 void AliITSvBeamTestITS04::AddSDDGeometry(TGeoVolume *moth) const
491 {
492   //Adds SDD geometry
493     TGeoMedium *siliconSDD = gGeoManager->GetMedium("ITSsddSi");
494     
495     //outer volume
496     TGeoBBox *waferSDDshape = new TGeoBBox("ITSsddWaferShape",fgkSDDwidth/2,fgkSDDthickness/2,fgkSDDlength/2,0);
497     TGeoVolume *waferSDD = new TGeoVolume("ITSsddWafer",waferSDDshape,siliconSDD);
498     //sensitive volume
499     TGeoBBox *sensSDDbox = new TGeoBBox("ITSsddSensorSensBox",fgkSDDwidthSens/2,fgkSDDthickSens/2,fgkSDDlengthSens/2,0);
500     TGeoVolume *sensVolSDD = new TGeoVolume(fgSDDsensitiveVolName,sensSDDbox,siliconSDD);
501     waferSDD->AddNode(sensVolSDD, 1, 0); //added to outer volume
502     
503     //locate them in space
504     TGeoTranslation *sdd1tr = new TGeoTranslation(0,fgkSDD0y,0);
505     TGeoTranslation *sdd2tr = new TGeoTranslation(0,fgkSDD1y,0);
506         
507     //add to top volume
508     moth->AddNode(waferSDD, fNspd+1, sdd1tr);
509     moth->AddNode(waferSDD, fNspd+2, sdd2tr);
510     
511     //draw options
512     waferSDD->SetLineColor(3);
513     sensVolSDD->SetLineColor(3);
514 }
515
516
517 //______________________________________________________________________
518 void AliITSvBeamTestITS04::AddSSDGeometry(TGeoVolume *moth) const
519 {
520   //Adds SSD geometry
521     TGeoMedium *siliconSSD = gGeoManager->GetMedium("ITSspdSi"); // SSD medium still needed!!!
522     
523     //outer volume 
524     TGeoBBox *waferSSDshape = new TGeoBBox("ITSssdWaferShape",fgkSSDwidth/2,fgkSSDthickness/2,fgkSSDlength/2,0);
525     TGeoVolume *waferSSD = new TGeoVolume("ITSssdWafer",waferSSDshape,siliconSSD);
526     //sensitive volume
527     TGeoBBox *sensSSDbox = new TGeoBBox("ITSssdSensorSensBox",fgkSSDwidthSens/2,fgkSSDthickSens/2,fgkSSDlengthSens/2,0);
528     TGeoVolume *sensVolSSD = new TGeoVolume(fgSSDsensitiveVolName,sensSSDbox,siliconSSD);
529     waferSSD->AddNode(sensVolSSD, 1, 0);
530     
531     //locate them in space
532     /* In the SSD, there was an overlap of sensitive volumes of 2.9mm = 0.29cm (0.29/2=0.145) 
533        in the modules in the same plane, therefore the modules where not in the same plane in 
534        the Y direction, there was a "thickness" (0.03cm) difference */
535     TGeoTranslation *ssd1tr = new TGeoTranslation(0,fgkSSD0y,fgkSSDlength/2-0.145);
536     TGeoTranslation *ssd2tr = new TGeoTranslation(0,fgkSSD0y+0.03,-fgkSSDlength/2+0.145);
537
538     TGeoTranslation *ssd3tr = new TGeoTranslation(0,fgkSSD1y,fgkSSDlength/2-0.145);
539     TGeoTranslation *ssd4tr = new TGeoTranslation(0,fgkSSD1y+0.03,-fgkSSDlength/2+0.145);
540
541     //add to top volume
542     moth->AddNode(waferSSD, fNspd+fNsdd+1, ssd1tr);
543     moth->AddNode(waferSSD, fNspd+fNsdd+2, ssd2tr);
544     moth->AddNode(waferSSD, fNspd+fNsdd+3, ssd3tr);
545     moth->AddNode(waferSSD, fNspd+fNsdd+4, ssd4tr);
546     
547     //draw options
548     waferSSD->SetLineColor(2);
549     sensVolSSD->SetLineColor(2);
550 }
551
552 //______________________________________________________________________
553 void AliITSvBeamTestITS04::StepManager()
554 {
555     // Called for every step in the ITS, then calles the AliITShit class
556     // creator with the information to be recoreded about that hit.
557
558     // "Standard" StepManager. (Similar to AliITSv11) mln
559     Int_t cpy0,mod,status,id,kk;
560     TLorentzVector position, momentum;
561     static AliITShit hit;// Saves on calls to construtors
562     
563     if(!(this->IsActive())) return;
564     if(!(gMC->TrackCharge())) return;
565     //TClonesArray &lhits = *(GetDetTypeSim()->GetHits());
566     TClonesArray &lhits = *(Hits());
567     //
568     // Track status
569     // Track status
570     status = 0;
571     if(gMC->IsTrackInside())      status +=  1;
572     if(gMC->IsTrackEntering())    status +=  2;
573     if(gMC->IsTrackExiting())     status +=  4;
574     if(gMC->IsTrackOut())         status +=  8;
575     if(gMC->IsTrackDisappeared()) status += 16;
576     if(gMC->IsTrackStop())        status += 32;
577     if(gMC->IsTrackAlive())       status += 64;
578     
579     id=gMC->CurrentVolID(cpy0);
580     
581     Bool_t sensvol = kFALSE;
582     for(kk=0;kk<fIdN;kk++) if(id == fIdSens[kk]) sensvol = kTRUE;
583     if(!sensvol) return;
584
585     fIgm.DecodeDetector(mod,gGeoManager->GetMother(1)->GetNumber(),1,1,1);
586     //
587     // Fill hit structure.
588     //
589     hit.SetModule(mod);
590     hit.SetTrack(gAlice->GetMCApp()->GetCurrentTrackNumber());
591     gMC->TrackPosition(position);
592     gMC->TrackMomentum(momentum);
593     hit.SetPosition(position);
594     hit.SetTime(gMC->TrackTime());
595     hit.SetMomentum(momentum);
596     hit.SetStatus(status);
597     hit.SetEdep(gMC->Edep());
598     hit.SetShunt(GetIshunt());
599     if(gMC->IsTrackEntering()){
600         hit.SetStartPosition(position);
601         hit.SetStartTime(gMC->TrackTime());
602         hit.SetStartStatus(status);
603         return; // don't save entering hit.
604     } // end if IsEntering
605     // Fill hit structure with this new hit.
606     //Info("StepManager","Calling Copy Constructor");
607     new(lhits[fNhits++]) AliITShit(hit); // Use Copy Construtor.
608     // Save old position... for next hit.
609     hit.SetStartPosition(position);
610     hit.SetStartTime(gMC->TrackTime());
611     hit.SetStartStatus(status);
612     return;
613 }
614 /*
615 //______________________________________________________________________
616 Int_t AliITSvBeamTestITS04::GetCurrentLayLaddDet(Int_t &lay,Int_t &ladd, Int_t &det) const
617
618   // Function which gives the layer, ladder and det.
619   // index of the current volume. To be used in
620   // AliITS::StepManager()
621
622     det  = 1;   ladd = 1;
623     
624     TGeoNode *node = gGeoManager->GetMother(1);
625     if (!node) return kFALSE;
626     Int_t nodeNum = node->GetNumber();
627     
628     // GetNumber() return the index recorded in the node
629     
630     if (nodeNum==5||nodeNum==6) {         // SDD: one layer, one detector
631         lay = nodeNum-2;
632     } else if (nodeNum==3||nodeNum==4) {  // SPD layer 2
633         lay = 2;
634         if (nodeNum==4) det = 2;
635     } else if (nodeNum==1||nodeNum==2){   // SPD layer 1
636         lay = 1;
637         if (nodeNum==2) det = 2; 
638     } else if (nodeNum==9||nodeNum==10) { // SSD layer 2
639         lay = 6;
640         if (nodeNum==10) det = 2;
641     } else if (nodeNum==7||nodeNum==8){   // SSD layer 1
642         lay = 5;
643         if (nodeNum==8) det = 2; 
644     };  
645     
646     return kTRUE;
647 }
648 */
649 //_____________________________________________________________
650
651  Int_t AliITSvBeamTestITS04::GetNumberOfSubDet(const TString& det) const{
652     
653    //Get number of individual detectors
654     if(det.Contains("SPD")) return fNspd;
655     if(det.Contains("SDD")) return fNsdd;
656     if(det.Contains("SSD")) return fNssd;
657     return 0;
658   }