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