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