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