]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFv4T0.cxx
- Adding alternate versions of methods for handling regional structures and
[u/mrichter/AliRoot.git] / TOF / AliTOFv4T0.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  This class contains the functions for version 4 of the Time Of Flight    //
21 //  detector.                                                                //
22 //                                                                           //
23 //  VERSION WITH 5 MODULES AND TILTED STRIPS                                 //
24 //                                                                           //
25 //   FULL COVERAGE VERSION +OPTION for PHOS holes                            //
26 //                                                                           //
27 //   Author:                                                                 //
28 //   Fabrizio Pierella                                                       //
29 //   University of Bologna - Italy                                           //
30 //                                                                           //
31 //                                                                           //
32 //Begin_Html                                                                 //
33 /*                                                                           //
34 <img src="picts/AliTOFv4T0Class.gif">                                        //
35 */                                                                           //
36 //End_Html                                                                   //
37 //                                                                           //
38 ///////////////////////////////////////////////////////////////////////////////
39
40 #include "TBRIK.h"
41 #include "TGeometry.h"
42 #include "TLorentzVector.h"
43 #include "TNode.h"
44 #include "TVirtualMC.h"
45
46 #include "AliConst.h"
47 #include "AliLog.h"
48 #include "AliMagF.h"
49 #include "AliMC.h"
50 #include "AliRun.h"
51 #include "AliTrackReference.h"
52
53 #include "AliTOFGeometry.h"
54 #include "AliTOFGeometryV4.h"
55 #include "AliTOFv4T0.h"
56
57 extern TDirectory *gDirectory;
58 extern TVirtualMC *gMC;
59
60 extern AliRun *gAlice;
61
62 ClassImp(AliTOFv4T0)
63
64 //_____________________________________________________________________________
65   AliTOFv4T0::AliTOFv4T0():
66   fIdFTOA(-1),
67   fIdFTOB(-1),
68   fIdFTOC(-1),
69   fIdFLTA(-1),
70   fIdFLTB(-1),
71   fIdFLTC(-1),
72   fTOFHoles(kFALSE)
73 {
74   //
75   // Default constructor
76   //
77 }
78  
79 //_____________________________________________________________________________
80 AliTOFv4T0::AliTOFv4T0(const char *name, const char *title):
81   AliTOF(name,title,"tzero"),
82   fIdFTOA(-1),
83   fIdFTOB(-1),
84   fIdFTOC(-1),
85   fIdFLTA(-1),
86   fIdFLTB(-1),
87   fIdFLTC(-1),
88   fTOFHoles(kFALSE)
89 {
90   //
91   // Standard constructor
92   //
93   //
94   // Check that FRAME is there otherwise we have no place where to
95   // put TOF
96
97
98   AliModule* frame = (AliModule*)gAlice->GetModule("FRAME");
99   if(!frame) {
100     AliFatal("TOF needs FRAME to be present");
101   } else{
102     
103     if (fTOFGeometry) delete fTOFGeometry;
104     fTOFGeometry = new AliTOFGeometryV4();
105
106     if(frame->IsVersion()==1) {
107       AliInfo(Form("Frame version %d", frame->IsVersion())); 
108       AliInfo("Full Coverage for TOF");
109       fTOFHoles=false;}    
110     else {
111       AliInfo(Form("Frame version %d", frame->IsVersion())); 
112       AliInfo("TOF with Holes for PHOS");
113       fTOFHoles=true;}      
114   }
115   fTOFGeometry->SetHoles(fTOFHoles);
116
117   // Save the geometry
118   TDirectory* saveDir = gDirectory;
119   gAlice->GetRunLoader()->CdGAFile();
120   fTOFGeometry->Write("TOFgeometry");
121   saveDir->cd();
122
123
124
125 //____________________________________________________________________________
126 void AliTOFv4T0::BuildGeometry()
127 {
128   //
129   // Build TOF ROOT geometry for the ALICE event display
130   //
131   TNode *node, *top;
132   const int kColorTOF  = 27;
133   
134   TGeometry *globalGeometry = (TGeometry*)gAlice->GetGeometry();
135
136   // Find top TNODE
137   top = (TNode*)globalGeometry->GetNode("alice");
138   
139   // Position the different copies
140   const Float_t krTof  =(fTOFGeometry->Rmax()+fTOFGeometry->Rmin())/2.;
141   const Float_t khTof  = fTOFGeometry->Rmax()-fTOFGeometry->Rmin();
142   const Int_t   kNTof  = fTOFGeometry->NSectors();
143   const Float_t kPi    = TMath::Pi();
144   const Float_t kangle = 2*kPi/kNTof;
145   Float_t ang;
146   
147   // define offset for nodes
148   Float_t zOffsetC = fTOFGeometry->MaxhZtof() - fTOFGeometry->ZlenC()*0.5;
149   Float_t zOffsetB = fTOFGeometry->MaxhZtof() - fTOFGeometry->ZlenC() - fTOFGeometry->ZlenB()*0.5;
150   Float_t zOffsetA = 0.;
151   // Define TOF basic volume
152   
153   char nodeName0[7], nodeName1[7], nodeName2[7];
154   char nodeName3[7], nodeName4[7], rotMatNum[7];
155   
156   new TBRIK("S_TOF_C","TOF box","void",
157             fTOFGeometry->StripLength()*0.5, khTof*0.5, fTOFGeometry->ZlenC()*0.5);
158   new TBRIK("S_TOF_B","TOF box","void",
159             fTOFGeometry->StripLength()*0.5, khTof*0.5, fTOFGeometry->ZlenB()*0.5);
160   new TBRIK("S_TOF_A","TOF box","void",
161             fTOFGeometry->StripLength()*0.5, khTof*0.5, fTOFGeometry->ZlenA()*0.5);
162   
163   for (Int_t nodeNum=1;nodeNum<19;nodeNum++){
164     
165     if (nodeNum<10) {
166       sprintf(rotMatNum,"rot50%i",nodeNum);
167       sprintf(nodeName0,"FTO00%i",nodeNum);
168       sprintf(nodeName1,"FTO10%i",nodeNum);
169       sprintf(nodeName2,"FTO20%i",nodeNum);
170       sprintf(nodeName3,"FTO30%i",nodeNum);
171       sprintf(nodeName4,"FTO40%i",nodeNum);
172     }
173     if (nodeNum>9) {
174       sprintf(rotMatNum,"rot5%i",nodeNum);
175       sprintf(nodeName0,"FTO0%i",nodeNum);
176       sprintf(nodeName1,"FTO1%i",nodeNum);
177       sprintf(nodeName2,"FTO2%i",nodeNum);
178       sprintf(nodeName3,"FTO3%i",nodeNum);
179       sprintf(nodeName4,"FTO4%i",nodeNum);
180     }
181     
182     new TRotMatrix(rotMatNum,rotMatNum,90,-20*nodeNum,90,90-20*nodeNum,0,0);
183     ang = (4.5-nodeNum) * kangle;
184
185     top->cd();
186     node = new TNode(nodeName0,nodeName0,"S_TOF_C", krTof*TMath::Cos(ang), krTof*TMath::Sin(ang), zOffsetC,rotMatNum);
187     node->SetLineColor(kColorTOF);
188     fNodes->Add(node);
189     
190     top->cd();
191     node = new TNode(nodeName1,nodeName1,"S_TOF_C", krTof*TMath::Cos(ang), krTof*TMath::Sin(ang),-zOffsetC,rotMatNum);
192     node->SetLineColor(kColorTOF);
193     fNodes->Add(node);
194     
195     top->cd();
196     node = new TNode(nodeName2,nodeName2,"S_TOF_B", krTof*TMath::Cos(ang), krTof*TMath::Sin(ang), zOffsetB,rotMatNum);
197     node->SetLineColor(kColorTOF);
198     fNodes->Add(node);
199     
200     top->cd();
201     node = new TNode(nodeName3,nodeName3,"S_TOF_B", krTof*TMath::Cos(ang), krTof*TMath::Sin(ang),-zOffsetB,rotMatNum);
202     node->SetLineColor(kColorTOF);
203     fNodes->Add(node);
204     
205     top->cd();
206     node = new TNode(nodeName4,nodeName4,"S_TOF_A", krTof*TMath::Cos(ang), krTof*TMath::Sin(ang), zOffsetA,rotMatNum);
207     node->SetLineColor(kColorTOF);
208     fNodes->Add(node);
209   } // end loop on nodeNum
210
211 }
212  
213 //_____________________________________________________________________________
214 void AliTOFv4T0::CreateGeometry()
215 {
216   //
217   // Create geometry for Time Of Flight version 0
218   //
219   //Begin_Html
220   /*
221     <img src="picts/AliTOFv4T0.gif">
222   */
223   //End_Html
224   //
225   // Creates common geometry
226   //
227   AliTOF::CreateGeometry();
228 }
229  
230
231 //_____________________________________________________________________________
232 void AliTOFv4T0::TOFpc(Float_t xtof, Float_t ytof, Float_t zlenC,
233                      Float_t zlenB, Float_t zlenA, Float_t ztof0)
234 {
235   //
236   // Definition of the Time Of Fligh Resistive Plate Chambers
237   // xFLT, yFLT, zFLT - sizes of TOF modules (large)
238
239   Float_t  ycoor;
240   Float_t  par[3];
241   Int_t    *idtmed = fIdtmed->GetArray()-499;
242   Int_t    idrotm[100];
243   Int_t    nrot = 0;
244
245   Float_t radius = fTOFGeometry->Rmin()+2.;//cm
246
247   par[0] =  xtof * 0.5;
248   par[1] =  ytof * 0.5;
249   par[2] = zlenC * 0.5;
250   gMC->Gsvolu("FTOC", "BOX ", idtmed[506], par, 3);
251   par[2] = zlenB * 0.5;
252   gMC->Gsvolu("FTOB", "BOX ", idtmed[506], par, 3);
253   par[2] = zlenA * 0.5;
254   gMC->Gsvolu("FTOA", "BOX ", idtmed[506], par, 3);
255   
256   
257   // Positioning of modules
258   
259   Float_t zcor1 = ztof0 - zlenC*0.5;
260   Float_t zcor2 = ztof0 - zlenC - zlenB*0.5;
261   Float_t zcor3 = 0.;
262   
263   AliMatrix(idrotm[0], 90.,  0., 0., 0., 90,-90.);
264   AliMatrix(idrotm[1], 90.,180., 0., 0., 90, 90.);
265
266   gMC->Gspos("FTOC", 1, "BTO1", 0,  zcor1, 0, idrotm[0], "ONLY");
267   gMC->Gspos("FTOC", 2, "BTO1", 0, -zcor1, 0, idrotm[1], "ONLY");
268   gMC->Gspos("FTOC", 1, "BTO2", 0,  zcor1, 0, idrotm[0], "ONLY");
269   gMC->Gspos("FTOC", 2, "BTO2", 0, -zcor1, 0, idrotm[1], "ONLY");
270   gMC->Gspos("FTOC", 1, "BTO3", 0,  zcor1, 0, idrotm[0], "ONLY");
271   gMC->Gspos("FTOC", 2, "BTO3", 0, -zcor1, 0, idrotm[1], "ONLY");
272   
273   gMC->Gspos("FTOB", 1, "BTO1", 0,  zcor2, 0, idrotm[0], "ONLY");
274   gMC->Gspos("FTOB", 2, "BTO1", 0, -zcor2, 0, idrotm[1], "ONLY");
275   gMC->Gspos("FTOB", 1, "BTO2", 0,  zcor2, 0, idrotm[0], "ONLY");
276   gMC->Gspos("FTOB", 2, "BTO2", 0, -zcor2, 0, idrotm[1], "ONLY");
277   gMC->Gspos("FTOB", 1, "BTO3", 0,  zcor2, 0, idrotm[0], "ONLY");
278   gMC->Gspos("FTOB", 2, "BTO3", 0, -zcor2, 0, idrotm[1], "ONLY");
279   
280   gMC->Gspos("FTOA", 0, "BTO1", 0, zcor3,  0, idrotm[0], "ONLY");
281   if(!fTOFHoles)gMC->Gspos("FTOA", 0, "BTO2", 0, zcor3,  0, idrotm[0], "ONLY");
282   gMC->Gspos("FTOA", 0, "BTO3", 0, zcor3,  0, idrotm[0], "ONLY");
283   
284
285   Float_t db = 0.5; // cm
286   Float_t xFLT, xFST, yFLT, zFLTA, zFLTB, zFLTC;
287   
288   xFLT = fTOFGeometry->StripLength();
289   yFLT = ytof;
290   zFLTA = zlenA;
291   zFLTB = zlenB;
292   zFLTC = zlenC;
293   
294   xFST = xFLT - dynamic_cast<AliTOFGeometryV4*>(fTOFGeometry)->DeadBndX()*2.; // cm
295   
296   // Sizes of MRPC pads
297   
298   Float_t yPad = 0.505; //cm
299   
300   // Large not sensitive volumes with Insensitive Freon
301   par[0] = xFLT*0.5;
302   par[1] = yFLT*0.5;
303   
304   AliDebug(1, "************************* TOF geometry **************************");
305   
306   par[2] = (zFLTA *0.5);
307   gMC->Gsvolu("FLTA", "BOX ", idtmed[512], par, 3); // Insensitive Freon
308   gMC->Gspos ("FLTA", 0, "FTOA", 0., 0., 0., 0, "ONLY");
309   
310   par[2] = (zFLTB * 0.5);
311   gMC->Gsvolu("FLTB", "BOX ", idtmed[512], par, 3); // Insensitive Freon
312   gMC->Gspos ("FLTB", 0, "FTOB", 0., 0., 0., 0, "ONLY");
313   
314   par[2] = (zFLTC * 0.5);
315   gMC->Gsvolu("FLTC", "BOX ", idtmed[512], par, 3); // Insensitive Freon
316   gMC->Gspos ("FLTC", 0, "FTOC", 0., 0., 0., 0, "ONLY");
317   
318   ///// Layers of Aluminum before and after detector /////
319   ///// Aluminum Box for Modules (1.8 mm thickness)  /////
320   ///// lateral walls not simulated for the time being
321   //    const Float_t khAlWall = 0.18;
322   // fp to be checked
323   const Float_t khAlWall = 0.11;
324   par[0] = xFLT*0.5;
325   par[1] = khAlWall/2.; // cm
326   ycoor = -yFLT/2 + par[1];
327   par[2] = (zFLTA *0.5);
328   gMC->Gsvolu("FALA", "BOX ", idtmed[508], par, 3); // Alluminium
329   gMC->Gspos ("FALA", 1, "FLTA", 0., ycoor, 0., 0, "ONLY");
330   gMC->Gspos ("FALA", 2, "FLTA", 0.,-ycoor, 0., 0, "ONLY");
331   par[2] = (zFLTB *0.5);
332   gMC->Gsvolu("FALB", "BOX ", idtmed[508], par, 3); // Alluminium 
333   gMC->Gspos ("FALB", 1, "FLTB", 0., ycoor, 0., 0, "ONLY");
334   gMC->Gspos ("FALB", 2, "FLTB", 0.,-ycoor, 0., 0, "ONLY");
335   par[2] = (zFLTC *0.5);
336   gMC->Gsvolu("FALC", "BOX ", idtmed[508], par, 3); // Alluminium
337   gMC->Gspos ("FALC", 1, "FLTC", 0., ycoor, 0., 0, "ONLY");
338   gMC->Gspos ("FALC", 2, "FLTC", 0.,-ycoor, 0., 0, "ONLY");
339   
340   ///////////////// Detector itself //////////////////////
341   
342   const Float_t  kdeadBound  =  dynamic_cast<AliTOFGeometryV4*>(fTOFGeometry)->DeadBndZ(); //cm non-sensitive between the pad edge 
343   //and the boundary of the strip
344   const Int_t    knx    = fTOFGeometry->NpadX();  // number of pads along x
345   const Int_t    knz    = fTOFGeometry->NpadZ();  // number of pads along z
346   
347   Float_t zSenStrip  = fTOFGeometry->ZPad() * fTOFGeometry->NpadZ(); // cm
348   Float_t stripWidth = zSenStrip + 2*kdeadBound;
349   
350   par[0] = xFLT*0.5;
351   par[1] = yPad*0.5;
352   par[2] = stripWidth*0.5;
353   
354   // new description for strip volume -double stack strip-
355   // -- all constants are expressed in cm
356   // heigth of different layers
357   const Float_t khhony = 0.8     ;   // heigth of HONY  Layer
358   const Float_t khpcby = 0.08    ;   // heigth of PCB   Layer
359   const Float_t khmyly = 0.035   ;   // heigth of MYLAR Layer
360   const Float_t khgraphy = 0.02  ;   // heigth of GRAPHITE Layer
361   const Float_t khglasseiy = 0.135;  // 0.6 Ext. Glass + 1.1 i.e. (Int. Glass/2) (mm)
362   const Float_t khsensmy = 0.11  ;   // heigth of Sensitive Freon Mixture
363   const Float_t kwsensmz = 2*3.5 ;   // cm
364   const Float_t klsensmx = 48*2.5;   // cm
365   const Float_t kwpadz = 3.5;   // cm z dimension of the FPAD volume
366   const Float_t klpadx = 2.5;   // cm x dimension of the FPAD volume
367   
368   // heigth of the FSTR Volume (the strip volume)
369   const Float_t khstripy = 2*khhony+3*khpcby+4*(khmyly+khgraphy+khglasseiy)+2*khsensmy;
370   // width  of the FSTR Volume (the strip volume)
371   const Float_t kwstripz = 10.;
372   // length of the FSTR Volume (the strip volume)
373   const Float_t klstripx = 122.;
374   
375   Float_t parfp[3]={klstripx*0.5,khstripy*0.5,kwstripz*0.5};
376   // Coordinates of the strip center in the strip reference frame;
377   // used for positioninG internal strip volumes
378   Float_t posfp[3]={0.,0.,0.};  
379   
380   
381   // FSTR volume definition-filling this volume with non sensitive Gas Mixture
382   gMC->Gsvolu("FSTR","BOX",idtmed[512],parfp,3);
383   //-- HONY Layer definition
384   //  parfp[0] = -1;
385   parfp[1] = khhony*0.5;
386   //  parfp[2] = -1;
387   gMC->Gsvolu("FHON","BOX",idtmed[503],parfp,3);
388   // positioning 2 HONY Layers on FSTR volume
389   
390   posfp[1]=-khstripy*0.5+parfp[1];
391   gMC->Gspos("FHON",1,"FSTR",0., posfp[1],0.,0,"ONLY");
392   gMC->Gspos("FHON",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
393   
394   //-- PCB Layer definition 
395  
396   parfp[1] = khpcby*0.5;
397   gMC->Gsvolu("FPCB","BOX",idtmed[504],parfp,3);
398   // positioning 2 PCB Layers on FSTR volume
399   posfp[1]=-khstripy*0.5+khhony+parfp[1];
400   gMC->Gspos("FPCB",1,"FSTR",0., posfp[1],0.,0,"ONLY");
401   gMC->Gspos("FPCB",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
402   // positioning the central PCB layer
403   gMC->Gspos("FPCB",3,"FSTR",0.,0.,0.,0,"ONLY");
404   
405   
406   
407   //-- MYLAR Layer definition
408
409   parfp[1] = khmyly*0.5;
410   gMC->Gsvolu("FMYL","BOX",idtmed[511],parfp,3);
411   // positioning 2 MYLAR Layers on FSTR volume
412   posfp[1] = -khstripy*0.5+khhony+khpcby+parfp[1];
413   gMC->Gspos("FMYL",1,"FSTR",0., posfp[1],0.,0,"ONLY");
414   gMC->Gspos("FMYL",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
415   // adding further 2 MYLAR Layers on FSTR volume
416   posfp[1] = khpcby*0.5+parfp[1];
417   gMC->Gspos("FMYL",3,"FSTR",0., posfp[1],0.,0,"ONLY");
418   gMC->Gspos("FMYL",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
419   
420   
421   //-- Graphite Layer definition
422  
423   parfp[1] = khgraphy*0.5;
424   gMC->Gsvolu("FGRP","BOX",idtmed[502],parfp,3);
425   // positioning 2 Graphite Layers on FSTR volume
426   posfp[1] = -khstripy*0.5+khhony+khpcby+khmyly+parfp[1];
427   gMC->Gspos("FGRP",1,"FSTR",0., posfp[1],0.,0,"ONLY");
428   gMC->Gspos("FGRP",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
429   // adding further 2 Graphite Layers on FSTR volume
430   posfp[1] = khpcby*0.5+khmyly+parfp[1];
431   gMC->Gspos("FGRP",3,"FSTR",0., posfp[1],0.,0,"ONLY");
432   gMC->Gspos("FGRP",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
433   
434   
435   //-- Glass (EXT. +Semi INT.) Layer definition
436
437   parfp[1] = khglasseiy*0.5;
438   gMC->Gsvolu("FGLA","BOX",idtmed[514],parfp,3);
439   // positioning 2 Glass Layers on FSTR volume
440   posfp[1] = -khstripy*0.5+khhony+khpcby+khmyly+khgraphy+parfp[1];
441   gMC->Gspos("FGLA",1,"FSTR",0., posfp[1],0.,0,"ONLY");
442   gMC->Gspos("FGLA",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
443   // adding further 2 Glass Layers on FSTR volume
444   posfp[1] = khpcby*0.5+khmyly+khgraphy+parfp[1];
445   gMC->Gspos("FGLA",3,"FSTR",0., posfp[1],0.,0,"ONLY");
446   gMC->Gspos("FGLA",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
447   
448   
449   //-- Sensitive Mixture Layer definition
450  
451   parfp[0] = klsensmx*0.5;
452   parfp[1] = khsensmy*0.5;
453   parfp[2] = kwsensmz*0.5;
454   gMC->Gsvolu("FSEN","BOX",idtmed[513],parfp,3);
455   gMC->Gsvolu("FNSE","BOX",idtmed[512],parfp,3);
456   // positioning 2 gas Layers on FSTR volume
457   // the upper is insensitive freon
458   // while the remaining is sensitive
459   posfp[1] = khpcby*0.5+khmyly+khgraphy+khglasseiy+parfp[1];
460   gMC->Gspos("FNSE",0,"FSTR", 0., posfp[1],0.,0,"ONLY");
461   gMC->Gspos("FSEN",0,"FSTR", 0.,-posfp[1],0.,0,"ONLY");
462   
463   // dividing FSEN along z in knz=2 and along x in knx=48
464
465   gMC->Gsdvn("FSEZ","FSEN",knz,3);
466   gMC->Gsdvn("FSEX","FSEZ",knx,1);
467   
468   // FPAD volume definition
469
470   parfp[0] = klpadx*0.5;   
471   parfp[1] = khsensmy*0.5;
472   parfp[2] = kwpadz*0.5;
473   gMC->Gsvolu("FPAD","BOX",idtmed[513],parfp,3);
474   // positioning the FPAD volumes on previous divisions
475   gMC->Gspos("FPAD",0,"FSEX",0.,0.,0.,0,"ONLY");
476   
477
478   ///////////////////Positioning A module//////////////////////////
479
480
481   for(Int_t istrip =0; istrip < fTOFGeometry->NStripA(); istrip++){
482
483     Float_t ang = fTOFGeometry->GetAngles(2,istrip);
484     AliMatrix (idrotm[0],90.,0.,90.-ang,90.,-ang, 90.);  
485     ang /= kRaddeg;
486     Float_t zpos = tan(ang)*radius;
487     Float_t ypos= fTOFGeometry->GetHeights(2,istrip);
488     gMC->Gspos("FSTR",fTOFGeometry->NStripA()-istrip,"FLTA",0.,ypos, zpos,idrotm[0],  "ONLY");
489     AliDebug(1, Form("y = %f,  z = %f, , z coord = %f, Rot ang = %f, St. %2i",ypos,zpos,tan(ang)*radius ,ang*kRaddeg,istrip));
490   }
491
492   
493   ///////////////////Positioning B module//////////////////////////
494
495   for(Int_t istrip =0; istrip < fTOFGeometry->NStripB(); istrip++){
496
497     Float_t ang = fTOFGeometry->GetAngles(3,istrip);
498     AliMatrix (idrotm[0],90.,0.,90.-ang,90.,-ang, 90.);  
499     ang /= kRaddeg;
500     Float_t zpos = tan(ang)*radius+(zFLTA*0.5+zFLTB*0.5+db);
501     Float_t ypos= fTOFGeometry->GetHeights(3,istrip);
502     gMC->Gspos("FSTR",istrip+1,"FLTB",0.,ypos, zpos,idrotm[nrot],  "ONLY");
503     AliDebug(1, Form("y = %f,  z = %f, , z coord = %f, Rot ang = %f, St. %2i",ypos,zpos,tan(ang)*radius,ang*kRaddeg,istrip));
504   }
505
506   
507   ///////////////////Positioning C module//////////////////////////
508
509   for(Int_t istrip =0; istrip < fTOFGeometry->NStripC(); istrip++){
510
511     Float_t ang = fTOFGeometry->GetAngles(4,istrip);
512     AliMatrix (idrotm[0],90.,0.,90.-ang,90.,-ang, 90.);  
513     ang /= kRaddeg;
514     Float_t zpos = tan(ang)*radius+(zFLTC*0.5+zFLTB+zFLTA*0.5+db*2);
515     Float_t ypos= fTOFGeometry->GetHeights(4,istrip);
516     gMC->Gspos("FSTR",istrip+1,"FLTC",0.,ypos, zpos,idrotm[nrot],  "ONLY");
517     AliDebug(1, Form("y = %f,  z = %f, z coord = %f, Rot ang = %f, St. %2i",ypos,zpos,tan(ang)*radius,ang*kRaddeg,istrip));
518   }
519    
520   ////////// Layers after strips /////////////////
521   // Al Layer thickness (2.3mm) factor 0.7
522   
523   Float_t overSpace = dynamic_cast<AliTOFGeometryV4*>(fTOFGeometry)->OverSpc();//cm
524   
525   par[0] = xFLT*0.5;
526   par[1] = 0.115*0.7; // factor 0.7
527   par[2] = (zFLTA *0.5);
528   ycoor = -yFLT/2 + overSpace + par[1];
529   gMC->Gsvolu("FPEA", "BOX ", idtmed[508], par, 3); // Al
530   gMC->Gspos ("FPEA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
531   par[2] = (zFLTB *0.5);
532   gMC->Gsvolu("FPEB", "BOX ", idtmed[508], par, 3); // Al
533   gMC->Gspos ("FPEB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
534   par[2] = (zFLTC *0.5);
535   gMC->Gsvolu("FPEC", "BOX ", idtmed[508], par, 3); // Al
536   gMC->Gspos ("FPEC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
537   
538   
539   // plexiglass thickness: 1.5 mm ; factor 0.3
540
541   ycoor += par[1];
542   par[0] = xFLT*0.5;
543   par[1] = 0.075*0.3; // factor 0.3 
544   par[2] = (zFLTA *0.5);
545   ycoor += par[1];
546   gMC->Gsvolu("FECA", "BOX ", idtmed[505], par, 3); // Plexigl.
547   gMC->Gspos ("FECA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
548   par[2] = (zFLTB *0.5);
549   gMC->Gsvolu("FECB", "BOX ", idtmed[505], par, 3); // Plexigl.
550   gMC->Gspos ("FECB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
551   par[2] = (zFLTC *0.5);
552   gMC->Gsvolu("FECC", "BOX ", idtmed[505], par, 3); // Plexigl.
553   gMC->Gspos ("FECC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
554   
555   // frame of Air
556
557   ycoor += par[1];
558   par[0] = xFLT*0.5;
559   par[1] = (yFLT/2-ycoor-khAlWall)*0.5; // Aluminum layer considered (0.18 cm)
560   par[2] = (zFLTA *0.5);
561   ycoor += par[1];
562   gMC->Gsvolu("FAIA", "BOX ", idtmed[500], par, 3); // Air
563   gMC->Gspos ("FAIA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
564   par[2] = (zFLTB *0.5);
565   gMC->Gsvolu("FAIB", "BOX ", idtmed[500], par, 3); // Air
566   gMC->Gspos ("FAIB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
567   par[2] = (zFLTC *0.5);
568   gMC->Gsvolu("FAIC", "BOX ", idtmed[500], par, 3); // Air
569   gMC->Gspos ("FAIC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
570   
571   
572   // start with cards and cooling tubes
573   // finally, cards, cooling tubes and layer for thermal dispersion
574   // 3 volumes
575   // card volume definition
576   
577   // see GEOM200 in GEANT manual
578
579
580   AliMatrix(idrotm[98], 90., 0., 90., 90., 0., 0.); // 0 deg
581   
582   Float_t cardpar[3];
583   cardpar[0]= 61.;
584   cardpar[1]= 5.;
585   cardpar[2]= 0.1;
586   gMC->Gsvolu("FCAR", "BOX ", idtmed[504], cardpar, 3); // PCB Card 
587   //alu plate volume definition
588   cardpar[1]= 3.5;
589   cardpar[2]= 0.05;
590   gMC->Gsvolu("FALP", "BOX ", idtmed[508], cardpar, 3); // Alu Plate
591   
592   
593   // central module positioning (FAIA)
594   Float_t cardpos[3], aplpos2, stepforcardA=6.625;
595   cardpos[0]= 0.;
596   cardpos[1]= -0.5;
597   cardpos[2]= -53.;
598   Float_t aplpos1 = -2.;
599   Int_t icard;
600   for (icard=0; icard < fTOFGeometry->NStripA(); ++icard) {
601     cardpos[2]= cardpos[2]+stepforcardA;
602     aplpos2 = cardpos[2]+0.15;
603     gMC->Gspos("FCAR",icard,"FAIA",cardpos[0],cardpos[1],cardpos[2],idrotm[98],"ONLY");
604     gMC->Gspos("FALP",icard,"FAIA",cardpos[0],aplpos1,aplpos2,idrotm[98],"ONLY");
605     
606   }
607   
608   
609   // intermediate module positioning (FAIB)
610   Float_t stepforcardB= 7.05;
611   cardpos[2]= -70.5;
612   for (icard=0; icard < fTOFGeometry->NStripB(); ++icard) {
613     cardpos[2]= cardpos[2]+stepforcardB;
614     aplpos2 = cardpos[2]+0.15; 
615     gMC->Gspos("FCAR",icard,"FAIB",cardpos[0],cardpos[1],cardpos[2],idrotm[98],"ONLY");
616     gMC->Gspos("FALP",icard,"FAIB",cardpos[0],aplpos1,aplpos2,idrotm[98],"ONLY");
617   }
618   
619   
620   // outer module positioning (FAIC)
621   Float_t stepforcardC= 8.45238;
622   cardpos[2]= -88.75;
623   for (icard=0; icard < fTOFGeometry->NStripC(); ++icard) {
624     cardpos[2]= cardpos[2]+stepforcardC;
625     aplpos2 = cardpos[2]+0.15;
626     gMC->Gspos("FCAR",icard,"FAIC",cardpos[0],cardpos[1],cardpos[2],idrotm[98],"ONLY");
627     gMC->Gspos("FALP",icard,"FAIC",cardpos[0],aplpos1,aplpos2,idrotm[98],"ONLY");
628   }
629   
630   // tube volume definition
631
632   Float_t tubepar[3];
633   tubepar[0]= 0.;
634   tubepar[1]= 0.4;
635   tubepar[2]= 61.;
636   gMC->Gsvolu("FTUB", "TUBE", idtmed[516], tubepar, 3); // cooling tubes (steel)
637   tubepar[0]= 0.;
638   tubepar[1]= 0.35;
639   tubepar[2]= 61.;
640   gMC->Gsvolu("FITU", "TUBE", idtmed[515], tubepar, 3); // cooling water
641   // positioning water tube into the steel one
642   gMC->Gspos("FITU",1,"FTUB",0.,0.,0.,0,"ONLY");
643   
644   
645   // rotation matrix
646   AliMatrix(idrotm[99], 180., 90., 90., 90., 90., 0.);
647   // central module positioning (FAIA)
648   Float_t tubepos[3], tdis=0.6;
649   tubepos[0]= 0.;
650   tubepos[1]= cardpos[1];
651   tubepos[2]= -53.+tdis;
652   //  tub1pos = 5.;
653   Int_t itub;
654   for (itub=0; itub < fTOFGeometry->NStripA(); ++itub) {
655     tubepos[2]= tubepos[2]+stepforcardA;
656     gMC->Gspos("FTUB",itub,"FAIA",tubepos[0],tubepos[1],tubepos[2],idrotm[99],
657                "ONLY");
658   }
659   
660   
661   // intermediate module positioning (FAIB)
662   tubepos[2]= -70.5+tdis;
663   for (itub=0; itub < fTOFGeometry->NStripB(); ++itub) {
664     tubepos[2]= tubepos[2]+stepforcardB;
665     gMC->Gspos("FTUB",itub,"FAIB",tubepos[0],tubepos[1],tubepos[2],idrotm[99],
666                "ONLY");
667   }
668   
669   // outer module positioning (FAIC)
670   tubepos[2]= -88.75+tdis;
671   for (itub=0; itub < fTOFGeometry->NStripC(); ++itub) {
672     tubepos[2]= tubepos[2]+stepforcardC;
673     gMC->Gspos("FTUB",itub,"FAIC",tubepos[0],tubepos[1],tubepos[2],idrotm[99],
674                "ONLY");
675   }
676
677 }
678 //_____________________________________________________________________________
679 void AliTOFv4T0::DrawModule() const
680 {
681   //
682   // Draw a shaded view of the Time Of Flight version 4
683   //
684   // Set everything unseen
685   gMC->Gsatt("*", "seen", -1);
686   // 
687   // Set ALIC mother transparent
688   gMC->Gsatt("ALIC","SEEN",0);
689   //
690   // Set the volumes visible
691   gMC->Gsatt("ALIC","SEEN",0);
692
693   gMC->Gsatt("FTOA","SEEN",1);
694   gMC->Gsatt("FTOB","SEEN",1);
695   gMC->Gsatt("FTOC","SEEN",1);
696   gMC->Gsatt("FLTA","SEEN",1);
697   gMC->Gsatt("FLTB","SEEN",1);
698   gMC->Gsatt("FLTC","SEEN",1);
699   gMC->Gsatt("FPLA","SEEN",1);
700   gMC->Gsatt("FPLB","SEEN",1);
701   gMC->Gsatt("FPLC","SEEN",1);
702   gMC->Gsatt("FSTR","SEEN",1);
703   gMC->Gsatt("FPEA","SEEN",1);
704   gMC->Gsatt("FPEB","SEEN",1);
705   gMC->Gsatt("FPEC","SEEN",1);
706   
707   gMC->Gsatt("FLZ1","SEEN",0);
708   gMC->Gsatt("FLZ2","SEEN",0);
709   gMC->Gsatt("FLZ3","SEEN",0);
710   gMC->Gsatt("FLX1","SEEN",0);
711   gMC->Gsatt("FLX2","SEEN",0);
712   gMC->Gsatt("FLX3","SEEN",0);
713   gMC->Gsatt("FPAD","SEEN",0);
714
715   gMC->Gdopt("hide", "on");
716   gMC->Gdopt("shad", "on");
717   gMC->Gsatt("*", "fill", 7);
718   gMC->SetClipBox(".");
719   gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
720   gMC->DefaultRange();
721   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
722   gMC->Gdhead(1111, "Time Of Flight");
723   gMC->Gdman(18, 4, "MAN");
724   gMC->Gdopt("hide","off");
725 }
726 //_____________________________________________________________________________
727 void AliTOFv4T0::DrawDetectorModules() const
728 {
729 //
730 // Draw a shaded view of the TOF detector version 4
731 //
732  
733  
734 //Set ALIC mother transparent
735   gMC->Gsatt("ALIC","SEEN",0);
736
737 //
738 //Set volumes visible
739 // 
740 //=====> Level 1
741   // Level 1 for TOF volumes
742   gMC->Gsatt("B077","seen",0);
743  
744  
745 //==========> Level 2
746   // Level 2
747   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
748   gMC->Gsatt("B071","seen",0);
749   gMC->Gsatt("B074","seen",0);
750   gMC->Gsatt("B075","seen",0);
751   gMC->Gsatt("B080","seen",0); // B080 does not has sub-level                
752
753
754   // Level 2 of B071
755   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
756   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
757   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
758   gMC->Gsatt("B069","seen",-1); // all B069 sub-levels skipped   -
759   gMC->Gsatt("B056","seen",0);  // B056 does not has sub-levels  -
760   gMC->Gsatt("B059","seen",-1); // all B059 sub-levels skipped   -
761   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
762   gMC->Gsatt("BTR1","seen",0);  // BTR1 do not have sub-levels   -
763   gMC->Gsatt("BTO1","seen",0);
764
765  
766   // Level 2 of B074
767   gMC->Gsatt("BTR2","seen",0); // BTR2 does not has sub-levels -
768   gMC->Gsatt("BTO2","seen",0);
769
770   // Level 2 of B075
771   gMC->Gsatt("BTR3","seen",0); // BTR3 do not have sub-levels -
772   gMC->Gsatt("BTO3","seen",0);
773
774 // ==================> Level 3
775   // Level 3 of B071 / Level 2 of BTO1
776   gMC->Gsatt("FTOC","seen",-2);
777   gMC->Gsatt("FTOB","seen",-2);
778   gMC->Gsatt("FTOA","seen",-2);
779  
780   // Level 3 of B074 / Level 2 of BTO2
781   // -> cfr previous settings
782  
783   // Level 3 of B075 / Level 2 of BTO3
784   // -> cfr previous settings
785
786   gMC->Gdopt("hide","on");
787   gMC->Gdopt("shad","on");
788   gMC->Gsatt("*", "fill", 5);
789   gMC->SetClipBox(".");
790   gMC->SetClipBox("*", 0, 1000, 0, 1000, 0, 1000);
791   gMC->DefaultRange();
792   gMC->Gdraw("alic", 45, 40, 0, 10, 10, .015, .015);
793   gMC->Gdhead(1111,"TOF detector V1");
794   gMC->Gdman(18, 4, "MAN");
795   gMC->Gdopt("hide","off");
796 }                                 
797
798 //_____________________________________________________________________________
799 void AliTOFv4T0::DrawDetectorStrips() const
800 {
801   //
802   // Draw a shaded view of the TOF strips for version 4
803   //
804   
805   //Set ALIC mother transparent
806   gMC->Gsatt("ALIC","SEEN",0);
807   
808   //
809   //Set volumes visible 
810   //=====> Level 1
811   // Level 1 for TOF volumes
812   gMC->Gsatt("B077","seen",0);
813   
814   //==========> Level 2
815   // Level 2
816   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
817   gMC->Gsatt("B071","seen",0);
818   gMC->Gsatt("B074","seen",0);
819   gMC->Gsatt("B075","seen",0);
820   gMC->Gsatt("B080","seen",0); // B080 does not has sub-level
821   
822   // Level 2 of B071
823   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
824   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
825   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
826   gMC->Gsatt("B069","seen",-1); // all B069 sub-levels skipped   -
827   gMC->Gsatt("B056","seen",0);  // B056 does not has sub-levels  -
828   gMC->Gsatt("B059","seen",-1); // all B059 sub-levels skipped   -
829   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
830   gMC->Gsatt("BTR1","seen",0);  // BTR1 do not have sub-levels   -
831   gMC->Gsatt("BTO1","seen",0);
832   
833   // ==================> Level 3
834   // Level 3 of B071 / Level 2 of BTO1
835   gMC->Gsatt("FTOC","seen",0);
836   gMC->Gsatt("FTOB","seen",0);
837   gMC->Gsatt("FTOA","seen",0);
838   
839   // Level 3 of B074 / Level 2 of BTO2
840   // -> cfr previous settings
841   
842   // Level 3 of B075 / Level 2 of BTO3
843   // -> cfr previous settings
844   
845   
846   // ==========================> Level 4
847   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOC
848   gMC->Gsatt("FLTC","seen",0);
849   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOB
850   gMC->Gsatt("FLTB","seen",0);
851   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOA
852   gMC->Gsatt("FLTA","seen",0);
853   
854   // Level 4 of B074 / Level 3 of BTO2 / Level 2 of FTOC
855   // -> cfr previous settings
856   // Level 4 of B074 / Level 3 of BTO2 / Level 2 of FTOB
857   // -> cfr previous settings
858   
859   // Level 4 of B075 / Level 3 of BTO3 / Level 2 of FTOC
860   // -> cfr previous settings
861   
862   //======================================> Level 5
863   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOC / Level 2 of FLTC
864   gMC->Gsatt("FALC","seen",0); // no children for FALC
865   gMC->Gsatt("FSTR","seen",-2);
866   gMC->Gsatt("FPEC","seen",0); // no children for FPEC
867   gMC->Gsatt("FECC","seen",0); // no children for FECC
868   gMC->Gsatt("FWAC","seen",0); // no children for FWAC
869   gMC->Gsatt("FAIC","seen",0); // no children for FAIC
870   
871   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOB / Level 2 of FLTB
872   gMC->Gsatt("FALB","seen",0); // no children for FALB
873   //-->  gMC->Gsatt("FSTR","seen",-2);
874   
875   
876   // -> cfr previous settings
877   gMC->Gsatt("FPEB","seen",0); // no children for FPEB
878   gMC->Gsatt("FECB","seen",0); // no children for FECB
879   gMC->Gsatt("FWAB","seen",0); // no children for FWAB
880   gMC->Gsatt("FAIB","seen",0); // no children for FAIB
881   
882   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOA / Level 2 of FLTA
883   gMC->Gsatt("FALA","seen",0); // no children for FALB
884   //-->  gMC->Gsatt("FSTR","seen",-2);
885   // -> cfr previous settings
886   gMC->Gsatt("FPEA","seen",0); // no children for FPEA
887   gMC->Gsatt("FECA","seen",0); // no children for FECA
888   gMC->Gsatt("FWAA","seen",0); // no children for FWAA
889   gMC->Gsatt("FAIA","seen",0); // no children for FAIA
890   
891   // Level 2 of B074
892   gMC->Gsatt("BTR2","seen",0); // BTR2 does not has sub-levels -
893   gMC->Gsatt("BTO2","seen",0);
894   
895   // Level 2 of B075
896   gMC->Gsatt("BTR3","seen",0); // BTR3 do not have sub-levels -
897   gMC->Gsatt("BTO3","seen",0);
898   
899   // for others Level 5, cfr. previous settings
900
901   gMC->Gdopt("hide","on");
902   gMC->Gdopt("shad","on");
903   gMC->Gsatt("*", "fill", 5);
904   gMC->SetClipBox(".");
905   gMC->SetClipBox("*", 0, 1000, 0, 1000, 0, 1000);
906   gMC->DefaultRange();
907   gMC->Gdraw("alic", 45, 40, 0, 10, 10, .015, .015);
908   gMC->Gdhead(1111,"TOF Strips V1");
909   gMC->Gdman(18, 4, "MAN");
910   gMC->Gdopt("hide","off");
911 }
912
913 //_____________________________________________________________________________
914 void AliTOFv4T0::CreateMaterials()
915 {
916   //
917   // Define materials for the Time Of Flight
918   //
919   //AliTOF::CreateMaterials();
920
921   //
922   // Defines TOF materials for all versions
923   // Revision: F. Pierella 18-VI-2002
924   //
925
926   AliMagF *magneticField = (AliMagF*)gAlice->Field();
927
928   Int_t   isxfld = magneticField->Integ();
929   Float_t sxmgmx = magneticField->Max();
930
931   //--- Quartz (SiO2) to simulate float glass
932   //    density tuned to have correct float glass 
933   //    radiation length
934   Float_t   aq[2] = { 28.0855,15.9994 };
935   Float_t   zq[2] = { 14.,8. };
936   Float_t   wq[2] = { 1.,2. };
937   Float_t   dq = 2.55; // std value: 2.2
938   Int_t nq = -2;
939
940   // --- Freon C2F4H2 (TOF-TDR pagg.)
941   // Geant Manual CONS110-1, pag. 43 (Geant, Detector Description and Simulation Tool)
942   Float_t afre[3]  = {12.011,18.998,1.007};
943   Float_t zfre[3]  = { 6., 9., 1.}; 
944   Float_t wfre[3]  = { 2., 4., 2.};
945   Float_t densfre  = 0.00375;   
946 // http://www.fi.infn.it/sezione/prevprot/gas/freon.html
947   Int_t nfre = -3; 
948 /*
949   //-- Isobutane quencher C4H10 (5% in the sensitive mixture)
950   Float_t aiso[2]  = {12.011,1.007};
951   Float_t ziso[2]  = { 6.,  1.};
952   Float_t wiso[2]  = { 4., 10.};
953   Float_t densiso  = .......;  // (g/cm3) density
954   Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
955   //-- SF6 (5% in the sensitive mixture)
956   Float_t asf[3]  = {32.066,18.998};
957   Float_t zsf[3]  = { 16., 9.};
958   Float_t wsf[3]  = {  1., 6.}; 
959   Float_t denssf  = .....;   // (g/cm3) density
960   Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
961 */
962   // --- CO2 
963   Float_t ac[2]   = {12.,16.};
964   Float_t zc[2]   = { 6., 8.};
965   Float_t wc[2]   = { 1., 2.};
966   Float_t dc = .001977;
967   Int_t nc = -2;
968    // For mylar (C5H4O2) 
969   Float_t amy[3] = { 12., 1., 16. };
970   Float_t zmy[3] = {  6., 1.,  8. };
971   Float_t wmy[3] = {  5., 4.,  2. };
972   Float_t dmy    = 1.39;
973   Int_t nmy = -3;
974  // For polyethilene (CH2) - honeycomb -
975   Float_t ape[2] = { 12., 1. };
976   Float_t zpe[2] = {  6., 1. };
977   Float_t wpe[2] = {  1., 2. };
978   Float_t dpe    = 0.935*0.479; //To have 1%X0 for 1cm as for honeycomb
979   Int_t npe = -2;
980   // --- G10 
981   Float_t ag10[4] = { 12.,1.,16.,28. };
982   Float_t zg10[4] = {  6.,1., 8.,14. };
983   Float_t wmatg10[4] = { .259,.288,.248,.205 };
984   Float_t densg10  = 1.7;
985   Int_t nlmatg10 = -4;
986
987   // plexiglass CH2=C(CH3)CO2CH3
988   Float_t aplex[3] = { 12.,1.,16.};
989   Float_t zplex[3] = {  6.,1., 8.};
990   Float_t wmatplex[3] = {5.,8.,2.};
991   Float_t densplex  =1.16;
992   Int_t nplex = -3;
993
994   // ---- ALUMINA (AL203) 
995   Float_t aal[2] = { 27.,16.};
996   Float_t zal[2] = { 13., 8.};
997   Float_t wmatal[2] = { 2.,3. };
998   Float_t densal  = 2.3;
999   Int_t nlmatal = -2;
1000   // -- Water
1001   Float_t awa[2] = {  1., 16. };
1002   Float_t zwa[2] = {  1.,  8. };
1003   Float_t wwa[2] = {  2.,  1. };
1004   Float_t dwa    = 1.0;
1005   Int_t nwa = -2;
1006
1007 // stainless steel
1008   Float_t asteel[4] = { 55.847,51.9961,58.6934,28.0855 };
1009   Float_t zsteel[4] = { 26.,24.,28.,14. };
1010   Float_t wsteel[4] = { .715,.18,.1,.005 };
1011
1012   //AliMaterial(0, "Vacuum$", 1e-16, 1e-16, 1e-16, 1e16, 1e16);
1013
1014   // AIR
1015   Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
1016   Float_t zAir[4]={6.,7.,8.,18.};
1017   Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
1018   Float_t dAir = 1.20479E-3;
1019
1020   AliMixture( 1, "Air$", aAir, zAir, dAir, 4, wAir);
1021
1022   AliMaterial( 2, "Cu $",  63.54, 29.0, 8.96, 1.43, 14.8);
1023   AliMaterial( 3, "C  $",  12.01,  6.0, 2.265,18.8, 74.4);
1024   AliMixture ( 4, "Polyethilene$", ape, zpe, dpe, npe, wpe);
1025   AliMixture ( 5, "G10$", ag10, zg10, densg10, nlmatg10, wmatg10);
1026   AliMixture ( 6, "PLE$", aplex, zplex, densplex, nplex, wmatplex);
1027   AliMixture ( 7, "CO2$", ac, zc, dc, nc, wc);
1028   AliMixture ( 8, "ALUMINA$", aal, zal, densal, nlmatal, wmatal);
1029   AliMaterial( 9, "Al $", 26.98, 13., 2.7, 8.9, 37.2);
1030   AliMaterial(10, "C-TRD$", 12.01, 6., 2.265*18.8/69.282*15./100, 18.8, 74.4); // for 15%
1031   AliMixture (11, "Mylar$",  amy, zmy, dmy, nmy, wmy);
1032   AliMixture (12, "Freon$",  afre, zfre, densfre, nfre, wfre);
1033   AliMixture (13, "Glass$", aq, zq, dq, nq, wq);
1034   AliMixture (14, "Water$",  awa, zwa, dwa, nwa, wwa);
1035   AliMixture (15, "STAINLESS STEEL$", asteel, zsteel, 7.88, 4, wsteel);
1036
1037   Float_t epsil, stmin, deemax, stemax;
1038  
1039   //   Previous data
1040   //       EPSIL  =  0.1   ! Tracking precision, 
1041   //       STEMAX = 0.1      ! Maximum displacement for multiple scattering
1042   //       DEEMAX = 0.1    ! Maximum fractional energy loss, DLS 
1043   //       STMIN  = 0.1 
1044   //
1045   //   New data  
1046   epsil  = .001;  // Tracking precision,
1047   stemax = -1.;   // Maximum displacement for multiple scattering
1048   deemax = -.3;   // Maximum fractional energy loss, DLS
1049   stmin  = -.8;
1050
1051   AliMedium( 1, "Air$"  ,  1, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1052   AliMedium( 2, "Cu $"  ,  2, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1053   AliMedium( 3, "C  $"  ,  3, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1054   AliMedium( 4, "Pol$"  ,  4, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1055   AliMedium( 5, "G10$"  ,  5, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1056   AliMedium( 6, "PLE$"  ,  6, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1057   AliMedium( 7, "CO2$"  ,  7, 0, isxfld, sxmgmx, 10., -.01, -.1, .01, -.01);
1058   AliMedium( 8,"ALUMINA$", 8, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1059   AliMedium( 9,"Al Frame$",9, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1060   AliMedium(10, "DME-S$",  6, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1061   AliMedium(11, "C-TRD$", 10, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1062   AliMedium(12, "Myl$"  , 11, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1063   AliMedium(13, "Fre$"  , 12, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1064   AliMedium(14, "Fre-S$", 12, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1065   AliMedium(15, "Glass$", 13, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1066   AliMedium(16, "Water$", 14, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1067   AliMedium(17, "STEEL$", 15, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
1068
1069 }
1070
1071 //_____________________________________________________________________________
1072 void AliTOFv4T0::Init()
1073 {
1074   //
1075   // Initialise the detector after the geometry has been defined
1076   //
1077   AliDebug(1, "**************************************"
1078            "  TOF  "
1079            "**************************************");
1080   AliDebug(1, "  Version 4 of TOF initialing, "
1081            "symmetric TOF - Full Coverage version");
1082   
1083   AliTOF::Init();
1084   
1085   fIdFTOA = gMC->VolId("FTOA");
1086   fIdFTOB = gMC->VolId("FTOB");
1087   fIdFTOC = gMC->VolId("FTOC");
1088   fIdFLTA = gMC->VolId("FLTA");
1089   fIdFLTB = gMC->VolId("FLTB");
1090   fIdFLTC = gMC->VolId("FLTC");
1091
1092   AliDebug(1, "**************************************"
1093            "  TOF  "
1094            "**************************************");
1095 }
1096  
1097 //_____________________________________________________________________________
1098 void AliTOFv4T0::StepManager()
1099 {
1100
1101   //
1102   // Procedure called at each step in the Time Of Flight
1103   //
1104
1105   TLorentzVector mom, pos;
1106   Float_t xm[3],pm[3],xpad[3],ppad[3];
1107   Float_t hits[14];
1108   Int_t   vol[5];
1109   Int_t   sector, plate, padx, padz, strip;
1110   Int_t   copy, padzid, padxid, stripid, i;
1111   Int_t   *idtmed = fIdtmed->GetArray()-499;
1112   Float_t incidenceAngle;
1113       
1114   if(
1115      gMC->IsTrackEntering()
1116      && gMC->TrackCharge()
1117      //&& gMC->GetMedium()==idtmed[513]
1118      && gMC->CurrentMedium()==idtmed[513]
1119      && gMC->CurrentVolID(copy)==fIdSens
1120      )
1121   {
1122
1123     AliMC *mcApplication = (AliMC*)gAlice->GetMCApp();
1124
1125     AddTrackReference(mcApplication->GetCurrentTrackNumber(), AliTrackReference::kTOF);
1126     //AddTrackReference(gAlice->GetMCApp()->GetCurrentTrackNumber());
1127
1128     // getting information about hit volumes
1129     
1130     padzid=gMC->CurrentVolOffID(2,copy);
1131     padz=copy; 
1132
1133     
1134     padxid=gMC->CurrentVolOffID(1,copy);
1135     padx=copy; 
1136     
1137     stripid=gMC->CurrentVolOffID(4,copy);
1138     strip=copy; 
1139
1140     gMC->TrackPosition(pos);
1141     gMC->TrackMomentum(mom);
1142
1143
1144     //    Double_t NormPos=1./pos.Rho();
1145
1146     Double_t normMom=1./mom.Rho();
1147
1148     //  getting the cohordinates in pad ref system
1149
1150     xm[0] = (Float_t)pos.X();
1151     xm[1] = (Float_t)pos.Y();
1152     xm[2] = (Float_t)pos.Z();
1153
1154     pm[0] = (Float_t)mom.X()*normMom;
1155     pm[1] = (Float_t)mom.Y()*normMom;
1156     pm[2] = (Float_t)mom.Z()*normMom;
1157  
1158     gMC->Gmtod(xm,xpad,1);
1159     gMC->Gmtod(pm,ppad,2);
1160
1161     
1162     if (TMath::Abs(ppad[1])>1) {
1163       AliWarning("Abs(ppad) > 1");
1164       ppad[1]=TMath::Sign((Float_t)1,ppad[1]);
1165     }
1166     incidenceAngle = TMath::ACos(ppad[1])*kRaddeg;
1167
1168
1169     const char * pathA="FTOA";
1170     const char * pathB="FTOB";
1171     const char * pathC="FTOC";
1172     const char * path71="B071";
1173     const char * path75="B075";
1174     const char * path74="B074";
1175     const char* volpath;    
1176
1177     Int_t index=0;
1178     volpath=gMC->CurrentVolOffName(6);
1179     index=gMC->CurrentVolOffID(6,copy);
1180     index=copy;
1181
1182     
1183     plate=-1;
1184     if(strcmp(pathC,volpath)==0 && index==1)plate=0;
1185     if(strcmp(pathB,volpath)==0 && index==1)plate=1;
1186     if(strcmp(pathA,volpath)==0 && index==0)plate=2;
1187     if(strcmp(pathB,volpath)==0 && index==2)plate=3;
1188     if(strcmp(pathC,volpath)==0 && index==2)plate=4;
1189
1190
1191
1192     if (plate==0) strip=fTOFGeometry->NStripC()-strip;
1193     else if (plate==1) strip=fTOFGeometry->NStripB()-strip;
1194     else strip--;
1195  
1196     //Apply ALICE conventions for volume numbering increasing with theta, phi
1197
1198     if (plate==3 || plate==4){
1199       padx=fTOFGeometry->NpadX()-padx;
1200       padz=fTOFGeometry->NpadZ()-padz;
1201       xpad[0]=-xpad[0];      
1202       xpad[2]=-xpad[2];      
1203     }
1204     else {
1205      padx--;
1206      padz--;
1207     }
1208
1209
1210
1211     volpath=gMC->CurrentVolOffName(8);
1212     index=gMC->CurrentVolOffID(8,copy);
1213     index=copy;
1214
1215     sector=-1;
1216     if(strcmp(path71,volpath)==0 && index <6) sector=12+index;
1217     if(strcmp(path71,volpath)==0 && index >=6) sector=index-3;
1218     if(strcmp(path75,volpath)==0) sector=index-1;
1219     if(strcmp(path74,volpath)==0) sector=10+index;
1220
1221     for(i=0;i<3;++i) {
1222       hits[i]   = pos[i];
1223       hits[i+3] = pm[i];
1224     }
1225
1226     hits[6] = mom.Rho();
1227     hits[7] = pos[3];
1228     hits[8] = xpad[0];
1229     hits[9] = xpad[1];
1230     hits[10]= xpad[2];
1231     hits[11]= incidenceAngle;
1232     hits[12]= gMC->Edep();
1233     hits[13]= gMC->TrackLength();
1234     
1235     vol[0]= sector;
1236     vol[1]= plate;
1237     vol[2]= strip;
1238     vol[3]= padx;
1239     vol[4]= padz;    
1240
1241     AddT0Hit(mcApplication->GetCurrentTrackNumber(),vol, hits);
1242     //AddT0Hit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
1243   }
1244 }