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