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