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