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