DrawModule declared const
[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
88cb7938 16/* $Id$ */
68861244 17
fe4da5cc 18///////////////////////////////////////////////////////////////////////////////
19// //
68861244 20// Time Of Flight //
fe4da5cc 21// This class contains the basic functions for the Time Of Flight //
22// detector. Functions specific to one particular geometry are //
23// contained in the derived classes //
937fe4a4 24//
25// VERSIONE WITH 5 SYMMETRIC MODULES ALONG Z AXIS
26// ==============================================
27//
28// VERSION WITH HOLES FOR PHOS AND TRD IN SPACEFRAME WITH HOLES
29//
30// Volume sensibile : FPAD
31//
32//
33//
34// Begin_Html
fe4da5cc 35/*
1439f98e 36<img src="picts/AliTOFClass.gif">
fe4da5cc 37*/
38//End_Html
937fe4a4 39//
40//
fe4da5cc 41// //
42///////////////////////////////////////////////////////////////////////////////
43
88cb7938 44
f8014e68 45#include <Riostream.h>
46#include <Rstrstream.h>
517b7f8f 47#include <stdlib.h>
826b71ec 48
88cb7938 49#include <TBRIK.h>
50#include <TFile.h>
51#include <TFolder.h>
52#include <TNode.h>
53#include <TObject.h>
54#include <TROOT.h>
55#include <TSystem.h>
56#include <TTask.h>
57#include <TTree.h>
58#include <TVirtualMC.h>
59
d076c8d5 60#include "AliLog.h"
7e6dce66 61#include "AliConfig.h"
62#include "AliHeader.h"
88cb7938 63#include "AliConst.h"
64#include "AliLoader.h"
65#include "AliMagF.h"
66#include "AliRun.h"
fe4da5cc 67#include "AliTOF.h"
7e6dce66 68#include "AliTOFGeometry.h"
88cb7938 69#include "AliTOFSDigit.h"
70#include "AliTOFdigit.h"
71#include "AliTOFhit.h"
72#include "AliTOFhitT0.h"
5d12ce38 73#include "AliMC.h"
85a5290f 74#include "AliTOFDigitizer.h"
7e6dce66 75#include "AliTOFDDLRawData.h"
fe4da5cc 76
77ClassImp(AliTOF)
78
79//_____________________________________________________________________________
80AliTOF::AliTOF()
81{
82 //
83 // Default constructor
84 //
7e6dce66 85 fFGeom = 0x0;
86 fDTask = 0x0;
00711221 87 fReTask = 0x0;
fe4da5cc 88 fIshunt = 0;
7e6dce66 89 fSDigits = 0 ;
8e72349e 90 fNSDigits = 0;
7e6dce66 91 fDigits = 0 ;
00711221 92 fReconParticles = 0x0;
68861244 93 fName="TOF";
7e6dce66 94 fTZero = kFALSE;
0f4a7374 95 fTOFGeometry = 0;
fe4da5cc 96}
97
98//_____________________________________________________________________________
792995c1 99AliTOF::AliTOF(const char *name, const char *title, Option_t *option)
fe4da5cc 100 : AliDetector(name,title)
101{
102 //
103 // AliTOF standard constructor
104 //
2cef3cb2 105 // Here are fixed some important parameters
106 //
107
68861244 108 // Initialization of hits, sdigits and digits array
d599d913 109 // added option for time zero analysis
7e6dce66 110 fFGeom = 0x0; //skowron
111 fDTask = 0x0;
112 fReTask = 0x0;
88cb7938 113 fReconParticles= 0x0;
0f4a7374 114 fTOFGeometry = 0;
88cb7938 115
d599d913 116 if (strstr(option,"tzero")){
117 fHits = new TClonesArray("AliTOFhitT0", 1000);
88cb7938 118 fTZero = kTRUE;
d076c8d5 119 AliWarning("tzero option requires AliTOFv4T0 as TOF version (check Your Config.C)");
d599d913 120 }else{
121 fHits = new TClonesArray("AliTOFhit", 1000);
88cb7938 122 fTZero = kFALSE;
d599d913 123 }
c630aafd 124 if (gAlice==0) {
d076c8d5 125 AliFatal("gAlice==0 !");
c630aafd 126 }
5d12ce38 127 if (gAlice->GetMCApp()->GetHitLists())
128 gAlice->GetMCApp()->AddHitList(fHits);
d076c8d5 129 else AliError("gAlice->GetHitLists()==0");
c630aafd 130
2cef3cb2 131 fIshunt = 0;
7e6dce66 132 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
133 fDigits = new TClonesArray("AliTOFdigit", 1000);
8e72349e 134 fNSDigits = 0;
00711221 135
136 fFGeom = 0x0;
137 fDTask = 0x0;
138 fReTask = 0x0;
139 fReconParticles = 0x0;
00711221 140
2cef3cb2 141 //
142 // Digitization parameters
fe4da5cc 143 //
2cef3cb2 144 // (Transfer Functions to be inserted here)
fe4da5cc 145 //
146 SetMarkerColor(7);
147 SetMarkerStyle(2);
148 SetMarkerSize(0.4);
2cef3cb2 149
2cef3cb2 150// Strip Parameters
7e6dce66 151 //fGapA = 4.; //cm Gap beetween tilted strip in A-type plate
152 //fGapB = 6.; //cm Gap beetween tilted strip in B-type plate
153
154 // Physical performances
155 //fTimeRes = 100.;//ps
156 //fChrgRes = 100.;//pC
157
68861244 158}
159
160//_____________________________________________________________________________
161void AliTOF::CreateTOFFolders()
162{
163 // create the ALICE TFolder
164 // create the ALICE TTasks
165 // create the ALICE main TFolder
166 // to be done by AliRun
167
168 TFolder * alice = new TFolder();
169 alice->SetNameTitle("FPAlice", "Alice Folder") ;
170 gROOT->GetListOfBrowsables()->Add(alice) ;
171
172 TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ;
173 // make it the owner of the objects that it contains
174 aliceF->SetOwner() ;
175 // geometry folder
176 TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ;
177 TFolder * aliceT = alice->AddFolder("tasks", "Alice tasks Folder") ;
178 // make it the owner of the objects that it contains
179 aliceT->SetOwner() ;
180
181 TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ;
182 aliceT->Add(aliceDi);
183
184 TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
185 aliceT->Add(aliceRe);
186
187 char * tempo = new char[80] ;
188
189 // creates the TOF Digitizer and adds it to alice main (S)Digitizer task
190 sprintf(tempo, "%sDigitizers container",GetName() ) ;
191 fDTask = new TTask(GetName(), tempo);
192 aliceDi->Add(fDTask) ;
193
194 // creates the TOF reconstructioner and adds it to alice main Reconstructioner task
195 sprintf(tempo, "%sReconstructioner container",GetName() ) ;
196 fReTask = new TTask(GetName(), tempo);
197 aliceRe->Add(fReTask) ;
198
3ff0c331 199 delete [] tempo ;
68861244 200
201 // creates the TOF geometry folder
202 geomF->AddFolder("TOF", "Geometry for TOF") ;
203}
204
205//_____________________________________________________________________________
206AliTOF::~AliTOF()
207{
517b7f8f 208 // dtor:
209 // it remove also the alice folder
68861244 210 // and task that TOF creates instead of AliRun
5839f074 211 /* PH Temporarily commented because of problems
68861244 212 TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ;
213 delete alice;
214 alice = 0;
5839f074 215 */
517b7f8f 216 if (fHits)
217 {
218 fHits->Delete ();
219 delete fHits;
220 fHits = 0;
221 }
222 if (fDigits)
223 {
224 fDigits->Delete ();
225 delete fDigits;
226 fDigits = 0;
227 }
228 if (fSDigits)
229 {
88cb7938 230 fSDigits->Delete();
517b7f8f 231 delete fSDigits;
232 fSDigits = 0;
233 }
234 if (fReconParticles)
235 {
236 fReconParticles->Delete ();
237 delete fReconParticles;
238 fReconParticles = 0;
239 }
240
fe4da5cc 241}
242
243//_____________________________________________________________________________
2cef3cb2 244void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits)
fe4da5cc 245{
246 //
247 // Add a TOF hit
68861244 248 // new with placement used
fe4da5cc 249 //
250 TClonesArray &lhits = *fHits;
2cef3cb2 251 new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits);
fe4da5cc 252}
d599d913 253
254//_____________________________________________________________________________
255void AliTOF::AddT0Hit(Int_t track, Int_t *vol, Float_t *hits)
256{
257 //
258 // Add a TOF hit
259 // new with placement used
260 //
261 TClonesArray &lhits = *fHits;
262 new(lhits[fNhits++]) AliTOFhitT0(fIshunt, track, vol, hits);
263}
264
fe4da5cc 265//_____________________________________________________________________________
2cef3cb2 266void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
fe4da5cc 267{
268 //
2cef3cb2 269 // Add a TOF digit
68861244 270 // new with placement used
2cef3cb2 271 //
272 TClonesArray &ldigits = *fDigits;
273 new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits);
fe4da5cc 274}
275
517b7f8f 276//___________________________________________
5919c40c 277void AliTOF::AddSDigit(Int_t tracknum, Int_t *vol, Float_t *digits)
517b7f8f 278{
279
280//
281// Add a TOF sdigit
282//
283
284 TClonesArray &lSDigits = *fSDigits;
5919c40c 285 new(lSDigits[fNSDigits++]) AliTOFSDigit(tracknum, vol, digits);
517b7f8f 286}
287
288//_____________________________________________________________________________
289void AliTOF::SetTreeAddress ()
290{
291 // Set branch address for the Hits and Digits Tree.
88cb7938 292
293 if (fLoader->TreeH())
294 {
295 if (fHits == 0x0)
296 {
297 if (fTZero) fHits = new TClonesArray("AliTOFhitT0", 1000);
298 else fHits = new TClonesArray("AliTOFhit", 1000);
299 }
300 }
517b7f8f 301 AliDetector::SetTreeAddress ();
302
303 TBranch *branch;
517b7f8f 304
88cb7938 305 if (fLoader->TreeS () )
517b7f8f 306 {
88cb7938 307 branch = fLoader->TreeS ()->GetBranch ("TOF");
308 if (branch) {
309 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit", 1000);
310 branch->SetAddress (&fSDigits);
311 }
517b7f8f 312 }
313
88cb7938 314 if (fLoader->TreeR() && fReconParticles) //I do not know where this array is created - skowron
517b7f8f 315 {
88cb7938 316 branch = fLoader->TreeR()->GetBranch("TOF");
317 if (branch)
318 {
319 branch->SetAddress(&fReconParticles) ;
320 }
517b7f8f 321 }
322}
2cef3cb2 323
fe4da5cc 324//_____________________________________________________________________________
325void AliTOF::CreateGeometry()
326{
327 //
3fe3a833 328 // Common geometry code
fe4da5cc 329 //
330 //Begin_Html
331 /*
1439f98e 332 <img src="picts/AliTOFv23.gif">
fe4da5cc 333 */
334 //End_Html
335 //
fe4da5cc 336 const Double_t kPi=TMath::Pi();
2cef3cb2 337 const Double_t kDegrad=kPi/180.;
fe4da5cc 338 //
b94fa26c 339 Float_t xTof, yTof, wall;
937fe4a4 340
3fe3a833 341 // frame inbetween TOF modules
b94fa26c 342 wall = 4.;//cm
3fe3a833 343
2cef3cb2 344 // Sizes of TOF module with its support etc..
7e6dce66 345 xTof = 2.*(AliTOFGeometry::Rmin()*TMath::Tan(10*kDegrad)-wall/2-.5);
346 yTof = AliTOFGeometry::Rmax()-AliTOFGeometry::Rmin();
3fe3a833 347
937fe4a4 348// TOF module internal definitions
7e6dce66 349 //TOFpc(xTof, yTof, fZlenC, fZlenB, fZlenA, AliTOFGeometry::MaxhZtof());
350 TOFpc(xTof, yTof, AliTOFGeometry::ZlenC(), AliTOFGeometry::ZlenB(), AliTOFGeometry::ZlenA(), AliTOFGeometry::MaxhZtof());
fe4da5cc 351}
352
353//_____________________________________________________________________________
ba380e33 354void AliTOF::DrawModule() const
fe4da5cc 355{
356 //
357 // Draw a shaded view of the common part of the TOF geometry
fe4da5cc 358 //
359
d076c8d5 360 AliInfo(" Drawing of AliTOF");
fe4da5cc 361 // Set everything unseen
cfce8870 362 gMC->Gsatt("*", "seen", -1);
fe4da5cc 363 //
364 // Set ALIC mother transparent
cfce8870 365 gMC->Gsatt("ALIC","SEEN",0);
fe4da5cc 366 //
367 // Set the volumes visible
2cef3cb2 368 gMC->Gsatt("FTOA","SEEN",1);
369 gMC->Gsatt("FTOB","SEEN",1);
370 gMC->Gsatt("FTOC","SEEN",1);
371 gMC->Gsatt("FLTA","SEEN",1);
372 gMC->Gsatt("FLTB","SEEN",1);
373 gMC->Gsatt("FLTC","SEEN",1);
374 gMC->Gsatt("FSTR","SEEN",1);
cfce8870 375 //
376 gMC->Gdopt("hide", "on");
377 gMC->Gdopt("shad", "on");
378 gMC->Gsatt("*", "fill", 7);
379 gMC->SetClipBox(".");
380 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
381 gMC->DefaultRange();
382 gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
383 gMC->Gdhead(1111, "Time Of Flight");
384 gMC->Gdman(18, 4, "MAN");
385 gMC->Gdopt("hide","off");
fe4da5cc 386}
387
388//_____________________________________________________________________________
389void AliTOF::CreateMaterials()
390{
391 //
392 // Defines TOF materials for all versions
43808676 393 // Revision: F. Pierella 18-VI-2002
fe4da5cc 394 //
43808676 395
b94fa26c 396 Int_t isxfld = gAlice->Field()->Integ();
397 Float_t sxmgmx = gAlice->Field()->Max();
fe4da5cc 398 //
43808676 399 //--- Quartz (SiO2) to simulate float glass
400 // density tuned to have correct float glass
401 // radiation length
3fe3a833 402 Float_t aq[2] = { 28.0855,15.9994 };
403 Float_t zq[2] = { 14.,8. };
404 Float_t wq[2] = { 1.,2. };
43808676 405 Float_t dq = 2.55; // std value: 2.2
3fe3a833 406 Int_t nq = -2;
43808676 407
b94fa26c 408 // --- Freon C2F4H2 (TOF-TDR pagg.)
409 // Geant Manual CONS110-1, pag. 43 (Geant, Detector Description and Simulation Tool)
410 Float_t afre[3] = {12.011,18.998,1.007};
411 Float_t zfre[3] = { 6., 9., 1.};
412 Float_t wfre[3] = { 2., 4., 2.};
413 Float_t densfre = 0.00375;
414// http://www.fi.infn.it/sezione/prevprot/gas/freon.html
415 Int_t nfre = -3;
416/*
417 //-- Isobutane quencher C4H10 (5% in the sensitive mixture)
418 Float_t aiso[2] = {12.011,1.007};
419 Float_t ziso[2] = { 6., 1.};
420 Float_t wiso[2] = { 4., 10.};
421 Float_t densiso = .......; // (g/cm3) density
422 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
423 //-- SF6 (5% in the sensitive mixture)
424 Float_t asf[3] = {32.066,18.998};
425 Float_t zsf[3] = { 16., 9.};
426 Float_t wsf[3] = { 1., 6.};
427 Float_t denssf = .....; // (g/cm3) density
428 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
429*/
3fe3a833 430 // --- CO2
2cef3cb2 431 Float_t ac[2] = {12.,16.};
432 Float_t zc[2] = { 6., 8.};
433 Float_t wc[2] = { 1., 2.};
3fe3a833 434 Float_t dc = .001977;
435 Int_t nc = -2;
436 // For mylar (C5H4O2)
437 Float_t amy[3] = { 12., 1., 16. };
438 Float_t zmy[3] = { 6., 1., 8. };
439 Float_t wmy[3] = { 5., 4., 2. };
440 Float_t dmy = 1.39;
441 Int_t nmy = -3;
b94fa26c 442 // For polyethilene (CH2) - honeycomb -
3fe3a833 443 Float_t ape[2] = { 12., 1. };
444 Float_t zpe[2] = { 6., 1. };
445 Float_t wpe[2] = { 1., 2. };
446 Float_t dpe = 0.935*0.479; //To have 1%X0 for 1cm as for honeycomb
447 Int_t npe = -2;
448 // --- G10
fe4da5cc 449 Float_t ag10[4] = { 12.,1.,16.,28. };
2cef3cb2 450 Float_t zg10[4] = { 6.,1., 8.,14. };
fe4da5cc 451 Float_t wmatg10[4] = { .259,.288,.248,.205 };
3fe3a833 452 Float_t densg10 = 1.7;
453 Int_t nlmatg10 = -4;
43808676 454
455 // plexiglass CH2=C(CH3)CO2CH3
456 Float_t aplex[3] = { 12.,1.,16.};
457 Float_t zplex[3] = { 6.,1., 8.};
458 Float_t wmatplex[3] = {5.,8.,2.};
459 Float_t densplex =1.16;
460 Int_t nplex = -3;
461
3fe3a833 462 // ---- ALUMINA (AL203)
2cef3cb2 463 Float_t aal[2] = { 27.,16.};
464 Float_t zal[2] = { 13., 8.};
fe4da5cc 465 Float_t wmatal[2] = { 2.,3. };
3fe3a833 466 Float_t densal = 2.3;
467 Int_t nlmatal = -2;
468 // -- Water
469 Float_t awa[2] = { 1., 16. };
470 Float_t zwa[2] = { 1., 8. };
471 Float_t wwa[2] = { 2., 1. };
472 Float_t dwa = 1.0;
473 Int_t nwa = -2;
d599d913 474
475// stainless steel
476 Float_t asteel[4] = { 55.847,51.9961,58.6934,28.0855 };
477 Float_t zsteel[4] = { 26.,24.,28.,14. };
478 Float_t wsteel[4] = { .715,.18,.1,.005 };
479
3fe3a833 480 //AliMaterial(0, "Vacuum$", 1e-16, 1e-16, 1e-16, 1e16, 1e16);
849bff36 481
482 // AIR
483 Float_t aAir[4]={12.0107,14.0067,15.9994,39.948};
484 Float_t zAir[4]={6.,7.,8.,18.};
485 Float_t wAir[4]={0.000124,0.755267,0.231781,0.012827};
486 Float_t dAir = 1.20479E-3;
487
488 AliMixture( 1, "Air$", aAir, zAir, dAir, 4, wAir);
489
2cef3cb2 490 AliMaterial( 2, "Cu $", 63.54, 29.0, 8.96, 1.43, 14.8);
491 AliMaterial( 3, "C $", 12.01, 6.0, 2.265,18.8, 74.4);
492 AliMixture ( 4, "Polyethilene$", ape, zpe, dpe, npe, wpe);
493 AliMixture ( 5, "G10$", ag10, zg10, densg10, nlmatg10, wmatg10);
43808676 494 AliMixture ( 6, "PLE$", aplex, zplex, densplex, nplex, wmatplex);
2cef3cb2 495 AliMixture ( 7, "CO2$", ac, zc, dc, nc, wc);
496 AliMixture ( 8, "ALUMINA$", aal, zal, densal, nlmatal, wmatal);
497 AliMaterial( 9, "Al $", 26.98, 13., 2.7, 8.9, 37.2);
3fe3a833 498 AliMaterial(10, "C-TRD$", 12.01, 6., 2.265*18.8/69.282*15./100, 18.8, 74.4); // for 15%
2cef3cb2 499 AliMixture (11, "Mylar$", amy, zmy, dmy, nmy, wmy);
500 AliMixture (12, "Freon$", afre, zfre, densfre, nfre, wfre);
43808676 501 AliMixture (13, "Glass$", aq, zq, dq, nq, wq);
2cef3cb2 502 AliMixture (14, "Water$", awa, zwa, dwa, nwa, wwa);
d599d913 503 AliMixture (15, "STAINLESS STEEL$", asteel, zsteel, 7.88, 4, wsteel);
3fe3a833 504
505 Float_t epsil, stmin, deemax, stemax;
2cef3cb2 506
507 // Previous data
fe4da5cc 508 // EPSIL = 0.1 ! Tracking precision,
509 // STEMAX = 0.1 ! Maximum displacement for multiple scattering
510 // DEEMAX = 0.1 ! Maximum fractional energy loss, DLS
511 // STMIN = 0.1
2cef3cb2 512 //
513 // New data
514 epsil = .001; // Tracking precision,
515 stemax = -1.; // Maximum displacement for multiple scattering
516 deemax = -.3; // Maximum fractional energy loss, DLS
fe4da5cc 517 stmin = -.8;
937fe4a4 518
b94fa26c 519 AliMedium( 1, "Air$" , 1, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
520 AliMedium( 2, "Cu $" , 2, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
521 AliMedium( 3, "C $" , 3, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
522 AliMedium( 4, "Pol$" , 4, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
523 AliMedium( 5, "G10$" , 5, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
43808676 524 AliMedium( 6, "PLE$" , 6, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
b94fa26c 525 AliMedium( 7, "CO2$" , 7, 0, isxfld, sxmgmx, 10., -.01, -.1, .01, -.01);
526 AliMedium( 8,"ALUMINA$", 8, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
527 AliMedium( 9,"Al Frame$",9, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
528 AliMedium(10, "DME-S$", 6, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
529 AliMedium(11, "C-TRD$", 10, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
530 AliMedium(12, "Myl$" , 11, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
531 AliMedium(13, "Fre$" , 12, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
532 AliMedium(14, "Fre-S$", 12, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
533 AliMedium(15, "Glass$", 13, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
534 AliMedium(16, "Water$", 14, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
d599d913 535 AliMedium(17, "STEEL$", 15, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
fe4da5cc 536}
537
538//_____________________________________________________________________________
5d11728f 539Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t )
fe4da5cc 540{
541 //
542 // Returns distance from mouse pointer to detector, default version
543 //
544 return 9999;
545}
517b7f8f 546
547//___________________________________________
548void AliTOF::ResetHits ()
549{
550 // Reset number of clusters and the cluster array for this detector
551 AliDetector::ResetHits ();
552}
553
554//____________________________________________
555void AliTOF::ResetDigits ()
556{
557 //
558 // Reset number of digits and the digits array for this detector
559 AliDetector::ResetDigits ();
560 //
561}
d61f73d9 562//____________________________________________
563void AliTOF::ResetSDigits ()
564{
565 //
566 // Reset number of sdigits and the sdigits array for this detector
567 fNSDigits = 0;
e615b5b5 568 //fSDigits = 0x0;
d61f73d9 569 //
570}
fe4da5cc 571//_____________________________________________________________________________
572void AliTOF::Init()
573{
574 //
575 // Initialise TOF detector after it has been built
576 //
fe4da5cc 577 // Set id of TOF sensitive volume
937fe4a4 578 if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD");
fe4da5cc 579 //
d076c8d5 580 // Save the geometry
581 TDirectory* saveDir = gDirectory;
582 gAlice->GetRunLoader()->CdGAFile();
583 fTOFGeometry->Write("TOFGeometry");
584 saveDir->cd();
fe4da5cc 585}
586
2cef3cb2 587//____________________________________________________________________________
88cb7938 588void AliTOF::MakeBranch(Option_t* option)
2cef3cb2 589{
b94fa26c 590 //
591 // Initializes the Branches of the TOF inside the
592 // trees written for each event.
517b7f8f 593 // AliDetector::MakeBranch initializes just the
68861244 594 // Branch inside TreeH. Here we add the branches in
517b7f8f 595 // TreeD, TreeS and TreeR.
b94fa26c 596 //
88cb7938 597 const char *oH = strstr(option,"H");
598 if (fLoader->TreeH() && oH)
599 {
600 if (fHits == 0x0)
601 {
602 if (fTZero) fHits = new TClonesArray("AliTOFhitT0", 1000);
603 else fHits = new TClonesArray("AliTOFhit", 1000);
604 }
605 }
606
607 AliDetector::MakeBranch(option);
2cef3cb2 608
609 Int_t buffersize = 4000;
610 Char_t branchname[10];
611 sprintf(branchname,"%s",GetName());
2ab0c725 612
68861244 613 const char *oD = strstr(option,"D");
614 const char *oS = strstr(option,"S");
517b7f8f 615 const char *oR = strstr(option,"R");
68861244 616
88cb7938 617 if (fLoader->TreeD() && oD){
618 if (fDigits == 0x0) fDigits = new TClonesArray("AliTOFdigit", 1000);
619 MakeBranchInTree(fLoader->TreeD(), branchname, &fDigits,buffersize, 0) ;
2cef3cb2 620 }
68861244 621
88cb7938 622 if (fLoader->TreeS() && oS){
623 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit", 1000);
624 MakeBranchInTree(fLoader->TreeS(), branchname, &fSDigits,buffersize, 0) ;
68861244 625 }
626
88cb7938 627 if (fReconParticles && fLoader->TreeR() && oR){
628 MakeBranchInTree(fLoader->TreeR(), branchname, &fReconParticles,buffersize, 0) ;
517b7f8f 629 }
68861244 630}
631
632//____________________________________________________________________________
633void AliTOF::Makehits(Bool_t hits)
634{
635// default argument used, see AliTOF.h
636// Enable/Disable the writing of the TOF-hits branch
637// on TreeH
638// by default : enabled for TOFv1, v2, v3, v4
639// disabled for TOFv0
640//
641 if (hits && (IsVersion()!=0))
642 fIdSens = gMC->VolId("FPAD");
643 else
d076c8d5 644 AliInfo("Option for writing the TOF-hits branch on TreeH: disabled");
2cef3cb2 645}
646
647//____________________________________________________________________________
648void AliTOF::FinishEvent()
649{
68861244 650// do nothing
2cef3cb2 651}
652
517b7f8f 653//---------------------------------------------------------------------
517b7f8f 654void AliTOF::Hits2SDigits()
655{
656//
657// Use the TOF SDigitizer to make TOF SDigits
658//
d61f73d9 659
f540341d 660// cout<<"AliTOF::Hits2SDigits> start...\n";
68861244 661
be385a87 662 AliRunLoader * rl = fLoader->GetRunLoader();
663 AliTOFSDigitizer sd((rl->GetFileName()).Data());
d076c8d5 664 ToAliDebug(1, sd.Print(""));
68861244 665
be385a87 666 sd.Exec("") ;
d61f73d9 667
668}
669
670//---------------------------------------------------------------------
671void AliTOF::Hits2SDigits(Int_t evNumber1, Int_t evNumber2)
672{
673//
674// Use the TOF SDigitizer to make TOF SDigits
675//
676
677 if ((evNumber2-evNumber1)==1)
d076c8d5 678 AliDebug(1, Form("I am making sdigits for the %dth event", evNumber1))
d61f73d9 679 else if ((evNumber2-evNumber1)>1)
d076c8d5 680 AliDebug(1, Form("I am making sdigits for the events from the "
681 "%dth to the %dth", evNumber1, evNumber2-1));
d61f73d9 682
be385a87 683 AliRunLoader * rl = fLoader->GetRunLoader();
684 AliTOFSDigitizer sd((rl->GetFileName()).Data(),evNumber1,evNumber2) ;
d076c8d5 685 ToAliDebug(1, sd.Print(""));
68861244 686
be385a87 687 sd.Exec("") ;
d61f73d9 688
2cef3cb2 689}
d61f73d9 690
2cef3cb2 691//___________________________________________________________________________
c92eb8ad 692AliDigitizer* AliTOF::CreateDigitizer(AliRunDigitizer* manager) const
85a5290f 693{
694 return new AliTOFDigitizer(manager);
695}
696
697//___________________________________________________________________________
2cef3cb2 698Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
b94fa26c 699{
2cef3cb2 700//
701// Checks if 2 or more hits belong to the same pad.
702// In this case the data assigned to the digit object
703// are the ones of the first hit in order of Time.
517b7f8f 704// 2 hits from the same track on the same pad are collected.
705// Called only by Hits2SDigits.
706// This procedure has to be optimized in the next TOF release.
2cef3cb2 707//
b94fa26c 708
517b7f8f 709 Bool_t overlap = kFALSE;
2cef3cb2 710 Int_t vol2[5];
711
517b7f8f 712 for (Int_t ndig=0; ndig<fSDigits->GetEntries(); ndig++){
713 AliTOFdigit* currentDigit = (AliTOFdigit*)(fSDigits->UncheckedAt(ndig));
2cef3cb2 714 currentDigit->GetLocation(vol2);
517b7f8f 715 Bool_t idem= kTRUE;
716 // check on digit volume
2cef3cb2 717 for (Int_t i=0;i<=4;i++){
517b7f8f 718 if (!idem) break;
719 if (vol[i]!=vol2[i]) idem=kFALSE;}
720
721 if (idem){ // same pad fired
b94fa26c 722 Float_t tdc2 = digit[0];
723 Float_t tdc1 = currentDigit->GetTdc();
517b7f8f 724
725 // we separate two digits on the same pad if
726 // they are separated in time by at least 25 ns
727 // remember that tdc time is given in ps
728
729 if (TMath::Abs(tdc1-tdc2)<25000){
730 // in case of overlap we take the earliest
731 if (tdc1>tdc2){
732 currentDigit->SetTdc(tdc2);
733 currentDigit->SetAdc(digit[1]);
734 }
735 else {
736 currentDigit->SetTdc(tdc1);
737 currentDigit->SetAdc(digit[1]);
738 }
739 currentDigit->AddTrack(Track); // add track number in the track array
517b7f8f 740 overlap = kTRUE;
f3de6e9e 741 return overlap;
742 } else
743 overlap= kFALSE;
517b7f8f 744
745 } // close if (idem) -> two digits on the same TOF pad
746
747 } // end loop on existing sdigits
748
b94fa26c 749 return overlap;
2cef3cb2 750}
751
752
753//____________________________________________________________________________
7e6dce66 754void AliTOF::Digits2Raw()
b94fa26c 755{
2cef3cb2 756//
7e6dce66 757// Starting from the TOF digits, writes the Raw Data objects
2cef3cb2 758//
759
7e6dce66 760 fLoader->LoadDigits();
2cef3cb2 761
7e6dce66 762 TTree* digits = fLoader->TreeD();
763 if (!digits) {
d076c8d5 764 AliError("no digits tree");
7e6dce66 765 return;
766 }
2cef3cb2 767
7e6dce66 768 AliTOFDDLRawData rawWriter;
769 rawWriter.SetVerbose(0);
2cef3cb2 770
d076c8d5 771 AliInfo("Formatting raw data for TOF");
7e6dce66 772 digits->GetEvent(0);
773 rawWriter.RawDataTOF(digits->GetBranch("TOF"));
2cef3cb2 774
7e6dce66 775 fLoader->UnloadDigits();
776
777}
55991c8b 778////////////////////////////////////////////////////////////////////////
779void AliTOF::RecreateSDigitsArray() {
780//
781// delete TClonesArray fSDigits and create it again
782// needed for backward compatability with PPR test production
783//
784 delete fSDigits;
785 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
786}
787////////////////////////////////////////////////////////////////////////
788void AliTOF::CreateSDigitsArray() {
789//
790// create TClonesArray fSDigits
791// needed for backward compatability with PPR test production
792//
793 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
794}
596a855f 795