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.33 2002/02/19 10:39:38 vicinanz
19 t0 classes added and material update (steel added)
21 Revision 1.31 2001/11/22 11:22:51 hristov
22 Updated version of TOF digitization, N^2 problem solved (J.Chudoba)
24 Revision 1.30 2001/10/21 18:30:39 hristov
25 Several pointers were set to zero in the default constructors to avoid memory management problems
27 Revision 1.29 2001/10/17 14:19:24 hristov
28 delete replaced by delete []
30 Revision 1.28 2001/10/05 12:02:01 vicinanz
31 Minor improvements on Merger and SDigitizer
33 Revision 1.27 2001/10/02 13:03:13 vicinanz
34 Minor improvements on the code
36 Revision 1.26 2001/09/27 10:39:20 vicinanz
37 SDigitizer and Merger added
39 Revision 1.25 2001/09/07 08:37:40 hristov
40 Pointers initialised to 0 in the default constructor
42 Revision 1.24 2001/09/05 16:31:00 hristov
43 The deletion of TOF folders temporarily commented out
45 Revision 1.23 2001/08/29 12:59:01 vicinanz
46 Minor changes to the Digitizer procedure
48 Revision 1.22 2001/08/28 08:45:58 vicinanz
49 TTask and TFolder structures implemented
51 Revision 1.21 2001/05/16 14:57:24 alibrary
52 New files for folders and Stack
54 Revision 1.20 2001/05/04 10:09:47 vicinanz
55 Major upgrades to the strip structure
57 Revision 1.19 2001/03/12 17:47:25 hristov
58 Changes needed on Sun with CC 5.0
60 Revision 1.18 2001/01/26 19:57:42 hristov
61 Major upgrade of AliRoot code
63 Revision 1.17 2000/10/19 09:58:14 vicinanz
64 Updated Hits2Digit procedure
66 Revision 1.16 2000/10/02 21:28:17 fca
67 Removal of useless dependecies via forward declarations
69 Revision 1.15 2000/05/18 14:33:01 vicinanz
70 Modified to be full HP compliant
72 Revision 1.14 2000/05/15 19:32:36 fca
75 Revision 1.13 2000/05/10 16:52:18 vicinanz
76 New TOF version with holes for PHOS/RICH
78 Revision 1.11.2.1 2000/05/10 09:37:15 vicinanz
79 New version with Holes for PHOS/RICH
81 Revision 1.11 1999/11/05 22:39:06 fca
84 Revision 1.10 1999/11/01 20:41:57 fca
85 Added protections against using the wrong version of FRAME
87 Revision 1.9 1999/10/15 15:35:19 fca
88 New version for frame1099 with and without holes
90 Revision 1.9 1999/09/29 09:24:33 fca
91 Introduction of the Copyright and cvs Log
95 ///////////////////////////////////////////////////////////////////////////////
98 // This class contains the basic functions for the Time Of Flight //
99 // detector. Functions specific to one particular geometry are //
100 // contained in the derived classes //
102 // VERSIONE WITH 5 SYMMETRIC MODULES ALONG Z AXIS
103 // ==============================================
105 // VERSION WITH HOLES FOR PHOS AND TRD IN SPACEFRAME WITH HOLES
107 // Volume sensibile : FPAD
113 <img src="picts/AliTOFClass.gif">
119 ///////////////////////////////////////////////////////////////////////////////
121 #include <iostream.h>
122 #include <strstream.h>
127 #include "AliTOFhit.h"
128 #include "AliTOFhitT0.h"
129 #include "AliTOFdigit.h"
130 #include "AliTOFSDigit.h"
131 #include "AliTOFRawSector.h"
132 #include "AliTOFRoc.h"
133 #include "AliTOFRawDigit.h"
148 #include "AliConst.h"
153 //_____________________________________________________________________________
157 // Default constructor
173 //_____________________________________________________________________________
174 AliTOF::AliTOF(const char *name, const char *title, Option_t *option)
175 : AliDetector(name,title)
178 // AliTOF standard constructor
180 // Here are fixed some important parameters
183 // Initialization of hits, sdigits and digits array
184 // added option for time zero analysis
185 if (strstr(option,"tzero")){
186 fHits = new TClonesArray("AliTOFhitT0", 1000);
187 cout << "tzero option requires AliTOFv4T0 as TOF version (check Your Config.C)" << endl;
189 fHits = new TClonesArray("AliTOFhit", 1000);
191 gAlice->AddHitList(fHits);
193 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
194 fDigits = new TClonesArray("AliTOFdigit", 1000);
196 // Digitization parameters
198 // (Transfer Functions to be inserted here)
204 // General Geometrical Parameters
205 fNTof = 18; // number of sectors
208 fZlenC = 177.5;//cm length of module C
209 fZlenB = 141.0;//cm length of module B
210 fZlenA = 106.0;//cm length of module A
211 fZtof = 371.5;//cm total semi-length of TOF detector
214 fStripLn = 122.0;//cm Strip Length
215 fSpace = 5.5;//cm Space Beetween the strip and the bottom of the plate
216 fDeadBndZ= 1.5;//cm Dead Boundaries of a Strip along Z direction (width)
217 fDeadBndX= 1.0;//cm Dead Boundaries of a Strip along X direction (length)
218 fXpad = 2.5;//cm X size of a pad
219 fZpad = 3.5;//cm Z size of a pad
220 fGapA = 4.; //cm Gap beetween tilted strip in A-type plate
221 fGapB = 6.; //cm Gap beetween tilted strip in B-type plate
222 fOverSpc = 15.3;//cm Space available for sensitive layers in radial direction
223 fNpadX = 48; // Number of pads in a strip along the X direction
224 fNpadZ = 2; // Number of pads in a strip along the Z direction
225 fPadXStr = fNpadX*fNpadZ; //Number of pads per strip
226 fNStripA = 15; // number of strips in A type module
227 fNStripB = 19; // number of strips in B type module
228 fNStripC = 20; // number of strips in C type module
230 // Physical performances
234 // DAQ characteristics
235 // cfr. TOF-TDR pag. 105 for Glossary
236 // TARODA : TOF-ALICE Read Out and Data Acquisition system
237 fPadXSector = 8928; // number of pad per sector -with no holes-
238 // ((15+2*19+2*20)*(48*2))
239 fNRoc = 14; // number of Roc (Read Out Controller) (TARODA)
240 fNFec = 32; // number of Fec (Front-End electronic Card)
242 fNTdc = 32; // number of Tdc (Time to Digital Converter)
243 fNPadXRoc = (Int_t)fPadXSector/fNRoc; // number of pads for each ROC
245 // Create TOF Folder Structure
250 //_____________________________________________________________________________
251 void AliTOF::CreateTOFFolders()
253 // create the ALICE TFolder
254 // create the ALICE TTasks
255 // create the ALICE main TFolder
256 // to be done by AliRun
258 TFolder * alice = new TFolder();
259 alice->SetNameTitle("FPAlice", "Alice Folder") ;
260 gROOT->GetListOfBrowsables()->Add(alice) ;
262 TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ;
263 // make it the owner of the objects that it contains
266 TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ;
267 TFolder * aliceT = alice->AddFolder("tasks", "Alice tasks Folder") ;
268 // make it the owner of the objects that it contains
271 TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ;
272 aliceT->Add(aliceDi);
274 TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
275 aliceT->Add(aliceRe);
277 char * tempo = new char[80] ;
279 // creates the TOF Digitizer and adds it to alice main (S)Digitizer task
280 sprintf(tempo, "%sDigitizers container",GetName() ) ;
281 fDTask = new TTask(GetName(), tempo);
282 aliceDi->Add(fDTask) ;
284 // creates the TOF reconstructioner and adds it to alice main Reconstructioner task
285 sprintf(tempo, "%sReconstructioner container",GetName() ) ;
286 fReTask = new TTask(GetName(), tempo);
287 aliceRe->Add(fReTask) ;
291 // creates the TOF geometry folder
292 geomF->AddFolder("TOF", "Geometry for TOF") ;
295 //_____________________________________________________________________________
299 // it remove also the alice folder
300 // and task that TOF creates instead of AliRun
301 /* PH Temporarily commented because of problems
302 TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ;
326 fReconParticles->Delete ();
327 delete fReconParticles;
333 //_____________________________________________________________________________
334 void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits)
338 // new with placement used
340 TClonesArray &lhits = *fHits;
341 new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits);
344 //_____________________________________________________________________________
345 void AliTOF::AddT0Hit(Int_t track, Int_t *vol, Float_t *hits)
349 // new with placement used
351 TClonesArray &lhits = *fHits;
352 new(lhits[fNhits++]) AliTOFhitT0(fIshunt, track, vol, hits);
355 //_____________________________________________________________________________
356 void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
360 // new with placement used
362 TClonesArray &ldigits = *fDigits;
363 new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits);
366 //___________________________________________
367 void AliTOF::AddSDigit(Int_t tracknum, Int_t *vol, Float_t *digits)
374 TClonesArray &lSDigits = *fSDigits;
375 new(lSDigits[fNSDigits++]) AliTOFSDigit(tracknum, vol, digits);
378 //_____________________________________________________________________________
379 void AliTOF::SetTreeAddress ()
381 // Set branch address for the Hits and Digits Tree.
383 AliDetector::SetTreeAddress ();
386 TTree *treeD = gAlice->TreeD ();
393 branch = treeD->GetBranch (branchname);
395 branch->SetAddress (&fDigits);
400 // fSDigits->Clear ();
402 if (gAlice->TreeS () && fSDigits)
404 branch = gAlice->TreeS ()->GetBranch ("TOF");
406 branch->SetAddress (&fSDigits);
409 if (gAlice->TreeR() && fReconParticles)
411 branch = gAlice->TreeR()->GetBranch("TOF");
412 if (branch) branch->SetAddress(&fReconParticles) ;
416 //_____________________________________________________________________________
417 void AliTOF::CreateGeometry()
420 // Common geometry code
424 <img src="picts/AliTOFv23.gif">
428 const Double_t kPi=TMath::Pi();
429 const Double_t kDegrad=kPi/180.;
431 Float_t xTof, yTof, wall;
433 // frame inbetween TOF modules
436 // Sizes of TOF module with its support etc..
437 xTof = 2.*(fRmin*TMath::Tan(10*kDegrad)-wall/2-.5);
440 // TOF module internal definitions
441 TOFpc(xTof, yTof, fZlenC, fZlenB, fZlenA, fZtof);
444 //_____________________________________________________________________________
445 void AliTOF::DrawModule() const
448 // Draw a shaded view of the common part of the TOF geometry
451 cout << " Drawing of AliTOF"<< endl;
452 // Set everything unseen
453 gMC->Gsatt("*", "seen", -1);
455 // Set ALIC mother transparent
456 gMC->Gsatt("ALIC","SEEN",0);
458 // Set the volumes visible
459 gMC->Gsatt("FTOA","SEEN",1);
460 gMC->Gsatt("FTOB","SEEN",1);
461 gMC->Gsatt("FTOC","SEEN",1);
462 gMC->Gsatt("FLTA","SEEN",1);
463 gMC->Gsatt("FLTB","SEEN",1);
464 gMC->Gsatt("FLTC","SEEN",1);
465 gMC->Gsatt("FSTR","SEEN",1);
467 gMC->Gdopt("hide", "on");
468 gMC->Gdopt("shad", "on");
469 gMC->Gsatt("*", "fill", 7);
470 gMC->SetClipBox(".");
471 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
473 gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
474 gMC->Gdhead(1111, "Time Of Flight");
475 gMC->Gdman(18, 4, "MAN");
476 gMC->Gdopt("hide","off");
479 //_____________________________________________________________________________
480 void AliTOF::CreateMaterials()
483 // Defines TOF materials for all versions
484 // Authors : Maxim Martemianov, Boris Zagreev (ITEP)
486 // Revision: F. Pierella 5-3-2001
487 // Bologna University
489 Int_t isxfld = gAlice->Field()->Integ();
490 Float_t sxmgmx = gAlice->Field()->Max();
493 Float_t aq[2] = { 28.0855,15.9994 };
494 Float_t zq[2] = { 14.,8. };
495 Float_t wq[2] = { 1.,2. };
498 // --- Freon C2F4H2 (TOF-TDR pagg.)
499 // Geant Manual CONS110-1, pag. 43 (Geant, Detector Description and Simulation Tool)
500 Float_t afre[3] = {12.011,18.998,1.007};
501 Float_t zfre[3] = { 6., 9., 1.};
502 Float_t wfre[3] = { 2., 4., 2.};
503 Float_t densfre = 0.00375;
504 // http://www.fi.infn.it/sezione/prevprot/gas/freon.html
507 //-- Isobutane quencher C4H10 (5% in the sensitive mixture)
508 Float_t aiso[2] = {12.011,1.007};
509 Float_t ziso[2] = { 6., 1.};
510 Float_t wiso[2] = { 4., 10.};
511 Float_t densiso = .......; // (g/cm3) density
512 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
513 //-- SF6 (5% in the sensitive mixture)
514 Float_t asf[3] = {32.066,18.998};
515 Float_t zsf[3] = { 16., 9.};
516 Float_t wsf[3] = { 1., 6.};
517 Float_t denssf = .....; // (g/cm3) density
518 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
521 Float_t ac[2] = {12.,16.};
522 Float_t zc[2] = { 6., 8.};
523 Float_t wc[2] = { 1., 2.};
524 Float_t dc = .001977;
526 // For mylar (C5H4O2)
527 Float_t amy[3] = { 12., 1., 16. };
528 Float_t zmy[3] = { 6., 1., 8. };
529 Float_t wmy[3] = { 5., 4., 2. };
532 // For polyethilene (CH2) - honeycomb -
533 Float_t ape[2] = { 12., 1. };
534 Float_t zpe[2] = { 6., 1. };
535 Float_t wpe[2] = { 1., 2. };
536 Float_t dpe = 0.935*0.479; //To have 1%X0 for 1cm as for honeycomb
539 Float_t ag10[4] = { 12.,1.,16.,28. };
540 Float_t zg10[4] = { 6.,1., 8.,14. };
541 Float_t wmatg10[4] = { .259,.288,.248,.205 };
542 Float_t densg10 = 1.7;
545 Float_t adme[5] = { 12.,1.,16.,19.,79. };
546 Float_t zdme[5] = { 6.,1., 8., 9.,35. };
547 Float_t wmatdme[5] = { .4056,.0961,.2562,.1014,.1407 };
548 Float_t densdme = .00205;
550 // ---- ALUMINA (AL203)
551 Float_t aal[2] = { 27.,16.};
552 Float_t zal[2] = { 13., 8.};
553 Float_t wmatal[2] = { 2.,3. };
554 Float_t densal = 2.3;
557 Float_t awa[2] = { 1., 16. };
558 Float_t zwa[2] = { 1., 8. };
559 Float_t wwa[2] = { 2., 1. };
564 Float_t asteel[4] = { 55.847,51.9961,58.6934,28.0855 };
565 Float_t zsteel[4] = { 26.,24.,28.,14. };
566 Float_t wsteel[4] = { .715,.18,.1,.005 };
569 //AliMaterial(0, "Vacuum$", 1e-16, 1e-16, 1e-16, 1e16, 1e16);
570 AliMaterial( 1, "Air$",14.61,7.3,0.001205,30423.24,67500.);
571 AliMaterial( 2, "Cu $", 63.54, 29.0, 8.96, 1.43, 14.8);
572 AliMaterial( 3, "C $", 12.01, 6.0, 2.265,18.8, 74.4);
573 AliMixture ( 4, "Polyethilene$", ape, zpe, dpe, npe, wpe);
574 AliMixture ( 5, "G10$", ag10, zg10, densg10, nlmatg10, wmatg10);
575 AliMixture ( 6, "DME ", adme, zdme, densdme, nlmatdme, wmatdme);
576 AliMixture ( 7, "CO2$", ac, zc, dc, nc, wc);
577 AliMixture ( 8, "ALUMINA$", aal, zal, densal, nlmatal, wmatal);
578 AliMaterial( 9, "Al $", 26.98, 13., 2.7, 8.9, 37.2);
579 AliMaterial(10, "C-TRD$", 12.01, 6., 2.265*18.8/69.282*15./100, 18.8, 74.4); // for 15%
580 AliMixture (11, "Mylar$", amy, zmy, dmy, nmy, wmy);
581 AliMixture (12, "Freon$", afre, zfre, densfre, nfre, wfre);
582 AliMixture (13, "Quartz$", aq, zq, dq, nq, wq);
583 AliMixture (14, "Water$", awa, zwa, dwa, nwa, wwa);
584 AliMixture (15, "STAINLESS STEEL$", asteel, zsteel, 7.88, 4, wsteel);
586 Float_t epsil, stmin, deemax, stemax;
589 // EPSIL = 0.1 ! Tracking precision,
590 // STEMAX = 0.1 ! Maximum displacement for multiple scattering
591 // DEEMAX = 0.1 ! Maximum fractional energy loss, DLS
595 epsil = .001; // Tracking precision,
596 stemax = -1.; // Maximum displacement for multiple scattering
597 deemax = -.3; // Maximum fractional energy loss, DLS
600 AliMedium( 1, "Air$" , 1, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
601 AliMedium( 2, "Cu $" , 2, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
602 AliMedium( 3, "C $" , 3, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
603 AliMedium( 4, "Pol$" , 4, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
604 AliMedium( 5, "G10$" , 5, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
605 AliMedium( 6, "DME$" , 6, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
606 AliMedium( 7, "CO2$" , 7, 0, isxfld, sxmgmx, 10., -.01, -.1, .01, -.01);
607 AliMedium( 8,"ALUMINA$", 8, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
608 AliMedium( 9,"Al Frame$",9, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
609 AliMedium(10, "DME-S$", 6, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
610 AliMedium(11, "C-TRD$", 10, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
611 AliMedium(12, "Myl$" , 11, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
612 AliMedium(13, "Fre$" , 12, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
613 AliMedium(14, "Fre-S$", 12, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
614 AliMedium(15, "Glass$", 13, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
615 AliMedium(16, "Water$", 14, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
616 AliMedium(17, "STEEL$", 15, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
619 //_____________________________________________________________________________
620 Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t ) const
623 // Returns distance from mouse pointer to detector, default version
628 //___________________________________________
629 void AliTOF::ResetHits ()
631 // Reset number of clusters and the cluster array for this detector
632 AliDetector::ResetHits ();
635 //____________________________________________
636 void AliTOF::ResetDigits ()
639 // Reset number of digits and the digits array for this detector
640 AliDetector::ResetDigits ();
643 //_____________________________________________________________________________
647 // Initialise TOF detector after it has been built
649 // Set id of TOF sensitive volume
650 if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD");
654 //____________________________________________________________________________
655 void AliTOF::MakeBranch(Option_t* option, const char *file)
658 // Initializes the Branches of the TOF inside the
659 // trees written for each event.
660 // AliDetector::MakeBranch initializes just the
661 // Branch inside TreeH. Here we add the branches in
662 // TreeD, TreeS and TreeR.
664 AliDetector::MakeBranch(option,file);
666 Int_t buffersize = 4000;
667 Char_t branchname[10];
668 sprintf(branchname,"%s",GetName());
670 const char *oD = strstr(option,"D");
671 const char *oS = strstr(option,"S");
672 const char *oR = strstr(option,"R");
676 // one branch for TOF digits
680 if (fDigits && gAlice->TreeD() && oD){
681 MakeBranchInTree(gAlice->TreeD(),
682 branchname, &fDigits,buffersize, file) ;
687 // one branch for TOF sdigits
691 if (fSDigits && gAlice->TreeS() && oS){
692 MakeBranchInTree(gAlice->TreeS(),
693 branchname, &fSDigits,buffersize, file) ;
698 // one branch for TOF reconstructed particles
702 if (fReconParticles && gAlice->TreeR() && oR){
703 MakeBranchInTree(gAlice->TreeR(),
704 branchname, &fReconParticles,buffersize, file) ;
709 //____________________________________________________________________________
710 void AliTOF::Makehits(Bool_t hits)
712 // default argument used, see AliTOF.h
713 // Enable/Disable the writing of the TOF-hits branch
715 // by default : enabled for TOFv1, v2, v3, v4
716 // disabled for TOFv0
718 if (hits && (IsVersion()!=0))
719 fIdSens = gMC->VolId("FPAD");
721 cout << "Option for writing the TOF-hits branch on TreeH: disabled" << endl;
724 //____________________________________________________________________________
725 void AliTOF::FinishEvent()
730 //___________________________________________
731 void AliTOF::SDigits2Digits()
734 // Generate digits performing merging
737 int nparticles = gAlice->GetNtrack();
738 cout << "Particles :" <<nparticles<<endl;
739 if (nparticles > 0 ) {
741 AliTOF::Hits2Digits();
745 cout<<"AliTOF::SDigits2Digits"<<endl;
748 cout<<"AliTOF::SDigits2Digits Init"<<endl;
750 cout<<"AliTOF::SDigits2Digits Digitise() "<<endl;
754 //---------------------------------------------------------------------
755 void AliTOF::SetMerger(AliTOFMerger* merger)
757 // Set pointer to merger
761 //---------------------------------------------------------------------
762 AliTOFMerger* AliTOF::Merger()
764 // Return pointer to merger
769 //---------------------------------------------------------------------
771 void AliTOF::Hits2SDigits()
774 // Use the TOF SDigitizer to make TOF SDigits
778 cout<<"ALiTOF::Hits2SDigits> start...\n";
781 char * fileSDigits = 0 ;
782 char * fileHeader = 0;
783 AliTOFSDigitizer * sd = new AliTOFSDigitizer(fileHeader,fileSDigits) ;
791 //___________________________________________________________________________
792 Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
795 // Checks if 2 or more hits belong to the same pad.
796 // In this case the data assigned to the digit object
797 // are the ones of the first hit in order of Time.
798 // 2 hits from the same track on the same pad are collected.
799 // Called only by Hits2SDigits.
800 // This procedure has to be optimized in the next TOF release.
803 Bool_t overlap = kFALSE;
806 for (Int_t ndig=0; ndig<fSDigits->GetEntries(); ndig++){
807 AliTOFdigit* currentDigit = (AliTOFdigit*)(fSDigits->UncheckedAt(ndig));
808 currentDigit->GetLocation(vol2);
810 // check on digit volume
811 for (Int_t i=0;i<=4;i++){
813 if (vol[i]!=vol2[i]) idem=kFALSE;}
815 if (idem){ // same pad fired
816 Float_t tdc2 = digit[0];
817 Float_t tdc1 = currentDigit->GetTdc();
819 // we separate two digits on the same pad if
820 // they are separated in time by at least 25 ns
821 // remember that tdc time is given in ps
823 if (TMath::Abs(tdc1-tdc2)<25000){
824 // in case of overlap we take the earliest
826 currentDigit->SetTdc(tdc2);
827 currentDigit->SetAdc(digit[1]);
830 currentDigit->SetTdc(tdc1);
831 currentDigit->SetAdc(digit[1]);
833 currentDigit->AddTrack(Track); // add track number in the track array
839 } // close if (idem) -> two digits on the same TOF pad
841 } // end loop on existing sdigits
847 //____________________________________________________________________________
848 void AliTOF::Digits2Raw(Int_t evNumber)
851 // Starting from digits, writes the
852 // Raw Data objects, i.e. a
853 // TClonesArray of 18 AliTOFRawSector objects
858 // do nothing if no particles
859 Int_t nparticles = gAlice->GetEvent(evNumber);
860 if (nparticles <= 0) return;
862 tD = gAlice->TreeD();
864 TClonesArray* tofdigits = this->Digits();
865 Int_t ndigits = tofdigits->GetEntriesFast();
867 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
869 for (Int_t isect=1;isect<=fNTof;isect++){
870 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(isect);
871 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
873 for (Int_t digit=0; digit<ndigits; digit++){
874 AliTOFdigit* currentDigit = (AliTOFdigit*)tofdigits->UncheckedAt(digit);
875 Int_t sector = currentDigit->GetSector();
877 Int_t pad = currentDigit -> GetTotPad();
878 Int_t roc = (Int_t)(pad/fNPadXRoc)-1;
879 if (roc>=fNRoc) printf("Wrong n. of ROC ! Roc = %i",roc);
880 Int_t padRoc = (Int_t) pad%fNPadXRoc;
881 Int_t fec = (Int_t)(padRoc/fNFec)-1;
882 Int_t tdc = (Int_t)(padRoc%fNFec)-1;
883 Float_t time = currentDigit->GetTdc();
884 Float_t charge = currentDigit->GetAdc();
885 AliTOFRoc* currentROC = (AliTOFRoc*)rocData->UncheckedAt(roc);
887 currentROC->AddItem(fec, tdc, error, charge, time);
888 } // close if (sector==isect) i.e. end loop on digits for the current sector
889 } // end loop on TOF digits
891 UInt_t totSize=16,rocSize=0;
892 UInt_t rocHead[14],rocChek[14];
893 UInt_t globalCheckSum=0;
895 for (UInt_t iRoc = 1; iRoc<(UInt_t)fNRoc; iRoc++){
896 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(iRoc);
897 rocSize = currentRoc->GetItems()*2+1;
898 totSize += rocSize*4;
899 if (rocSize>=TMath::Power(2,16)) rocSize=0;
900 rocHead[iRoc] = iRoc<<28;
901 rocHead[iRoc] += rocSize;
902 rocChek[iRoc] = currentRoc->GetCheckSum();
903 Int_t headCheck = currentRoc->BitCount(rocHead[iRoc]);
904 globalCheckSum += headCheck;
905 globalCheckSum += rocChek[iRoc];
908 AliTOFRoc* dummyRoc = new AliTOFRoc();
910 if (totSize>=TMath::Power(2,24)) totSize=0;
911 UInt_t header = totSize;
912 UInt_t sectId = ((UInt_t)isect)<<24;
914 globalCheckSum += dummyRoc->BitCount(header);
915 currentSector->SetGlobalCS(globalCheckSum);
916 currentSector->SetHeader(header);
920 //____________________________________________________________________________
921 void AliTOF::Raw2Digits(Int_t evNumber)
924 // Converts Raw Data objects into digits objects.
925 // We schematize the raw data with a
926 // TClonesArray of 18 AliTOFRawSector objects
938 Int_t nparticles = gAlice->GetEvent(evNumber);
939 if (nparticles <= 0) return;
941 tD = gAlice->TreeD();
943 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
945 for(Int_t nSec=1; nSec<=fNTof; nSec++){
946 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(nSec);
947 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
948 for(Int_t nRoc=1; nRoc<=14; nRoc++){
949 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(nRoc);
950 Int_t currentItems = currentRoc->GetItems();
951 for(Int_t item=1; item<currentItems; item++){
952 Int_t nPad = currentRoc->GetTotPad(item);
954 Int_t nStrip = (Int_t)(nPad/fPadXStr)+1;
956 if (nStrip<=fNStripC+2*fNStripB+fNStripA) nPlate = 4;
957 if (nStrip<=fNStripC+fNStripB+fNStripA) nPlate = 3;
958 if (nStrip<=fNStripC+fNStripB) nPlate = 2;
959 if (nStrip<=fNStripC) nPlate=1;
963 case 2: nStrip -= (fNStripC);
965 case 3: nStrip -= (fNStripC+fNStripB);
967 case 4: nStrip -= (fNStripC+fNStripB+fNStripA);
969 case 5: nStrip -= (fNStripC+2*fNStripB+fNStripA);
973 Int_t pad = nPad%fPadXStr;
974 if (pad==0) pad=fPadXStr;
975 Int_t nPadX=0, nPadZ=0;
976 (pad>fNpadX)? nPadX -= fNpadX : nPadX = pad ;
978 (pad>fNpadX)? nPadZ = 2 : nPadZ = 1 ;
981 Float_t tdc = currentRoc->GetTime(item,error);
982 if (!error) digit[0]=tdc;
983 digit[1] = currentRoc->GetCharge(item);
984 AddDigit(tracks,vol,digit);
989 tD->Write(0,TObject::kOverwrite);