e7ffd04eb832fc94b1168f7d958aaf084e592f55
[u/mrichter/AliRoot.git] / TOF / AliTOFv1.cxx
1 ///////////////////////////////////////////////////////////////////////////////
2 //                                                                           //
3 //  Time Of Flight                                                           //
4 //  This class contains the functions for version 1 of the Time Of Flight    //
5 //  detector.                                                                //
6 //                                                                           //
7 //Begin_Html
8 /*
9 <img src="gif/AliTOFv1Class.gif">
10 */
11 //End_Html
12 //                                                                           //
13 ///////////////////////////////////////////////////////////////////////////////
14
15 #include "AliTOFv1.h"
16 #include "AliRun.h"
17 #include "AliMC.h"
18 #include "AliConst.h"
19  
20 ClassImp(AliTOFv1)
21  
22 //_____________________________________________________________________________
23 AliTOFv1::AliTOFv1() : AliTOF()
24 {
25   //
26   // Default constructor
27   //
28 }
29  
30 //_____________________________________________________________________________
31 AliTOFv1::AliTOFv1(const char *name, const char *title)
32        : AliTOF(name,title)
33 {
34   //
35   // Standard constructor for version 1 of Time Of Flight
36   //
37 }
38  
39 //_____________________________________________________________________________
40 void AliTOFv1::CreateGeometry()
41 {
42   //
43   // Create geometry for version 1 of Time Of Flight
44   // Authors :   Maxim Martemianov, Boris Zagreev (ITEP)   18/09/98 
45   //Begin_Html
46   /*
47     <img src="gif/AliTOFv1.gif">
48   */
49   //End_Html
50   //
51
52   AliMC* pMC = AliMC::GetMC();
53   
54   Float_t fil_rich;
55   Int_t lmax;
56   Float_t phos_phi, zcor2, zcor3, ztof0, ztof1, ztof2;
57   Float_t zl, phos_r, zazor;
58   Int_t idrotm[101];
59   Float_t phos_x;
60   Float_t rp1, rp2;
61   Float_t par[10], fil_min, fil_max, ysz, fil0;
62   //
63   Int_t *idtmed = gAlice->Idtmed();
64   //
65   // barrel size along Z axis 
66   rp1 = 360.;
67   rp2 = 372.;
68   zl  = 720.;
69   //
70   // TOF width along radius of barrel 
71   //xtof  = rp2 - rp1;
72   ztof0 = 350.;
73   ztof1 = 200.;
74   ztof2 = 150.;
75   //
76   // Plate width 
77   ysz = .3;
78   //
79   // DME barrel width
80   zazor = 0.03;
81   //
82   // PHOS and RICH angles 
83   phos_x = 214.6;
84   phos_r = 467.;
85   //phos_z = 260.;
86   //rich_z = 472.5;
87   fil_rich = 30.;
88   lmax = 19;
89   zcor2 = ztof0 - ztof1 / 2.;
90   zcor3 = ztof0 - ztof2 / 2.;
91   phos_phi = TMath::ATan(phos_x / (phos_r * 2.));
92   fil_min = (kPI - phos_phi * 4.) * kRaddeg - 180. / lmax;
93   fil_max = (phos_phi * 4. + kPI) * kRaddeg + 180. / lmax;
94   //
95   // barrel radius in ALIC 
96   par[0] = rp1;
97   par[1] = rp2;
98   par[2] = zl / 2.;
99   pMC->Gsvolu("FBAR", "TUBE", idtmed[500], par, 3);
100   pMC->Gspos("FBAR", 1, "ALIC", 0., 0., 0., 0, "ONLY");
101   pMC->Gsatt("FBAR", "SEEN", 0);
102   //
103   // --- First Block
104   par[0] = (rp1+rp2-zazor)/2.;
105   par[1] = (rp1+rp2+zazor)/2.;
106   par[2] = ztof0;
107   par[3] = 90. - fil_min;
108   par[4] = 90. - fil_rich;
109   fil0 = 180. - (par[3] + par[4]);
110   //
111   // --- Sensitive volume 
112   pMC->Gsvolu("FBT1", "TUBS", idtmed[509], par, 5);
113   AliMatrix(idrotm[1], 90., fil0, 90., fil0 + 90., 0., 0.);
114   pMC->Gspos("FBT1", 0, "FBAR", 0., 0., 0., 0, "ONLY");
115   pMC->Gspos("FBT1", 1, "FBAR", 0., 0., 0., idrotm[1], "ONLY");
116   //
117   // ALUMINA
118   par[0] = (rp1+rp2+zazor)/2.;
119   par[1] = (rp1+rp2+zazor)/2.+ysz;
120   pMC->Gsvolu("FPE1","TUBS",idtmed[507], par, 0);
121   pMC->Gsposp("FPE1",2,"FBAR", 0., 0., 0., 0,         "ONLY", par, 5);
122   pMC->Gsposp("FPE1",3,"FBAR", 0., 0., 0., idrotm[1], "ONLY", par, 5);
123   //
124   par[0] = (rp1+rp2-zazor)/2.-ysz;
125   par[1] = (rp1+rp2-zazor)/2.;
126   pMC->Gsposp("FPE1",4,"FBAR", 0., 0., 0., 0,         "ONLY", par, 5);
127   pMC->Gsposp("FPE1",5,"FBAR", 0., 0., 0., idrotm[1], "ONLY", par, 5);
128   // --- Second block 
129   par[0] = (rp1+rp2-zazor)/2.;
130   par[1] = (rp1+rp2+zazor)/2.;
131   par[2] = ztof1 / 2.;
132   par[3] = 90. - fil_max;
133   par[4] = 90. - fil_min;
134   pMC->Gsvolu("FBT2", "TUBS", idtmed[509], par, 5);
135   pMC->Gspos("FBT2", 0, "FBAR", 0., 0., zcor2, 0, "ONLY");
136   pMC->Gspos("FBT2", 1, "FBAR", 0., 0., -zcor2, 0, "ONLY");
137   //
138   par[0]=(rp1+rp2+zazor)/2.;
139   par[1]=(rp1+rp2+zazor)/2.+ysz;
140   pMC->Gsvolu("FPE2","TUBS",idtmed[507], par, 0);
141   pMC->Gsposp("FPE2",2,"FBAR",0.,0.,zcor2,0,"ONLY",par,5);
142   pMC->Gsposp("FPE2",3,"FBAR",0.,0.,-zcor2,0,"ONLY",par,5);
143   //
144   par[0]=(rp1+rp2-zazor)/2.-ysz;
145   par[1]=(rp1+rp2-zazor)/2.;
146   pMC->Gsposp("FPE2",4,"FBAR",0.,0.,zcor2,0,"ONLY",par,5);
147   pMC->Gsposp("FPE2",5,"FBAR",0.,0.,-zcor2,0,"ONLY",par,5);
148   //
149   // --- Third block 
150   par[0] = (rp1+rp2-zazor)/2.;
151   par[1] = (rp1+rp2-zazor)/2.;
152   par[2] = ztof2 / 2.;
153   par[3] = 90. - fil_rich;
154   par[4] = fil_rich + 90.;
155   pMC->Gsvolu("FBT3", "TUBS", idtmed[509], par, 5);
156   pMC->Gspos("FBT3", 0, "FBAR", 0., 0., zcor3, 0, "ONLY");
157   pMC->Gspos("FBT3", 1, "FBAR", 0., 0., -zcor3, 0, "ONLY");
158   //
159   par[0]=(rp1+rp2+zazor)/2.;
160   par[1]=(rp1+rp2+zazor)/2.+ysz;
161   pMC->Gsvolu("FPE3","TUBS",idtmed[507], par, 0);
162   pMC->Gsposp("FPE3",2,"FBAR",0.,0.,zcor3,0,"ONLY",par,5);
163   pMC->Gsposp("FPE3",3,"FBAR",0.,0.,-zcor3,0,"ONLY",par,5);
164   //
165   par[0]=(rp1+rp2-zazor)/2.-ysz;
166   par[1]=(rp1+rp2-zazor)/2.;
167   pMC->Gsposp("FPE3",4,"FBAR",0.,0.,zcor3,0,"ONLY",par,5);
168   pMC->Gsposp("FPE3",5,"FBAR",0.,0.,-zcor3,0,"ONLY",par,5);
169   //
170 }
171  
172 //_____________________________________________________________________________
173 void AliTOFv1::DrawModule()
174 {
175   //
176   // Draw a shaded view of the Time Of Flight version 1
177   //
178
179   AliMC* pMC = AliMC::GetMC();
180   
181   // Set everything unseen
182   pMC->Gsatt("*", "seen", -1);
183   // 
184   // Set ALIC mother transparent
185   pMC->Gsatt("ALIC","SEEN",0);
186   //
187   // Set the volumes visible
188   pMC->Gsatt("FBAR","SEEN",0);
189   pMC->Gsatt("FPE1","SEEN",1);
190   pMC->Gsatt("FPE2","SEEN",1);
191   pMC->Gsatt("FPE3","SEEN",1);
192   //
193   pMC->Gdopt("hide", "on");
194   pMC->Gdopt("shad", "on");
195   pMC->Gsatt("*", "fill", 7);
196   pMC->SetClipBox(".");
197   pMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
198   pMC->DefaultRange();
199   pMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
200   pMC->Gdhead(1111, "Time Of Flight");
201   pMC->Gdman(18, 4, "MAN");
202   pMC->Gdopt("hide","off");
203 }
204
205 //___________________________________________
206 void AliTOFv1::CreateMaterials()
207 {
208   //
209   // Define materials for Time Of Flight
210   //
211   AliTOF::CreateMaterials();
212 }
213  
214 //______________________________________________________________________________
215 void AliTOFv1::Init()
216 {
217   //
218   // Initialise Time Of Flight after it has been built
219
220   AliMC* pMC = AliMC::GetMC();
221   
222   AliTOF::Init();
223   fIdFBT2=pMC->VolId("FBT2");
224   fIdFBT3=pMC->VolId("FBT3");
225 }
226  
227 //______________________________________________________________________________
228 void AliTOFv1::StepManager()
229 {
230   Float_t hits[8];
231   Int_t vol[3];
232   Int_t copy, id;
233   AliMC *pMC= AliMC::GetMC();
234   Int_t *idtmed = gAlice->Idtmed();
235   if(pMC->GetMedium()==idtmed[510-1] && 
236      pMC->TrackEntering() && pMC->TrackCharge()
237      && (id=pMC->CurrentVol(0,copy))==fIdSens) {
238     TClonesArray &lhits = *fHits;
239 //
240 // Record only charged tracks at entrance
241     vol[2]=copy;
242     vol[1]=pMC->CurrentVolOff(1,0,copy);
243     if(id==fIdFBT2) copy+=2; else 
244       if(id==fIdFBT2) copy+=4;
245     vol[0]=1;
246     pMC->TrackPosition(hits);
247     pMC->TrackMomentum(&hits[3]);
248     hits[7]=pMC->TrackTime();
249     new(lhits[fNhits++]) AliTOFhit(fIshunt,gAlice->CurrentTrack(),vol,hits);
250   }
251 }
252