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