]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFv0.cxx
Major upgrades to the strip structure
[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 /*
17 $Log$
18 Revision 1.18  2000/12/04 08:48:20  alibrary
19 Fixing problems in the HEAD
20
21 Revision 1.17  2000/10/02 21:28:17  fca
22 Removal of useless dependecies via forward declarations
23
24 Revision 1.16  2000/05/10 16:52:18  vicinanz
25 New TOF version with holes for PHOS/RICH
26
27 Revision 1.14.2.1  2000/05/10 09:37:16  vicinanz
28 New version with Holes for PHOS/RICH
29
30 Revision 1.14  1999/11/05 22:39:06  fca
31 New hits structure
32
33 Revision 1.13  1999/11/02 11:26:39  fca
34 added stdlib.h for exit
35
36 Revision 1.12  1999/11/01 20:41:57  fca
37 Added protections against using the wrong version of FRAME
38
39 Revision 1.11  1999/10/22 08:04:14  fca
40 Correct improper use of negative parameters
41
42 Revision 1.10  1999/10/16 19:30:06  fca
43 Corrected Rotation Matrix and CVS log
44
45 Revision 1.9  1999/10/15 15:35:20  fca
46 New version for frame1099 with and without holes
47
48 Revision 1.8  1999/09/29 09:24:33  fca
49 Introduction of the Copyright and cvs Log
50
51 */
52
53 ///////////////////////////////////////////////////////////////////////////////
54 //                                                                           //
55 //  Time Of Flight: design of C.Williams                FCA                  //
56 //  This class contains the functions for version 1 of the Time Of Flight    //
57 //  detector.                                                                //
58 //
59 //  VERSION WITH 5 MODULES AND TILTED STRIPS 
60 //  
61 //   FULL COVERAGE VERSION
62 //
63 //   Authors:
64 //
65 //   Alessio Seganti
66 //   Domenico Vicinanza
67 //
68 //   University of Salerno - Italy
69 //
70 //   Fabrizio Pierella
71 //   University of Bologna - Italy
72 //
73 //
74 //Begin_Html
75 /*
76 <img src="picts/AliTOFv0Class.gif">
77 */
78 //End_Html
79 //                                                                           //
80 ///////////////////////////////////////////////////////////////////////////////
81
82 #include <iostream.h>
83 #include <stdlib.h>
84
85 #include "AliTOFv0.h"
86 #include "TBRIK.h"
87 #include "TGeometry.h"
88 #include "TNode.h"
89 #include "TObject.h"
90 #include <TLorentzVector.h>
91 #include "AliRun.h"
92 #include "AliMC.h"
93 #include "AliConst.h"
94  
95 ClassImp(AliTOFv0)
96  
97 //_____________________________________________________________________________
98 AliTOFv0::AliTOFv0()
99 {
100   //
101   // Default constructor
102   //
103
104   //
105   // Check that FRAME is there otherwise we have no place where to
106   // put TOF
107   AliModule* frame=gAlice->GetModule("FRAME");
108   if(!frame) {
109     Error("Ctor","TOF needs FRAME to be present\n");
110     exit(1);
111   } else
112     if(frame->IsVersion()!=1) {
113       Error("Ctor","FRAME version 1 needed with this version of TOF\n");
114       exit(1);
115     }
116  
117
118 }
119  
120 //_____________________________________________________________________________
121 AliTOFv0::AliTOFv0(const char *name, const char *title)
122        : AliTOF(name,title)
123 {
124   //
125   // Standard constructor
126   //
127 }
128
129 //____________________________________________________________________________
130 AliTOFv0::~AliTOFv0()
131 {
132   // destructor
133
134   if ( fHits) {
135     fHits->Delete() ; 
136     delete fHits ;
137     fHits = 0 ; 
138   }
139 /*
140   if ( fSDigits) {
141     fSDigits->Delete() ; 
142     delete fSDigits ;
143     fSDigits = 0 ; 
144   }
145 */
146   if ( fDigits) {
147     fDigits->Delete() ; 
148     delete fDigits ;
149     fDigits = 0 ; 
150   }
151   
152 }
153  
154 //_____________________________________________________________________________
155 void AliTOFv0::BuildGeometry()
156 {
157   // Build TOF ROOT geometry for the ALICE event viewver
158   //
159   TNode *node, *top;
160   const int kColorTOF  = 27;
161
162   // Find top TNODE
163   top = gAlice->GetGeometry()->GetNode("alice");
164
165   // Position the different copies
166   const Float_t krTof  =(fRmax+fRmin)/2;
167   const Float_t khTof  = fRmax-fRmin;
168   const Int_t   kNTof = fNTof;
169   const Float_t kPi   = TMath::Pi();
170   const Float_t kangle = 2*kPi/kNTof;
171   Float_t ang;
172
173   // Define TOF basic volume
174   
175   char nodeName0[7], nodeName1[7], nodeName2[7]; 
176   char nodeName3[7], nodeName4[7], rotMatNum[7];
177
178   new TBRIK("S_TOF_C","TOF box","void",
179             120*0.5,khTof*0.5,fZlenC*0.5);
180   new TBRIK("S_TOF_B","TOF box","void",
181             120*0.5,khTof*0.5,fZlenB*0.5);
182   new TBRIK("S_TOF_A","TOF box","void",
183             120*0.5,khTof*0.5,fZlenA*0.5);
184
185   for (Int_t nodeNum=1;nodeNum<19;nodeNum++){
186      
187       if (nodeNum<10) {
188            sprintf(rotMatNum,"rot50%i",nodeNum);
189            sprintf(nodeName0,"FTO00%i",nodeNum);
190            sprintf(nodeName1,"FTO10%i",nodeNum);
191            sprintf(nodeName2,"FTO20%i",nodeNum);
192            sprintf(nodeName3,"FTO30%i",nodeNum);
193            sprintf(nodeName4,"FTO40%i",nodeNum);
194       }
195       if (nodeNum>9) {
196            sprintf(rotMatNum,"rot5%i",nodeNum);
197            sprintf(nodeName0,"FTO0%i",nodeNum);
198            sprintf(nodeName1,"FTO1%i",nodeNum);
199            sprintf(nodeName2,"FTO2%i",nodeNum);
200            sprintf(nodeName3,"FTO3%i",nodeNum);
201            sprintf(nodeName4,"FTO4%i",nodeNum);
202       }
203  
204       new TRotMatrix(rotMatNum,rotMatNum,90,-20*nodeNum,90,90-20*nodeNum,0,0);
205       ang = (4.5-nodeNum) * kangle;
206
207       top->cd();
208       node = new TNode(nodeName0,nodeName0,"S_TOF_C",krTof*TMath::Cos(ang),krTof*TMath::Sin(ang),299.15,rotMatNum);
209       node->SetLineColor(kColorTOF);
210       fNodes->Add(node); 
211
212       top->cd(); 
213       node = new TNode(nodeName1,nodeName1,"S_TOF_C",krTof*TMath::Cos(ang),krTof*TMath::Sin(ang),-299.15,rotMatNum);
214       node->SetLineColor(kColorTOF);
215       fNodes->Add(node); 
216
217       top->cd();
218       node = new TNode(nodeName2,nodeName2,"S_TOF_B",krTof*TMath::Cos(ang),krTof*TMath::Sin(ang),146.45,rotMatNum);
219       node->SetLineColor(kColorTOF);
220       fNodes->Add(node); 
221
222       top->cd();
223       node = new TNode(nodeName3,nodeName3,"S_TOF_B",krTof*TMath::Cos(ang),krTof*TMath::Sin(ang),-146.45,rotMatNum);
224       node->SetLineColor(kColorTOF);
225       fNodes->Add(node); 
226
227       top->cd();
228       node = new TNode(nodeName4,nodeName4,"S_TOF_A",krTof*TMath::Cos(ang),krTof*TMath::Sin(ang),0.,rotMatNum);
229       node->SetLineColor(kColorTOF);
230       fNodes->Add(node); 
231   }
232 }
233
234 //_____________________________________________________________________________
235 void AliTOFv0::CreateGeometry()
236 {
237   //
238   // Create geometry for Time Of Flight version 0
239   //
240   //Begin_Html
241   /*
242     <img src="picts/AliTOFv0.gif">
243   */
244   //End_Html
245   //
246   // Creates common geometry
247   //
248   AliTOF::CreateGeometry();
249 }
250  
251 //_____________________________________________________________________________
252 void AliTOFv0::TOFpc(Float_t xtof, Float_t ytof, Float_t zlenC,
253                      Float_t zlenB, Float_t zlenA, Float_t ztof0)
254 {
255   //
256   // Definition of the Time Of Fligh Resistive Plate Chambers
257   // xFLT, yFLT, zFLT - sizes of TOF modules (large)
258   
259   Float_t  ycoor, zcoor;
260   Float_t par[3];
261   Int_t *idtmed = fIdtmed->GetArray()-499;
262   Int_t idrotm[100];
263   Int_t nrot = 0;
264   
265   Float_t radius = fRmin+2.;//cm
266
267   par[0] =  xtof * 0.5;
268   par[1] =  ytof * 0.5;
269   par[2] = zlenC * 0.5;
270   gMC->Gsvolu("FTOC", "BOX ", idtmed[506], par, 3);
271   par[2] = zlenB * 0.5;
272   gMC->Gsvolu("FTOB", "BOX ", idtmed[506], par, 3);
273   par[2] = zlenA * 0.5;
274   gMC->Gsvolu("FTOA", "BOX ", idtmed[506], par, 3);
275
276
277 // Positioning of modules
278
279    Float_t zcor1 = ztof0 - zlenC*0.5;
280    Float_t zcor2 = ztof0 - zlenC - zlenB*0.5;
281    Float_t zcor3 = 0.;
282
283    AliMatrix(idrotm[0], 90., 0., 0., 0., 90, -90.);
284    AliMatrix(idrotm[1], 90., 180., 0., 0., 90, 90.);
285    gMC->Gspos("FTOC", 1, "BTO1", 0,  zcor1, 0, idrotm[0], "ONLY");
286    gMC->Gspos("FTOC", 2, "BTO1", 0, -zcor1, 0, idrotm[1], "ONLY");
287    gMC->Gspos("FTOC", 1, "BTO2", 0,  zcor1, 0, idrotm[0], "ONLY");
288    gMC->Gspos("FTOC", 2, "BTO2", 0, -zcor1, 0, idrotm[1], "ONLY");
289    gMC->Gspos("FTOC", 1, "BTO3", 0,  zcor1, 0, idrotm[0], "ONLY");
290    gMC->Gspos("FTOC", 2, "BTO3", 0, -zcor1, 0, idrotm[1], "ONLY");
291
292    gMC->Gspos("FTOB", 1, "BTO1", 0,  zcor2, 0, idrotm[0], "ONLY");
293    gMC->Gspos("FTOB", 2, "BTO1", 0, -zcor2, 0, idrotm[1], "ONLY");
294    gMC->Gspos("FTOB", 1, "BTO2", 0,  zcor2, 0, idrotm[0], "ONLY");
295    gMC->Gspos("FTOB", 2, "BTO2", 0, -zcor2, 0, idrotm[1], "ONLY");
296    gMC->Gspos("FTOB", 1, "BTO3", 0,  zcor2, 0, idrotm[0], "ONLY");
297    gMC->Gspos("FTOB", 2, "BTO3", 0, -zcor2, 0, idrotm[1], "ONLY");
298
299    gMC->Gspos("FTOA", 0, "BTO1", 0, zcor3,  0, idrotm[0], "ONLY");
300    gMC->Gspos("FTOA", 0, "BTO2", 0, zcor3,  0, idrotm[0], "ONLY");
301    gMC->Gspos("FTOA", 0, "BTO3", 0, zcor3,  0, idrotm[0], "ONLY");
302
303   Float_t db = 0.5;//cm
304   Float_t xFLT, yFLT, zFLTA, zFLTB, zFLTC;
305
306   xFLT = 122.0;//cm
307   yFLT = ytof;
308   zFLTA = zlenA - db*0.5;
309   zFLTB = zlenB - db*0.5;
310   zFLTC = zlenC - db*0.5;
311
312 // Sizes of MRPC pads
313
314   Float_t yPad = 0.505;//cm 
315   
316 // Large not sensitive volumes with Insensitive Freon
317   par[0] = xFLT*0.5;
318   par[1] = yFLT*0.5;   
319   
320   cout <<"************************* TOF geometry **************************"<<endl;
321   
322   par[2] = (zFLTA *0.5);
323   gMC->Gsvolu("FLTA", "BOX ", idtmed[512], par, 3); // Insensitive Freon
324   gMC->Gspos("FLTA", 0, "FTOA", 0., 0., 0., 0, "ONLY");
325            
326   par[2] = (zFLTB * 0.5);
327   gMC->Gsvolu("FLTB", "BOX ", idtmed[512], par, 3); // Insensitive Freon
328   gMC->Gspos("FLTB", 0, "FTOB", 0., 0., 0., 0, "ONLY");
329
330   par[2] = (zFLTC * 0.5);
331   gMC->Gsvolu("FLTC", "BOX ", idtmed[512], par, 3); // Insensitive Freon
332   gMC->Gspos("FLTC", 0, "FTOC", 0., 0., 0., 0, "ONLY");
333
334 ////////// Layers of Aluminum before and after detector ////////// 
335 ////////// Aluminum Box for Modules (2.0 mm thickness)  /////////
336 ////////// lateral walls not simulated
337   par[0] = xFLT*0.5;
338   par[1] = 0.1;//cm
339   ycoor = -yFLT/2 + par[1];
340   par[2] = (zFLTA *0.5);
341   gMC->Gsvolu("FALA", "BOX ", idtmed[508], par, 3); // Alluminium
342   gMC->Gspos("FALA", 1, "FLTA", 0., ycoor, 0., 0, "ONLY");
343   gMC->Gspos("FALA", 2, "FLTA", 0.,-ycoor, 0., 0, "ONLY");
344   par[2] = (zFLTB *0.5);
345   gMC->Gsvolu("FALB", "BOX ", idtmed[508], par, 3); // Alluminium
346   gMC->Gspos("FALB", 1, "FLTB", 0., ycoor, 0., 0, "ONLY");
347   gMC->Gspos("FALB", 2, "FLTB", 0.,-ycoor, 0., 0, "ONLY");   
348   par[2] = (zFLTC *0.5);
349   gMC->Gsvolu("FALC", "BOX ", idtmed[508], par, 3); // Alluminium
350   gMC->Gspos("FALC", 1, "FLTC", 0., ycoor, 0., 0, "ONLY");
351   gMC->Gspos("FALC", 2, "FLTC", 0.,-ycoor, 0., 0, "ONLY");
352
353 ///////////////// Detector itself //////////////////////
354
355   Float_t  stripWidth = 10.0;//cm
356   const Float_t  kdeadBound  =  1.5;//cm non-sensitive between the pad edge 
357                                    //and the boundary of the strip
358   const Int_t    knx   = 48;        // number of pads along x
359   const Int_t    knz   =  2;        // number of pads along z
360   const Float_t  kspace=  5.5;      //cm distance from the front plate of the box
361
362   Float_t zSenStrip;
363   zSenStrip = stripWidth-2*kdeadBound;//cm
364
365   par[0] = xFLT/2;
366   par[1] = yPad/2; 
367   par[2] = stripWidth/2.;
368
369 // new description for strip volume
370 // -- all constants are expressed in cm
371   // heigth of different layers
372   const Float_t khhony = 1.      ;   // heigth of HONY  Layer
373   const Float_t khpcby = 0.15    ;   // heigth of PCB   Layer
374   const Float_t khmyly = 0.035   ;   // heigth of MYLAR Layer
375   const Float_t khgraphy = 0.02  ;   // heigth of GRAPHITE Layer
376   const Float_t khglasseiy = 0.32;   // 2.2 Ext. Glass + 1. Semi Int. Glass (mm)
377   const Float_t khsensmy = 0.11  ;   // heigth of Sensitive Freon Mixture
378   const Float_t kwsensmz = 2*3.5 ;   // cm
379   const Float_t klsensmx = 48*2.5;   // cm
380   const Float_t kwpadz = 3.5;   // cm z dimension of the FPAD volume
381   const Float_t klpadx = 2.5;   // cm x dimension of the FPAD volume
382
383   // heigth of the FSTR Volume (the strip volume)
384   const Float_t khstripy = 2*(khhony+khpcby+khmyly+khgraphy+khglasseiy)+khsensmy;
385   // width  of the FSTR Volume (the strip volume)
386   const Float_t kwstripz = 10.; 
387   // length of the FSTR Volume (the strip volume)
388   const Float_t klstripx = 122.;
389   
390   Float_t parfp[3]={klstripx*0.5,khstripy*0.5,kwstripz*0.5};
391 // coordinates of the strip center in the strip reference frame; used for positioning
392 // internal strip volumes
393   Float_t posfp[3]={0.,0.,0.};
394   
395   // FSTR volume definition and filling this volume with non sensitive Gas Mixture
396   gMC->Gsvolu("FSTR","BOX",idtmed[512],parfp,3);
397   //-- HONY Layer definition
398 //  parfp[0] = -1;
399   parfp[1] = khhony*0.5;
400 //  parfp[2] = -1;
401   gMC->Gsvolu("FHON","BOX",idtmed[503],parfp,3);
402   // positioning 2 HONY Layers on FSTR volume
403   posfp[1]=-khstripy*0.5+parfp[1];
404   gMC->Gspos("FHON",1,"FSTR",0., posfp[1],0.,0,"ONLY");
405   gMC->Gspos("FHON",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");  
406
407   //-- PCB Layer definition   
408   parfp[1] = khpcby*0.5;
409   gMC->Gsvolu("FPCB","BOX",idtmed[504],parfp,3);
410   // positioning 2 PCB Layers on FSTR volume
411   posfp[1]=-khstripy*0.5+khhony+parfp[1];
412   gMC->Gspos("FPCB",1,"FSTR",0., posfp[1],0.,0,"ONLY");
413   gMC->Gspos("FPCB",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
414
415   //-- MYLAR Layer definition
416   parfp[1] = khmyly*0.5;
417   gMC->Gsvolu("FMYL","BOX",idtmed[511],parfp,3);
418   // positioning 2 MYLAR Layers on FSTR volume
419   posfp[1] = -khstripy*0.5+khhony+khpcby+parfp[1];
420   gMC->Gspos("FMYL",1,"FSTR",0., posfp[1],0.,0,"ONLY");
421   gMC->Gspos("FMYL",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
422
423   //-- Graphite Layer definition
424   parfp[1] = khgraphy*0.5;
425   gMC->Gsvolu("FGRP","BOX",idtmed[502],parfp,3);
426   // positioning 2 Graphite Layers on FSTR volume
427   posfp[1] = -khstripy*0.5+khhony+khpcby+khmyly+parfp[1];  
428   gMC->Gspos("FGRP",1,"FSTR",0., posfp[1],0.,0,"ONLY");
429   gMC->Gspos("FGRP",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
430   
431   //-- Glass (EXT. +Semi INT.) Layer definition
432   parfp[1] = khglasseiy*0.5;
433   gMC->Gsvolu("FGLA","BOX",idtmed[514],parfp,3);
434   // positioning 2 Glass Layers on FSTR volume 
435   posfp[1] = -khstripy*0.5+khhony+khpcby+khmyly+khgraphy+parfp[1];
436   gMC->Gspos("FGLA",1,"FSTR",0., posfp[1],0.,0,"ONLY");
437   gMC->Gspos("FGLA",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
438
439   //-- Sensitive Mixture Layer definition
440   parfp[0] = klsensmx*0.5;
441   parfp[1] = khsensmy*0.5;
442   parfp[2] = kwsensmz*0.5;
443   gMC->Gsvolu("FSEN","BOX",idtmed[513],parfp,3);
444   // positioning the sensitive gas Layer on FSTR volume
445   gMC->Gspos("FSEN",0,"FSTR",0.,0.,0.,0,"ONLY");
446   
447   // dividing FSEN along z in knz=2 and along x in knx=48
448   gMC->Gsdvn("FSEZ","FSEN",knz,3);
449   gMC->Gsdvn("FSEX","FSEZ",knx,1);
450
451   // FPAD volume definition
452   parfp[0] = klpadx*0.5;
453   parfp[1] = khsensmy*0.5;
454   parfp[2] = kwpadz*0.5;
455   gMC->Gsvolu("FPAD","BOX",idtmed[513],parfp,3);
456   // positioning the FPAD volumes on previous divisions
457   gMC->Gspos("FPAD",0,"FSEX",0.,0.,0.,0,"ONLY");
458
459 ////  Positioning the Strips  (FSTR) in the FLT volumes  /////
460
461   // Plate A (Central) 
462   
463   Float_t t = zFLTC+zFLTB+zFLTA*0.5+ 2*db;//Half Width of Barrel
464
465   Float_t gap  =  4.; //cm  distance between the strip axis
466   Float_t zpos = 0;
467   Float_t ang  = 0;
468   Float_t last;
469   Int_t i=1,j=1;
470   nrot  = 0;
471   zcoor = 0;
472   ycoor = -14.5 + kspace ; //2 cm over front plate
473
474   AliMatrix (idrotm[0],  90.,  0.,90.,90.,0., 90.);   
475   gMC->Gspos("FSTR",j,"FLTA",0.,ycoor, 0.,idrotm[0],"ONLY");
476   zcoor -= zSenStrip;
477
478   j++;
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      j += 2;
492      upDown*= -1; // Alternate strips 
493      zcoor = zcoor-(zSenStrip/2)/TMath::Cos(ang)-
494              upDown*gap*TMath::Tan(ang)-
495              (zSenStrip/2)/TMath::Cos(ang);
496   } while (zcoor-(stripWidth/2)*TMath::Cos(ang)>-t+zFLTC+zFLTB+db*2);
497   
498   zcoor = zcoor+(zSenStrip/2)/TMath::Cos(ang)-
499           upDown*gap*TMath::Tan(ang)+
500           (zSenStrip/2)/TMath::Cos(ang);
501           
502   gap = 6.;
503   zcoor = zcoor-(zSenStrip/2)/TMath::Cos(ang)-
504           upDown*gap*TMath::Tan(ang)-
505           (zSenStrip/2)/TMath::Cos(ang);
506
507   ang = atan(zcoor/radius);
508   ang *= kRaddeg;
509   AliMatrix (idrotm[nrot],  90.,  0.,90.-ang,90.,-ang, 90.);   
510   AliMatrix (idrotm[nrot+1],90.,180.,90.+ang,90., ang, 90.);
511   ang /= kRaddeg;
512           
513   ycoor = -14.5+ kspace; //2 cm over front plate
514   ycoor += (1-(upDown+1)/2)*gap;
515   gMC->Gspos("FSTR",j  ,"FLTA",0.,ycoor, zcoor,idrotm[nrot],  "ONLY");
516   gMC->Gspos("FSTR",j+1,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
517   
518   ycoor = -29./2.+ kspace;//2 cm over front plate
519
520   // Plate  B
521
522   nrot = 0;
523   i=1;
524   upDown *= -1;
525   
526   zpos = zcoor - (zSenStrip/2)/TMath::Cos(ang)-
527          upDown*gap*TMath::Tan(ang)-
528          (zSenStrip/2)/TMath::Cos(ang)-0.5/TMath::Cos(ang);
529
530   ang = atan(zpos/radius);
531   ang *= kRaddeg;
532   AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
533   ang /= kRaddeg;
534   ycoor = -29.*0.5+ kspace ; //2 cm over front plate
535   ycoor += (1-(upDown+1)/2)*gap;
536   zcoor = zpos+(zFLTA*0.5+zFLTB*0.5+db); // Moves to the system of the modulus FLTB
537   gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
538   i++;
539   upDown*=-1;
540
541   do {
542      zpos = zpos - (zSenStrip/2)/TMath::Cos(ang)-
543             upDown*gap*TMath::Tan(ang)-
544             (zSenStrip/2)/TMath::Cos(ang);
545      ang = atan(zpos/radius);
546      ang *= kRaddeg;
547      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
548      ang /= kRaddeg;
549      ycoor = -29.*0.5+ kspace ; //2 cm over front plate
550      ycoor += (1-(upDown+1)/2)*gap;
551      zcoor = zpos+(zFLTA*0.5+zFLTB*0.5+db); // Moves to the system of the modulus FLTB
552      gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
553      upDown*=-1;
554      i++;
555   } while (TMath::Abs(ang*kRaddeg)<22.5);//till we reach a tilting angle of 22.5 degrees
556
557   ycoor = -29.*0.5+ kspace ; //2 cm over front plate
558
559   do {
560      i++;
561      ang = atan(zpos/radius);
562      ang *= kRaddeg;
563      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
564      ang /= kRaddeg;
565      zcoor = zpos+(zFLTB/2+zFLTA/2+db);
566      gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
567      zpos = zpos - zSenStrip/TMath::Cos(ang);
568      last = stripWidth*TMath::Cos(ang)/2.;
569   }  while (zpos>-t+zFLTC+db);
570
571   // Plate  C
572
573   zpos = zpos - (zSenStrip/2)/TMath::Cos(ang)-
574          gap*TMath::Tan(ang)-
575          (zSenStrip/2)/TMath::Cos(ang);
576
577   nrot = 0;
578   i=0;
579   ycoor= -29.*0.5+kspace+gap;
580
581   do {
582      i++;
583      ang = atan(zpos/radius);
584      ang *= kRaddeg;
585      AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
586      ang /= kRaddeg;
587      zcoor = zpos+(zFLTC*0.5+zFLTB+zFLTA*0.5+db*2);
588      gMC->Gspos("FSTR",i, "FLTC", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
589      zpos = zpos - zSenStrip/TMath::Cos(ang);
590      last = stripWidth*TMath::Cos(ang)*0.5;
591   }  while (zpos>-t+last);
592
593
594 ////////// Layers after strips /////////////////
595 // honeycomb (Polyethilene) Layer after (1.2cm)
596
597   Float_t overSpace = fOverSpc;//cm
598
599   par[0] = xFLT*0.5;
600   par[1] = 0.6;
601   par[2] = (zFLTA *0.5);
602   ycoor = -yFLT/2 + overSpace + par[1];
603   gMC->Gsvolu("FPEA", "BOX ", idtmed[503], par, 3); // Hony
604   gMC->Gspos ("FPEA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
605   par[2] = (zFLTB *0.5);
606   gMC->Gsvolu("FPEB", "BOX ", idtmed[503], par, 3); // Hony
607   gMC->Gspos ("FPEB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
608   par[2] = (zFLTC *0.5);
609   gMC->Gsvolu("FPEC", "BOX ", idtmed[503], par, 3); // Hony
610   gMC->Gspos ("FPEC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
611
612 // Electronics (Cu) after
613   ycoor += par[1];
614   par[0] = xFLT*0.5;
615   par[1] = 1.43*0.05*0.5; // 5% of X0
616   par[2] = (zFLTA *0.5);
617   ycoor += par[1];
618   gMC->Gsvolu("FECA", "BOX ", idtmed[501], par, 3); // Cu
619   gMC->Gspos ("FECA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
620   par[2] = (zFLTB *0.5);
621   gMC->Gsvolu("FECB", "BOX ", idtmed[501], par, 3); // Cu
622   gMC->Gspos ("FECB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
623   par[2] = (zFLTC *0.5);
624   gMC->Gsvolu("FECC", "BOX ", idtmed[501], par, 3); // Cu
625   gMC->Gspos ("FECC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
626
627 // cooling WAter after
628   ycoor += par[1];
629   par[0] = xFLT*0.5;
630   par[1] = 36.1*0.02*0.5; // 2% of X0
631   par[2] = (zFLTA *0.5);
632   ycoor += par[1];
633   gMC->Gsvolu("FWAA", "BOX ", idtmed[515], par, 3); // Water
634   gMC->Gspos ("FWAA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
635   par[2] = (zFLTB *0.5);
636   gMC->Gsvolu("FWAB", "BOX ", idtmed[515], par, 3); // Water
637   gMC->Gspos ("FWAB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
638   par[2] = (zFLTC *0.5);
639   gMC->Gsvolu("FWAC", "BOX ", idtmed[515], par, 3); // Water
640   gMC->Gspos ("FWAC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
641
642 // frame of Air
643   ycoor += par[1];
644   par[0] = xFLT*0.5;
645   par[1] = (yFLT/2-ycoor-0.2)*0.5; // Aluminum layer considered (0.2 cm)
646   par[2] = (zFLTA *0.5);
647   ycoor += par[1];
648   gMC->Gsvolu("FAIA", "BOX ", idtmed[500], par, 3); // Air
649   gMC->Gspos ("FAIA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
650   par[2] = (zFLTB *0.5);
651   gMC->Gsvolu("FAIB", "BOX ", idtmed[500], par, 3); // Air
652   gMC->Gspos ("FAIB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
653   par[2] = (zFLTC *0.5);
654   gMC->Gsvolu("FAIC", "BOX ", idtmed[500], par, 3); // Air
655   gMC->Gspos ("FAIC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
656 /* fp
657 //Back Plate honycomb (2cm)
658   par[0] = -1;
659   par[1] = 2 *0.5;
660   par[2] = -1;
661   ycoor = yFLT/2 - par[1];
662   gMC->Gsvolu("FBPA", "BOX ", idtmed[503], par, 3); // Hony
663   gMC->Gspos ("FBPA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
664   gMC->Gsvolu("FBPB", "BOX ", idtmed[503], par, 3); // Hony
665   gMC->Gspos ("FBPB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
666   gMC->Gsvolu("FBPC", "BOX ", idtmed[503], par, 3); // Hony
667   gMC->Gspos ("FBPC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
668 fp */
669 }
670
671 //_____________________________________________________________________________
672 void AliTOFv0::DrawModule()
673 {
674   //
675   // Draw a shaded view of the Time Of Flight version 1
676   //
677   // Set everything unseen
678   gMC->Gsatt("*", "seen", -1);
679   // 
680   // Set ALIC mother transparent
681   gMC->Gsatt("ALIC","SEEN",0);
682   //
683   // Set the volumes visible
684   gMC->Gsatt("ALIC","SEEN",0);
685
686   gMC->Gsatt("FTOA","SEEN",1);
687   gMC->Gsatt("FTOB","SEEN",1);
688   gMC->Gsatt("FTOC","SEEN",1);
689   gMC->Gsatt("FLTA","SEEN",1);
690   gMC->Gsatt("FLTB","SEEN",1);
691   gMC->Gsatt("FLTC","SEEN",1);
692   gMC->Gsatt("FPLA","SEEN",1);
693   gMC->Gsatt("FPLB","SEEN",1);
694   gMC->Gsatt("FPLC","SEEN",1);
695   gMC->Gsatt("FSTR","SEEN",1);
696   gMC->Gsatt("FPEA","SEEN",1);
697   gMC->Gsatt("FPEB","SEEN",1);
698   gMC->Gsatt("FPEC","SEEN",1);
699   
700   gMC->Gsatt("FLZ1","SEEN",0);
701   gMC->Gsatt("FLZ2","SEEN",0);
702   gMC->Gsatt("FLZ3","SEEN",0);
703   gMC->Gsatt("FLX1","SEEN",0);
704   gMC->Gsatt("FLX2","SEEN",0);
705   gMC->Gsatt("FLX3","SEEN",0);
706   gMC->Gsatt("FPAD","SEEN",0);
707
708   gMC->Gdopt("hide", "on");
709   gMC->Gdopt("shad", "on");
710   gMC->Gsatt("*", "fill", 7);
711   gMC->SetClipBox(".");
712   gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
713   gMC->DefaultRange();
714   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
715   gMC->Gdhead(1111, "Time Of Flight");
716   gMC->Gdman(18, 4, "MAN");
717   gMC->Gdopt("hide","off");
718 }
719
720 //_____________________________________________________________________________
721 void AliTOFv0::CreateMaterials()
722 {
723   //
724   // Define materials for the Time Of Flight
725   //
726   AliTOF::CreateMaterials();
727 }
728  
729 //_____________________________________________________________________________
730 void AliTOFv0::Init()
731 {
732   //
733   // Initialise the detector after the geometry has been defined
734   //
735   printf("**************************************"
736          "  TOF  "
737          "**************************************\n");
738   printf("\n   Version 0 of TOF initialing, "
739               "symmetric TOF\n");
740
741   AliTOF::Init();
742
743   fIdFTOA = gMC->VolId("FTOA");
744   fIdFTOB = gMC->VolId("FTOB");
745   fIdFTOC = gMC->VolId("FTOC");
746   fIdFLTA = gMC->VolId("FLTA");
747   fIdFLTB = gMC->VolId("FLTB");
748   fIdFLTC = gMC->VolId("FLTC");
749
750   printf("**************************************"
751          "  TOF  "
752          "**************************************\n");
753 }
754  
755 //_____________________________________________________________________________
756 void AliTOFv0::StepManager()
757 {
758   //
759   // Procedure called at each step in the Time Of Flight
760   //
761   Float_t hits[8],rho,phi,phid,z;
762   Int_t   sector, plate, padx, padz, strip;
763   Int_t   copy, padzid, padxid, stripid, i;
764   Int_t   vol[4];
765   Int_t   *idtmed = fIdtmed->GetArray()-499;
766   TLorentzVector mom, pos;
767   
768   
769   if(gMC->GetMedium()==idtmed[513] && 
770      gMC->IsTrackEntering() && gMC->TrackCharge()
771      && gMC->CurrentVolID(copy)==fIdSens) 
772   {    
773 // getting information about hit volumes
774     
775     padzid=gMC->CurrentVolOffID(2,copy);
776     padz=copy;  
777     
778     padxid=gMC->CurrentVolOffID(1,copy);
779     padx=copy;  
780     
781     stripid=gMC->CurrentVolOffID(4,copy);
782     strip=copy;  
783
784     padz = (strip-1)*2+padz;
785
786     gMC->TrackPosition(pos);
787     gMC->TrackMomentum(mom);
788
789     rho = sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
790     phi = TMath::ACos(pos[0]/rho);
791     Float_t as = TMath::ASin(pos[1]/rho);
792     if (as<0) phi = 2*3.141592654-phi;
793
794     z = pos[2];
795    
796     plate = 0;
797     Float_t limA = fZlenA*0.5;
798     Float_t limB = fZlenB+limA;
799     
800     if (TMath::Abs(z)<=limA) plate = 3;
801     if (z<= limB && z> limA) plate = 2;
802     if (z>=-limB && z<-limA) plate = 4;
803     if (z> limB)             plate = 1;
804     if (z<-limB)             plate = 5;
805
806     if (plate==3)  padz -= 2;
807
808     phid   = phi*kRaddeg;
809     sector = Int_t (phid/20.);
810     sector++;
811
812     Double_t ptot = mom.Rho();
813     Double_t norm = 1/ptot;
814     for(i=0;i<3;++i) {
815       hits[i]   = pos[i];
816       hits[i+3] = mom[i]*norm;
817     }
818     hits[6] = ptot;
819     hits[7] = pos[3];
820     
821     vol[0] = sector;
822     vol[1] = plate;
823     vol[2] = padx;
824     vol[3] = padz;
825     
826     Int_t track = gAlice->CurrentTrack();
827     AliTOF::AddHit(track,vol, hits);
828   }
829 }
830
831
832
833
834
835