1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.38 2002/06/13 08:43:46 vicinanz
19 Merging added and test macro
21 Revision 1.37 2002/05/03 07:34:19 vicinanz
22 Updated SDigitizer; Added AliTOFanalyzeSDigits.C macro
24 Revision 1.36 2002/04/19 14:40:51 vicinanz
27 Revision 1.35 2002/03/21 13:52:53 vicinanz
28 Minor changes to AliTOF constructor
30 Revision 1.34 2002/02/20 13:41:38 hristov
31 Default arguments set only in the header file
33 Revision 1.33 2002/02/19 10:39:38 vicinanz
34 t0 classes added and material update (steel added)
36 Revision 1.31 2001/11/22 11:22:51 hristov
37 Updated version of TOF digitization, N^2 problem solved (J.Chudoba)
39 Revision 1.30 2001/10/21 18:30:39 hristov
40 Several pointers were set to zero in the default constructors to avoid memory management problems
42 Revision 1.29 2001/10/17 14:19:24 hristov
43 delete replaced by delete []
45 Revision 1.28 2001/10/05 12:02:01 vicinanz
46 Minor improvements on Merger and SDigitizer
48 Revision 1.27 2001/10/02 13:03:13 vicinanz
49 Minor improvements on the code
51 Revision 1.26 2001/09/27 10:39:20 vicinanz
52 SDigitizer and Merger added
54 Revision 1.25 2001/09/07 08:37:40 hristov
55 Pointers initialised to 0 in the default constructor
57 Revision 1.24 2001/09/05 16:31:00 hristov
58 The deletion of TOF folders temporarily commented out
60 Revision 1.23 2001/08/29 12:59:01 vicinanz
61 Minor changes to the Digitizer procedure
63 Revision 1.22 2001/08/28 08:45:58 vicinanz
64 TTask and TFolder structures implemented
66 Revision 1.21 2001/05/16 14:57:24 alibrary
67 New files for folders and Stack
69 Revision 1.20 2001/05/04 10:09:47 vicinanz
70 Major upgrades to the strip structure
72 Revision 1.19 2001/03/12 17:47:25 hristov
73 Changes needed on Sun with CC 5.0
75 Revision 1.18 2001/01/26 19:57:42 hristov
76 Major upgrade of AliRoot code
78 Revision 1.17 2000/10/19 09:58:14 vicinanz
79 Updated Hits2Digit procedure
81 Revision 1.16 2000/10/02 21:28:17 fca
82 Removal of useless dependecies via forward declarations
84 Revision 1.15 2000/05/18 14:33:01 vicinanz
85 Modified to be full HP compliant
87 Revision 1.14 2000/05/15 19:32:36 fca
90 Revision 1.13 2000/05/10 16:52:18 vicinanz
91 New TOF version with holes for PHOS/RICH
93 Revision 1.11.2.1 2000/05/10 09:37:15 vicinanz
94 New version with Holes for PHOS/RICH
96 Revision 1.11 1999/11/05 22:39:06 fca
99 Revision 1.10 1999/11/01 20:41:57 fca
100 Added protections against using the wrong version of FRAME
102 Revision 1.9 1999/10/15 15:35:19 fca
103 New version for frame1099 with and without holes
105 Revision 1.9 1999/09/29 09:24:33 fca
106 Introduction of the Copyright and cvs Log
110 ///////////////////////////////////////////////////////////////////////////////
113 // This class contains the basic functions for the Time Of Flight //
114 // detector. Functions specific to one particular geometry are //
115 // contained in the derived classes //
117 // VERSIONE WITH 5 SYMMETRIC MODULES ALONG Z AXIS
118 // ==============================================
120 // VERSION WITH HOLES FOR PHOS AND TRD IN SPACEFRAME WITH HOLES
122 // Volume sensibile : FPAD
128 <img src="picts/AliTOFClass.gif">
134 ///////////////////////////////////////////////////////////////////////////////
136 #include <iostream.h>
137 #include <strstream.h>
142 #include "AliTOFhit.h"
143 #include "AliTOFhitT0.h"
144 #include "AliTOFdigit.h"
145 #include "AliTOFSDigit.h"
146 #include "AliTOFRawSector.h"
147 #include "AliTOFRoc.h"
148 #include "AliTOFRawDigit.h"
163 #include "AliConst.h"
168 //_____________________________________________________________________________
172 // Default constructor
181 fReconParticles = 0x0;
189 //_____________________________________________________________________________
190 AliTOF::AliTOF(const char *name, const char *title, Option_t *option)
191 : AliDetector(name,title)
194 // AliTOF standard constructor
196 // Here are fixed some important parameters
199 // Initialization of hits, sdigits and digits array
200 // added option for time zero analysis
201 if (strstr(option,"tzero")){
202 fHits = new TClonesArray("AliTOFhitT0", 1000);
203 cout << "tzero option requires AliTOFv4T0 as TOF version (check Your Config.C)" << endl;
205 fHits = new TClonesArray("AliTOFhit", 1000);
207 gAlice->AddHitList(fHits);
209 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
210 fDigits = new TClonesArray("AliTOFdigit", 1000);
216 fReconParticles = 0x0;
220 // Digitization parameters
222 // (Transfer Functions to be inserted here)
228 // General Geometrical Parameters
229 fNTof = 18; // number of sectors
232 fZlenC = 177.5;//cm length of module C
233 fZlenB = 141.0;//cm length of module B
234 fZlenA = 106.0;//cm length of module A
235 fZtof = 371.5;//cm total semi-length of TOF detector
238 fStripLn = 122.0;//cm Strip Length
239 fSpace = 5.5;//cm Space Beetween the strip and the bottom of the plate
240 fDeadBndZ= 1.5;//cm Dead Boundaries of a Strip along Z direction (width)
241 fDeadBndX= 1.0;//cm Dead Boundaries of a Strip along X direction (length)
242 fXpad = 2.5;//cm X size of a pad
243 fZpad = 3.5;//cm Z size of a pad
244 fGapA = 4.; //cm Gap beetween tilted strip in A-type plate
245 fGapB = 6.; //cm Gap beetween tilted strip in B-type plate
246 fOverSpc = 15.3;//cm Space available for sensitive layers in radial direction
247 fNpadX = 48; // Number of pads in a strip along the X direction
248 fNpadZ = 2; // Number of pads in a strip along the Z direction
249 fPadXStr = fNpadX*fNpadZ; //Number of pads per strip
250 fNStripA = 15; // number of strips in A type module
251 fNStripB = 19; // number of strips in B type module
252 fNStripC = 20; // number of strips in C type module
254 // Physical performances
258 // DAQ characteristics
259 // cfr. TOF-TDR pag. 105 for Glossary
260 // TARODA : TOF-ALICE Read Out and Data Acquisition system
261 fPadXSector = 8928; // number of pad per sector -with no holes-
262 // ((15+2*19+2*20)*(48*2))
263 fNRoc = 14; // number of Roc (Read Out Controller) (TARODA)
264 fNFec = 32; // number of Fec (Front-End electronic Card)
266 fNTdc = 32; // number of Tdc (Time to Digital Converter)
267 fNPadXRoc = (Int_t)fPadXSector/fNRoc; // number of pads for each ROC
269 // Create TOF Folder Structure
274 //_____________________________________________________________________________
275 void AliTOF::CreateTOFFolders()
277 // create the ALICE TFolder
278 // create the ALICE TTasks
279 // create the ALICE main TFolder
280 // to be done by AliRun
282 TFolder * alice = new TFolder();
283 alice->SetNameTitle("FPAlice", "Alice Folder") ;
284 gROOT->GetListOfBrowsables()->Add(alice) ;
286 TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ;
287 // make it the owner of the objects that it contains
290 TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ;
291 TFolder * aliceT = alice->AddFolder("tasks", "Alice tasks Folder") ;
292 // make it the owner of the objects that it contains
295 TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ;
296 aliceT->Add(aliceDi);
298 TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
299 aliceT->Add(aliceRe);
301 char * tempo = new char[80] ;
303 // creates the TOF Digitizer and adds it to alice main (S)Digitizer task
304 sprintf(tempo, "%sDigitizers container",GetName() ) ;
305 fDTask = new TTask(GetName(), tempo);
306 aliceDi->Add(fDTask) ;
308 // creates the TOF reconstructioner and adds it to alice main Reconstructioner task
309 sprintf(tempo, "%sReconstructioner container",GetName() ) ;
310 fReTask = new TTask(GetName(), tempo);
311 aliceRe->Add(fReTask) ;
315 // creates the TOF geometry folder
316 geomF->AddFolder("TOF", "Geometry for TOF") ;
319 //_____________________________________________________________________________
323 // it remove also the alice folder
324 // and task that TOF creates instead of AliRun
325 /* PH Temporarily commented because of problems
326 TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ;
350 fReconParticles->Delete ();
351 delete fReconParticles;
357 //_____________________________________________________________________________
358 void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits)
362 // new with placement used
364 TClonesArray &lhits = *fHits;
365 new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits);
368 //_____________________________________________________________________________
369 void AliTOF::AddT0Hit(Int_t track, Int_t *vol, Float_t *hits)
373 // new with placement used
375 TClonesArray &lhits = *fHits;
376 new(lhits[fNhits++]) AliTOFhitT0(fIshunt, track, vol, hits);
379 //_____________________________________________________________________________
380 void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
384 // new with placement used
386 TClonesArray &ldigits = *fDigits;
387 new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits);
390 //___________________________________________
391 void AliTOF::AddSDigit(Int_t tracknum, Int_t *vol, Float_t *digits)
398 TClonesArray &lSDigits = *fSDigits;
399 new(lSDigits[fNSDigits++]) AliTOFSDigit(tracknum, vol, digits);
402 //_____________________________________________________________________________
403 void AliTOF::SetTreeAddress ()
405 // Set branch address for the Hits and Digits Tree.
407 AliDetector::SetTreeAddress ();
410 TTree *treeD = gAlice->TreeD ();
417 branch = treeD->GetBranch (branchname);
419 branch->SetAddress (&fDigits);
424 // fSDigits->Clear ();
426 if (gAlice->TreeS () && fSDigits)
428 branch = gAlice->TreeS ()->GetBranch ("TOF");
430 branch->SetAddress (&fSDigits);
433 if (gAlice->TreeR() && fReconParticles)
435 branch = gAlice->TreeR()->GetBranch("TOF");
436 if (branch) branch->SetAddress(&fReconParticles) ;
440 //_____________________________________________________________________________
441 void AliTOF::CreateGeometry()
444 // Common geometry code
448 <img src="picts/AliTOFv23.gif">
452 const Double_t kPi=TMath::Pi();
453 const Double_t kDegrad=kPi/180.;
455 Float_t xTof, yTof, wall;
457 // frame inbetween TOF modules
460 // Sizes of TOF module with its support etc..
461 xTof = 2.*(fRmin*TMath::Tan(10*kDegrad)-wall/2-.5);
464 // TOF module internal definitions
465 TOFpc(xTof, yTof, fZlenC, fZlenB, fZlenA, fZtof);
468 //_____________________________________________________________________________
469 void AliTOF::DrawModule() const
472 // Draw a shaded view of the common part of the TOF geometry
475 cout << " Drawing of AliTOF"<< endl;
476 // Set everything unseen
477 gMC->Gsatt("*", "seen", -1);
479 // Set ALIC mother transparent
480 gMC->Gsatt("ALIC","SEEN",0);
482 // Set the volumes visible
483 gMC->Gsatt("FTOA","SEEN",1);
484 gMC->Gsatt("FTOB","SEEN",1);
485 gMC->Gsatt("FTOC","SEEN",1);
486 gMC->Gsatt("FLTA","SEEN",1);
487 gMC->Gsatt("FLTB","SEEN",1);
488 gMC->Gsatt("FLTC","SEEN",1);
489 gMC->Gsatt("FSTR","SEEN",1);
491 gMC->Gdopt("hide", "on");
492 gMC->Gdopt("shad", "on");
493 gMC->Gsatt("*", "fill", 7);
494 gMC->SetClipBox(".");
495 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
497 gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
498 gMC->Gdhead(1111, "Time Of Flight");
499 gMC->Gdman(18, 4, "MAN");
500 gMC->Gdopt("hide","off");
503 //_____________________________________________________________________________
504 void AliTOF::CreateMaterials()
507 // Defines TOF materials for all versions
508 // Revision: F. Pierella 18-VI-2002
511 Int_t isxfld = gAlice->Field()->Integ();
512 Float_t sxmgmx = gAlice->Field()->Max();
514 //--- Quartz (SiO2) to simulate float glass
515 // density tuned to have correct float glass
517 Float_t aq[2] = { 28.0855,15.9994 };
518 Float_t zq[2] = { 14.,8. };
519 Float_t wq[2] = { 1.,2. };
520 Float_t dq = 2.55; // std value: 2.2
523 // --- Freon C2F4H2 (TOF-TDR pagg.)
524 // Geant Manual CONS110-1, pag. 43 (Geant, Detector Description and Simulation Tool)
525 Float_t afre[3] = {12.011,18.998,1.007};
526 Float_t zfre[3] = { 6., 9., 1.};
527 Float_t wfre[3] = { 2., 4., 2.};
528 Float_t densfre = 0.00375;
529 // http://www.fi.infn.it/sezione/prevprot/gas/freon.html
532 //-- Isobutane quencher C4H10 (5% in the sensitive mixture)
533 Float_t aiso[2] = {12.011,1.007};
534 Float_t ziso[2] = { 6., 1.};
535 Float_t wiso[2] = { 4., 10.};
536 Float_t densiso = .......; // (g/cm3) density
537 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
538 //-- SF6 (5% in the sensitive mixture)
539 Float_t asf[3] = {32.066,18.998};
540 Float_t zsf[3] = { 16., 9.};
541 Float_t wsf[3] = { 1., 6.};
542 Float_t denssf = .....; // (g/cm3) density
543 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
546 Float_t ac[2] = {12.,16.};
547 Float_t zc[2] = { 6., 8.};
548 Float_t wc[2] = { 1., 2.};
549 Float_t dc = .001977;
551 // For mylar (C5H4O2)
552 Float_t amy[3] = { 12., 1., 16. };
553 Float_t zmy[3] = { 6., 1., 8. };
554 Float_t wmy[3] = { 5., 4., 2. };
557 // For polyethilene (CH2) - honeycomb -
558 Float_t ape[2] = { 12., 1. };
559 Float_t zpe[2] = { 6., 1. };
560 Float_t wpe[2] = { 1., 2. };
561 Float_t dpe = 0.935*0.479; //To have 1%X0 for 1cm as for honeycomb
564 Float_t ag10[4] = { 12.,1.,16.,28. };
565 Float_t zg10[4] = { 6.,1., 8.,14. };
566 Float_t wmatg10[4] = { .259,.288,.248,.205 };
567 Float_t densg10 = 1.7;
570 // plexiglass CH2=C(CH3)CO2CH3
571 Float_t aplex[3] = { 12.,1.,16.};
572 Float_t zplex[3] = { 6.,1., 8.};
573 Float_t wmatplex[3] = {5.,8.,2.};
574 Float_t densplex =1.16;
577 // ---- ALUMINA (AL203)
578 Float_t aal[2] = { 27.,16.};
579 Float_t zal[2] = { 13., 8.};
580 Float_t wmatal[2] = { 2.,3. };
581 Float_t densal = 2.3;
584 Float_t awa[2] = { 1., 16. };
585 Float_t zwa[2] = { 1., 8. };
586 Float_t wwa[2] = { 2., 1. };
591 Float_t asteel[4] = { 55.847,51.9961,58.6934,28.0855 };
592 Float_t zsteel[4] = { 26.,24.,28.,14. };
593 Float_t wsteel[4] = { .715,.18,.1,.005 };
596 //AliMaterial(0, "Vacuum$", 1e-16, 1e-16, 1e-16, 1e16, 1e16);
597 AliMaterial( 1, "Air$",14.61,7.3,0.001205,30423.24,67500.);
598 AliMaterial( 2, "Cu $", 63.54, 29.0, 8.96, 1.43, 14.8);
599 AliMaterial( 3, "C $", 12.01, 6.0, 2.265,18.8, 74.4);
600 AliMixture ( 4, "Polyethilene$", ape, zpe, dpe, npe, wpe);
601 AliMixture ( 5, "G10$", ag10, zg10, densg10, nlmatg10, wmatg10);
602 AliMixture ( 6, "PLE$", aplex, zplex, densplex, nplex, wmatplex);
603 AliMixture ( 7, "CO2$", ac, zc, dc, nc, wc);
604 AliMixture ( 8, "ALUMINA$", aal, zal, densal, nlmatal, wmatal);
605 AliMaterial( 9, "Al $", 26.98, 13., 2.7, 8.9, 37.2);
606 AliMaterial(10, "C-TRD$", 12.01, 6., 2.265*18.8/69.282*15./100, 18.8, 74.4); // for 15%
607 AliMixture (11, "Mylar$", amy, zmy, dmy, nmy, wmy);
608 AliMixture (12, "Freon$", afre, zfre, densfre, nfre, wfre);
609 AliMixture (13, "Glass$", aq, zq, dq, nq, wq);
610 AliMixture (14, "Water$", awa, zwa, dwa, nwa, wwa);
611 AliMixture (15, "STAINLESS STEEL$", asteel, zsteel, 7.88, 4, wsteel);
613 Float_t epsil, stmin, deemax, stemax;
616 // EPSIL = 0.1 ! Tracking precision,
617 // STEMAX = 0.1 ! Maximum displacement for multiple scattering
618 // DEEMAX = 0.1 ! Maximum fractional energy loss, DLS
622 epsil = .001; // Tracking precision,
623 stemax = -1.; // Maximum displacement for multiple scattering
624 deemax = -.3; // Maximum fractional energy loss, DLS
627 AliMedium( 1, "Air$" , 1, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
628 AliMedium( 2, "Cu $" , 2, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
629 AliMedium( 3, "C $" , 3, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
630 AliMedium( 4, "Pol$" , 4, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
631 AliMedium( 5, "G10$" , 5, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
632 AliMedium( 6, "PLE$" , 6, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
633 AliMedium( 7, "CO2$" , 7, 0, isxfld, sxmgmx, 10., -.01, -.1, .01, -.01);
634 AliMedium( 8,"ALUMINA$", 8, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
635 AliMedium( 9,"Al Frame$",9, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
636 AliMedium(10, "DME-S$", 6, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
637 AliMedium(11, "C-TRD$", 10, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
638 AliMedium(12, "Myl$" , 11, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
639 AliMedium(13, "Fre$" , 12, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
640 AliMedium(14, "Fre-S$", 12, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
641 AliMedium(15, "Glass$", 13, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
642 AliMedium(16, "Water$", 14, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
643 AliMedium(17, "STEEL$", 15, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
646 //_____________________________________________________________________________
647 Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t ) const
650 // Returns distance from mouse pointer to detector, default version
655 //___________________________________________
656 void AliTOF::ResetHits ()
658 // Reset number of clusters and the cluster array for this detector
659 AliDetector::ResetHits ();
662 //____________________________________________
663 void AliTOF::ResetDigits ()
666 // Reset number of digits and the digits array for this detector
667 AliDetector::ResetDigits ();
670 //_____________________________________________________________________________
674 // Initialise TOF detector after it has been built
676 // Set id of TOF sensitive volume
677 if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD");
681 //____________________________________________________________________________
682 void AliTOF::MakeBranch(Option_t* option, const char *file)
685 // Initializes the Branches of the TOF inside the
686 // trees written for each event.
687 // AliDetector::MakeBranch initializes just the
688 // Branch inside TreeH. Here we add the branches in
689 // TreeD, TreeS and TreeR.
691 AliDetector::MakeBranch(option,file);
693 Int_t buffersize = 4000;
694 Char_t branchname[10];
695 sprintf(branchname,"%s",GetName());
697 const char *oD = strstr(option,"D");
698 const char *oS = strstr(option,"S");
699 const char *oR = strstr(option,"R");
703 // one branch for TOF digits
707 if (fDigits && gAlice->TreeD() && oD){
708 MakeBranchInTree(gAlice->TreeD(),
709 branchname, &fDigits,buffersize, file) ;
714 // one branch for TOF sdigits
718 if (fSDigits && gAlice->TreeS() && oS){
719 MakeBranchInTree(gAlice->TreeS(),
720 branchname, &fSDigits,buffersize, file) ;
725 // one branch for TOF reconstructed particles
729 if (fReconParticles && gAlice->TreeR() && oR){
730 MakeBranchInTree(gAlice->TreeR(),
731 branchname, &fReconParticles,buffersize, file) ;
736 //____________________________________________________________________________
737 void AliTOF::Makehits(Bool_t hits)
739 // default argument used, see AliTOF.h
740 // Enable/Disable the writing of the TOF-hits branch
742 // by default : enabled for TOFv1, v2, v3, v4
743 // disabled for TOFv0
745 if (hits && (IsVersion()!=0))
746 fIdSens = gMC->VolId("FPAD");
748 cout << "Option for writing the TOF-hits branch on TreeH: disabled" << endl;
751 //____________________________________________________________________________
752 void AliTOF::FinishEvent()
757 //___________________________________________
758 void AliTOF::SDigits2Digits()
761 // Generate digits performing merging
764 int nparticles = gAlice->GetNtrack();
765 cout << "Particles :" <<nparticles<<endl;
766 if (nparticles > 0 ) {
768 AliTOF::Hits2Digits();
772 cout<<"AliTOF::SDigits2Digits"<<endl;
775 cout<<"AliTOF::SDigits2Digits Init"<<endl;
777 cout<<"AliTOF::SDigits2Digits Digitise() "<<endl;
781 //---------------------------------------------------------------------
782 void AliTOF::SetMerger(AliTOFMerger* merger)
784 // Set pointer to merger
788 //---------------------------------------------------------------------
789 AliTOFMerger* AliTOF::Merger()
791 // Return pointer to merger
796 //---------------------------------------------------------------------
798 void AliTOF::Hits2SDigits()
801 // Use the TOF SDigitizer to make TOF SDigits
805 cout<<"ALiTOF::Hits2SDigits> start...\n";
808 //char * fileSDigits = 0 ;
809 char * fileHeader = 0;
810 AliTOFSDigitizer * sd = new AliTOFSDigitizer(fileHeader) ;
818 //___________________________________________________________________________
819 Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
822 // Checks if 2 or more hits belong to the same pad.
823 // In this case the data assigned to the digit object
824 // are the ones of the first hit in order of Time.
825 // 2 hits from the same track on the same pad are collected.
826 // Called only by Hits2SDigits.
827 // This procedure has to be optimized in the next TOF release.
830 Bool_t overlap = kFALSE;
833 for (Int_t ndig=0; ndig<fSDigits->GetEntries(); ndig++){
834 AliTOFdigit* currentDigit = (AliTOFdigit*)(fSDigits->UncheckedAt(ndig));
835 currentDigit->GetLocation(vol2);
837 // check on digit volume
838 for (Int_t i=0;i<=4;i++){
840 if (vol[i]!=vol2[i]) idem=kFALSE;}
842 if (idem){ // same pad fired
843 Float_t tdc2 = digit[0];
844 Float_t tdc1 = currentDigit->GetTdc();
846 // we separate two digits on the same pad if
847 // they are separated in time by at least 25 ns
848 // remember that tdc time is given in ps
850 if (TMath::Abs(tdc1-tdc2)<25000){
851 // in case of overlap we take the earliest
853 currentDigit->SetTdc(tdc2);
854 currentDigit->SetAdc(digit[1]);
857 currentDigit->SetTdc(tdc1);
858 currentDigit->SetAdc(digit[1]);
860 currentDigit->AddTrack(Track); // add track number in the track array
866 } // close if (idem) -> two digits on the same TOF pad
868 } // end loop on existing sdigits
874 //____________________________________________________________________________
875 void AliTOF::Digits2Raw(Int_t evNumber)
878 // Starting from digits, writes the
879 // Raw Data objects, i.e. a
880 // TClonesArray of 18 AliTOFRawSector objects
885 // do nothing if no particles
886 Int_t nparticles = gAlice->GetEvent(evNumber);
887 if (nparticles <= 0) return;
889 tD = gAlice->TreeD();
891 TClonesArray* tofdigits = this->Digits();
892 Int_t ndigits = tofdigits->GetEntriesFast();
894 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
896 for (Int_t isect=1;isect<=fNTof;isect++){
897 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(isect);
898 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
900 for (Int_t digit=0; digit<ndigits; digit++){
901 AliTOFdigit* currentDigit = (AliTOFdigit*)tofdigits->UncheckedAt(digit);
902 Int_t sector = currentDigit->GetSector();
904 Int_t pad = currentDigit -> GetTotPad();
905 Int_t roc = (Int_t)(pad/fNPadXRoc)-1;
906 if (roc>=fNRoc) printf("Wrong n. of ROC ! Roc = %i",roc);
907 Int_t padRoc = (Int_t) pad%fNPadXRoc;
908 Int_t fec = (Int_t)(padRoc/fNFec)-1;
909 Int_t tdc = (Int_t)(padRoc%fNFec)-1;
910 Float_t time = currentDigit->GetTdc();
911 Float_t charge = currentDigit->GetAdc();
912 AliTOFRoc* currentROC = (AliTOFRoc*)rocData->UncheckedAt(roc);
914 currentROC->AddItem(fec, tdc, error, charge, time);
915 } // close if (sector==isect) i.e. end loop on digits for the current sector
916 } // end loop on TOF digits
918 UInt_t totSize=16,rocSize=0;
919 UInt_t rocHead[14],rocChek[14];
920 UInt_t globalCheckSum=0;
922 for (UInt_t iRoc = 1; iRoc<(UInt_t)fNRoc; iRoc++){
923 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(iRoc);
924 rocSize = currentRoc->GetItems()*2+1;
925 totSize += rocSize*4;
926 if (rocSize>=TMath::Power(2,16)) rocSize=0;
927 rocHead[iRoc] = iRoc<<28;
928 rocHead[iRoc] += rocSize;
929 rocChek[iRoc] = currentRoc->GetCheckSum();
930 Int_t headCheck = currentRoc->BitCount(rocHead[iRoc]);
931 globalCheckSum += headCheck;
932 globalCheckSum += rocChek[iRoc];
935 AliTOFRoc* dummyRoc = new AliTOFRoc();
937 if (totSize>=TMath::Power(2,24)) totSize=0;
938 UInt_t header = totSize;
939 UInt_t sectId = ((UInt_t)isect)<<24;
941 globalCheckSum += dummyRoc->BitCount(header);
942 currentSector->SetGlobalCS(globalCheckSum);
943 currentSector->SetHeader(header);
947 //____________________________________________________________________________
948 void AliTOF::Raw2Digits(Int_t evNumber)
951 // Converts Raw Data objects into digits objects.
952 // We schematize the raw data with a
953 // TClonesArray of 18 AliTOFRawSector objects
965 Int_t nparticles = gAlice->GetEvent(evNumber);
966 if (nparticles <= 0) return;
968 tD = gAlice->TreeD();
970 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
972 for(Int_t nSec=1; nSec<=fNTof; nSec++){
973 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(nSec);
974 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
975 for(Int_t nRoc=1; nRoc<=14; nRoc++){
976 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(nRoc);
977 Int_t currentItems = currentRoc->GetItems();
978 for(Int_t item=1; item<currentItems; item++){
979 Int_t nPad = currentRoc->GetTotPad(item);
981 Int_t nStrip = (Int_t)(nPad/fPadXStr)+1;
983 if (nStrip<=fNStripC+2*fNStripB+fNStripA) nPlate = 4;
984 if (nStrip<=fNStripC+fNStripB+fNStripA) nPlate = 3;
985 if (nStrip<=fNStripC+fNStripB) nPlate = 2;
986 if (nStrip<=fNStripC) nPlate=1;
990 case 2: nStrip -= (fNStripC);
992 case 3: nStrip -= (fNStripC+fNStripB);
994 case 4: nStrip -= (fNStripC+fNStripB+fNStripA);
996 case 5: nStrip -= (fNStripC+2*fNStripB+fNStripA);
1000 Int_t pad = nPad%fPadXStr;
1001 if (pad==0) pad=fPadXStr;
1002 Int_t nPadX=0, nPadZ=0;
1003 (pad>fNpadX)? nPadX -= fNpadX : nPadX = pad ;
1005 (pad>fNpadX)? nPadZ = 2 : nPadZ = 1 ;
1008 Float_t tdc = currentRoc->GetTime(item,error);
1009 if (!error) digit[0]=tdc;
1010 digit[1] = currentRoc->GetCharge(item);
1011 AddDigit(tracks,vol,digit);
1016 tD->Write(0,TObject::kOverwrite);
1019 ////////////////////////////////////////////////////////////////////////
1020 void AliTOF::RecreateSDigitsArray() {
1022 // delete TClonesArray fSDigits and create it again
1023 // needed for backward compatability with PPR test production
1026 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
1028 ////////////////////////////////////////////////////////////////////////
1029 void AliTOF::CreateSDigitsArray() {
1031 // create TClonesArray fSDigits
1032 // needed for backward compatability with PPR test production
1034 fSDigits = new TClonesArray("AliTOFSDigit", 1000);