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