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