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