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