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