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