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