]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFv3.cxx
b1d8d33425480ef08170f2e93e6b9dda5f3d0870
[u/mrichter/AliRoot.git] / TOF / AliTOFv3.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17 $Log$
18 Revision 1.12  1999/11/01 20:41:57  fca
19 Added protections against using the wrong version of FRAME
20
21 Revision 1.11  1999/10/22 08:04:14  fca
22 Correct improper use of negative parameters
23
24 Revision 1.10  1999/10/16 19:30:06  fca
25 Corrected Rotation Matrix and CVS log
26
27 Revision 1.9  1999/10/15 15:35:20  fca
28 New version for frame1099 with and without holes
29
30 Revision 1.8  1999/09/29 09:24:33  fca
31 Introduction of the Copyright and cvs Log
32
33 */
34
35 ///////////////////////////////////////////////////////////////////////////////
36 //                                                                           //
37 //  Time Of Flight: design of C.Williams                FCA                  //
38 //  This class contains the functions for version 1 of the Time Of Flight    //
39 //  detector.                                                                //
40 //
41 //  VERSION WITH 5 MODULES AND TILTED STRIPS 
42 //  
43 //   FULL COVERAGE VERSION
44 //
45 //   Authors:
46 //
47 //   Alessio Seganti
48 //   Domenico Vicinanza
49 //
50 //   University of Salerno - Italy
51 //
52 //
53 //Begin_Html
54 /*
55 <img src="picts/AliTOFv3Class.gif">
56 */
57 //End_Html
58 //                                                                           //
59 ///////////////////////////////////////////////////////////////////////////////
60
61 #include <stdlib.h>
62
63 #include "AliTOFv3.h"
64 #include "AliRun.h"
65 #include "AliConst.h"
66  
67 ClassImp(AliTOFv3)
68  
69 //_____________________________________________________________________________
70 AliTOFv3::AliTOFv3()
71 {
72   //
73   // Default constructor
74   //
75 }
76  
77 //_____________________________________________________________________________
78 AliTOFv3::AliTOFv3(const char *name, const char *title)
79        : AliTOF(name,title)
80 {
81   //
82   // Standard constructor
83   //
84 }
85  
86 //_____________________________________________________________________________
87 void AliTOFv3::CreateGeometry()
88 {
89   //
90   // Create geometry for Time Of Flight version 0
91   //
92   //Begin_Html
93   /*
94     <img src="picts/AliTOFv3.gif">
95   */
96   //End_Html
97   //
98   // Creates common geometry
99   //
100   AliTOF::CreateGeometry();
101 }
102  
103 //_____________________________________________________________________________
104 void AliTOFv3::TOFpc(Float_t xtof, Float_t ytof, Float_t zlen1,
105                      Float_t zlen2, Float_t zlen3, Float_t ztof0)
106 {
107   //
108   // Definition of the Time Of Fligh Resistive Plate Chambers
109   // xFLT, yFLT, zFLT - sizes of TOF modules (large)
110   
111   Float_t  ycoor, zcoor;
112   Float_t par[10];
113   
114   Int_t *idtmed = fIdtmed->GetArray()-499;
115
116   Int_t idrotm[100];
117   Int_t nrot = 0;
118   
119
120
121   par[0] =  xtof / 2.;
122   par[1] =  ytof / 2.;
123   par[2] = zlen1 / 2.;
124   gMC->Gsvolu("FTO1", "BOX ", idtmed[506], par, 3);
125   par[2] = zlen2 / 2.;
126   gMC->Gsvolu("FTO2", "BOX ", idtmed[506], par, 3);
127   par[2] = zlen3 / 2.;
128   gMC->Gsvolu("FTO3", "BOX ", idtmed[506], par, 3);
129
130
131 // Positioning of modules
132
133    Float_t zcor1 = ztof0 - zlen1/2;
134    Float_t zcor2 = ztof0 - zlen1 - zlen2/2.;
135    Float_t zcor3 = 0.;
136
137    AliMatrix(idrotm[0], 90., 0., 0., 0., 90, -90.);
138    AliMatrix(idrotm[1], 90., 180., 0., 0., 90, 90.);
139    gMC->Gspos("FTO1", 1, "BTO1", 0,  zcor1, 0, idrotm[0], "ONLY");
140    gMC->Gspos("FTO1", 2, "BTO1", 0, -zcor1, 0, idrotm[1], "ONLY");
141    gMC->Gspos("FTO1", 1, "BTO2", 0,  zcor1, 0, idrotm[0], "ONLY");
142    gMC->Gspos("FTO1", 2, "BTO2", 0, -zcor1, 0, idrotm[1], "ONLY");
143    gMC->Gspos("FTO1", 1, "BTO3", 0,  zcor1, 0, idrotm[0], "ONLY");
144    gMC->Gspos("FTO1", 2, "BTO3", 0, -zcor1, 0, idrotm[1], "ONLY");
145
146    gMC->Gspos("FTO2", 1, "BTO1", 0,  zcor2, 0, idrotm[0], "ONLY");
147    gMC->Gspos("FTO2", 2, "BTO1", 0, -zcor2, 0, idrotm[1], "ONLY");
148    gMC->Gspos("FTO2", 1, "BTO2", 0,  zcor2, 0, idrotm[0], "ONLY");
149    gMC->Gspos("FTO2", 2, "BTO2", 0, -zcor2, 0, idrotm[1], "ONLY");
150    gMC->Gspos("FTO2", 1, "BTO3", 0,  zcor2, 0, idrotm[0], "ONLY");
151    gMC->Gspos("FTO2", 2, "BTO3", 0, -zcor2, 0, idrotm[1], "ONLY");
152
153    gMC->Gspos("FTO3", 0, "BTO1", 0, zcor3,  0, idrotm[0], "ONLY");
154    gMC->Gspos("FTO3", 0, "BTO2", 0, zcor3,  0, idrotm[0], "ONLY");
155    gMC->Gspos("FTO3", 0, "BTO3", 0, zcor3,  0, idrotm[0], "ONLY");
156
157 // Subtraction the distance to TOF module boundaries 
158
159   Float_t db = 7.;
160   Float_t xFLT, yFLT, zFLT1, zFLT2, zFLT3;
161
162   xFLT = xtof -(.5 +.5)*2;
163   yFLT = ytof;
164   zFLT1 = zlen1 - db;
165   zFLT2 = zlen2 - db;
166   zFLT3 = zlen3 - db;
167
168 // Sizes of MRPC pads
169
170   Float_t yPad = 0.505; 
171   
172 // Large not sensitive volumes with CO2 
173   par[0] = xFLT/2;
174   par[1] = yFLT/2;
175
176   cout <<"************************* TOF geometry **************************"<<endl;
177
178   par[2] = (zFLT1 / 2.);
179   gMC->Gsvolu("FLT1", "BOX ", idtmed[506], par, 3); // CO2
180   gMC->Gspos("FLT1", 0, "FTO1", 0., 0., 0., 0, "ONLY");
181
182   par[2] = (zFLT2 / 2.);
183   gMC->Gsvolu("FLT2", "BOX ", idtmed[506], par, 3); // CO2
184   gMC->Gspos("FLT2", 0, "FTO2", 0., 0., 0., 0, "ONLY");
185
186   par[2] = (zFLT3 / 2.); 
187   gMC->Gsvolu("FLT3", "BOX ", idtmed[506], par, 3); // CO2
188   gMC->Gspos("FLT3", 0, "FTO3", 0., 0., 0., 0, "ONLY");
189
190 ////////// Layers before detector ////////////////////
191
192 // Alluminium layer in front 1.0 mm thick at the beginning
193   par[0] = -1;
194   par[1] = 0.1;
195   par[2] = -1;
196   ycoor = -yFLT/2 + par[1];
197   gMC->Gsvolu("FMY1", "BOX ", idtmed[508], par, 3); // Alluminium
198   gMC->Gspos("FMY1", 0, "FLT1", 0., ycoor, 0., 0, "ONLY");
199   gMC->Gsvolu("FMY2", "BOX ", idtmed[508], par, 3); // Alluminium
200   gMC->Gspos("FMY2", 0, "FLT2", 0., ycoor, 0., 0, "ONLY");
201   gMC->Gsvolu("FMY3", "BOX ", idtmed[508], par, 3); // Alluminium 
202   gMC->Gspos("FMY3", 0, "FLT3", 0., ycoor, 0., 0, "ONLY");
203
204 // Honeycomb layer (1cm of special polyethilene)
205   ycoor = ycoor + par[1];
206   par[0] = -1;
207   par[1] = 0.5;
208   par[2] = -1;
209   ycoor = ycoor + par[1];
210   gMC->Gsvolu("FPL1", "BOX ", idtmed[503], par, 3); // Hony
211   gMC->Gspos("FPL1", 0, "FLT1", 0., ycoor, 0., 0, "ONLY");
212   gMC->Gsvolu("FPL2", "BOX ", idtmed[503], par, 3); // Hony
213   gMC->Gspos("FPL2", 0, "FLT2", 0., ycoor, 0., 0, "ONLY");
214   gMC->Gsvolu("FPL3", "BOX ", idtmed[503], par, 3); // Hony
215   gMC->Gspos("FPL3", 0, "FLT3", 0., ycoor, 0., 0, "ONLY");
216
217 ///////////////// Detector itself //////////////////////
218
219   const Float_t StripWidth = 7.81;//cm
220   const Float_t DeadBound = 1.;//cm non-sensitive between the pad edge and the boundary of the strip
221   const Int_t nx = 40; // number of pads along x
222   const Int_t nz = 2;  // number of pads along z
223   const Float_t Gap=4.; //cm  distance between the strip axis
224   const Float_t Space = 5.5; //cm distance from the front plate of the box
225
226   Float_t zSenStrip;
227   zSenStrip = StripWidth-2*DeadBound;//cm
228
229   par[0] = xFLT/2;
230   par[1] = yPad/2; 
231   par[2] = StripWidth/2.;
232   
233   // Glass Layer of detector
234   gMC->Gsvolu("FSTR","BOX",idtmed[514],par,3);
235
236   // Freon for non-sesitive boundaries
237   par[0] = xFLT/2;
238   par[1] = 0.110/2;
239   par[2] = -1;
240   gMC->Gsvolu("FNSF","BOX",idtmed[512],par,3);
241   gMC->Gspos("FNSF",0,"FSTR",0.,0.,0.,0,"ONLY");
242   // Mylar for non-sesitive boundaries
243   par[1] = 0.025;
244   gMC->Gsvolu("FMYI","BOX",idtmed[510],par,3); 
245   gMC->Gspos("FMYI",0,"FNSF",0.,0.,0.,0,"ONLY");
246
247   // Mylar for outer layers
248   par[1] = 0.035/2;
249   ycoor = -yPad/2.+par[1];
250   gMC->Gsvolu("FMYX","BOX",idtmed[510],par,3);
251   gMC->Gspos("FMYX",1,"FSTR",0.,ycoor,0.,0,"ONLY");
252   gMC->Gspos("FMYX",2,"FSTR",0.,-ycoor,0.,0,"ONLY");
253   ycoor += par[1];
254  
255   // Graphyte layers
256   par[1] = 0.003/2;
257   ycoor += par[1];
258   gMC->Gsvolu("FGRL","BOX",idtmed[502],par,3);
259   gMC->Gspos("FGRL",1,"FSTR",0.,ycoor,0.,0,"ONLY");
260   gMC->Gspos("FGRL",2,"FSTR",0.,-ycoor,0.,0,"ONLY");
261
262   // Freon sensitive layer
263   par[0] = -1;
264   par[1] = 0.110/2.;
265   par[2] = zSenStrip/2.;
266   gMC->Gsvolu("FCFC","BOX",idtmed[513],par,3);
267   gMC->Gspos("FCFC",0,"FNSF",0.,0.,0.,0,"ONLY");
268   
269   // Pad definition x & z
270   gMC->Gsdvn("FLZ","FCFC", nz, 3); 
271   gMC->Gsdvn("FLX","FLZ" , nx, 1); 
272
273   // MRPC pixel itself 
274   par[0] = -1;
275   par[1] = -1; 
276   par[2] = -1;
277   gMC->Gsvolu("FPAD", "BOX ", idtmed[513], par, 3);
278   gMC->Gspos("FPAD", 0, "FLX", 0., 0., 0., 0, "ONLY");
279
280
281 ////  Positioning the Strips  (FSTR) in the FLT volumes  /////
282
283  
284   // 3 (Central) Plate 
285   Float_t t = zFLT1+zFLT2+zFLT3/2.+7.*2.5;//Half Width of Barrel
286   Float_t zpos = 0;
287   Float_t ang;
288   Float_t Offset;  
289   Float_t last;
290   nrot = 0;
291   Int_t i=1,j=1;
292   zcoor=0;
293   Int_t UpDown=-1; // UpDown=-1 -> Upper strip, UpDown=+1 -> Lower strip
294  
295   do{
296      ang = atan(zcoor/t);
297      ang = ang * kRaddeg;
298      AliMatrix (idrotm[nrot]  ,90.,  0.,90.-ang,90.,-ang,90.);
299      AliMatrix (idrotm[nrot+1],90.,180.,90.+ang,90., ang,90.);
300      ycoor = -29./2.+ Space; //2 cm over front plate
301      ycoor += (1-(UpDown+1)/2)*Gap;
302      gMC->Gspos("FSTR",j,"FLT3",0.,ycoor,zcoor,idrotm[nrot],"ONLY");
303      gMC->Gspos("FSTR",j+1,"FLT3",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
304      ang  = ang / kRaddeg;     
305      zcoor=zcoor-(zSenStrip/2)/TMath::Cos(ang)+UpDown*Gap*TMath::Tan(ang)-(zSenStrip/2)/TMath::Cos(ang);
306      UpDown*= -1; // Alternate strips 
307      i++;
308      j+=2;
309   } while (zcoor-(StripWidth/2)*TMath::Cos(ang)>-t+zFLT1+zFLT2+7*2.5);
310   
311   ycoor = -29./2.+ Space; //2 cm over front plate
312
313   // Plate  2
314   zpos = -zFLT3/2-7;
315   ang = atan(zpos/sqrt(2*t*t-zpos*zpos));
316   Offset = StripWidth*TMath::Cos(ang)/2;
317   zpos -= Offset;
318   nrot = 0;
319   i=1;
320   // UpDown has not to be reinitialized, so that the arrangement of the strips can continue coherently
321
322   do {
323      ang = atan(zpos/sqrt(2*t*t-zpos*zpos));
324      ang = ang*kRaddeg;
325      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
326      ycoor = -29./2.+ Space ; //2 cm over front plate
327      ycoor += (1-(UpDown+1)/2)*Gap;
328      zcoor = zpos+(zFLT3/2.+7+zFLT2/2); // Moves to the system of the centre of the modulus FLT2
329      gMC->Gspos("FSTR",i, "FLT2", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
330      ang  = ang/kRaddeg;
331      zpos = zpos - (zSenStrip/2)/TMath::Cos(ang)+UpDown*Gap*TMath::Tan(ang)-(zSenStrip/2)/TMath::Cos(ang);
332      last = StripWidth*TMath::Cos(ang)/2;
333      UpDown*=-1;
334      i++; 
335   } while (zpos-(StripWidth/2)*TMath::Cos(ang)>-t+zFLT1+7);
336
337   // Plate  1
338   zpos = -t+zFLT1+3.5;
339   ang = atan(zpos/sqrt(2*t*t-zpos*zpos));
340   Offset = StripWidth*TMath::Cos(ang)/2.;
341   zpos -= Offset;
342   nrot = 0;
343   i=0;
344   ycoor= -29./2.+Space+Gap/2;
345
346  do {
347      ang = atan(zpos/sqrt(2*t*t-zpos*zpos));
348      ang = ang*kRaddeg;
349      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
350      i++;
351      zcoor = zpos+(zFLT1/2+zFLT2+zFLT3/2+7.*2.);
352      gMC->Gspos("FSTR",i, "FLT1", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
353      ang  = ang/kRaddeg;
354      zpos = zpos - zSenStrip/TMath::Cos(ang);
355      last = StripWidth*TMath::Cos(ang)/2.;
356   }  while (zpos>-t+7.+last);
357
358 printf("#######################################################\n");
359 printf("     Distance from the bound of the FLT3: %f cm \n",t+zpos-(zSenStrip/2)/TMath::Cos(ang));
360      ang = atan(zpos/sqrt(2*t*t-zpos*zpos));
361      zpos = zpos - zSenStrip/TMath::Cos(ang);
362 printf("NEXT Distance from the bound of the FLT3: %f cm \n",t+zpos-(zSenStrip/2)/TMath::Cos(ang));
363 printf("#######################################################\n");
364
365 ////////// Layers after detector /////////////////
366
367 // Honeycomb layer after (3cm)
368
369   Float_t OverSpace = Space + 7.3;
370 ///  StripWidth*TMath::Sin(ang) + 1.3;
371
372   par[0] = -1;
373   par[1] = 0.6;
374   par[2] = -1;
375   ycoor = -yFLT/2 + OverSpace + par[1];
376   gMC->Gsvolu("FPE1", "BOX ", idtmed[503], par, 3); // Hony
377   gMC->Gspos("FPE1", 0, "FLT1", 0., ycoor, 0., 0, "ONLY");
378   gMC->Gsvolu("FPE2", "BOX ", idtmed[503], par, 3); // Hony
379   gMC->Gspos("FPE2", 0, "FLT2", 0., ycoor, 0., 0, "ONLY");
380   gMC->Gsvolu("FPE3", "BOX ", idtmed[503], par, 3); // Hony
381   gMC->Gspos("FPE3", 0, "FLT3", 0., ycoor, 0., 0, "ONLY");
382
383 // Electronics (Cu) after
384   ycoor += par[1];
385   par[0] = -1;
386   par[1] = 1.43*0.05 / 2.; // 5% of X0
387   par[2] = -1;
388   ycoor += par[1];
389   gMC->Gsvolu("FEC1", "BOX ", idtmed[501], par, 3); // Cu
390   gMC->Gspos("FEC1", 0, "FLT1", 0., ycoor, 0., 0, "ONLY");
391   gMC->Gsvolu("FEC2", "BOX ", idtmed[501], par, 3); // Cu
392   gMC->Gspos("FEC2", 0, "FLT2", 0., ycoor, 0., 0, "ONLY");
393   gMC->Gsvolu("FEC3", "BOX ", idtmed[501], par, 3); // Cu
394   gMC->Gspos("FEC3", 0, "FLT3", 0., ycoor, 0., 0, "ONLY");
395
396 // Cooling water after
397   ycoor += par[1];
398   par[0] = -1;
399   par[1] = 36.1*0.02 / 2.; // 2% of X0
400   par[2] = -1;
401   ycoor += par[1];
402   gMC->Gsvolu("FWA1", "BOX ", idtmed[515], par, 3); // Water
403   gMC->Gspos("FWA1", 0, "FLT1", 0., ycoor, 0., 0, "ONLY");
404   gMC->Gsvolu("FWA2", "BOX ", idtmed[515], par, 3); // Water
405   gMC->Gspos("FWA2", 0, "FLT2", 0., ycoor, 0., 0, "ONLY");
406   gMC->Gsvolu("FWA3", "BOX ", idtmed[515], par, 3); // Water
407   gMC->Gspos("FWA3", 0, "FLT3", 0., ycoor, 0., 0, "ONLY");
408
409 //back plate honycomb (2cm)
410   par[0] = -1;
411   par[1] = 2 / 2.;
412   par[2] = -1;
413   ycoor = yFLT/2 - par[1];
414   gMC->Gsvolu("FEG1", "BOX ", idtmed[503], par, 3); // Hony
415   gMC->Gspos("FEG1", 0, "FLT1", 0., ycoor, 0., 0, "ONLY");
416   gMC->Gsvolu("FEG2", "BOX ", idtmed[503], par, 3); // Hony
417   gMC->Gspos("FEG2", 0, "FLT2", 0., ycoor, 0., 0, "ONLY");
418   gMC->Gsvolu("FEG3", "BOX ", idtmed[503], par, 3); // Hony
419   gMC->Gspos("FEG3", 0, "FLT3", 0., ycoor, 0., 0, "ONLY");
420 }
421
422 //_____________________________________________________________________________
423 void AliTOFv3::DrawModule()
424 {
425   //
426   // Draw a shaded view of the Time Of Flight version 1
427   //
428   // Set everything unseen
429   gMC->Gsatt("*", "seen", -1);
430   // 
431   // Set ALIC mother transparent
432   gMC->Gsatt("ALIC","SEEN",0);
433   //
434   // Set the volumes visible
435   gMC->Gsatt("ALIC","SEEN",0);
436   gMC->Gsatt("FBAR","SEEN",1);
437   gMC->Gsatt("FTO1","SEEN",1);
438   gMC->Gsatt("FTO2","SEEN",1);
439   gMC->Gsatt("FTO3","SEEN",1);
440   gMC->Gsatt("FBT1","SEEN",1);
441   gMC->Gsatt("FBT2","SEEN",1);
442   gMC->Gsatt("FBT3","SEEN",1);
443   gMC->Gsatt("FDT1","SEEN",1);
444   gMC->Gsatt("FDT2","SEEN",1);
445   gMC->Gsatt("FDT3","SEEN",1);
446   gMC->Gsatt("FLT1","SEEN",1);
447   gMC->Gsatt("FLT2","SEEN",1);
448   gMC->Gsatt("FLT3","SEEN",1);
449   gMC->Gsatt("FPL1","SEEN",1);
450   gMC->Gsatt("FPL2","SEEN",1);
451   gMC->Gsatt("FPL3","SEEN",1);
452   gMC->Gsatt("FLD1","SEEN",1);
453   gMC->Gsatt("FLD2","SEEN",1);
454   gMC->Gsatt("FLD3","SEEN",1);
455   gMC->Gsatt("FLZ1","SEEN",1);
456   gMC->Gsatt("FLZ2","SEEN",1);
457   gMC->Gsatt("FLZ3","SEEN",1);
458   gMC->Gsatt("FLX1","SEEN",1);
459   gMC->Gsatt("FLX2","SEEN",1);
460   gMC->Gsatt("FLX3","SEEN",1);
461   gMC->Gsatt("FPA0","SEEN",1);
462   //
463   gMC->Gdopt("hide", "on");
464   gMC->Gdopt("shad", "on");
465   gMC->Gsatt("*", "fill", 7);
466   gMC->SetClipBox(".");
467   gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
468   gMC->DefaultRange();
469   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
470   gMC->Gdhead(1111, "Time Of Flight");
471   gMC->Gdman(18, 4, "MAN");
472   gMC->Gdopt("hide","off");
473 }
474
475 //_____________________________________________________________________________
476 void AliTOFv3::CreateMaterials()
477 {
478   //
479   // Define materials for the Time Of Flight
480   //
481   AliTOF::CreateMaterials();
482 }
483  
484 //_____________________________________________________________________________
485 void AliTOFv3::Init()
486 {
487   //
488   // Initialise the detector after the geometry has been defined
489   //
490   printf("**************************************"
491          "  TOF  "
492          "**************************************\n");
493   printf("\n     Version 3 of TOF initialing, "
494          "symmetric TOF\n\n");
495
496   AliTOF::Init();
497
498   //
499   // Check that FRAME is there otherwise we have no place where to
500   // put TOF
501   AliModule* FRAME=gAlice->GetModule("FRAME");
502   if(!FRAME) {
503     Error("Ctor","TOF needs FRAME to be present\n");
504     exit(1);
505   } else 
506     if(FRAME->IsVersion()!=1) {
507       Error("Ctor","FRAME version 1 needed with this version of TOF\n");
508       exit(1);
509     }
510
511   fIdFTO2=gMC->VolId("FTO2");
512   fIdFTO3=gMC->VolId("FTO3");
513   fIdFLT1=gMC->VolId("FLT1");
514   fIdFLT2=gMC->VolId("FLT2");
515   fIdFLT3=gMC->VolId("FLT3");
516
517   printf("**************************************"
518          "  TOF  "
519          "**************************************\n");
520 }
521  
522 //_____________________________________________________________________________
523 void AliTOFv3::StepManager()
524 {
525   //
526   // Procedure called at each step in the Time Of Flight
527   //
528   TLorentzVector mom, pos;
529   Float_t hits[8];
530   Int_t vol[3];
531   Int_t copy, id, i;
532   Int_t *idtmed = fIdtmed->GetArray()-499;
533   if(gMC->GetMedium()==idtmed[514-1] && 
534      gMC->IsTrackEntering() && gMC->TrackCharge()
535      && gMC->CurrentVolID(copy)==fIdSens) {
536     TClonesArray &lhits = *fHits;
537     //
538     // Record only charged tracks at entrance
539     gMC->CurrentVolOffID(1,copy);
540     vol[2]=copy;
541     gMC->CurrentVolOffID(3,copy);
542     vol[1]=copy;
543     id=gMC->CurrentVolOffID(8,copy);
544     vol[0]=copy;
545     if(id==fIdFTO3) {
546       vol[0]+=22;
547       id=gMC->CurrentVolOffID(5,copy);
548       if(id==fIdFLT3) vol[1]+=6;
549     } else if (id==fIdFTO2) {
550       vol[0]+=20;
551       id=gMC->CurrentVolOffID(5,copy);
552       if(id==fIdFLT2) vol[1]+=8;
553     } else {
554       id=gMC->CurrentVolOffID(5,copy);
555       if(id==fIdFLT1) vol[1]+=14;
556     }
557     gMC->TrackPosition(pos);
558     gMC->TrackMomentum(mom);
559     //
560     Double_t ptot=mom.Rho();
561     Double_t norm=1/ptot;
562     for(i=0;i<3;++i) {
563       hits[i]=pos[i];
564       hits[i+3]=mom[i]*norm;
565     }
566     hits[6]=ptot;
567     hits[7]=pos[3];
568     new(lhits[fNhits++]) AliTOFhit(fIshunt,gAlice->CurrentTrack(),vol,hits);
569   }
570 }
571