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