]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFv4T0.cxx
Updated SDigitizer; Added AliTOFanalyzeSDigits.C macro
[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; //cm  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      ycoor = -hTof*0.5+ kspace ; //2 cm over front plate
531      ycoor += (1-(upDown+1)/2)*gap;
532      zcoor = zpos+(zFLTA*0.5+zFLTB*0.5+db); // Moves to the system of the modulus FLTB
533      gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
534      if(fDebug) {
535         printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i);
536         printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
537      }
538      upDown*=-1;
539      i++;
540   } while (TMath::Abs(ang*kRaddeg)<22.5);
541   //till we reach a tilting angle of 22.5 degrees
542
543   ycoor = -hTof*0.5+ kspace ; //2 cm over front plate
544   zpos = zpos - zSenStrip/TMath::Cos(ang);
545
546   do {
547      ang = atan(zpos/radius);
548      ang *= kRaddeg;
549      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
550      ang /= kRaddeg;
551      zcoor = zpos+(zFLTB/2+zFLTA/2+db);
552      gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
553      zpos = zpos - zSenStrip/TMath::Cos(ang);
554      if(fDebug) {
555        printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i);
556        printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
557      }
558      i++;
559
560   }  while (zpos-stripWidth*0.5/TMath::Cos(ang)>-t+zFLTC+db);
561
562   // Plate  C
563   
564   zpos = zpos + zSenStrip/TMath::Cos(ang);
565
566   zpos = zpos - (zSenStrip/2)/TMath::Cos(ang)+
567          gap*TMath::Tan(ang)-
568          (zSenStrip/2)/TMath::Cos(ang);
569
570   nrot = 0;
571   i=0;
572   ycoor= -hTof*0.5+kspace+gap;
573
574   do {
575      i++;
576      ang = atan(zpos/radius);
577      ang *= kRaddeg;
578      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
579      ang /= kRaddeg;
580      zcoor = zpos+(zFLTC*0.5+zFLTB+zFLTA*0.5+db*2);
581      gMC->Gspos("FSTR",i, "FLTC", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
582      if(fDebug) {
583        printf("%s: %f,  St. %2i, Pl.5 ",ClassName(),ang*kRaddeg,i);
584        printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
585      }
586      zpos = zpos - zSenStrip/TMath::Cos(ang);
587   }  while (zpos-stripWidth*TMath::Cos(ang)*0.5>-t);
588
589
590 ////////// Layers after strips /////////////////
591 // honeycomb (Polyethilene) Layer after (1.2cm)
592
593   Float_t overSpace = fOverSpc;//cm
594
595   par[0] = xFLT*0.5;
596   par[1] = 0.6;
597   par[2] = (zFLTA *0.5);
598   ycoor = -yFLT/2 + overSpace + par[1];
599   gMC->Gsvolu("FPEA", "BOX ", idtmed[503], par, 3); // Hony
600   gMC->Gspos ("FPEA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
601   par[2] = (zFLTB *0.5);
602   gMC->Gsvolu("FPEB", "BOX ", idtmed[503], par, 3); // Hony
603   gMC->Gspos ("FPEB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
604   par[2] = (zFLTC *0.5);
605   gMC->Gsvolu("FPEC", "BOX ", idtmed[503], par, 3); // Hony
606   gMC->Gspos ("FPEC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
607
608 // Electronics (Cu) after
609   ycoor += par[1];
610   par[0] = xFLT*0.5;
611   par[1] = 1.43*0.05*0.5; // 5% of X0
612   par[2] = (zFLTA *0.5);
613   ycoor += par[1];
614   gMC->Gsvolu("FECA", "BOX ", idtmed[501], par, 3); // Cu
615   gMC->Gspos ("FECA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
616   par[2] = (zFLTB *0.5);
617   gMC->Gsvolu("FECB", "BOX ", idtmed[501], par, 3); // Cu
618   gMC->Gspos ("FECB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
619   par[2] = (zFLTC *0.5);
620   gMC->Gsvolu("FECC", "BOX ", idtmed[501], par, 3); // Cu
621   gMC->Gspos ("FECC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
622
623 // cooling WAter after
624   ycoor += par[1];
625   par[0] = xFLT*0.5;
626   par[1] = 36.1*0.02*0.5; // 2% of X0
627   par[2] = (zFLTA *0.5);
628   ycoor += par[1];
629   gMC->Gsvolu("FWAA", "BOX ", idtmed[515], par, 3); // Water
630   gMC->Gspos ("FWAA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
631   par[2] = (zFLTB *0.5);
632   gMC->Gsvolu("FWAB", "BOX ", idtmed[515], par, 3); // Water
633   gMC->Gspos ("FWAB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
634   par[2] = (zFLTC *0.5);
635   gMC->Gsvolu("FWAC", "BOX ", idtmed[515], par, 3); // Water
636   gMC->Gspos ("FWAC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
637
638 // frame of Air
639   ycoor += par[1];
640   par[0] = xFLT*0.5;
641   par[1] = (yFLT/2-ycoor-0.2)*0.5; // Aluminum layer considered (0.2 cm)
642   par[2] = (zFLTA *0.5);
643   ycoor += par[1];
644   gMC->Gsvolu("FAIA", "BOX ", idtmed[500], par, 3); // Air
645   gMC->Gspos ("FAIA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
646   par[2] = (zFLTB *0.5);
647   gMC->Gsvolu("FAIB", "BOX ", idtmed[500], par, 3); // Air
648   gMC->Gspos ("FAIB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
649   par[2] = (zFLTC *0.5);
650   gMC->Gsvolu("FAIC", "BOX ", idtmed[500], par, 3); // Air
651   gMC->Gspos ("FAIC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
652 /* fp
653 //Back Plate honycomb (2cm)
654   par[0] = -1;
655   par[1] = 2 *0.5;
656   par[2] = -1;
657   ycoor = yFLT/2 - par[1];
658   gMC->Gsvolu("FBPA", "BOX ", idtmed[503], par, 3); // Hony
659   gMC->Gspos ("FBPA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
660   gMC->Gsvolu("FBPB", "BOX ", idtmed[503], par, 3); // Hony
661   gMC->Gspos ("FBPB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
662   gMC->Gsvolu("FBPC", "BOX ", idtmed[503], par, 3); // Hony
663   gMC->Gspos ("FBPC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
664 fp */
665 }
666
667 //_____________________________________________________________________________
668 void AliTOFv4T0::DrawModule() const
669 {
670   //
671   // Draw a shaded view of the Time Of Flight version 4
672   //
673   // Set everything unseen
674   gMC->Gsatt("*", "seen", -1);
675   // 
676   // Set ALIC mother transparent
677   gMC->Gsatt("ALIC","SEEN",0);
678   //
679   // Set the volumes visible
680   gMC->Gsatt("ALIC","SEEN",0);
681
682   gMC->Gsatt("FTOA","SEEN",1);
683   gMC->Gsatt("FTOB","SEEN",1);
684   gMC->Gsatt("FTOC","SEEN",1);
685   gMC->Gsatt("FLTA","SEEN",1);
686   gMC->Gsatt("FLTB","SEEN",1);
687   gMC->Gsatt("FLTC","SEEN",1);
688   gMC->Gsatt("FPLA","SEEN",1);
689   gMC->Gsatt("FPLB","SEEN",1);
690   gMC->Gsatt("FPLC","SEEN",1);
691   gMC->Gsatt("FSTR","SEEN",1);
692   gMC->Gsatt("FPEA","SEEN",1);
693   gMC->Gsatt("FPEB","SEEN",1);
694   gMC->Gsatt("FPEC","SEEN",1);
695   
696   gMC->Gsatt("FLZ1","SEEN",0);
697   gMC->Gsatt("FLZ2","SEEN",0);
698   gMC->Gsatt("FLZ3","SEEN",0);
699   gMC->Gsatt("FLX1","SEEN",0);
700   gMC->Gsatt("FLX2","SEEN",0);
701   gMC->Gsatt("FLX3","SEEN",0);
702   gMC->Gsatt("FPAD","SEEN",0);
703
704   gMC->Gdopt("hide", "on");
705   gMC->Gdopt("shad", "on");
706   gMC->Gsatt("*", "fill", 7);
707   gMC->SetClipBox(".");
708   gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
709   gMC->DefaultRange();
710   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
711   gMC->Gdhead(1111, "Time Of Flight");
712   gMC->Gdman(18, 4, "MAN");
713   gMC->Gdopt("hide","off");
714 }
715 //_____________________________________________________________________________
716 void AliTOFv4T0::DrawDetectorModules()
717 {
718 //
719 // Draw a shaded view of the TOF detector version 4
720 //
721  
722  AliMC* pMC = AliMC::GetMC();
723  
724 //Set ALIC mother transparent
725  pMC->Gsatt("ALIC","SEEN",0);
726
727 //
728 //Set volumes visible
729 // 
730 //=====> Level 1
731   // Level 1 for TOF volumes
732   gMC->Gsatt("B077","seen",0);
733  
734  
735 //==========> Level 2
736   // Level 2
737   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
738   gMC->Gsatt("B071","seen",0);
739   gMC->Gsatt("B074","seen",0);
740   gMC->Gsatt("B075","seen",0);
741   gMC->Gsatt("B080","seen",0); // B080 does not has sub-level                
742
743
744   // Level 2 of B071
745   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
746   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
747   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
748   gMC->Gsatt("B069","seen",-1); // all B069 sub-levels skipped   -
749   gMC->Gsatt("B056","seen",0);  // B056 does not has sub-levels  -
750   gMC->Gsatt("B059","seen",-1); // all B059 sub-levels skipped   -
751   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
752   gMC->Gsatt("BTR1","seen",0);  // BTR1 do not have sub-levels   -
753   gMC->Gsatt("BTO1","seen",0);
754
755  
756   // Level 2 of B074
757   gMC->Gsatt("BTR2","seen",0); // BTR2 does not has sub-levels -
758   gMC->Gsatt("BTO2","seen",0);
759
760   // Level 2 of B075
761   gMC->Gsatt("BTR3","seen",0); // BTR3 do not have sub-levels -
762   gMC->Gsatt("BTO3","seen",0);
763
764 // ==================> Level 3
765   // Level 3 of B071 / Level 2 of BTO1
766   gMC->Gsatt("FTOC","seen",-2);
767   gMC->Gsatt("FTOB","seen",-2);
768   gMC->Gsatt("FTOA","seen",-2);
769  
770   // Level 3 of B074 / Level 2 of BTO2
771   // -> cfr previous settings
772  
773   // Level 3 of B075 / Level 2 of BTO3
774   // -> cfr previous settings
775
776   gMC->Gdopt("hide","on");
777   gMC->Gdopt("shad","on");
778   gMC->Gsatt("*", "fill", 5);
779   gMC->SetClipBox(".");
780   gMC->SetClipBox("*", 0, 1000, 0, 1000, 0, 1000);
781   gMC->DefaultRange();
782   gMC->Gdraw("alic", 45, 40, 0, 10, 10, .015, .015);
783   gMC->Gdhead(1111,"TOF detector V1");
784   gMC->Gdman(18, 4, "MAN");
785   gMC->Gdopt("hide","off");
786 }                                 
787
788 //_____________________________________________________________________________
789 void AliTOFv4T0::DrawDetectorStrips()
790 {
791   //
792   // Draw a shaded view of the TOF strips for version 4
793   //
794   
795   AliMC* pMC = AliMC::GetMC();
796  
797   //Set ALIC mother transparent
798   pMC->Gsatt("ALIC","SEEN",0);
799   
800   //
801   //Set volumes visible 
802   //=====> Level 1
803   // Level 1 for TOF volumes
804   gMC->Gsatt("B077","seen",0);
805   
806   //==========> Level 2
807   // Level 2
808   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
809   gMC->Gsatt("B071","seen",0);
810   gMC->Gsatt("B074","seen",0);
811   gMC->Gsatt("B075","seen",0);
812   gMC->Gsatt("B080","seen",0); // B080 does not has sub-level
813   
814   // Level 2 of B071
815   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
816   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
817   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
818   gMC->Gsatt("B069","seen",-1); // all B069 sub-levels skipped   -
819   gMC->Gsatt("B056","seen",0);  // B056 does not has sub-levels  -
820   gMC->Gsatt("B059","seen",-1); // all B059 sub-levels skipped   -
821   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
822   gMC->Gsatt("BTR1","seen",0);  // BTR1 do not have sub-levels   -
823   gMC->Gsatt("BTO1","seen",0);
824   
825   // ==================> Level 3
826   // Level 3 of B071 / Level 2 of BTO1
827   gMC->Gsatt("FTOC","seen",0);
828   gMC->Gsatt("FTOB","seen",0);
829   gMC->Gsatt("FTOA","seen",0);
830   
831   // Level 3 of B074 / Level 2 of BTO2
832   // -> cfr previous settings
833   
834   // Level 3 of B075 / Level 2 of BTO3
835   // -> cfr previous settings
836   
837   
838   // ==========================> Level 4
839   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOC
840   gMC->Gsatt("FLTC","seen",0);
841   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOB
842   gMC->Gsatt("FLTB","seen",0);
843   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOA
844   gMC->Gsatt("FLTA","seen",0);
845   
846   // Level 4 of B074 / Level 3 of BTO2 / Level 2 of FTOC
847   // -> cfr previous settings
848   // Level 4 of B074 / Level 3 of BTO2 / Level 2 of FTOB
849   // -> cfr previous settings
850   
851   // Level 4 of B075 / Level 3 of BTO3 / Level 2 of FTOC
852   // -> cfr previous settings
853   
854   //======================================> Level 5
855   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOC / Level 2 of FLTC
856   gMC->Gsatt("FALC","seen",0); // no children for FALC
857   gMC->Gsatt("FSTR","seen",-2);
858   gMC->Gsatt("FPEC","seen",0); // no children for FPEC
859   gMC->Gsatt("FECC","seen",0); // no children for FECC
860   gMC->Gsatt("FWAC","seen",0); // no children for FWAC
861   gMC->Gsatt("FAIC","seen",0); // no children for FAIC
862   
863   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOB / Level 2 of FLTB
864   gMC->Gsatt("FALB","seen",0); // no children for FALB
865   //-->  gMC->Gsatt("FSTR","seen",-2);
866   
867   
868   // -> cfr previous settings
869   gMC->Gsatt("FPEB","seen",0); // no children for FPEB
870   gMC->Gsatt("FECB","seen",0); // no children for FECB
871   gMC->Gsatt("FWAB","seen",0); // no children for FWAB
872   gMC->Gsatt("FAIB","seen",0); // no children for FAIB
873   
874   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOA / Level 2 of FLTA
875   gMC->Gsatt("FALA","seen",0); // no children for FALB
876   //-->  gMC->Gsatt("FSTR","seen",-2);
877   // -> cfr previous settings
878   gMC->Gsatt("FPEA","seen",0); // no children for FPEA
879   gMC->Gsatt("FECA","seen",0); // no children for FECA
880   gMC->Gsatt("FWAA","seen",0); // no children for FWAA
881   gMC->Gsatt("FAIA","seen",0); // no children for FAIA
882   
883   // Level 2 of B074
884   gMC->Gsatt("BTR2","seen",0); // BTR2 does not has sub-levels -
885   gMC->Gsatt("BTO2","seen",0);
886   
887   // Level 2 of B075
888   gMC->Gsatt("BTR3","seen",0); // BTR3 do not have sub-levels -
889   gMC->Gsatt("BTO3","seen",0);
890   
891   // for others Level 5, cfr. previous settings
892
893   gMC->Gdopt("hide","on");
894   gMC->Gdopt("shad","on");
895   gMC->Gsatt("*", "fill", 5);
896   gMC->SetClipBox(".");
897   gMC->SetClipBox("*", 0, 1000, 0, 1000, 0, 1000);
898   gMC->DefaultRange();
899   gMC->Gdraw("alic", 45, 40, 0, 10, 10, .015, .015);
900   gMC->Gdhead(1111,"TOF Strips V1");
901   gMC->Gdman(18, 4, "MAN");
902   gMC->Gdopt("hide","off");
903 }
904
905 //_____________________________________________________________________________
906 void AliTOFv4T0::CreateMaterials()
907 {
908   //
909   // Define materials for the Time Of Flight
910   //
911   AliTOF::CreateMaterials();
912 }
913
914 //_____________________________________________________________________________
915 void AliTOFv4T0::Init()
916 {
917   //
918   // Initialise the detector after the geometry has been defined
919   //
920   if(fDebug) {   
921     printf("%s: **************************************"
922            "  TOF  "
923            "**************************************\n",ClassName());
924     printf("\n%s:   Version 4 of TOF initialing, "
925            "symmetric TOF - Full Coverage version\n",ClassName());
926   }
927   
928   AliTOF::Init();
929   
930   fIdFTOA = gMC->VolId("FTOA");
931   fIdFTOB = gMC->VolId("FTOB");
932   fIdFTOC = gMC->VolId("FTOC");
933   fIdFLTA = gMC->VolId("FLTA");
934   fIdFLTB = gMC->VolId("FLTB");
935   fIdFLTC = gMC->VolId("FLTC");
936
937   if(fDebug) {   
938     printf("%s: **************************************"
939            "  TOF  "
940            "**************************************\n",ClassName());
941   }
942 }
943  
944 //_____________________________________________________________________________
945 void AliTOFv4T0::StepManager()
946 {
947   //
948   // Procedure called at each step in the Time Of Flight
949   //
950   TLorentzVector mom, pos;
951   Float_t xm[3],pm[3],xpad[3],ppad[3];
952   Float_t hits[14],phi,phid,z;
953   Int_t   vol[5];
954   Int_t   sector, plate, padx, padz, strip;
955   Int_t   copy, padzid, padxid, stripid, i;
956   Int_t   *idtmed = fIdtmed->GetArray()-499;
957   Float_t incidenceAngle;
958   
959   if(gMC->GetMedium()==idtmed[513] && 
960      gMC->IsTrackEntering() && gMC->TrackCharge()
961      && gMC->CurrentVolID(copy)==fIdSens) 
962   {    
963     // getting information about hit volumes
964     
965     padzid=gMC->CurrentVolOffID(2,copy);
966     padz=copy;  
967     
968     padxid=gMC->CurrentVolOffID(1,copy);
969     padx=copy;  
970     
971     stripid=gMC->CurrentVolOffID(4,copy);
972     strip=copy;  
973
974     gMC->TrackPosition(pos);
975     gMC->TrackMomentum(mom);
976
977 //    Double_t NormPos=1./pos.Rho();
978     Double_t normMom=1./mom.Rho();
979
980 //  getting the cohordinates in pad ref system
981     xm[0] = (Float_t)pos.X();
982     xm[1] = (Float_t)pos.Y();
983     xm[2] = (Float_t)pos.Z();
984
985     pm[0] = (Float_t)mom.X()*normMom;
986     pm[1] = (Float_t)mom.Y()*normMom;
987     pm[2] = (Float_t)mom.Z()*normMom;
988  
989     gMC->Gmtod(xm,xpad,1);
990     gMC->Gmtod(pm,ppad,2);
991
992     incidenceAngle = TMath::ACos(ppad[1])*kRaddeg;
993
994     z = pos[2];
995
996     plate = 0;   
997     if (TMath::Abs(z) <=  fZlenA*0.5)  plate = 3;
998     if (z < (fZlenA*0.5+fZlenB) && 
999         z >  fZlenA*0.5)               plate = 4;
1000     if (z >-(fZlenA*0.5+fZlenB) &&
1001         z < -fZlenA*0.5)               plate = 2;
1002     if (z > (fZlenA*0.5+fZlenB))       plate = 5;
1003     if (z <-(fZlenA*0.5+fZlenB))       plate = 1;
1004
1005     phi = pos.Phi();
1006     phid = phi*kRaddeg+180.;
1007     sector = Int_t (phid/20.);
1008     sector++;
1009
1010     for(i=0;i<3;++i) {
1011       hits[i]   = pos[i];
1012       hits[i+3] = pm[i];
1013     }
1014
1015     hits[6] = mom.Rho();
1016     hits[7] = pos[3];
1017     hits[8] = xpad[0];
1018     hits[9] = xpad[1];
1019     hits[10]= xpad[2];
1020     hits[11]= incidenceAngle;
1021     hits[12]= gMC->Edep();
1022     hits[13]= gMC->TrackLength();
1023     
1024     vol[0]= sector;
1025     vol[1]= plate;
1026     vol[2]= strip;
1027     vol[3]= padx;
1028     vol[4]= padz;
1029     
1030     AddT0Hit(gAlice->CurrentTrack(),vol, hits);
1031   }
1032 }