GetMedium replaced by CurrentMedium (I.Hrivnacova)
[u/mrichter/AliRoot.git] / TOF / AliTOFv0.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 0 of the Time Of Flight    //
21 //  detector.                                                                //
22 //                                                                           //
23 //  VERSION WITH 5 MODULES AND TILTED STRIPS                                 //
24 //  NO HITS DEFINED BY DEFAULT FOR THIS VERSION                              //
25 //   FULL COVERAGE VERSION                                                   //
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/AliTOFv0Class.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 "AliTOFv0.h"
59 #include "AliTOFConstants.h" // AdC
60 #include "AliMC.h"
61  
62 ClassImp(AliTOFv0)
63  
64 //_____________________________________________________________________________
65 AliTOFv0::AliTOFv0()
66 {
67   //
68   // Default constructor
69   //
70 }
71  
72 //_____________________________________________________________________________
73 AliTOFv0::AliTOFv0(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 AliTOFv0::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 AliTOFv0::CreateGeometry()
184 {
185   //
186   // Create geometry for Time Of Flight version 0
187   //
188   //Begin_Html
189   /*
190     <img src="picts/AliTOFv0.gif">
191   */
192   //End_Html
193   //
194   // Creates common geometry
195   //
196   AliTOF::CreateGeometry();
197 }
198  
199 //_____________________________________________________________________________
200 void AliTOFv0::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   cout <<"************************* TOF geometry **************************"<<endl;
272  
273   par[2] = (zFLTA *0.5);
274   gMC->Gsvolu("FLTA", "BOX ", idtmed[512], par, 3); // Insensitive Freon
275   gMC->Gspos ("FLTA", 0, "FTOA", 0., 0., 0., 0, "ONLY");
276
277   par[2] = (zFLTB * 0.5);
278   gMC->Gsvolu("FLTB", "BOX ", idtmed[512], par, 3); // Insensitive Freon
279   gMC->Gspos ("FLTB", 0, "FTOB", 0., 0., 0., 0, "ONLY");
280
281   par[2] = (zFLTC * 0.5);
282   gMC->Gsvolu("FLTC", "BOX ", idtmed[512], par, 3); // Insensitive Freon
283   gMC->Gspos ("FLTC", 0, "FTOC", 0., 0., 0., 0, "ONLY");
284  
285 ////////// Layers of Aluminum before and after detector //////////
286 ////////// Aluminum Box for Modules (2.0 mm thickness)  /////////
287 ////////// lateral walls not simulated
288   par[0] = xFLT*0.5;
289   par[1] = 0.1;//cm
290   ycoor = -yFLT/2 + par[1];
291   par[2] = (zFLTA *0.5);
292   gMC->Gsvolu("FALA", "BOX ", idtmed[508], par, 3); // Alluminium
293   gMC->Gspos ("FALA", 1, "FLTA", 0., ycoor, 0., 0, "ONLY");
294   gMC->Gspos ("FALA", 2, "FLTA", 0.,-ycoor, 0., 0, "ONLY");
295   par[2] = (zFLTB *0.5);
296   gMC->Gsvolu("FALB", "BOX ", idtmed[508], par, 3); // Alluminium 
297   gMC->Gspos ("FALB", 1, "FLTB", 0., ycoor, 0., 0, "ONLY");
298   gMC->Gspos ("FALB", 2, "FLTB", 0.,-ycoor, 0., 0, "ONLY");
299   par[2] = (zFLTC *0.5);
300   gMC->Gsvolu("FALC", "BOX ", idtmed[508], par, 3); // Alluminium
301   gMC->Gspos ("FALC", 1, "FLTC", 0., ycoor, 0., 0, "ONLY");
302   gMC->Gspos ("FALC", 2, "FLTC", 0.,-ycoor, 0., 0, "ONLY");
303   
304 ///////////////// Detector itself //////////////////////
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   par[0] = xFLT*0.5;
314   par[1] = yPad*0.5; 
315   par[2] = stripWidth*0.5;
316   
317 // new description for strip volume -double stack strip-
318 // -- all constants are expressed in cm
319 // heigth of different layers
320   const Float_t khhony = 1.      ;   // heigth of HONY  Layer
321   const Float_t khpcby = 0.15    ;   // heigth of PCB   Layer
322   const Float_t khmyly = 0.035   ;   // heigth of MYLAR Layer
323   const Float_t khgraphy = 0.02  ;   // heigth of GRAPHITE Layer
324   const Float_t khglasseiy = 0.17;   // 0.6 Ext. Glass + 1.1 i.e. (Int. Glass/2) (mm)
325   const Float_t khsensmy = 0.11  ;   // heigth of Sensitive Freon Mixture
326   const Float_t kwsensmz = 2*3.5 ;   // cm
327   const Float_t klsensmx = 48*2.5;   // cm
328   const Float_t kwpadz = 3.5;   // cm z dimension of the FPAD volume
329   const Float_t klpadx = 2.5;   // cm x dimension of the FPAD volume
330   
331   // heigth of the FSTR Volume (the strip volume)
332   const Float_t khstripy = 2*khhony+3*khpcby+4*(khmyly+khgraphy+khglasseiy)+2*khsensmy;
333   // width  of the FSTR Volume (the strip volume)
334   const Float_t kwstripz = 10.;
335   // length of the FSTR Volume (the strip volume)
336   const Float_t klstripx = 122.;
337   
338   Float_t parfp[3]={klstripx*0.5,khstripy*0.5,kwstripz*0.5};
339 // coordinates of the strip center in the strip reference frame; used for positioning
340 // internal strip volumes
341   Float_t posfp[3]={0.,0.,0.};   
342
343   
344   // FSTR volume definition and filling this volume with non sensitive Gas Mixture
345   gMC->Gsvolu("FSTR","BOX",idtmed[512],parfp,3);
346   //-- HONY Layer definition
347 //  parfp[0] = -1;
348   parfp[1] = khhony*0.5;
349 //  parfp[2] = -1;
350   gMC->Gsvolu("FHON","BOX",idtmed[503],parfp,3);
351   // positioning 2 HONY Layers on FSTR volume
352
353   posfp[1]=-khstripy*0.5+parfp[1];
354   gMC->Gspos("FHON",1,"FSTR",0., posfp[1],0.,0,"ONLY");
355   gMC->Gspos("FHON",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
356
357   //-- PCB Layer definition 
358   parfp[1] = khpcby*0.5;
359   gMC->Gsvolu("FPCB","BOX",idtmed[504],parfp,3);
360   // positioning 2 PCB Layers on FSTR volume
361   posfp[1]=-khstripy*0.5+khhony+parfp[1];
362   gMC->Gspos("FPCB",1,"FSTR",0., posfp[1],0.,0,"ONLY");
363   gMC->Gspos("FPCB",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
364   // positioning the central PCB layer
365   gMC->Gspos("FPCB",3,"FSTR",0.,0.,0.,0,"ONLY");
366
367
368
369   //-- MYLAR Layer definition
370   parfp[1] = khmyly*0.5;
371   gMC->Gsvolu("FMYL","BOX",idtmed[511],parfp,3);
372   // positioning 2 MYLAR Layers on FSTR volume
373   posfp[1] = -khstripy*0.5+khhony+khpcby+parfp[1]; 
374   gMC->Gspos("FMYL",1,"FSTR",0., posfp[1],0.,0,"ONLY");
375   gMC->Gspos("FMYL",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
376   // adding further 2 MYLAR Layers on FSTR volume
377   posfp[1] = khpcby*0.5+parfp[1];
378   gMC->Gspos("FMYL",3,"FSTR",0., posfp[1],0.,0,"ONLY");
379   gMC->Gspos("FMYL",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
380
381
382   //-- Graphite Layer definition
383   parfp[1] = khgraphy*0.5;
384   gMC->Gsvolu("FGRP","BOX",idtmed[502],parfp,3);
385   // positioning 2 Graphite Layers on FSTR volume
386   posfp[1] = -khstripy*0.5+khhony+khpcby+khmyly+parfp[1];
387   gMC->Gspos("FGRP",1,"FSTR",0., posfp[1],0.,0,"ONLY");
388   gMC->Gspos("FGRP",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
389   // adding further 2 Graphite Layers on FSTR volume
390   posfp[1] = khpcby*0.5+khmyly+parfp[1];
391   gMC->Gspos("FGRP",3,"FSTR",0., posfp[1],0.,0,"ONLY");
392   gMC->Gspos("FGRP",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
393  
394
395   //-- Glass (EXT. +Semi INT.) Layer definition
396   parfp[1] = khglasseiy*0.5;
397   gMC->Gsvolu("FGLA","BOX",idtmed[514],parfp,3);
398   // positioning 2 Glass Layers on FSTR volume
399   posfp[1] = -khstripy*0.5+khhony+khpcby+khmyly+khgraphy+parfp[1];
400   gMC->Gspos("FGLA",1,"FSTR",0., posfp[1],0.,0,"ONLY");
401   gMC->Gspos("FGLA",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
402   // adding further 2 Glass Layers on FSTR volume
403   posfp[1] = khpcby*0.5+khmyly+khgraphy+parfp[1];
404   gMC->Gspos("FGLA",3,"FSTR",0., posfp[1],0.,0,"ONLY");
405   gMC->Gspos("FGLA",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
406
407   
408   //-- Sensitive Mixture Layer definition
409   parfp[0] = klsensmx*0.5;
410   parfp[1] = khsensmy*0.5;
411   parfp[2] = kwsensmz*0.5;
412   gMC->Gsvolu("FSEN","BOX",idtmed[513],parfp,3);
413   gMC->Gsvolu("FNSE","BOX",idtmed[512],parfp,3);
414   // positioning 2 gas Layers on FSTR volume
415   // the upper is insensitive freon
416   // while the remaining is sensitive
417   posfp[1] = khpcby*0.5+khmyly+khgraphy+khglasseiy+parfp[1];
418   gMC->Gspos("FNSE",0,"FSTR", 0., posfp[1],0.,0,"ONLY");
419   gMC->Gspos("FSEN",0,"FSTR", 0.,-posfp[1],0.,0,"ONLY");
420
421   // dividing FSEN along z in knz=2 and along x in knx=48
422   gMC->Gsdvn("FSEZ","FSEN",knz,3);
423   gMC->Gsdvn("FSEX","FSEZ",knx,1);
424   
425   // FPAD volume definition
426   parfp[0] = klpadx*0.5;    
427   parfp[1] = khsensmy*0.5;
428   parfp[2] = kwpadz*0.5;
429   gMC->Gsvolu("FPAD","BOX",idtmed[513],parfp,3);
430   // positioning the FPAD volumes on previous divisions
431   gMC->Gspos("FPAD",0,"FSEX",0.,0.,0.,0,"ONLY");
432   
433 ////  Positioning the Strips  (FSTR) in the FLT volumes  /////
434
435   // Plate A (Central) 
436   
437   Float_t t = zFLTC+zFLTB+zFLTA*0.5+ 2*db;//Half Width of Barrel
438
439   Float_t gap  = fGapA+0.5; //cm  updated distance between the strip axis
440   Float_t zpos = 0;
441   Float_t ang  = 0;
442   Int_t j=1; // AdC
443   nrot  = 0;
444   zcoor = 0;
445   ycoor = -14.5 + kspace ; //2 cm over front plate
446
447   AliMatrix (idrotm[0],  90.,  0.,90.,90.,0., 90.);   
448
449   Int_t centerLoc= (Int_t)(fNStripA/2.) + 1; // AdC
450
451   //gMC->Gspos("FSTR",j,"FLTA",0.,ycoor, 0.,idrotm[0],"ONLY");
452   gMC->Gspos("FSTR",centerLoc,"FLTA",0.,ycoor, 0.,idrotm[0],"ONLY"); // AdC
453   if(fDebug>=1) {
454     printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,j); // AdC
455     printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
456   }
457   zcoor -= zSenStrip;
458   //j++; // AdC
459   Int_t upDown = -1; // upDown=-1 -> Upper strip
460                      // upDown=+1 -> Lower strip
461   do{
462      ang = atan(zcoor/radius);
463      ang *= kRaddeg;
464      AliMatrix (idrotm[nrot],  90.,  0.,90.-ang,90.,-ang, 90.);   
465      AliMatrix (idrotm[nrot+1],90.,180.,90.+ang,90., ang, 90.);
466      ang /= kRaddeg;
467      ycoor = -14.5+ kspace; //2 cm over front plate
468      ycoor += (1-(upDown+1)/2)*gap;
469      //gMC->Gspos("FSTR",j  ,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY");
470      //gMC->Gspos("FSTR",j+1,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
471     gMC->Gspos("FSTR",centerLoc-j,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY"); // AdC
472     gMC->Gspos("FSTR",centerLoc+j,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY"); // AdC
473     if(fDebug>=1) {
474       printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,j); // AdC
475       printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
476     }
477     //j += 2; // AdC
478     upDown*= -1; // Alternate strips 
479     zcoor = zcoor-(zSenStrip/2)/TMath::Cos(ang)-
480       upDown*gap*TMath::Tan(ang)-
481       (zSenStrip/2)/TMath::Cos(ang);
482   } while (zcoor-(stripWidth/2)*TMath::Cos(ang)>-t+zFLTC+zFLTB+db*2);
483   
484   zcoor = zcoor+(zSenStrip/2)/TMath::Cos(ang)+
485     upDown*gap*TMath::Tan(ang)+
486     (zSenStrip/2)/TMath::Cos(ang);
487   
488   gap = fGapB;
489   zcoor = zcoor-(zSenStrip/2)/TMath::Cos(ang)-
490     upDown*gap*TMath::Tan(ang)-
491     (zSenStrip/2)/TMath::Cos(ang);
492   
493   ang = atan(zcoor/radius);
494   ang *= kRaddeg;
495   AliMatrix (idrotm[nrot],  90.,  0.,90.-ang,90.,-ang, 90.);   
496   AliMatrix (idrotm[nrot+1],90.,180.,90.+ang,90., ang, 90.);
497   ang /= kRaddeg;
498           
499   ycoor = -14.5+ kspace; //2 cm over front plate
500   ycoor += (1-(upDown+1)/2)*gap;
501   //gMC->Gspos("FSTR",j  ,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY");
502   //gMC->Gspos("FSTR",j+1,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
503   gMC->Gspos("FSTR",centerLoc-j,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY"); // AdC
504   gMC->Gspos("FSTR",centerLoc+j,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY"); // AdC
505   if(fDebug>=1) {
506     printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,j); // AdC
507     printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
508   }
509   ycoor = -hTof/2.+ kspace;//2 cm over front plate
510
511   // Plate  B
512
513   nrot = 0;
514   Int_t i=1; // AdC
515   upDown = 1;
516   Float_t deadRegion = 1.0;//cm
517   
518   zpos = zcoor - (zSenStrip/2)/TMath::Cos(ang)-
519          upDown*gap*TMath::Tan(ang)-
520          (zSenStrip/2)/TMath::Cos(ang)-
521          deadRegion/TMath::Cos(ang);
522
523   ang = atan(zpos/radius);
524   ang *= kRaddeg;
525   AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
526   ang /= kRaddeg;
527   ycoor = -hTof*0.5+ kspace ; //2 cm over front plate
528   ycoor += (1-(upDown+1)/2)*gap;
529   zcoor = zpos+(zFLTA*0.5+zFLTB*0.5+db); // Moves to the system of the modulus FLTB
530   gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
531   if(fDebug>=1) {   
532     printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i); 
533     printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
534   }
535   i++;
536   upDown*=-1;
537
538   do {
539      zpos = zpos - (zSenStrip/2)/TMath::Cos(ang)-
540             upDown*gap*TMath::Tan(ang)-
541             (zSenStrip/2)/TMath::Cos(ang);
542      ang = atan(zpos/radius);
543      ang *= kRaddeg;
544      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
545      ang /= kRaddeg;
546      Float_t deltaSpaceinB=-0.5; // [cm] to avoid overlaps with the end of freon frame
547      Float_t deltaGapinB=0.5;    // [cm] to avoid overlaps in between initial strips
548      ycoor = -hTof*0.5+ kspace+deltaSpaceinB ; //2 cm over front plate
549      ycoor += (1-(upDown+1)/2)*(gap+deltaGapinB);
550      zcoor = zpos+(zFLTA*0.5+zFLTB*0.5+db); // Moves to the system of the modulus FLTB
551      gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
552      if(fDebug>=1) {   
553        printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i); 
554        printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
555      }
556      upDown*=-1;
557      i++;
558   } while (TMath::Abs(ang*kRaddeg)<22.5);
559   //till we reach a tilting angle of 22.5 degrees
560
561   ycoor = -hTof*0.5+ kspace ; //2 cm over front plate
562   zpos = zpos - zSenStrip/TMath::Cos(ang);
563   // this avoid overlaps in between outer strips in plate B
564   Float_t deltaMovingUp=0.8;    // [cm]
565   Float_t deltaMovingDown=-0.5; // [cm]
566
567   do {
568      ang = atan(zpos/radius);
569      ang *= kRaddeg;
570      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
571      ang /= kRaddeg;
572      zcoor = zpos+(zFLTB/2+zFLTA/2+db);
573      gMC->Gspos("FSTR",i, "FLTB", 0., ycoor+deltaMovingDown+deltaMovingUp, zcoor,idrotm[nrot], "ONLY");
574      deltaMovingUp+=0.8; // update delta moving toward the end of the plate
575      zpos = zpos - zSenStrip/TMath::Cos(ang);
576      if(fDebug>=1) {
577        printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i);
578        printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
579      }
580      i++;
581   }  while (zpos-stripWidth*0.5/TMath::Cos(ang)>-t+zFLTC+db);
582   
583   // Plate  C
584   
585   zpos = zpos + zSenStrip/TMath::Cos(ang);
586
587   zpos = zpos - (zSenStrip/2)/TMath::Cos(ang)+
588          gap*TMath::Tan(ang)-
589          (zSenStrip/2)/TMath::Cos(ang);
590
591   nrot = 0;
592   i=0;
593   Float_t deltaGap=-2.5; // [cm] update distance from strip center and plate
594   ycoor= -hTof*0.5+kspace+gap+deltaGap;
595
596   do {
597      i++;
598      ang = atan(zpos/radius);
599      ang *= kRaddeg;
600      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
601      ang /= kRaddeg;
602      zcoor = zpos+(zFLTC*0.5+zFLTB+zFLTA*0.5+db*2);
603      gMC->Gspos("FSTR",i, "FLTC", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
604      if(fDebug>=1) {
605        printf("%s: %f,  St. %2i, Pl.5 ",ClassName(),ang*kRaddeg,i);
606        printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
607      }
608      zpos = zpos - zSenStrip/TMath::Cos(ang);
609   }  while (zpos-stripWidth*TMath::Cos(ang)*0.5>-t);
610
611
612 ////////// Layers after strips /////////////////
613 // honeycomb (Polyethilene) Layer after (1.2cm)
614
615   Float_t overSpace = fOverSpc;//cm
616
617   par[0] = xFLT*0.5;
618   par[1] = 0.6;
619   par[2] = (zFLTA *0.5);
620   ycoor = -yFLT/2 + overSpace + par[1];
621   gMC->Gsvolu("FPEA", "BOX ", idtmed[503], par, 3); // Hony
622   gMC->Gspos ("FPEA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
623   par[2] = (zFLTB *0.5);
624   gMC->Gsvolu("FPEB", "BOX ", idtmed[503], par, 3); // Hony
625   gMC->Gspos ("FPEB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
626   par[2] = (zFLTC *0.5);
627   gMC->Gsvolu("FPEC", "BOX ", idtmed[503], par, 3); // Hony
628   gMC->Gspos ("FPEC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
629
630 // Electronics (Cu) after
631   ycoor += par[1];
632   par[0] = xFLT*0.5;
633   par[1] = 1.43*0.05*0.5; // 5% of X0
634   par[2] = (zFLTA *0.5);
635   ycoor += par[1];
636   gMC->Gsvolu("FECA", "BOX ", idtmed[501], par, 3); // Cu
637   gMC->Gspos ("FECA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
638   par[2] = (zFLTB *0.5);
639   gMC->Gsvolu("FECB", "BOX ", idtmed[501], par, 3); // Cu
640   gMC->Gspos ("FECB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
641   par[2] = (zFLTC *0.5);
642   gMC->Gsvolu("FECC", "BOX ", idtmed[501], par, 3); // Cu
643   gMC->Gspos ("FECC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
644
645 // cooling WAter after
646   ycoor += par[1];
647   par[0] = xFLT*0.5;
648   par[1] = 36.1*0.02*0.5; // 2% of X0
649   par[2] = (zFLTA *0.5);
650   ycoor += par[1];
651   gMC->Gsvolu("FWAA", "BOX ", idtmed[515], par, 3); // Water
652   gMC->Gspos ("FWAA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
653   par[2] = (zFLTB *0.5);
654   gMC->Gsvolu("FWAB", "BOX ", idtmed[515], par, 3); // Water
655   gMC->Gspos ("FWAB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
656   par[2] = (zFLTC *0.5);
657   gMC->Gsvolu("FWAC", "BOX ", idtmed[515], par, 3); // Water
658   gMC->Gspos ("FWAC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
659
660 // frame of Air
661   ycoor += par[1];
662   par[0] = xFLT*0.5;
663   par[1] = (yFLT/2-ycoor-0.2)*0.5; // Aluminum layer considered (0.2 cm)
664   par[2] = (zFLTA *0.5);
665   ycoor += par[1];
666   gMC->Gsvolu("FAIA", "BOX ", idtmed[500], par, 3); // Air
667   gMC->Gspos ("FAIA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
668   par[2] = (zFLTB *0.5);
669   gMC->Gsvolu("FAIB", "BOX ", idtmed[500], par, 3); // Air
670   gMC->Gspos ("FAIB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
671   par[2] = (zFLTC *0.5);
672   gMC->Gsvolu("FAIC", "BOX ", idtmed[500], par, 3); // Air
673   gMC->Gspos ("FAIC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
674 /* fp
675 //Back Plate honycomb (2cm)
676   par[0] = -1;
677   par[1] = 2 *0.5;
678   par[2] = -1;
679   ycoor = yFLT/2 - par[1];
680   gMC->Gsvolu("FBPA", "BOX ", idtmed[503], par, 3); // Hony
681   gMC->Gspos ("FBPA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
682   gMC->Gsvolu("FBPB", "BOX ", idtmed[503], par, 3); // Hony
683   gMC->Gspos ("FBPB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
684   gMC->Gsvolu("FBPC", "BOX ", idtmed[503], par, 3); // Hony
685   gMC->Gspos ("FBPC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
686 fp */
687 }
688
689 //_____________________________________________________________________________
690 void AliTOFv0::DrawModule() const
691 {
692   //
693   // Draw a shaded view of the Time Of Flight version 0
694   //
695   // Set everything unseen
696   gMC->Gsatt("*", "seen", -1);
697   // 
698   // Set ALIC mother transparent
699   gMC->Gsatt("ALIC","SEEN",0);
700   //
701   // Set the volumes visible
702   gMC->Gsatt("ALIC","SEEN",0);
703
704   gMC->Gsatt("FTOA","SEEN",1);
705   gMC->Gsatt("FTOB","SEEN",1);
706   gMC->Gsatt("FTOC","SEEN",1);
707   gMC->Gsatt("FLTA","SEEN",1);
708   gMC->Gsatt("FLTB","SEEN",1);
709   gMC->Gsatt("FLTC","SEEN",1);
710   gMC->Gsatt("FPLA","SEEN",1);
711   gMC->Gsatt("FPLB","SEEN",1);
712   gMC->Gsatt("FPLC","SEEN",1);
713   gMC->Gsatt("FSTR","SEEN",1);
714   gMC->Gsatt("FPEA","SEEN",1);
715   gMC->Gsatt("FPEB","SEEN",1);
716   gMC->Gsatt("FPEC","SEEN",1);
717   
718   gMC->Gsatt("FLZ1","SEEN",0);
719   gMC->Gsatt("FLZ2","SEEN",0);
720   gMC->Gsatt("FLZ3","SEEN",0);
721   gMC->Gsatt("FLX1","SEEN",0);
722   gMC->Gsatt("FLX2","SEEN",0);
723   gMC->Gsatt("FLX3","SEEN",0);
724   gMC->Gsatt("FPAD","SEEN",0);
725
726   gMC->Gdopt("hide", "on");
727   gMC->Gdopt("shad", "on");
728   gMC->Gsatt("*", "fill", 7);
729   gMC->SetClipBox(".");
730   gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
731   gMC->DefaultRange();
732   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
733   gMC->Gdhead(1111, "Time Of Flight");
734   gMC->Gdman(18, 4, "MAN");
735   gMC->Gdopt("hide","off");
736 }
737 //_____________________________________________________________________________
738 void AliTOFv0::DrawDetectorModules()
739 {
740 //
741 // Draw a shaded view of the TOF detector version 0
742 //
743  
744 //Set ALIC mother transparent
745  gMC->Gsatt("ALIC","SEEN",0);
746
747 //
748 //Set volumes visible
749 // 
750 //=====> Level 1
751   // Level 1 for TOF volumes
752   gMC->Gsatt("B077","seen",0);
753  
754  
755 //==========> Level 2
756   // Level 2
757   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
758   gMC->Gsatt("B071","seen",0);
759   gMC->Gsatt("B074","seen",0);
760   gMC->Gsatt("B075","seen",0);
761   gMC->Gsatt("B080","seen",0); // B080 does not has sub-level                
762
763
764   // Level 2 of B071
765   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
766   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
767   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
768   gMC->Gsatt("B069","seen",-1); // all B069 sub-levels skipped   -
769   gMC->Gsatt("B056","seen",0);  // B056 does not has sub-levels  -
770   gMC->Gsatt("B059","seen",-1); // all B059 sub-levels skipped   -
771   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
772   gMC->Gsatt("BTR1","seen",0);  // BTR1 do not have sub-levels   -
773   gMC->Gsatt("BTO1","seen",0);
774
775  
776   // Level 2 of B074
777   gMC->Gsatt("BTR2","seen",0); // BTR2 does not has sub-levels -
778   gMC->Gsatt("BTO2","seen",0);
779
780   // Level 2 of B075
781   gMC->Gsatt("BTR3","seen",0); // BTR3 do not have sub-levels -
782   gMC->Gsatt("BTO3","seen",0);
783
784 // ==================> Level 3
785   // Level 3 of B071 / Level 2 of BTO1
786   gMC->Gsatt("FTOC","seen",-2);
787   gMC->Gsatt("FTOB","seen",-2);
788   gMC->Gsatt("FTOA","seen",-2);
789  
790   // Level 3 of B074 / Level 2 of BTO2
791   // -> cfr previous settings
792  
793   // Level 3 of B075 / Level 2 of BTO3
794   // -> cfr previous settings
795
796   gMC->Gdopt("hide","on");
797   gMC->Gdopt("shad","on");
798   gMC->Gsatt("*", "fill", 5);
799   gMC->SetClipBox(".");
800   gMC->SetClipBox("*", 0, 1000, 0, 1000, 0, 1000);
801   gMC->DefaultRange();
802   gMC->Gdraw("alic", 45, 40, 0, 10, 10, .015, .015);
803   gMC->Gdhead(1111,"TOF detector V1");
804   gMC->Gdman(18, 4, "MAN");
805   gMC->Gdopt("hide","off");
806 }                                 
807
808 //_____________________________________________________________________________
809 void AliTOFv0::DrawDetectorStrips()
810 {
811 //
812 // Draw a shaded view of the TOF strips for version 0
813 //
814  
815 //Set ALIC mother transparent
816  gMC->Gsatt("ALIC","SEEN",0);
817
818 //
819 //Set volumes visible 
820 //=====> Level 1
821   // Level 1 for TOF volumes
822   gMC->Gsatt("B077","seen",0);
823   
824 //==========> Level 2
825   // Level 2
826   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
827   gMC->Gsatt("B071","seen",0);
828   gMC->Gsatt("B074","seen",0);
829   gMC->Gsatt("B075","seen",0);
830   gMC->Gsatt("B080","seen",0); // B080 does not has sub-level
831
832   // Level 2 of B071
833   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
834   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
835   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
836   gMC->Gsatt("B069","seen",-1); // all B069 sub-levels skipped   -
837   gMC->Gsatt("B056","seen",0);  // B056 does not has sub-levels  -
838   gMC->Gsatt("B059","seen",-1); // all B059 sub-levels skipped   -
839   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
840   gMC->Gsatt("BTR1","seen",0);  // BTR1 do not have sub-levels   -
841   gMC->Gsatt("BTO1","seen",0);
842
843 // ==================> Level 3
844   // Level 3 of B071 / Level 2 of BTO1
845   gMC->Gsatt("FTOC","seen",0);
846   gMC->Gsatt("FTOB","seen",0);
847   gMC->Gsatt("FTOA","seen",0);
848  
849   // Level 3 of B074 / Level 2 of BTO2
850   // -> cfr previous settings
851  
852   // Level 3 of B075 / Level 2 of BTO3
853   // -> cfr previous settings
854
855
856 // ==========================> Level 4
857   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOC
858   gMC->Gsatt("FLTC","seen",0);
859   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOB
860   gMC->Gsatt("FLTB","seen",0);
861   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOA
862   gMC->Gsatt("FLTA","seen",0);
863  
864   // Level 4 of B074 / Level 3 of BTO2 / Level 2 of FTOC
865   // -> cfr previous settings
866   // Level 4 of B074 / Level 3 of BTO2 / Level 2 of FTOB
867   // -> cfr previous settings
868  
869   // Level 4 of B075 / Level 3 of BTO3 / Level 2 of FTOC
870   // -> cfr previous settings
871
872 //======================================> Level 5
873   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOC / Level 2 of FLTC
874   gMC->Gsatt("FALC","seen",0); // no children for FALC
875   gMC->Gsatt("FSTR","seen",-2);
876   gMC->Gsatt("FPEC","seen",0); // no children for FPEC
877   gMC->Gsatt("FECC","seen",0); // no children for FECC
878   gMC->Gsatt("FWAC","seen",0); // no children for FWAC
879   gMC->Gsatt("FAIC","seen",0); // no children for FAIC
880
881   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOB / Level 2 of FLTB
882   gMC->Gsatt("FALB","seen",0); // no children for FALB
883 //-->  gMC->Gsatt("FSTR","seen",-2);
884
885
886   // -> cfr previous settings
887   gMC->Gsatt("FPEB","seen",0); // no children for FPEB
888   gMC->Gsatt("FECB","seen",0); // no children for FECB
889   gMC->Gsatt("FWAB","seen",0); // no children for FWAB
890   gMC->Gsatt("FAIB","seen",0); // no children for FAIB
891  
892   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOA / Level 2 of FLTA
893   gMC->Gsatt("FALA","seen",0); // no children for FALB
894 //-->  gMC->Gsatt("FSTR","seen",-2);
895   // -> cfr previous settings
896   gMC->Gsatt("FPEA","seen",0); // no children for FPEA
897   gMC->Gsatt("FECA","seen",0); // no children for FECA
898   gMC->Gsatt("FWAA","seen",0); // no children for FWAA
899   gMC->Gsatt("FAIA","seen",0); // no children for FAIA
900
901   // Level 2 of B074
902   gMC->Gsatt("BTR2","seen",0); // BTR2 does not has sub-levels -
903   gMC->Gsatt("BTO2","seen",0);
904
905   // Level 2 of B075
906   gMC->Gsatt("BTR3","seen",0); // BTR3 do not have sub-levels -
907   gMC->Gsatt("BTO3","seen",0);
908
909 // for others Level 5, cfr. previous settings
910
911   gMC->Gdopt("hide","on");
912   gMC->Gdopt("shad","on");
913   gMC->Gsatt("*", "fill", 5);
914   gMC->SetClipBox(".");
915   gMC->SetClipBox("*", 0, 1000, 0, 1000, 0, 1000);
916   gMC->DefaultRange();
917   gMC->Gdraw("alic", 45, 40, 0, 10, 10, .015, .015);
918   gMC->Gdhead(1111,"TOF Strips V1");
919   gMC->Gdman(18, 4, "MAN");
920   gMC->Gdopt("hide","off");
921 }
922
923 //_____________________________________________________________________________
924 void AliTOFv0::CreateMaterials()
925 {
926   //
927   // Define materials for the Time Of Flight
928   //
929   AliTOF::CreateMaterials();
930 }
931  
932 //_____________________________________________________________________________
933 void AliTOFv0::Init()
934 {
935   //
936   // Initialise the detector after the geometry has been defined
937   //
938   printf("**************************************"
939          "  TOF  "
940          "**************************************\n");
941   printf("\n   Version 0 of TOF initialing, "
942               "symmetric TOF - Full Coverage version\n");
943
944   AliTOF::Init();
945
946   fIdFTOA = gMC->VolId("FTOA");
947   fIdFTOB = gMC->VolId("FTOB");
948   fIdFTOC = gMC->VolId("FTOC");
949   fIdFLTA = gMC->VolId("FLTA");
950   fIdFLTB = gMC->VolId("FLTB");
951   fIdFLTC = gMC->VolId("FLTC");
952
953   if(fDebug) {
954     printf("%s: **************************************"
955            "  TOF  "
956            "**************************************\n",ClassName());
957   }
958 }
959  
960 //_____________________________________________________________________________
961 void AliTOFv0::StepManager()
962 {
963   //
964   // Procedure called at each step in the Time Of Flight
965   //
966   TLorentzVector mom, pos;
967   Float_t xm[3],pm[3],xpad[3],ppad[3];
968   Float_t hits[13],phi,phid,z;
969   Int_t   vol[5];
970   Int_t   sector, plate, padx, padz, strip;
971   Int_t   copy, padzid, padxid, stripid, i;
972   Int_t   *idtmed = fIdtmed->GetArray()-499;
973   Float_t incidenceAngle;
974   
975   if(gMC->CurrentMedium()==idtmed[513] && 
976      gMC->IsTrackEntering() && gMC->TrackCharge()
977      && gMC->CurrentVolID(copy)==fIdSens) 
978   {    
979     // getting information about hit volumes
980     
981     padzid=gMC->CurrentVolOffID(2,copy);
982     padz=copy;  
983     
984     padxid=gMC->CurrentVolOffID(1,copy);
985     padx=copy;  
986     
987     stripid=gMC->CurrentVolOffID(4,copy);
988     strip=copy;  
989
990     gMC->TrackPosition(pos);
991     gMC->TrackMomentum(mom);
992
993 //    Double_t NormPos=1./pos.Rho();
994     Double_t normMom=1./mom.Rho();
995
996 //  getting the cohordinates in pad ref system
997     xm[0] = (Float_t)pos.X();
998     xm[1] = (Float_t)pos.Y();
999     xm[2] = (Float_t)pos.Z();
1000
1001     pm[0] = (Float_t)mom.X()*normMom;
1002     pm[1] = (Float_t)mom.Y()*normMom;
1003     pm[2] = (Float_t)mom.Z()*normMom;
1004  
1005     gMC->Gmtod(xm,xpad,1);
1006     gMC->Gmtod(pm,ppad,2);
1007
1008     incidenceAngle = TMath::ACos(ppad[1])*kRaddeg;
1009
1010     z = pos[2];
1011
1012     plate = 0;   
1013     if (TMath::Abs(z) <=  fZlenA*0.5)  plate = 2; //3; // AdC
1014     if (z < (fZlenA*0.5+fZlenB) && 
1015         z >  fZlenA*0.5)               plate = 1; //4; // AdC
1016     if (z >-(fZlenA*0.5+fZlenB) &&
1017         z < -fZlenA*0.5)               plate = 3; //2; // AdC
1018     if (z > (fZlenA*0.5+fZlenB))       plate = 0; //5; // AdC
1019     if (z <-(fZlenA*0.5+fZlenB))       plate = 4; //1; // AdC
1020
1021     if (plate==0) strip=AliTOFConstants::fgkNStripC-strip; // AdC
1022     else if (plate==1) strip=AliTOFConstants::fgkNStripB-strip; // AdC
1023     else strip--; // AdC
1024
1025     if (z<=0.) padx=AliTOFConstants::fgkNpadX-padx; // AdC
1026     else padx--; // AdC
1027
1028     if (plate==3 || plate==4) padz=AliTOFConstants::fgkNpadZ-padz; // AdC
1029     else padz--; // AdC
1030
1031     phi = pos.Phi();
1032     if (phi>=0.) phid = phi*kRaddeg; //+180.; // AdC
1033     else phid = phi*kRaddeg + 360.; // AdC
1034     sector = Int_t (phid/20.);
1035     //sector++;  // AdC
1036
1037     for(i=0;i<3;++i) {
1038       hits[i]   = pos[i];
1039       hits[i+3] = pm[i];
1040     }
1041
1042     hits[6] = mom.Rho();
1043     hits[7] = pos[3];
1044     hits[8] = xpad[0];
1045     hits[9] = xpad[1];
1046     hits[10]= xpad[2];
1047     hits[11]= incidenceAngle;
1048     hits[12]= gMC->Edep();
1049     
1050     vol[0]= sector;
1051     vol[1]= plate;
1052     vol[2]= strip;
1053     vol[3]= padx;
1054     vol[4]= padz;
1055
1056     AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
1057   }
1058 }
1059
1060
1061
1062
1063
1064