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