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