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.28 2001/10/05 12:02:01 vicinanz
19 Minor improvements on Merger and SDigitizer
21 Revision 1.27 2001/10/02 13:03:13 vicinanz
22 Minor improvements on the code
24 Revision 1.26 2001/09/27 10:39:20 vicinanz
25 SDigitizer and Merger added
27 Revision 1.25 2001/09/07 08:37:40 hristov
28 Pointers initialised to 0 in the default constructor
30 Revision 1.24 2001/09/05 16:31:00 hristov
31 The deletion of TOF folders temporarily commented out
33 Revision 1.23 2001/08/29 12:59:01 vicinanz
34 Minor changes to the Digitizer procedure
36 Revision 1.22 2001/08/28 08:45:58 vicinanz
37 TTask and TFolder structures implemented
39 Revision 1.21 2001/05/16 14:57:24 alibrary
40 New files for folders and Stack
42 Revision 1.20 2001/05/04 10:09:47 vicinanz
43 Major upgrades to the strip structure
45 Revision 1.19 2001/03/12 17:47:25 hristov
46 Changes needed on Sun with CC 5.0
48 Revision 1.18 2001/01/26 19:57:42 hristov
49 Major upgrade of AliRoot code
51 Revision 1.17 2000/10/19 09:58:14 vicinanz
52 Updated Hits2Digit procedure
54 Revision 1.16 2000/10/02 21:28:17 fca
55 Removal of useless dependecies via forward declarations
57 Revision 1.15 2000/05/18 14:33:01 vicinanz
58 Modified to be full HP compliant
60 Revision 1.14 2000/05/15 19:32:36 fca
63 Revision 1.13 2000/05/10 16:52:18 vicinanz
64 New TOF version with holes for PHOS/RICH
66 Revision 1.11.2.1 2000/05/10 09:37:15 vicinanz
67 New version with Holes for PHOS/RICH
69 Revision 1.11 1999/11/05 22:39:06 fca
72 Revision 1.10 1999/11/01 20:41:57 fca
73 Added protections against using the wrong version of FRAME
75 Revision 1.9 1999/10/15 15:35:19 fca
76 New version for frame1099 with and without holes
78 Revision 1.9 1999/09/29 09:24:33 fca
79 Introduction of the Copyright and cvs Log
83 ///////////////////////////////////////////////////////////////////////////////
86 // This class contains the basic functions for the Time Of Flight //
87 // detector. Functions specific to one particular geometry are //
88 // contained in the derived classes //
90 // VERSIONE WITH 5 SYMMETRIC MODULES ALONG Z AXIS
91 // ==============================================
93 // VERSION WITH HOLES FOR PHOS AND TRD IN SPACEFRAME WITH HOLES
95 // Volume sensibile : FPAD
101 <img src="picts/AliTOFClass.gif">
107 ///////////////////////////////////////////////////////////////////////////////
109 #include <iostream.h>
110 #include <strstream.h>
115 #include "AliTOFhit.h"
116 #include "AliTOFdigit.h"
117 #include "AliTOFRawSector.h"
118 #include "AliTOFRoc.h"
119 #include "AliTOFRawDigit.h"
134 #include "AliConst.h"
139 //_____________________________________________________________________________
143 // Default constructor
157 //_____________________________________________________________________________
158 AliTOF::AliTOF(const char *name, const char *title)
159 : AliDetector(name,title)
162 // AliTOF standard constructor
164 // Here are fixed some important parameters
167 // Initialization of hits, sdigits and digits array
169 fHits = new TClonesArray("AliTOFhit", 1000);
170 gAlice->AddHitList(fHits);
172 fSDigits = new TClonesArray("AliTOFdigit", 1000);
173 fDigits = new TClonesArray("AliTOFdigit", 1000);
175 // Digitization parameters
177 // (Transfer Functions to be inserted here)
183 // General Geometrical Parameters
184 fNTof = 18; // number of sectors
187 fZlenC = 177.5;//cm length of module C
188 fZlenB = 141.0;//cm length of module B
189 fZlenA = 106.0;//cm length of module A
190 fZtof = 371.5;//cm total semi-length of TOF detector
193 fStripLn = 122.0;//cm Strip Length
194 fSpace = 5.5;//cm Space Beetween the strip and the bottom of the plate
195 fDeadBndZ= 1.5;//cm Dead Boundaries of a Strip along Z direction (width)
196 fDeadBndX= 1.0;//cm Dead Boundaries of a Strip along X direction (length)
197 fXpad = 2.5;//cm X size of a pad
198 fZpad = 3.5;//cm Z size of a pad
199 fGapA = 4.; //cm Gap beetween tilted strip in A-type plate
200 fGapB = 6.; //cm Gap beetween tilted strip in B-type plate
201 fOverSpc = 15.3;//cm Space available for sensitive layers in radial direction
202 fNpadX = 48; // Number of pads in a strip along the X direction
203 fNpadZ = 2; // Number of pads in a strip along the Z direction
204 fPadXStr = fNpadX*fNpadZ; //Number of pads per strip
205 fNStripA = 15; // number of strips in A type module
206 fNStripB = 19; // number of strips in B type module
207 fNStripC = 20; // number of strips in C type module
209 // Physical performances
213 // DAQ characteristics
214 // cfr. TOF-TDR pag. 105 for Glossary
215 // TARODA : TOF-ALICE Read Out and Data Acquisition system
216 fPadXSector = 8928; // number of pad per sector -with no holes-
217 // ((15+2*19+2*20)*(48*2))
218 fNRoc = 14; // number of Roc (Read Out Controller) (TARODA)
219 fNFec = 32; // number of Fec (Front-End electronic Card)
221 fNTdc = 32; // number of Tdc (Time to Digital Converter)
222 fNPadXRoc = (Int_t)fPadXSector/fNRoc; // number of pads for each ROC
224 // Create TOF Folder Structure
229 //_____________________________________________________________________________
230 void AliTOF::CreateTOFFolders()
232 // create the ALICE TFolder
233 // create the ALICE TTasks
234 // create the ALICE main TFolder
235 // to be done by AliRun
237 TFolder * alice = new TFolder();
238 alice->SetNameTitle("FPAlice", "Alice Folder") ;
239 gROOT->GetListOfBrowsables()->Add(alice) ;
241 TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ;
242 // make it the owner of the objects that it contains
245 TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ;
246 TFolder * aliceT = alice->AddFolder("tasks", "Alice tasks Folder") ;
247 // make it the owner of the objects that it contains
250 TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ;
251 aliceT->Add(aliceDi);
253 TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
254 aliceT->Add(aliceRe);
256 char * tempo = new char[80] ;
258 // creates the TOF Digitizer and adds it to alice main (S)Digitizer task
259 sprintf(tempo, "%sDigitizers container",GetName() ) ;
260 fDTask = new TTask(GetName(), tempo);
261 aliceDi->Add(fDTask) ;
263 // creates the TOF reconstructioner and adds it to alice main Reconstructioner task
264 sprintf(tempo, "%sReconstructioner container",GetName() ) ;
265 fReTask = new TTask(GetName(), tempo);
266 aliceRe->Add(fReTask) ;
270 // creates the TOF geometry folder
271 geomF->AddFolder("TOF", "Geometry for TOF") ;
274 //_____________________________________________________________________________
278 // it remove also the alice folder
279 // and task that TOF creates instead of AliRun
280 /* PH Temporarily commented because of problems
281 TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ;
305 fReconParticles->Delete ();
306 delete fReconParticles;
312 //_____________________________________________________________________________
313 void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits)
317 // new with placement used
319 TClonesArray &lhits = *fHits;
320 new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits);
323 //_____________________________________________________________________________
324 void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
328 // new with placement used
330 TClonesArray &ldigits = *fDigits;
331 new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits);
334 //___________________________________________
335 void AliTOF::AddSDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
342 TClonesArray &lSDigits = *fSDigits;
343 new(lSDigits[fNSDigits++]) AliTOFdigit(tracks, vol, digits);
346 //_____________________________________________________________________________
347 void AliTOF::SetTreeAddress ()
349 // Set branch address for the Hits and Digits Tree.
351 AliDetector::SetTreeAddress ();
354 TTree *treeD = gAlice->TreeD ();
361 branch = treeD->GetBranch (branchname);
363 branch->SetAddress (&fDigits);
368 // fSDigits->Clear ();
370 if (gAlice->TreeS () && fSDigits)
372 branch = gAlice->TreeS ()->GetBranch ("TOF");
374 branch->SetAddress (&fSDigits);
377 if (gAlice->TreeR() && fReconParticles)
379 branch = gAlice->TreeR()->GetBranch("TOF");
380 if (branch) branch->SetAddress(&fReconParticles) ;
384 //_____________________________________________________________________________
385 void AliTOF::CreateGeometry()
388 // Common geometry code
392 <img src="picts/AliTOFv23.gif">
396 const Double_t kPi=TMath::Pi();
397 const Double_t kDegrad=kPi/180.;
399 Float_t xTof, yTof, wall;
401 // frame inbetween TOF modules
404 // Sizes of TOF module with its support etc..
405 xTof = 2.*(fRmin*TMath::Tan(10*kDegrad)-wall/2-.5);
408 // TOF module internal definitions
409 TOFpc(xTof, yTof, fZlenC, fZlenB, fZlenA, fZtof);
412 //_____________________________________________________________________________
413 void AliTOF::DrawModule() const
416 // Draw a shaded view of the common part of the TOF geometry
419 cout << " Drawing of AliTOF"<< endl;
420 // Set everything unseen
421 gMC->Gsatt("*", "seen", -1);
423 // Set ALIC mother transparent
424 gMC->Gsatt("ALIC","SEEN",0);
426 // Set the volumes visible
427 gMC->Gsatt("FTOA","SEEN",1);
428 gMC->Gsatt("FTOB","SEEN",1);
429 gMC->Gsatt("FTOC","SEEN",1);
430 gMC->Gsatt("FLTA","SEEN",1);
431 gMC->Gsatt("FLTB","SEEN",1);
432 gMC->Gsatt("FLTC","SEEN",1);
433 gMC->Gsatt("FSTR","SEEN",1);
435 gMC->Gdopt("hide", "on");
436 gMC->Gdopt("shad", "on");
437 gMC->Gsatt("*", "fill", 7);
438 gMC->SetClipBox(".");
439 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
441 gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
442 gMC->Gdhead(1111, "Time Of Flight");
443 gMC->Gdman(18, 4, "MAN");
444 gMC->Gdopt("hide","off");
447 //_____________________________________________________________________________
448 void AliTOF::CreateMaterials()
451 // Defines TOF materials for all versions
452 // Authors : Maxim Martemianov, Boris Zagreev (ITEP)
454 // Revision: F. Pierella 5-3-2001
455 // Bologna University
457 Int_t isxfld = gAlice->Field()->Integ();
458 Float_t sxmgmx = gAlice->Field()->Max();
461 Float_t aq[2] = { 28.0855,15.9994 };
462 Float_t zq[2] = { 14.,8. };
463 Float_t wq[2] = { 1.,2. };
466 // --- Freon C2F4H2 (TOF-TDR pagg.)
467 // Geant Manual CONS110-1, pag. 43 (Geant, Detector Description and Simulation Tool)
468 Float_t afre[3] = {12.011,18.998,1.007};
469 Float_t zfre[3] = { 6., 9., 1.};
470 Float_t wfre[3] = { 2., 4., 2.};
471 Float_t densfre = 0.00375;
472 // http://www.fi.infn.it/sezione/prevprot/gas/freon.html
475 //-- Isobutane quencher C4H10 (5% in the sensitive mixture)
476 Float_t aiso[2] = {12.011,1.007};
477 Float_t ziso[2] = { 6., 1.};
478 Float_t wiso[2] = { 4., 10.};
479 Float_t densiso = .......; // (g/cm3) density
480 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
481 //-- SF6 (5% in the sensitive mixture)
482 Float_t asf[3] = {32.066,18.998};
483 Float_t zsf[3] = { 16., 9.};
484 Float_t wsf[3] = { 1., 6.};
485 Float_t denssf = .....; // (g/cm3) density
486 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
489 Float_t ac[2] = {12.,16.};
490 Float_t zc[2] = { 6., 8.};
491 Float_t wc[2] = { 1., 2.};
492 Float_t dc = .001977;
494 // For mylar (C5H4O2)
495 Float_t amy[3] = { 12., 1., 16. };
496 Float_t zmy[3] = { 6., 1., 8. };
497 Float_t wmy[3] = { 5., 4., 2. };
500 // For polyethilene (CH2) - honeycomb -
501 Float_t ape[2] = { 12., 1. };
502 Float_t zpe[2] = { 6., 1. };
503 Float_t wpe[2] = { 1., 2. };
504 Float_t dpe = 0.935*0.479; //To have 1%X0 for 1cm as for honeycomb
507 Float_t ag10[4] = { 12.,1.,16.,28. };
508 Float_t zg10[4] = { 6.,1., 8.,14. };
509 Float_t wmatg10[4] = { .259,.288,.248,.205 };
510 Float_t densg10 = 1.7;
513 Float_t adme[5] = { 12.,1.,16.,19.,79. };
514 Float_t zdme[5] = { 6.,1., 8., 9.,35. };
515 Float_t wmatdme[5] = { .4056,.0961,.2562,.1014,.1407 };
516 Float_t densdme = .00205;
518 // ---- ALUMINA (AL203)
519 Float_t aal[2] = { 27.,16.};
520 Float_t zal[2] = { 13., 8.};
521 Float_t wmatal[2] = { 2.,3. };
522 Float_t densal = 2.3;
525 Float_t awa[2] = { 1., 16. };
526 Float_t zwa[2] = { 1., 8. };
527 Float_t wwa[2] = { 2., 1. };
531 //AliMaterial(0, "Vacuum$", 1e-16, 1e-16, 1e-16, 1e16, 1e16);
532 AliMaterial( 1, "Air$",14.61,7.3,0.001205,30423.24,67500.);
533 AliMaterial( 2, "Cu $", 63.54, 29.0, 8.96, 1.43, 14.8);
534 AliMaterial( 3, "C $", 12.01, 6.0, 2.265,18.8, 74.4);
535 AliMixture ( 4, "Polyethilene$", ape, zpe, dpe, npe, wpe);
536 AliMixture ( 5, "G10$", ag10, zg10, densg10, nlmatg10, wmatg10);
537 AliMixture ( 6, "DME ", adme, zdme, densdme, nlmatdme, wmatdme);
538 AliMixture ( 7, "CO2$", ac, zc, dc, nc, wc);
539 AliMixture ( 8, "ALUMINA$", aal, zal, densal, nlmatal, wmatal);
540 AliMaterial( 9, "Al $", 26.98, 13., 2.7, 8.9, 37.2);
541 AliMaterial(10, "C-TRD$", 12.01, 6., 2.265*18.8/69.282*15./100, 18.8, 74.4); // for 15%
542 AliMixture (11, "Mylar$", amy, zmy, dmy, nmy, wmy);
543 AliMixture (12, "Freon$", afre, zfre, densfre, nfre, wfre);
544 AliMixture (13, "Quartz$", aq, zq, dq, nq, wq);
545 AliMixture (14, "Water$", awa, zwa, dwa, nwa, wwa);
547 Float_t epsil, stmin, deemax, stemax;
550 // EPSIL = 0.1 ! Tracking precision,
551 // STEMAX = 0.1 ! Maximum displacement for multiple scattering
552 // DEEMAX = 0.1 ! Maximum fractional energy loss, DLS
556 epsil = .001; // Tracking precision,
557 stemax = -1.; // Maximum displacement for multiple scattering
558 deemax = -.3; // Maximum fractional energy loss, DLS
561 AliMedium( 1, "Air$" , 1, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
562 AliMedium( 2, "Cu $" , 2, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
563 AliMedium( 3, "C $" , 3, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
564 AliMedium( 4, "Pol$" , 4, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
565 AliMedium( 5, "G10$" , 5, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
566 AliMedium( 6, "DME$" , 6, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
567 AliMedium( 7, "CO2$" , 7, 0, isxfld, sxmgmx, 10., -.01, -.1, .01, -.01);
568 AliMedium( 8,"ALUMINA$", 8, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
569 AliMedium( 9,"Al Frame$",9, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
570 AliMedium(10, "DME-S$", 6, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
571 AliMedium(11, "C-TRD$", 10, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
572 AliMedium(12, "Myl$" , 11, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
573 AliMedium(13, "Fre$" , 12, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
574 AliMedium(14, "Fre-S$", 12, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
575 AliMedium(15, "Glass$", 13, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
576 AliMedium(16, "Water$", 14, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
579 //_____________________________________________________________________________
580 Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t ) const
583 // Returns distance from mouse pointer to detector, default version
588 //___________________________________________
589 void AliTOF::ResetHits ()
591 // Reset number of clusters and the cluster array for this detector
592 AliDetector::ResetHits ();
595 //____________________________________________
596 void AliTOF::ResetDigits ()
599 // Reset number of digits and the digits array for this detector
600 AliDetector::ResetDigits ();
603 //_____________________________________________________________________________
607 // Initialise TOF detector after it has been built
609 // Set id of TOF sensitive volume
610 if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD");
614 //____________________________________________________________________________
615 void AliTOF::MakeBranch(Option_t* option, const char *file)
618 // Initializes the Branches of the TOF inside the
619 // trees written for each event.
620 // AliDetector::MakeBranch initializes just the
621 // Branch inside TreeH. Here we add the branches in
622 // TreeD, TreeS and TreeR.
624 AliDetector::MakeBranch(option,file);
626 Int_t buffersize = 4000;
627 Char_t branchname[10];
628 sprintf(branchname,"%s",GetName());
630 const char *oD = strstr(option,"D");
631 const char *oS = strstr(option,"S");
632 const char *oR = strstr(option,"R");
636 // one branch for TOF digits
640 if (fDigits && gAlice->TreeD() && oD){
641 MakeBranchInTree(gAlice->TreeD(),
642 branchname, &fDigits,buffersize, file) ;
647 // one branch for TOF sdigits
651 if (fSDigits && gAlice->TreeS() && oS){
652 MakeBranchInTree(gAlice->TreeS(),
653 branchname, &fSDigits,buffersize, file) ;
658 // one branch for TOF reconstructed particles
662 if (fReconParticles && gAlice->TreeR() && oR){
663 MakeBranchInTree(gAlice->TreeR(),
664 branchname, &fReconParticles,buffersize, file) ;
669 //____________________________________________________________________________
670 void AliTOF::Makehits(Bool_t hits)
672 // default argument used, see AliTOF.h
673 // Enable/Disable the writing of the TOF-hits branch
675 // by default : enabled for TOFv1, v2, v3, v4
676 // disabled for TOFv0
678 if (hits && (IsVersion()!=0))
679 fIdSens = gMC->VolId("FPAD");
681 cout << "Option for writing the TOF-hits branch on TreeH: disabled" << endl;
684 //____________________________________________________________________________
685 void AliTOF::FinishEvent()
690 //___________________________________________
691 void AliTOF::SDigits2Digits()
694 // Generate digits performing merging
697 int nparticles = gAlice->GetNtrack();
698 cout << "Particles :" <<nparticles<<endl;
699 if (nparticles > 0 ) {
701 AliTOF::Hits2Digits();
705 cout<<"AliTOF::SDigits2Digits"<<endl;
708 cout<<"AliTOF::SDigits2Digits Init"<<endl;
710 cout<<"AliTOF::SDigits2Digits Digitise() "<<endl;
714 //---------------------------------------------------------------------
715 void AliTOF::SetMerger(AliTOFMerger* merger)
717 // Set pointer to merger
721 //---------------------------------------------------------------------
722 AliTOFMerger* AliTOF::Merger()
724 // Return pointer to merger
728 //____________________________________________________________________________
729 void AliTOF::TOFHits2SDigits()
732 // Starting from the Hits Tree (TreeH), this
733 // function writes the TOF SDigits Branch in the TreeS storing
734 // the digits informations.
735 // It has to be called just at the end of an event or
736 // at the end of a whole run.
737 // It could also be called by AliTOF::Finish Event()
738 // Just for MC events.
740 // Called by the ROOT script Hits2SDigits.C
742 // Simulation of detector response.
744 Int_t ver = this->IsVersion();
745 if(ver==0) return; // no sdigits for AliTOFv0
747 AliTOF *TOF = (AliTOF *) gAlice->GetDetector ("TOF");
750 fNevents = (Int_t) gAlice->TreeE ()->GetEntries ();
752 cout << "nevents found on file " << fNevents << endl;
753 // Start Event ------------------------- LOOP
755 for (Int_t ievent = 0; ievent < fNevents; ievent++)
757 gAlice->GetEvent (ievent);
758 if (gAlice->TreeH () == 0)
759 return; // no hits stored
760 if (gAlice->TreeS () == 0)
761 gAlice->MakeTree ("S");
768 sprintf (branchname, "%s", TOF->GetName ());
769 //Make branch for TOF sdigits
770 TOF->MakeBranch ("S");
772 Int_t tracks[3]; // track info
773 Int_t vol[5]; // location for a digit
774 Float_t digit[2]; // TOF digit variables
778 TClonesArray *TOFhits = TOF->Hits();
783 TOFhits = TOF->Hits(); // pointer to the TClonesArray of TOF hits
784 TTree *TH = gAlice->TreeH(); // pointer to the current TreeH
785 Stat_t ntracks = TH->GetEntries(); // number of tracks for the current event
786 for (Int_t track = 0; track < ntracks; track++)
788 gAlice->ResetHits ();
789 nbytes += TH->GetEvent(track);
790 particle = gAlice->Particle(track);
791 Int_t nhits = TOFhits->GetEntriesFast(); // number of hits for the current track
793 for (hit = 0; hit < nhits; hit++)
795 tofHit = (AliTOFhit*) TOFhits->UncheckedAt(hit);
796 vol[0] = tofHit->GetSector();
797 vol[1] = tofHit->GetPlate();
798 vol[2] = tofHit->GetStrip();
799 vol[3] = tofHit->GetPadx();
800 vol[4] = tofHit->GetPadz();
802 // 95% of efficiency to be inserted here
803 // edge effect to be inserted here
804 // cross talk to be inserted here
806 Float_t idealtime = tofHit->GetTof(); // unit s
807 idealtime *= 1.E+12; // conversion from s to ps
808 // fTimeRes is given usually in ps
809 Float_t tdctime = gRandom->Gaus(idealtime, fTimeRes);
812 // typical Landau Distribution to be inserted here
813 // instead of Gaussian Distribution
814 Float_t idealcharge = tofHit->GetEdep();
815 Float_t adccharge = gRandom->Gaus(idealcharge, fChrgRes);
816 digit[1] = adccharge;
817 Int_t tracknum = tofHit->GetTrack();
818 tracks[0] = tracknum;
822 // check if two digit are on the same pad; in that case we sum
823 // the two or more digits
824 Bool_t overlap = CheckOverlap(vol, digit, tracknum);
826 new ((*fSDigits)[nSdigits++]) AliTOFdigit(tracks, vol, digit);
827 //cout << "nSdigits" << endl;
828 } // end loop on hits for the current track
830 } // end loop on ntracks
832 } // close if TOF switched ON
834 gAlice->TreeS()->Fill();
835 gAlice->TreeS()->Print();
841 //---------------------------------------------------------------------
843 void AliTOF::Hits2SDigits()
846 // Use the TOF SDigitizer to make TOF SDigits
850 cout<<"ALiTOF::Hits2SDigits> start...\n";
853 char * fileSDigits = 0 ;
854 char * fileHeader = 0;
855 AliTOFSDigitizer * sd = new AliTOFSDigitizer(fileHeader,fileSDigits) ;
863 //___________________________________________________________________________
864 Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
867 // Checks if 2 or more hits belong to the same pad.
868 // In this case the data assigned to the digit object
869 // are the ones of the first hit in order of Time.
870 // 2 hits from the same track on the same pad are collected.
871 // Called only by Hits2SDigits.
872 // This procedure has to be optimized in the next TOF release.
875 Bool_t overlap = kFALSE;
878 for (Int_t ndig=0; ndig<fSDigits->GetEntries(); ndig++){
879 AliTOFdigit* currentDigit = (AliTOFdigit*)(fSDigits->UncheckedAt(ndig));
880 currentDigit->GetLocation(vol2);
882 // check on digit volume
883 for (Int_t i=0;i<=4;i++){
885 if (vol[i]!=vol2[i]) idem=kFALSE;}
887 if (idem){ // same pad fired
888 Float_t tdc2 = digit[0];
889 Float_t tdc1 = currentDigit->GetTdc();
891 // we separate two digits on the same pad if
892 // they are separated in time by at least 25 ns
893 // remember that tdc time is given in ps
895 if (TMath::Abs(tdc1-tdc2)<25000){
896 // in case of overlap we take the earliest
898 currentDigit->SetTdc(tdc2);
899 currentDigit->SetAdc(digit[1]);
902 currentDigit->SetTdc(tdc1);
903 currentDigit->SetAdc(digit[1]);
905 currentDigit->AddTrack(Track); // add track number in the track array
911 } // close if (idem) -> two digits on the same TOF pad
913 } // end loop on existing sdigits
919 //____________________________________________________________________________
920 void AliTOF::Digits2Raw(Int_t evNumber)
923 // Starting from digits, writes the
924 // Raw Data objects, i.e. a
925 // TClonesArray of 18 AliTOFRawSector objects
930 // do nothing if no particles
931 Int_t nparticles = gAlice->GetEvent(evNumber);
932 if (nparticles <= 0) return;
934 tD = gAlice->TreeD();
936 TClonesArray* tofdigits = this->Digits();
937 Int_t ndigits = tofdigits->GetEntriesFast();
939 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
941 for (Int_t isect=1;isect<=fNTof;isect++){
942 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(isect);
943 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
945 for (Int_t digit=0; digit<ndigits; digit++){
946 AliTOFdigit* currentDigit = (AliTOFdigit*)tofdigits->UncheckedAt(digit);
947 Int_t sector = currentDigit->GetSector();
949 Int_t pad = currentDigit -> GetTotPad();
950 Int_t roc = (Int_t)(pad/fNPadXRoc)-1;
951 if (roc>=fNRoc) printf("Wrong n. of ROC ! Roc = %i",roc);
952 Int_t padRoc = (Int_t) pad%fNPadXRoc;
953 Int_t fec = (Int_t)(padRoc/fNFec)-1;
954 Int_t tdc = (Int_t)(padRoc%fNFec)-1;
955 Float_t time = currentDigit->GetTdc();
956 Float_t charge = currentDigit->GetAdc();
957 AliTOFRoc* currentROC = (AliTOFRoc*)rocData->UncheckedAt(roc);
959 currentROC->AddItem(fec, tdc, error, charge, time);
960 } // close if (sector==isect) i.e. end loop on digits for the current sector
961 } // end loop on TOF digits
963 UInt_t totSize=16,rocSize=0;
964 UInt_t rocHead[14],rocChek[14];
965 UInt_t globalCheckSum=0;
967 for (UInt_t iRoc = 1; iRoc<(UInt_t)fNRoc; iRoc++){
968 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(iRoc);
969 rocSize = currentRoc->GetItems()*2+1;
970 totSize += rocSize*4;
971 if (rocSize>=TMath::Power(2,16)) rocSize=0;
972 rocHead[iRoc] = iRoc<<28;
973 rocHead[iRoc] += rocSize;
974 rocChek[iRoc] = currentRoc->GetCheckSum();
975 Int_t headCheck = currentRoc->BitCount(rocHead[iRoc]);
976 globalCheckSum += headCheck;
977 globalCheckSum += rocChek[iRoc];
980 AliTOFRoc* dummyRoc = new AliTOFRoc();
982 if (totSize>=TMath::Power(2,24)) totSize=0;
983 UInt_t header = totSize;
984 UInt_t sectId = ((UInt_t)isect)<<24;
986 globalCheckSum += dummyRoc->BitCount(header);
987 currentSector->SetGlobalCS(globalCheckSum);
988 currentSector->SetHeader(header);
992 //____________________________________________________________________________
993 void AliTOF::Raw2Digits(Int_t evNumber)
996 // Converts Raw Data objects into digits objects.
997 // We schematize the raw data with a
998 // TClonesArray of 18 AliTOFRawSector objects
1010 Int_t nparticles = gAlice->GetEvent(evNumber);
1011 if (nparticles <= 0) return;
1013 tD = gAlice->TreeD();
1015 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
1017 for(Int_t nSec=1; nSec<=fNTof; nSec++){
1018 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(nSec);
1019 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
1020 for(Int_t nRoc=1; nRoc<=14; nRoc++){
1021 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(nRoc);
1022 Int_t currentItems = currentRoc->GetItems();
1023 for(Int_t item=1; item<currentItems; item++){
1024 Int_t nPad = currentRoc->GetTotPad(item);
1026 Int_t nStrip = (Int_t)(nPad/fPadXStr)+1;
1028 if (nStrip<=fNStripC+2*fNStripB+fNStripA) nPlate = 4;
1029 if (nStrip<=fNStripC+fNStripB+fNStripA) nPlate = 3;
1030 if (nStrip<=fNStripC+fNStripB) nPlate = 2;
1031 if (nStrip<=fNStripC) nPlate=1;
1035 case 2: nStrip -= (fNStripC);
1037 case 3: nStrip -= (fNStripC+fNStripB);
1039 case 4: nStrip -= (fNStripC+fNStripB+fNStripA);
1041 case 5: nStrip -= (fNStripC+2*fNStripB+fNStripA);
1045 Int_t pad = nPad%fPadXStr;
1046 if (pad==0) pad=fPadXStr;
1047 Int_t nPadX=0, nPadZ=0;
1048 (pad>fNpadX)? nPadX -= fNpadX : nPadX = pad ;
1050 (pad>fNpadX)? nPadZ = 2 : nPadZ = 1 ;
1053 Float_t tdc = currentRoc->GetTime(item,error);
1054 if (!error) digit[0]=tdc;
1055 digit[1] = currentRoc->GetCharge(item);
1056 AddDigit(tracks,vol,digit);
1061 tD->Write(0,TObject::kOverwrite);