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