]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFv4.cxx
9115e997d61d9c744b72f50c8a4bc923cd7c6dea
[u/mrichter/AliRoot.git] / TOF / AliTOFv4.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 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  This class contains the functions for version 4 of the Time Of Flight    //
21 //  detector.                                                                //
22 //                                                                           //
23 //  VERSION WITH 5 MODULES AND TILTED STRIPS                                 //
24 //                                                                           //
25 //   FULL COVERAGE VERSION                                                   //
26 //                                                                           //
27 //                                                                           //
28 //   Authors:                                                                //
29 //                                                                           //
30 //   Alessio Seganti                                                         //
31 //   Domenico Vicinanza                                                      //
32 //                                                                           //
33 //   University of Salerno - Italy                                           //
34 //                                                                           //
35 //   Fabrizio Pierella                                                       //
36 //   University of Bologna - Italy                                           //
37 //                                                                           //
38 //                                                                           //
39 //Begin_Html                                                                 //
40 /*                                                                           //
41 <img src="picts/AliTOFv4Class.gif">                                          //
42 */                                                                           //
43 //End_Html                                                                   //
44 //                                                                           //
45 ///////////////////////////////////////////////////////////////////////////////
46
47 #include <Riostream.h>
48 #include <stdlib.h>
49
50 #include <TBRIK.h>
51 #include <TGeometry.h>
52 #include <TLorentzVector.h>
53 #include <TNode.h>
54 #include <TObject.h>
55 #include <TVirtualMC.h>
56
57 #include "AliConst.h"
58 #include "AliRun.h"
59 #include "AliTOFv4.h"
60 #include "AliTOFConstants.h" // AdC
61 #include "AliMC.h"
62  
63 ClassImp(AliTOFv4)
64  
65 //_____________________________________________________________________________
66 AliTOFv4::AliTOFv4()
67 {
68   //
69   // Default constructor
70   //
71 }
72  
73 //_____________________________________________________________________________
74 AliTOFv4::AliTOFv4(const char *name, const char *title)
75         : AliTOF(name,title)
76 {
77   //
78   // Standard constructor
79   //
80   //
81   // Check that FRAME is there otherwise we have no place where to
82   // put TOF
83   AliModule* frame=gAlice->GetModule("FRAME");
84   if(!frame) {
85     Error("Ctor","TOF needs FRAME to be present\n");
86     exit(1);
87   } else
88     if(frame->IsVersion()!=1) {
89       Error("Ctor","FRAME version 1 needed with this version of TOF\n");
90       exit(1);
91     }
92  
93 }
94  
95 //_____________________________________________________________________________
96 void AliTOFv4::CreateGeometry()
97 {
98   //
99   // Create geometry for Time Of Flight version 0
100   //
101   //Begin_Html
102   /*
103     <img src="picts/AliTOFv4.gif">
104   */
105   //End_Html
106   //
107   // Creates common geometry
108   //
109   AliTOF::CreateGeometry();
110 }
111  
112 //_____________________________________________________________________________
113 void AliTOFv4::TOFpc(Float_t xtof, Float_t ytof, Float_t zlenC,
114                      Float_t zlenB, Float_t zlenA, Float_t ztof0)
115 {
116   //
117   // Definition of the Time Of Fligh Resistive Plate Chambers
118   // xFLT, yFLT, zFLT - sizes of TOF modules (large)
119   
120   Float_t  ycoor, zcoor;
121   Float_t  par[3];
122   Int_t    *idtmed = fIdtmed->GetArray()-499;
123   Int_t    idrotm[100];
124   Int_t    nrot = 0;
125   Float_t  hTof = fRmax-fRmin;
126   
127   Float_t radius = fRmin+2.;//cm
128
129   par[0] =  xtof * 0.5;
130   par[1] =  ytof * 0.5;
131   par[2] = zlenC * 0.5;
132   gMC->Gsvolu("FTOC", "BOX ", idtmed[506], par, 3);
133   par[2] = zlenB * 0.5;
134   gMC->Gsvolu("FTOB", "BOX ", idtmed[506], par, 3);
135   par[2] = zlenA * 0.5;
136   gMC->Gsvolu("FTOA", "BOX ", idtmed[506], par, 3);
137
138
139   // Positioning of modules
140
141   Float_t zcor1 = ztof0 - zlenC*0.5;
142   Float_t zcor2 = ztof0 - zlenC - zlenB*0.5;
143   Float_t zcor3 = 0.;
144   
145   AliMatrix(idrotm[0], 90.,  0., 0., 0., 90,-90.);
146   AliMatrix(idrotm[1], 90.,180., 0., 0., 90, 90.);
147   gMC->Gspos("FTOC", 1, "BTO1", 0,  zcor1, 0, idrotm[0], "ONLY");
148   gMC->Gspos("FTOC", 2, "BTO1", 0, -zcor1, 0, idrotm[1], "ONLY");
149   gMC->Gspos("FTOC", 1, "BTO2", 0,  zcor1, 0, idrotm[0], "ONLY");
150   gMC->Gspos("FTOC", 2, "BTO2", 0, -zcor1, 0, idrotm[1], "ONLY");
151   gMC->Gspos("FTOC", 1, "BTO3", 0,  zcor1, 0, idrotm[0], "ONLY");
152   gMC->Gspos("FTOC", 2, "BTO3", 0, -zcor1, 0, idrotm[1], "ONLY");
153   
154   gMC->Gspos("FTOB", 1, "BTO1", 0,  zcor2, 0, idrotm[0], "ONLY");
155   gMC->Gspos("FTOB", 2, "BTO1", 0, -zcor2, 0, idrotm[1], "ONLY");
156   gMC->Gspos("FTOB", 1, "BTO2", 0,  zcor2, 0, idrotm[0], "ONLY");
157   gMC->Gspos("FTOB", 2, "BTO2", 0, -zcor2, 0, idrotm[1], "ONLY");
158   gMC->Gspos("FTOB", 1, "BTO3", 0,  zcor2, 0, idrotm[0], "ONLY");
159   gMC->Gspos("FTOB", 2, "BTO3", 0, -zcor2, 0, idrotm[1], "ONLY");
160   
161   gMC->Gspos("FTOA", 0, "BTO1", 0, zcor3,  0, idrotm[0], "ONLY");
162   gMC->Gspos("FTOA", 0, "BTO2", 0, zcor3,  0, idrotm[0], "ONLY");
163   gMC->Gspos("FTOA", 0, "BTO3", 0, zcor3,  0, idrotm[0], "ONLY");
164   
165   Float_t db = 0.5;//cm
166   Float_t xFLT, xFST, yFLT, zFLTA, zFLTB, zFLTC;
167   
168   xFLT = fStripLn;
169   yFLT = ytof;
170   zFLTA = zlenA;
171   zFLTB = zlenB;
172   zFLTC = zlenC;
173   
174   xFST = xFLT-fDeadBndX*2;//cm
175
176   // Sizes of MRPC pads
177   
178   Float_t yPad = 0.505;//cm 
179   
180   // Large not sensitive volumes with Insensitive Freon
181   par[0] = xFLT*0.5;
182   par[1] = yFLT*0.5;
183   
184   if (fDebug) cout << ClassName() <<
185                 ": ************************* TOF geometry **************************"<<endl;
186   
187   par[2] = (zFLTA *0.5);
188   gMC->Gsvolu("FLTA", "BOX ", idtmed[512], par, 3); // Insensitive Freon
189   gMC->Gspos ("FLTA", 0, "FTOA", 0., 0., 0., 0, "ONLY");
190   
191   par[2] = (zFLTB * 0.5);
192   gMC->Gsvolu("FLTB", "BOX ", idtmed[512], par, 3); // Insensitive Freon
193   gMC->Gspos ("FLTB", 0, "FTOB", 0., 0., 0., 0, "ONLY");
194   
195   par[2] = (zFLTC * 0.5);
196   gMC->Gsvolu("FLTC", "BOX ", idtmed[512], par, 3); // Insensitive Freon
197   gMC->Gspos ("FLTC", 0, "FTOC", 0., 0., 0., 0, "ONLY");
198   
199   ///// Layers of Aluminum before and after detector /////
200   ///// Aluminum Box for Modules (1.8 mm thickness)  /////
201   ///// lateral walls not simulated for the time being
202   //const Float_t khAlWall = 0.18;
203   // fp to be checked
204   const Float_t khAlWall = 0.11;
205   par[0] = xFLT*0.5;
206   par[1] = khAlWall/2.;//cm
207   ycoor = -yFLT/2 + par[1];
208   par[2] = (zFLTA *0.5);
209   gMC->Gsvolu("FALA", "BOX ", idtmed[508], par, 3); // Alluminium
210   gMC->Gspos ("FALA", 1, "FLTA", 0., ycoor, 0., 0, "ONLY");
211   gMC->Gspos ("FALA", 2, "FLTA", 0.,-ycoor, 0., 0, "ONLY");
212   par[2] = (zFLTB *0.5);
213   gMC->Gsvolu("FALB", "BOX ", idtmed[508], par, 3); // Alluminium 
214   gMC->Gspos ("FALB", 1, "FLTB", 0., ycoor, 0., 0, "ONLY");
215   gMC->Gspos ("FALB", 2, "FLTB", 0.,-ycoor, 0., 0, "ONLY");
216   par[2] = (zFLTC *0.5);
217   gMC->Gsvolu("FALC", "BOX ", idtmed[508], par, 3); // Alluminium
218   gMC->Gspos ("FALC", 1, "FLTC", 0., ycoor, 0., 0, "ONLY");
219   gMC->Gspos ("FALC", 2, "FLTC", 0.,-ycoor, 0., 0, "ONLY");
220   
221   ///////////////// Detector itself //////////////////////
222
223   const Float_t  kdeadBound  =  fDeadBndZ; //cm non-sensitive between the pad edge 
224   //and the boundary of the strip
225   const Int_t    knx    = fNpadX;          // number of pads along x
226   const Int_t    knz    = fNpadZ;          // number of pads along z
227   const Float_t  kspace = fSpace;            //cm distance from the front plate of the box
228   
229   Float_t zSenStrip  = fZpad*fNpadZ;//cm
230   Float_t stripWidth = zSenStrip + 2*kdeadBound;
231   
232   par[0] = xFLT*0.5;
233   par[1] = yPad*0.5;
234   par[2] = stripWidth*0.5;
235   
236   // new description for strip volume -double stack strip-
237   // -- all constants are expressed in cm
238   // heigth of different layers
239   const Float_t khhony = 0.8     ;   // heigth of HONY  Layer
240   const Float_t khpcby = 0.08    ;   // heigth of PCB   Layer
241   const Float_t khmyly = 0.035   ;   // heigth of MYLAR Layer
242   const Float_t khgraphy = 0.02  ;   // heigth of GRAPHITE Layer
243   const Float_t khglasseiy = 0.135;   // 0.6 Ext. Glass + 1.1 i.e. (Int. Glass/2) (mm)
244   const Float_t khsensmy = 0.11  ;   // heigth of Sensitive Freon Mixture
245   const Float_t kwsensmz = 2*3.5 ;   // cm
246   const Float_t klsensmx = 48*2.5;   // cm
247   const Float_t kwpadz = 3.5;   // cm z dimension of the FPAD volume
248   const Float_t klpadx = 2.5;   // cm x dimension of the FPAD volume
249   
250   // heigth of the FSTR Volume (the strip volume)
251   const Float_t khstripy = 2*khhony+3*khpcby+4*(khmyly+khgraphy+khglasseiy)+2*khsensmy;
252   // width  of the FSTR Volume (the strip volume)
253   const Float_t kwstripz = 10.;
254   // length of the FSTR Volume (the strip volume)
255   const Float_t klstripx = 122.;
256   
257   Float_t parfp[3]={klstripx*0.5,khstripy*0.5,kwstripz*0.5};
258   // coordinates of the strip center in the strip reference frame; used for positioning
259   // internal strip volumes
260   Float_t posfp[3]={0.,0.,0.};  
261   
262   
263   // FSTR volume definition and filling this volume with non sensitive Gas Mixture
264   gMC->Gsvolu("FSTR","BOX",idtmed[512],parfp,3);
265   //-- HONY Layer definition
266   //  parfp[0] = -1;
267   parfp[1] = khhony*0.5;
268   //  parfp[2] = -1;
269   gMC->Gsvolu("FHON","BOX",idtmed[503],parfp,3);
270   // positioning 2 HONY Layers on FSTR volume
271   
272   posfp[1]=-khstripy*0.5+parfp[1];
273   gMC->Gspos("FHON",1,"FSTR",0., posfp[1],0.,0,"ONLY");
274   gMC->Gspos("FHON",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
275   
276   //-- PCB Layer definition 
277   parfp[1] = khpcby*0.5;
278   gMC->Gsvolu("FPCB","BOX",idtmed[504],parfp,3);
279   // positioning 2 PCB Layers on FSTR volume
280   posfp[1]=-khstripy*0.5+khhony+parfp[1];
281   gMC->Gspos("FPCB",1,"FSTR",0., posfp[1],0.,0,"ONLY");
282   gMC->Gspos("FPCB",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
283   // positioning the central PCB layer
284   gMC->Gspos("FPCB",3,"FSTR",0.,0.,0.,0,"ONLY");
285   
286   
287   
288   //-- MYLAR Layer definition
289   parfp[1] = khmyly*0.5;
290   gMC->Gsvolu("FMYL","BOX",idtmed[511],parfp,3);
291   // positioning 2 MYLAR Layers on FSTR volume
292   posfp[1] = -khstripy*0.5+khhony+khpcby+parfp[1];
293   gMC->Gspos("FMYL",1,"FSTR",0., posfp[1],0.,0,"ONLY");
294   gMC->Gspos("FMYL",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
295   // adding further 2 MYLAR Layers on FSTR volume
296   posfp[1] = khpcby*0.5+parfp[1];
297   gMC->Gspos("FMYL",3,"FSTR",0., posfp[1],0.,0,"ONLY");
298   gMC->Gspos("FMYL",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
299   
300   
301   //-- Graphite Layer definition
302   parfp[1] = khgraphy*0.5;
303   gMC->Gsvolu("FGRP","BOX",idtmed[502],parfp,3);
304   // positioning 2 Graphite Layers on FSTR volume
305   posfp[1] = -khstripy*0.5+khhony+khpcby+khmyly+parfp[1];
306   gMC->Gspos("FGRP",1,"FSTR",0., posfp[1],0.,0,"ONLY");
307   gMC->Gspos("FGRP",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
308   // adding further 2 Graphite Layers on FSTR volume
309   posfp[1] = khpcby*0.5+khmyly+parfp[1];
310   gMC->Gspos("FGRP",3,"FSTR",0., posfp[1],0.,0,"ONLY");
311   gMC->Gspos("FGRP",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
312   
313   
314   //-- Glass (EXT. +Semi INT.) Layer definition
315   parfp[1] = khglasseiy*0.5;
316   gMC->Gsvolu("FGLA","BOX",idtmed[514],parfp,3);
317   // positioning 2 Glass Layers on FSTR volume
318   posfp[1] = -khstripy*0.5+khhony+khpcby+khmyly+khgraphy+parfp[1];
319   gMC->Gspos("FGLA",1,"FSTR",0., posfp[1],0.,0,"ONLY");
320   gMC->Gspos("FGLA",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
321   // adding further 2 Glass Layers on FSTR volume
322   posfp[1] = khpcby*0.5+khmyly+khgraphy+parfp[1];
323   gMC->Gspos("FGLA",3,"FSTR",0., posfp[1],0.,0,"ONLY");
324   gMC->Gspos("FGLA",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
325   
326   
327   //-- Sensitive Mixture Layer definition
328   parfp[0] = klsensmx*0.5;
329   parfp[1] = khsensmy*0.5;
330   parfp[2] = kwsensmz*0.5;
331   gMC->Gsvolu("FSEN","BOX",idtmed[513],parfp,3);
332   gMC->Gsvolu("FNSE","BOX",idtmed[512],parfp,3);
333   // positioning 2 gas Layers on FSTR volume
334   // the upper is insensitive freon
335   // while the remaining is sensitive
336   posfp[1] = khpcby*0.5+khmyly+khgraphy+khglasseiy+parfp[1];
337   gMC->Gspos("FNSE",0,"FSTR", 0., posfp[1],0.,0,"ONLY");
338   gMC->Gspos("FSEN",0,"FSTR", 0.,-posfp[1],0.,0,"ONLY");
339   
340   // dividing FSEN along z in knz=2 and along x in knx=48
341   gMC->Gsdvn("FSEZ","FSEN",knz,3);
342   gMC->Gsdvn("FSEX","FSEZ",knx,1);
343   
344   // FPAD volume definition
345   parfp[0] = klpadx*0.5;   
346   parfp[1] = khsensmy*0.5;
347   parfp[2] = kwpadz*0.5;
348   gMC->Gsvolu("FPAD","BOX",idtmed[513],parfp,3);
349   // positioning the FPAD volumes on previous divisions
350   gMC->Gspos("FPAD",0,"FSEX",0.,0.,0.,0,"ONLY");
351   
352   ////  Positioning the Strips  (FSTR) in the FLT volumes  /////
353   
354   // Plate A (Central) 
355   
356   Float_t t = zFLTC+zFLTB+zFLTA*0.5+ 2*db;//Half Width of Barrel
357   
358   Float_t gap  = fGapA+0.5; //cm  updated distance between the strip axis
359   Float_t zpos = 0;
360   Float_t ang  = 0;
361   Int_t j=1; // AdC
362   nrot  = 0;
363   zcoor = 0;
364   ycoor = -14.5 + kspace ; //2 cm over front plate
365
366   AliMatrix (idrotm[0],  90.,  0.,90.,90.,0., 90.);  
367
368   Int_t centerLoc= (Int_t)(fNStripA/2.) + 1; // AdC
369
370   //gMC->Gspos("FSTR",j,"FLTA",0.,ycoor, 0.,idrotm[0],"ONLY");
371   gMC->Gspos("FSTR",centerLoc,"FLTA",0.,ycoor, 0.,idrotm[0],"ONLY"); // AdC
372   if(fDebug>=1) {
373     printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,j); // AdC
374     printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
375   }
376   zcoor -= zSenStrip;
377   //j++; // AdC
378   Int_t upDown = -1; // upDown=-1 -> Upper strip
379                      // upDown=+1 -> Lower strip
380   do{
381      ang = atan(zcoor/radius);
382      ang *= kRaddeg;
383      AliMatrix (idrotm[nrot],  90.,  0.,90.-ang,90.,-ang, 90.);  
384      AliMatrix (idrotm[nrot+1],90.,180.,90.+ang,90., ang, 90.);
385      ang /= kRaddeg;
386      ycoor = -14.5+ kspace; //2 cm over front plate
387      ycoor += (1-(upDown+1)/2)*gap;
388      //gMC->Gspos("FSTR",j  ,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY");
389      //gMC->Gspos("FSTR",j+1,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
390      gMC->Gspos("FSTR",centerLoc-j,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY"); // AdC
391      gMC->Gspos("FSTR",centerLoc+j,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY"); // AdC
392      if(fDebug>=1) {
393        printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,j); // AdC
394        printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
395      }
396      j++; //j += 2; // AdC
397      upDown*= -1; // Alternate strips 
398      zcoor = zcoor-(zSenStrip/2)/TMath::Cos(ang)-
399              upDown*gap*TMath::Tan(ang)-
400              (zSenStrip/2)/TMath::Cos(ang);
401   } while (zcoor-(stripWidth/2)*TMath::Cos(ang)>-t+zFLTC+zFLTB+db*2);
402   
403   zcoor = zcoor+(zSenStrip/2)/TMath::Cos(ang)+
404           upDown*gap*TMath::Tan(ang)+
405           (zSenStrip/2)/TMath::Cos(ang);
406
407   gap = fGapB;
408   zcoor = zcoor-(zSenStrip/2)/TMath::Cos(ang)-
409           upDown*gap*TMath::Tan(ang)-
410           (zSenStrip/2)/TMath::Cos(ang);
411
412   ang = atan(zcoor/radius);
413   ang *= kRaddeg;
414   AliMatrix (idrotm[nrot],  90.,  0.,90.-ang,90.,-ang, 90.);  
415   AliMatrix (idrotm[nrot+1],90.,180.,90.+ang,90., ang, 90.);
416   ang /= kRaddeg;
417           
418   ycoor = -14.5+ kspace; //2 cm over front plate
419   ycoor += (1-(upDown+1)/2)*gap;
420   //gMC->Gspos("FSTR",j  ,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY");
421   //gMC->Gspos("FSTR",j+1,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
422   gMC->Gspos("FSTR",centerLoc-j,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY"); // AdC
423   gMC->Gspos("FSTR",centerLoc+j,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY"); // AdC
424   if(fDebug>=1) {   
425     printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,j); // AdC
426     printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
427   }   
428   ycoor = -hTof/2.+ kspace;//2 cm over front plate
429
430   // Plate  B
431
432   nrot = 0;
433   Int_t i=1; // AdC
434   upDown = 1;
435   Float_t deadRegion = 1.0;//cm
436   
437   zpos = zcoor - (zSenStrip/2)/TMath::Cos(ang)-
438          upDown*gap*TMath::Tan(ang)-
439          (zSenStrip/2)/TMath::Cos(ang)-
440          deadRegion/TMath::Cos(ang);
441
442   ang = atan(zpos/radius);
443   ang *= kRaddeg;
444   AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
445   ang /= kRaddeg;
446   ycoor = -hTof*0.5+ kspace ; //2 cm over front plate
447   ycoor += (1-(upDown+1)/2)*gap;
448   zcoor = zpos+(zFLTA*0.5+zFLTB*0.5+db); // Moves to the system of the modulus FLTB
449   gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
450   if(fDebug>=1) {   
451      printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i); 
452      printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
453   }   
454   i++;
455   upDown*=-1;
456
457   do {
458      zpos = zpos - (zSenStrip/2)/TMath::Cos(ang)-
459             upDown*gap*TMath::Tan(ang)-
460             (zSenStrip/2)/TMath::Cos(ang);
461      ang = atan(zpos/radius);
462      ang *= kRaddeg;
463      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
464      ang /= kRaddeg;
465      Float_t deltaSpaceinB=-0.5; // [cm] to avoid overlaps with the end of freon frame
466      Float_t deltaGapinB=0.5;    // [cm] to avoid overlaps in between initial strips
467      ycoor = -hTof*0.5+ kspace+deltaSpaceinB ; //2 cm over front plate
468      ycoor += (1-(upDown+1)/2)*(gap+deltaGapinB);
469      zcoor = zpos+(zFLTA*0.5+zFLTB*0.5+db); // Moves to the system of the modulus FLTB
470      gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
471      if(fDebug>=1) {
472         printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i);
473         printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
474      }
475      upDown*=-1;
476      i++;
477   } while (TMath::Abs(ang*kRaddeg)<22.5);
478   //till we reach a tilting angle of 22.5 degrees
479
480   ycoor = -hTof*0.5+ kspace ; //2 cm over front plate
481   zpos = zpos - zSenStrip/TMath::Cos(ang);
482   // this avoid overlaps in between outer strips in plate B
483   Float_t deltaMovingUp=0.8;    // [cm]
484   Float_t deltaMovingDown=-0.5; // [cm]
485
486   do {
487      ang = atan(zpos/radius);
488      ang *= kRaddeg;
489      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
490      ang /= kRaddeg;
491      zcoor = zpos+(zFLTB/2+zFLTA/2+db);
492      gMC->Gspos("FSTR",i, "FLTB", 0., ycoor+deltaMovingDown+deltaMovingUp, zcoor,idrotm[nrot], "ONLY");
493      deltaMovingUp+=0.8; // update delta moving toward the end of the plate
494      zpos = zpos - zSenStrip/TMath::Cos(ang);
495      if(fDebug>=1) {
496        printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i);
497        printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
498      }
499      i++;
500
501   }  while (zpos-stripWidth*0.5/TMath::Cos(ang)>-t+zFLTC+db);
502
503   // Plate  C
504   
505   zpos = zpos + zSenStrip/TMath::Cos(ang);
506
507   zpos = zpos - (zSenStrip/2)/TMath::Cos(ang)+
508          gap*TMath::Tan(ang)-
509          (zSenStrip/2)/TMath::Cos(ang);
510
511   nrot = 0;
512   i=0;
513   Float_t deltaGap=-2.5; // [cm] update distance from strip center and plate
514   ycoor= -hTof*0.5+kspace+gap+deltaGap;
515
516   do {
517      i++;
518      ang = atan(zpos/radius);
519      ang *= kRaddeg;
520      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
521      ang /= kRaddeg;
522      zcoor = zpos+(zFLTC*0.5+zFLTB+zFLTA*0.5+db*2);
523      gMC->Gspos("FSTR",i, "FLTC", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
524      if(fDebug>=1) {
525        printf("%s: %f,  St. %2i, Pl.5 ",ClassName(),ang*kRaddeg,i);
526        printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
527      }
528      zpos = zpos - zSenStrip/TMath::Cos(ang);
529   }  while (zpos-stripWidth*TMath::Cos(ang)*0.5>-t);
530
531  
532   ////////// Layers after strips /////////////////
533   // Al Layer thickness (2.3mm) factor 0.7
534   
535   Float_t overSpace = fOverSpc;//cm
536   
537   par[0] = xFLT*0.5;
538   par[1] = 0.115*0.7; // factor 0.7
539   par[2] = (zFLTA *0.5);
540   ycoor = -yFLT/2 + overSpace + par[1];
541   gMC->Gsvolu("FPEA", "BOX ", idtmed[508], par, 3); // Al
542   gMC->Gspos ("FPEA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
543   par[2] = (zFLTB *0.5);
544   gMC->Gsvolu("FPEB", "BOX ", idtmed[508], par, 3); // Al
545   gMC->Gspos ("FPEB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
546   par[2] = (zFLTC *0.5);
547   gMC->Gsvolu("FPEC", "BOX ", idtmed[508], par, 3); // Al
548   gMC->Gspos ("FPEC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
549
550
551   // plexiglass thickness: 1.5 mm ; factor 0.3
552   ycoor += par[1];
553   par[0] = xFLT*0.5;
554   par[1] = 0.075*0.3; // factor 0.3 
555   par[2] = (zFLTA *0.5);
556   ycoor += par[1];
557   gMC->Gsvolu("FECA", "BOX ", idtmed[505], par, 3); // Plexigl.
558   gMC->Gspos ("FECA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
559   par[2] = (zFLTB *0.5);
560   gMC->Gsvolu("FECB", "BOX ", idtmed[505], par, 3); // Plexigl.
561   gMC->Gspos ("FECB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
562   par[2] = (zFLTC *0.5);
563   gMC->Gsvolu("FECC", "BOX ", idtmed[505], par, 3); // Plexigl.
564   gMC->Gspos ("FECC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
565   
566   // frame of Air
567   ycoor += par[1];
568   par[0] = xFLT*0.5;
569   par[1] = (yFLT/2-ycoor-khAlWall)*0.5; // Aluminum layer considered (0.18 cm)
570   par[2] = (zFLTA *0.5);
571   ycoor += par[1];
572   gMC->Gsvolu("FAIA", "BOX ", idtmed[500], par, 3); // Air
573   gMC->Gspos ("FAIA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
574   par[2] = (zFLTB *0.5);
575   gMC->Gsvolu("FAIB", "BOX ", idtmed[500], par, 3); // Air
576   gMC->Gspos ("FAIB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
577   par[2] = (zFLTC *0.5);
578   gMC->Gsvolu("FAIC", "BOX ", idtmed[500], par, 3); // Air
579   gMC->Gspos ("FAIC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
580
581   
582   // start with cards and cooling tubes
583   // finally, cards, cooling tubes and layer for thermal dispersion
584   // 3 volumes
585   // card volume definition
586   
587   // see GEOM200 in GEANT manual
588   AliMatrix(idrotm[98], 90., 0., 90., 90., 0., 0.); // 0 deg
589   
590   Float_t cardpar[3];
591   cardpar[0]= 61.;
592   cardpar[1]= 5.;
593   cardpar[2]= 0.1;
594   gMC->Gsvolu("FCAR", "BOX ", idtmed[504], cardpar, 3); // PCB Card 
595   //alu plate volume definition
596   cardpar[1]= 3.5;
597   cardpar[2]= 0.05;
598   gMC->Gsvolu("FALP", "BOX ", idtmed[508], cardpar, 3); // Alu Plate
599   
600   
601   // central module positioning (FAIA)
602   Float_t cardpos[3], aplpos2, stepforcardA=6.625;
603   cardpos[0]= 0.;
604   cardpos[1]= -0.5;
605   cardpos[2]= -53.;
606   Float_t aplpos1 = -2.;
607   Int_t icard;
608   for (icard=0; icard<15; ++icard) {
609     cardpos[2]= cardpos[2]+stepforcardA;
610     aplpos2 = cardpos[2]+0.15;
611     gMC->Gspos("FCAR",icard,"FAIA",cardpos[0],cardpos[1],cardpos[2],idrotm[98],"ONLY");
612     gMC->Gspos("FALP",icard,"FAIA",cardpos[0],aplpos1,aplpos2,idrotm[98],"ONLY");
613     
614   }
615   
616   
617   // intermediate module positioning (FAIB)
618   Float_t stepforcardB= 7.05;
619   cardpos[2]= -70.5;
620   for (icard=0; icard<19; ++icard) {
621     cardpos[2]= cardpos[2]+stepforcardB;
622     aplpos2 = cardpos[2]+0.15; 
623     gMC->Gspos("FCAR",icard,"FAIB",cardpos[0],cardpos[1],cardpos[2],idrotm[98],"ONLY");
624     gMC->Gspos("FALP",icard,"FAIB",cardpos[0],aplpos1,aplpos2,idrotm[98],"ONLY");
625   }
626   
627   
628   // outer module positioning (FAIC)
629   Float_t stepforcardC= 8.45238;
630   cardpos[2]= -88.75;
631   for (icard=0; icard<20; ++icard) {
632     cardpos[2]= cardpos[2]+stepforcardC;
633     aplpos2 = cardpos[2]+0.15;
634     gMC->Gspos("FCAR",icard,"FAIC",cardpos[0],cardpos[1],cardpos[2],idrotm[98],"ONLY");
635     gMC->Gspos("FALP",icard,"FAIC",cardpos[0],aplpos1,aplpos2,idrotm[98],"ONLY");
636   }
637   
638   // tube volume definition
639   Float_t tubepar[3];
640   tubepar[0]= 0.;
641   tubepar[1]= 0.4;
642   tubepar[2]= 61.;
643   gMC->Gsvolu("FTUB", "TUBE", idtmed[516], tubepar, 3); // cooling tubes (steel)
644   tubepar[0]= 0.;
645   tubepar[1]= 0.35;
646   tubepar[2]= 61.;
647   gMC->Gsvolu("FITU", "TUBE", idtmed[515], tubepar, 3); // cooling water
648   // positioning water tube into the steel one
649   gMC->Gspos("FITU",1,"FTUB",0.,0.,0.,0,"ONLY");
650   
651   
652   // rotation matrix
653   AliMatrix(idrotm[99], 180., 90., 90., 90., 90., 0.);
654   // central module positioning (FAIA)
655   Float_t tubepos[3], tdis=0.6;
656   tubepos[0]= 0.;
657   tubepos[1]= cardpos[1];
658   tubepos[2]= -53.+tdis;
659   //  tub1pos = 5.;
660   Int_t itub;
661   for (itub=0; itub<15; ++itub) {
662     tubepos[2]= tubepos[2]+stepforcardA;
663     gMC->Gspos("FTUB",itub,"FAIA",tubepos[0],tubepos[1],tubepos[2],idrotm[99],
664                "ONLY");
665   }
666   
667   
668   // intermediate module positioning (FAIB)
669   tubepos[2]= -70.5+tdis;
670   for (itub=0; itub<19; ++itub) {
671     tubepos[2]= tubepos[2]+stepforcardB;
672     gMC->Gspos("FTUB",itub,"FAIB",tubepos[0],tubepos[1],tubepos[2],idrotm[99],
673                "ONLY");
674   }
675   
676   // outer module positioning (FAIC)
677   tubepos[2]= -88.75+tdis;
678   for (itub=0; itub<20; ++itub) {
679     tubepos[2]= tubepos[2]+stepforcardC;
680     gMC->Gspos("FTUB",itub,"FAIC",tubepos[0],tubepos[1],tubepos[2],idrotm[99],
681                "ONLY");
682   }
683   
684 }
685
686 //_____________________________________________________________________________
687 void AliTOFv4::DrawModule() const
688 {
689   //
690   // Draw a shaded view of the Time Of Flight version 4
691   //
692   // Set everything unseen
693   gMC->Gsatt("*", "seen", -1);
694   // 
695   // Set ALIC mother transparent
696   gMC->Gsatt("ALIC","SEEN",0);
697   //
698   // Set the volumes visible
699   gMC->Gsatt("ALIC","SEEN",0);
700
701   gMC->Gsatt("FTOA","SEEN",1);
702   gMC->Gsatt("FTOB","SEEN",1);
703   gMC->Gsatt("FTOC","SEEN",1);
704   gMC->Gsatt("FLTA","SEEN",1);
705   gMC->Gsatt("FLTB","SEEN",1);
706   gMC->Gsatt("FLTC","SEEN",1);
707   gMC->Gsatt("FPLA","SEEN",1);
708   gMC->Gsatt("FPLB","SEEN",1);
709   gMC->Gsatt("FPLC","SEEN",1);
710   gMC->Gsatt("FSTR","SEEN",1);
711   gMC->Gsatt("FPEA","SEEN",1);
712   gMC->Gsatt("FPEB","SEEN",1);
713   gMC->Gsatt("FPEC","SEEN",1);
714   
715   gMC->Gsatt("FLZ1","SEEN",0);
716   gMC->Gsatt("FLZ2","SEEN",0);
717   gMC->Gsatt("FLZ3","SEEN",0);
718   gMC->Gsatt("FLX1","SEEN",0);
719   gMC->Gsatt("FLX2","SEEN",0);
720   gMC->Gsatt("FLX3","SEEN",0);
721   gMC->Gsatt("FPAD","SEEN",0);
722
723   gMC->Gdopt("hide", "on");
724   gMC->Gdopt("shad", "on");
725   gMC->Gsatt("*", "fill", 7);
726   gMC->SetClipBox(".");
727   gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
728   gMC->DefaultRange();
729   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
730   gMC->Gdhead(1111, "Time Of Flight");
731   gMC->Gdman(18, 4, "MAN");
732   gMC->Gdopt("hide","off");
733 }
734 //_____________________________________________________________________________
735 void AliTOFv4::DrawDetectorModules()
736 {
737 //
738 // Draw a shaded view of the TOF detector version 4
739 //
740  
741  
742 //Set ALIC mother transparent
743  gMC->Gsatt("ALIC","SEEN",0);
744
745 //
746 //Set volumes visible
747 // 
748 //=====> Level 1
749   // Level 1 for TOF volumes
750   gMC->Gsatt("B077","seen",0);
751  
752  
753 //==========> Level 2
754   // Level 2
755   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
756   gMC->Gsatt("B071","seen",0);
757   gMC->Gsatt("B074","seen",0);
758   gMC->Gsatt("B075","seen",0);
759   gMC->Gsatt("B080","seen",0); // B080 does not has sub-level                
760
761
762   // Level 2 of B071
763   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
764   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
765   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
766   gMC->Gsatt("B069","seen",-1); // all B069 sub-levels skipped   -
767   gMC->Gsatt("B056","seen",0);  // B056 does not has sub-levels  -
768   gMC->Gsatt("B059","seen",-1); // all B059 sub-levels skipped   -
769   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
770   gMC->Gsatt("BTR1","seen",0);  // BTR1 do not have sub-levels   -
771   gMC->Gsatt("BTO1","seen",0);
772
773  
774   // Level 2 of B074
775   gMC->Gsatt("BTR2","seen",0); // BTR2 does not has sub-levels -
776   gMC->Gsatt("BTO2","seen",0);
777
778   // Level 2 of B075
779   gMC->Gsatt("BTR3","seen",0); // BTR3 do not have sub-levels -
780   gMC->Gsatt("BTO3","seen",0);
781
782 // ==================> Level 3
783   // Level 3 of B071 / Level 2 of BTO1
784   gMC->Gsatt("FTOC","seen",-2);
785   gMC->Gsatt("FTOB","seen",-2);
786   gMC->Gsatt("FTOA","seen",-2);
787  
788   // Level 3 of B074 / Level 2 of BTO2
789   // -> cfr previous settings
790  
791   // Level 3 of B075 / Level 2 of BTO3
792   // -> cfr previous settings
793
794   gMC->Gdopt("hide","on");
795   gMC->Gdopt("shad","on");
796   gMC->Gsatt("*", "fill", 5);
797   gMC->SetClipBox(".");
798   gMC->SetClipBox("*", 0, 1000, 0, 1000, 0, 1000);
799   gMC->DefaultRange();
800   gMC->Gdraw("alic", 45, 40, 0, 10, 10, .015, .015);
801   gMC->Gdhead(1111,"TOF detector V1");
802   gMC->Gdman(18, 4, "MAN");
803   gMC->Gdopt("hide","off");
804 }                                 
805
806 //_____________________________________________________________________________
807 void AliTOFv4::DrawDetectorStrips()
808 {
809 //
810 // Draw a shaded view of the TOF strips for version 4
811 //
812  
813 //Set ALIC mother transparent
814  gMC->Gsatt("ALIC","SEEN",0);
815
816 //
817 //Set volumes visible 
818 //=====> Level 1
819   // Level 1 for TOF volumes
820   gMC->Gsatt("B077","seen",0);
821   
822 //==========> Level 2
823   // Level 2
824   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
825   gMC->Gsatt("B071","seen",0);
826   gMC->Gsatt("B074","seen",0);
827   gMC->Gsatt("B075","seen",0);
828   gMC->Gsatt("B080","seen",0); // B080 does not has sub-level
829
830   // Level 2 of B071
831   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
832   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
833   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
834   gMC->Gsatt("B069","seen",-1); // all B069 sub-levels skipped   -
835   gMC->Gsatt("B056","seen",0);  // B056 does not has sub-levels  -
836   gMC->Gsatt("B059","seen",-1); // all B059 sub-levels skipped   -
837   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
838   gMC->Gsatt("BTR1","seen",0);  // BTR1 do not have sub-levels   -
839   gMC->Gsatt("BTO1","seen",0);
840
841 // ==================> Level 3
842   // Level 3 of B071 / Level 2 of BTO1
843   gMC->Gsatt("FTOC","seen",0);
844   gMC->Gsatt("FTOB","seen",0);
845   gMC->Gsatt("FTOA","seen",0);
846  
847   // Level 3 of B074 / Level 2 of BTO2
848   // -> cfr previous settings
849  
850   // Level 3 of B075 / Level 2 of BTO3
851   // -> cfr previous settings
852
853
854 // ==========================> Level 4
855   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOC
856   gMC->Gsatt("FLTC","seen",0);
857   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOB
858   gMC->Gsatt("FLTB","seen",0);
859   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOA
860   gMC->Gsatt("FLTA","seen",0);
861  
862   // Level 4 of B074 / Level 3 of BTO2 / Level 2 of FTOC
863   // -> cfr previous settings
864   // Level 4 of B074 / Level 3 of BTO2 / Level 2 of FTOB
865   // -> cfr previous settings
866  
867   // Level 4 of B075 / Level 3 of BTO3 / Level 2 of FTOC
868   // -> cfr previous settings
869
870 //======================================> Level 5
871   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOC / Level 2 of FLTC
872   gMC->Gsatt("FALC","seen",0); // no children for FALC
873   gMC->Gsatt("FSTR","seen",-2);
874   gMC->Gsatt("FPEC","seen",0); // no children for FPEC
875   gMC->Gsatt("FECC","seen",0); // no children for FECC
876   gMC->Gsatt("FWAC","seen",0); // no children for FWAC
877   gMC->Gsatt("FAIC","seen",0); // no children for FAIC
878
879   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOB / Level 2 of FLTB
880   gMC->Gsatt("FALB","seen",0); // no children for FALB
881 //-->  gMC->Gsatt("FSTR","seen",-2);
882
883
884   // -> cfr previous settings
885   gMC->Gsatt("FPEB","seen",0); // no children for FPEB
886   gMC->Gsatt("FECB","seen",0); // no children for FECB
887   gMC->Gsatt("FWAB","seen",0); // no children for FWAB
888   gMC->Gsatt("FAIB","seen",0); // no children for FAIB
889  
890   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOA / Level 2 of FLTA
891   gMC->Gsatt("FALA","seen",0); // no children for FALB
892 //-->  gMC->Gsatt("FSTR","seen",-2);
893   // -> cfr previous settings
894   gMC->Gsatt("FPEA","seen",0); // no children for FPEA
895   gMC->Gsatt("FECA","seen",0); // no children for FECA
896   gMC->Gsatt("FWAA","seen",0); // no children for FWAA
897   gMC->Gsatt("FAIA","seen",0); // no children for FAIA
898
899   // Level 2 of B074
900   gMC->Gsatt("BTR2","seen",0); // BTR2 does not has sub-levels -
901   gMC->Gsatt("BTO2","seen",0);
902
903   // Level 2 of B075
904   gMC->Gsatt("BTR3","seen",0); // BTR3 do not have sub-levels -
905   gMC->Gsatt("BTO3","seen",0);
906
907 // for others Level 5, cfr. previous settings
908
909   gMC->Gdopt("hide","on");
910   gMC->Gdopt("shad","on");
911   gMC->Gsatt("*", "fill", 5);
912   gMC->SetClipBox(".");
913   gMC->SetClipBox("*", 0, 1000, 0, 1000, 0, 1000);
914   gMC->DefaultRange();
915   gMC->Gdraw("alic", 45, 40, 0, 10, 10, .015, .015);
916   gMC->Gdhead(1111,"TOF Strips V1");
917   gMC->Gdman(18, 4, "MAN");
918   gMC->Gdopt("hide","off");
919 }
920
921 //_____________________________________________________________________________
922 void AliTOFv4::CreateMaterials()
923 {
924   //
925   // Define materials for the Time Of Flight
926   //
927   AliTOF::CreateMaterials();
928 }
929  
930 //_____________________________________________________________________________
931 void AliTOFv4::Init()
932 {
933   //
934   // Initialise the detector after the geometry has been defined
935   //
936   if(fDebug) {   
937     printf("%s: **************************************"
938            "  TOF  "
939            "**************************************\n",ClassName());
940     printf("\n%s:   Version 4 of TOF initialing, "
941                 "symmetric TOF - Full Coverage version\n",ClassName());
942   }
943
944   AliTOF::Init();
945
946   fIdFTOA = gMC->VolId("FTOA");
947   fIdFTOB = gMC->VolId("FTOB");
948   fIdFTOC = gMC->VolId("FTOC");
949   fIdFLTA = gMC->VolId("FLTA");
950   fIdFLTB = gMC->VolId("FLTB");
951   fIdFLTC = gMC->VolId("FLTC");
952
953   if(fDebug) {   
954     printf("%s: **************************************"
955            "  TOF  "
956            "**************************************\n",ClassName());
957   }
958 }
959  
960 //_____________________________________________________________________________
961 void AliTOFv4::StepManager()
962 {
963   //
964   // Procedure called at each step in the Time Of Flight
965   //
966   TLorentzVector mom, pos;
967   Float_t xm[3],pm[3],xpad[3],ppad[3];
968   Float_t hits[13],phi,phid,z;
969   Int_t   vol[5];
970   Int_t   sector, plate, padx, padz, strip;
971   Int_t   copy, padzid, padxid, stripid, i;
972   Int_t   *idtmed = fIdtmed->GetArray()-499;
973   Float_t incidenceAngle;
974   
975   if(gMC->CurrentMedium()==idtmed[513] && 
976      gMC->IsTrackEntering() && gMC->TrackCharge()
977      && gMC->CurrentVolID(copy)==fIdSens) 
978   {    
979     // getting information about hit volumes
980     
981     padzid=gMC->CurrentVolOffID(2,copy);
982     padz=copy; 
983     
984     padxid=gMC->CurrentVolOffID(1,copy);
985     padx=copy; 
986     
987     stripid=gMC->CurrentVolOffID(4,copy);
988     strip=copy; 
989
990     gMC->TrackPosition(pos);
991     gMC->TrackMomentum(mom);
992
993 //    Double_t NormPos=1./pos.Rho();
994     Double_t normMom=1./mom.Rho();
995
996 //  getting the cohordinates in pad ref system
997     xm[0] = (Float_t)pos.X();
998     xm[1] = (Float_t)pos.Y();
999     xm[2] = (Float_t)pos.Z();
1000
1001     pm[0] = (Float_t)mom.X()*normMom;
1002     pm[1] = (Float_t)mom.Y()*normMom;
1003     pm[2] = (Float_t)mom.Z()*normMom;
1004  
1005     gMC->Gmtod(xm,xpad,1);
1006     gMC->Gmtod(pm,ppad,2);
1007
1008     incidenceAngle = TMath::ACos(ppad[1])*kRaddeg;
1009
1010     z = pos[2];
1011
1012     plate = 0;  
1013     if (TMath::Abs(z) <=  fZlenA*0.5)  plate = 2; //3; // AdC
1014     if (z < (fZlenA*0.5+fZlenB) && 
1015         z >  fZlenA*0.5)               plate = 1; //4; // AdC
1016     if (z >-(fZlenA*0.5+fZlenB) &&
1017         z < -fZlenA*0.5)               plate = 3; //2; // AdC
1018     if (z > (fZlenA*0.5+fZlenB))       plate = 0; //5; // AdC
1019     if (z <-(fZlenA*0.5+fZlenB))       plate = 4; //1; // AdC
1020
1021     if (plate==0) strip=AliTOFConstants::fgkNStripC-strip; // AdC
1022     else if (plate==1) strip=AliTOFConstants::fgkNStripB-strip; // AdC
1023     else strip--; // AdC
1024
1025     if (z<=0.) padx=AliTOFConstants::fgkNpadX-padx; // AdC
1026     else padx--; // AdC
1027
1028     if (plate==3 || plate==4) padz=AliTOFConstants::fgkNpadZ-padz; // AdC
1029     else padz--; // AdC
1030
1031     phi = pos.Phi();
1032     if (phi>=0.) phid = phi*kRaddeg; //+180.; // AdC
1033     else phid = phi*kRaddeg + 360.; // AdC
1034     sector = Int_t (phid/20.); // AdC
1035     //sector++; // AdC
1036
1037     for(i=0;i<3;++i) {
1038       hits[i]   = pos[i];
1039       hits[i+3] = pm[i];
1040     }
1041
1042     hits[6] = mom.Rho();
1043     hits[7] = pos[3];
1044     hits[8] = xpad[0];
1045     hits[9] = xpad[1];
1046     hits[10]= xpad[2];
1047     hits[11]= incidenceAngle;
1048     hits[12]= gMC->Edep();
1049     
1050     vol[0]= sector;
1051     vol[1]= plate;
1052     vol[2]= strip;
1053     vol[3]= padx;
1054     vol[4]= padz;
1055     
1056     AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
1057   }
1058 }