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