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