Minor changes (R.Barbera)
[u/mrichter/AliRoot.git] / TOF / AliTOFv4.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$
b94fa26c 18Revision 1.8 2000/12/04 08:48:20 alibrary
19Fixing problems in the HEAD
20
0cc62300 21Revision 1.7 2000/10/02 21:28:17 fca
22Removal of useless dependecies via forward declarations
23
94de3818 24Revision 1.6 2000/05/10 16:52:18 vicinanz
25New TOF version with holes for PHOS/RICH
26
2cef3cb2 27Revision 1.4.2.1 2000/05/10 09:37:16 vicinanz
28New version with Holes for PHOS/RICH
29
30Revision 1.14 1999/11/05 22:39:06 fca
da39da0c 31New hits structure
32
2cef3cb2 33Revision 1.13 1999/11/02 11:26:39 fca
34added stdlib.h for exit
35
36Revision 1.12 1999/11/01 20:41:57 fca
826b71ec 37Added protections against using the wrong version of FRAME
38
2cef3cb2 39Revision 1.11 1999/10/22 08:04:14 fca
40Correct improper use of negative parameters
41
42Revision 1.10 1999/10/16 19:30:06 fca
ab76897d 43Corrected Rotation Matrix and CVS log
44
2cef3cb2 45Revision 1.9 1999/10/15 15:35:20 fca
0172a4d9 46New version for frame1099 with and without holes
937fe4a4 47
2cef3cb2 48Revision 1.8 1999/09/29 09:24:33 fca
49Introduction of the Copyright and cvs Log
50
937fe4a4 51*/
52
53///////////////////////////////////////////////////////////////////////////////
54// //
2cef3cb2 55// Time Of Flight: design of C.Williams
56//
937fe4a4 57// This class contains the functions for version 1 of the Time Of Flight //
58// detector. //
59//
2cef3cb2 60// VERSION WITH 5 MODULES AND TILTED STRIPS
937fe4a4 61//
2cef3cb2 62// FULL COVERAGE VERSION
937fe4a4 63//
64// Authors:
65//
66// Alessio Seganti
2cef3cb2 67// Domenico Vicinanza
937fe4a4 68//
69// University of Salerno - Italy
70//
b94fa26c 71// Fabrizio Pierella
72// University of Bologna - Italy
73//
937fe4a4 74//
75//Begin_Html
76/*
77<img src="picts/AliTOFv4Class.gif">
78*/
79//End_Html
80// //
81///////////////////////////////////////////////////////////////////////////////
82
826b71ec 83#include <iostream.h>
ab76897d 84#include <stdlib.h>
85
937fe4a4 86#include "AliTOFv4.h"
2cef3cb2 87#include "TBRIK.h"
94de3818 88#include "TGeometry.h"
2cef3cb2 89#include "TNode.h"
0cc62300 90#include <TLorentzVector.h>
2cef3cb2 91#include "TObject.h"
937fe4a4 92#include "AliRun.h"
94de3818 93#include "AliMC.h"
937fe4a4 94#include "AliConst.h"
2cef3cb2 95
937fe4a4 96
97ClassImp(AliTOFv4)
98
99//_____________________________________________________________________________
100AliTOFv4::AliTOFv4()
101{
102 //
103 // Default constructor
104 //
105}
106
107//_____________________________________________________________________________
108AliTOFv4::AliTOFv4(const char *name, const char *title)
2cef3cb2 109 : AliTOF(name,title)
937fe4a4 110{
111 //
112 // Standard constructor
113 //
da39da0c 114 //
115 // Check that FRAME is there otherwise we have no place where to
116 // put TOF
b94fa26c 117 AliModule* frame=gAlice->GetModule("FRAME");
118 if(!frame) {
da39da0c 119 Error("Ctor","TOF needs FRAME to be present\n");
120 exit(1);
2cef3cb2 121 } else
b94fa26c 122 if(frame->IsVersion()!=1) {
2cef3cb2 123 Error("Ctor","FRAME version 1 needed with this version of TOF\n");
da39da0c 124 exit(1);
125 }
2cef3cb2 126
127}
128
b94fa26c 129//____________________________________________________________________________
130AliTOFv4::~AliTOFv4()
131{
132 // destructor
133
134 if ( fHits) {
135 fHits->Delete() ;
136 delete fHits ;
137 fHits = 0 ;
138 }
139/*
140 if ( fSDigits) {
141 fSDigits->Delete() ;
142 delete fSDigits ;
143 fSDigits = 0 ;
144 }
145*/
146 if ( fDigits) {
147 fDigits->Delete() ;
148 delete fDigits ;
149 fDigits = 0 ;
150 }
151
152}
153
2cef3cb2 154//_____________________________________________________________________________
155void AliTOFv4::BuildGeometry()
156{
157 //
158 // Build TOF ROOT geometry for the ALICE event display
159 //
b94fa26c 160 TNode *node, *top;
2cef3cb2 161 const int kColorTOF = 27;
162
163 // Find top TNODE
b94fa26c 164 top = gAlice->GetGeometry()->GetNode("alice");
da39da0c 165
2cef3cb2 166 // Position the different copies
b94fa26c 167 const Float_t krTof =(fRmax+fRmin)/2;
168 const Float_t khTof = fRmax-fRmin;
169 const Int_t kNTof = fNTof;
2cef3cb2 170 const Float_t kPi = TMath::Pi();
b94fa26c 171 const Float_t kangle = 2*kPi/kNTof;
2cef3cb2 172 Float_t ang;
173
174 // Define TOF basic volume
175
b94fa26c 176 char nodeName0[7], nodeName1[7], nodeName2[7];
177 char nodeName3[7], nodeName4[7], rotMatNum[7];
2cef3cb2 178
179 new TBRIK("S_TOF_C","TOF box","void",
b94fa26c 180 120*0.5,khTof*0.5,fZlenC*0.5);
2cef3cb2 181 new TBRIK("S_TOF_B","TOF box","void",
b94fa26c 182 120*0.5,khTof*0.5,fZlenB*0.5);
2cef3cb2 183 new TBRIK("S_TOF_A","TOF box","void",
b94fa26c 184 120*0.5,khTof*0.5,fZlenA*0.5);
2cef3cb2 185
b94fa26c 186 for (Int_t nodeNum=1;nodeNum<19;nodeNum++){
2cef3cb2 187
b94fa26c 188 if (nodeNum<10) {
189 sprintf(rotMatNum,"rot50%i",nodeNum);
190 sprintf(nodeName0,"FTO00%i",nodeNum);
191 sprintf(nodeName1,"FTO10%i",nodeNum);
192 sprintf(nodeName2,"FTO20%i",nodeNum);
193 sprintf(nodeName3,"FTO30%i",nodeNum);
194 sprintf(nodeName4,"FTO40%i",nodeNum);
2cef3cb2 195 }
b94fa26c 196 if (nodeNum>9) {
197 sprintf(rotMatNum,"rot5%i",nodeNum);
198 sprintf(nodeName0,"FTO0%i",nodeNum);
199 sprintf(nodeName1,"FTO1%i",nodeNum);
200 sprintf(nodeName2,"FTO2%i",nodeNum);
201 sprintf(nodeName3,"FTO3%i",nodeNum);
202 sprintf(nodeName4,"FTO4%i",nodeNum);
2cef3cb2 203 }
204
b94fa26c 205 new TRotMatrix(rotMatNum,rotMatNum,90,-20*nodeNum,90,90-20*nodeNum,0,0);
206 ang = (4.5-nodeNum) * kangle;
207
208 top->cd();
209 node = new TNode(nodeName0,nodeName0,"S_TOF_C",krTof*TMath::Cos(ang),krTof*TMath::Sin(ang),299.15,rotMatNum);
210 node->SetLineColor(kColorTOF);
211 fNodes->Add(node);
212
213 top->cd();
214 node = new TNode(nodeName1,nodeName1,"S_TOF_C",krTof*TMath::Cos(ang),krTof*TMath::Sin(ang),-299.15,rotMatNum);
215 node->SetLineColor(kColorTOF);
216 fNodes->Add(node);
217
218 top->cd();
219 node = new TNode(nodeName2,nodeName2,"S_TOF_B",krTof*TMath::Cos(ang),krTof*TMath::Sin(ang),146.45,rotMatNum);
220 node->SetLineColor(kColorTOF);
221 fNodes->Add(node);
222
223 top->cd();
224 node = new TNode(nodeName3,nodeName3,"S_TOF_B",krTof*TMath::Cos(ang),krTof*TMath::Sin(ang),-146.45,rotMatNum);
225 node->SetLineColor(kColorTOF);
226 fNodes->Add(node);
227
228 top->cd();
229 node = new TNode(nodeName4,nodeName4,"S_TOF_A",krTof*TMath::Cos(ang),krTof*TMath::Sin(ang),0.,rotMatNum);
230 node->SetLineColor(kColorTOF);
231 fNodes->Add(node);
232 } // end loop on nodeNum
937fe4a4 233}
2cef3cb2 234
235
937fe4a4 236
237//_____________________________________________________________________________
238void AliTOFv4::CreateGeometry()
239{
240 //
241 // Create geometry for Time Of Flight version 0
242 //
243 //Begin_Html
244 /*
245 <img src="picts/AliTOFv4.gif">
246 */
247 //End_Html
248 //
249 // Creates common geometry
250 //
251 AliTOF::CreateGeometry();
252}
253
254//_____________________________________________________________________________
2cef3cb2 255void AliTOFv4::TOFpc(Float_t xtof, Float_t ytof, Float_t zlenC,
256 Float_t zlenB, Float_t zlenA, Float_t ztof0)
937fe4a4 257{
258 //
259 // Definition of the Time Of Fligh Resistive Plate Chambers
260 // xFLT, yFLT, zFLT - sizes of TOF modules (large)
261
937fe4a4 262 Float_t ycoor, zcoor;
b94fa26c 263 Float_t par[3];
2cef3cb2 264 Int_t *idtmed = fIdtmed->GetArray()-499;
265 Int_t idrotm[100];
266 Int_t nrot = 0;
267 Float_t hTof = fRmax-fRmin;
937fe4a4 268
b94fa26c 269 Float_t radius = fRmin+2.;//cm
937fe4a4 270
2cef3cb2 271 par[0] = xtof * 0.5;
272 par[1] = ytof * 0.5;
273 par[2] = zlenC * 0.5;
274 gMC->Gsvolu("FTOC", "BOX ", idtmed[506], par, 3);
275 par[2] = zlenB * 0.5;
276 gMC->Gsvolu("FTOB", "BOX ", idtmed[506], par, 3);
277 par[2] = zlenA * 0.5;
278 gMC->Gsvolu("FTOA", "BOX ", idtmed[506], par, 3);
937fe4a4 279
280
281// Positioning of modules
282
2cef3cb2 283 Float_t zcor1 = ztof0 - zlenC*0.5;
284 Float_t zcor2 = ztof0 - zlenC - zlenB*0.5;
937fe4a4 285 Float_t zcor3 = 0.;
286
2cef3cb2 287 AliMatrix(idrotm[0], 90., 0., 0., 0., 90,-90.);
288 AliMatrix(idrotm[1], 90.,180., 0., 0., 90, 90.);
289 gMC->Gspos("FTOC", 1, "BTO1", 0, zcor1, 0, idrotm[0], "ONLY");
290 gMC->Gspos("FTOC", 2, "BTO1", 0, -zcor1, 0, idrotm[1], "ONLY");
291 gMC->Gspos("FTOC", 1, "BTO2", 0, zcor1, 0, idrotm[0], "ONLY");
292 gMC->Gspos("FTOC", 2, "BTO2", 0, -zcor1, 0, idrotm[1], "ONLY");
293 gMC->Gspos("FTOC", 1, "BTO3", 0, zcor1, 0, idrotm[0], "ONLY");
294 gMC->Gspos("FTOC", 2, "BTO3", 0, -zcor1, 0, idrotm[1], "ONLY");
295
296 gMC->Gspos("FTOB", 1, "BTO1", 0, zcor2, 0, idrotm[0], "ONLY");
297 gMC->Gspos("FTOB", 2, "BTO1", 0, -zcor2, 0, idrotm[1], "ONLY");
298 gMC->Gspos("FTOB", 1, "BTO2", 0, zcor2, 0, idrotm[0], "ONLY");
299 gMC->Gspos("FTOB", 2, "BTO2", 0, -zcor2, 0, idrotm[1], "ONLY");
300 gMC->Gspos("FTOB", 1, "BTO3", 0, zcor2, 0, idrotm[0], "ONLY");
301 gMC->Gspos("FTOB", 2, "BTO3", 0, -zcor2, 0, idrotm[1], "ONLY");
302
303 gMC->Gspos("FTOA", 0, "BTO1", 0, zcor3, 0, idrotm[0], "ONLY");
304 gMC->Gspos("FTOA", 0, "BTO2", 0, zcor3, 0, idrotm[0], "ONLY");
305 gMC->Gspos("FTOA", 0, "BTO3", 0, zcor3, 0, idrotm[0], "ONLY");
306
307 Float_t db = 0.5;//cm
308 Float_t xFLT, xFST, yFLT, zFLTA, zFLTB, zFLTC;
309
310 xFLT = fStripLn;
937fe4a4 311 yFLT = ytof;
2cef3cb2 312 zFLTA = zlenA;
313 zFLTB = zlenB;
314 zFLTC = zlenC;
937fe4a4 315
2cef3cb2 316 xFST = xFLT-fDeadBndX*2;//cm
937fe4a4 317
318// Sizes of MRPC pads
319
2cef3cb2 320 Float_t yPad = 0.505;//cm
321
b94fa26c 322// Large not sensitive volumes with Insensitive Freon
2cef3cb2 323 par[0] = xFLT*0.5;
324 par[1] = yFLT*0.5;
b94fa26c 325
2cef3cb2 326 cout <<"************************* TOF geometry **************************"<<endl;
b94fa26c 327
2cef3cb2 328 par[2] = (zFLTA *0.5);
b94fa26c 329 gMC->Gsvolu("FLTA", "BOX ", idtmed[512], par, 3); // Insensitive Freon
2cef3cb2 330 gMC->Gspos ("FLTA", 0, "FTOA", 0., 0., 0., 0, "ONLY");
937fe4a4 331
2cef3cb2 332 par[2] = (zFLTB * 0.5);
b94fa26c 333 gMC->Gsvolu("FLTB", "BOX ", idtmed[512], par, 3); // Insensitive Freon
2cef3cb2 334 gMC->Gspos ("FLTB", 0, "FTOB", 0., 0., 0., 0, "ONLY");
937fe4a4 335
b94fa26c 336 par[2] = (zFLTC * 0.5);
337 gMC->Gsvolu("FLTC", "BOX ", idtmed[512], par, 3); // Insensitive Freon
2cef3cb2 338 gMC->Gspos ("FLTC", 0, "FTOC", 0., 0., 0., 0, "ONLY");
b94fa26c 339
340////////// Layers of Aluminum before and after detector //////////
341////////// Aluminum Box for Modules (2.0 mm thickness) /////////
342////////// lateral walls not simulated
343 par[0] = xFLT*0.5;
2cef3cb2 344 par[1] = 0.1;//cm
937fe4a4 345 ycoor = -yFLT/2 + par[1];
b94fa26c 346 par[2] = (zFLTA *0.5);
347 gMC->Gsvolu("FALA", "BOX ", idtmed[508], par, 3); // Alluminium
348 gMC->Gspos ("FALA", 1, "FLTA", 0., ycoor, 0., 0, "ONLY");
349 gMC->Gspos ("FALA", 2, "FLTA", 0.,-ycoor, 0., 0, "ONLY");
350 par[2] = (zFLTB *0.5);
351 gMC->Gsvolu("FALB", "BOX ", idtmed[508], par, 3); // Alluminium
352 gMC->Gspos ("FALB", 1, "FLTB", 0., ycoor, 0., 0, "ONLY");
353 gMC->Gspos ("FALB", 2, "FLTB", 0.,-ycoor, 0., 0, "ONLY");
354 par[2] = (zFLTC *0.5);
355 gMC->Gsvolu("FALC", "BOX ", idtmed[508], par, 3); // Alluminium
356 gMC->Gspos ("FALC", 1, "FLTC", 0., ycoor, 0., 0, "ONLY");
357 gMC->Gspos ("FALC", 2, "FLTC", 0.,-ycoor, 0., 0, "ONLY");
358
937fe4a4 359///////////////// Detector itself //////////////////////
360
b94fa26c 361 const Float_t kdeadBound = fDeadBndZ; //cm non-sensitive between the pad edge
2cef3cb2 362 //and the boundary of the strip
b94fa26c 363 const Int_t knx = fNpadX; // number of pads along x
364 const Int_t knz = fNpadZ; // number of pads along z
365 const Float_t kspace = fSpace; //cm distance from the front plate of the box
937fe4a4 366
2cef3cb2 367 Float_t zSenStrip = fZpad*fNpadZ;//cm
b94fa26c 368 Float_t stripWidth = zSenStrip + 2*kdeadBound;
2cef3cb2 369
370 par[0] = xFLT*0.5;
371 par[1] = yPad*0.5;
b94fa26c 372 par[2] = stripWidth*0.5;
2cef3cb2 373
b94fa26c 374// new description for strip volume
375// -- all constants are expressed in cm
376// heigth of different layers
377 const Float_t khhony = 1. ; // heigth of HONY Layer
378 const Float_t khpcby = 0.15 ; // heigth of PCB Layer
379 const Float_t khmyly = 0.035 ; // heigth of MYLAR Layer
380 const Float_t khgraphy = 0.02 ; // heigth of GRAPHITE Layer
381 const Float_t khglasseiy = 0.32; // 2.2 Ext. Glass + 1. Semi Int. Glass (mm)
382 const Float_t khsensmy = 0.11 ; // heigth of Sensitive Freon Mixture
383 const Float_t kwsensmz = 2*3.5 ; // cm
384 const Float_t klsensmx = 48*2.5; // cm
385 const Float_t kwpadz = 3.5; // cm z dimension of the FPAD volume
386 const Float_t klpadx = 2.5; // cm x dimension of the FPAD volume
387
388 // heigth of the FSTR Volume (the strip volume)
389 const Float_t khstripy = 2*(khhony+khpcby+khmyly+khgraphy+khglasseiy)+khsensmy;
390 // width of the FSTR Volume (the strip volume)
391 const Float_t kwstripz = 10.;
392 // length of the FSTR Volume (the strip volume)
393 const Float_t klstripx = 122.;
394
395 Float_t parfp[3]={klstripx*0.5,khstripy*0.5,kwstripz*0.5};
396// coordinates of the strip center in the strip reference frame; used for positioning
397// internal strip volumes
398 Float_t posfp[3]={0.,0.,0.};
399
400 // FSTR volume definition and filling this volume with non sensitive Gas Mixture
401 gMC->Gsvolu("FSTR","BOX",idtmed[512],parfp,3);
402 //-- HONY Layer definition
403// parfp[0] = -1;
404 parfp[1] = khhony*0.5;
405// parfp[2] = -1;
406 gMC->Gsvolu("FHON","BOX",idtmed[503],parfp,3);
407 // positioning 2 HONY Layers on FSTR volume
408 posfp[1]=-khstripy*0.5+parfp[1];
409 gMC->Gspos("FHON",1,"FSTR",0., posfp[1],0.,0,"ONLY");
410 gMC->Gspos("FHON",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
411
412 //-- PCB Layer definition
413 parfp[1] = khpcby*0.5;
414 gMC->Gsvolu("FPCB","BOX",idtmed[504],parfp,3);
415 // positioning 2 PCB Layers on FSTR volume
416 posfp[1]=-khstripy*0.5+khhony+parfp[1];
417 gMC->Gspos("FPCB",1,"FSTR",0., posfp[1],0.,0,"ONLY");
418 gMC->Gspos("FPCB",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
419
420 //-- MYLAR Layer definition
421 parfp[1] = khmyly*0.5;
422 gMC->Gsvolu("FMYL","BOX",idtmed[511],parfp,3);
423 // positioning 2 MYLAR Layers on FSTR volume
424 posfp[1] = -khstripy*0.5+khhony+khpcby+parfp[1];
425 gMC->Gspos("FMYL",1,"FSTR",0., posfp[1],0.,0,"ONLY");
426 gMC->Gspos("FMYL",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
427
428 //-- Graphite Layer definition
429 parfp[1] = khgraphy*0.5;
430 gMC->Gsvolu("FGRP","BOX",idtmed[502],parfp,3);
431 // positioning 2 Graphite Layers on FSTR volume
432 posfp[1] = -khstripy*0.5+khhony+khpcby+khmyly+parfp[1];
433 gMC->Gspos("FGRP",1,"FSTR",0., posfp[1],0.,0,"ONLY");
434 gMC->Gspos("FGRP",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
435
436 //-- Glass (EXT. +Semi INT.) Layer definition
437 parfp[1] = khglasseiy*0.5;
438 gMC->Gsvolu("FGLA","BOX",idtmed[514],parfp,3);
439 // positioning 2 Glass Layers on FSTR volume
440 posfp[1] = -khstripy*0.5+khhony+khpcby+khmyly+khgraphy+parfp[1];
441 gMC->Gspos("FGLA",1,"FSTR",0., posfp[1],0.,0,"ONLY");
442 gMC->Gspos("FGLA",2,"FSTR",0.,-posfp[1],0.,0,"ONLY");
443
444 //-- Sensitive Mixture Layer definition
445 parfp[0] = klsensmx*0.5;
446 parfp[1] = khsensmy*0.5;
447 parfp[2] = kwsensmz*0.5;
448 gMC->Gsvolu("FSEN","BOX",idtmed[513],parfp,3);
449 // positioning the sensitive gas Layer on FSTR volume
450 gMC->Gspos("FSEN",0,"FSTR",0.,0.,0.,0,"ONLY");
451
452 // dividing FSEN along z in knz=2 and along x in knx=48
453 gMC->Gsdvn("FSEZ","FSEN",knz,3);
454 gMC->Gsdvn("FSEX","FSEZ",knx,1);
455
456 // FPAD volume definition
457 parfp[0] = klpadx*0.5;
458 parfp[1] = khsensmy*0.5;
459 parfp[2] = kwpadz*0.5;
460 gMC->Gsvolu("FPAD","BOX",idtmed[513],parfp,3);
461 // positioning the FPAD volumes on previous divisions
462 gMC->Gspos("FPAD",0,"FSEX",0.,0.,0.,0,"ONLY");
2cef3cb2 463
2cef3cb2 464//// Positioning the Strips (FSTR) in the FLT volumes /////
937fe4a4 465
2cef3cb2 466 // Plate A (Central)
467
468 Float_t t = zFLTC+zFLTB+zFLTA*0.5+ 2*db;//Half Width of Barrel
469
b94fa26c 470 Float_t gap = fGapA; //cm distance between the strip axis
2cef3cb2 471 Float_t zpos = 0;
472 Float_t ang = 0;
473 Int_t i=1,j=1;
474 nrot = 0;
475 zcoor = 0;
b94fa26c 476 ycoor = -14.5 + kspace ; //2 cm over front plate
2cef3cb2 477
478 AliMatrix (idrotm[0], 90., 0.,90.,90.,0., 90.);
479 gMC->Gspos("FSTR",j,"FLTA",0.,ycoor, 0.,idrotm[0],"ONLY");
480
481 printf("%f, St. %2i, Pl.3 ",ang*kRaddeg,i);
482 printf("y = %f, z = %f, zpos = %f \n",ycoor,zcoor,zpos);
483
484 zcoor -= zSenStrip;
485 j++;
b94fa26c 486 Int_t upDown = -1; // upDown=-1 -> Upper strip
487 // upDown=+1 -> Lower strip
2cef3cb2 488 do{
b94fa26c 489 ang = atan(zcoor/radius);
2cef3cb2 490 ang *= kRaddeg;
491 AliMatrix (idrotm[nrot], 90., 0.,90.-ang,90.,-ang, 90.);
492 AliMatrix (idrotm[nrot+1],90.,180.,90.+ang,90., ang, 90.);
493 ang /= kRaddeg;
b94fa26c 494 ycoor = -14.5+ kspace; //2 cm over front plate
495 ycoor += (1-(upDown+1)/2)*gap;
2cef3cb2 496 gMC->Gspos("FSTR",j ,"FLTA",0.,ycoor, zcoor,idrotm[nrot], "ONLY");
497 gMC->Gspos("FSTR",j+1,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
498
499 printf("%f, St. %2i, Pl.3 ",ang*kRaddeg,i);
500 printf("y = %f, z = %f, zpos = %f \n",ycoor,zcoor,zpos);
501
502 j += 2;
b94fa26c 503 upDown*= -1; // Alternate strips
2cef3cb2 504 zcoor = zcoor-(zSenStrip/2)/TMath::Cos(ang)-
b94fa26c 505 upDown*gap*TMath::Tan(ang)-
2cef3cb2 506 (zSenStrip/2)/TMath::Cos(ang);
b94fa26c 507 } while (zcoor-(stripWidth/2)*TMath::Cos(ang)>-t+zFLTC+zFLTB+db*2);
2cef3cb2 508
509 zcoor = zcoor+(zSenStrip/2)/TMath::Cos(ang)+
b94fa26c 510 upDown*gap*TMath::Tan(ang)+
2cef3cb2 511 (zSenStrip/2)/TMath::Cos(ang);
512
b94fa26c 513 gap = fGapB;
2cef3cb2 514 zcoor = zcoor-(zSenStrip/2)/TMath::Cos(ang)-
b94fa26c 515 upDown*gap*TMath::Tan(ang)-
2cef3cb2 516 (zSenStrip/2)/TMath::Cos(ang);
517
b94fa26c 518 ang = atan(zcoor/radius);
2cef3cb2 519 ang *= kRaddeg;
520 AliMatrix (idrotm[nrot], 90., 0.,90.-ang,90.,-ang, 90.);
521 AliMatrix (idrotm[nrot+1],90.,180.,90.+ang,90., ang, 90.);
522 ang /= kRaddeg;
523
b94fa26c 524 ycoor = -14.5+ kspace; //2 cm over front plate
525 ycoor += (1-(upDown+1)/2)*gap;
2cef3cb2 526 gMC->Gspos("FSTR",j ,"FLTA",0.,ycoor, zcoor,idrotm[nrot], "ONLY");
527 gMC->Gspos("FSTR",j+1,"FLTA",0.,ycoor,-zcoor,idrotm[nrot+1],"ONLY");
528
529 printf("%f, St. %2i, Pl.3 ",ang*kRaddeg,i);
530 printf("y = %f, z = %f, zpos = %f \n",ycoor,zcoor,zpos);
531
b94fa26c 532 ycoor = -hTof/2.+ kspace;//2 cm over front plate
2cef3cb2 533
534 // Plate B
535
536 nrot = 0;
537 i=1;
b94fa26c 538 upDown = 1;
539 Float_t deadRegion = 1.0;//cm
937fe4a4 540
2cef3cb2 541 zpos = zcoor - (zSenStrip/2)/TMath::Cos(ang)-
b94fa26c 542 upDown*gap*TMath::Tan(ang)-
2cef3cb2 543 (zSenStrip/2)/TMath::Cos(ang)-
b94fa26c 544 deadRegion/TMath::Cos(ang);
2cef3cb2 545
b94fa26c 546 ang = atan(zpos/radius);
2cef3cb2 547 ang *= kRaddeg;
548 AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
549 ang /= kRaddeg;
b94fa26c 550 ycoor = -hTof*0.5+ kspace ; //2 cm over front plate
551 ycoor += (1-(upDown+1)/2)*gap;
2cef3cb2 552 zcoor = zpos+(zFLTA*0.5+zFLTB*0.5+db); // Moves to the system of the modulus FLTB
553 gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
554
555 printf("%f, St. %2i, Pl.4 ",ang*kRaddeg,i);
556 printf("y = %f, z = %f, zpos = %f \n",ycoor,zcoor,zpos);
557
558 i++;
b94fa26c 559 upDown*=-1;
2cef3cb2 560
561 do {
562 zpos = zpos - (zSenStrip/2)/TMath::Cos(ang)-
b94fa26c 563 upDown*gap*TMath::Tan(ang)-
2cef3cb2 564 (zSenStrip/2)/TMath::Cos(ang);
b94fa26c 565 ang = atan(zpos/radius);
2cef3cb2 566 ang *= kRaddeg;
567 AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
568 ang /= kRaddeg;
b94fa26c 569 ycoor = -hTof*0.5+ kspace ; //2 cm over front plate
570 ycoor += (1-(upDown+1)/2)*gap;
2cef3cb2 571 zcoor = zpos+(zFLTA*0.5+zFLTB*0.5+db); // Moves to the system of the modulus FLTB
572 gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
573
574 printf("%f, St. %2i, Pl.4 ",ang*kRaddeg,i);
575 printf("y = %f, z = %f, zpos = %f \n",ycoor,zcoor,zpos);
576
b94fa26c 577 upDown*=-1;
2cef3cb2 578 i++;
579 } while (TMath::Abs(ang*kRaddeg)<22.5);
580 //till we reach a tilting angle of 22.5 degrees
581
b94fa26c 582 ycoor = -hTof*0.5+ kspace ; //2 cm over front plate
2cef3cb2 583 zpos = zpos - zSenStrip/TMath::Cos(ang);
584
585 do {
b94fa26c 586 ang = atan(zpos/radius);
2cef3cb2 587 ang *= kRaddeg;
588 AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
589 ang /= kRaddeg;
590 zcoor = zpos+(zFLTB/2+zFLTA/2+db);
591 gMC->Gspos("FSTR",i, "FLTB", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
592 zpos = zpos - zSenStrip/TMath::Cos(ang);
593 printf("%f, St. %2i, Pl.4 ",ang*kRaddeg,i);
594 printf("y = %f, z = %f, zpos = %f \n",ycoor,zcoor,zpos);
595 i++;
596
b94fa26c 597 } while (zpos-stripWidth*0.5/TMath::Cos(ang)>-t+zFLTC+db);
2cef3cb2 598
599 // Plate C
600
601 zpos = zpos + zSenStrip/TMath::Cos(ang);
602
603 zpos = zpos - (zSenStrip/2)/TMath::Cos(ang)+
b94fa26c 604 gap*TMath::Tan(ang)-
2cef3cb2 605 (zSenStrip/2)/TMath::Cos(ang);
606
607 nrot = 0;
608 i=0;
b94fa26c 609 ycoor= -hTof*0.5+kspace+gap;
2cef3cb2 610
611 do {
612 i++;
b94fa26c 613 ang = atan(zpos/radius);
2cef3cb2 614 ang *= kRaddeg;
615 AliMatrix (idrotm[nrot], 90., 0., 90.-ang,90.,ang, 270.);
616 ang /= kRaddeg;
617 zcoor = zpos+(zFLTC*0.5+zFLTB+zFLTA*0.5+db*2);
618 gMC->Gspos("FSTR",i, "FLTC", 0., ycoor, zcoor,idrotm[nrot], "ONLY");
619
620 printf("%f, St. %2i, Pl.5 ",ang*kRaddeg,i);
621 printf("y = %f, z = %f, zpos = %f \n",ycoor,zcoor,zpos);
622
623 zpos = zpos - zSenStrip/TMath::Cos(ang);
b94fa26c 624 } while (zpos-stripWidth*TMath::Cos(ang)*0.5>-t);
2cef3cb2 625
2cef3cb2 626
b94fa26c 627////////// Layers after strips /////////////////
628// honeycomb (Polyethilene) Layer after (1.2cm)
2cef3cb2 629
b94fa26c 630 Float_t overSpace = fOverSpc;//cm
2cef3cb2 631
b94fa26c 632 par[0] = xFLT*0.5;
937fe4a4 633 par[1] = 0.6;
b94fa26c 634 par[2] = (zFLTA *0.5);
635 ycoor = -yFLT/2 + overSpace + par[1];
2cef3cb2 636 gMC->Gsvolu("FPEA", "BOX ", idtmed[503], par, 3); // Hony
637 gMC->Gspos ("FPEA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
b94fa26c 638 par[2] = (zFLTB *0.5);
2cef3cb2 639 gMC->Gsvolu("FPEB", "BOX ", idtmed[503], par, 3); // Hony
640 gMC->Gspos ("FPEB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
b94fa26c 641 par[2] = (zFLTC *0.5);
2cef3cb2 642 gMC->Gsvolu("FPEC", "BOX ", idtmed[503], par, 3); // Hony
643 gMC->Gspos ("FPEC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
937fe4a4 644
645// Electronics (Cu) after
2cef3cb2 646 ycoor += par[1];
b94fa26c 647 par[0] = xFLT*0.5;
2cef3cb2 648 par[1] = 1.43*0.05*0.5; // 5% of X0
b94fa26c 649 par[2] = (zFLTA *0.5);
2cef3cb2 650 ycoor += par[1];
651 gMC->Gsvolu("FECA", "BOX ", idtmed[501], par, 3); // Cu
652 gMC->Gspos ("FECA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
b94fa26c 653 par[2] = (zFLTB *0.5);
2cef3cb2 654 gMC->Gsvolu("FECB", "BOX ", idtmed[501], par, 3); // Cu
655 gMC->Gspos ("FECB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
b94fa26c 656 par[2] = (zFLTC *0.5);
2cef3cb2 657 gMC->Gsvolu("FECC", "BOX ", idtmed[501], par, 3); // Cu
658 gMC->Gspos ("FECC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
659
660// cooling WAter after
661 ycoor += par[1];
b94fa26c 662 par[0] = xFLT*0.5;
2cef3cb2 663 par[1] = 36.1*0.02*0.5; // 2% of X0
b94fa26c 664 par[2] = (zFLTA *0.5);
2cef3cb2 665 ycoor += par[1];
666 gMC->Gsvolu("FWAA", "BOX ", idtmed[515], par, 3); // Water
667 gMC->Gspos ("FWAA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
b94fa26c 668 par[2] = (zFLTB *0.5);
2cef3cb2 669 gMC->Gsvolu("FWAB", "BOX ", idtmed[515], par, 3); // Water
670 gMC->Gspos ("FWAB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
b94fa26c 671 par[2] = (zFLTC *0.5);
2cef3cb2 672 gMC->Gsvolu("FWAC", "BOX ", idtmed[515], par, 3); // Water
673 gMC->Gspos ("FWAC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
674
b94fa26c 675// frame of Air
676 ycoor += par[1];
677 par[0] = xFLT*0.5;
678 par[1] = (yFLT/2-ycoor-0.2)*0.5; // Aluminum layer considered (0.2 cm)
679 par[2] = (zFLTA *0.5);
680 ycoor += par[1];
681 gMC->Gsvolu("FAIA", "BOX ", idtmed[500], par, 3); // Air
682 gMC->Gspos ("FAIA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
683 par[2] = (zFLTB *0.5);
684 gMC->Gsvolu("FAIB", "BOX ", idtmed[500], par, 3); // Air
685 gMC->Gspos ("FAIB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
686 par[2] = (zFLTC *0.5);
687 gMC->Gsvolu("FAIC", "BOX ", idtmed[500], par, 3); // Air
688 gMC->Gspos ("FAIC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
689/* fp
2cef3cb2 690//Back Plate honycomb (2cm)
937fe4a4 691 par[0] = -1;
2cef3cb2 692 par[1] = 2 *0.5;
937fe4a4 693 par[2] = -1;
694 ycoor = yFLT/2 - par[1];
2cef3cb2 695 gMC->Gsvolu("FBPA", "BOX ", idtmed[503], par, 3); // Hony
696 gMC->Gspos ("FBPA", 0, "FLTA", 0., ycoor, 0., 0, "ONLY");
697 gMC->Gsvolu("FBPB", "BOX ", idtmed[503], par, 3); // Hony
698 gMC->Gspos ("FBPB", 0, "FLTB", 0., ycoor, 0., 0, "ONLY");
699 gMC->Gsvolu("FBPC", "BOX ", idtmed[503], par, 3); // Hony
700 gMC->Gspos ("FBPC", 0, "FLTC", 0., ycoor, 0., 0, "ONLY");
b94fa26c 701fp */
937fe4a4 702}
703
704//_____________________________________________________________________________
705void AliTOFv4::DrawModule()
706{
707 //
708 // Draw a shaded view of the Time Of Flight version 1
709 //
710 // Set everything unseen
711 gMC->Gsatt("*", "seen", -1);
712 //
713 // Set ALIC mother transparent
714 gMC->Gsatt("ALIC","SEEN",0);
715 //
716 // Set the volumes visible
717 gMC->Gsatt("ALIC","SEEN",0);
2cef3cb2 718
719 gMC->Gsatt("FTOA","SEEN",1);
720 gMC->Gsatt("FTOB","SEEN",1);
721 gMC->Gsatt("FTOC","SEEN",1);
722 gMC->Gsatt("FLTA","SEEN",1);
723 gMC->Gsatt("FLTB","SEEN",1);
724 gMC->Gsatt("FLTC","SEEN",1);
725 gMC->Gsatt("FPLA","SEEN",1);
726 gMC->Gsatt("FPLB","SEEN",1);
727 gMC->Gsatt("FPLC","SEEN",1);
728 gMC->Gsatt("FSTR","SEEN",1);
729 gMC->Gsatt("FPEA","SEEN",1);
730 gMC->Gsatt("FPEB","SEEN",1);
731 gMC->Gsatt("FPEC","SEEN",1);
732
733 gMC->Gsatt("FLZ1","SEEN",0);
734 gMC->Gsatt("FLZ2","SEEN",0);
735 gMC->Gsatt("FLZ3","SEEN",0);
736 gMC->Gsatt("FLX1","SEEN",0);
737 gMC->Gsatt("FLX2","SEEN",0);
738 gMC->Gsatt("FLX3","SEEN",0);
739 gMC->Gsatt("FPAD","SEEN",0);
740
937fe4a4 741 gMC->Gdopt("hide", "on");
742 gMC->Gdopt("shad", "on");
743 gMC->Gsatt("*", "fill", 7);
744 gMC->SetClipBox(".");
745 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
746 gMC->DefaultRange();
747 gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
748 gMC->Gdhead(1111, "Time Of Flight");
749 gMC->Gdman(18, 4, "MAN");
750 gMC->Gdopt("hide","off");
751}
752
753//_____________________________________________________________________________
754void AliTOFv4::CreateMaterials()
755{
756 //
757 // Define materials for the Time Of Flight
758 //
759 AliTOF::CreateMaterials();
760}
761
762//_____________________________________________________________________________
763void AliTOFv4::Init()
764{
765 //
766 // Initialise the detector after the geometry has been defined
767 //
ab76897d 768 printf("**************************************"
769 " TOF "
770 "**************************************\n");
2cef3cb2 771 printf("\n Version 4 of TOF initialing, "
772 "symmetric TOF - Full Coverage version\n");
ab76897d 773
937fe4a4 774 AliTOF::Init();
ab76897d 775
2cef3cb2 776 fIdFTOA = gMC->VolId("FTOA");
777 fIdFTOB = gMC->VolId("FTOB");
778 fIdFTOC = gMC->VolId("FTOC");
779 fIdFLTA = gMC->VolId("FLTA");
780 fIdFLTB = gMC->VolId("FLTB");
781 fIdFLTC = gMC->VolId("FLTC");
782
ab76897d 783 printf("**************************************"
784 " TOF "
785 "**************************************\n");
937fe4a4 786}
787
788//_____________________________________________________________________________
789void AliTOFv4::StepManager()
790{
791 //
792 // Procedure called at each step in the Time Of Flight
793 //
794 TLorentzVector mom, pos;
2cef3cb2 795 Float_t xm[3],pm[3],xpad[3],ppad[3];
796 Float_t hits[13],phi,phid,z;
797 Int_t vol[5];
b94fa26c 798 Int_t sector, plate, padx, padz, strip;
799 Int_t copy, padzid, padxid, stripid, i;
2cef3cb2 800 Int_t *idtmed = fIdtmed->GetArray()-499;
b94fa26c 801 Float_t incidenceAngle;
2cef3cb2 802
803 if(gMC->GetMedium()==idtmed[513] &&
937fe4a4 804 gMC->IsTrackEntering() && gMC->TrackCharge()
2cef3cb2 805 && gMC->CurrentVolID(copy)==fIdSens)
806 {
807 // getting information about hit volumes
826b71ec 808
b94fa26c 809 padzid=gMC->CurrentVolOffID(2,copy);
810 padz=copy;
826b71ec 811
b94fa26c 812 padxid=gMC->CurrentVolOffID(1,copy);
813 padx=copy;
826b71ec 814
b94fa26c 815 stripid=gMC->CurrentVolOffID(4,copy);
2cef3cb2 816 strip=copy;
817
818 gMC->TrackPosition(pos);
819 gMC->TrackMomentum(mom);
820
821// Double_t NormPos=1./pos.Rho();
b94fa26c 822 Double_t normMom=1./mom.Rho();
2cef3cb2 823
824// getting the cohordinates in pad ref system
825 xm[0] = (Float_t)pos.X();
826 xm[1] = (Float_t)pos.Y();
827 xm[2] = (Float_t)pos.Z();
828
b94fa26c 829 pm[0] = (Float_t)mom.X()*normMom;
830 pm[1] = (Float_t)mom.Y()*normMom;
831 pm[2] = (Float_t)mom.Z()*normMom;
2cef3cb2 832
833 gMC->Gmtod(xm,xpad,1);
834 gMC->Gmtod(pm,ppad,2);
835
b94fa26c 836 incidenceAngle = TMath::ACos(ppad[1])*kRaddeg;
2cef3cb2 837
838 z = pos[2];
839
840 plate = 0;
841 if (TMath::Abs(z) <= fZlenA*0.5) plate = 3;
842 if (z < (fZlenA*0.5+fZlenB) &&
843 z > fZlenA*0.5) plate = 4;
844 if (z >-(fZlenA*0.5+fZlenB) &&
845 z < -fZlenA*0.5) plate = 2;
846 if (z > (fZlenA*0.5+fZlenB)) plate = 5;
847 if (z <-(fZlenA*0.5+fZlenB)) plate = 1;
848
849 phi = pos.Phi();
850 phid = phi*kRaddeg+180.;
851 sector = Int_t (phid/20.);
852 sector++;
853
937fe4a4 854 for(i=0;i<3;++i) {
2cef3cb2 855 hits[i] = pos[i];
856 hits[i+3] = pm[i];
937fe4a4 857 }
2cef3cb2 858
859 hits[6] = mom.Rho();
860 hits[7] = pos[3];
861 hits[8] = xpad[0];
862 hits[9] = xpad[1];
863 hits[10]= xpad[2];
b94fa26c 864 hits[11]= incidenceAngle;
2cef3cb2 865 hits[12]= gMC->Edep();
866
867 vol[0]= sector;
868 vol[1]= plate;
869 vol[2]= strip;
b94fa26c 870 vol[3]= padx;
871 vol[4]= padz;
2cef3cb2 872
873 AddHit(gAlice->CurrentTrack(),vol, hits);
937fe4a4 874 }
875}