Changes in SSD segmentation and simulation classes in order to take into account...
[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
7#include <TLorentzVector.h>
8
9#include <TGeoManager.h>
10#include <TGeoVolume.h>
268f57b1 11#include <TGeoMatrix.h>
0237c22c 12#include <TGeoPcon.h>
5ba31760 13#include "AliRun.h"
14#include "AliITSvBeamTestITS04.h"
5ba31760 15#include <TClonesArray.h>
16#include <TString.h>
5ba31760 17#include "AliITS.h"
5ba31760 18#include "AliMagF.h"
19#include "TVirtualMC.h"
20#include "AliMC.h"
0237c22c 21#include "AliTrackReference.h"
22#include "AliITSgeom.h"
23#include "AliITShit.h"
5ba31760 24
25const Int_t AliITSvBeamTestITS04::fgkNumberOfSPD = 4;
26const Int_t AliITSvBeamTestITS04::fgkNumberOfSDD = 2;
27const Int_t AliITSvBeamTestITS04::fgkNumberOfSSD = 4;
5ba31760 28// Dimension (thickness:Y (beam direction), width:X, length:Z)
29
30const char* AliITSvBeamTestITS04::fgSPDsensitiveVolName = "ITSspdSensitiv";
31//dimensions (preliminary values from Petra (in cms))
32const Double_t AliITSvBeamTestITS04::fgkSPDthickness = 0.02;
33const Double_t AliITSvBeamTestITS04::fgkSPDwidth = 1.4;
34const Double_t AliITSvBeamTestITS04::fgkSPDlength = 7.2;
35const Double_t AliITSvBeamTestITS04::fgkSPDthickSens = 0.02;
36const Double_t AliITSvBeamTestITS04::fgkSPDwidthSens = 1.2;
37const Double_t AliITSvBeamTestITS04::fgkSPDlengthSens = 7.0;
38//position
39const Double_t AliITSvBeamTestITS04::fgkSPD0y = 23.7;
40const Double_t AliITSvBeamTestITS04::fgkSPD1y = 33.7;
41
42//===
43const char* AliITSvBeamTestITS04::fgSDDsensitiveVolName = "ITSsddSensitiv";
44//dimensions (preliminary values from Ludovic (in cms))
45const Double_t AliITSvBeamTestITS04::fgkSDDthickness = 0.03;
46const Double_t AliITSvBeamTestITS04::fgkSDDwidth = 7.22;
47const Double_t AliITSvBeamTestITS04::fgkSDDlength = 8.76;
48const Double_t AliITSvBeamTestITS04::fgkSDDthickSens = 0.02998;
49const Double_t AliITSvBeamTestITS04::fgkSDDwidthSens = 7.017;
50const Double_t AliITSvBeamTestITS04::fgkSDDlengthSens = 7.497;
51//position
52const Double_t AliITSvBeamTestITS04::fgkSDD0y = 51.7;
53const Double_t AliITSvBeamTestITS04::fgkSDD1y = 57.2;
54
55//===
56const char* AliITSvBeamTestITS04::fgSSDsensitiveVolName = "ITSssdSensitiv";
57//dimensions (final values from Javier (in cms))
58const Double_t AliITSvBeamTestITS04::fgkSSDthickness = 0.03;
59const Double_t AliITSvBeamTestITS04::fgkSSDwidth = 7.7;
60const Double_t AliITSvBeamTestITS04::fgkSSDlength = 4.4;
61const Double_t AliITSvBeamTestITS04::fgkSSDthickSens = 0.03;
62const Double_t AliITSvBeamTestITS04::fgkSSDwidthSens = 7.5;
63const Double_t AliITSvBeamTestITS04::fgkSSDlengthSens = 4.2;
64//position
65const Double_t AliITSvBeamTestITS04::fgkSSD0y = 73.6;
66const Double_t AliITSvBeamTestITS04::fgkSSD1y = 80.6;
67
68//===============================================================
69
5ba31760 70
5ba31760 71
72ClassImp(AliITSvBeamTestITS04)
73
74//_____________________________________________________________
012f0f4c 75 AliITSvBeamTestITS04::AliITSvBeamTestITS04() :
76AliITS(), // Base class
77fITSmotherVolume(0), // Pointer to ITS mother volume.
78fNspd(fgkNumberOfSPD), //Number of SPD modules
79fNsdd(fgkNumberOfSDD), //Number of SDD modules
80fNssd(fgkNumberOfSSD), //Number of SSD modules
81fGeomDetOut(kFALSE), // Flag to write .det file out
82fGeomDetIn(kFALSE), // Flag to read geometry file (JC)
83fWrite(), //! file name to write .det file
84fRead(), // file name to read .det file (JC)
85fMajorVersion(kvITS04),// Major Version
86fMinorVersion(1), // Minor Version
87fIgm(kvITS04) //! Init geometry object
88{
5ba31760 89 //
90 // Constructor
91 //
012f0f4c 92
5ba31760 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
5ba31760 101 for(Int_t a=0;a<60;a++) fWrite[a] = '\0';
102}
5ba31760 103//_____________________________________________________________
012f0f4c 104AliITSvBeamTestITS04::AliITSvBeamTestITS04(const char* name,const char *title):
105AliITS(name,title), // Base class
106fITSmotherVolume(0), // Pointer to ITS mother volume.
107fNspd(fgkNumberOfSPD), //Number of SPD modules
108fNsdd(fgkNumberOfSDD), //Number of SDD modules
109fNssd(fgkNumberOfSSD), //Number of SSD modules
110fGeomDetOut(kFALSE), // Flag to write .det file out
111fGeomDetIn(kFALSE), // Flag to read geometry file (JC)
112fWrite(), //! file name to write .det file
113fRead(), // file name to read .det file (JC)
114fMajorVersion(kvITS04),// Major Version
115fMinorVersion(1), // Minor Version
116fIgm(kvITS04) //! Init geometry object
5ba31760 117{
118 //
119 // Constructor
120 //
012f0f4c 121
5ba31760 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;
5ba31760 129 for(Int_t a=0;a<60;a++) fWrite[a] = '\0';
130}
5ba31760 131//__________________________________________________________________
012f0f4c 132AliITSvBeamTestITS04::~AliITSvBeamTestITS04(){
5ba31760 133 //
134 // Destructor
135 //
136}
5ba31760 137//______________________________________________________________________
012f0f4c 138void AliITSvBeamTestITS04::CreateMaterials(){
5ba31760 139 // Media defined here should correspond to the one defined in galice.cuts
140 // This file is read in (AliMC*) fMCApp::Init() { ReadTransPar(); }
5ba31760 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//______________________________________________________________________
012f0f4c 180void 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$";
5ba31760 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
012f0f4c 197 TGeoMedium *air = geoManager->GetMedium("ITSair");
198 fITSmotherVolume = new TGeoVolume("ITSV",sITS,air);
0237c22c 199 const Int_t kLength=100;
200 Char_t vstrng[kLength];
201 if(fIgm.WriteVersionString(vstrng,kLength,(AliITSVersion_t)IsVersion(),
012f0f4c 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
5ba31760 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//______________________________________________________________________
232void AliITSvBeamTestITS04::Init()
233{
234 // Initialize the ITS after it has been created.
012f0f4c 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();
5ba31760 246 AliITS::Init();
012f0f4c 247 if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
5ba31760 248
012f0f4c 249 //
5ba31760 250}
012f0f4c 251/*
5ba31760 252//______________________________________________________________________
253void 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;
7d62fb64 267 if (GetITSgeom()) SetITSgeom(0x0);
268 AliITSgeom* geom = new AliITSgeom(0,knlayers,nlad,ndet,nModTot);
269 SetITSgeom(geom);
012f0f4c 270 // *** Set default shapes
5ba31760 271 const Float_t kDxyzSPD[] = {fgkSPDwidthSens/2, fgkSPDthickSens/2,fgkSPDlengthSens/2};
7d62fb64 272 if(!(GetITSgeom()->IsShapeDefined(kSPD)))
273 GetITSgeom()->ReSetShape(kSPD,new AliITSgeomSPD425Short(3,(Float_t *)kDxyzSPD));
5ba31760 274
275 const Float_t kDxyzSDD[] = {fgkSDDwidthSens/2., fgkSDDthickSens/2.,fgkSDDlengthSens/2.};
7d62fb64 276 if(!(GetITSgeom()->IsShapeDefined(kSDD)))
277 GetITSgeom()->ReSetShape(kSDD, new AliITSgeomSDD256(3,(Float_t *)kDxyzSDD));
5ba31760 278
279 const Float_t kDxyzSSD[] = {fgkSSDlengthSens/2, fgkSSDthickSens/2,fgkSSDwidthSens/2};
7d62fb64 280 if(!(GetITSgeom()->IsShapeDefined(kSSD)))
281 GetITSgeom()->ReSetShape(kSSD,new AliITSgeomSSD75and275(3,(Float_t *)kDxyzSSD));
5ba31760 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;
023ae34b 306 GetITSgeom()->CreateMatrix(startMod,iLay,iLad,iDet,kSPD,trans,rot);
5ba31760 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;
023ae34b 325 GetITSgeom()->CreateMatrix(startMod,iLay,iLad,iDet,kSDD,trans,rot);
5ba31760 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;
023ae34b 346 GetITSgeom()->CreateMatrix(startMod,iLay,iLad,iDet,kSSD,trans,rot);
5ba31760 347 startMod++;
348 };
349 };
350
351 return;
352}
5ba31760 353//______________________________________________________________________
354void AliITSvBeamTestITS04::SetDefaults()
355{
356 // (from AliITSv11) mln
357
358 const Float_t kconv = 1.0e+04; // convert cm to microns
359
7d62fb64 360 if(!fDetTypeSim) fDetTypeSim = new AliITSDetTypeSim();
361 fDetTypeSim->SetITSgeom(GetITSgeom());
fcf95fc7 362 fDetTypeSim->ResetCalibrationArray();
7d62fb64 363 fDetTypeSim->ResetSegmentation();
364
5ba31760 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)
7d62fb64 373 if(GetITSgeom()!=0) SetITSgeom(0x0);
374 AliITSgeom* geom = new AliITSgeom();
375 SetITSgeom(geom);
376 if(fGeomDetIn) GetITSgeom()->ReadNewFile(fRead);
5ba31760 377 if(!fGeomDetIn) this->InitAliITSgeom();
7d62fb64 378 if(fGeomDetOut) GetITSgeom()->WriteNewFile(fWrite);
5ba31760 379
380
381 // SPD
7d62fb64 382
383 s0 = (AliITSgeomSPD*) GetITSgeom()->GetShape(kSPD);// Get shape info.
5ba31760 384 if (s0) {
fcf95fc7 385 AliITSCalibration *resp0=new AliITSCalibrationSPD();
386 SetCalibrationModel(kSPD,resp0);
7d62fb64 387
023ae34b 388 AliITSsegmentationSPD *seg0=new AliITSsegmentationSPD();
5ba31760 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);
7d62fb64 403 }
5ba31760 404
405 // SDD
7d62fb64 406
407 s1 = (AliITSgeomSDD*) GetITSgeom()->GetShape(kSDD);// Get shape info.
5ba31760 408 if (s1) {
fcf95fc7 409 AliITSCalibrationSDD *resp1=new AliITSCalibrationSDD("simulated");
410 SetCalibrationModel(kSDD,resp1);
023ae34b 411 AliITSsegmentationSDD *seg1=new AliITSsegmentationSDD();
3a7c3e6d 412 seg1->SetDetSize(s1->GetDx()*kconv, // base this on AliITSgeomSDD
413 s1->GetDz()*4.*kconv, // for now.
414 s1->GetDy()*4.*kconv); // x,z,y full width in microns.
4952f440 415 seg1->SetDriftSpeed(AliITSresponseSDD::DefaultDriftSpeed());
3a7c3e6d 416 seg1->SetNPads(256,256);// Use AliITSgeomSDD for now
417 SetSegmentationModel(kSDD,seg1);
7d62fb64 418 }
5ba31760 419
420 // SSD
7d62fb64 421
422 s2 = (AliITSgeomSSD*) GetITSgeom()->GetShape(kSSD);// Get shape info. Do it this way for now.
5ba31760 423 if (s2) {
fcf95fc7 424 AliITSCalibration *resp2=new AliITSCalibrationSSD("simulated");
425 SetCalibrationModel(kSSD,resp2);
7d62fb64 426
023ae34b 427 AliITSsegmentationSSD *seg2=new AliITSsegmentationSSD();
7d62fb64 428 seg2->SetDetSize(s2->GetDx()*2.*kconv, // base this on AliITSgeomSSD
429 s2->GetDz()*2.*kconv, // for now.
430 s2->GetDy()*2.*kconv); // x,z,y full width in microns.
431 seg2->SetPadSize(95.,0.); // strip x pitch in microns
432 seg2->SetNPads(768,0); // number of strips on each side.
433 seg2->SetAngles(0.0075,0.0275); // strip angels rad P and N side.
7d62fb64 434 SetSegmentationModel(kSSD,seg2);
7d62fb64 435 }
436
437 if(fgkNTYPES>3){Warning("SetDefaults","Only the four basic detector types are initialised!");}
5ba31760 438 return;
e93245aa 439}
012f0f4c 440*/
5ba31760 441//______________________________________________________________________
442void AliITSvBeamTestITS04::AddSPDGeometry(TGeoVolume *moth) const
443{
444 //Adds SPD geometry
445 TGeoMedium *siliconSPD = gGeoManager->GetMedium("ITSspdSi");
446
447 //outer volume
448 TGeoBBox *waferSPDshape = new TGeoBBox("ITSspdWaferShape",fgkSPDwidth/2,fgkSPDthickness/2,fgkSPDlength/2,0);
449 TGeoVolume *waferSPD = new TGeoVolume("ITSspdWafer",waferSPDshape,siliconSPD);
450 //sensitive volume
451 TGeoBBox *sensSPDbox = new TGeoBBox("ITSsddSensorSensBox",fgkSPDwidthSens/2,fgkSPDthickSens/2,fgkSPDlengthSens/2,0);
452 TGeoVolume *sensVolSPD = new TGeoVolume(fgSPDsensitiveVolName,sensSPDbox,siliconSPD);
453 waferSPD->AddNode(sensVolSPD, 1, 0); //added to outer volume
454
455 //locate them in space (with respect top volume)
456 TGeoTranslation *spd1tr = new TGeoTranslation(0,fgkSPD0y,fgkSPDlength/2);
457 TGeoTranslation *spd2tr = new TGeoTranslation(0,fgkSPD0y,-fgkSPDlength/2);
458
459 TGeoTranslation *spd3tr = new TGeoTranslation(0,fgkSPD1y,fgkSPDlength/2);
460 TGeoTranslation *spd4tr = new TGeoTranslation(0,fgkSPD1y,-fgkSPDlength/2);
461
462 //add to top volume
463 moth->AddNode(waferSPD, 1, spd1tr);
464 moth->AddNode(waferSPD, 2, spd2tr);
465 moth->AddNode(waferSPD, 3, spd3tr);
466 moth->AddNode(waferSPD, 4, spd4tr);
467
468 //draw options
469 waferSPD->SetLineColor(4);
470 sensVolSPD->SetLineColor(4);
e93245aa 471}
5ba31760 472
473
474//______________________________________________________________________
475void AliITSvBeamTestITS04::AddSDDGeometry(TGeoVolume *moth) const
476{
477 //Adds SDD geometry
478 TGeoMedium *siliconSDD = gGeoManager->GetMedium("ITSsddSi");
479
480 //outer volume
481 TGeoBBox *waferSDDshape = new TGeoBBox("ITSsddWaferShape",fgkSDDwidth/2,fgkSDDthickness/2,fgkSDDlength/2,0);
482 TGeoVolume *waferSDD = new TGeoVolume("ITSsddWafer",waferSDDshape,siliconSDD);
483 //sensitive volume
484 TGeoBBox *sensSDDbox = new TGeoBBox("ITSsddSensorSensBox",fgkSDDwidthSens/2,fgkSDDthickSens/2,fgkSDDlengthSens/2,0);
485 TGeoVolume *sensVolSDD = new TGeoVolume(fgSDDsensitiveVolName,sensSDDbox,siliconSDD);
486 waferSDD->AddNode(sensVolSDD, 1, 0); //added to outer volume
487
488 //locate them in space
489 TGeoTranslation *sdd1tr = new TGeoTranslation(0,fgkSDD0y,0);
490 TGeoTranslation *sdd2tr = new TGeoTranslation(0,fgkSDD1y,0);
491
492 //add to top volume
493 moth->AddNode(waferSDD, fNspd+1, sdd1tr);
494 moth->AddNode(waferSDD, fNspd+2, sdd2tr);
495
496 //draw options
497 waferSDD->SetLineColor(3);
498 sensVolSDD->SetLineColor(3);
e93245aa 499}
5ba31760 500
501
502//______________________________________________________________________
503void AliITSvBeamTestITS04::AddSSDGeometry(TGeoVolume *moth) const
504{
505 //Adds SSD geometry
506 TGeoMedium *siliconSSD = gGeoManager->GetMedium("ITSspdSi"); // SSD medium still needed!!!
507
508 //outer volume
509 TGeoBBox *waferSSDshape = new TGeoBBox("ITSssdWaferShape",fgkSSDwidth/2,fgkSSDthickness/2,fgkSSDlength/2,0);
510 TGeoVolume *waferSSD = new TGeoVolume("ITSssdWafer",waferSSDshape,siliconSSD);
511 //sensitive volume
512 TGeoBBox *sensSSDbox = new TGeoBBox("ITSssdSensorSensBox",fgkSSDwidthSens/2,fgkSSDthickSens/2,fgkSSDlengthSens/2,0);
513 TGeoVolume *sensVolSSD = new TGeoVolume(fgSSDsensitiveVolName,sensSSDbox,siliconSSD);
514 waferSSD->AddNode(sensVolSSD, 1, 0);
515
516 //locate them in space
517 /* In the SSD, there was an overlap of sensitive volumes of 2.9mm = 0.29cm (0.29/2=0.145)
518 in the modules in the same plane, therefore the modules where not in the same plane in
519 the Y direction, there was a "thickness" (0.03cm) difference */
520 TGeoTranslation *ssd1tr = new TGeoTranslation(0,fgkSSD0y,fgkSSDlength/2-0.145);
521 TGeoTranslation *ssd2tr = new TGeoTranslation(0,fgkSSD0y+0.03,-fgkSSDlength/2+0.145);
522
523 TGeoTranslation *ssd3tr = new TGeoTranslation(0,fgkSSD1y,fgkSSDlength/2-0.145);
524 TGeoTranslation *ssd4tr = new TGeoTranslation(0,fgkSSD1y+0.03,-fgkSSDlength/2+0.145);
525
526 //add to top volume
527 moth->AddNode(waferSSD, fNspd+fNsdd+1, ssd1tr);
528 moth->AddNode(waferSSD, fNspd+fNsdd+2, ssd2tr);
529 moth->AddNode(waferSSD, fNspd+fNsdd+3, ssd3tr);
530 moth->AddNode(waferSSD, fNspd+fNsdd+4, ssd4tr);
531
532 //draw options
533 waferSSD->SetLineColor(2);
534 sensVolSSD->SetLineColor(2);
e93245aa 535}
5ba31760 536
537//______________________________________________________________________
538void AliITSvBeamTestITS04::StepManager()
539{
540 // Called for every step in the ITS, then calles the AliITShit class
541 // creator with the information to be recoreded about that hit.
542
543 // "Standard" StepManager. (Similar to AliITSv11) mln
012f0f4c 544 Int_t cpy0,mod,status,id,kk;
5ba31760 545 TLorentzVector position, momentum;
012f0f4c 546 static AliITShit hit;// Saves on calls to construtors
5ba31760 547
012f0f4c 548 if(!(this->IsActive())) return;
5ba31760 549 if(!(gMC->TrackCharge())) return;
012f0f4c 550 //TClonesArray &lhits = *(GetDetTypeSim()->GetHits());
551 TClonesArray &lhits = *(Hits());
552 //
553 // Track status
554 // Track status
555 status = 0;
556 if(gMC->IsTrackInside()) status += 1;
557 if(gMC->IsTrackEntering()) status += 2;
558 if(gMC->IsTrackExiting()) status += 4;
559 if(gMC->IsTrackOut()) status += 8;
560 if(gMC->IsTrackDisappeared()) status += 16;
561 if(gMC->IsTrackStop()) status += 32;
562 if(gMC->IsTrackAlive()) status += 64;
5ba31760 563
012f0f4c 564 id=gMC->CurrentVolID(cpy0);
5ba31760 565
566 Bool_t sensvol = kFALSE;
012f0f4c 567 for(kk=0;kk<fIdN;kk++) if(id == fIdSens[kk]) sensvol = kTRUE;
568 if(!sensvol) return;
569
570 fIgm.DecodeDetector(mod,gGeoManager->GetMother(1)->GetNumber(),1,1,1);
5ba31760 571 //
5ba31760 572 // Fill hit structure.
012f0f4c 573 //
574 hit.SetModule(mod);
575 hit.SetTrack(gAlice->GetMCApp()->GetCurrentTrackNumber());
5ba31760 576 gMC->TrackPosition(position);
577 gMC->TrackMomentum(momentum);
012f0f4c 578 hit.SetPosition(position);
579 hit.SetTime(gMC->TrackTime());
580 hit.SetMomentum(momentum);
581 hit.SetStatus(status);
582 hit.SetEdep(gMC->Edep());
583 hit.SetShunt(GetIshunt());
5ba31760 584 if(gMC->IsTrackEntering()){
012f0f4c 585 hit.SetStartPosition(position);
586 hit.SetStartTime(gMC->TrackTime());
587 hit.SetStartStatus(status);
588 return; // don't save entering hit.
5ba31760 589 } // end if IsEntering
590 // Fill hit structure with this new hit.
012f0f4c 591 //Info("StepManager","Calling Copy Constructor");
592 new(lhits[fNhits++]) AliITShit(hit); // Use Copy Construtor.
593 // Save old position... for next hit.
594 hit.SetStartPosition(position);
595 hit.SetStartTime(gMC->TrackTime());
596 hit.SetStartStatus(status);
5ba31760 597 return;
e93245aa 598}
012f0f4c 599/*
5ba31760 600//______________________________________________________________________
601Int_t AliITSvBeamTestITS04::GetCurrentLayLaddDet(Int_t &lay,Int_t &ladd, Int_t &det) const
602{
603 // Function which gives the layer, ladder and det.
604 // index of the current volume. To be used in
605 // AliITS::StepManager()
606
607 det = 1; ladd = 1;
608
609 TGeoNode *node = gGeoManager->GetMother(1);
610 if (!node) return kFALSE;
611 Int_t nodeNum = node->GetNumber();
612
613 // GetNumber() return the index recorded in the node
614
615 if (nodeNum==5||nodeNum==6) { // SDD: one layer, one detector
616 lay = nodeNum-2;
617 } else if (nodeNum==3||nodeNum==4) { // SPD layer 2
618 lay = 2;
619 if (nodeNum==4) det = 2;
620 } else if (nodeNum==1||nodeNum==2){ // SPD layer 1
621 lay = 1;
622 if (nodeNum==2) det = 2;
623 } else if (nodeNum==9||nodeNum==10) { // SSD layer 2
624 lay = 6;
625 if (nodeNum==10) det = 2;
626 } else if (nodeNum==7||nodeNum==8){ // SSD layer 1
627 lay = 5;
628 if (nodeNum==8) det = 2;
629 };
630
631 return kTRUE;
e93245aa 632}
012f0f4c 633*/
5ba31760 634//_____________________________________________________________
635
636 Int_t AliITSvBeamTestITS04::GetNumberOfSubDet(const TString& det) const{
637
638 //Get number of individual detectors
639 if(det.Contains("SPD")) return fNspd;
640 if(det.Contains("SDD")) return fNsdd;
641 if(det.Contains("SSD")) return fNssd;
642 return 0;
643 }