]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOF.cxx
- Correct initialisation of sRandom.
[u/mrichter/AliRoot.git] / TOF / AliTOF.cxx
CommitLineData
4c039060 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$
f8014e68 18Revision 1.40 2002/10/14 14:57:42 hristov
19Merging the VirtualMC branch to the main development branch (HEAD)
20
b9d0a01d 21Revision 1.35.4.2 2002/07/24 10:08:43 alibrary
22Updating VirtualMC
23
24Revision 1.39 2002/06/24 14:09:12 vicinanz
25review on materials and
26
43808676 27Revision 1.38 2002/06/13 08:43:46 vicinanz
28Merging added and test macro
29
8e72349e 30Revision 1.37 2002/05/03 07:34:19 vicinanz
31Updated SDigitizer; Added AliTOFanalyzeSDigits.C macro
32
55991c8b 33Revision 1.36 2002/04/19 14:40:51 vicinanz
34Updated SDigitizer
35
bfec09a6 36Revision 1.35 2002/03/21 13:52:53 vicinanz
37Minor changes to AliTOF constructor
38
00711221 39Revision 1.34 2002/02/20 13:41:38 hristov
40Default arguments set only in the header file
41
792995c1 42Revision 1.33 2002/02/19 10:39:38 vicinanz
43t0 classes added and material update (steel added)
44
0440c089 45Revision 1.31 2001/11/22 11:22:51 hristov
46Updated version of TOF digitization, N^2 problem solved (J.Chudoba)
47
5919c40c 48Revision 1.30 2001/10/21 18:30:39 hristov
49Several pointers were set to zero in the default constructors to avoid memory management problems
50
2685bf00 51Revision 1.29 2001/10/17 14:19:24 hristov
52delete replaced by delete []
53
3ff0c331 54Revision 1.28 2001/10/05 12:02:01 vicinanz
55Minor improvements on Merger and SDigitizer
56
766a7c4e 57Revision 1.27 2001/10/02 13:03:13 vicinanz
58Minor improvements on the code
59
f3de6e9e 60Revision 1.26 2001/09/27 10:39:20 vicinanz
61SDigitizer and Merger added
62
517b7f8f 63Revision 1.25 2001/09/07 08:37:40 hristov
64Pointers initialised to 0 in the default constructor
65
519351ab 66Revision 1.24 2001/09/05 16:31:00 hristov
67The deletion of TOF folders temporarily commented out
68
5839f074 69Revision 1.23 2001/08/29 12:59:01 vicinanz
70Minor changes to the Digitizer procedure
71
0efc163f 72Revision 1.22 2001/08/28 08:45:58 vicinanz
73TTask and TFolder structures implemented
74
68861244 75Revision 1.21 2001/05/16 14:57:24 alibrary
76New files for folders and Stack
77
9e1a0ddb 78Revision 1.20 2001/05/04 10:09:47 vicinanz
79Major upgrades to the strip structure
80
b94fa26c 81Revision 1.19 2001/03/12 17:47:25 hristov
82Changes needed on Sun with CC 5.0
83
5cf7bbad 84Revision 1.18 2001/01/26 19:57:42 hristov
85Major upgrade of AliRoot code
86
2ab0c725 87Revision 1.17 2000/10/19 09:58:14 vicinanz
88Updated Hits2Digit procedure
89
c2af3d73 90Revision 1.16 2000/10/02 21:28:17 fca
91Removal of useless dependecies via forward declarations
92
94de3818 93Revision 1.15 2000/05/18 14:33:01 vicinanz
94Modified to be full HP compliant
95
f5489efc 96Revision 1.14 2000/05/15 19:32:36 fca
97Add AddHitList !!
98
c8bd506f 99Revision 1.13 2000/05/10 16:52:18 vicinanz
100New TOF version with holes for PHOS/RICH
101
2cef3cb2 102Revision 1.11.2.1 2000/05/10 09:37:15 vicinanz
103New version with Holes for PHOS/RICH
104
1cedd08a 105Revision 1.11 1999/11/05 22:39:06 fca
106New hits structure
107
826b71ec 108Revision 1.10 1999/11/01 20:41:57 fca
109Added protections against using the wrong version of FRAME
110
ab76897d 111Revision 1.9 1999/10/15 15:35:19 fca
112New version for frame1099 with and without holes
113
937fe4a4 114Revision 1.9 1999/09/29 09:24:33 fca
115Introduction of the Copyright and cvs Log
4c039060 116
937fe4a4 117*/
68861244 118
fe4da5cc 119///////////////////////////////////////////////////////////////////////////////
120// //
68861244 121// Time Of Flight //
fe4da5cc 122// This class contains the basic functions for the Time Of Flight //
123// detector. Functions specific to one particular geometry are //
124// contained in the derived classes //
937fe4a4 125//
126// VERSIONE WITH 5 SYMMETRIC MODULES ALONG Z AXIS
127// ==============================================
128//
129// VERSION WITH HOLES FOR PHOS AND TRD IN SPACEFRAME WITH HOLES
130//
131// Volume sensibile : FPAD
132//
133//
134//
135// Begin_Html
fe4da5cc 136/*
1439f98e 137<img src="picts/AliTOFClass.gif">
fe4da5cc 138*/
139//End_Html
937fe4a4 140//
141//
fe4da5cc 142// //
143///////////////////////////////////////////////////////////////////////////////
144
f8014e68 145#include <Riostream.h>
146#include <Rstrstream.h>
147#include <Riostream.h>
517b7f8f 148#include <stdlib.h>
826b71ec 149
fe4da5cc 150#include "AliTOF.h"
68861244 151#include "AliTOFhit.h"
d599d913 152#include "AliTOFhitT0.h"
68861244 153#include "AliTOFdigit.h"
5919c40c 154#include "AliTOFSDigit.h"
68861244 155#include "AliTOFRawSector.h"
156#include "AliTOFRoc.h"
157#include "AliTOFRawDigit.h"
158
159#include "TROOT.h"
826b71ec 160#include "TBRIK.h"
2cef3cb2 161#include "TNode.h"
162#include "TObject.h"
0efc163f 163#include "TSystem.h"
94de3818 164#include "TTree.h"
2ab0c725 165#include "TFile.h"
68861244 166#include "TFolder.h"
167#include "TTask.h"
94de3818 168
fe4da5cc 169#include "AliRun.h"
94de3818 170#include "AliMC.h"
171#include "AliMagF.h"
fe4da5cc 172#include "AliConst.h"
2cef3cb2 173
fe4da5cc 174
175ClassImp(AliTOF)
176
177//_____________________________________________________________________________
178AliTOF::AliTOF()
179{
180 //
181 // Default constructor
182 //
00711221 183 fFGeom = 0x0;
184 fDTask = 0x0;
185 fReTask = 0x0;
fe4da5cc 186 fIshunt = 0;
68861244 187 fSDigits = 0 ;
8e72349e 188 fNSDigits = 0;
68861244 189 fDigits = 0 ;
00711221 190 fReconParticles = 0x0;
68861244 191 fName="TOF";
00711221 192 fMerger = 0x0;
517b7f8f 193/* fp
68861244 194 CreateTOFFolders();
517b7f8f 195*/
fe4da5cc 196}
197
198//_____________________________________________________________________________
792995c1 199AliTOF::AliTOF(const char *name, const char *title, Option_t *option)
fe4da5cc 200 : AliDetector(name,title)
201{
202 //
203 // AliTOF standard constructor
204 //
2cef3cb2 205 // Here are fixed some important parameters
206 //
207
68861244 208 // Initialization of hits, sdigits and digits array
d599d913 209 // added option for time zero analysis
210 if (strstr(option,"tzero")){
211 fHits = new TClonesArray("AliTOFhitT0", 1000);
212 cout << "tzero option requires AliTOFv4T0 as TOF version (check Your Config.C)" << endl;
213 }else{
214 fHits = new TClonesArray("AliTOFhit", 1000);
215 }
c8bd506f 216 gAlice->AddHitList(fHits);
2cef3cb2 217 fIshunt = 0;
5919c40c 218 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
517b7f8f 219 fDigits = new TClonesArray("AliTOFdigit", 1000);
8e72349e 220 fNSDigits = 0;
00711221 221
222 fFGeom = 0x0;
223 fDTask = 0x0;
224 fReTask = 0x0;
225 fReconParticles = 0x0;
226 fMerger = 0x0;
227
2cef3cb2 228 //
229 // Digitization parameters
fe4da5cc 230 //
2cef3cb2 231 // (Transfer Functions to be inserted here)
fe4da5cc 232 //
233 SetMarkerColor(7);
234 SetMarkerStyle(2);
235 SetMarkerSize(0.4);
2cef3cb2 236
237// General Geometrical Parameters
b94fa26c 238 fNTof = 18; // number of sectors
239 fRmax = 399.0;//cm
2cef3cb2 240 fRmin = 370.0;//cm
b94fa26c 241 fZlenC = 177.5;//cm length of module C
242 fZlenB = 141.0;//cm length of module B
243 fZlenA = 106.0;//cm length of module A
517b7f8f 244 fZtof = 371.5;//cm total semi-length of TOF detector
2cef3cb2 245
246// Strip Parameters
247 fStripLn = 122.0;//cm Strip Length
248 fSpace = 5.5;//cm Space Beetween the strip and the bottom of the plate
249 fDeadBndZ= 1.5;//cm Dead Boundaries of a Strip along Z direction (width)
250 fDeadBndX= 1.0;//cm Dead Boundaries of a Strip along X direction (length)
251 fXpad = 2.5;//cm X size of a pad
252 fZpad = 3.5;//cm Z size of a pad
253 fGapA = 4.; //cm Gap beetween tilted strip in A-type plate
254 fGapB = 6.; //cm Gap beetween tilted strip in B-type plate
255 fOverSpc = 15.3;//cm Space available for sensitive layers in radial direction
256 fNpadX = 48; // Number of pads in a strip along the X direction
257 fNpadZ = 2; // Number of pads in a strip along the Z direction
258 fPadXStr = fNpadX*fNpadZ; //Number of pads per strip
b94fa26c 259 fNStripA = 15; // number of strips in A type module
260 fNStripB = 19; // number of strips in B type module
261 fNStripC = 20; // number of strips in C type module
2cef3cb2 262
263// Physical performances
264 fTimeRes = 100.;//ps
265 fChrgRes = 100.;//pC
266
267// DAQ characteristics
68861244 268// cfr. TOF-TDR pag. 105 for Glossary
269// TARODA : TOF-ALICE Read Out and Data Acquisition system
270 fPadXSector = 8928; // number of pad per sector -with no holes-
271 // ((15+2*19+2*20)*(48*2))
272 fNRoc = 14; // number of Roc (Read Out Controller) (TARODA)
273 fNFec = 32; // number of Fec (Front-End electronic Card)
274 // (TARODA)
275 fNTdc = 32; // number of Tdc (Time to Digital Converter)
276 fNPadXRoc = (Int_t)fPadXSector/fNRoc; // number of pads for each ROC
517b7f8f 277 /* fp 25 Sept 2001
68861244 278 // Create TOF Folder Structure
517b7f8f 279 CreateTOFFolders();
280 */
68861244 281}
282
283//_____________________________________________________________________________
284void AliTOF::CreateTOFFolders()
285{
286 // create the ALICE TFolder
287 // create the ALICE TTasks
288 // create the ALICE main TFolder
289 // to be done by AliRun
290
291 TFolder * alice = new TFolder();
292 alice->SetNameTitle("FPAlice", "Alice Folder") ;
293 gROOT->GetListOfBrowsables()->Add(alice) ;
294
295 TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ;
296 // make it the owner of the objects that it contains
297 aliceF->SetOwner() ;
298 // geometry folder
299 TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ;
300 TFolder * aliceT = alice->AddFolder("tasks", "Alice tasks Folder") ;
301 // make it the owner of the objects that it contains
302 aliceT->SetOwner() ;
303
304 TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ;
305 aliceT->Add(aliceDi);
306
307 TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
308 aliceT->Add(aliceRe);
309
310 char * tempo = new char[80] ;
311
312 // creates the TOF Digitizer and adds it to alice main (S)Digitizer task
313 sprintf(tempo, "%sDigitizers container",GetName() ) ;
314 fDTask = new TTask(GetName(), tempo);
315 aliceDi->Add(fDTask) ;
316
317 // creates the TOF reconstructioner and adds it to alice main Reconstructioner task
318 sprintf(tempo, "%sReconstructioner container",GetName() ) ;
319 fReTask = new TTask(GetName(), tempo);
320 aliceRe->Add(fReTask) ;
321
3ff0c331 322 delete [] tempo ;
68861244 323
324 // creates the TOF geometry folder
325 geomF->AddFolder("TOF", "Geometry for TOF") ;
326}
327
328//_____________________________________________________________________________
329AliTOF::~AliTOF()
330{
517b7f8f 331 // dtor:
332 // it remove also the alice folder
68861244 333 // and task that TOF creates instead of AliRun
5839f074 334 /* PH Temporarily commented because of problems
68861244 335 TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ;
336 delete alice;
337 alice = 0;
5839f074 338 */
517b7f8f 339 if (fHits)
340 {
341 fHits->Delete ();
342 delete fHits;
343 fHits = 0;
344 }
345 if (fDigits)
346 {
347 fDigits->Delete ();
348 delete fDigits;
349 fDigits = 0;
350 }
351 if (fSDigits)
352 {
353 fSDigits->Delete ();
354 delete fSDigits;
355 fSDigits = 0;
356 }
357 if (fReconParticles)
358 {
359 fReconParticles->Delete ();
360 delete fReconParticles;
361 fReconParticles = 0;
362 }
363
fe4da5cc 364}
365
366//_____________________________________________________________________________
2cef3cb2 367void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits)
fe4da5cc 368{
369 //
370 // Add a TOF hit
68861244 371 // new with placement used
fe4da5cc 372 //
373 TClonesArray &lhits = *fHits;
2cef3cb2 374 new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits);
fe4da5cc 375}
d599d913 376
377//_____________________________________________________________________________
378void AliTOF::AddT0Hit(Int_t track, Int_t *vol, Float_t *hits)
379{
380 //
381 // Add a TOF hit
382 // new with placement used
383 //
384 TClonesArray &lhits = *fHits;
385 new(lhits[fNhits++]) AliTOFhitT0(fIshunt, track, vol, hits);
386}
387
fe4da5cc 388//_____________________________________________________________________________
2cef3cb2 389void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
fe4da5cc 390{
391 //
2cef3cb2 392 // Add a TOF digit
68861244 393 // new with placement used
2cef3cb2 394 //
395 TClonesArray &ldigits = *fDigits;
396 new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits);
fe4da5cc 397}
398
517b7f8f 399//___________________________________________
5919c40c 400void AliTOF::AddSDigit(Int_t tracknum, Int_t *vol, Float_t *digits)
517b7f8f 401{
402
403//
404// Add a TOF sdigit
405//
406
407 TClonesArray &lSDigits = *fSDigits;
5919c40c 408 new(lSDigits[fNSDigits++]) AliTOFSDigit(tracknum, vol, digits);
517b7f8f 409}
410
411//_____________________________________________________________________________
412void AliTOF::SetTreeAddress ()
413{
414 // Set branch address for the Hits and Digits Tree.
415 char branchname[30];
416 AliDetector::SetTreeAddress ();
417
418 TBranch *branch;
419 TTree *treeD = gAlice->TreeD ();
420
421
422 if (treeD)
423 {
424 if (fDigits)
425 {
426 branch = treeD->GetBranch (branchname);
427 if (branch)
428 branch->SetAddress (&fDigits);
429 }
430
431 }
5919c40c 432// if (fSDigits)
517b7f8f 433 // fSDigits->Clear ();
434
435 if (gAlice->TreeS () && fSDigits)
436 {
437 branch = gAlice->TreeS ()->GetBranch ("TOF");
438 if (branch)
439 branch->SetAddress (&fSDigits);
440 }
441
442 if (gAlice->TreeR() && fReconParticles)
443 {
444 branch = gAlice->TreeR()->GetBranch("TOF");
445 if (branch) branch->SetAddress(&fReconParticles) ;
446 }
447}
2cef3cb2 448
fe4da5cc 449//_____________________________________________________________________________
450void AliTOF::CreateGeometry()
451{
452 //
3fe3a833 453 // Common geometry code
fe4da5cc 454 //
455 //Begin_Html
456 /*
1439f98e 457 <img src="picts/AliTOFv23.gif">
fe4da5cc 458 */
459 //End_Html
460 //
fe4da5cc 461 const Double_t kPi=TMath::Pi();
2cef3cb2 462 const Double_t kDegrad=kPi/180.;
fe4da5cc 463 //
b94fa26c 464 Float_t xTof, yTof, wall;
937fe4a4 465
3fe3a833 466 // frame inbetween TOF modules
b94fa26c 467 wall = 4.;//cm
3fe3a833 468
2cef3cb2 469 // Sizes of TOF module with its support etc..
b94fa26c 470 xTof = 2.*(fRmin*TMath::Tan(10*kDegrad)-wall/2-.5);
2cef3cb2 471 yTof = fRmax-fRmin;
3fe3a833 472
937fe4a4 473// TOF module internal definitions
2cef3cb2 474 TOFpc(xTof, yTof, fZlenC, fZlenB, fZlenA, fZtof);
fe4da5cc 475}
476
477//_____________________________________________________________________________
68861244 478void AliTOF::DrawModule() const
fe4da5cc 479{
480 //
481 // Draw a shaded view of the common part of the TOF geometry
fe4da5cc 482 //
483
3fe3a833 484 cout << " Drawing of AliTOF"<< endl;
fe4da5cc 485 // Set everything unseen
cfce8870 486 gMC->Gsatt("*", "seen", -1);
fe4da5cc 487 //
488 // Set ALIC mother transparent
cfce8870 489 gMC->Gsatt("ALIC","SEEN",0);
fe4da5cc 490 //
491 // Set the volumes visible
2cef3cb2 492 gMC->Gsatt("FTOA","SEEN",1);
493 gMC->Gsatt("FTOB","SEEN",1);
494 gMC->Gsatt("FTOC","SEEN",1);
495 gMC->Gsatt("FLTA","SEEN",1);
496 gMC->Gsatt("FLTB","SEEN",1);
497 gMC->Gsatt("FLTC","SEEN",1);
498 gMC->Gsatt("FSTR","SEEN",1);
cfce8870 499 //
500 gMC->Gdopt("hide", "on");
501 gMC->Gdopt("shad", "on");
502 gMC->Gsatt("*", "fill", 7);
503 gMC->SetClipBox(".");
504 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
505 gMC->DefaultRange();
506 gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
507 gMC->Gdhead(1111, "Time Of Flight");
508 gMC->Gdman(18, 4, "MAN");
509 gMC->Gdopt("hide","off");
fe4da5cc 510}
511
512//_____________________________________________________________________________
513void AliTOF::CreateMaterials()
514{
515 //
516 // Defines TOF materials for all versions
43808676 517 // Revision: F. Pierella 18-VI-2002
fe4da5cc 518 //
43808676 519
b94fa26c 520 Int_t isxfld = gAlice->Field()->Integ();
521 Float_t sxmgmx = gAlice->Field()->Max();
fe4da5cc 522 //
43808676 523 //--- Quartz (SiO2) to simulate float glass
524 // density tuned to have correct float glass
525 // radiation length
3fe3a833 526 Float_t aq[2] = { 28.0855,15.9994 };
527 Float_t zq[2] = { 14.,8. };
528 Float_t wq[2] = { 1.,2. };
43808676 529 Float_t dq = 2.55; // std value: 2.2
3fe3a833 530 Int_t nq = -2;
43808676 531
b94fa26c 532 // --- Freon C2F4H2 (TOF-TDR pagg.)
533 // Geant Manual CONS110-1, pag. 43 (Geant, Detector Description and Simulation Tool)
534 Float_t afre[3] = {12.011,18.998,1.007};
535 Float_t zfre[3] = { 6., 9., 1.};
536 Float_t wfre[3] = { 2., 4., 2.};
537 Float_t densfre = 0.00375;
538// http://www.fi.infn.it/sezione/prevprot/gas/freon.html
539 Int_t nfre = -3;
540/*
541 //-- Isobutane quencher C4H10 (5% in the sensitive mixture)
542 Float_t aiso[2] = {12.011,1.007};
543 Float_t ziso[2] = { 6., 1.};
544 Float_t wiso[2] = { 4., 10.};
545 Float_t densiso = .......; // (g/cm3) density
546 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
547 //-- SF6 (5% in the sensitive mixture)
548 Float_t asf[3] = {32.066,18.998};
549 Float_t zsf[3] = { 16., 9.};
550 Float_t wsf[3] = { 1., 6.};
551 Float_t denssf = .....; // (g/cm3) density
552 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
553*/
3fe3a833 554 // --- CO2
2cef3cb2 555 Float_t ac[2] = {12.,16.};
556 Float_t zc[2] = { 6., 8.};
557 Float_t wc[2] = { 1., 2.};
3fe3a833 558 Float_t dc = .001977;
559 Int_t nc = -2;
560 // For mylar (C5H4O2)
561 Float_t amy[3] = { 12., 1., 16. };
562 Float_t zmy[3] = { 6., 1., 8. };
563 Float_t wmy[3] = { 5., 4., 2. };
564 Float_t dmy = 1.39;
565 Int_t nmy = -3;
b94fa26c 566 // For polyethilene (CH2) - honeycomb -
3fe3a833 567 Float_t ape[2] = { 12., 1. };
568 Float_t zpe[2] = { 6., 1. };
569 Float_t wpe[2] = { 1., 2. };
570 Float_t dpe = 0.935*0.479; //To have 1%X0 for 1cm as for honeycomb
571 Int_t npe = -2;
572 // --- G10
fe4da5cc 573 Float_t ag10[4] = { 12.,1.,16.,28. };
2cef3cb2 574 Float_t zg10[4] = { 6.,1., 8.,14. };
fe4da5cc 575 Float_t wmatg10[4] = { .259,.288,.248,.205 };
3fe3a833 576 Float_t densg10 = 1.7;
577 Int_t nlmatg10 = -4;
43808676 578
579 // plexiglass CH2=C(CH3)CO2CH3
580 Float_t aplex[3] = { 12.,1.,16.};
581 Float_t zplex[3] = { 6.,1., 8.};
582 Float_t wmatplex[3] = {5.,8.,2.};
583 Float_t densplex =1.16;
584 Int_t nplex = -3;
585
3fe3a833 586 // ---- ALUMINA (AL203)
2cef3cb2 587 Float_t aal[2] = { 27.,16.};
588 Float_t zal[2] = { 13., 8.};
fe4da5cc 589 Float_t wmatal[2] = { 2.,3. };
3fe3a833 590 Float_t densal = 2.3;
591 Int_t nlmatal = -2;
592 // -- Water
593 Float_t awa[2] = { 1., 16. };
594 Float_t zwa[2] = { 1., 8. };
595 Float_t wwa[2] = { 2., 1. };
596 Float_t dwa = 1.0;
597 Int_t nwa = -2;
d599d913 598
599// stainless steel
600 Float_t asteel[4] = { 55.847,51.9961,58.6934,28.0855 };
601 Float_t zsteel[4] = { 26.,24.,28.,14. };
602 Float_t wsteel[4] = { .715,.18,.1,.005 };
603
fe4da5cc 604 //
3fe3a833 605 //AliMaterial(0, "Vacuum$", 1e-16, 1e-16, 1e-16, 1e16, 1e16);
2cef3cb2 606 AliMaterial( 1, "Air$",14.61,7.3,0.001205,30423.24,67500.);
607 AliMaterial( 2, "Cu $", 63.54, 29.0, 8.96, 1.43, 14.8);
608 AliMaterial( 3, "C $", 12.01, 6.0, 2.265,18.8, 74.4);
609 AliMixture ( 4, "Polyethilene$", ape, zpe, dpe, npe, wpe);
610 AliMixture ( 5, "G10$", ag10, zg10, densg10, nlmatg10, wmatg10);
43808676 611 AliMixture ( 6, "PLE$", aplex, zplex, densplex, nplex, wmatplex);
2cef3cb2 612 AliMixture ( 7, "CO2$", ac, zc, dc, nc, wc);
613 AliMixture ( 8, "ALUMINA$", aal, zal, densal, nlmatal, wmatal);
614 AliMaterial( 9, "Al $", 26.98, 13., 2.7, 8.9, 37.2);
3fe3a833 615 AliMaterial(10, "C-TRD$", 12.01, 6., 2.265*18.8/69.282*15./100, 18.8, 74.4); // for 15%
2cef3cb2 616 AliMixture (11, "Mylar$", amy, zmy, dmy, nmy, wmy);
617 AliMixture (12, "Freon$", afre, zfre, densfre, nfre, wfre);
43808676 618 AliMixture (13, "Glass$", aq, zq, dq, nq, wq);
2cef3cb2 619 AliMixture (14, "Water$", awa, zwa, dwa, nwa, wwa);
d599d913 620 AliMixture (15, "STAINLESS STEEL$", asteel, zsteel, 7.88, 4, wsteel);
3fe3a833 621
622 Float_t epsil, stmin, deemax, stemax;
2cef3cb2 623
624 // Previous data
fe4da5cc 625 // EPSIL = 0.1 ! Tracking precision,
626 // STEMAX = 0.1 ! Maximum displacement for multiple scattering
627 // DEEMAX = 0.1 ! Maximum fractional energy loss, DLS
628 // STMIN = 0.1
2cef3cb2 629 //
630 // New data
631 epsil = .001; // Tracking precision,
632 stemax = -1.; // Maximum displacement for multiple scattering
633 deemax = -.3; // Maximum fractional energy loss, DLS
fe4da5cc 634 stmin = -.8;
937fe4a4 635
b94fa26c 636 AliMedium( 1, "Air$" , 1, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
637 AliMedium( 2, "Cu $" , 2, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
638 AliMedium( 3, "C $" , 3, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
639 AliMedium( 4, "Pol$" , 4, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
640 AliMedium( 5, "G10$" , 5, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
43808676 641 AliMedium( 6, "PLE$" , 6, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
b94fa26c 642 AliMedium( 7, "CO2$" , 7, 0, isxfld, sxmgmx, 10., -.01, -.1, .01, -.01);
643 AliMedium( 8,"ALUMINA$", 8, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
644 AliMedium( 9,"Al Frame$",9, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
645 AliMedium(10, "DME-S$", 6, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
646 AliMedium(11, "C-TRD$", 10, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
647 AliMedium(12, "Myl$" , 11, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
648 AliMedium(13, "Fre$" , 12, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
649 AliMedium(14, "Fre-S$", 12, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
650 AliMedium(15, "Glass$", 13, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
651 AliMedium(16, "Water$", 14, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
d599d913 652 AliMedium(17, "STEEL$", 15, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
fe4da5cc 653}
654
655//_____________________________________________________________________________
68861244 656Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t ) const
fe4da5cc 657{
658 //
659 // Returns distance from mouse pointer to detector, default version
660 //
661 return 9999;
662}
517b7f8f 663
664//___________________________________________
665void AliTOF::ResetHits ()
666{
667 // Reset number of clusters and the cluster array for this detector
668 AliDetector::ResetHits ();
669}
670
671//____________________________________________
672void AliTOF::ResetDigits ()
673{
674 //
675 // Reset number of digits and the digits array for this detector
676 AliDetector::ResetDigits ();
677 //
678}
fe4da5cc 679//_____________________________________________________________________________
680void AliTOF::Init()
681{
682 //
683 // Initialise TOF detector after it has been built
684 //
fe4da5cc 685 // Set id of TOF sensitive volume
937fe4a4 686 if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD");
fe4da5cc 687 //
fe4da5cc 688}
689
2cef3cb2 690//____________________________________________________________________________
9e1a0ddb 691void AliTOF::MakeBranch(Option_t* option, const char *file)
2cef3cb2 692{
b94fa26c 693 //
694 // Initializes the Branches of the TOF inside the
695 // trees written for each event.
517b7f8f 696 // AliDetector::MakeBranch initializes just the
68861244 697 // Branch inside TreeH. Here we add the branches in
517b7f8f 698 // TreeD, TreeS and TreeR.
b94fa26c 699 //
2ab0c725 700 AliDetector::MakeBranch(option,file);
2cef3cb2 701
702 Int_t buffersize = 4000;
703 Char_t branchname[10];
704 sprintf(branchname,"%s",GetName());
2ab0c725 705
68861244 706 const char *oD = strstr(option,"D");
707 const char *oS = strstr(option,"S");
517b7f8f 708 const char *oR = strstr(option,"R");
68861244 709
710 if (oD)
711 //
712 // one branch for TOF digits
713 //
714
2cef3cb2 715
68861244 716 if (fDigits && gAlice->TreeD() && oD){
717 MakeBranchInTree(gAlice->TreeD(),
2ab0c725 718 branchname, &fDigits,buffersize, file) ;
2cef3cb2 719 }
68861244 720
721 if (oS)
722 //
723 // one branch for TOF sdigits
724 //
725
726
727 if (fSDigits && gAlice->TreeS() && oS){
728 MakeBranchInTree(gAlice->TreeS(),
729 branchname, &fSDigits,buffersize, file) ;
730 }
731
517b7f8f 732 if (oR)
733 //
734 // one branch for TOF reconstructed particles
735 //
736
737
738 if (fReconParticles && gAlice->TreeR() && oR){
739 MakeBranchInTree(gAlice->TreeR(),
740 branchname, &fReconParticles,buffersize, file) ;
741 }
742
68861244 743}
744
745//____________________________________________________________________________
746void AliTOF::Makehits(Bool_t hits)
747{
748// default argument used, see AliTOF.h
749// Enable/Disable the writing of the TOF-hits branch
750// on TreeH
751// by default : enabled for TOFv1, v2, v3, v4
752// disabled for TOFv0
753//
754 if (hits && (IsVersion()!=0))
755 fIdSens = gMC->VolId("FPAD");
756 else
757 cout << "Option for writing the TOF-hits branch on TreeH: disabled" << endl;
2cef3cb2 758}
759
760//____________________________________________________________________________
761void AliTOF::FinishEvent()
762{
68861244 763// do nothing
2cef3cb2 764}
765
2ab0c725 766//___________________________________________
767void AliTOF::SDigits2Digits()
768{
769//
517b7f8f 770// Generate digits performing merging
2ab0c725 771//
517b7f8f 772 /*
2ab0c725 773 int nparticles = gAlice->GetNtrack();
774 cout << "Particles :" <<nparticles<<endl;
775 if (nparticles > 0 ) {
517b7f8f 776
68861244 777 AliTOF::Hits2Digits();
517b7f8f 778
2ab0c725 779 }
517b7f8f 780 */
781 cout<<"AliTOF::SDigits2Digits"<<endl;
782 if (fMerger) {
783 fMerger->Init();
784 cout<<"AliTOF::SDigits2Digits Init"<<endl;
785 fMerger->Digitise();
786 cout<<"AliTOF::SDigits2Digits Digitise() "<<endl;
787 }
788}
789
790//---------------------------------------------------------------------
791void AliTOF::SetMerger(AliTOFMerger* merger)
792{
793// Set pointer to merger
794 fMerger = merger;
795}
796
797//---------------------------------------------------------------------
798AliTOFMerger* AliTOF::Merger()
799{
800// Return pointer to merger
801 return fMerger;
2ab0c725 802}
2cef3cb2 803
68861244 804
517b7f8f 805//---------------------------------------------------------------------
2cef3cb2 806
517b7f8f 807void AliTOF::Hits2SDigits()
808{
809//
810// Use the TOF SDigitizer to make TOF SDigits
811//
812//
813 //#ifdef DEBUG
814 cout<<"ALiTOF::Hits2SDigits> start...\n";
815 //#endif
68861244 816
bfec09a6 817 //char * fileSDigits = 0 ;
517b7f8f 818 char * fileHeader = 0;
bfec09a6 819 AliTOFSDigitizer * sd = new AliTOFSDigitizer(fileHeader) ;
68861244 820
517b7f8f 821 sd->Exec("") ;
822 sd->Print("");
68861244 823
517b7f8f 824 delete sd ;
68861244 825
2cef3cb2 826}
2cef3cb2 827//___________________________________________________________________________
828Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
b94fa26c 829{
2cef3cb2 830//
831// Checks if 2 or more hits belong to the same pad.
832// In this case the data assigned to the digit object
833// are the ones of the first hit in order of Time.
517b7f8f 834// 2 hits from the same track on the same pad are collected.
835// Called only by Hits2SDigits.
836// This procedure has to be optimized in the next TOF release.
2cef3cb2 837//
b94fa26c 838
517b7f8f 839 Bool_t overlap = kFALSE;
2cef3cb2 840 Int_t vol2[5];
841
517b7f8f 842 for (Int_t ndig=0; ndig<fSDigits->GetEntries(); ndig++){
843 AliTOFdigit* currentDigit = (AliTOFdigit*)(fSDigits->UncheckedAt(ndig));
2cef3cb2 844 currentDigit->GetLocation(vol2);
517b7f8f 845 Bool_t idem= kTRUE;
846 // check on digit volume
2cef3cb2 847 for (Int_t i=0;i<=4;i++){
517b7f8f 848 if (!idem) break;
849 if (vol[i]!=vol2[i]) idem=kFALSE;}
850
851 if (idem){ // same pad fired
b94fa26c 852 Float_t tdc2 = digit[0];
853 Float_t tdc1 = currentDigit->GetTdc();
517b7f8f 854
855 // we separate two digits on the same pad if
856 // they are separated in time by at least 25 ns
857 // remember that tdc time is given in ps
858
859 if (TMath::Abs(tdc1-tdc2)<25000){
860 // in case of overlap we take the earliest
861 if (tdc1>tdc2){
862 currentDigit->SetTdc(tdc2);
863 currentDigit->SetAdc(digit[1]);
864 }
865 else {
866 currentDigit->SetTdc(tdc1);
867 currentDigit->SetAdc(digit[1]);
868 }
869 currentDigit->AddTrack(Track); // add track number in the track array
517b7f8f 870 overlap = kTRUE;
f3de6e9e 871 return overlap;
872 } else
873 overlap= kFALSE;
517b7f8f 874
875 } // close if (idem) -> two digits on the same TOF pad
876
877 } // end loop on existing sdigits
878
b94fa26c 879 return overlap;
2cef3cb2 880}
881
882
883//____________________________________________________________________________
884void AliTOF::Digits2Raw(Int_t evNumber)
b94fa26c 885{
2cef3cb2 886//
887// Starting from digits, writes the
888// Raw Data objects, i.e. a
889// TClonesArray of 18 AliTOFRawSector objects
890//
891
b94fa26c 892 TTree* tD;
2cef3cb2 893
68861244 894 // do nothing if no particles
2cef3cb2 895 Int_t nparticles = gAlice->GetEvent(evNumber);
896 if (nparticles <= 0) return;
897
b94fa26c 898 tD = gAlice->TreeD();
2cef3cb2 899
b94fa26c 900 TClonesArray* tofdigits = this->Digits();
901 Int_t ndigits = tofdigits->GetEntriesFast();
2cef3cb2 902
b94fa26c 903 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
2cef3cb2 904
905 for (Int_t isect=1;isect<=fNTof;isect++){
b94fa26c 906 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(isect);
907 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
2cef3cb2 908
909 for (Int_t digit=0; digit<ndigits; digit++){
b94fa26c 910 AliTOFdigit* currentDigit = (AliTOFdigit*)tofdigits->UncheckedAt(digit);
2cef3cb2 911 Int_t sector = currentDigit->GetSector();
912 if (sector==isect){
b94fa26c 913 Int_t pad = currentDigit -> GetTotPad();
914 Int_t roc = (Int_t)(pad/fNPadXRoc)-1;
915 if (roc>=fNRoc) printf("Wrong n. of ROC ! Roc = %i",roc);
916 Int_t padRoc = (Int_t) pad%fNPadXRoc;
917 Int_t fec = (Int_t)(padRoc/fNFec)-1;
918 Int_t tdc = (Int_t)(padRoc%fNFec)-1;
919 Float_t time = currentDigit->GetTdc();
920 Float_t charge = currentDigit->GetAdc();
921 AliTOFRoc* currentROC = (AliTOFRoc*)rocData->UncheckedAt(roc);
922 Int_t error = 0;
923 currentROC->AddItem(fec, tdc, error, charge, time);
68861244 924 } // close if (sector==isect) i.e. end loop on digits for the current sector
925 } // end loop on TOF digits
2cef3cb2 926
b94fa26c 927 UInt_t totSize=16,rocSize=0;
928 UInt_t rocHead[14],rocChek[14];
929 UInt_t globalCheckSum=0;
2cef3cb2 930
931 for (UInt_t iRoc = 1; iRoc<(UInt_t)fNRoc; iRoc++){
b94fa26c 932 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(iRoc);
933 rocSize = currentRoc->GetItems()*2+1;
934 totSize += rocSize*4;
935 if (rocSize>=TMath::Power(2,16)) rocSize=0;
936 rocHead[iRoc] = iRoc<<28;
937 rocHead[iRoc] += rocSize;
938 rocChek[iRoc] = currentRoc->GetCheckSum();
939 Int_t headCheck = currentRoc->BitCount(rocHead[iRoc]);
940 globalCheckSum += headCheck;
941 globalCheckSum += rocChek[iRoc];
2cef3cb2 942 }
943
b94fa26c 944 AliTOFRoc* dummyRoc = new AliTOFRoc();
945 totSize *= 4;
946 if (totSize>=TMath::Power(2,24)) totSize=0;
947 UInt_t header = totSize;
948 UInt_t sectId = ((UInt_t)isect)<<24;
949 header += sectId;
950 globalCheckSum += dummyRoc->BitCount(header);
951 currentSector->SetGlobalCS(globalCheckSum);
952 currentSector->SetHeader(header);
2cef3cb2 953 }
954}
955
956//____________________________________________________________________________
957void AliTOF::Raw2Digits(Int_t evNumber)
b94fa26c 958{
2cef3cb2 959//
960// Converts Raw Data objects into digits objects.
961// We schematize the raw data with a
962// TClonesArray of 18 AliTOFRawSector objects
963//
b94fa26c 964
965 TTree *tD;
2cef3cb2 966 Int_t vol[5];
967 Int_t tracks[3];
968 Float_t digit[2];
969
970 tracks[0]=0;
971 tracks[1]=0;
972 tracks[2]=0;
fe4da5cc 973
2cef3cb2 974 Int_t nparticles = gAlice->GetEvent(evNumber);
975 if (nparticles <= 0) return;
976
b94fa26c 977 tD = gAlice->TreeD();
2cef3cb2 978
b94fa26c 979 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
2cef3cb2 980
981 for(Int_t nSec=1; nSec<=fNTof; nSec++){
b94fa26c 982 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(nSec);
983 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
2cef3cb2 984 for(Int_t nRoc=1; nRoc<=14; nRoc++){
b94fa26c 985 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(nRoc);
2cef3cb2 986 Int_t currentItems = currentRoc->GetItems();
987 for(Int_t item=1; item<currentItems; item++){
988 Int_t nPad = currentRoc->GetTotPad(item);
989 vol[0] = nSec;
990 Int_t nStrip = (Int_t)(nPad/fPadXStr)+1;
991 Int_t nPlate = 5;
992 if (nStrip<=fNStripC+2*fNStripB+fNStripA) nPlate = 4;
993 if (nStrip<=fNStripC+fNStripB+fNStripA) nPlate = 3;
994 if (nStrip<=fNStripC+fNStripB) nPlate = 2;
995 if (nStrip<=fNStripC) nPlate=1;
996 vol[1] = nPlate;
997 switch (nPlate){
998 case 1: break;
999 case 2: nStrip -= (fNStripC);
1000 break;
1001 case 3: nStrip -= (fNStripC+fNStripB);
1002 break;
1003 case 4: nStrip -= (fNStripC+fNStripB+fNStripA);
1004 break;
1005 case 5: nStrip -= (fNStripC+2*fNStripB+fNStripA);
1006 break;
1007 }
1008 vol[2] = nStrip;
b94fa26c 1009 Int_t pad = nPad%fPadXStr;
1010 if (pad==0) pad=fPadXStr;
2cef3cb2 1011 Int_t nPadX=0, nPadZ=0;
b94fa26c 1012 (pad>fNpadX)? nPadX -= fNpadX : nPadX = pad ;
2cef3cb2 1013 vol[3] = nPadX;
b94fa26c 1014 (pad>fNpadX)? nPadZ = 2 : nPadZ = 1 ;
2cef3cb2 1015 vol[4] = nPadZ;
1016 UInt_t error=0;
b94fa26c 1017 Float_t tdc = currentRoc->GetTime(item,error);
1018 if (!error) digit[0]=tdc;
2cef3cb2 1019 digit[1] = currentRoc->GetCharge(item);
1020 AddDigit(tracks,vol,digit);
1021 }
1022 }
1023 }
b94fa26c 1024 tD->Fill();
68861244 1025 tD->Write(0,TObject::kOverwrite);
2cef3cb2 1026}
1027
55991c8b 1028////////////////////////////////////////////////////////////////////////
1029void AliTOF::RecreateSDigitsArray() {
1030//
1031// delete TClonesArray fSDigits and create it again
1032// needed for backward compatability with PPR test production
1033//
1034 delete fSDigits;
1035 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
1036}
1037////////////////////////////////////////////////////////////////////////
1038void AliTOF::CreateSDigitsArray() {
1039//
1040// create TClonesArray fSDigits
1041// needed for backward compatability with PPR test production
1042//
1043 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
1044}