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