]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFv5.cxx
Vertex reconstruction
[u/mrichter/AliRoot.git] / TOF / AliTOFv5.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.4  1999/11/05 22:39:06  fca
19 New hits structure
20
21 Revision 1.3  1999/11/01 20:41:58  fca
22 Added protections against using the wrong version of FRAME
23
24 Revision 1.2  1999/10/16 19:21:57  fca
25 Corrected Rotation Matrix and CVS logAliTOFv4.cxx
26
27 Revision 1.1  1999/10/15 15:35:20  fca
28 New version for frame1099 with and without holes
29
30 */
31
32 ///////////////////////////////////////////////////////////////////////////////
33 //                                                                           //
34 //  Time Of Flight: design of C.Williams                FCA                  //
35 //  This class contains the functions for version 1 of the Time Of Flight    //
36 //  detector.                                                                //
37 //
38 //  VERSION WITH 5 MODULES AND FLAT PLATES 
39 //  
40 //   WITH HOLES FOR PHOS AND HMPID 
41 //   INSIDE A FULL COVERAGE SPACE FRAME
42 //
43 //
44 //   Authors:
45 //
46 //   Alessio Seganti
47 //   Domenico Vicinanza
48 //
49 //   University of Salerno - Italy
50 //
51 //
52 //Begin_Html
53 /*
54 <img src="picts/AliTOFv5Class.gif">
55 */
56 //End_Html
57 //                                                                           //
58 ///////////////////////////////////////////////////////////////////////////////
59
60 #include <iostream.h>
61 #include <stdlib.h>
62
63 #include "AliTOFv5.h"
64 #include "AliRun.h"
65 #include "AliConst.h"
66  
67 ClassImp(AliTOFv5)
68  
69 //_____________________________________________________________________________
70 AliTOFv5::AliTOFv5()
71 {
72   //
73   // Default constructor
74   //
75 }
76  
77 //_____________________________________________________________________________
78 AliTOFv5::AliTOFv5(const char *name, const char *title)
79        : AliTOF(name,title)
80 {
81   //
82   // Standard constructor
83   //
84   //
85   // Check that FRAME is there otherwise we have no place where to
86   // put TOF
87   AliModule* FRAME=gAlice->GetModule("FRAME");
88   if(!FRAME) {
89     Error("Ctor","TOF needs FRAME to be present\n");
90     exit(1);
91   } else 
92     if(FRAME->IsVersion()!=1) {
93       Error("Ctor","FRAME version 1 needed with this version of TOF\n");
94       exit(1);
95     }
96
97 }
98  
99 //_____________________________________________________________________________
100 void AliTOFv5::CreateGeometry()
101 {
102   //
103   // Create geometry for Time Of Flight version 0
104   //
105   //Begin_Html
106   /*
107     <img src="picts/AliTOFv5.gif">
108   */
109   //End_Html
110   //
111   // Creates common geometry
112   //
113   AliTOF::CreateGeometry();
114 }
115  
116 //_____________________________________________________________________________
117 void AliTOFv5::TOFpc(Float_t xtof, Float_t ytof, Float_t zlen1,
118                      Float_t zlen2, Float_t zlen3, Float_t ztof0)
119 {
120   //
121   // Definition of the Time Of Fligh Resistive Plate Chambers
122   // xFLT, yFLT, zFLT - sizes of TOF modules (large)
123   
124   Float_t  ycoor;
125   Float_t par[10];
126   Int_t idrotm[100];
127   
128   Float_t yFREON, xp, yp, zp;
129   
130   Int_t *idtmed = fIdtmed->GetArray()-499;
131
132
133   par[0] =  xtof / 2.;
134   par[1] =  ytof / 2.;
135   par[2] = zlen1 / 2.;
136   gMC->Gsvolu("FTO1", "BOX ", idtmed[506], par, 3);
137   par[2] = zlen2 / 2.;
138   gMC->Gsvolu("FTO2", "BOX ", idtmed[506], par, 3);
139   par[2] = zlen3 / 2.;
140   gMC->Gsvolu("FTO3", "BOX ", idtmed[506], par, 3);
141
142
143 // Position of modules
144   Float_t zcor1 = ztof0 - zlen1/2;
145   Float_t zcor2 = ztof0 - zlen1 - zlen2/2.;
146   Float_t zcor3 = 0.;
147
148    AliMatrix(idrotm[0], 90., 0., 0., 0., 90, -90.);
149    AliMatrix(idrotm[1], 90., 180., 0., 0., 90, 90.);
150    gMC->Gspos("FTO1", 1, "BTO1", 0,  zcor1, 0, idrotm[0], "ONLY");
151    gMC->Gspos("FTO1", 2, "BTO1", 0, -zcor1, 0, idrotm[1], "ONLY");
152    gMC->Gspos("FTO1", 1, "BTO2", 0,  zcor1, 0, idrotm[0], "ONLY");
153    gMC->Gspos("FTO1", 2, "BTO2", 0, -zcor1, 0, idrotm[1], "ONLY");
154    gMC->Gspos("FTO1", 1, "BTO3", 0,  zcor1, 0, idrotm[0], "ONLY");
155    gMC->Gspos("FTO1", 2, "BTO3", 0, -zcor1, 0, idrotm[1], "ONLY");
156
157    gMC->Gspos("FTO2", 1, "BTO1", 0,  zcor2, 0, idrotm[0], "ONLY");
158    gMC->Gspos("FTO2", 2, "BTO1", 0, -zcor2, 0, idrotm[1], "ONLY");
159    gMC->Gspos("FTO2", 1, "BTO2", 0,  zcor2, 0, idrotm[0], "ONLY");
160    gMC->Gspos("FTO2", 2, "BTO2", 0, -zcor2, 0, idrotm[1], "ONLY");
161
162    gMC->Gspos("FTO3", 0, "BTO1", 0, zcor3,  0, idrotm[0], "ONLY");
163
164 // Subtraction the distance to TOF module boundaries 
165
166   Float_t db = 7.;
167   Float_t xFLT, yFLT, zFLT1, zFLT2, zFLT3;
168
169
170   xFLT = xtof -(.5 +.5)*2;
171   yFLT = ytof;
172   zFLT1 = zlen1 - db;
173   zFLT2 = zlen2 - db;
174   zFLT3 = zlen3 - db;
175
176   
177 // fron gaps in MRPC chamber 
178   yFREON = .11; //cm
179
180 // Sizes of MRPC pads
181
182   xp = 3.0; 
183   yp = 12.3*0.05; // 5% X0 of glass 
184   zp = 3.0;
185
186 //  Subtraction of dead boundaries in X=2 cm and Z=7/2 cm 
187
188 cout <<"************************* TOF geometry **************************"<<endl;
189
190   Int_t nz1, nz2, nz3, nx; //- numbers of pixels
191   nx = Int_t (xFLT/xp);
192
193   printf("Number of pixel along x axis = %i",nx);
194
195   par[0] = xFLT/2;
196   par[1] = yFLT/2;
197   par[2] = (zFLT1 / 2.);
198   nz1 = Int_t (par[2]*2/zp);
199   gMC->Gsvolu("FLT1", "BOX ", idtmed[506], par, 3); // CO2
200   gMC->Gspos("FLT1", 0, "FTO1", 0., 0., 0., 0, "ONLY");
201   printf("Number of pixel along z axis (module 1) = %i",nz1);
202
203   par[2] = (zFLT2 / 2.);
204   nz2 = Int_t (par[2]*2/zp);
205   gMC->Gsvolu("FLT2", "BOX ", idtmed[506], par, 3); // CO2
206   gMC->Gspos("FLT2", 0, "FTO2", 0., 0., 0., 0, "ONLY");
207   printf("Number of pixel along z axis (module 2) = %i",nz2);
208
209   par[2] = (zFLT3 / 2.); 
210   nz3 = Int_t (par[2]*2/zp);
211   gMC->Gsvolu("FLT3", "BOX ", idtmed[506], par, 3); // CO2
212   gMC->Gspos("FLT3", 0, "FTO3", 0., 0., 0., 0, "ONLY");
213   printf("Number of pixel along z axis (module 3) = %i",nz3);
214
215 ////////// Layers before detector ////////////////////
216
217 // Alluminium layer in front 1.0 mm thick at the beginning
218   par[0] = -1;
219   par[1] = 0.1;
220   par[2] = -1;
221   ycoor = -yFLT/2 + par[1];
222   gMC->Gsvolu("FMY1", "BOX ", idtmed[508], par, 3); // Alluminium
223   gMC->Gspos("FMY1", 0, "FLT1", 0., ycoor, 0., 0, "ONLY");
224   gMC->Gsvolu("FMY2", "BOX ", idtmed[508], par, 3); // Alluminium
225   gMC->Gspos("FMY2", 0, "FLT2", 0., ycoor, 0., 0, "ONLY");
226   gMC->Gsvolu("FMY3", "BOX ", idtmed[508], par, 3); // Alluminium 
227   gMC->Gspos("FMY3", 0, "FLT3", 0., ycoor, 0., 0, "ONLY");
228
229 // Honeycomb layer (1cm of special polyethilene)
230   ycoor = ycoor + par[1];
231   par[0] = -1;
232   par[1] = 1. / 2;
233   par[2] = -1;
234   ycoor = ycoor + par[1];
235   gMC->Gsvolu("FPL1", "BOX ", idtmed[503], par, 3); // Hony
236   gMC->Gspos("FPL1", 0, "FLT1", 0., ycoor, 0., 0, "ONLY");
237   gMC->Gsvolu("FPL2", "BOX ", idtmed[503], par, 3); // Hony
238   gMC->Gspos("FPL2", 0, "FLT2", 0., ycoor, 0., 0, "ONLY");
239   gMC->Gsvolu("FPL3", "BOX ", idtmed[503], par, 3); // Hony
240   gMC->Gspos("FPL3", 0, "FLT3", 0., ycoor, 0., 0, "ONLY");
241
242 ///////////////// Detector itself //////////////////////
243
244   const Float_t SpaceBefore=2.;
245
246   par[0] = -1;
247   par[1] = yp/2; // 5 %X0 thick of glass  
248   par[2] = -1;
249   ycoor = -yFLT/2 + SpaceBefore;
250   gMC->Gsvolu("FLD1", "BOX ", idtmed[514], par, 3); // Glass
251   gMC->Gspos("FLD1", 0, "FLT1", 0., ycoor, 0., 0, "ONLY");
252   gMC->Gsvolu("FLD2", "BOX ", idtmed[514], par, 3); // Glass
253   gMC->Gspos("FLD2", 0, "FLT2", 0., ycoor, 0., 0, "ONLY");
254   gMC->Gsvolu("FLD3", "BOX ", idtmed[514], par, 3); // Glass
255   gMC->Gspos("FLD3", 0, "FLT3", 0., ycoor, 0., 0, "ONLY");
256
257   gMC->Gsdvn("FLZ1", "FLD1", nz1, 3); //pixel size xp=zp=3
258   gMC->Gsdvn("FLZ2", "FLD2", nz2, 3); 
259   gMC->Gsdvn("FLZ3", "FLD3", nz3, 3); 
260   gMC->Gsdvn("FLX1", "FLZ1", nx, 1);
261   gMC->Gsdvn("FLX2", "FLZ2", nx, 1); 
262   gMC->Gsdvn("FLX3", "FLZ3", nx, 1); 
263
264 // MRPC pixel itself 
265   par[0] = -1;//xp/2;
266   par[1] = -1;//yp/2; // 5 %X0 thick of glass  
267   par[2] = -1;//zp/2;
268   gMC->Gsvolu("FPA0", "BOX ", idtmed[514], par, 3);// Glass
269   gMC->Gspos("FPA0", 1, "FLX1", 0., 0., 0., 0, "ONLY");
270   gMC->Gspos("FPA0", 2, "FLX2", 0., 0., 0., 0, "ONLY");
271   gMC->Gspos("FPA0", 3, "FLX3", 0., 0., 0., 0, "ONLY");
272
273 // Freon gas sencitive vol.ume
274   par[0] = -1;
275   par[1] = yFREON/2;
276   par[2] = -1;
277   gMC->Gsvolu("FPAD", "BOX ", idtmed[513], par, 3);// Freon 
278   gMC->Gspos("FPAD", 0, "FPA0", 0., 0., 0., 0, "ONLY");
279
280 ////////// Layers after detector ////////////////////
281
282   const Float_t SpaceAfter=6.;
283
284 // Honeycomb layer after (3cm)
285   par[0] = -1;
286   par[1] = 0.6;
287   par[2] = -1;
288   ycoor = -yFLT/2 + SpaceAfter - par[1];
289   gMC->Gsvolu("FPE1", "BOX ", idtmed[503], par, 3); // Hony
290   gMC->Gspos("FPE1", 0, "FLT1", 0., ycoor, 0., 0, "ONLY");
291   gMC->Gsvolu("FPE2", "BOX ", idtmed[503], par, 3); // Hony
292   gMC->Gspos("FPE2", 0, "FLT2", 0., ycoor, 0., 0, "ONLY");
293   gMC->Gsvolu("FPE3", "BOX ", idtmed[503], par, 3); // Hony
294   gMC->Gspos("FPE3", 0, "FLT3", 0., ycoor, 0., 0, "ONLY");
295
296 // Electronics (Cu) after
297   par[0] = -1;
298   par[1] = 1.43*0.05 / 2.; // 5% of X0
299   par[2] = -1;
300   ycoor = -yFLT/2 + SpaceAfter +par[1];
301   gMC->Gsvolu("FEC1", "BOX ", idtmed[501], par, 3); // Cu
302   gMC->Gspos("FEC1", 0, "FLT1", 0., ycoor, 0., 0, "ONLY");
303   gMC->Gsvolu("FEC2", "BOX ", idtmed[501], par, 3); // Cu
304   gMC->Gspos("FEC2", 0, "FLT2", 0., ycoor, 0., 0, "ONLY");
305   gMC->Gsvolu("FEC3", "BOX ", idtmed[501], par, 3); // Cu
306   gMC->Gspos("FEC3", 0, "FLT3", 0., ycoor, 0., 0, "ONLY");
307
308 // Cooling water after
309   ycoor = ycoor+par[1];
310   par[0] = -1;
311   par[1] = 36.1*0.02 / 2.; // 2% of X0
312   par[2] = -1;
313   ycoor = ycoor+par[1];
314   gMC->Gsvolu("FWA1", "BOX ", idtmed[515], par, 3); // Water
315   gMC->Gspos("FWA1", 0, "FLT1", 0., ycoor, 0., 0, "ONLY");
316   gMC->Gsvolu("FWA2", "BOX ", idtmed[515], par, 3); // Water
317   gMC->Gspos("FWA2", 0, "FLT2", 0., ycoor, 0., 0, "ONLY");
318   gMC->Gsvolu("FWA3", "BOX ", idtmed[515], par, 3); // Water
319   gMC->Gspos("FWA3", 0, "FLT3", 0., ycoor, 0., 0, "ONLY");
320
321 //back plate honycomb (2cm)
322   par[0] = -1;
323   par[1] = 2 / 2.;
324   par[2] = -1;
325   ycoor = yFLT/2 - par[1];
326   gMC->Gsvolu("FEG1", "BOX ", idtmed[503], par, 3); // Hony
327   gMC->Gspos("FEG1", 0, "FLT1", 0., ycoor, 0., 0, "ONLY");
328   gMC->Gsvolu("FEG2", "BOX ", idtmed[503], par, 3); // Hony
329   gMC->Gspos("FEG2", 0, "FLT2", 0., ycoor, 0., 0, "ONLY");
330   gMC->Gsvolu("FEG3", "BOX ", idtmed[503], par, 3); // Hony
331   gMC->Gspos("FEG3", 0, "FLT3", 0., ycoor, 0., 0, "ONLY");}
332
333 //_____________________________________________________________________________
334 void AliTOFv5::DrawModule()
335 {
336   //
337   // Draw a shaded view of the Time Of Flight version 1
338   //
339   // Set everything unseen
340   gMC->Gsatt("*", "seen", -1);
341   // 
342   // Set ALIC mother transparent
343   gMC->Gsatt("ALIC","SEEN",0);
344   //
345   // Set the volumes visible
346   gMC->Gsatt("ALIC","SEEN",0);
347   gMC->Gsatt("FBAR","SEEN",1);
348   gMC->Gsatt("FTO1","SEEN",1);
349   gMC->Gsatt("FTO2","SEEN",1);
350   gMC->Gsatt("FTO3","SEEN",1);
351   gMC->Gsatt("FBT1","SEEN",1);
352   gMC->Gsatt("FBT2","SEEN",1);
353   gMC->Gsatt("FBT3","SEEN",1);
354   gMC->Gsatt("FDT1","SEEN",1);
355   gMC->Gsatt("FDT2","SEEN",1);
356   gMC->Gsatt("FDT3","SEEN",1);
357   gMC->Gsatt("FLT1","SEEN",1);
358   gMC->Gsatt("FLT2","SEEN",1);
359   gMC->Gsatt("FLT3","SEEN",1);
360   gMC->Gsatt("FPL1","SEEN",1);
361   gMC->Gsatt("FPL2","SEEN",1);
362   gMC->Gsatt("FPL3","SEEN",1);
363   gMC->Gsatt("FLD1","SEEN",1);
364   gMC->Gsatt("FLD2","SEEN",1);
365   gMC->Gsatt("FLD3","SEEN",1);
366   gMC->Gsatt("FLZ1","SEEN",1);
367   gMC->Gsatt("FLZ2","SEEN",1);
368   gMC->Gsatt("FLZ3","SEEN",1);
369   gMC->Gsatt("FLX1","SEEN",1);
370   gMC->Gsatt("FLX2","SEEN",1);
371   gMC->Gsatt("FLX3","SEEN",1);
372   gMC->Gsatt("FPA0","SEEN",1);
373   //
374   gMC->Gdopt("hide", "on");
375   gMC->Gdopt("shad", "on");
376   gMC->Gsatt("*", "fill", 7);
377   gMC->SetClipBox(".");
378   gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
379   gMC->DefaultRange();
380   gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
381   gMC->Gdhead(1111, "Time Of Flight");
382   gMC->Gdman(18, 4, "MAN");
383   gMC->Gdopt("hide","off");
384 }
385
386 //_____________________________________________________________________________
387 void AliTOFv5::CreateMaterials()
388 {
389   //
390   // Define materials for the Time Of Flight
391   //
392   AliTOF::CreateMaterials();
393 }
394  
395 //_____________________________________________________________________________
396 void AliTOFv5::Init()
397 {
398   //
399   // Initialise the detector after the geometry has been defined
400   //
401   printf("**************************************"
402          "  TOF  "
403          "**************************************\n");
404   printf("\n     Version 5 of TOF initialing, "
405          "with openings for PHOS and RICH in symmetric frame\n\n");
406
407   AliTOF::Init();
408
409   fIdFTO2=gMC->VolId("FTO2");
410   fIdFTO3=gMC->VolId("FTO3");
411   fIdFLT1=gMC->VolId("FLT1");
412   fIdFLT2=gMC->VolId("FLT2");
413   fIdFLT3=gMC->VolId("FLT3");
414
415   printf("**************************************"
416          "  TOF  "
417          "**************************************\n");
418 }
419  
420 //_____________________________________________________________________________
421 void AliTOFv5::StepManager()
422 {
423   //
424   // Procedure called at each step in the Time Of Flight
425   //
426   TLorentzVector mom, pos;
427   Float_t hits[8],rho,z,phi,phid;
428   Int_t sector, plate, pad_x, pad_z;
429   Int_t copy, pad_x_id, pad_z_id, i;
430   Int_t *idtmed = fIdtmed->GetArray()-499;
431   if(gMC->GetMedium()==idtmed[514-1] && 
432      gMC->IsTrackEntering() && gMC->TrackCharge()
433      && gMC->CurrentVolID(copy)==fIdSens) {
434     TClonesArray &lhits = *fHits;
435
436
437     //_________getting information about hit volumes_____________
438     
439     pad_z_id=gMC->CurrentVolOffID(3,copy);
440     pad_z=copy;  
441     
442     pad_x_id=gMC->CurrentVolOffID(2,copy);
443     pad_x=copy;  
444     
445    gMC->TrackPosition(pos);
446    gMC->TrackMomentum(mom);
447
448    rho = sqrt(pos[0]*pos[0]+pos[1]*pos[1]);
449    phi = TMath::ACos(pos[0]/rho);
450    Float_t as = TMath::ASin(pos[1]/rho);
451    if (as<0) phi = 2*3.141592654-phi;
452
453    z = pos[2];
454    
455    if (z<=62. && z>=-62)  plate = 3;
456    if (z<=216. && z>62.)   plate = 4;
457    if (z>=-216. && z<-62.) plate = 2;
458    if (z>216.)  plate = 5;
459    if (z<-216.) plate = 1;
460
461    phid = phi*kRaddeg;
462    sector = Int_t (phid/20.);
463    sector++;
464
465     Double_t ptot=mom.Rho();
466     Double_t norm=1/ptot;
467     for(i=0;i<3;++i) {
468       hits[i]=pos[i];
469       hits[i+3]=mom[i]*norm;
470     }
471     hits[6]=ptot;
472     hits[7]=pos[3];
473     new(lhits[fNhits++]) AliTOFhit(fIshunt,gAlice->CurrentTrack(),sector,plate,pad_x,pad_z,hits);
474   }
475 }