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