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