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