]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFv4T0.cxx
Style corrections
[u/mrichter/AliRoot.git] / TOF / AliTOFv4T0.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 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  This class contains the functions for version 4 of the Time Of Flight    //
21 //  detector.                                                                //
22 //                                                                           //
23 //  VERSION WITH 5 MODULES AND TILTED STRIPS                                 //
24 //                                                                           //
25 //   FULL COVERAGE VERSION +OPTION for PHOS holes                            //
26 //                                                                           //
27 //   Author:                                                                 //
28 //   Fabrizio Pierella                                                       //
29 //   University of Bologna - Italy                                           //
30 //                                                                           //
31 //                                                                           //
32 //Begin_Html                                                                 //
33 /*                                                                           //
34 <img src="picts/AliTOFv4T0Class.gif">                                        //
35 */                                                                           //
36 //End_Html                                                                   //
37 //                                                                           //
38 ///////////////////////////////////////////////////////////////////////////////
39
40 #include "TLorentzVector.h"
41 #include "TVirtualMC.h"
42
43 #include "AliConst.h"
44 #include "AliLog.h"
45 #include "AliMagF.h"
46 #include "AliMC.h"
47 #include "AliRun.h"
48 #include "AliTrackReference.h"
49
50 #include "AliTOFGeometry.h"
51 #include "AliTOFGeometryV4.h"
52 #include "AliTOFv4T0.h"
53
54 extern TDirectory *gDirectory;
55 extern TVirtualMC *gMC;
56
57 extern AliRun *gAlice;
58
59 ClassImp(AliTOFv4T0)
60
61 //_____________________________________________________________________________
62   AliTOFv4T0::AliTOFv4T0():
63   fIdFTOA(-1),
64   fIdFTOB(-1),
65   fIdFTOC(-1),
66   fIdFLTA(-1),
67   fIdFLTB(-1),
68   fIdFLTC(-1),
69   fTOFHoles(kFALSE)
70 {
71   //
72   // Default constructor
73   //
74 }
75  
76 //_____________________________________________________________________________
77 AliTOFv4T0::AliTOFv4T0(const char *name, const char *title):
78   AliTOF(name,title,"tzero"),
79   fIdFTOA(-1),
80   fIdFTOB(-1),
81   fIdFTOC(-1),
82   fIdFLTA(-1),
83   fIdFLTB(-1),
84   fIdFLTC(-1),
85   fTOFHoles(kFALSE)
86 {
87   //
88   // Standard constructor
89   //
90   //
91   // Check that FRAME is there otherwise we have no place where to
92   // put TOF
93
94
95   AliModule* frame = (AliModule*)gAlice->GetModule("FRAME");
96   if(!frame) {
97     AliFatal("TOF needs FRAME to be present");
98   } else{
99     
100     if (fTOFGeometry) delete fTOFGeometry;
101     fTOFGeometry = new AliTOFGeometryV4();
102
103     if(frame->IsVersion()==1) {
104       AliInfo(Form("Frame version %d", frame->IsVersion())); 
105       AliInfo("Full Coverage for TOF");
106       fTOFHoles=false;}    
107     else {
108       AliInfo(Form("Frame version %d", frame->IsVersion())); 
109       AliInfo("TOF with Holes for PHOS");
110       fTOFHoles=true;}      
111   }
112   fTOFGeometry->SetHoles(fTOFHoles);
113
114   // Save the geometry
115   TDirectory* saveDir = gDirectory;
116   AliRunLoader::Instance()->CdGAFile();
117   fTOFGeometry->Write("TOFgeometry");
118   saveDir->cd();
119
120
121  
122 //_____________________________________________________________________________
123 void AliTOFv4T0::CreateGeometry()
124 {
125   //
126   // Create geometry for Time Of Flight version 0
127   //
128   //Begin_Html
129   /*
130     <img src="picts/AliTOFv4T0.gif">
131   */
132   //End_Html
133   //
134   // Creates common geometry
135   //
136   AliTOF::CreateGeometry();
137 }
138  
139
140 //_____________________________________________________________________________
141 void AliTOFv4T0::TOFpc(Float_t xtof, Float_t ytof, Float_t zlenC,
142                      Float_t zlenB, Float_t zlenA, Float_t ztof0)
143 {
144   //
145   // Definition of the Time Of Fligh Resistive Plate Chambers
146   // xFLT, yFLT, zFLT - sizes of TOF modules (large)
147
148   Float_t  ycoor;
149   Float_t  par[3];
150   Int_t    *idtmed = fIdtmed->GetArray()-499;
151   Int_t    idrotm[100];
152   Int_t    nrot = 0;
153
154   Float_t radius = fTOFGeometry->Rmin()+2.;//cm
155
156   par[0] =  xtof * 0.5;
157   par[1] =  ytof * 0.5;
158   par[2] = zlenC * 0.5;
159   gMC->Gsvolu("FTOC", "BOX ", idtmed[506], par, 3);
160   par[2] = zlenB * 0.5;
161   gMC->Gsvolu("FTOB", "BOX ", idtmed[506], par, 3);
162   par[2] = zlenA * 0.5;
163   gMC->Gsvolu("FTOA", "BOX ", idtmed[506], par, 3);
164   
165   
166   // Positioning of modules
167   
168   Float_t zcor1 = ztof0 - zlenC*0.5;
169   Float_t zcor2 = ztof0 - zlenC - zlenB*0.5;
170   Float_t zcor3 = 0.;
171   
172   AliMatrix(idrotm[0], 90.,  0., 0., 0., 90,-90.);
173   AliMatrix(idrotm[1], 90.,180., 0., 0., 90, 90.);
174
175   gMC->Gspos("FTOC", 1, "BTO1", 0,  zcor1, 0, idrotm[0], "ONLY");
176   gMC->Gspos("FTOC", 2, "BTO1", 0, -zcor1, 0, idrotm[1], "ONLY");
177   gMC->Gspos("FTOC", 1, "BTO2", 0,  zcor1, 0, idrotm[0], "ONLY");
178   gMC->Gspos("FTOC", 2, "BTO2", 0, -zcor1, 0, idrotm[1], "ONLY");
179   gMC->Gspos("FTOC", 1, "BTO3", 0,  zcor1, 0, idrotm[0], "ONLY");
180   gMC->Gspos("FTOC", 2, "BTO3", 0, -zcor1, 0, idrotm[1], "ONLY");
181   
182   gMC->Gspos("FTOB", 1, "BTO1", 0,  zcor2, 0, idrotm[0], "ONLY");
183   gMC->Gspos("FTOB", 2, "BTO1", 0, -zcor2, 0, idrotm[1], "ONLY");
184   gMC->Gspos("FTOB", 1, "BTO2", 0,  zcor2, 0, idrotm[0], "ONLY");
185   gMC->Gspos("FTOB", 2, "BTO2", 0, -zcor2, 0, idrotm[1], "ONLY");
186   gMC->Gspos("FTOB", 1, "BTO3", 0,  zcor2, 0, idrotm[0], "ONLY");
187   gMC->Gspos("FTOB", 2, "BTO3", 0, -zcor2, 0, idrotm[1], "ONLY");
188   
189   gMC->Gspos("FTOA", 0, "BTO1", 0, zcor3,  0, idrotm[0], "ONLY");
190   if(!fTOFHoles)gMC->Gspos("FTOA", 0, "BTO2", 0, zcor3,  0, idrotm[0], "ONLY");
191   gMC->Gspos("FTOA", 0, "BTO3", 0, zcor3,  0, idrotm[0], "ONLY");
192   
193
194   Float_t db = 0.5; // cm
195   Float_t xFLT, xFST, yFLT, zFLTA, zFLTB, zFLTC;
196   
197   xFLT = fTOFGeometry->StripLength();
198   yFLT = ytof;
199   zFLTA = zlenA;
200   zFLTB = zlenB;
201   zFLTC = zlenC;
202   
203   xFST = xFLT - dynamic_cast<AliTOFGeometryV4*>(fTOFGeometry)->DeadBndX()*2.; // cm
204   
205   // Sizes of MRPC pads
206   
207   Float_t yPad = 0.505; //cm
208   
209   // Large not sensitive volumes with Insensitive Freon
210   par[0] = xFLT*0.5;
211   par[1] = yFLT*0.5;
212   
213   AliDebug(1, "************************* TOF geometry **************************");
214   
215   par[2] = (zFLTA *0.5);
216   gMC->Gsvolu("FLTA", "BOX ", idtmed[512], par, 3); // Insensitive Freon
217   gMC->Gspos ("FLTA", 0, "FTOA", 0., 0., 0., 0, "ONLY");
218   
219   par[2] = (zFLTB * 0.5);
220   gMC->Gsvolu("FLTB", "BOX ", idtmed[512], par, 3); // Insensitive Freon
221   gMC->Gspos ("FLTB", 0, "FTOB", 0., 0., 0., 0, "ONLY");
222   
223   par[2] = (zFLTC * 0.5);
224   gMC->Gsvolu("FLTC", "BOX ", idtmed[512], par, 3); // Insensitive Freon
225   gMC->Gspos ("FLTC", 0, "FTOC", 0., 0., 0., 0, "ONLY");
226   
227   ///// Layers of Aluminum before and after detector /////
228   ///// Aluminum Box for Modules (1.8 mm thickness)  /////
229   ///// lateral walls not simulated for the time being
230   //    const Float_t khAlWall = 0.18;
231   // fp to be checked
232   const Float_t khAlWall = 0.11;
233   par[0] = xFLT*0.5;
234   par[1] = khAlWall/2.; // cm
235   ycoor = -yFLT/2 + par[1];
236   par[2] = (zFLTA *0.5);
237   gMC->Gsvolu("FALA", "BOX ", idtmed[508], par, 3); // Alluminium
238   gMC->Gspos ("FALA", 1, "FLTA", 0., ycoor, 0., 0, "ONLY");
239   gMC->Gspos ("FALA", 2, "FLTA", 0.,-ycoor, 0., 0, "ONLY");
240   par[2] = (zFLTB *0.5);
241   gMC->Gsvolu("FALB", "BOX ", idtmed[508], par, 3); // Alluminium 
242   gMC->Gspos ("FALB", 1, "FLTB", 0., ycoor, 0., 0, "ONLY");
243   gMC->Gspos ("FALB", 2, "FLTB", 0.,-ycoor, 0., 0, "ONLY");
244   par[2] = (zFLTC *0.5);
245   gMC->Gsvolu("FALC", "BOX ", idtmed[508], par, 3); // Alluminium
246   gMC->Gspos ("FALC", 1, "FLTC", 0., ycoor, 0., 0, "ONLY");
247   gMC->Gspos ("FALC", 2, "FLTC", 0.,-ycoor, 0., 0, "ONLY");
248   
249   ///////////////// Detector itself //////////////////////
250   
251   const Float_t  kdeadBound  =  dynamic_cast<AliTOFGeometryV4*>(fTOFGeometry)->DeadBndZ(); //cm non-sensitive between the pad edge 
252   //and the boundary of the strip
253   const Int_t    knx    = fTOFGeometry->NpadX();  // number of pads along x
254   const Int_t    knz    = fTOFGeometry->NpadZ();  // number of pads along z
255   
256   Float_t zSenStrip  = fTOFGeometry->ZPad() * fTOFGeometry->NpadZ(); // cm
257   Float_t stripWidth = zSenStrip + 2*kdeadBound;
258   
259   par[0] = xFLT*0.5;
260   par[1] = yPad*0.5;
261   par[2] = stripWidth*0.5;
262   
263   // new description for strip volume -double stack strip-
264   // -- all constants are expressed in cm
265   // heigth of different layers
266   const Float_t khhony = 0.8     ;   // heigth of HONY  Layer
267   const Float_t khpcby = 0.08    ;   // heigth of PCB   Layer
268   const Float_t khmyly = 0.035   ;   // heigth of MYLAR Layer
269   const Float_t khgraphy = 0.02  ;   // heigth of GRAPHITE Layer
270   const Float_t khglasseiy = 0.135;  // 0.6 Ext. Glass + 1.1 i.e. (Int. Glass/2) (mm)
271   const Float_t khsensmy = 0.11  ;   // heigth of Sensitive Freon Mixture
272   const Float_t kwsensmz = 2*3.5 ;   // cm
273   const Float_t klsensmx = 48*2.5;   // cm
274   const Float_t kwpadz = 3.5;   // cm z dimension of the FPAD volume
275   const Float_t klpadx = 2.5;   // cm x dimension of the FPAD volume
276   
277   // heigth of the FSTR Volume (the strip volume)
278   const Float_t khstripy = 2*khhony+3*khpcby+4*(khmyly+khgraphy+khglasseiy)+2*khsensmy;
279   // width  of the FSTR Volume (the strip volume)
280   const Float_t kwstripz = 10.;
281   // length of the FSTR Volume (the strip volume)
282   const Float_t klstripx = 122.;
283   
284   Float_t parfp[3]={klstripx*0.5,khstripy*0.5,kwstripz*0.5};
285   // Coordinates of the strip center in the strip reference frame;
286   // used for positioninG internal strip volumes
287   Float_t posfp[3]={0.,0.,0.};  
288   
289   
290   // FSTR volume definition-filling this volume with non sensitive Gas Mixture
291   gMC->Gsvolu("FSTR","BOX",idtmed[512],parfp,3);
292   //-- HONY Layer definition
293   //  parfp[0] = -1;
294   parfp[1] = khhony*0.5;
295   //  parfp[2] = -1;
296   gMC->Gsvolu("FHON","BOX",idtmed[503],parfp,3);
297   // positioning 2 HONY Layers on FSTR volume
298   
299   posfp[1]=-khstripy*0.5+parfp[1];
300   gMC->Gspos("FHON",1,"FSTR",0., posfp[1],0.,0,"ONLY");
301   gMC->Gspos("FHON",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
302   
303   //-- PCB Layer definition 
304  
305   parfp[1] = khpcby*0.5;
306   gMC->Gsvolu("FPCB","BOX",idtmed[504],parfp,3);
307   // positioning 2 PCB Layers on FSTR volume
308   posfp[1]=-khstripy*0.5+khhony+parfp[1];
309   gMC->Gspos("FPCB",1,"FSTR",0., posfp[1],0.,0,"ONLY");
310   gMC->Gspos("FPCB",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
311   // positioning the central PCB layer
312   gMC->Gspos("FPCB",3,"FSTR",0.,0.,0.,0,"ONLY");
313   
314   
315   
316   //-- MYLAR Layer definition
317
318   parfp[1] = khmyly*0.5;
319   gMC->Gsvolu("FMYL","BOX",idtmed[511],parfp,3);
320   // positioning 2 MYLAR Layers on FSTR volume
321   posfp[1] = -khstripy*0.5+khhony+khpcby+parfp[1];
322   gMC->Gspos("FMYL",1,"FSTR",0., posfp[1],0.,0,"ONLY");
323   gMC->Gspos("FMYL",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
324   // adding further 2 MYLAR Layers on FSTR volume
325   posfp[1] = khpcby*0.5+parfp[1];
326   gMC->Gspos("FMYL",3,"FSTR",0., posfp[1],0.,0,"ONLY");
327   gMC->Gspos("FMYL",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
328   
329   
330   //-- Graphite Layer definition
331  
332   parfp[1] = khgraphy*0.5;
333   gMC->Gsvolu("FGRP","BOX",idtmed[502],parfp,3);
334   // positioning 2 Graphite Layers on FSTR volume
335   posfp[1] = -khstripy*0.5+khhony+khpcby+khmyly+parfp[1];
336   gMC->Gspos("FGRP",1,"FSTR",0., posfp[1],0.,0,"ONLY");
337   gMC->Gspos("FGRP",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
338   // adding further 2 Graphite Layers on FSTR volume
339   posfp[1] = khpcby*0.5+khmyly+parfp[1];
340   gMC->Gspos("FGRP",3,"FSTR",0., posfp[1],0.,0,"ONLY");
341   gMC->Gspos("FGRP",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
342   
343   
344   //-- Glass (EXT. +Semi INT.) Layer definition
345
346   parfp[1] = khglasseiy*0.5;
347   gMC->Gsvolu("FGLA","BOX",idtmed[514],parfp,3);
348   // positioning 2 Glass Layers on FSTR volume
349   posfp[1] = -khstripy*0.5+khhony+khpcby+khmyly+khgraphy+parfp[1];
350   gMC->Gspos("FGLA",1,"FSTR",0., posfp[1],0.,0,"ONLY");
351   gMC->Gspos("FGLA",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
352   // adding further 2 Glass Layers on FSTR volume
353   posfp[1] = khpcby*0.5+khmyly+khgraphy+parfp[1];
354   gMC->Gspos("FGLA",3,"FSTR",0., posfp[1],0.,0,"ONLY");
355   gMC->Gspos("FGLA",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
356   
357   
358   //-- Sensitive Mixture Layer definition
359  
360   parfp[0] = klsensmx*0.5;
361   parfp[1] = khsensmy*0.5;
362   parfp[2] = kwsensmz*0.5;
363   gMC->Gsvolu("FSEN","BOX",idtmed[513],parfp,3);
364   gMC->Gsvolu("FNSE","BOX",idtmed[512],parfp,3);
365   // positioning 2 gas Layers on FSTR volume
366   // the upper is insensitive freon
367   // while the remaining is sensitive
368   posfp[1] = khpcby*0.5+khmyly+khgraphy+khglasseiy+parfp[1];
369   gMC->Gspos("FNSE",0,"FSTR", 0., posfp[1],0.,0,"ONLY");
370   gMC->Gspos("FSEN",0,"FSTR", 0.,-posfp[1],0.,0,"ONLY");
371   
372   // dividing FSEN along z in knz=2 and along x in knx=48
373
374   gMC->Gsdvn("FSEZ","FSEN",knz,3);
375   gMC->Gsdvn("FSEX","FSEZ",knx,1);
376   
377   // FPAD volume definition
378
379   parfp[0] = klpadx*0.5;   
380   parfp[1] = khsensmy*0.5;
381   parfp[2] = kwpadz*0.5;
382   gMC->Gsvolu("FPAD","BOX",idtmed[513],parfp,3);
383   // positioning the FPAD volumes on previous divisions
384   gMC->Gspos("FPAD",0,"FSEX",0.,0.,0.,0,"ONLY");
385   
386
387   ///////////////////Positioning A module//////////////////////////
388
389
390   for(Int_t istrip =0; istrip < fTOFGeometry->NStripA(); istrip++){
391
392     Float_t ang = fTOFGeometry->GetAngles(2,istrip);
393     AliMatrix (idrotm[0],90.,0.,90.-ang,90.,-ang, 90.);  
394     ang /= kRaddeg;
395     Float_t zpos = tan(ang)*radius;
396     Float_t ypos= fTOFGeometry->GetHeights(2,istrip);
397     gMC->Gspos("FSTR",fTOFGeometry->NStripA()-istrip,"FLTA",0.,ypos, zpos,idrotm[0],  "ONLY");
398     AliDebug(1, Form("y = %f,  z = %f, , z coord = %f, Rot ang = %f, St. %2i",ypos,zpos,tan(ang)*radius ,ang*kRaddeg,istrip));
399   }
400
401   
402   ///////////////////Positioning B module//////////////////////////
403
404   for(Int_t istrip =0; istrip < fTOFGeometry->NStripB(); istrip++){
405
406     Float_t ang = fTOFGeometry->GetAngles(3,istrip);
407     AliMatrix (idrotm[0],90.,0.,90.-ang,90.,-ang, 90.);  
408     ang /= kRaddeg;
409     Float_t zpos = tan(ang)*radius+(zFLTA*0.5+zFLTB*0.5+db);
410     Float_t ypos= fTOFGeometry->GetHeights(3,istrip);
411     gMC->Gspos("FSTR",istrip+1,"FLTB",0.,ypos, zpos,idrotm[nrot],  "ONLY");
412     AliDebug(1, Form("y = %f,  z = %f, , z coord = %f, Rot ang = %f, St. %2i",ypos,zpos,tan(ang)*radius,ang*kRaddeg,istrip));
413   }
414
415   
416   ///////////////////Positioning C module//////////////////////////
417
418   for(Int_t istrip =0; istrip < fTOFGeometry->NStripC(); istrip++){
419
420     Float_t ang = fTOFGeometry->GetAngles(4,istrip);
421     AliMatrix (idrotm[0],90.,0.,90.-ang,90.,-ang, 90.);  
422     ang /= kRaddeg;
423     Float_t zpos = tan(ang)*radius+(zFLTC*0.5+zFLTB+zFLTA*0.5+db*2);
424     Float_t ypos= fTOFGeometry->GetHeights(4,istrip);
425     gMC->Gspos("FSTR",istrip+1,"FLTC",0.,ypos, zpos,idrotm[nrot],  "ONLY");
426     AliDebug(1, Form("y = %f,  z = %f, z coord = %f, Rot ang = %f, St. %2i",ypos,zpos,tan(ang)*radius,ang*kRaddeg,istrip));
427   }
428    
429   ////////// Layers after strips /////////////////
430   // Al Layer thickness (2.3mm) factor 0.7
431   
432   Float_t overSpace = dynamic_cast<AliTOFGeometryV4*>(fTOFGeometry)->OverSpc();//cm
433   
434   par[0] = xFLT*0.5;
435   par[1] = 0.115*0.7; // factor 0.7
436   par[2] = (zFLTA *0.5);
437   ycoor = -yFLT/2 + overSpace + par[1];
438   gMC->Gsvolu("FPEA", "BOX ", idtmed[508], par, 3); // Al
439   gMC->Gspos ("FPEA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
440   par[2] = (zFLTB *0.5);
441   gMC->Gsvolu("FPEB", "BOX ", idtmed[508], par, 3); // Al
442   gMC->Gspos ("FPEB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
443   par[2] = (zFLTC *0.5);
444   gMC->Gsvolu("FPEC", "BOX ", idtmed[508], par, 3); // Al
445   gMC->Gspos ("FPEC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
446   
447   
448   // plexiglass thickness: 1.5 mm ; factor 0.3
449
450   ycoor += par[1];
451   par[0] = xFLT*0.5;
452   par[1] = 0.075*0.3; // factor 0.3 
453   par[2] = (zFLTA *0.5);
454   ycoor += par[1];
455   gMC->Gsvolu("FECA", "BOX ", idtmed[505], par, 3); // Plexigl.
456   gMC->Gspos ("FECA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
457   par[2] = (zFLTB *0.5);
458   gMC->Gsvolu("FECB", "BOX ", idtmed[505], par, 3); // Plexigl.
459   gMC->Gspos ("FECB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
460   par[2] = (zFLTC *0.5);
461   gMC->Gsvolu("FECC", "BOX ", idtmed[505], par, 3); // Plexigl.
462   gMC->Gspos ("FECC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
463   
464   // frame of Air
465
466   ycoor += par[1];
467   par[0] = xFLT*0.5;
468   par[1] = (yFLT/2-ycoor-khAlWall)*0.5; // Aluminum layer considered (0.18 cm)
469   par[2] = (zFLTA *0.5);
470   ycoor += par[1];
471   gMC->Gsvolu("FAIA", "BOX ", idtmed[500], par, 3); // Air
472   gMC->Gspos ("FAIA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
473   par[2] = (zFLTB *0.5);
474   gMC->Gsvolu("FAIB", "BOX ", idtmed[500], par, 3); // Air
475   gMC->Gspos ("FAIB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
476   par[2] = (zFLTC *0.5);
477   gMC->Gsvolu("FAIC", "BOX ", idtmed[500], par, 3); // Air
478   gMC->Gspos ("FAIC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
479   
480   
481   // start with cards and cooling tubes
482   // finally, cards, cooling tubes and layer for thermal dispersion
483   // 3 volumes
484   // card volume definition
485   
486   // see GEOM200 in GEANT manual
487
488
489   AliMatrix(idrotm[98], 90., 0., 90., 90., 0., 0.); // 0 deg
490   
491   Float_t cardpar[3];
492   cardpar[0]= 61.;
493   cardpar[1]= 5.;
494   cardpar[2]= 0.1;
495   gMC->Gsvolu("FCAR", "BOX ", idtmed[504], cardpar, 3); // PCB Card 
496   //alu plate volume definition
497   cardpar[1]= 3.5;
498   cardpar[2]= 0.05;
499   gMC->Gsvolu("FALP", "BOX ", idtmed[508], cardpar, 3); // Alu Plate
500   
501   
502   // central module positioning (FAIA)
503   Float_t cardpos[3], aplpos2, stepforcardA=6.625;
504   cardpos[0]= 0.;
505   cardpos[1]= -0.5;
506   cardpos[2]= -53.;
507   Float_t aplpos1 = -2.;
508   Int_t icard;
509   for (icard=0; icard < fTOFGeometry->NStripA(); ++icard) {
510     cardpos[2]= cardpos[2]+stepforcardA;
511     aplpos2 = cardpos[2]+0.15;
512     gMC->Gspos("FCAR",icard,"FAIA",cardpos[0],cardpos[1],cardpos[2],idrotm[98],"ONLY");
513     gMC->Gspos("FALP",icard,"FAIA",cardpos[0],aplpos1,aplpos2,idrotm[98],"ONLY");
514     
515   }
516   
517   
518   // intermediate module positioning (FAIB)
519   Float_t stepforcardB= 7.05;
520   cardpos[2]= -70.5;
521   for (icard=0; icard < fTOFGeometry->NStripB(); ++icard) {
522     cardpos[2]= cardpos[2]+stepforcardB;
523     aplpos2 = cardpos[2]+0.15; 
524     gMC->Gspos("FCAR",icard,"FAIB",cardpos[0],cardpos[1],cardpos[2],idrotm[98],"ONLY");
525     gMC->Gspos("FALP",icard,"FAIB",cardpos[0],aplpos1,aplpos2,idrotm[98],"ONLY");
526   }
527   
528   
529   // outer module positioning (FAIC)
530   Float_t stepforcardC= 8.45238;
531   cardpos[2]= -88.75;
532   for (icard=0; icard < fTOFGeometry->NStripC(); ++icard) {
533     cardpos[2]= cardpos[2]+stepforcardC;
534     aplpos2 = cardpos[2]+0.15;
535     gMC->Gspos("FCAR",icard,"FAIC",cardpos[0],cardpos[1],cardpos[2],idrotm[98],"ONLY");
536     gMC->Gspos("FALP",icard,"FAIC",cardpos[0],aplpos1,aplpos2,idrotm[98],"ONLY");
537   }
538   
539   // tube volume definition
540
541   Float_t tubepar[3];
542   tubepar[0]= 0.;
543   tubepar[1]= 0.4;
544   tubepar[2]= 61.;
545   gMC->Gsvolu("FTUB", "TUBE", idtmed[516], tubepar, 3); // cooling tubes (steel)
546   tubepar[0]= 0.;
547   tubepar[1]= 0.35;
548   tubepar[2]= 61.;
549   gMC->Gsvolu("FITU", "TUBE", idtmed[515], tubepar, 3); // cooling water
550   // positioning water tube into the steel one
551   gMC->Gspos("FITU",1,"FTUB",0.,0.,0.,0,"ONLY");
552   
553   
554   // rotation matrix
555   AliMatrix(idrotm[99], 180., 90., 90., 90., 90., 0.);
556   // central module positioning (FAIA)
557   Float_t tubepos[3], tdis=0.6;
558   tubepos[0]= 0.;
559   tubepos[1]= cardpos[1];
560   tubepos[2]= -53.+tdis;
561   //  tub1pos = 5.;
562   Int_t itub;
563   for (itub=0; itub < fTOFGeometry->NStripA(); ++itub) {
564     tubepos[2]= tubepos[2]+stepforcardA;
565     gMC->Gspos("FTUB",itub,"FAIA",tubepos[0],tubepos[1],tubepos[2],idrotm[99],
566                "ONLY");
567   }
568   
569   
570   // intermediate module positioning (FAIB)
571   tubepos[2]= -70.5+tdis;
572   for (itub=0; itub < fTOFGeometry->NStripB(); ++itub) {
573     tubepos[2]= tubepos[2]+stepforcardB;
574     gMC->Gspos("FTUB",itub,"FAIB",tubepos[0],tubepos[1],tubepos[2],idrotm[99],
575                "ONLY");
576   }
577   
578   // outer module positioning (FAIC)
579   tubepos[2]= -88.75+tdis;
580   for (itub=0; itub < fTOFGeometry->NStripC(); ++itub) {
581     tubepos[2]= tubepos[2]+stepforcardC;
582     gMC->Gspos("FTUB",itub,"FAIC",tubepos[0],tubepos[1],tubepos[2],idrotm[99],
583                "ONLY");
584   }
585
586 }
587 //_____________________________________________________________________________
588 void AliTOFv4T0::DrawModule() const
589 {
590   //
591   // Draw a shaded view of the Time Of Flight version 4
592   //
593   // Set everything unseen
594   gMC->Gsatt("*", "seen", -1);
595   // 
596   // Set ALIC mother transparent
597   gMC->Gsatt("ALIC","SEEN",0);
598   //
599   // Set the volumes visible
600   gMC->Gsatt("ALIC","SEEN",0);
601
602   gMC->Gsatt("FTOA","SEEN",1);
603   gMC->Gsatt("FTOB","SEEN",1);
604   gMC->Gsatt("FTOC","SEEN",1);
605   gMC->Gsatt("FLTA","SEEN",1);
606   gMC->Gsatt("FLTB","SEEN",1);
607   gMC->Gsatt("FLTC","SEEN",1);
608   gMC->Gsatt("FPLA","SEEN",1);
609   gMC->Gsatt("FPLB","SEEN",1);
610   gMC->Gsatt("FPLC","SEEN",1);
611   gMC->Gsatt("FSTR","SEEN",1);
612   gMC->Gsatt("FPEA","SEEN",1);
613   gMC->Gsatt("FPEB","SEEN",1);
614   gMC->Gsatt("FPEC","SEEN",1);
615   
616   gMC->Gsatt("FLZ1","SEEN",0);
617   gMC->Gsatt("FLZ2","SEEN",0);
618   gMC->Gsatt("FLZ3","SEEN",0);
619   gMC->Gsatt("FLX1","SEEN",0);
620   gMC->Gsatt("FLX2","SEEN",0);
621   gMC->Gsatt("FLX3","SEEN",0);
622   gMC->Gsatt("FPAD","SEEN",0);
623
624   gMC->Gdopt("hide", "on");
625   gMC->Gdopt("shad", "on");
626   gMC->Gsatt("*", "fill", 7);
627   gMC->SetClipBox(".");
628   gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
629   gMC->DefaultRange();
630   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
631   gMC->Gdhead(1111, "Time Of Flight");
632   gMC->Gdman(18, 4, "MAN");
633   gMC->Gdopt("hide","off");
634 }
635 //_____________________________________________________________________________
636 void AliTOFv4T0::DrawDetectorModules() const
637 {
638 //
639 // Draw a shaded view of the TOF detector version 4
640 //
641  
642  
643 //Set ALIC mother transparent
644   gMC->Gsatt("ALIC","SEEN",0);
645
646 //
647 //Set volumes visible
648 // 
649 //=====> Level 1
650   // Level 1 for TOF volumes
651   gMC->Gsatt("B077","seen",0);
652  
653  
654 //==========> Level 2
655   // Level 2
656   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
657   gMC->Gsatt("B071","seen",0);
658   gMC->Gsatt("B074","seen",0);
659   gMC->Gsatt("B075","seen",0);
660   gMC->Gsatt("B080","seen",0); // B080 does not has sub-level                
661
662
663   // Level 2 of B071
664   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
665   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
666   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
667   gMC->Gsatt("B069","seen",-1); // all B069 sub-levels skipped   -
668   gMC->Gsatt("B056","seen",0);  // B056 does not has sub-levels  -
669   gMC->Gsatt("B059","seen",-1); // all B059 sub-levels skipped   -
670   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
671   gMC->Gsatt("BTR1","seen",0);  // BTR1 do not have sub-levels   -
672   gMC->Gsatt("BTO1","seen",0);
673
674  
675   // Level 2 of B074
676   gMC->Gsatt("BTR2","seen",0); // BTR2 does not has sub-levels -
677   gMC->Gsatt("BTO2","seen",0);
678
679   // Level 2 of B075
680   gMC->Gsatt("BTR3","seen",0); // BTR3 do not have sub-levels -
681   gMC->Gsatt("BTO3","seen",0);
682
683 // ==================> Level 3
684   // Level 3 of B071 / Level 2 of BTO1
685   gMC->Gsatt("FTOC","seen",-2);
686   gMC->Gsatt("FTOB","seen",-2);
687   gMC->Gsatt("FTOA","seen",-2);
688  
689   // Level 3 of B074 / Level 2 of BTO2
690   // -> cfr previous settings
691  
692   // Level 3 of B075 / Level 2 of BTO3
693   // -> cfr previous settings
694
695   gMC->Gdopt("hide","on");
696   gMC->Gdopt("shad","on");
697   gMC->Gsatt("*", "fill", 5);
698   gMC->SetClipBox(".");
699   gMC->SetClipBox("*", 0, 1000, 0, 1000, 0, 1000);
700   gMC->DefaultRange();
701   gMC->Gdraw("alic", 45, 40, 0, 10, 10, .015, .015);
702   gMC->Gdhead(1111,"TOF detector V1");
703   gMC->Gdman(18, 4, "MAN");
704   gMC->Gdopt("hide","off");
705 }                                 
706
707 //_____________________________________________________________________________
708 void AliTOFv4T0::DrawDetectorStrips() const
709 {
710   //
711   // Draw a shaded view of the TOF strips for version 4
712   //
713   
714   //Set ALIC mother transparent
715   gMC->Gsatt("ALIC","SEEN",0);
716   
717   //
718   //Set volumes visible 
719   //=====> Level 1
720   // Level 1 for TOF volumes
721   gMC->Gsatt("B077","seen",0);
722   
723   //==========> Level 2
724   // Level 2
725   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
726   gMC->Gsatt("B071","seen",0);
727   gMC->Gsatt("B074","seen",0);
728   gMC->Gsatt("B075","seen",0);
729   gMC->Gsatt("B080","seen",0); // B080 does not has sub-level
730   
731   // Level 2 of B071
732   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
733   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
734   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
735   gMC->Gsatt("B069","seen",-1); // all B069 sub-levels skipped   -
736   gMC->Gsatt("B056","seen",0);  // B056 does not has sub-levels  -
737   gMC->Gsatt("B059","seen",-1); // all B059 sub-levels skipped   -
738   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
739   gMC->Gsatt("BTR1","seen",0);  // BTR1 do not have sub-levels   -
740   gMC->Gsatt("BTO1","seen",0);
741   
742   // ==================> Level 3
743   // Level 3 of B071 / Level 2 of BTO1
744   gMC->Gsatt("FTOC","seen",0);
745   gMC->Gsatt("FTOB","seen",0);
746   gMC->Gsatt("FTOA","seen",0);
747   
748   // Level 3 of B074 / Level 2 of BTO2
749   // -> cfr previous settings
750   
751   // Level 3 of B075 / Level 2 of BTO3
752   // -> cfr previous settings
753   
754   
755   // ==========================> Level 4
756   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOC
757   gMC->Gsatt("FLTC","seen",0);
758   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOB
759   gMC->Gsatt("FLTB","seen",0);
760   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOA
761   gMC->Gsatt("FLTA","seen",0);
762   
763   // Level 4 of B074 / Level 3 of BTO2 / Level 2 of FTOC
764   // -> cfr previous settings
765   // Level 4 of B074 / Level 3 of BTO2 / Level 2 of FTOB
766   // -> cfr previous settings
767   
768   // Level 4 of B075 / Level 3 of BTO3 / Level 2 of FTOC
769   // -> cfr previous settings
770   
771   //======================================> Level 5
772   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOC / Level 2 of FLTC
773   gMC->Gsatt("FALC","seen",0); // no children for FALC
774   gMC->Gsatt("FSTR","seen",-2);
775   gMC->Gsatt("FPEC","seen",0); // no children for FPEC
776   gMC->Gsatt("FECC","seen",0); // no children for FECC
777   gMC->Gsatt("FWAC","seen",0); // no children for FWAC
778   gMC->Gsatt("FAIC","seen",0); // no children for FAIC
779   
780   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOB / Level 2 of FLTB
781   gMC->Gsatt("FALB","seen",0); // no children for FALB
782   //-->  gMC->Gsatt("FSTR","seen",-2);
783   
784   
785   // -> cfr previous settings
786   gMC->Gsatt("FPEB","seen",0); // no children for FPEB
787   gMC->Gsatt("FECB","seen",0); // no children for FECB
788   gMC->Gsatt("FWAB","seen",0); // no children for FWAB
789   gMC->Gsatt("FAIB","seen",0); // no children for FAIB
790   
791   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOA / Level 2 of FLTA
792   gMC->Gsatt("FALA","seen",0); // no children for FALB
793   //-->  gMC->Gsatt("FSTR","seen",-2);
794   // -> cfr previous settings
795   gMC->Gsatt("FPEA","seen",0); // no children for FPEA
796   gMC->Gsatt("FECA","seen",0); // no children for FECA
797   gMC->Gsatt("FWAA","seen",0); // no children for FWAA
798   gMC->Gsatt("FAIA","seen",0); // no children for FAIA
799   
800   // Level 2 of B074
801   gMC->Gsatt("BTR2","seen",0); // BTR2 does not has sub-levels -
802   gMC->Gsatt("BTO2","seen",0);
803   
804   // Level 2 of B075
805   gMC->Gsatt("BTR3","seen",0); // BTR3 do not have sub-levels -
806   gMC->Gsatt("BTO3","seen",0);
807   
808   // for others Level 5, cfr. previous settings
809
810   gMC->Gdopt("hide","on");
811   gMC->Gdopt("shad","on");
812   gMC->Gsatt("*", "fill", 5);
813   gMC->SetClipBox(".");
814   gMC->SetClipBox("*", 0, 1000, 0, 1000, 0, 1000);
815   gMC->DefaultRange();
816   gMC->Gdraw("alic", 45, 40, 0, 10, 10, .015, .015);
817   gMC->Gdhead(1111,"TOF Strips V1");
818   gMC->Gdman(18, 4, "MAN");
819   gMC->Gdopt("hide","off");
820 }
821
822 //_____________________________________________________________________________
823 void AliTOFv4T0::CreateMaterials()
824 {
825   //
826   // Define materials for the Time Of Flight
827   //
828   //AliTOF::CreateMaterials();
829
830   //
831   // Defines TOF materials for all versions
832   // Revision: F. Pierella 18-VI-2002
833   //
834
835   AliMagF *magneticField = (AliMagF*)((AliMagF*)TGeoGlobalMagField::Instance()->GetField());
836
837   Int_t   isxfld = magneticField->Integ();
838   Float_t sxmgmx = magneticField->Max();
839
840   //--- Quartz (SiO2) to simulate float glass
841   //    density tuned to have correct float glass 
842   //    radiation length
843   Float_t   aq[2] = { 28.0855,15.9994 };
844   Float_t   zq[2] = { 14.,8. };
845   Float_t   wq[2] = { 1.,2. };
846   Float_t   dq = 2.55; // std value: 2.2
847   Int_t nq = -2;
848
849   // --- Freon C2F4H2 (TOF-TDR pagg.)
850   // Geant Manual CONS110-1, pag. 43 (Geant, Detector Description and Simulation Tool)
851   Float_t afre[3]  = {12.011,18.998,1.007};
852   Float_t zfre[3]  = { 6., 9., 1.}; 
853   Float_t wfre[3]  = { 2., 4., 2.};
854   Float_t densfre  = 0.00375;   
855 // http://www.fi.infn.it/sezione/prevprot/gas/freon.html
856   Int_t nfre = -3; 
857 /*
858   //-- Isobutane quencher C4H10 (5% in the sensitive mixture)
859   Float_t aiso[2]  = {12.011,1.007};
860   Float_t ziso[2]  = { 6.,  1.};
861   Float_t wiso[2]  = { 4., 10.};
862   Float_t densiso  = .......;  // (g/cm3) density
863   Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
864   //-- SF6 (5% in the sensitive mixture)
865   Float_t asf[3]  = {32.066,18.998};
866   Float_t zsf[3]  = { 16., 9.};
867   Float_t wsf[3]  = {  1., 6.}; 
868   Float_t denssf  = .....;   // (g/cm3) density
869   Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
870 */
871   // --- CO2 
872   Float_t ac[2]   = {12.,16.};
873   Float_t zc[2]   = { 6., 8.};
874   Float_t wc[2]   = { 1., 2.};
875   Float_t dc = .001977;
876   Int_t nc = -2;
877    // For mylar (C5H4O2) 
878   Float_t amy[3] = { 12., 1., 16. };
879   Float_t zmy[3] = {  6., 1.,  8. };
880   Float_t wmy[3] = {  5., 4.,  2. };
881   Float_t dmy    = 1.39;
882   Int_t nmy = -3;
883  // For polyethilene (CH2) - honeycomb -
884   Float_t ape[2] = { 12., 1. };
885   Float_t zpe[2] = {  6., 1. };
886   Float_t wpe[2] = {  1., 2. };
887   Float_t dpe    = 0.935*0.479; //To have 1%X0 for 1cm as for honeycomb
888   Int_t npe = -2;
889   // --- G10 
890   Float_t ag10[4] = { 12.,1.,16.,28. };
891   Float_t zg10[4] = {  6.,1., 8.,14. };
892   Float_t wmatg10[4] = { .259,.288,.248,.205 };
893   Float_t densg10  = 1.7;
894   Int_t nlmatg10 = -4;
895
896   // plexiglass CH2=C(CH3)CO2CH3
897   Float_t aplex[3] = { 12.,1.,16.};
898   Float_t zplex[3] = {  6.,1., 8.};
899   Float_t wmatplex[3] = {5.,8.,2.};
900   Float_t densplex  =1.16;
901   Int_t nplex = -3;
902
903   // ---- ALUMINA (AL203) 
904   Float_t aal[2] = { 27.,16.};
905   Float_t zal[2] = { 13., 8.};
906   Float_t wmatal[2] = { 2.,3. };
907   Float_t densal  = 2.3;
908   Int_t nlmatal = -2;
909   // -- Water
910   Float_t awa[2] = {  1., 16. };
911   Float_t zwa[2] = {  1.,  8. };
912   Float_t wwa[2] = {  2.,  1. };
913   Float_t dwa    = 1.0;
914   Int_t nwa = -2;
915
916 // stainless steel
917   Float_t asteel[4] = { 55.847,51.9961,58.6934,28.0855 };
918   Float_t zsteel[4] = { 26.,24.,28.,14. };
919   Float_t wsteel[4] = { .715,.18,.1,.005 };
920
921   //AliMaterial(0, "Vacuum$", 1e-16, 1e-16, 1e-16, 1e16, 1e16);
922
923   // AIR
924   Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
925   Float_t zAir[4]={6.,7.,8.,18.};
926   Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
927   Float_t dAir = 1.20479E-3;
928
929   AliMixture( 1, "Air$", aAir, zAir, dAir, 4, wAir);
930
931   AliMaterial( 2, "Cu $",  63.54, 29.0, 8.96, 1.43, 14.8);
932   AliMaterial( 3, "C  $",  12.01,  6.0, 2.265,18.8, 74.4);
933   AliMixture ( 4, "Polyethilene$", ape, zpe, dpe, npe, wpe);
934   AliMixture ( 5, "G10$", ag10, zg10, densg10, nlmatg10, wmatg10);
935   AliMixture ( 6, "PLE$", aplex, zplex, densplex, nplex, wmatplex);
936   AliMixture ( 7, "CO2$", ac, zc, dc, nc, wc);
937   AliMixture ( 8, "ALUMINA$", aal, zal, densal, nlmatal, wmatal);
938   AliMaterial( 9, "Al $", 26.98, 13., 2.7, 8.9, 37.2);
939   AliMaterial(10, "C-TRD$", 12.01, 6., 2.265*18.8/69.282*15./100, 18.8, 74.4); // for 15%
940   AliMixture (11, "Mylar$",  amy, zmy, dmy, nmy, wmy);
941   AliMixture (12, "Freon$",  afre, zfre, densfre, nfre, wfre);
942   AliMixture (13, "Glass$", aq, zq, dq, nq, wq);
943   AliMixture (14, "Water$",  awa, zwa, dwa, nwa, wwa);
944   AliMixture (15, "STAINLESS STEEL$", asteel, zsteel, 7.88, 4, wsteel);
945
946   Float_t epsil, stmin, deemax, stemax;
947  
948   //   Previous data
949   //       EPSIL  =  0.1   ! Tracking precision, 
950   //       STEMAX = 0.1      ! Maximum displacement for multiple scattering
951   //       DEEMAX = 0.1    ! Maximum fractional energy loss, DLS 
952   //       STMIN  = 0.1 
953   //
954   //   New data  
955   epsil  = .001;  // Tracking precision,
956   stemax = -1.;   // Maximum displacement for multiple scattering
957   deemax = -.3;   // Maximum fractional energy loss, DLS
958   stmin  = -.8;
959
960   AliMedium( 1, "Air$"  ,  1, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
961   AliMedium( 2, "Cu $"  ,  2, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
962   AliMedium( 3, "C  $"  ,  3, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
963   AliMedium( 4, "Pol$"  ,  4, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
964   AliMedium( 5, "G10$"  ,  5, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
965   AliMedium( 6, "PLE$"  ,  6, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
966   AliMedium( 7, "CO2$"  ,  7, 0, isxfld, sxmgmx, 10., -.01, -.1, .01, -.01);
967   AliMedium( 8,"ALUMINA$", 8, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
968   AliMedium( 9,"Al Frame$",9, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
969   AliMedium(10, "DME-S$",  6, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
970   AliMedium(11, "C-TRD$", 10, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
971   AliMedium(12, "Myl$"  , 11, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
972   AliMedium(13, "Fre$"  , 12, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
973   AliMedium(14, "Fre-S$", 12, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
974   AliMedium(15, "Glass$", 13, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
975   AliMedium(16, "Water$", 14, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
976   AliMedium(17, "STEEL$", 15, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
977
978 }
979
980 //_____________________________________________________________________________
981 void AliTOFv4T0::Init()
982 {
983   //
984   // Initialise the detector after the geometry has been defined
985   //
986   AliDebug(1, "**************************************"
987            "  TOF  "
988            "**************************************");
989   AliDebug(1, "  Version 4 of TOF initialing, "
990            "symmetric TOF - Full Coverage version");
991   
992   AliTOF::Init();
993   
994   fIdFTOA = gMC->VolId("FTOA");
995   fIdFTOB = gMC->VolId("FTOB");
996   fIdFTOC = gMC->VolId("FTOC");
997   fIdFLTA = gMC->VolId("FLTA");
998   fIdFLTB = gMC->VolId("FLTB");
999   fIdFLTC = gMC->VolId("FLTC");
1000
1001   AliDebug(1, "**************************************"
1002            "  TOF  "
1003            "**************************************");
1004 }
1005  
1006 //_____________________________________________________________________________
1007 void AliTOFv4T0::StepManager()
1008 {
1009
1010   //
1011   // Procedure called at each step in the Time Of Flight
1012   //
1013
1014   TLorentzVector mom, pos;
1015   Float_t xm[3],pm[3],xpad[3],ppad[3];
1016   Float_t hits[14];
1017   Int_t   vol[5];
1018   Int_t   sector, plate, padx, padz, strip;
1019   Int_t   copy, padzid, padxid, stripid, i;
1020   Int_t   *idtmed = fIdtmed->GetArray()-499;
1021   Float_t incidenceAngle;
1022       
1023   if(
1024      gMC->IsTrackEntering()
1025      && gMC->TrackCharge()
1026      //&& gMC->GetMedium()==idtmed[513]
1027      && gMC->CurrentMedium()==idtmed[513]
1028      && gMC->CurrentVolID(copy)==fIdSens
1029      )
1030   {
1031
1032     AliMC *mcApplication = (AliMC*)gAlice->GetMCApp();
1033
1034     AddTrackReference(mcApplication->GetCurrentTrackNumber(), AliTrackReference::kTOF);
1035     //AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
1036
1037     // getting information about hit volumes
1038     
1039     padzid=gMC->CurrentVolOffID(2,copy);
1040     padz=copy; 
1041
1042     
1043     padxid=gMC->CurrentVolOffID(1,copy);
1044     padx=copy; 
1045     
1046     stripid=gMC->CurrentVolOffID(4,copy);
1047     strip=copy; 
1048
1049     gMC->TrackPosition(pos);
1050     gMC->TrackMomentum(mom);
1051
1052
1053     //    Double_t NormPos=1./pos.Rho();
1054
1055     Double_t normMom=1./mom.Rho();
1056
1057     //  getting the cohordinates in pad ref system
1058
1059     xm[0] = (Float_t)pos.X();
1060     xm[1] = (Float_t)pos.Y();
1061     xm[2] = (Float_t)pos.Z();
1062
1063     pm[0] = (Float_t)mom.X()*normMom;
1064     pm[1] = (Float_t)mom.Y()*normMom;
1065     pm[2] = (Float_t)mom.Z()*normMom;
1066  
1067     gMC->Gmtod(xm,xpad,1);
1068     gMC->Gmtod(pm,ppad,2);
1069
1070     
1071     if (TMath::Abs(ppad[1])>1) {
1072       AliWarning("Abs(ppad) > 1");
1073       ppad[1]=TMath::Sign((Float_t)1,ppad[1]);
1074     }
1075     incidenceAngle = TMath::ACos(ppad[1])*kRaddeg;
1076
1077
1078     const char * pathA="FTOA";
1079     const char * pathB="FTOB";
1080     const char * pathC="FTOC";
1081     const char * path71="B071";
1082     const char * path75="B075";
1083     const char * path74="B074";
1084     const char* volpath;    
1085
1086     Int_t index=0;
1087     volpath=gMC->CurrentVolOffName(6);
1088     index=gMC->CurrentVolOffID(6,copy);
1089     index=copy;
1090
1091     
1092     plate=-1;
1093     if(strcmp(pathC,volpath)==0 && index==1)plate=0;
1094     if(strcmp(pathB,volpath)==0 && index==1)plate=1;
1095     if(strcmp(pathA,volpath)==0 && index==0)plate=2;
1096     if(strcmp(pathB,volpath)==0 && index==2)plate=3;
1097     if(strcmp(pathC,volpath)==0 && index==2)plate=4;
1098
1099
1100
1101     if (plate==0) strip=fTOFGeometry->NStripC()-strip;
1102     else if (plate==1) strip=fTOFGeometry->NStripB()-strip;
1103     else strip--;
1104  
1105     //Apply ALICE conventions for volume numbering increasing with theta, phi
1106
1107     if (plate==3 || plate==4){
1108       padx=fTOFGeometry->NpadX()-padx;
1109       padz=fTOFGeometry->NpadZ()-padz;
1110       xpad[0]=-xpad[0];      
1111       xpad[2]=-xpad[2];      
1112     }
1113     else {
1114      padx--;
1115      padz--;
1116     }
1117
1118
1119
1120     volpath=gMC->CurrentVolOffName(8);
1121     index=gMC->CurrentVolOffID(8,copy);
1122     index=copy;
1123
1124     sector=-1;
1125     if(strcmp(path71,volpath)==0 && index <6) sector=12+index;
1126     if(strcmp(path71,volpath)==0 && index >=6) sector=index-3;
1127     if(strcmp(path75,volpath)==0) sector=index-1;
1128     if(strcmp(path74,volpath)==0) sector=10+index;
1129
1130     for(i=0;i<3;++i) {
1131       hits[i]   = pos[i];
1132       hits[i+3] = pm[i];
1133     }
1134
1135     hits[6] = mom.Rho();
1136     hits[7] = pos[3];
1137     hits[8] = xpad[0];
1138     hits[9] = xpad[1];
1139     hits[10]= xpad[2];
1140     hits[11]= incidenceAngle;
1141     hits[12]= gMC->Edep();
1142     hits[13]= gMC->TrackLength();
1143     
1144     vol[0]= sector;
1145     vol[1]= plate;
1146     vol[2]= strip;
1147     vol[3]= padx;
1148     vol[4]= padz;    
1149
1150     AddT0Hit(mcApplication->GetCurrentTrackNumber(),vol, hits);
1151     //AddT0Hit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
1152   }
1153 }