Use gMC and not pMC everywhere
[u/mrichter/AliRoot.git] / ITS / AliITSv5.cxx
CommitLineData
fe4da5cc 1///////////////////////////////////////////////////////////////////////////////
2// //
3// Inner Traking System version 5 //
4// This class contains the base procedures for the Inner Tracking System //
5// //
6//Begin_Html
7/*
1439f98e 8<img src="picts/AliITSv5Class.gif">
fe4da5cc 9</pre>
10<br clear=left>
11<font size=+2 color=red>
12<p>The responsible person for this module is
13<a href="mailto:roberto.barbera@ct.infn.it">Roberto Barbera</a>.
14</font>
15<pre>
16*/
17//End_Html
18// //
19///////////////////////////////////////////////////////////////////////////////
20
21#include <stdio.h>
22
23#include <TMath.h>
24#include "AliITSv5.h"
25#include "AliRun.h"
26#include "stdlib.h"
27#include "TSystem.h"
28#include "TGeant3.h"
29
30ClassImp(AliITSv5)
31
32//_____________________________________________________________________________
33AliITSv5::AliITSv5() : AliITS()
34{
35 //
36 // Default constructor for the ITS
37 //
38}
39
40//_____________________________________________________________________________
41AliITSv5::AliITSv5(const char *name, const char *title)
42 : AliITS(name, title)
43{
44 //
45 // Standard constructor for the ITS
46 //
47 fEuclidMaterial="$(ALICE_ROOT)/ITSgeometry_60.tme";
48 fEuclidGeometry="$(ALICE_ROOT)/ITSgeometry_60.euc";
49}
50
51
52//_____________________________________________________________________________
53void AliITSv5::CreateMaterials()
54{
55 //
56 // Read materials for the ITS
57 //
58 FILE *file = fopen(fEuclidMaterial.Data(),"r");
59 if(file) {
60 fclose(file);
02ca2762 61 gAlice->ReadEuclidMedia(fEuclidMaterial.Data(),this);
fe4da5cc 62 } else {
63 Error("CreateMaterials"," THE MEDIA FILE %s DOES NOT EXIST !",fEuclidMaterial.Data());
64 exit(1);
65 }
66}
67
68//_____________________________________________________________________________
69void AliITSv5::CreateGeometry()
70{
71 //
72 // Read geometry for the ITS
73 //
74
fe4da5cc 75 char topvol[5];
76 char *filtmp;
77//
78 filtmp=gSystem->ExpandPathName(fEuclidGeometry.Data());
79 FILE *file = fopen(filtmp,"r");
80 delete [] filtmp;
81 if(file) {
82 fclose(file);
02ca2762 83 gAlice->ReadEuclid(fEuclidGeometry.Data(),this,topvol);
fe4da5cc 84 } else {
85 Error("CreateGeometry"," THE GEOM FILE %s DOES NOT EXIST !",fEuclidGeometry.Data());
86 exit(1);
87 }
88 //
89 // --- Place the ITS ghost volume ITSV in its mother volume (ALIC) and make it
90 // invisible
91 //
cfce8870 92 gMC->Gspos("ITSV",1,"ALIC",0,0,0,0,"ONLY");
fe4da5cc 93 //
94 // --- Outputs the geometry tree in the EUCLID/CAD format
95
96 if (fEuclidOut) {
cfce8870 97 gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
fe4da5cc 98 }
99}
100
101//_____________________________________________________________________________
102void AliITSv5::Init()
103{
104 //
105 // Initialise the ITS after it has been created
106 //
107 AliITS::Init();
108}
109
110//_____________________________________________________________________________
111void AliITSv5::StepManager()
112{
113 //
114 // Called for every step in the ITS
115 //
116 Int_t copy, id;
117 Int_t copy1,copy2;
118 Float_t hits[7];
119 Int_t vol[3];
120 Float_t position[3];
121 Float_t momentum[4];
122 TClonesArray &lhits = *fHits;
fe4da5cc 123 //
cfce8870 124 if(gMC->TrackCharge() && gMC->Edep()) {
fe4da5cc 125 //
126 // Only entering charged tracks
cfce8870 127 if((id=gMC->CurrentVol(0,copy))==fIdSens1) {
fe4da5cc 128 vol[0]=1;
cfce8870 129 id=gMC->CurrentVolOff(0,0,copy); //detector copy in the ladder = 1<->4 (ITS1)
fe4da5cc 130 vol[1]=copy;
cfce8870 131 gMC->CurrentVolOff(1,0,copy1); //ladder copy in the module = 1<->2 (I186)
132 gMC->CurrentVolOff(2,0,copy2); //module copy in the layer = 1<->10 (I132)
fe4da5cc 133 vol[2]=copy1+(copy2-1)*2; //# of ladders in one module = 2
134 } else if(id==fIdSens2) {
135 vol[0]=2;
cfce8870 136 id=gMC->CurrentVolOff(0,0,copy); //detector copy in the ladder = 1<->4 (ITS2)
fe4da5cc 137 vol[1]=copy;
cfce8870 138 gMC->CurrentVolOff(1,0,copy1); //ladder copy in the module = 1<->4 (I131)
139 gMC->CurrentVolOff(2,0,copy2); //module copy in the layer = 1<->10 (I132)
fe4da5cc 140 vol[2]=copy1+(copy2-1)*4; //# of ladders in one module = 4
141 } else if(id==fIdSens3) {
142 vol[0]=3;
cfce8870 143 id=gMC->CurrentVolOff(1,0,copy); //detector copy in the ladder = 1<->5 (ITS3 is inside I314)
fe4da5cc 144 vol[1]=copy;
cfce8870 145 id=gMC->CurrentVolOff(2,0,copy); //ladder copy in the layer = 1<->12 (I316)
fe4da5cc 146 vol[2]=copy;
147 } else if(id==fIdSens4) {
148 vol[0]=4;
cfce8870 149 id=gMC->CurrentVolOff(1,0,copy); //detector copy in the ladder = 1<->8 (ITS4 is inside I414)
fe4da5cc 150 vol[1]=copy;
cfce8870 151 id=gMC->CurrentVolOff(2,0,copy); //ladder copy in the layer = 1<->22 (I417)
fe4da5cc 152 vol[2]=copy;
153 } else if(id==fIdSens5) {
154 vol[0]=5;
cfce8870 155 id=gMC->CurrentVolOff(1,0,copy); //detector copy in the ladder = 1<->23 (ITS5 is inside I562)
fe4da5cc 156 vol[1]=copy;
cfce8870 157 id=gMC->CurrentVolOff(2,0,copy); //ladder copy in the layer = 1<->34 (I565)
fe4da5cc 158 vol[2]=copy;
159 } else if(id==fIdSens6) {
160 vol[0]=6;
cfce8870 161 id=gMC->CurrentVolOff(1,0,copy); //detector copy in the ladder = 1<->26 (ITS6 is inside I566)
fe4da5cc 162 vol[1]=copy;
cfce8870 163 id=gMC->CurrentVolOff(2,0,copy); //ladder copy in the layer = 1<->38 (I569)
fe4da5cc 164 vol[2]=copy;
165 } else return;
cfce8870 166 gMC->TrackPosition(position);
167 gMC->TrackMomentum(momentum);
fe4da5cc 168 hits[0]=position[0];
169 hits[1]=position[1];
170 hits[2]=position[2];
171 hits[3]=momentum[0]*momentum[3];
172 hits[4]=momentum[1]*momentum[3];
173 hits[5]=momentum[2]*momentum[3];
cfce8870 174 hits[6]=gMC->Edep();
fe4da5cc 175 new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
176 }
177}