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