]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFv0.cxx
Savannah bug 45804 fixed
[u/mrichter/AliRoot.git] / TOF / AliTOFv0.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 0 of the Time Of Flight    //
21 //  detector.                                                                //
22 //                                                                           //
23 //  VERSION WITH 5 MODULES AND TILTED STRIPS                                 //
24 //  NO HITS DEFINED BY DEFAULT FOR THIS VERSION                              //
25 //   FULL COVERAGE VERSION                                                   //
26 //                                                                           //
27 //   Authors:                                                                //
28 //                                                                           //
29 //   Alessio Seganti                                                         //
30 //   Domenico Vicinanza                                                      //
31 //                                                                           //
32 //   University of Salerno - Italy                                           //
33 //                                                                           //
34 //   Fabrizio Pierella                                                       //
35 //   University of Bologna - Italy                                           //
36 //                                                                           //
37 //                                                                           //
38 //Begin_Html                                                                 //
39 /*                                                                           //
40 <img src="picts/AliTOFv0Class.gif">                                          //
41 */                                                                           //
42 //End_Html                                                                   //
43 //                                                                           //
44 ///////////////////////////////////////////////////////////////////////////////
45
46 #include <Riostream.h>
47 #include <stdlib.h>
48
49 #include <TLorentzVector.h>
50 #include <TObject.h>
51 #include <TVirtualMC.h>
52
53 #include "AliConst.h"
54 #include "AliRun.h"
55 #include "AliTOFv0.h"
56 #include "AliTOFConstants.h" // AdC
57 #include "AliMC.h"
58  
59 ClassImp(AliTOFv0)
60  
61 //_____________________________________________________________________________
62 AliTOFv0::AliTOFv0()
63 {
64   //
65   // Default constructor
66   //
67 }
68  
69 //_____________________________________________________________________________
70 AliTOFv0::AliTOFv0(const char *name, const char *title)
71         : AliTOF(name,title)
72 {
73   //
74   // Standard constructor
75   //
76   //
77   // Check that FRAME is there otherwise we have no place where to
78   // put TOF
79   AliModule* frame=gAlice->GetModule("FRAME");
80   if(!frame) {
81     Error("Ctor","TOF needs FRAME to be present\n");
82     exit(1);
83   } else
84     if(frame->IsVersion()!=1) {
85       Error("Ctor","FRAME version 1 needed with this version of TOF\n");
86       exit(1);
87     }
88  
89 }
90
91 //_____________________________________________________________________________
92 void AliTOFv0::CreateGeometry()
93 {
94   //
95   // Create geometry for Time Of Flight version 0
96   //
97   //Begin_Html
98   /*
99     <img src="picts/AliTOFv0.gif">
100   */
101   //End_Html
102   //
103   // Creates common geometry
104   //
105   AliTOF::CreateGeometry();
106 }
107  
108 //_____________________________________________________________________________
109 void AliTOFv0::TOFpc(Float_t xtof, Float_t ytof, Float_t zlenC,
110                      Float_t zlenB, Float_t zlenA, Float_t ztof0)
111 {
112   //
113   // Definition of the Time Of Fligh Resistive Plate Chambers
114   // xFLT, yFLT, zFLT - sizes of TOF modules (large)
115   
116   Float_t  ycoor, zcoor;
117   Float_t  par[3];
118   Int_t    *idtmed = fIdtmed->GetArray()-499;
119   Int_t    idrotm[100];
120   Int_t    nrot = 0;
121   Float_t  hTof = fRmax-fRmin;
122   
123   Float_t radius = fRmin+2.;//cm
124
125   par[0] =  xtof * 0.5;
126   par[1] =  ytof * 0.5;
127   par[2] = zlenC * 0.5;
128   gMC->Gsvolu("FTOC", "BOX ", idtmed[506], par, 3);
129   par[2] = zlenB * 0.5;
130   gMC->Gsvolu("FTOB", "BOX ", idtmed[506], par, 3);
131   par[2] = zlenA * 0.5;
132   gMC->Gsvolu("FTOA", "BOX ", idtmed[506], par, 3);
133
134
135 // Positioning of modules
136
137    Float_t zcor1 = ztof0 - zlenC*0.5;
138    Float_t zcor2 = ztof0 - zlenC - zlenB*0.5;
139    Float_t zcor3 = 0.;
140
141    AliMatrix(idrotm[0], 90.,  0., 0., 0., 90,-90.);
142    AliMatrix(idrotm[1], 90.,180., 0., 0., 90, 90.);
143    gMC->Gspos("FTOC", 1, "BTO1", 0,  zcor1, 0, idrotm[0], "ONLY");
144    gMC->Gspos("FTOC", 2, "BTO1", 0, -zcor1, 0, idrotm[1], "ONLY");
145    gMC->Gspos("FTOC", 1, "BTO2", 0,  zcor1, 0, idrotm[0], "ONLY");
146    gMC->Gspos("FTOC", 2, "BTO2", 0, -zcor1, 0, idrotm[1], "ONLY");
147    gMC->Gspos("FTOC", 1, "BTO3", 0,  zcor1, 0, idrotm[0], "ONLY");
148    gMC->Gspos("FTOC", 2, "BTO3", 0, -zcor1, 0, idrotm[1], "ONLY");
149
150    gMC->Gspos("FTOB", 1, "BTO1", 0,  zcor2, 0, idrotm[0], "ONLY");
151    gMC->Gspos("FTOB", 2, "BTO1", 0, -zcor2, 0, idrotm[1], "ONLY");
152    gMC->Gspos("FTOB", 1, "BTO2", 0,  zcor2, 0, idrotm[0], "ONLY");
153    gMC->Gspos("FTOB", 2, "BTO2", 0, -zcor2, 0, idrotm[1], "ONLY");
154    gMC->Gspos("FTOB", 1, "BTO3", 0,  zcor2, 0, idrotm[0], "ONLY");
155    gMC->Gspos("FTOB", 2, "BTO3", 0, -zcor2, 0, idrotm[1], "ONLY");
156
157    gMC->Gspos("FTOA", 0, "BTO1", 0, zcor3,  0, idrotm[0], "ONLY");
158    gMC->Gspos("FTOA", 0, "BTO2", 0, zcor3,  0, idrotm[0], "ONLY");
159    gMC->Gspos("FTOA", 0, "BTO3", 0, zcor3,  0, idrotm[0], "ONLY");
160
161   Float_t db = 0.5;//cm
162   Float_t xFLT, xFST, yFLT, zFLTA, zFLTB, zFLTC;
163
164   xFLT = fStripLn;
165   yFLT = ytof;
166   zFLTA = zlenA;
167   zFLTB = zlenB;
168   zFLTC = zlenC;
169
170   xFST = xFLT-fDeadBndX*2;//cm
171
172 // Sizes of MRPC pads
173
174   Float_t yPad = 0.505;//cm 
175   
176 // Large not sensitive volumes with Insensitive Freon
177   par[0] = xFLT*0.5;
178   par[1] = yFLT*0.5;
179   
180   cout <<"************************* TOF geometry **************************"<<endl;
181  
182   par[2] = (zFLTA *0.5);
183   gMC->Gsvolu("FLTA", "BOX ", idtmed[512], par, 3); // Insensitive Freon
184   gMC->Gspos ("FLTA", 0, "FTOA", 0., 0., 0., 0, "ONLY");
185
186   par[2] = (zFLTB * 0.5);
187   gMC->Gsvolu("FLTB", "BOX ", idtmed[512], par, 3); // Insensitive Freon
188   gMC->Gspos ("FLTB", 0, "FTOB", 0., 0., 0., 0, "ONLY");
189
190   par[2] = (zFLTC * 0.5);
191   gMC->Gsvolu("FLTC", "BOX ", idtmed[512], par, 3); // Insensitive Freon
192   gMC->Gspos ("FLTC", 0, "FTOC", 0., 0., 0., 0, "ONLY");
193  
194 ////////// Layers of Aluminum before and after detector //////////
195 ////////// Aluminum Box for Modules (2.0 mm thickness)  /////////
196 ////////// lateral walls not simulated
197   par[0] = xFLT*0.5;
198   par[1] = 0.1;//cm
199   ycoor = -yFLT/2 + par[1];
200   par[2] = (zFLTA *0.5);
201   gMC->Gsvolu("FALA", "BOX ", idtmed[508], par, 3); // Alluminium
202   gMC->Gspos ("FALA", 1, "FLTA", 0., ycoor, 0., 0, "ONLY");
203   gMC->Gspos ("FALA", 2, "FLTA", 0.,-ycoor, 0., 0, "ONLY");
204   par[2] = (zFLTB *0.5);
205   gMC->Gsvolu("FALB", "BOX ", idtmed[508], par, 3); // Alluminium 
206   gMC->Gspos ("FALB", 1, "FLTB", 0., ycoor, 0., 0, "ONLY");
207   gMC->Gspos ("FALB", 2, "FLTB", 0.,-ycoor, 0., 0, "ONLY");
208   par[2] = (zFLTC *0.5);
209   gMC->Gsvolu("FALC", "BOX ", idtmed[508], par, 3); // Alluminium
210   gMC->Gspos ("FALC", 1, "FLTC", 0., ycoor, 0., 0, "ONLY");
211   gMC->Gspos ("FALC", 2, "FLTC", 0.,-ycoor, 0., 0, "ONLY");
212   
213 ///////////////// Detector itself //////////////////////
214   const Float_t  kdeadBound  =  fDeadBndZ; //cm non-sensitive between the pad edge 
215                                           //and the boundary of the strip
216   const Int_t    knx    = fNpadX;          // number of pads along x
217   const Int_t    knz    = fNpadZ;          // number of pads along z
218   const Float_t  kspace = fSpace;            //cm distance from the front plate of the box
219
220   Float_t zSenStrip  = fZpad*fNpadZ;//cm
221   Float_t stripWidth = zSenStrip + 2*kdeadBound;
222   par[0] = xFLT*0.5;
223   par[1] = yPad*0.5; 
224   par[2] = stripWidth*0.5;
225   
226 // new description for strip volume -double stack strip-
227 // -- all constants are expressed in cm
228 // heigth of different layers
229   const Float_t khhony = 1.      ;   // heigth of HONY  Layer
230   const Float_t khpcby = 0.15    ;   // heigth of PCB   Layer
231   const Float_t khmyly = 0.035   ;   // heigth of MYLAR Layer
232   const Float_t khgraphy = 0.02  ;   // heigth of GRAPHITE Layer
233   const Float_t khglasseiy = 0.17;   // 0.6 Ext. Glass + 1.1 i.e. (Int. Glass/2) (mm)
234   const Float_t khsensmy = 0.11  ;   // heigth of Sensitive Freon Mixture
235   const Float_t kwsensmz = 2*3.5 ;   // cm
236   const Float_t klsensmx = 48*2.5;   // cm
237   const Float_t kwpadz = 3.5;   // cm z dimension of the FPAD volume
238   const Float_t klpadx = 2.5;   // cm x dimension of the FPAD volume
239   
240   // heigth of the FSTR Volume (the strip volume)
241   const Float_t khstripy = 2*khhony+3*khpcby+4*(khmyly+khgraphy+khglasseiy)+2*khsensmy;
242   // width  of the FSTR Volume (the strip volume)
243   const Float_t kwstripz = 10.;
244   // length of the FSTR Volume (the strip volume)
245   const Float_t klstripx = 122.;
246   
247   Float_t parfp[3]={klstripx*0.5,khstripy*0.5,kwstripz*0.5};
248 // coordinates of the strip center in the strip reference frame; used for positioning
249 // internal strip volumes
250   Float_t posfp[3]={0.,0.,0.};   
251
252   
253   // FSTR volume definition and filling this volume with non sensitive Gas Mixture
254   gMC->Gsvolu("FSTR","BOX",idtmed[512],parfp,3);
255   //-- HONY Layer definition
256 //  parfp[0] = -1;
257   parfp[1] = khhony*0.5;
258 //  parfp[2] = -1;
259   gMC->Gsvolu("FHON","BOX",idtmed[503],parfp,3);
260   // positioning 2 HONY Layers on FSTR volume
261
262   posfp[1]=-khstripy*0.5+parfp[1];
263   gMC->Gspos("FHON",1,"FSTR",0., posfp[1],0.,0,"ONLY");
264   gMC->Gspos("FHON",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
265
266   //-- PCB Layer definition 
267   parfp[1] = khpcby*0.5;
268   gMC->Gsvolu("FPCB","BOX",idtmed[504],parfp,3);
269   // positioning 2 PCB Layers on FSTR volume
270   posfp[1]=-khstripy*0.5+khhony+parfp[1];
271   gMC->Gspos("FPCB",1,"FSTR",0., posfp[1],0.,0,"ONLY");
272   gMC->Gspos("FPCB",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
273   // positioning the central PCB layer
274   gMC->Gspos("FPCB",3,"FSTR",0.,0.,0.,0,"ONLY");
275
276
277
278   //-- MYLAR Layer definition
279   parfp[1] = khmyly*0.5;
280   gMC->Gsvolu("FMYL","BOX",idtmed[511],parfp,3);
281   // positioning 2 MYLAR Layers on FSTR volume
282   posfp[1] = -khstripy*0.5+khhony+khpcby+parfp[1]; 
283   gMC->Gspos("FMYL",1,"FSTR",0., posfp[1],0.,0,"ONLY");
284   gMC->Gspos("FMYL",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
285   // adding further 2 MYLAR Layers on FSTR volume
286   posfp[1] = khpcby*0.5+parfp[1];
287   gMC->Gspos("FMYL",3,"FSTR",0., posfp[1],0.,0,"ONLY");
288   gMC->Gspos("FMYL",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
289
290
291   //-- Graphite Layer definition
292   parfp[1] = khgraphy*0.5;
293   gMC->Gsvolu("FGRP","BOX",idtmed[502],parfp,3);
294   // positioning 2 Graphite Layers on FSTR volume
295   posfp[1] = -khstripy*0.5+khhony+khpcby+khmyly+parfp[1];
296   gMC->Gspos("FGRP",1,"FSTR",0., posfp[1],0.,0,"ONLY");
297   gMC->Gspos("FGRP",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
298   // adding further 2 Graphite Layers on FSTR volume
299   posfp[1] = khpcby*0.5+khmyly+parfp[1];
300   gMC->Gspos("FGRP",3,"FSTR",0., posfp[1],0.,0,"ONLY");
301   gMC->Gspos("FGRP",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
302  
303
304   //-- Glass (EXT. +Semi INT.) Layer definition
305   parfp[1] = khglasseiy*0.5;
306   gMC->Gsvolu("FGLA","BOX",idtmed[514],parfp,3);
307   // positioning 2 Glass Layers on FSTR volume
308   posfp[1] = -khstripy*0.5+khhony+khpcby+khmyly+khgraphy+parfp[1];
309   gMC->Gspos("FGLA",1,"FSTR",0., posfp[1],0.,0,"ONLY");
310   gMC->Gspos("FGLA",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
311   // adding further 2 Glass Layers on FSTR volume
312   posfp[1] = khpcby*0.5+khmyly+khgraphy+parfp[1];
313   gMC->Gspos("FGLA",3,"FSTR",0., posfp[1],0.,0,"ONLY");
314   gMC->Gspos("FGLA",4,"FSTR",0.,-posfp[1],0.,0,"ONLY");
315
316   
317   //-- Sensitive Mixture Layer definition
318   parfp[0] = klsensmx*0.5;
319   parfp[1] = khsensmy*0.5;
320   parfp[2] = kwsensmz*0.5;
321   gMC->Gsvolu("FSEN","BOX",idtmed[513],parfp,3);
322   gMC->Gsvolu("FNSE","BOX",idtmed[512],parfp,3);
323   // positioning 2 gas Layers on FSTR volume
324   // the upper is insensitive freon
325   // while the remaining is sensitive
326   posfp[1] = khpcby*0.5+khmyly+khgraphy+khglasseiy+parfp[1];
327   gMC->Gspos("FNSE",0,"FSTR", 0., posfp[1],0.,0,"ONLY");
328   gMC->Gspos("FSEN",0,"FSTR", 0.,-posfp[1],0.,0,"ONLY");
329
330   // dividing FSEN along z in knz=2 and along x in knx=48
331   gMC->Gsdvn("FSEZ","FSEN",knz,3);
332   gMC->Gsdvn("FSEX","FSEZ",knx,1);
333   
334   // FPAD volume definition
335   parfp[0] = klpadx*0.5;    
336   parfp[1] = khsensmy*0.5;
337   parfp[2] = kwpadz*0.5;
338   gMC->Gsvolu("FPAD","BOX",idtmed[513],parfp,3);
339   // positioning the FPAD volumes on previous divisions
340   gMC->Gspos("FPAD",0,"FSEX",0.,0.,0.,0,"ONLY");
341   
342 ////  Positioning the Strips  (FSTR) in the FLT volumes  /////
343
344   // Plate A (Central) 
345   
346   Float_t t = zFLTC+zFLTB+zFLTA*0.5+ 2*db;//Half Width of Barrel
347
348   Float_t gap  = fGapA+0.5; //cm  updated distance between the strip axis
349   Float_t zpos = 0;
350   Float_t ang  = 0;
351   Int_t j=1; // AdC
352   nrot  = 0;
353   zcoor = 0;
354   ycoor = -14.5 + kspace ; //2 cm over front plate
355
356   AliMatrix (idrotm[0],  90.,  0.,90.,90.,0., 90.);   
357
358   Int_t centerLoc= (Int_t)(fNStripA/2.) + 1; // AdC
359
360   //gMC->Gspos("FSTR",j,"FLTA",0.,ycoor, 0.,idrotm[0],"ONLY");
361   gMC->Gspos("FSTR",centerLoc,"FLTA",0.,ycoor, 0.,idrotm[0],"ONLY"); // AdC
362   if(fDebug>=1) {
363     printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,j); // AdC
364     printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
365   }
366   zcoor -= zSenStrip;
367   //j++; // AdC
368   Int_t upDown = -1; // upDown=-1 -> Upper strip
369                      // upDown=+1 -> Lower strip
370   do{
371      ang = atan(zcoor/radius);
372      ang *= kRaddeg;
373      AliMatrix (idrotm[nrot],  90.,  0.,90.-ang,90.,-ang, 90.);   
374      AliMatrix (idrotm[nrot+1],90.,180.,90.+ang,90., ang, 90.);
375      ang /= kRaddeg;
376      ycoor = -14.5+ kspace; //2 cm over front plate
377      ycoor += (1-(upDown+1)/2)*gap;
378      //gMC->Gspos("FSTR",j  ,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY");
379      //gMC->Gspos("FSTR",j+1,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
380     gMC->Gspos("FSTR",centerLoc-j,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY"); // AdC
381     gMC->Gspos("FSTR",centerLoc+j,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY"); // AdC
382     if(fDebug>=1) {
383       printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,j); // AdC
384       printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
385     }
386     //j += 2; // AdC
387     upDown*= -1; // Alternate strips 
388     zcoor = zcoor-(zSenStrip/2)/TMath::Cos(ang)-
389       upDown*gap*TMath::Tan(ang)-
390       (zSenStrip/2)/TMath::Cos(ang);
391   } while (zcoor-(stripWidth/2)*TMath::Cos(ang)>-t+zFLTC+zFLTB+db*2);
392   
393   zcoor = zcoor+(zSenStrip/2)/TMath::Cos(ang)+
394     upDown*gap*TMath::Tan(ang)+
395     (zSenStrip/2)/TMath::Cos(ang);
396   
397   gap = fGapB;
398   zcoor = zcoor-(zSenStrip/2)/TMath::Cos(ang)-
399     upDown*gap*TMath::Tan(ang)-
400     (zSenStrip/2)/TMath::Cos(ang);
401   
402   ang = atan(zcoor/radius);
403   ang *= kRaddeg;
404   AliMatrix (idrotm[nrot],  90.,  0.,90.-ang,90.,-ang, 90.);   
405   AliMatrix (idrotm[nrot+1],90.,180.,90.+ang,90., ang, 90.);
406   ang /= kRaddeg;
407           
408   ycoor = -14.5+ kspace; //2 cm over front plate
409   ycoor += (1-(upDown+1)/2)*gap;
410   //gMC->Gspos("FSTR",j  ,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY");
411   //gMC->Gspos("FSTR",j+1,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
412   gMC->Gspos("FSTR",centerLoc-j,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY"); // AdC
413   gMC->Gspos("FSTR",centerLoc+j,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY"); // AdC
414   if(fDebug>=1) {
415     printf("%s: %f,  St. %2i, Pl.3 ",ClassName(),ang*kRaddeg,j); // AdC
416     printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
417   }
418   ycoor = -hTof/2.+ kspace;//2 cm over front plate
419
420   // Plate  B
421
422   nrot = 0;
423   Int_t i=1; // AdC
424   upDown = 1;
425   Float_t deadRegion = 1.0;//cm
426   
427   zpos = zcoor - (zSenStrip/2)/TMath::Cos(ang)-
428          upDown*gap*TMath::Tan(ang)-
429          (zSenStrip/2)/TMath::Cos(ang)-
430          deadRegion/TMath::Cos(ang);
431
432   ang = atan(zpos/radius);
433   ang *= kRaddeg;
434   AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
435   ang /= kRaddeg;
436   ycoor = -hTof*0.5+ kspace ; //2 cm over front plate
437   ycoor += (1-(upDown+1)/2)*gap;
438   zcoor = zpos+(zFLTA*0.5+zFLTB*0.5+db); // Moves to the system of the modulus FLTB
439   gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
440   if(fDebug>=1) {   
441     printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i); 
442     printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
443   }
444   i++;
445   upDown*=-1;
446
447   do {
448      zpos = zpos - (zSenStrip/2)/TMath::Cos(ang)-
449             upDown*gap*TMath::Tan(ang)-
450             (zSenStrip/2)/TMath::Cos(ang);
451      ang = atan(zpos/radius);
452      ang *= kRaddeg;
453      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
454      ang /= kRaddeg;
455      Float_t deltaSpaceinB=-0.5; // [cm] to avoid overlaps with the end of freon frame
456      Float_t deltaGapinB=0.5;    // [cm] to avoid overlaps in between initial strips
457      ycoor = -hTof*0.5+ kspace+deltaSpaceinB ; //2 cm over front plate
458      ycoor += (1-(upDown+1)/2)*(gap+deltaGapinB);
459      zcoor = zpos+(zFLTA*0.5+zFLTB*0.5+db); // Moves to the system of the modulus FLTB
460      gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
461      if(fDebug>=1) {   
462        printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i); 
463        printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
464      }
465      upDown*=-1;
466      i++;
467   } while (TMath::Abs(ang*kRaddeg)<22.5);
468   //till we reach a tilting angle of 22.5 degrees
469
470   ycoor = -hTof*0.5+ kspace ; //2 cm over front plate
471   zpos = zpos - zSenStrip/TMath::Cos(ang);
472   // this avoid overlaps in between outer strips in plate B
473   Float_t deltaMovingUp=0.8;    // [cm]
474   Float_t deltaMovingDown=-0.5; // [cm]
475
476   do {
477      ang = atan(zpos/radius);
478      ang *= kRaddeg;
479      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
480      ang /= kRaddeg;
481      zcoor = zpos+(zFLTB/2+zFLTA/2+db);
482      gMC->Gspos("FSTR",i, "FLTB", 0., ycoor+deltaMovingDown+deltaMovingUp, zcoor,idrotm[nrot], "ONLY");
483      deltaMovingUp+=0.8; // update delta moving toward the end of the plate
484      zpos = zpos - zSenStrip/TMath::Cos(ang);
485      if(fDebug>=1) {
486        printf("%s: %f,  St. %2i, Pl.4 ",ClassName(),ang*kRaddeg,i);
487        printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
488      }
489      i++;
490   }  while (zpos-stripWidth*0.5/TMath::Cos(ang)>-t+zFLTC+db);
491   
492   // Plate  C
493   
494   zpos = zpos + zSenStrip/TMath::Cos(ang);
495
496   zpos = zpos - (zSenStrip/2)/TMath::Cos(ang)+
497          gap*TMath::Tan(ang)-
498          (zSenStrip/2)/TMath::Cos(ang);
499
500   nrot = 0;
501   i=0;
502   Float_t deltaGap=-2.5; // [cm] update distance from strip center and plate
503   ycoor= -hTof*0.5+kspace+gap+deltaGap;
504
505   do {
506      i++;
507      ang = atan(zpos/radius);
508      ang *= kRaddeg;
509      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
510      ang /= kRaddeg;
511      zcoor = zpos+(zFLTC*0.5+zFLTB+zFLTA*0.5+db*2);
512      gMC->Gspos("FSTR",i, "FLTC", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
513      if(fDebug>=1) {
514        printf("%s: %f,  St. %2i, Pl.5 ",ClassName(),ang*kRaddeg,i);
515        printf("y = %f,  z = %f, zpos = %f \n",ycoor,zcoor,zpos);
516      }
517      zpos = zpos - zSenStrip/TMath::Cos(ang);
518   }  while (zpos-stripWidth*TMath::Cos(ang)*0.5>-t);
519
520
521 ////////// Layers after strips /////////////////
522 // honeycomb (Polyethilene) Layer after (1.2cm)
523
524   Float_t overSpace = fOverSpc;//cm
525
526   par[0] = xFLT*0.5;
527   par[1] = 0.6;
528   par[2] = (zFLTA *0.5);
529   ycoor = -yFLT/2 + overSpace + par[1];
530   gMC->Gsvolu("FPEA", "BOX ", idtmed[503], par, 3); // Hony
531   gMC->Gspos ("FPEA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
532   par[2] = (zFLTB *0.5);
533   gMC->Gsvolu("FPEB", "BOX ", idtmed[503], par, 3); // Hony
534   gMC->Gspos ("FPEB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
535   par[2] = (zFLTC *0.5);
536   gMC->Gsvolu("FPEC", "BOX ", idtmed[503], par, 3); // Hony
537   gMC->Gspos ("FPEC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
538
539 // Electronics (Cu) after
540   ycoor += par[1];
541   par[0] = xFLT*0.5;
542   par[1] = 1.43*0.05*0.5; // 5% of X0
543   par[2] = (zFLTA *0.5);
544   ycoor += par[1];
545   gMC->Gsvolu("FECA", "BOX ", idtmed[501], par, 3); // Cu
546   gMC->Gspos ("FECA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
547   par[2] = (zFLTB *0.5);
548   gMC->Gsvolu("FECB", "BOX ", idtmed[501], par, 3); // Cu
549   gMC->Gspos ("FECB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
550   par[2] = (zFLTC *0.5);
551   gMC->Gsvolu("FECC", "BOX ", idtmed[501], par, 3); // Cu
552   gMC->Gspos ("FECC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
553
554 // cooling WAter after
555   ycoor += par[1];
556   par[0] = xFLT*0.5;
557   par[1] = 36.1*0.02*0.5; // 2% of X0
558   par[2] = (zFLTA *0.5);
559   ycoor += par[1];
560   gMC->Gsvolu("FWAA", "BOX ", idtmed[515], par, 3); // Water
561   gMC->Gspos ("FWAA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
562   par[2] = (zFLTB *0.5);
563   gMC->Gsvolu("FWAB", "BOX ", idtmed[515], par, 3); // Water
564   gMC->Gspos ("FWAB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
565   par[2] = (zFLTC *0.5);
566   gMC->Gsvolu("FWAC", "BOX ", idtmed[515], par, 3); // Water
567   gMC->Gspos ("FWAC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
568
569 // frame of Air
570   ycoor += par[1];
571   par[0] = xFLT*0.5;
572   par[1] = (yFLT/2-ycoor-0.2)*0.5; // Aluminum layer considered (0.2 cm)
573   par[2] = (zFLTA *0.5);
574   ycoor += par[1];
575   gMC->Gsvolu("FAIA", "BOX ", idtmed[500], par, 3); // Air
576   gMC->Gspos ("FAIA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
577   par[2] = (zFLTB *0.5);
578   gMC->Gsvolu("FAIB", "BOX ", idtmed[500], par, 3); // Air
579   gMC->Gspos ("FAIB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
580   par[2] = (zFLTC *0.5);
581   gMC->Gsvolu("FAIC", "BOX ", idtmed[500], par, 3); // Air
582   gMC->Gspos ("FAIC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
583 /* fp
584 //Back Plate honycomb (2cm)
585   par[0] = -1;
586   par[1] = 2 *0.5;
587   par[2] = -1;
588   ycoor = yFLT/2 - par[1];
589   gMC->Gsvolu("FBPA", "BOX ", idtmed[503], par, 3); // Hony
590   gMC->Gspos ("FBPA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
591   gMC->Gsvolu("FBPB", "BOX ", idtmed[503], par, 3); // Hony
592   gMC->Gspos ("FBPB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
593   gMC->Gsvolu("FBPC", "BOX ", idtmed[503], par, 3); // Hony
594   gMC->Gspos ("FBPC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
595 fp */
596 }
597
598 //_____________________________________________________________________________
599 void AliTOFv0::DrawModule() const
600 {
601   //
602   // Draw a shaded view of the Time Of Flight version 0
603   //
604   // Set everything unseen
605   gMC->Gsatt("*", "seen", -1);
606   // 
607   // Set ALIC mother transparent
608   gMC->Gsatt("ALIC","SEEN",0);
609   //
610   // Set the volumes visible
611   gMC->Gsatt("ALIC","SEEN",0);
612
613   gMC->Gsatt("FTOA","SEEN",1);
614   gMC->Gsatt("FTOB","SEEN",1);
615   gMC->Gsatt("FTOC","SEEN",1);
616   gMC->Gsatt("FLTA","SEEN",1);
617   gMC->Gsatt("FLTB","SEEN",1);
618   gMC->Gsatt("FLTC","SEEN",1);
619   gMC->Gsatt("FPLA","SEEN",1);
620   gMC->Gsatt("FPLB","SEEN",1);
621   gMC->Gsatt("FPLC","SEEN",1);
622   gMC->Gsatt("FSTR","SEEN",1);
623   gMC->Gsatt("FPEA","SEEN",1);
624   gMC->Gsatt("FPEB","SEEN",1);
625   gMC->Gsatt("FPEC","SEEN",1);
626   
627   gMC->Gsatt("FLZ1","SEEN",0);
628   gMC->Gsatt("FLZ2","SEEN",0);
629   gMC->Gsatt("FLZ3","SEEN",0);
630   gMC->Gsatt("FLX1","SEEN",0);
631   gMC->Gsatt("FLX2","SEEN",0);
632   gMC->Gsatt("FLX3","SEEN",0);
633   gMC->Gsatt("FPAD","SEEN",0);
634
635   gMC->Gdopt("hide", "on");
636   gMC->Gdopt("shad", "on");
637   gMC->Gsatt("*", "fill", 7);
638   gMC->SetClipBox(".");
639   gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
640   gMC->DefaultRange();
641   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
642   gMC->Gdhead(1111, "Time Of Flight");
643   gMC->Gdman(18, 4, "MAN");
644   gMC->Gdopt("hide","off");
645 }
646 //_____________________________________________________________________________
647 void AliTOFv0::DrawDetectorModules()
648 {
649 //
650 // Draw a shaded view of the TOF detector version 0
651 //
652  
653 //Set ALIC mother transparent
654  gMC->Gsatt("ALIC","SEEN",0);
655
656 //
657 //Set volumes visible
658 // 
659 //=====> Level 1
660   // Level 1 for TOF volumes
661   gMC->Gsatt("B077","seen",0);
662  
663  
664 //==========> Level 2
665   // Level 2
666   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
667   gMC->Gsatt("B071","seen",0);
668   gMC->Gsatt("B074","seen",0);
669   gMC->Gsatt("B075","seen",0);
670   gMC->Gsatt("B080","seen",0); // B080 does not has sub-level                
671
672
673   // Level 2 of B071
674   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
675   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
676   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
677   gMC->Gsatt("B069","seen",-1); // all B069 sub-levels skipped   -
678   gMC->Gsatt("B056","seen",0);  // B056 does not has sub-levels  -
679   gMC->Gsatt("B059","seen",-1); // all B059 sub-levels skipped   -
680   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
681   gMC->Gsatt("BTR1","seen",0);  // BTR1 do not have sub-levels   -
682   gMC->Gsatt("BTO1","seen",0);
683
684  
685   // Level 2 of B074
686   gMC->Gsatt("BTR2","seen",0); // BTR2 does not has sub-levels -
687   gMC->Gsatt("BTO2","seen",0);
688
689   // Level 2 of B075
690   gMC->Gsatt("BTR3","seen",0); // BTR3 do not have sub-levels -
691   gMC->Gsatt("BTO3","seen",0);
692
693 // ==================> Level 3
694   // Level 3 of B071 / Level 2 of BTO1
695   gMC->Gsatt("FTOC","seen",-2);
696   gMC->Gsatt("FTOB","seen",-2);
697   gMC->Gsatt("FTOA","seen",-2);
698  
699   // Level 3 of B074 / Level 2 of BTO2
700   // -> cfr previous settings
701  
702   // Level 3 of B075 / Level 2 of BTO3
703   // -> cfr previous settings
704
705   gMC->Gdopt("hide","on");
706   gMC->Gdopt("shad","on");
707   gMC->Gsatt("*", "fill", 5);
708   gMC->SetClipBox(".");
709   gMC->SetClipBox("*", 0, 1000, 0, 1000, 0, 1000);
710   gMC->DefaultRange();
711   gMC->Gdraw("alic", 45, 40, 0, 10, 10, .015, .015);
712   gMC->Gdhead(1111,"TOF detector V1");
713   gMC->Gdman(18, 4, "MAN");
714   gMC->Gdopt("hide","off");
715 }                                 
716
717 //_____________________________________________________________________________
718 void AliTOFv0::DrawDetectorStrips()
719 {
720 //
721 // Draw a shaded view of the TOF strips for version 0
722 //
723  
724 //Set ALIC mother transparent
725  gMC->Gsatt("ALIC","SEEN",0);
726
727 //
728 //Set volumes visible 
729 //=====> Level 1
730   // Level 1 for TOF volumes
731   gMC->Gsatt("B077","seen",0);
732   
733 //==========> Level 2
734   // Level 2
735   gMC->Gsatt("B076","seen",-1); // all B076 sub-levels skipped -
736   gMC->Gsatt("B071","seen",0);
737   gMC->Gsatt("B074","seen",0);
738   gMC->Gsatt("B075","seen",0);
739   gMC->Gsatt("B080","seen",0); // B080 does not has sub-level
740
741   // Level 2 of B071
742   gMC->Gsatt("B063","seen",-1); // all B063 sub-levels skipped   -
743   gMC->Gsatt("B065","seen",-1); // all B065 sub-levels skipped   -
744   gMC->Gsatt("B067","seen",-1); // all B067 sub-levels skipped   -
745   gMC->Gsatt("B069","seen",-1); // all B069 sub-levels skipped   -
746   gMC->Gsatt("B056","seen",0);  // B056 does not has sub-levels  -
747   gMC->Gsatt("B059","seen",-1); // all B059 sub-levels skipped   -
748   gMC->Gsatt("B072","seen",-1); // all B072 sub-levels skipped   -
749   gMC->Gsatt("BTR1","seen",0);  // BTR1 do not have sub-levels   -
750   gMC->Gsatt("BTO1","seen",0);
751
752 // ==================> Level 3
753   // Level 3 of B071 / Level 2 of BTO1
754   gMC->Gsatt("FTOC","seen",0);
755   gMC->Gsatt("FTOB","seen",0);
756   gMC->Gsatt("FTOA","seen",0);
757  
758   // Level 3 of B074 / Level 2 of BTO2
759   // -> cfr previous settings
760  
761   // Level 3 of B075 / Level 2 of BTO3
762   // -> cfr previous settings
763
764
765 // ==========================> Level 4
766   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOC
767   gMC->Gsatt("FLTC","seen",0);
768   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOB
769   gMC->Gsatt("FLTB","seen",0);
770   // Level 4 of B071 / Level 3 of BTO1 / Level 2 of FTOA
771   gMC->Gsatt("FLTA","seen",0);
772  
773   // Level 4 of B074 / Level 3 of BTO2 / Level 2 of FTOC
774   // -> cfr previous settings
775   // Level 4 of B074 / Level 3 of BTO2 / Level 2 of FTOB
776   // -> cfr previous settings
777  
778   // Level 4 of B075 / Level 3 of BTO3 / Level 2 of FTOC
779   // -> cfr previous settings
780
781 //======================================> Level 5
782   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOC / Level 2 of FLTC
783   gMC->Gsatt("FALC","seen",0); // no children for FALC
784   gMC->Gsatt("FSTR","seen",-2);
785   gMC->Gsatt("FPEC","seen",0); // no children for FPEC
786   gMC->Gsatt("FECC","seen",0); // no children for FECC
787   gMC->Gsatt("FWAC","seen",0); // no children for FWAC
788   gMC->Gsatt("FAIC","seen",0); // no children for FAIC
789
790   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOB / Level 2 of FLTB
791   gMC->Gsatt("FALB","seen",0); // no children for FALB
792 //-->  gMC->Gsatt("FSTR","seen",-2);
793
794
795   // -> cfr previous settings
796   gMC->Gsatt("FPEB","seen",0); // no children for FPEB
797   gMC->Gsatt("FECB","seen",0); // no children for FECB
798   gMC->Gsatt("FWAB","seen",0); // no children for FWAB
799   gMC->Gsatt("FAIB","seen",0); // no children for FAIB
800  
801   // Level 5 of B071 / Level 4 of BTO1 / Level 3 of FTOA / Level 2 of FLTA
802   gMC->Gsatt("FALA","seen",0); // no children for FALB
803 //-->  gMC->Gsatt("FSTR","seen",-2);
804   // -> cfr previous settings
805   gMC->Gsatt("FPEA","seen",0); // no children for FPEA
806   gMC->Gsatt("FECA","seen",0); // no children for FECA
807   gMC->Gsatt("FWAA","seen",0); // no children for FWAA
808   gMC->Gsatt("FAIA","seen",0); // no children for FAIA
809
810   // Level 2 of B074
811   gMC->Gsatt("BTR2","seen",0); // BTR2 does not has sub-levels -
812   gMC->Gsatt("BTO2","seen",0);
813
814   // Level 2 of B075
815   gMC->Gsatt("BTR3","seen",0); // BTR3 do not have sub-levels -
816   gMC->Gsatt("BTO3","seen",0);
817
818 // for others Level 5, cfr. previous settings
819
820   gMC->Gdopt("hide","on");
821   gMC->Gdopt("shad","on");
822   gMC->Gsatt("*", "fill", 5);
823   gMC->SetClipBox(".");
824   gMC->SetClipBox("*", 0, 1000, 0, 1000, 0, 1000);
825   gMC->DefaultRange();
826   gMC->Gdraw("alic", 45, 40, 0, 10, 10, .015, .015);
827   gMC->Gdhead(1111,"TOF Strips V1");
828   gMC->Gdman(18, 4, "MAN");
829   gMC->Gdopt("hide","off");
830 }
831
832 //_____________________________________________________________________________
833 void AliTOFv0::CreateMaterials()
834 {
835   //
836   // Define materials for the Time Of Flight
837   //
838   AliTOF::CreateMaterials();
839 }
840  
841 //_____________________________________________________________________________
842 void AliTOFv0::Init()
843 {
844   //
845   // Initialise the detector after the geometry has been defined
846   //
847   printf("**************************************"
848          "  TOF  "
849          "**************************************\n");
850   printf("\n   Version 0 of TOF initialing, "
851               "symmetric TOF - Full Coverage version\n");
852
853   AliTOF::Init();
854
855   fIdFTOA = gMC->VolId("FTOA");
856   fIdFTOB = gMC->VolId("FTOB");
857   fIdFTOC = gMC->VolId("FTOC");
858   fIdFLTA = gMC->VolId("FLTA");
859   fIdFLTB = gMC->VolId("FLTB");
860   fIdFLTC = gMC->VolId("FLTC");
861
862   if(fDebug) {
863     printf("%s: **************************************"
864            "  TOF  "
865            "**************************************\n",ClassName());
866   }
867 }
868  
869 //_____________________________________________________________________________
870 void AliTOFv0::StepManager()
871 {
872   //
873   // Procedure called at each step in the Time Of Flight
874   //
875   TLorentzVector mom, pos;
876   Float_t xm[3],pm[3],xpad[3],ppad[3];
877   Float_t hits[13],phi,phid,z;
878   Int_t   vol[5];
879   Int_t   sector, plate, padx, padz, strip;
880   Int_t   copy, padzid, padxid, stripid, i;
881   Int_t   *idtmed = fIdtmed->GetArray()-499;
882   Float_t incidenceAngle;
883   
884   if(gMC->CurrentMedium()==idtmed[513] && 
885      gMC->IsTrackEntering() && gMC->TrackCharge()
886      && gMC->CurrentVolID(copy)==fIdSens) 
887   {    
888     // getting information about hit volumes
889     
890     padzid=gMC->CurrentVolOffID(2,copy);
891     padz=copy;  
892     
893     padxid=gMC->CurrentVolOffID(1,copy);
894     padx=copy;  
895     
896     stripid=gMC->CurrentVolOffID(4,copy);
897     strip=copy;  
898
899     gMC->TrackPosition(pos);
900     gMC->TrackMomentum(mom);
901
902 //    Double_t NormPos=1./pos.Rho();
903     Double_t normMom=1./mom.Rho();
904
905 //  getting the cohordinates in pad ref system
906     xm[0] = (Float_t)pos.X();
907     xm[1] = (Float_t)pos.Y();
908     xm[2] = (Float_t)pos.Z();
909
910     pm[0] = (Float_t)mom.X()*normMom;
911     pm[1] = (Float_t)mom.Y()*normMom;
912     pm[2] = (Float_t)mom.Z()*normMom;
913  
914     gMC->Gmtod(xm,xpad,1);
915     gMC->Gmtod(pm,ppad,2);
916
917     incidenceAngle = TMath::ACos(ppad[1])*kRaddeg;
918
919     z = pos[2];
920
921     plate = 0;   
922     if (TMath::Abs(z) <=  fZlenA*0.5)  plate = 2; //3; // AdC
923     if (z < (fZlenA*0.5+fZlenB) && 
924         z >  fZlenA*0.5)               plate = 1; //4; // AdC
925     if (z >-(fZlenA*0.5+fZlenB) &&
926         z < -fZlenA*0.5)               plate = 3; //2; // AdC
927     if (z > (fZlenA*0.5+fZlenB))       plate = 0; //5; // AdC
928     if (z <-(fZlenA*0.5+fZlenB))       plate = 4; //1; // AdC
929
930     if (plate==0) strip=AliTOFConstants::fgkNStripC-strip; // AdC
931     else if (plate==1) strip=AliTOFConstants::fgkNStripB-strip; // AdC
932     else strip--; // AdC
933
934     if (z<=0.) padx=AliTOFConstants::fgkNpadX-padx; // AdC
935     else padx--; // AdC
936
937     if (plate==3 || plate==4) padz=AliTOFConstants::fgkNpadZ-padz; // AdC
938     else padz--; // AdC
939
940     phi = pos.Phi();
941     if (phi>=0.) phid = phi*kRaddeg; //+180.; // AdC
942     else phid = phi*kRaddeg + 360.; // AdC
943     sector = Int_t (phid/20.);
944     //sector++;  // AdC
945
946     for(i=0;i<3;++i) {
947       hits[i]   = pos[i];
948       hits[i+3] = pm[i];
949     }
950
951     hits[6] = mom.Rho();
952     hits[7] = pos[3];
953     hits[8] = xpad[0];
954     hits[9] = xpad[1];
955     hits[10]= xpad[2];
956     hits[11]= incidenceAngle;
957     hits[12]= gMC->Edep();
958     
959     vol[0]= sector;
960     vol[1]= plate;
961     vol[2]= strip;
962     vol[3]= padx;
963     vol[4]= padz;
964
965     AddHit(gAlice->GetMCApp()->GetCurrentTrackNumber(),vol, hits);
966   }
967 }
968
969
970
971
972
973