New version of space frame
[u/mrichter/AliRoot.git] / TOF / AliTOFv3.cxx
CommitLineData
fe4da5cc 1///////////////////////////////////////////////////////////////////////////////
2// //
3// Time Of Flight //
4// This class contains the functions for version 3 of the Time Of Flight //
5// detector. //
6// //
7//Begin_Html
8/*
1439f98e 9<img src="picts/AliTOFv3Class.gif">
fe4da5cc 10*/
11//End_Html
12// //
13///////////////////////////////////////////////////////////////////////////////
14
15#include "AliTOFv3.h"
fe4da5cc 16#include "AliRun.h"
fe4da5cc 17
18ClassImp(AliTOFv3)
19
20//_____________________________________________________________________________
ad51aeb0 21AliTOFv3::AliTOFv3()
fe4da5cc 22{
23 //
24 // Default constructor
25 //
26}
27
28//_____________________________________________________________________________
29AliTOFv3::AliTOFv3(const char *name, const char *title)
30 : AliTOF(name,title)
31{
32 //
33 // Standard constructor
34 //
35}
36
37//_____________________________________________________________________________
38void AliTOFv3::CreateGeometry()
39{
40 //
41 // Create geometry for Time Of Flight version 2
42 //
43 //Begin_Html
44 /*
1439f98e 45 <img src="picts/AliTOFv3.gif">
fe4da5cc 46 */
47 //End_Html
48 //
49
50 //
51 // Create common geometry between version 2 and 3
52 //
53 AliTOF::CreateGeometry();
54}
55
56//_____________________________________________________________________________
57void AliTOFv3::TOFpc(Float_t xm, Float_t ym, Float_t zm0,
58 Float_t zm1, Float_t zm2)
59{
60 //
61 // Definition of the Time Of Fligh Parallel Plate Chambers
62 //
63
fe4da5cc 64 Int_t inum;
65 Float_t xcor, zcor, ytop;
66 Int_t inum1;
67 Float_t xcor1, xcor2, ycoor;
68 Float_t stepx, stepz, dx, dy, dz, xp, yp, zp, shiftx, shiftz, ywidth;
69 Float_t shiftx1, shiftx2, xad, zad;
70 Int_t ink;
71 Float_t par[10];
72 Int_t inz;
73 Float_t xzd;
74 Int_t nxp, npx, npz;
75 Float_t xsz, ysz, zsz;
76 Int_t nzp0, nzp1, nzp2;
77
ad51aeb0 78 Int_t *idtmed = fIdtmed->GetArray()-499;
fe4da5cc 79
80 // X size of PPC plate
81 xsz = 54.;
82 // Y size of PPC plate
83 ysz = .2;
84 // Z size of PPC plate
85 zsz = 48.;
86 // First return additional shift along X
87 xad = 1.5;
88 // Second return additional shift along X
89 xzd = .5;
90 // Return additional shift along Z
91 zad = .25;
92 // Width of DME box
93 ywidth = 4.;
94 // X size of PPC chamber
95 xp = 5.7;
96 // Y size of PPC chamber
97 yp = .32;
98 // Z size of PPC chamber
99 zp = 5.7;
100 // Frame width along X,Y and Z axis of PPC chambers
101 dx = .2;
102 dy = .1;
103 dz = .2;
104 // No sensitive volumes with DME
105 par[0] = xm / 2.;
106 par[1] = ywidth / 2.;
107 par[2] = zm0 / 2.;
108 ycoor = ym / 3. - ywidth / 2.;
cfce8870 109 gMC->Gsvolu("FBT1", "BOX ", idtmed[505], par, 3);
110 gMC->Gspos("FBT1", 0, "FTO1", 0., 0., 0., 0, "ONLY");
fe4da5cc 111 par[2] = zm1 / 2.;
cfce8870 112 gMC->Gsvolu("FBT2", "BOX ", idtmed[505], par, 3);
113 gMC->Gspos("FBT2", 1, "FTO2", 0., 0., 0., 0, "ONLY");
fe4da5cc 114 par[2] = zm2 / 2.;
cfce8870 115 gMC->Gsvolu("FBT3", "BOX ", idtmed[505], par, 3);
116 gMC->Gspos("FBT3", 2, "FTO3", 0., 0., 0., 0, "ONLY");
fe4da5cc 117 // Electronic plate
118 par[1] = ysz / 2.;
119 par[2] = zm0 / 2.;
120 ycoor = ywidth / 2. - ysz / 2.;
cfce8870 121 gMC->Gsvolu("FPE1", "BOX ", idtmed[504], par, 3);
122 gMC->Gspos("FPE1", 0, "FBT1", 0., ycoor, 0., 0, "ONLY");
123 gMC->Gspos("FPE1", 1, "FBT1", 0., -ycoor, 0., 0, "ONLY");
fe4da5cc 124 par[2] = zm1 / 2.;
cfce8870 125 gMC->Gsvolu("FPE2", "BOX ", idtmed[504], par, 3);
126 gMC->Gspos("FPE2", 0, "FBT2", 0., ycoor, 0., 0, "ONLY");
127 gMC->Gspos("FPE2", 1, "FBT2", 0., -ycoor, 0., 0, "ONLY");
fe4da5cc 128 par[2] = zm2 / 2.;
cfce8870 129 gMC->Gsvolu("FPE3", "BOX ", idtmed[504], par, 3);
130 gMC->Gspos("FPE3", 0, "FBT3", 0., ycoor, 0., 0, "ONLY");
131 gMC->Gspos("FPE3", 1, "FBT3", 0., -ycoor, 0., 0, "ONLY");
fe4da5cc 132 // Electronic insensitive volumes
133 par[1] = yp / 2.;
134 par[2] = zm0 / 2.;
135 ytop = ywidth / 2. - (ysz * 2 + yp) / 2.;
cfce8870 136 gMC->Gsvolu("FST1", "BOX ", idtmed[505], par, 3);
137 gMC->Gsvolu("FLT1", "BOX ", idtmed[505], par, 3);
138 gMC->Gspos("FST1", 0, "FBT1", 0., ytop, 0., 0, "ONLY");
139 gMC->Gspos("FLT1", 0, "FBT1", 0., -ytop, 0., 0, "ONLY");
fe4da5cc 140 par[2] = zm1 / 2.;
cfce8870 141 gMC->Gsvolu("FST2", "BOX ", idtmed[505], par, 3);
142 gMC->Gsvolu("FLT2", "BOX ", idtmed[505], par, 3);
143 gMC->Gspos("FST2", 0, "FBT2", 0., ytop, 0., 0, "ONLY");
144 gMC->Gspos("FLT2", 0, "FBT2", 0., -ytop, 0., 0, "ONLY");
fe4da5cc 145 par[2] = zm2 / 2.;
cfce8870 146 gMC->Gsvolu("FST3", "BOX ", idtmed[505], par, 3);
147 gMC->Gsvolu("FLT3", "BOX ", idtmed[505], par, 3);
148 gMC->Gspos("FST3", 0, "FBT3", 0., ytop, 0., 0, "ONLY");
149 gMC->Gspos("FLT3", 0, "FBT3", 0., -ytop, 0., 0, "ONLY");
fe4da5cc 150 // PPC-plate number along X axis
151 nxp = Int_t (xm / xsz);
152 // PPC-plate number along Z axis
153 nzp0 = Int_t (zm0 / zsz);
154 nzp1 = Int_t (zm1 / zsz);
155 nzp2 = Int_t (zm2 / zsz);
156 // Position of big PPC-plate
157 par[0] = xm * .5 / nxp;
158 par[2] = zm0 * .5 / nzp0;
cfce8870 159 gMC->Gsvolu("FSK1", "BOX ", idtmed[505], par, 3);
160 gMC->Gsvolu("FLK1", "BOX ", idtmed[505], par, 3);
fe4da5cc 161 inum = 0;
162 for (ink = 1; ink <= nxp; ++ink) {
163 xcor = xm * .5 * ((ink * 2 - 1) / (Float_t) nxp - 1.);
164 for (inz = 1; inz <= nzp0; ++inz) {
165 zcor = zm0 * .5 * ((inz * 2 - 1) / (Float_t) nzp0 - 1.);
166 ++inum;
cfce8870 167 gMC->Gspos("FSK1", inum, "FST1", xcor, 0., zcor, 0, "ONLY");
168 gMC->Gspos("FLK1", inum, "FLT1", xcor, 0., zcor, 0, "ONLY");
fe4da5cc 169 }
170 for (inz = 1; inz <= nzp1; ++inz) {
171 zcor = zm1 * .5 * ((inz * 2 - 1) / (Float_t) nzp1 - 1.);
172 ++inum;
cfce8870 173 gMC->Gspos("FSK1", inum, "FST2", xcor, 0., zcor, 0, "ONLY");
174 gMC->Gspos("FLK1", inum, "FLT2", xcor, 0., zcor, 0, "ONLY");
fe4da5cc 175 }
176 for (inz = 1; inz <= nzp2; ++inz) {
177 zcor = zm2 * .5 * ((inz * 2 - 1) / (Float_t) nzp2 - 1.);
178 ++inum;
cfce8870 179 gMC->Gspos("FSK1", inum, "FST3", xcor, 0., zcor, 0, "ONLY");
180 gMC->Gspos("FLK1", inum, "FLT3", xcor, 0., zcor, 0, "ONLY");
fe4da5cc 181 }
182 }
183 par[0] = xsz / 2.;
184 par[1] = yp / 2.;
185 par[2] = zsz / 2.;
cfce8870 186 gMC->Gsvolu("FSL1", "BOX ", idtmed[505], par, 3);
187 gMC->Gsvolu("FLL1", "BOX ", idtmed[505], par, 3);
fe4da5cc 188 shiftx = (xp / 2. + xad / 2.) / 2.;
189 shiftz = (zm0 / nzp0 - zsz) / 2.;
cfce8870 190 gMC->Gspos("FSL1", 0, "FSK1", -shiftx, 0., -shiftz, 0, "ONLY");
191 gMC->Gspos("FLL1", 0, "FLK1", shiftx, 0., shiftz, 0, "ONLY");
fe4da5cc 192 // PPC position on PPC-plate
193 npx = 4;
194 npz = 8;
195 par[0] = xp / 2.;
196 par[1] = yp / 2.;
197 par[2] = zp / 2.;
198 stepx = (xad + xzd + xp * 2) / 2.;
199 stepz = (zp + zad) / 2.;
200 shiftz = npz * (zad + zp) / 2.;
201 shiftx = npx * (xp * 2 + xad + xzd) / 2.;
202 shiftx1 = (xp * 2 + xzd + xad) / 2. - xp / 2.;
203 shiftx2 = (xp * 2 + xzd + xad) / 2. - xp / 2. - xzd;
cfce8870 204 gMC->Gsvolu("FPG1", "BOX ", idtmed[507], par, 3);
fe4da5cc 205 for (ink = 1; ink <= npx; ++ink) {
206 xcor1 = -shiftx + stepx * (ink * 2 - 1) - shiftx1;
207 xcor2 = -shiftx + stepx * (ink * 2 - 1) + shiftx2;
208 for (inz = 1; inz <= npz; ++inz) {
209 zcor = -shiftz + stepz * (inz * 2 - 1);
210 ++inum;
211 inum1 = npx * npz + inum;
cfce8870 212 gMC->Gspos("FPG1", inum, "FSL1", xcor1, 0., zcor, 0, "ONLY");
213 gMC->Gspos("FPG1", inum1, "FSL1", xcor2, 0., zcor, 0, "ONLY");
214 gMC->Gspos("FPG1", inum, "FLL1", xcor1, 0., zcor, 0, "ONLY");
215 gMC->Gspos("FPG1", inum1, "FLL1", xcor2, 0., zcor, 0, "ONLY");
fe4da5cc 216 }
217 }
218 par[0] = xp / 2. - dx;
219 par[1] = yp / 2. - dy;
220 par[2] = zp / 2. - dz;
cfce8870 221 gMC->Gsvolu("FPG2", "BOX ", idtmed[509], par, 3);
222 gMC->Gspos("FPG2", 0, "FPG1", 0., 0., 0., 0, "ONLY");
fe4da5cc 223}
224
225//_____________________________________________________________________________
8f72dc0c 226void AliTOFv3::DrawModule()
fe4da5cc 227{
228 //
229 // Draw a shaded view of the Time Of Flight version 3
230 //
231
fe4da5cc 232 // Set everything unseen
cfce8870 233 gMC->Gsatt("*", "seen", -1);
fe4da5cc 234 //
235 // Set ALIC mother transparent
cfce8870 236 gMC->Gsatt("ALIC","SEEN",0);
fe4da5cc 237 //
238 // Set the volumes visible
cfce8870 239 gMC->Gsatt("ALIC","SEEN",0);
240 gMC->Gsatt("FBAR","SEEN",0);
241 gMC->Gsatt("FTO1","SEEN",0);
242 gMC->Gsatt("FTO2","SEEN",0);
243 gMC->Gsatt("FTO3","SEEN",0);
244 gMC->Gsatt("FBT1","SEEN",0);
245 gMC->Gsatt("FBT2","SEEN",0);
246 gMC->Gsatt("FBT3","SEEN",0);
247 gMC->Gsatt("FST1","SEEN",0);
248 gMC->Gsatt("FLT1","SEEN",0);
249 gMC->Gsatt("FST2","SEEN",0);
250 gMC->Gsatt("FLT2","SEEN",0);
251 gMC->Gsatt("FST3","SEEN",0);
252 gMC->Gsatt("FLT3","SEEN",0);
253 gMC->Gsatt("FSK1","SEEN",0);
254 gMC->Gsatt("FLK1","SEEN",0);
255 gMC->Gsatt("FSL1","SEEN",1);
256 gMC->Gsatt("FLL1","SEEN",1);
fe4da5cc 257 //
cfce8870 258 gMC->Gdopt("hide", "on");
259 gMC->Gdopt("shad", "on");
260 gMC->Gsatt("*", "fill", 7);
261 gMC->SetClipBox(".");
262 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
263 gMC->DefaultRange();
264 gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
265 gMC->Gdhead(1111, "Time Of Flight");
266 gMC->Gdman(18, 4, "MAN");
267 gMC->Gdopt("hide","off");
fe4da5cc 268}
269
270//_____________________________________________________________________________
271void AliTOFv3::CreateMaterials()
272{
273 //
274 // Define materials for the Time Of Flight
275 //
276 AliTOF::CreateMaterials();
277}
278
279//_____________________________________________________________________________
280void AliTOFv3::Init()
281{
282 //
283 // Initialise the detector after the geometry has been defined
284 //
285
fe4da5cc 286 AliTOF::Init();
cfce8870 287 fIdFTO2=gMC->VolId("FTO2");
288 fIdFTO3=gMC->VolId("FTO3");
289 fIdFLT1=gMC->VolId("FLT1");
290 fIdFLT2=gMC->VolId("FLT2");
291 fIdFLT3=gMC->VolId("FLT3");
fe4da5cc 292}
293
294//_____________________________________________________________________________
295void AliTOFv3::StepManager()
296{
297 //
298 // Procedure called at each step in the Time Of Flight
299 //
0a6d8768 300 TLorentzVector mom, pos;
fe4da5cc 301 Float_t hits[8];
302 Int_t vol[3];
0a6d8768 303 Int_t copy, id, i;
ad51aeb0 304 Int_t *idtmed = fIdtmed->GetArray()-499;
cfce8870 305 if(gMC->GetMedium()==idtmed[510-1] &&
0a6d8768 306 gMC->IsTrackEntering() && gMC->TrackCharge()
307 && gMC->CurrentVolID(copy)==fIdSens) {
fe4da5cc 308 TClonesArray &lhits = *fHits;
309 //
310 // Record only charged tracks at entrance
0a6d8768 311 gMC->CurrentVolOffID(1,copy);
fe4da5cc 312 vol[2]=copy;
0a6d8768 313 gMC->CurrentVolOffID(3,copy);
fe4da5cc 314 vol[1]=copy;
0a6d8768 315 id=gMC->CurrentVolOffID(6,copy);
fe4da5cc 316 vol[0]=copy;
317 if(id==fIdFTO3) {
318 vol[0]+=22;
0a6d8768 319 id=gMC->CurrentVolOffID(4,copy);
fe4da5cc 320 if(id==fIdFLT3) vol[1]+=6;
321 } else if (id==fIdFTO2) {
322 vol[0]+=20;
0a6d8768 323 id=gMC->CurrentVolOffID(4,copy);
fe4da5cc 324 if(id==fIdFLT2) vol[1]+=8;
325 } else {
0a6d8768 326 id=gMC->CurrentVolOffID(4,copy);
fe4da5cc 327 if(id==fIdFLT1) vol[1]+=14;
328 }
0a6d8768 329 gMC->TrackPosition(pos);
330 gMC->TrackMomentum(mom);
331 Double_t ptot=mom.Rho();
332 Double_t norm=1/ptot;
333 for(i=0;i<3;++i) {
334 hits[i]=pos[i];
335 hits[i+3]=mom[i]*norm;
336 }
337 hits[6]=ptot;
338 hits[7]=pos[3];
fe4da5cc 339 new(lhits[fNhits++]) AliTOFhit(fIshunt,gAlice->CurrentTrack(),vol,hits);
340 }
341}