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