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