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