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