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