]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFv2FHoles.cxx
Minor corrections (Sun)
[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+1.; //cm  updated distance between the strip axis
447   // 1 cm is a special value exclusively for AliTOFv2FHoles geometry
448   Float_t zpos = 0;
449   Float_t ang  = 0;
450   Int_t i=1,j=1;
451   nrot  = 0;
452   zcoor = 0;
453   ycoor = -14.5 + kspace ; //2 cm over front plate
454
455   AliMatrix (idrotm[0],  90.,  0.,90.,90.,0., 90.);   
456   gMC->Gspos("FSTR",j,"FLTA",0.,ycoor, 0.,idrotm[0],"ONLY");
457
458   if(fDebug) {
459      printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,i); 
460      printf("%s: y = %f,  z = %f, zpos = %f \n",ClassName(),ycoor,zcoor,zpos);
461   }
462
463   zcoor -= zSenStrip;
464   j++;
465   Int_t upDown = -1; // upDown=-1 -> Upper strip
466                      // upDown=+1 -> Lower strip
467   do{
468      ang = atan(zcoor/radius);
469      ang *= kRaddeg;
470      AliMatrix (idrotm[nrot],  90.,  0.,90.-ang,90.,-ang, 90.);   
471      AliMatrix (idrotm[nrot+1],90.,180.,90.+ang,90., ang, 90.);
472      ang /= kRaddeg;
473      ycoor = -14.5+ kspace; //2 cm over front plate
474      ycoor += (1-(upDown+1)/2)*gap;
475      gMC->Gspos("FSTR",j  ,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY");
476      gMC->Gspos("FSTR",j+1,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
477
478      if(fDebug) {
479        printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,i);
480        printf("%s: y = %f,  z = %f, zpos = %f \n",ClassName(),ycoor,zcoor,zpos);
481      }
482
483      j += 2;
484      upDown*= -1; // Alternate strips 
485      zcoor = zcoor-(zSenStrip/2)/TMath::Cos(ang)-
486              upDown*gap*TMath::Tan(ang)-
487              (zSenStrip/2)/TMath::Cos(ang);
488   } while (zcoor-(stripWidth/2)*TMath::Cos(ang)>-t+zFLTC+zFLTB+db*2);
489   
490   zcoor = zcoor+(zSenStrip/2)/TMath::Cos(ang)+
491           upDown*gap*TMath::Tan(ang)+
492           (zSenStrip/2)/TMath::Cos(ang);
493
494   gap = fGapB;
495   zcoor = zcoor-(zSenStrip/2)/TMath::Cos(ang)-
496           upDown*gap*TMath::Tan(ang)-
497           (zSenStrip/2)/TMath::Cos(ang);
498
499   ang = atan(zcoor/radius);
500   ang *= kRaddeg;
501   AliMatrix (idrotm[nrot],  90.,  0.,90.-ang,90.,-ang, 90.);   
502   AliMatrix (idrotm[nrot+1],90.,180.,90.+ang,90., ang, 90.);
503   ang /= kRaddeg;
504           
505   ycoor = -14.5+ kspace; //2 cm over front plate
506   ycoor += (1-(upDown+1)/2)*gap;
507
508   /* for FRAME v0
509   gMC->Gspos("FSTR",j  ,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY");
510   gMC->Gspos("FSTR",j+1,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
511   */
512
513   if(fDebug) {   
514      printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,i);  
515      printf("%s: y = %f,  z = %f, zpos = %f \n",ClassName(),ycoor,zcoor,zpos);  
516   }   
517
518   ycoor = -hTof/2.+ kspace;//2 cm over front plate
519
520   // Plate  B
521
522   nrot = 0;
523   i=1;
524   upDown = 1;
525   Float_t deadRegion = 1.0;//cm
526   
527   zpos = zcoor - (zSenStrip/2)/TMath::Cos(ang)-
528          upDown*gap*TMath::Tan(ang)-
529          (zSenStrip/2)/TMath::Cos(ang)-
530          deadRegion/TMath::Cos(ang);
531
532   ang = atan(zpos/radius);
533   ang *= kRaddeg;
534   AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
535   ang /= kRaddeg;
536   ycoor = -hTof*0.5+ kspace ; //2 cm over front plate
537   ycoor += (1-(upDown+1)/2)*gap;
538   zcoor = zpos+(zFLTA*0.5+zFLTB*0.5+db); // Moves to the system of the modulus FLTB
539   gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
540
541   if(fDebug) {   
542      printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i);
543      printf("%s: y = %f,  z = %f, zpos = %f \n",ClassName(),ycoor,zcoor,zpos);
544   }   
545
546   i++;
547   upDown*=-1;
548
549   do {
550      zpos = zpos - (zSenStrip/2)/TMath::Cos(ang)-
551             upDown*gap*TMath::Tan(ang)-
552             (zSenStrip/2)/TMath::Cos(ang);
553      ang = atan(zpos/radius);
554      ang *= kRaddeg;
555      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
556      ang /= kRaddeg;
557      ycoor = -hTof*0.5+ kspace ; //2 cm over front plate
558      ycoor += (1-(upDown+1)/2)*gap;
559      zcoor = zpos+(zFLTA*0.5+zFLTB*0.5+db); // Moves to the system of the modulus FLTB
560      gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
561
562      if(fDebug) {
563        printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i);
564        printf("%s: y = %f,  z = %f, zpos = %f \n",ClassName(),ycoor,zcoor,zpos);
565      }
566
567      upDown*=-1;
568      i++;
569   } while (TMath::Abs(ang*kRaddeg)<22.5);
570   //till we reach a tilting angle of 22.5 degrees
571
572   ycoor = -hTof*0.5+ kspace ; //2 cm over front plate
573   zpos = zpos - zSenStrip/TMath::Cos(ang);
574   // this avoid overlaps in between outer strips in plate B
575   Float_t deltaMovingUp=0.8;    // [cm]
576   //Float_t deltaMovingDown=-0.0; // [cm] special value for AliTOFv2FHoles
577   
578   do {
579      ang = atan(zpos/radius);
580      ang *= kRaddeg;
581      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
582      ang /= kRaddeg;
583      zcoor = zpos+(zFLTB/2+zFLTA/2+db);
584      gMC->Gspos("FSTR",i, "FLTB", 0., ycoor+deltaMovingUp, zcoor,idrotm[nrot], "ONLY");
585      deltaMovingUp+=0.8; // update delta moving toward the end of the plate
586      zpos = zpos - zSenStrip/TMath::Cos(ang);
587      if(fDebug) {
588        printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i);
589        printf("%s: y = %f,  z = %f, zpos = %f \n",ClassName(),ycoor,zcoor,zpos);
590      }
591      i++;
592
593   }  while (zpos-stripWidth*0.5/TMath::Cos(ang)>-t+zFLTC+db);
594   
595   // Plate  C
596   
597   zpos = zpos + zSenStrip/TMath::Cos(ang);
598
599   zpos = zpos - (zSenStrip/2)/TMath::Cos(ang)+
600          gap*TMath::Tan(ang)-
601          (zSenStrip/2)/TMath::Cos(ang);
602
603   nrot = 0;
604   i=0;
605   Float_t deltaGap=-2.5; // [cm] update distance from strip center and plate
606   ycoor= -hTof*0.5+kspace+gap+deltaGap;
607
608   do {
609      i++;
610      ang = atan(zpos/radius);
611      ang *= kRaddeg;
612      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
613      ang /= kRaddeg;
614      zcoor = zpos+(zFLTC*0.5+zFLTB+zFLTA*0.5+db*2);
615      if (i!=1)
616      gMC->Gspos("FSTR",i, "FLTC", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
617
618      if(fDebug) {
619        printf("%s: %f,  St. %2i, Pl.5 ",ClassName(),ang*kRaddeg,i);
620        printf("%s: y = %f,  z = %f, zpos = %f \n",ClassName(),ycoor,zcoor,zpos);
621      }
622
623      zpos = zpos - zSenStrip/TMath::Cos(ang);
624   }  while (zpos-stripWidth*TMath::Cos(ang)*0.5>-t);
625
626
627 ////////// Layers after strips /////////////////
628 // honeycomb (Polyethilene) Layer after (1.2cm)
629
630   Float_t overSpace = fOverSpc;//cm
631
632   par[0] = xFLT*0.5;
633   par[1] = 0.6;
634   par[2] = (zFLTA *0.5);
635   ycoor = -yFLT/2 + overSpace + par[1];
636   gMC->Gsvolu("FPEA", "BOX ", idtmed[503], par, 3); // Hony
637   gMC->Gspos ("FPEA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
638   par[2] = (zFLTB *0.5);
639   gMC->Gsvolu("FPEB", "BOX ", idtmed[503], par, 3); // Hony
640   gMC->Gspos ("FPEB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
641   par[2] = (zFLTC *0.5);
642   gMC->Gsvolu("FPEC", "BOX ", idtmed[503], par, 3); // Hony
643   gMC->Gspos ("FPEC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
644
645 // Electronics (Cu) after
646   ycoor += par[1];
647   par[0] = xFLT*0.5;
648   par[1] = 1.43*0.05*0.5; // 5% of X0
649   par[2] = (zFLTA *0.5);
650   ycoor += par[1];
651   gMC->Gsvolu("FECA", "BOX ", idtmed[501], par, 3); // Cu
652   gMC->Gspos ("FECA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
653   par[2] = (zFLTB *0.5);
654   gMC->Gsvolu("FECB", "BOX ", idtmed[501], par, 3); // Cu
655   gMC->Gspos ("FECB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
656   par[2] = (zFLTC *0.5);
657   gMC->Gsvolu("FECC", "BOX ", idtmed[501], par, 3); // Cu
658   gMC->Gspos ("FECC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
659
660 // cooling WAter after
661   ycoor += par[1];
662   par[0] = xFLT*0.5;
663   par[1] = 36.1*0.02*0.5; // 2% of X0
664   par[2] = (zFLTA *0.5);
665   ycoor += par[1];
666   gMC->Gsvolu("FWAA", "BOX ", idtmed[515], par, 3); // Water
667   gMC->Gspos ("FWAA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
668   par[2] = (zFLTB *0.5);
669   gMC->Gsvolu("FWAB", "BOX ", idtmed[515], par, 3); // Water
670   gMC->Gspos ("FWAB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
671   par[2] = (zFLTC *0.5);
672   gMC->Gsvolu("FWAC", "BOX ", idtmed[515], par, 3); // Water
673   gMC->Gspos ("FWAC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
674
675 // frame of Air
676   ycoor += par[1];
677   par[0] = xFLT*0.5;
678   par[1] = (yFLT/2-ycoor-0.2)*0.5; // Aluminum layer considered (0.2 cm)
679   par[2] = (zFLTA *0.5);
680   ycoor += par[1];
681   gMC->Gsvolu("FAIA", "BOX ", idtmed[500], par, 3); // Air
682   gMC->Gspos ("FAIA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
683   par[2] = (zFLTB *0.5);
684   gMC->Gsvolu("FAIB", "BOX ", idtmed[500], par, 3); // Air
685   gMC->Gspos ("FAIB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
686   par[2] = (zFLTC *0.5);
687   gMC->Gsvolu("FAIC", "BOX ", idtmed[500], par, 3); // Air
688   gMC->Gspos ("FAIC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
689 /* fp
690 //Back Plate honycomb (2cm)
691   par[0] = -1;
692   par[1] = 2 *0.5;
693   par[2] = -1;
694   ycoor = yFLT/2 - par[1];
695   gMC->Gsvolu("FBPA", "BOX ", idtmed[503], par, 3); // Hony
696   gMC->Gspos ("FBPA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
697   gMC->Gsvolu("FBPB", "BOX ", idtmed[503], par, 3); // Hony
698   gMC->Gspos ("FBPB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
699   gMC->Gsvolu("FBPC", "BOX ", idtmed[503], par, 3); // Hony
700   gMC->Gspos ("FBPC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
701 fp */
702 }
703
704 //_____________________________________________________________________________
705 void AliTOFv2FHoles::DrawModule() const
706 {
707   //
708   // Draw a shaded view of the Time Of Flight version 2
709   //
710   // Set everything unseen
711   gMC->Gsatt("*", "seen", -1);
712   // 
713   // Set ALIC mother transparent
714   gMC->Gsatt("ALIC","SEEN",0);
715   //
716   // Set the volumes visible
717   gMC->Gsatt("ALIC","SEEN",0);
718
719   gMC->Gsatt("FTOA","SEEN",1);
720   gMC->Gsatt("FTOB","SEEN",1);
721   gMC->Gsatt("FTOC","SEEN",1);
722   gMC->Gsatt("FLTA","SEEN",1);
723   gMC->Gsatt("FLTB","SEEN",1);
724   gMC->Gsatt("FLTC","SEEN",1);
725   gMC->Gsatt("FPLA","SEEN",1);
726   gMC->Gsatt("FPLB","SEEN",1);
727   gMC->Gsatt("FPLC","SEEN",1);
728   gMC->Gsatt("FSTR","SEEN",1);
729   gMC->Gsatt("FPEA","SEEN",1);
730   gMC->Gsatt("FPEB","SEEN",1);
731   gMC->Gsatt("FPEC","SEEN",1);
732   
733   gMC->Gsatt("FLZ1","SEEN",0);
734   gMC->Gsatt("FLZ2","SEEN",0);
735   gMC->Gsatt("FLZ3","SEEN",0);
736   gMC->Gsatt("FLX1","SEEN",0);
737   gMC->Gsatt("FLX2","SEEN",0);
738   gMC->Gsatt("FLX3","SEEN",0);
739   gMC->Gsatt("FPAD","SEEN",0);
740
741   gMC->Gdopt("hide", "on");
742   gMC->Gdopt("shad", "on");
743   gMC->Gsatt("*", "fill", 7);
744   gMC->SetClipBox(".");
745   gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
746   gMC->DefaultRange();
747   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
748   gMC->Gdhead(1111, "Time Of Flight");
749   gMC->Gdman(18, 4, "MAN");
750   gMC->Gdopt("hide","off");
751 }
752 //_____________________________________________________________________________
753 void AliTOFv2FHoles::DrawDetectorModules()
754 {
755 //
756 // Draw a shaded view of the TOF detector version 2
757 //
758  
759  AliMC* pMC = AliMC::GetMC();
760  
761 //Set ALIC mother transparent
762  pMC->Gsatt("ALIC","SEEN",0);
763
764 //
765 //Set volumes visible
766 // 
767 //=====> Level 1
768   // Level 1 for TOF volumes
769   gMC->Gsatt("B077","seen",0);
770  
771  
772 //==========> Level 2
773   // Level 2
774   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
775   gMC->Gsatt("B071","seen",0);
776   gMC->Gsatt("B074","seen",0);
777   gMC->Gsatt("B075","seen",0);
778   gMC->Gsatt("B080","seen",0); // B080 does not has sub-level                
779
780
781   // Level 2 of B071
782   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
783   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
784   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
785   gMC->Gsatt("B069","seen",-1); // all B069 sub-levels skipped   -
786   gMC->Gsatt("B056","seen",0);  // B056 does not has sub-levels  -
787   gMC->Gsatt("B059","seen",-1); // all B059 sub-levels skipped   -
788   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
789   gMC->Gsatt("BTR1","seen",0);  // BTR1 do not have sub-levels   -
790   gMC->Gsatt("BTO1","seen",0);
791
792  
793   // Level 2 of B074
794   gMC->Gsatt("BTR2","seen",0); // BTR2 does not has sub-levels -
795   gMC->Gsatt("BTO2","seen",0);
796
797   // Level 2 of B075
798   gMC->Gsatt("BTR3","seen",0); // BTR3 do not have sub-levels -
799   gMC->Gsatt("BTO3","seen",0);
800
801 // ==================> Level 3
802   // Level 3 of B071 / Level 2 of BTO1
803   gMC->Gsatt("FTOC","seen",-2);
804   gMC->Gsatt("FTOB","seen",-2);
805   gMC->Gsatt("FTOA","seen",-2);
806  
807   // Level 3 of B074 / Level 2 of BTO2
808   // -> cfr previous settings
809  
810   // Level 3 of B075 / Level 2 of BTO3
811   // -> cfr previous settings
812
813   gMC->Gdopt("hide","on");
814   gMC->Gdopt("shad","on");
815   gMC->Gsatt("*", "fill", 5);
816   gMC->SetClipBox(".");
817   gMC->SetClipBox("*", 0, 1000, 0, 1000, 0, 1000);
818   gMC->DefaultRange();
819   gMC->Gdraw("alic", 45, 40, 0, 10, 10, .015, .015);
820   gMC->Gdhead(1111,"TOF detector V1");
821   gMC->Gdman(18, 4, "MAN");
822   gMC->Gdopt("hide","off");
823 }                                 
824
825 //_____________________________________________________________________________
826 void AliTOFv2FHoles::DrawDetectorStrips()
827 {
828 //
829 // Draw a shaded view of the TOF strips for version 2
830 //
831  
832  AliMC* pMC = AliMC::GetMC();
833  
834 //Set ALIC mother transparent
835  pMC->Gsatt("ALIC","SEEN",0);
836
837 //
838 //Set volumes visible 
839 //=====> Level 1
840   // Level 1 for TOF volumes
841   gMC->Gsatt("B077","seen",0);
842   
843 //==========> Level 2
844   // Level 2
845   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
846   gMC->Gsatt("B071","seen",0);
847   gMC->Gsatt("B074","seen",0);
848   gMC->Gsatt("B075","seen",0);
849   gMC->Gsatt("B080","seen",0); // B080 does not has sub-level
850
851   // Level 2 of B071
852   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
853   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
854   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
855   gMC->Gsatt("B069","seen",-1); // all B069 sub-levels skipped   -
856   gMC->Gsatt("B056","seen",0);  // B056 does not has sub-levels  -
857   gMC->Gsatt("B059","seen",-1); // all B059 sub-levels skipped   -
858   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
859   gMC->Gsatt("BTR1","seen",0);  // BTR1 do not have sub-levels   -
860   gMC->Gsatt("BTO1","seen",0);
861
862 // ==================> Level 3
863   // Level 3 of B071 / Level 2 of BTO1
864   gMC->Gsatt("FTOC","seen",0);
865   gMC->Gsatt("FTOB","seen",0);
866   gMC->Gsatt("FTOA","seen",0);
867  
868   // Level 3 of B074 / Level 2 of BTO2
869   // -> cfr previous settings
870  
871   // Level 3 of B075 / Level 2 of BTO3
872   // -> cfr previous settings
873
874
875 // ==========================> Level 4
876   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOC
877   gMC->Gsatt("FLTC","seen",0);
878   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOB
879   gMC->Gsatt("FLTB","seen",0);
880   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOA
881   gMC->Gsatt("FLTA","seen",0);
882  
883   // Level 4 of B074 / Level 3 of BTO2 / Level 2 of FTOC
884   // -> cfr previous settings
885   // Level 4 of B074 / Level 3 of BTO2 / Level 2 of FTOB
886   // -> cfr previous settings
887  
888   // Level 4 of B075 / Level 3 of BTO3 / Level 2 of FTOC
889   // -> cfr previous settings
890
891 //======================================> Level 5
892   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOC / Level 2 of FLTC
893   gMC->Gsatt("FALC","seen",0); // no children for FALC
894   gMC->Gsatt("FSTR","seen",-2);
895   gMC->Gsatt("FPEC","seen",0); // no children for FPEC
896   gMC->Gsatt("FECC","seen",0); // no children for FECC
897   gMC->Gsatt("FWAC","seen",0); // no children for FWAC
898   gMC->Gsatt("FAIC","seen",0); // no children for FAIC
899
900   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOB / Level 2 of FLTB
901   gMC->Gsatt("FALB","seen",0); // no children for FALB
902 //-->  gMC->Gsatt("FSTR","seen",-2);
903
904
905   // -> cfr previous settings
906   gMC->Gsatt("FPEB","seen",0); // no children for FPEB
907   gMC->Gsatt("FECB","seen",0); // no children for FECB
908   gMC->Gsatt("FWAB","seen",0); // no children for FWAB
909   gMC->Gsatt("FAIB","seen",0); // no children for FAIB
910  
911   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOA / Level 2 of FLTA
912   gMC->Gsatt("FALA","seen",0); // no children for FALB
913 //-->  gMC->Gsatt("FSTR","seen",-2);
914   // -> cfr previous settings
915   gMC->Gsatt("FPEA","seen",0); // no children for FPEA
916   gMC->Gsatt("FECA","seen",0); // no children for FECA
917   gMC->Gsatt("FWAA","seen",0); // no children for FWAA
918   gMC->Gsatt("FAIA","seen",0); // no children for FAIA
919
920   // Level 2 of B074
921   gMC->Gsatt("BTR2","seen",0); // BTR2 does not has sub-levels -
922   gMC->Gsatt("BTO2","seen",0);
923
924   // Level 2 of B075
925   gMC->Gsatt("BTR3","seen",0); // BTR3 do not have sub-levels -
926   gMC->Gsatt("BTO3","seen",0);
927
928 // for others Level 5, cfr. previous settings
929
930   gMC->Gdopt("hide","on");
931   gMC->Gdopt("shad","on");
932   gMC->Gsatt("*", "fill", 5);
933   gMC->SetClipBox(".");
934   gMC->SetClipBox("*", 0, 1000, 0, 1000, 0, 1000);
935   gMC->DefaultRange();
936   gMC->Gdraw("alic", 45, 40, 0, 10, 10, .015, .015);
937   gMC->Gdhead(1111,"TOF Strips V1");
938   gMC->Gdman(18, 4, "MAN");
939   gMC->Gdopt("hide","off");
940 }
941
942 //_____________________________________________________________________________
943 void AliTOFv2FHoles::CreateMaterials()
944 {
945   //
946   // Define materials for the Time Of Flight
947   //
948   AliTOF::CreateMaterials();
949 }
950  
951 //_____________________________________________________________________________
952 void AliTOFv2FHoles::Init()
953 {
954   //
955   // Initialise the detector after the geometry has been defined
956   //
957   if(fDebug) {   
958     printf("%s: **************************************"
959            "  TOF  "
960            "**************************************\n",ClassName());
961     printf("\n%s:   Version 2 of TOF initialing, "
962            "TOF with holes for PHOS and RICH \n",ClassName());
963   }  
964
965   AliTOF::Init();
966
967   fIdFTOA = gMC->VolId("FTOA");
968   fIdFTOB = gMC->VolId("FTOB");
969   fIdFTOC = gMC->VolId("FTOC");
970   fIdFLTA = gMC->VolId("FLTA");
971   fIdFLTB = gMC->VolId("FLTB");
972   fIdFLTC = gMC->VolId("FLTC");
973
974   if(fDebug) {
975     printf("%s: **************************************"
976            "  TOF  "
977            "**************************************\n",ClassName());
978   }
979 }
980  
981 //_____________________________________________________________________________
982 void AliTOFv2FHoles::StepManager()
983 {
984   //
985   // Procedure called at each step in the Time Of Flight
986   //
987   TLorentzVector mom, pos;
988   Float_t xm[3],pm[3],xpad[3],ppad[3];
989   Float_t hits[13],phi,phid,z;
990   Int_t   vol[5];
991   Int_t   sector, plate, padx, padz, strip;
992   Int_t   copy, padzid, padxid, stripid, i;
993   Int_t   *idtmed = fIdtmed->GetArray()-499;
994   Float_t incidenceAngle;
995   
996   if(gMC->GetMedium()==idtmed[513] && 
997      gMC->IsTrackEntering() && gMC->TrackCharge()
998      && gMC->CurrentVolID(copy)==fIdSens) 
999   {    
1000     // getting information about hit volumes
1001     
1002     padzid=gMC->CurrentVolOffID(2,copy);
1003     padz=copy;  
1004     
1005     padxid=gMC->CurrentVolOffID(1,copy);
1006     padx=copy;  
1007     
1008     stripid=gMC->CurrentVolOffID(4,copy);
1009     strip=copy;  
1010
1011     gMC->TrackPosition(pos);
1012     gMC->TrackMomentum(mom);
1013
1014 //    Double_t NormPos=1./pos.Rho();
1015     Double_t normMom=1./mom.Rho();
1016
1017 //  getting the cohordinates in pad ref system
1018     xm[0] = (Float_t)pos.X();
1019     xm[1] = (Float_t)pos.Y();
1020     xm[2] = (Float_t)pos.Z();
1021
1022     pm[0] = (Float_t)mom.X()*normMom;
1023     pm[1] = (Float_t)mom.Y()*normMom;
1024     pm[2] = (Float_t)mom.Z()*normMom;
1025  
1026     gMC->Gmtod(xm,xpad,1);
1027     gMC->Gmtod(pm,ppad,2);
1028
1029     incidenceAngle = TMath::ACos(ppad[1])*kRaddeg;
1030
1031     z = pos[2];
1032
1033     plate = 0;   
1034
1035     /* to be changed
1036     if (TMath::Abs(z) <=  fZlenA*0.5)  plate = 3;
1037     if (z < (fZlenA*0.5+fZlenB) && 
1038         z >  fZlenA*0.5)               plate = 4;
1039     if (z >-(fZlenA*0.5+fZlenB) &&
1040         z < -fZlenA*0.5)               plate = 2;
1041     if (z > (fZlenA*0.5+fZlenB))       plate = 5;
1042     if (z <-(fZlenA*0.5+fZlenB))       plate = 1;
1043     end to be changed */
1044
1045     if (TMath::Abs(z) <=  124.*0.5)  plate = 3;
1046     if (z < (124.*0.5+154.) && 
1047         z >  124.*0.5)               plate = 4;
1048     if (z >-(124.*0.5+154.) &&
1049         z < -124.*0.5)               plate = 2;
1050     if (z > (124.*0.5+154.))       plate = 5;
1051     if (z <-(124.*0.5+154.))       plate = 1;
1052
1053
1054     phi = pos.Phi();
1055     phid = phi*kRaddeg+180.;
1056     sector = Int_t (phid/20.);
1057     sector++;
1058
1059     for(i=0;i<3;++i) {
1060       hits[i]   = pos[i];
1061       hits[i+3] = pm[i];
1062     }
1063
1064     hits[6] = mom.Rho();
1065     hits[7] = pos[3];
1066     hits[8] = xpad[0];
1067     hits[9] = xpad[1];
1068     hits[10]= xpad[2];
1069     hits[11]= incidenceAngle;
1070     hits[12]= gMC->Edep();
1071     
1072     vol[0]= sector;
1073     vol[1]= plate;
1074     vol[2]= strip;
1075     vol[3]= padx;
1076     vol[4]= padz;
1077     
1078     AddHit(gAlice->CurrentTrack(),vol, hits);
1079   }
1080 }