]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFv3.cxx
Use tgt_ prefix for binary target directories
[u/mrichter/AliRoot.git] / TOF / AliTOFv3.cxx
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 /*
9 <img src="picts/AliTOFv3Class.gif">
10 */
11 //End_Html
12 //                                                                           //
13 ///////////////////////////////////////////////////////////////////////////////
14
15 #include "AliTOFv3.h"
16 #include "AliRun.h"
17  
18 ClassImp(AliTOFv3)
19  
20 //_____________________________________________________________________________
21 AliTOFv3::AliTOFv3()
22 {
23   //
24   // Default constructor
25   //
26 }
27  
28 //_____________________________________________________________________________
29 AliTOFv3::AliTOFv3(const char *name, const char *title)
30        : AliTOF(name,title)
31 {
32   //
33   // Standard constructor
34   //
35 }
36  
37 //_____________________________________________________________________________
38 void AliTOFv3::CreateGeometry()
39 {
40   //
41   // Create geometry for Time Of Flight version 2
42   //
43   //Begin_Html
44   /*
45     <img src="picts/AliTOFv3.gif">
46   */
47   //End_Html
48   //
49
50   //
51   // Create common geometry between version 2 and 3
52   //
53   AliTOF::CreateGeometry();
54 }
55  
56 //_____________________________________________________________________________
57 void 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
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   
78   Int_t *idtmed = fIdtmed->GetArray()-499;
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.;
109   gMC->Gsvolu("FBT1", "BOX ", idtmed[505], par, 3);
110   gMC->Gspos("FBT1", 0, "FTO1", 0., 0., 0., 0, "ONLY");
111   par[2] = zm1 / 2.;
112   gMC->Gsvolu("FBT2", "BOX ", idtmed[505], par, 3);
113   gMC->Gspos("FBT2", 1, "FTO2", 0., 0., 0., 0, "ONLY");
114   par[2] = zm2 / 2.;
115   gMC->Gsvolu("FBT3", "BOX ", idtmed[505], par, 3);
116   gMC->Gspos("FBT3", 2, "FTO3", 0., 0., 0., 0, "ONLY");
117   // Electronic plate 
118   par[1] = ysz / 2.;
119   par[2] = zm0 / 2.;
120   ycoor = ywidth / 2. - ysz / 2.;
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");
124   par[2] = zm1 / 2.;
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");
128   par[2] = zm2 / 2.;
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");
132   // Electronic insensitive volumes 
133   par[1] = yp / 2.;
134   par[2] = zm0 / 2.;
135   ytop = ywidth / 2. - (ysz * 2 + yp) / 2.;
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");
140   par[2] = zm1 / 2.;
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");
145   par[2] = zm2 / 2.;
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");
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;
159   gMC->Gsvolu("FSK1", "BOX ", idtmed[505], par, 3);
160   gMC->Gsvolu("FLK1", "BOX ", idtmed[505], par, 3);
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;
167       gMC->Gspos("FSK1", inum, "FST1", xcor, 0., zcor, 0, "ONLY");
168       gMC->Gspos("FLK1", inum, "FLT1", xcor, 0., zcor, 0, "ONLY");
169     }
170     for (inz = 1; inz <= nzp1; ++inz) {
171       zcor = zm1 * .5 * ((inz * 2 - 1) / (Float_t) nzp1 - 1.);
172       ++inum;
173       gMC->Gspos("FSK1", inum, "FST2", xcor, 0., zcor, 0, "ONLY");
174       gMC->Gspos("FLK1", inum, "FLT2", xcor, 0., zcor, 0, "ONLY");
175     }
176     for (inz = 1; inz <= nzp2; ++inz) {
177       zcor = zm2 * .5 * ((inz * 2 - 1) / (Float_t) nzp2 - 1.);
178       ++inum;
179       gMC->Gspos("FSK1", inum, "FST3", xcor, 0., zcor, 0, "ONLY");
180       gMC->Gspos("FLK1", inum, "FLT3", xcor, 0., zcor, 0, "ONLY");
181     }
182   }
183   par[0] = xsz / 2.;
184   par[1] = yp / 2.;
185   par[2] = zsz / 2.;
186   gMC->Gsvolu("FSL1", "BOX ", idtmed[505], par, 3);
187   gMC->Gsvolu("FLL1", "BOX ", idtmed[505], par, 3);
188   shiftx = (xp / 2. + xad / 2.) / 2.;
189   shiftz = (zm0 / nzp0 - zsz) / 2.;
190   gMC->Gspos("FSL1", 0, "FSK1", -shiftx, 0., -shiftz, 0, "ONLY");
191   gMC->Gspos("FLL1", 0, "FLK1", shiftx, 0., shiftz, 0, "ONLY");
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;
204   gMC->Gsvolu("FPG1", "BOX ", idtmed[507], par, 3);
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;
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");
216     }
217   }
218   par[0] = xp / 2. - dx;
219   par[1] = yp / 2. - dy;
220   par[2] = zp / 2. - dz;
221   gMC->Gsvolu("FPG2", "BOX ", idtmed[509], par, 3);
222   gMC->Gspos("FPG2", 0, "FPG1", 0., 0., 0., 0, "ONLY");
223 }
224
225 //_____________________________________________________________________________
226 void AliTOFv3::DrawModule()
227 {
228   //
229   // Draw a shaded view of the Time Of Flight version 3
230   //
231
232   // Set everything unseen
233   gMC->Gsatt("*", "seen", -1);
234   // 
235   // Set ALIC mother transparent
236   gMC->Gsatt("ALIC","SEEN",0);
237   //
238   // Set the volumes visible
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);
257   //
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");
268 }
269
270 //_____________________________________________________________________________
271 void AliTOFv3::CreateMaterials()
272 {
273   //
274   // Define materials for the Time Of Flight
275   //
276    AliTOF::CreateMaterials();
277 }
278  
279 //_____________________________________________________________________________
280 void AliTOFv3::Init()
281 {
282   //
283   // Initialise the detector after the geometry has been defined
284   //
285
286   AliTOF::Init();
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");
292 }
293  
294 //_____________________________________________________________________________
295 void AliTOFv3::StepManager()
296 {
297   //
298   // Procedure called at each step in the Time Of Flight
299   //
300   TLorentzVector mom, pos;
301   Float_t hits[8];
302   Int_t vol[3];
303   Int_t copy, id, i;
304   Int_t *idtmed = fIdtmed->GetArray()-499;
305   if(gMC->GetMedium()==idtmed[510-1] && 
306      gMC->IsTrackEntering() && gMC->TrackCharge()
307      && gMC->CurrentVolID(copy)==fIdSens) {
308     TClonesArray &lhits = *fHits;
309     //
310     // Record only charged tracks at entrance
311     gMC->CurrentVolOffID(1,copy);
312     vol[2]=copy;
313     gMC->CurrentVolOffID(3,copy);
314     vol[1]=copy;
315     id=gMC->CurrentVolOffID(6,copy);
316     vol[0]=copy;
317     if(id==fIdFTO3) {
318       vol[0]+=22;
319       id=gMC->CurrentVolOffID(4,copy);
320       if(id==fIdFLT3) vol[1]+=6;
321     } else if (id==fIdFTO2) {
322       vol[0]+=20;
323       id=gMC->CurrentVolOffID(4,copy);
324       if(id==fIdFLT2) vol[1]+=8;
325     } else {
326       id=gMC->CurrentVolOffID(4,copy);
327       if(id==fIdFLT1) vol[1]+=14;
328     }
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];
339     new(lhits[fNhits++]) AliTOFhit(fIshunt,gAlice->CurrentTrack(),vol,hits);
340   }
341 }