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