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.25 2001/09/07 08:37:40 hristov
19 Pointers initialised to 0 in the default constructor
21 Revision 1.24 2001/09/05 16:31:00 hristov
22 The deletion of TOF folders temporarily commented out
24 Revision 1.23 2001/08/29 12:59:01 vicinanz
25 Minor changes to the Digitizer procedure
27 Revision 1.22 2001/08/28 08:45:58 vicinanz
28 TTask and TFolder structures implemented
30 Revision 1.21 2001/05/16 14:57:24 alibrary
31 New files for folders and Stack
33 Revision 1.20 2001/05/04 10:09:47 vicinanz
34 Major upgrades to the strip structure
36 Revision 1.19 2001/03/12 17:47:25 hristov
37 Changes needed on Sun with CC 5.0
39 Revision 1.18 2001/01/26 19:57:42 hristov
40 Major upgrade of AliRoot code
42 Revision 1.17 2000/10/19 09:58:14 vicinanz
43 Updated Hits2Digit procedure
45 Revision 1.16 2000/10/02 21:28:17 fca
46 Removal of useless dependecies via forward declarations
48 Revision 1.15 2000/05/18 14:33:01 vicinanz
49 Modified to be full HP compliant
51 Revision 1.14 2000/05/15 19:32:36 fca
54 Revision 1.13 2000/05/10 16:52:18 vicinanz
55 New TOF version with holes for PHOS/RICH
57 Revision 1.11.2.1 2000/05/10 09:37:15 vicinanz
58 New version with Holes for PHOS/RICH
60 Revision 1.11 1999/11/05 22:39:06 fca
63 Revision 1.10 1999/11/01 20:41:57 fca
64 Added protections against using the wrong version of FRAME
66 Revision 1.9 1999/10/15 15:35:19 fca
67 New version for frame1099 with and without holes
69 Revision 1.9 1999/09/29 09:24:33 fca
70 Introduction of the Copyright and cvs Log
74 ///////////////////////////////////////////////////////////////////////////////
77 // This class contains the basic functions for the Time Of Flight //
78 // detector. Functions specific to one particular geometry are //
79 // contained in the derived classes //
81 // VERSIONE WITH 5 SYMMETRIC MODULES ALONG Z AXIS
82 // ==============================================
84 // VERSION WITH HOLES FOR PHOS AND TRD IN SPACEFRAME WITH HOLES
86 // Volume sensibile : FPAD
92 <img src="picts/AliTOFClass.gif">
98 ///////////////////////////////////////////////////////////////////////////////
100 #include <iostream.h>
101 #include <strstream.h>
106 #include "AliTOFhit.h"
107 #include "AliTOFdigit.h"
108 #include "AliTOFRawSector.h"
109 #include "AliTOFRoc.h"
110 #include "AliTOFRawDigit.h"
125 #include "AliConst.h"
130 //_____________________________________________________________________________
134 // Default constructor
148 //_____________________________________________________________________________
149 AliTOF::AliTOF(const char *name, const char *title)
150 : AliDetector(name,title)
153 // AliTOF standard constructor
155 // Here are fixed some important parameters
158 // Initialization of hits, sdigits and digits array
160 fHits = new TClonesArray("AliTOFhit", 1000);
161 gAlice->AddHitList(fHits);
163 fSDigits = new TClonesArray("AliTOFdigit", 1000);
164 fDigits = new TClonesArray("AliTOFdigit", 1000);
166 // Digitization parameters
168 // (Transfer Functions to be inserted here)
174 // General Geometrical Parameters
175 fNTof = 18; // number of sectors
178 fZlenC = 177.5;//cm length of module C
179 fZlenB = 141.0;//cm length of module B
180 fZlenA = 106.0;//cm length of module A
181 fZtof = 371.5;//cm total semi-length of TOF detector
184 fStripLn = 122.0;//cm Strip Length
185 fSpace = 5.5;//cm Space Beetween the strip and the bottom of the plate
186 fDeadBndZ= 1.5;//cm Dead Boundaries of a Strip along Z direction (width)
187 fDeadBndX= 1.0;//cm Dead Boundaries of a Strip along X direction (length)
188 fXpad = 2.5;//cm X size of a pad
189 fZpad = 3.5;//cm Z size of a pad
190 fGapA = 4.; //cm Gap beetween tilted strip in A-type plate
191 fGapB = 6.; //cm Gap beetween tilted strip in B-type plate
192 fOverSpc = 15.3;//cm Space available for sensitive layers in radial direction
193 fNpadX = 48; // Number of pads in a strip along the X direction
194 fNpadZ = 2; // Number of pads in a strip along the Z direction
195 fPadXStr = fNpadX*fNpadZ; //Number of pads per strip
196 fNStripA = 15; // number of strips in A type module
197 fNStripB = 19; // number of strips in B type module
198 fNStripC = 20; // number of strips in C type module
200 // Physical performances
204 // DAQ characteristics
205 // cfr. TOF-TDR pag. 105 for Glossary
206 // TARODA : TOF-ALICE Read Out and Data Acquisition system
207 fPadXSector = 8928; // number of pad per sector -with no holes-
208 // ((15+2*19+2*20)*(48*2))
209 fNRoc = 14; // number of Roc (Read Out Controller) (TARODA)
210 fNFec = 32; // number of Fec (Front-End electronic Card)
212 fNTdc = 32; // number of Tdc (Time to Digital Converter)
213 fNPadXRoc = (Int_t)fPadXSector/fNRoc; // number of pads for each ROC
215 // Create TOF Folder Structure
220 //_____________________________________________________________________________
221 void AliTOF::CreateTOFFolders()
223 // create the ALICE TFolder
224 // create the ALICE TTasks
225 // create the ALICE main TFolder
226 // to be done by AliRun
228 TFolder * alice = new TFolder();
229 alice->SetNameTitle("FPAlice", "Alice Folder") ;
230 gROOT->GetListOfBrowsables()->Add(alice) ;
232 TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ;
233 // make it the owner of the objects that it contains
236 TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ;
237 TFolder * aliceT = alice->AddFolder("tasks", "Alice tasks Folder") ;
238 // make it the owner of the objects that it contains
241 TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ;
242 aliceT->Add(aliceDi);
244 TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
245 aliceT->Add(aliceRe);
247 char * tempo = new char[80] ;
249 // creates the TOF Digitizer and adds it to alice main (S)Digitizer task
250 sprintf(tempo, "%sDigitizers container",GetName() ) ;
251 fDTask = new TTask(GetName(), tempo);
252 aliceDi->Add(fDTask) ;
254 // creates the TOF reconstructioner and adds it to alice main Reconstructioner task
255 sprintf(tempo, "%sReconstructioner container",GetName() ) ;
256 fReTask = new TTask(GetName(), tempo);
257 aliceRe->Add(fReTask) ;
261 // creates the TOF geometry folder
262 geomF->AddFolder("TOF", "Geometry for TOF") ;
265 //_____________________________________________________________________________
269 // it remove also the alice folder
270 // and task that TOF creates instead of AliRun
271 /* PH Temporarily commented because of problems
272 TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ;
296 fReconParticles->Delete ();
297 delete fReconParticles;
303 //_____________________________________________________________________________
304 void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits)
308 // new with placement used
310 TClonesArray &lhits = *fHits;
311 new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits);
314 //_____________________________________________________________________________
315 void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
319 // new with placement used
321 TClonesArray &ldigits = *fDigits;
322 new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits);
325 //___________________________________________
326 void AliTOF::AddSDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
333 TClonesArray &lSDigits = *fSDigits;
334 new(lSDigits[fNSDigits++]) AliTOFdigit(tracks, vol, digits);
337 //_____________________________________________________________________________
338 void AliTOF::SetTreeAddress ()
340 // Set branch address for the Hits and Digits Tree.
342 AliDetector::SetTreeAddress ();
345 TTree *treeD = gAlice->TreeD ();
352 branch = treeD->GetBranch (branchname);
354 branch->SetAddress (&fDigits);
359 // fSDigits->Clear ();
361 if (gAlice->TreeS () && fSDigits)
363 branch = gAlice->TreeS ()->GetBranch ("TOF");
365 branch->SetAddress (&fSDigits);
368 if (gAlice->TreeR() && fReconParticles)
370 branch = gAlice->TreeR()->GetBranch("TOF");
371 if (branch) branch->SetAddress(&fReconParticles) ;
375 //_____________________________________________________________________________
376 void AliTOF::CreateGeometry()
379 // Common geometry code
383 <img src="picts/AliTOFv23.gif">
387 const Double_t kPi=TMath::Pi();
388 const Double_t kDegrad=kPi/180.;
390 Float_t xTof, yTof, wall;
392 // frame inbetween TOF modules
395 // Sizes of TOF module with its support etc..
396 xTof = 2.*(fRmin*TMath::Tan(10*kDegrad)-wall/2-.5);
399 // TOF module internal definitions
400 TOFpc(xTof, yTof, fZlenC, fZlenB, fZlenA, fZtof);
403 //_____________________________________________________________________________
404 void AliTOF::DrawModule() const
407 // Draw a shaded view of the common part of the TOF geometry
410 cout << " Drawing of AliTOF"<< endl;
411 // Set everything unseen
412 gMC->Gsatt("*", "seen", -1);
414 // Set ALIC mother transparent
415 gMC->Gsatt("ALIC","SEEN",0);
417 // Set the volumes visible
418 gMC->Gsatt("FTOA","SEEN",1);
419 gMC->Gsatt("FTOB","SEEN",1);
420 gMC->Gsatt("FTOC","SEEN",1);
421 gMC->Gsatt("FLTA","SEEN",1);
422 gMC->Gsatt("FLTB","SEEN",1);
423 gMC->Gsatt("FLTC","SEEN",1);
424 gMC->Gsatt("FSTR","SEEN",1);
426 gMC->Gdopt("hide", "on");
427 gMC->Gdopt("shad", "on");
428 gMC->Gsatt("*", "fill", 7);
429 gMC->SetClipBox(".");
430 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
432 gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
433 gMC->Gdhead(1111, "Time Of Flight");
434 gMC->Gdman(18, 4, "MAN");
435 gMC->Gdopt("hide","off");
438 //_____________________________________________________________________________
439 void AliTOF::CreateMaterials()
442 // Defines TOF materials for all versions
443 // Authors : Maxim Martemianov, Boris Zagreev (ITEP)
445 // Revision: F. Pierella 5-3-2001
446 // Bologna University
448 Int_t isxfld = gAlice->Field()->Integ();
449 Float_t sxmgmx = gAlice->Field()->Max();
452 Float_t aq[2] = { 28.0855,15.9994 };
453 Float_t zq[2] = { 14.,8. };
454 Float_t wq[2] = { 1.,2. };
457 // --- Freon C2F4H2 (TOF-TDR pagg.)
458 // Geant Manual CONS110-1, pag. 43 (Geant, Detector Description and Simulation Tool)
459 Float_t afre[3] = {12.011,18.998,1.007};
460 Float_t zfre[3] = { 6., 9., 1.};
461 Float_t wfre[3] = { 2., 4., 2.};
462 Float_t densfre = 0.00375;
463 // http://www.fi.infn.it/sezione/prevprot/gas/freon.html
466 //-- Isobutane quencher C4H10 (5% in the sensitive mixture)
467 Float_t aiso[2] = {12.011,1.007};
468 Float_t ziso[2] = { 6., 1.};
469 Float_t wiso[2] = { 4., 10.};
470 Float_t densiso = .......; // (g/cm3) density
471 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
472 //-- SF6 (5% in the sensitive mixture)
473 Float_t asf[3] = {32.066,18.998};
474 Float_t zsf[3] = { 16., 9.};
475 Float_t wsf[3] = { 1., 6.};
476 Float_t denssf = .....; // (g/cm3) density
477 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
480 Float_t ac[2] = {12.,16.};
481 Float_t zc[2] = { 6., 8.};
482 Float_t wc[2] = { 1., 2.};
483 Float_t dc = .001977;
485 // For mylar (C5H4O2)
486 Float_t amy[3] = { 12., 1., 16. };
487 Float_t zmy[3] = { 6., 1., 8. };
488 Float_t wmy[3] = { 5., 4., 2. };
491 // For polyethilene (CH2) - honeycomb -
492 Float_t ape[2] = { 12., 1. };
493 Float_t zpe[2] = { 6., 1. };
494 Float_t wpe[2] = { 1., 2. };
495 Float_t dpe = 0.935*0.479; //To have 1%X0 for 1cm as for honeycomb
498 Float_t ag10[4] = { 12.,1.,16.,28. };
499 Float_t zg10[4] = { 6.,1., 8.,14. };
500 Float_t wmatg10[4] = { .259,.288,.248,.205 };
501 Float_t densg10 = 1.7;
504 Float_t adme[5] = { 12.,1.,16.,19.,79. };
505 Float_t zdme[5] = { 6.,1., 8., 9.,35. };
506 Float_t wmatdme[5] = { .4056,.0961,.2562,.1014,.1407 };
507 Float_t densdme = .00205;
509 // ---- ALUMINA (AL203)
510 Float_t aal[2] = { 27.,16.};
511 Float_t zal[2] = { 13., 8.};
512 Float_t wmatal[2] = { 2.,3. };
513 Float_t densal = 2.3;
516 Float_t awa[2] = { 1., 16. };
517 Float_t zwa[2] = { 1., 8. };
518 Float_t wwa[2] = { 2., 1. };
522 //AliMaterial(0, "Vacuum$", 1e-16, 1e-16, 1e-16, 1e16, 1e16);
523 AliMaterial( 1, "Air$",14.61,7.3,0.001205,30423.24,67500.);
524 AliMaterial( 2, "Cu $", 63.54, 29.0, 8.96, 1.43, 14.8);
525 AliMaterial( 3, "C $", 12.01, 6.0, 2.265,18.8, 74.4);
526 AliMixture ( 4, "Polyethilene$", ape, zpe, dpe, npe, wpe);
527 AliMixture ( 5, "G10$", ag10, zg10, densg10, nlmatg10, wmatg10);
528 AliMixture ( 6, "DME ", adme, zdme, densdme, nlmatdme, wmatdme);
529 AliMixture ( 7, "CO2$", ac, zc, dc, nc, wc);
530 AliMixture ( 8, "ALUMINA$", aal, zal, densal, nlmatal, wmatal);
531 AliMaterial( 9, "Al $", 26.98, 13., 2.7, 8.9, 37.2);
532 AliMaterial(10, "C-TRD$", 12.01, 6., 2.265*18.8/69.282*15./100, 18.8, 74.4); // for 15%
533 AliMixture (11, "Mylar$", amy, zmy, dmy, nmy, wmy);
534 AliMixture (12, "Freon$", afre, zfre, densfre, nfre, wfre);
535 AliMixture (13, "Quartz$", aq, zq, dq, nq, wq);
536 AliMixture (14, "Water$", awa, zwa, dwa, nwa, wwa);
538 Float_t epsil, stmin, deemax, stemax;
541 // EPSIL = 0.1 ! Tracking precision,
542 // STEMAX = 0.1 ! Maximum displacement for multiple scattering
543 // DEEMAX = 0.1 ! Maximum fractional energy loss, DLS
547 epsil = .001; // Tracking precision,
548 stemax = -1.; // Maximum displacement for multiple scattering
549 deemax = -.3; // Maximum fractional energy loss, DLS
552 AliMedium( 1, "Air$" , 1, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
553 AliMedium( 2, "Cu $" , 2, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
554 AliMedium( 3, "C $" , 3, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
555 AliMedium( 4, "Pol$" , 4, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
556 AliMedium( 5, "G10$" , 5, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
557 AliMedium( 6, "DME$" , 6, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
558 AliMedium( 7, "CO2$" , 7, 0, isxfld, sxmgmx, 10., -.01, -.1, .01, -.01);
559 AliMedium( 8,"ALUMINA$", 8, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
560 AliMedium( 9,"Al Frame$",9, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
561 AliMedium(10, "DME-S$", 6, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
562 AliMedium(11, "C-TRD$", 10, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
563 AliMedium(12, "Myl$" , 11, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
564 AliMedium(13, "Fre$" , 12, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
565 AliMedium(14, "Fre-S$", 12, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
566 AliMedium(15, "Glass$", 13, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
567 AliMedium(16, "Water$", 14, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
570 //_____________________________________________________________________________
571 Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t ) const
574 // Returns distance from mouse pointer to detector, default version
579 //___________________________________________
580 void AliTOF::ResetHits ()
582 // Reset number of clusters and the cluster array for this detector
583 AliDetector::ResetHits ();
586 //____________________________________________
587 void AliTOF::ResetDigits ()
590 // Reset number of digits and the digits array for this detector
591 AliDetector::ResetDigits ();
594 //_____________________________________________________________________________
598 // Initialise TOF detector after it has been built
600 // Set id of TOF sensitive volume
601 if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD");
605 //____________________________________________________________________________
606 void AliTOF::MakeBranch(Option_t* option, const char *file)
609 // Initializes the Branches of the TOF inside the
610 // trees written for each event.
611 // AliDetector::MakeBranch initializes just the
612 // Branch inside TreeH. Here we add the branches in
613 // TreeD, TreeS and TreeR.
615 AliDetector::MakeBranch(option,file);
617 Int_t buffersize = 4000;
618 Char_t branchname[10];
619 sprintf(branchname,"%s",GetName());
621 const char *oD = strstr(option,"D");
622 const char *oS = strstr(option,"S");
623 const char *oR = strstr(option,"R");
627 // one branch for TOF digits
631 if (fDigits && gAlice->TreeD() && oD){
632 MakeBranchInTree(gAlice->TreeD(),
633 branchname, &fDigits,buffersize, file) ;
638 // one branch for TOF sdigits
642 if (fSDigits && gAlice->TreeS() && oS){
643 MakeBranchInTree(gAlice->TreeS(),
644 branchname, &fSDigits,buffersize, file) ;
649 // one branch for TOF reconstructed particles
653 if (fReconParticles && gAlice->TreeR() && oR){
654 MakeBranchInTree(gAlice->TreeR(),
655 branchname, &fReconParticles,buffersize, file) ;
660 //____________________________________________________________________________
661 void AliTOF::Makehits(Bool_t hits)
663 // default argument used, see AliTOF.h
664 // Enable/Disable the writing of the TOF-hits branch
666 // by default : enabled for TOFv1, v2, v3, v4
667 // disabled for TOFv0
669 if (hits && (IsVersion()!=0))
670 fIdSens = gMC->VolId("FPAD");
672 cout << "Option for writing the TOF-hits branch on TreeH: disabled" << endl;
675 //____________________________________________________________________________
676 void AliTOF::FinishEvent()
681 //___________________________________________
682 void AliTOF::SDigits2Digits()
685 // Generate digits performing merging
688 int nparticles = gAlice->GetNtrack();
689 cout << "Particles :" <<nparticles<<endl;
690 if (nparticles > 0 ) {
692 AliTOF::Hits2Digits();
696 cout<<"AliTOF::SDigits2Digits"<<endl;
699 cout<<"AliTOF::SDigits2Digits Init"<<endl;
701 cout<<"AliTOF::SDigits2Digits Digitise() "<<endl;
705 //---------------------------------------------------------------------
706 void AliTOF::SetMerger(AliTOFMerger* merger)
708 // Set pointer to merger
712 //---------------------------------------------------------------------
713 AliTOFMerger* AliTOF::Merger()
715 // Return pointer to merger
719 //____________________________________________________________________________
720 void AliTOF::TOFHits2SDigits()
723 // Starting from the Hits Tree (TreeH), this
724 // function writes the TOF SDigits Branch in the TreeS storing
725 // the digits informations.
726 // It has to be called just at the end of an event or
727 // at the end of a whole run.
728 // It could also be called by AliTOF::Finish Event()
729 // Just for MC events.
731 // Called by the ROOT script Hits2SDigits.C
733 // Simulation of detector response.
735 Int_t ver = this->IsVersion();
736 if(ver==0) return; // no sdigits for AliTOFv0
738 AliTOF *TOF = (AliTOF *) gAlice->GetDetector ("TOF");
741 fNevents = (Int_t) gAlice->TreeE ()->GetEntries ();
743 cout << "nevents found on file " << fNevents << endl;
744 // Start Event ------------------------- LOOP
746 for (Int_t ievent = 0; ievent < fNevents; ievent++)
748 gAlice->GetEvent (ievent);
749 if (gAlice->TreeH () == 0)
750 return; // no hits stored
751 if (gAlice->TreeS () == 0)
752 gAlice->MakeTree ("S");
759 sprintf (branchname, "%s", TOF->GetName ());
760 //Make branch for TOF sdigits
761 TOF->MakeBranch ("S");
763 Int_t tracks[3]; // track info
764 Int_t vol[5]; // location for a digit
765 Float_t digit[2]; // TOF digit variables
769 TClonesArray *TOFhits = TOF->Hits();
774 TOFhits = TOF->Hits(); // pointer to the TClonesArray of TOF hits
775 TTree *TH = gAlice->TreeH(); // pointer to the current TreeH
776 Stat_t ntracks = TH->GetEntries(); // number of tracks for the current event
777 for (Int_t track = 0; track < ntracks; track++)
779 gAlice->ResetHits ();
780 nbytes += TH->GetEvent(track);
781 particle = gAlice->Particle(track);
782 Int_t nhits = TOFhits->GetEntriesFast(); // number of hits for the current track
784 for (hit = 0; hit < nhits; hit++)
786 tofHit = (AliTOFhit*) TOFhits->UncheckedAt(hit);
787 vol[0] = tofHit->GetSector();
788 vol[1] = tofHit->GetPlate();
789 vol[2] = tofHit->GetPadx();
790 vol[3] = tofHit->GetPadz();
791 vol[4] = tofHit->GetStrip();
793 // 95% of efficiency to be inserted here
794 // edge effect to be inserted here
795 // cross talk to be inserted here
797 Float_t idealtime = tofHit->GetTof(); // unit s
798 idealtime *= 1.E+12; // conversion from s to ps
799 // fTimeRes is given usually in ps
800 Float_t tdctime = gRandom->Gaus(idealtime, fTimeRes);
803 // typical Landau Distribution to be inserted here
804 // instead of Gaussian Distribution
805 Float_t idealcharge = tofHit->GetEdep();
806 Float_t adccharge = gRandom->Gaus(idealcharge, fChrgRes);
807 digit[1] = adccharge;
808 Int_t tracknum = tofHit->GetTrack();
809 tracks[0] = tracknum;
813 // check if two digit are on the same pad; in that case we sum
814 // the two or more digits
815 Bool_t overlap = CheckOverlap(vol, digit, tracknum);
817 new ((*fSDigits)[nSdigits++]) AliTOFdigit(tracks, vol, digit);
818 //cout << "nSdigits" << endl;
819 } // end loop on hits for the current track
821 } // end loop on ntracks
823 } // close if TOF switched ON
825 gAlice->TreeS()->Fill();
826 gAlice->TreeS()->Print();
832 //---------------------------------------------------------------------
834 void AliTOF::Hits2SDigits()
837 // Use the TOF SDigitizer to make TOF SDigits
841 cout<<"ALiTOF::Hits2SDigits> start...\n";
844 char * fileSDigits = 0 ;
845 char * fileHeader = 0;
846 AliTOFSDigitizer * sd = new AliTOFSDigitizer(fileHeader,fileSDigits) ;
854 //___________________________________________________________________________
855 Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
858 // Checks if 2 or more hits belong to the same pad.
859 // In this case the data assigned to the digit object
860 // are the ones of the first hit in order of Time.
861 // 2 hits from the same track on the same pad are collected.
862 // Called only by Hits2SDigits.
863 // This procedure has to be optimized in the next TOF release.
866 // Bool_t overlap = 0;
867 Bool_t overlap = kFALSE;
870 for (Int_t ndig=0; ndig<fSDigits->GetEntries(); ndig++){
871 AliTOFdigit* currentDigit = (AliTOFdigit*)(fSDigits->UncheckedAt(ndig));
872 currentDigit->GetLocation(vol2);
875 // check on digit volume
876 for (Int_t i=0;i<=4;i++){
878 if (vol[i]!=vol2[i]) idem=kFALSE;}
880 if (idem){ // same pad fired
881 Float_t tdc2 = digit[0];
882 Float_t tdc1 = currentDigit->GetTdc();
884 // we separate two digits on the same pad if
885 // they are separated in time by at least 25 ns
886 // remember that tdc time is given in ps
888 if (TMath::Abs(tdc1-tdc2)<25000){
889 // in case of overlap we take the earliest
891 currentDigit->SetTdc(tdc2);
892 currentDigit->SetAdc(digit[1]);
895 currentDigit->SetTdc(tdc1);
896 currentDigit->SetAdc(digit[1]);
898 currentDigit->AddTrack(Track); // add track number in the track array
899 // cout << "found overlap" << endl;
903 } // if (TMath:: ...)
905 } // close if (idem) -> two digits on the same TOF pad
907 } // end loop on existing sdigits
913 //____________________________________________________________________________
914 void AliTOF::Digits2Raw(Int_t evNumber)
917 // Starting from digits, writes the
918 // Raw Data objects, i.e. a
919 // TClonesArray of 18 AliTOFRawSector objects
924 // do nothing if no particles
925 Int_t nparticles = gAlice->GetEvent(evNumber);
926 if (nparticles <= 0) return;
928 tD = gAlice->TreeD();
930 TClonesArray* tofdigits = this->Digits();
931 Int_t ndigits = tofdigits->GetEntriesFast();
933 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
935 for (Int_t isect=1;isect<=fNTof;isect++){
936 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(isect);
937 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
939 for (Int_t digit=0; digit<ndigits; digit++){
940 AliTOFdigit* currentDigit = (AliTOFdigit*)tofdigits->UncheckedAt(digit);
941 Int_t sector = currentDigit->GetSector();
943 Int_t pad = currentDigit -> GetTotPad();
944 Int_t roc = (Int_t)(pad/fNPadXRoc)-1;
945 if (roc>=fNRoc) printf("Wrong n. of ROC ! Roc = %i",roc);
946 Int_t padRoc = (Int_t) pad%fNPadXRoc;
947 Int_t fec = (Int_t)(padRoc/fNFec)-1;
948 Int_t tdc = (Int_t)(padRoc%fNFec)-1;
949 Float_t time = currentDigit->GetTdc();
950 Float_t charge = currentDigit->GetAdc();
951 AliTOFRoc* currentROC = (AliTOFRoc*)rocData->UncheckedAt(roc);
953 currentROC->AddItem(fec, tdc, error, charge, time);
954 } // close if (sector==isect) i.e. end loop on digits for the current sector
955 } // end loop on TOF digits
957 UInt_t totSize=16,rocSize=0;
958 UInt_t rocHead[14],rocChek[14];
959 UInt_t globalCheckSum=0;
961 for (UInt_t iRoc = 1; iRoc<(UInt_t)fNRoc; iRoc++){
962 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(iRoc);
963 rocSize = currentRoc->GetItems()*2+1;
964 totSize += rocSize*4;
965 if (rocSize>=TMath::Power(2,16)) rocSize=0;
966 rocHead[iRoc] = iRoc<<28;
967 rocHead[iRoc] += rocSize;
968 rocChek[iRoc] = currentRoc->GetCheckSum();
969 Int_t headCheck = currentRoc->BitCount(rocHead[iRoc]);
970 globalCheckSum += headCheck;
971 globalCheckSum += rocChek[iRoc];
974 AliTOFRoc* dummyRoc = new AliTOFRoc();
976 if (totSize>=TMath::Power(2,24)) totSize=0;
977 UInt_t header = totSize;
978 UInt_t sectId = ((UInt_t)isect)<<24;
980 globalCheckSum += dummyRoc->BitCount(header);
981 currentSector->SetGlobalCS(globalCheckSum);
982 currentSector->SetHeader(header);
986 //____________________________________________________________________________
987 void AliTOF::Raw2Digits(Int_t evNumber)
990 // Converts Raw Data objects into digits objects.
991 // We schematize the raw data with a
992 // TClonesArray of 18 AliTOFRawSector objects
1004 Int_t nparticles = gAlice->GetEvent(evNumber);
1005 if (nparticles <= 0) return;
1007 tD = gAlice->TreeD();
1009 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
1011 for(Int_t nSec=1; nSec<=fNTof; nSec++){
1012 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(nSec);
1013 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
1014 for(Int_t nRoc=1; nRoc<=14; nRoc++){
1015 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(nRoc);
1016 Int_t currentItems = currentRoc->GetItems();
1017 for(Int_t item=1; item<currentItems; item++){
1018 Int_t nPad = currentRoc->GetTotPad(item);
1020 Int_t nStrip = (Int_t)(nPad/fPadXStr)+1;
1022 if (nStrip<=fNStripC+2*fNStripB+fNStripA) nPlate = 4;
1023 if (nStrip<=fNStripC+fNStripB+fNStripA) nPlate = 3;
1024 if (nStrip<=fNStripC+fNStripB) nPlate = 2;
1025 if (nStrip<=fNStripC) nPlate=1;
1029 case 2: nStrip -= (fNStripC);
1031 case 3: nStrip -= (fNStripC+fNStripB);
1033 case 4: nStrip -= (fNStripC+fNStripB+fNStripA);
1035 case 5: nStrip -= (fNStripC+2*fNStripB+fNStripA);
1039 Int_t pad = nPad%fPadXStr;
1040 if (pad==0) pad=fPadXStr;
1041 Int_t nPadX=0, nPadZ=0;
1042 (pad>fNpadX)? nPadX -= fNpadX : nPadX = pad ;
1044 (pad>fNpadX)? nPadZ = 2 : nPadZ = 1 ;
1047 Float_t tdc = currentRoc->GetTime(item,error);
1048 if (!error) digit[0]=tdc;
1049 digit[1] = currentRoc->GetCharge(item);
1050 AddDigit(tracks,vol,digit);
1055 tD->Write(0,TObject::kOverwrite);