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.29 2001/10/17 14:19:24 hristov
19 delete replaced by delete []
21 Revision 1.28 2001/10/05 12:02:01 vicinanz
22 Minor improvements on Merger and SDigitizer
24 Revision 1.27 2001/10/02 13:03:13 vicinanz
25 Minor improvements on the code
27 Revision 1.26 2001/09/27 10:39:20 vicinanz
28 SDigitizer and Merger added
30 Revision 1.25 2001/09/07 08:37:40 hristov
31 Pointers initialised to 0 in the default constructor
33 Revision 1.24 2001/09/05 16:31:00 hristov
34 The deletion of TOF folders temporarily commented out
36 Revision 1.23 2001/08/29 12:59:01 vicinanz
37 Minor changes to the Digitizer procedure
39 Revision 1.22 2001/08/28 08:45:58 vicinanz
40 TTask and TFolder structures implemented
42 Revision 1.21 2001/05/16 14:57:24 alibrary
43 New files for folders and Stack
45 Revision 1.20 2001/05/04 10:09:47 vicinanz
46 Major upgrades to the strip structure
48 Revision 1.19 2001/03/12 17:47:25 hristov
49 Changes needed on Sun with CC 5.0
51 Revision 1.18 2001/01/26 19:57:42 hristov
52 Major upgrade of AliRoot code
54 Revision 1.17 2000/10/19 09:58:14 vicinanz
55 Updated Hits2Digit procedure
57 Revision 1.16 2000/10/02 21:28:17 fca
58 Removal of useless dependecies via forward declarations
60 Revision 1.15 2000/05/18 14:33:01 vicinanz
61 Modified to be full HP compliant
63 Revision 1.14 2000/05/15 19:32:36 fca
66 Revision 1.13 2000/05/10 16:52:18 vicinanz
67 New TOF version with holes for PHOS/RICH
69 Revision 1.11.2.1 2000/05/10 09:37:15 vicinanz
70 New version with Holes for PHOS/RICH
72 Revision 1.11 1999/11/05 22:39:06 fca
75 Revision 1.10 1999/11/01 20:41:57 fca
76 Added protections against using the wrong version of FRAME
78 Revision 1.9 1999/10/15 15:35:19 fca
79 New version for frame1099 with and without holes
81 Revision 1.9 1999/09/29 09:24:33 fca
82 Introduction of the Copyright and cvs Log
86 ///////////////////////////////////////////////////////////////////////////////
89 // This class contains the basic functions for the Time Of Flight //
90 // detector. Functions specific to one particular geometry are //
91 // contained in the derived classes //
93 // VERSIONE WITH 5 SYMMETRIC MODULES ALONG Z AXIS
94 // ==============================================
96 // VERSION WITH HOLES FOR PHOS AND TRD IN SPACEFRAME WITH HOLES
98 // Volume sensibile : FPAD
104 <img src="picts/AliTOFClass.gif">
110 ///////////////////////////////////////////////////////////////////////////////
112 #include <iostream.h>
113 #include <strstream.h>
118 #include "AliTOFhit.h"
119 #include "AliTOFdigit.h"
120 #include "AliTOFRawSector.h"
121 #include "AliTOFRoc.h"
122 #include "AliTOFRawDigit.h"
137 #include "AliConst.h"
142 //_____________________________________________________________________________
146 // Default constructor
162 //_____________________________________________________________________________
163 AliTOF::AliTOF(const char *name, const char *title)
164 : AliDetector(name,title)
167 // AliTOF standard constructor
169 // Here are fixed some important parameters
172 // Initialization of hits, sdigits and digits array
174 fHits = new TClonesArray("AliTOFhit", 1000);
175 gAlice->AddHitList(fHits);
177 fSDigits = new TClonesArray("AliTOFdigit", 1000);
178 fDigits = new TClonesArray("AliTOFdigit", 1000);
180 // Digitization parameters
182 // (Transfer Functions to be inserted here)
188 // General Geometrical Parameters
189 fNTof = 18; // number of sectors
192 fZlenC = 177.5;//cm length of module C
193 fZlenB = 141.0;//cm length of module B
194 fZlenA = 106.0;//cm length of module A
195 fZtof = 371.5;//cm total semi-length of TOF detector
198 fStripLn = 122.0;//cm Strip Length
199 fSpace = 5.5;//cm Space Beetween the strip and the bottom of the plate
200 fDeadBndZ= 1.5;//cm Dead Boundaries of a Strip along Z direction (width)
201 fDeadBndX= 1.0;//cm Dead Boundaries of a Strip along X direction (length)
202 fXpad = 2.5;//cm X size of a pad
203 fZpad = 3.5;//cm Z size of a pad
204 fGapA = 4.; //cm Gap beetween tilted strip in A-type plate
205 fGapB = 6.; //cm Gap beetween tilted strip in B-type plate
206 fOverSpc = 15.3;//cm Space available for sensitive layers in radial direction
207 fNpadX = 48; // Number of pads in a strip along the X direction
208 fNpadZ = 2; // Number of pads in a strip along the Z direction
209 fPadXStr = fNpadX*fNpadZ; //Number of pads per strip
210 fNStripA = 15; // number of strips in A type module
211 fNStripB = 19; // number of strips in B type module
212 fNStripC = 20; // number of strips in C type module
214 // Physical performances
218 // DAQ characteristics
219 // cfr. TOF-TDR pag. 105 for Glossary
220 // TARODA : TOF-ALICE Read Out and Data Acquisition system
221 fPadXSector = 8928; // number of pad per sector -with no holes-
222 // ((15+2*19+2*20)*(48*2))
223 fNRoc = 14; // number of Roc (Read Out Controller) (TARODA)
224 fNFec = 32; // number of Fec (Front-End electronic Card)
226 fNTdc = 32; // number of Tdc (Time to Digital Converter)
227 fNPadXRoc = (Int_t)fPadXSector/fNRoc; // number of pads for each ROC
229 // Create TOF Folder Structure
234 //_____________________________________________________________________________
235 void AliTOF::CreateTOFFolders()
237 // create the ALICE TFolder
238 // create the ALICE TTasks
239 // create the ALICE main TFolder
240 // to be done by AliRun
242 TFolder * alice = new TFolder();
243 alice->SetNameTitle("FPAlice", "Alice Folder") ;
244 gROOT->GetListOfBrowsables()->Add(alice) ;
246 TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ;
247 // make it the owner of the objects that it contains
250 TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ;
251 TFolder * aliceT = alice->AddFolder("tasks", "Alice tasks Folder") ;
252 // make it the owner of the objects that it contains
255 TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ;
256 aliceT->Add(aliceDi);
258 TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
259 aliceT->Add(aliceRe);
261 char * tempo = new char[80] ;
263 // creates the TOF Digitizer and adds it to alice main (S)Digitizer task
264 sprintf(tempo, "%sDigitizers container",GetName() ) ;
265 fDTask = new TTask(GetName(), tempo);
266 aliceDi->Add(fDTask) ;
268 // creates the TOF reconstructioner and adds it to alice main Reconstructioner task
269 sprintf(tempo, "%sReconstructioner container",GetName() ) ;
270 fReTask = new TTask(GetName(), tempo);
271 aliceRe->Add(fReTask) ;
275 // creates the TOF geometry folder
276 geomF->AddFolder("TOF", "Geometry for TOF") ;
279 //_____________________________________________________________________________
283 // it remove also the alice folder
284 // and task that TOF creates instead of AliRun
285 /* PH Temporarily commented because of problems
286 TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ;
310 fReconParticles->Delete ();
311 delete fReconParticles;
317 //_____________________________________________________________________________
318 void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits)
322 // new with placement used
324 TClonesArray &lhits = *fHits;
325 new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits);
328 //_____________________________________________________________________________
329 void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
333 // new with placement used
335 TClonesArray &ldigits = *fDigits;
336 new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits);
339 //___________________________________________
340 void AliTOF::AddSDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
347 TClonesArray &lSDigits = *fSDigits;
348 new(lSDigits[fNSDigits++]) AliTOFdigit(tracks, vol, digits);
351 //_____________________________________________________________________________
352 void AliTOF::SetTreeAddress ()
354 // Set branch address for the Hits and Digits Tree.
356 AliDetector::SetTreeAddress ();
359 TTree *treeD = gAlice->TreeD ();
366 branch = treeD->GetBranch (branchname);
368 branch->SetAddress (&fDigits);
373 // fSDigits->Clear ();
375 if (gAlice->TreeS () && fSDigits)
377 branch = gAlice->TreeS ()->GetBranch ("TOF");
379 branch->SetAddress (&fSDigits);
382 if (gAlice->TreeR() && fReconParticles)
384 branch = gAlice->TreeR()->GetBranch("TOF");
385 if (branch) branch->SetAddress(&fReconParticles) ;
389 //_____________________________________________________________________________
390 void AliTOF::CreateGeometry()
393 // Common geometry code
397 <img src="picts/AliTOFv23.gif">
401 const Double_t kPi=TMath::Pi();
402 const Double_t kDegrad=kPi/180.;
404 Float_t xTof, yTof, wall;
406 // frame inbetween TOF modules
409 // Sizes of TOF module with its support etc..
410 xTof = 2.*(fRmin*TMath::Tan(10*kDegrad)-wall/2-.5);
413 // TOF module internal definitions
414 TOFpc(xTof, yTof, fZlenC, fZlenB, fZlenA, fZtof);
417 //_____________________________________________________________________________
418 void AliTOF::DrawModule() const
421 // Draw a shaded view of the common part of the TOF geometry
424 cout << " Drawing of AliTOF"<< endl;
425 // Set everything unseen
426 gMC->Gsatt("*", "seen", -1);
428 // Set ALIC mother transparent
429 gMC->Gsatt("ALIC","SEEN",0);
431 // Set the volumes visible
432 gMC->Gsatt("FTOA","SEEN",1);
433 gMC->Gsatt("FTOB","SEEN",1);
434 gMC->Gsatt("FTOC","SEEN",1);
435 gMC->Gsatt("FLTA","SEEN",1);
436 gMC->Gsatt("FLTB","SEEN",1);
437 gMC->Gsatt("FLTC","SEEN",1);
438 gMC->Gsatt("FSTR","SEEN",1);
440 gMC->Gdopt("hide", "on");
441 gMC->Gdopt("shad", "on");
442 gMC->Gsatt("*", "fill", 7);
443 gMC->SetClipBox(".");
444 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
446 gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
447 gMC->Gdhead(1111, "Time Of Flight");
448 gMC->Gdman(18, 4, "MAN");
449 gMC->Gdopt("hide","off");
452 //_____________________________________________________________________________
453 void AliTOF::CreateMaterials()
456 // Defines TOF materials for all versions
457 // Authors : Maxim Martemianov, Boris Zagreev (ITEP)
459 // Revision: F. Pierella 5-3-2001
460 // Bologna University
462 Int_t isxfld = gAlice->Field()->Integ();
463 Float_t sxmgmx = gAlice->Field()->Max();
466 Float_t aq[2] = { 28.0855,15.9994 };
467 Float_t zq[2] = { 14.,8. };
468 Float_t wq[2] = { 1.,2. };
471 // --- Freon C2F4H2 (TOF-TDR pagg.)
472 // Geant Manual CONS110-1, pag. 43 (Geant, Detector Description and Simulation Tool)
473 Float_t afre[3] = {12.011,18.998,1.007};
474 Float_t zfre[3] = { 6., 9., 1.};
475 Float_t wfre[3] = { 2., 4., 2.};
476 Float_t densfre = 0.00375;
477 // http://www.fi.infn.it/sezione/prevprot/gas/freon.html
480 //-- Isobutane quencher C4H10 (5% in the sensitive mixture)
481 Float_t aiso[2] = {12.011,1.007};
482 Float_t ziso[2] = { 6., 1.};
483 Float_t wiso[2] = { 4., 10.};
484 Float_t densiso = .......; // (g/cm3) density
485 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
486 //-- SF6 (5% in the sensitive mixture)
487 Float_t asf[3] = {32.066,18.998};
488 Float_t zsf[3] = { 16., 9.};
489 Float_t wsf[3] = { 1., 6.};
490 Float_t denssf = .....; // (g/cm3) density
491 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
494 Float_t ac[2] = {12.,16.};
495 Float_t zc[2] = { 6., 8.};
496 Float_t wc[2] = { 1., 2.};
497 Float_t dc = .001977;
499 // For mylar (C5H4O2)
500 Float_t amy[3] = { 12., 1., 16. };
501 Float_t zmy[3] = { 6., 1., 8. };
502 Float_t wmy[3] = { 5., 4., 2. };
505 // For polyethilene (CH2) - honeycomb -
506 Float_t ape[2] = { 12., 1. };
507 Float_t zpe[2] = { 6., 1. };
508 Float_t wpe[2] = { 1., 2. };
509 Float_t dpe = 0.935*0.479; //To have 1%X0 for 1cm as for honeycomb
512 Float_t ag10[4] = { 12.,1.,16.,28. };
513 Float_t zg10[4] = { 6.,1., 8.,14. };
514 Float_t wmatg10[4] = { .259,.288,.248,.205 };
515 Float_t densg10 = 1.7;
518 Float_t adme[5] = { 12.,1.,16.,19.,79. };
519 Float_t zdme[5] = { 6.,1., 8., 9.,35. };
520 Float_t wmatdme[5] = { .4056,.0961,.2562,.1014,.1407 };
521 Float_t densdme = .00205;
523 // ---- ALUMINA (AL203)
524 Float_t aal[2] = { 27.,16.};
525 Float_t zal[2] = { 13., 8.};
526 Float_t wmatal[2] = { 2.,3. };
527 Float_t densal = 2.3;
530 Float_t awa[2] = { 1., 16. };
531 Float_t zwa[2] = { 1., 8. };
532 Float_t wwa[2] = { 2., 1. };
536 //AliMaterial(0, "Vacuum$", 1e-16, 1e-16, 1e-16, 1e16, 1e16);
537 AliMaterial( 1, "Air$",14.61,7.3,0.001205,30423.24,67500.);
538 AliMaterial( 2, "Cu $", 63.54, 29.0, 8.96, 1.43, 14.8);
539 AliMaterial( 3, "C $", 12.01, 6.0, 2.265,18.8, 74.4);
540 AliMixture ( 4, "Polyethilene$", ape, zpe, dpe, npe, wpe);
541 AliMixture ( 5, "G10$", ag10, zg10, densg10, nlmatg10, wmatg10);
542 AliMixture ( 6, "DME ", adme, zdme, densdme, nlmatdme, wmatdme);
543 AliMixture ( 7, "CO2$", ac, zc, dc, nc, wc);
544 AliMixture ( 8, "ALUMINA$", aal, zal, densal, nlmatal, wmatal);
545 AliMaterial( 9, "Al $", 26.98, 13., 2.7, 8.9, 37.2);
546 AliMaterial(10, "C-TRD$", 12.01, 6., 2.265*18.8/69.282*15./100, 18.8, 74.4); // for 15%
547 AliMixture (11, "Mylar$", amy, zmy, dmy, nmy, wmy);
548 AliMixture (12, "Freon$", afre, zfre, densfre, nfre, wfre);
549 AliMixture (13, "Quartz$", aq, zq, dq, nq, wq);
550 AliMixture (14, "Water$", awa, zwa, dwa, nwa, wwa);
552 Float_t epsil, stmin, deemax, stemax;
555 // EPSIL = 0.1 ! Tracking precision,
556 // STEMAX = 0.1 ! Maximum displacement for multiple scattering
557 // DEEMAX = 0.1 ! Maximum fractional energy loss, DLS
561 epsil = .001; // Tracking precision,
562 stemax = -1.; // Maximum displacement for multiple scattering
563 deemax = -.3; // Maximum fractional energy loss, DLS
566 AliMedium( 1, "Air$" , 1, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
567 AliMedium( 2, "Cu $" , 2, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
568 AliMedium( 3, "C $" , 3, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
569 AliMedium( 4, "Pol$" , 4, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
570 AliMedium( 5, "G10$" , 5, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
571 AliMedium( 6, "DME$" , 6, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
572 AliMedium( 7, "CO2$" , 7, 0, isxfld, sxmgmx, 10., -.01, -.1, .01, -.01);
573 AliMedium( 8,"ALUMINA$", 8, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
574 AliMedium( 9,"Al Frame$",9, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
575 AliMedium(10, "DME-S$", 6, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
576 AliMedium(11, "C-TRD$", 10, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
577 AliMedium(12, "Myl$" , 11, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
578 AliMedium(13, "Fre$" , 12, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
579 AliMedium(14, "Fre-S$", 12, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
580 AliMedium(15, "Glass$", 13, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
581 AliMedium(16, "Water$", 14, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
584 //_____________________________________________________________________________
585 Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t ) const
588 // Returns distance from mouse pointer to detector, default version
593 //___________________________________________
594 void AliTOF::ResetHits ()
596 // Reset number of clusters and the cluster array for this detector
597 AliDetector::ResetHits ();
600 //____________________________________________
601 void AliTOF::ResetDigits ()
604 // Reset number of digits and the digits array for this detector
605 AliDetector::ResetDigits ();
608 //_____________________________________________________________________________
612 // Initialise TOF detector after it has been built
614 // Set id of TOF sensitive volume
615 if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD");
619 //____________________________________________________________________________
620 void AliTOF::MakeBranch(Option_t* option, const char *file)
623 // Initializes the Branches of the TOF inside the
624 // trees written for each event.
625 // AliDetector::MakeBranch initializes just the
626 // Branch inside TreeH. Here we add the branches in
627 // TreeD, TreeS and TreeR.
629 AliDetector::MakeBranch(option,file);
631 Int_t buffersize = 4000;
632 Char_t branchname[10];
633 sprintf(branchname,"%s",GetName());
635 const char *oD = strstr(option,"D");
636 const char *oS = strstr(option,"S");
637 const char *oR = strstr(option,"R");
641 // one branch for TOF digits
645 if (fDigits && gAlice->TreeD() && oD){
646 MakeBranchInTree(gAlice->TreeD(),
647 branchname, &fDigits,buffersize, file) ;
652 // one branch for TOF sdigits
656 if (fSDigits && gAlice->TreeS() && oS){
657 MakeBranchInTree(gAlice->TreeS(),
658 branchname, &fSDigits,buffersize, file) ;
663 // one branch for TOF reconstructed particles
667 if (fReconParticles && gAlice->TreeR() && oR){
668 MakeBranchInTree(gAlice->TreeR(),
669 branchname, &fReconParticles,buffersize, file) ;
674 //____________________________________________________________________________
675 void AliTOF::Makehits(Bool_t hits)
677 // default argument used, see AliTOF.h
678 // Enable/Disable the writing of the TOF-hits branch
680 // by default : enabled for TOFv1, v2, v3, v4
681 // disabled for TOFv0
683 if (hits && (IsVersion()!=0))
684 fIdSens = gMC->VolId("FPAD");
686 cout << "Option for writing the TOF-hits branch on TreeH: disabled" << endl;
689 //____________________________________________________________________________
690 void AliTOF::FinishEvent()
695 //___________________________________________
696 void AliTOF::SDigits2Digits()
699 // Generate digits performing merging
702 int nparticles = gAlice->GetNtrack();
703 cout << "Particles :" <<nparticles<<endl;
704 if (nparticles > 0 ) {
706 AliTOF::Hits2Digits();
710 cout<<"AliTOF::SDigits2Digits"<<endl;
713 cout<<"AliTOF::SDigits2Digits Init"<<endl;
715 cout<<"AliTOF::SDigits2Digits Digitise() "<<endl;
719 //---------------------------------------------------------------------
720 void AliTOF::SetMerger(AliTOFMerger* merger)
722 // Set pointer to merger
726 //---------------------------------------------------------------------
727 AliTOFMerger* AliTOF::Merger()
729 // Return pointer to merger
733 //____________________________________________________________________________
734 void AliTOF::TOFHits2SDigits()
737 // Starting from the Hits Tree (TreeH), this
738 // function writes the TOF SDigits Branch in the TreeS storing
739 // the digits informations.
740 // It has to be called just at the end of an event or
741 // at the end of a whole run.
742 // It could also be called by AliTOF::Finish Event()
743 // Just for MC events.
745 // Called by the ROOT script Hits2SDigits.C
747 // Simulation of detector response.
749 Int_t ver = this->IsVersion();
750 if(ver==0) return; // no sdigits for AliTOFv0
752 AliTOF *TOF = (AliTOF *) gAlice->GetDetector ("TOF");
755 fNevents = (Int_t) gAlice->TreeE ()->GetEntries ();
757 cout << "nevents found on file " << fNevents << endl;
758 // Start Event ------------------------- LOOP
760 for (Int_t ievent = 0; ievent < fNevents; ievent++)
762 gAlice->GetEvent (ievent);
763 if (gAlice->TreeH () == 0)
764 return; // no hits stored
765 if (gAlice->TreeS () == 0)
766 gAlice->MakeTree ("S");
773 sprintf (branchname, "%s", TOF->GetName ());
774 //Make branch for TOF sdigits
775 TOF->MakeBranch ("S");
777 Int_t tracks[3]; // track info
778 Int_t vol[5]; // location for a digit
779 Float_t digit[2]; // TOF digit variables
783 TClonesArray *TOFhits = TOF->Hits();
788 TOFhits = TOF->Hits(); // pointer to the TClonesArray of TOF hits
789 TTree *TH = gAlice->TreeH(); // pointer to the current TreeH
790 Stat_t ntracks = TH->GetEntries(); // number of tracks for the current event
791 for (Int_t track = 0; track < ntracks; track++)
793 gAlice->ResetHits ();
794 nbytes += TH->GetEvent(track);
795 particle = gAlice->Particle(track);
796 Int_t nhits = TOFhits->GetEntriesFast(); // number of hits for the current track
798 for (hit = 0; hit < nhits; hit++)
800 tofHit = (AliTOFhit*) TOFhits->UncheckedAt(hit);
801 vol[0] = tofHit->GetSector();
802 vol[1] = tofHit->GetPlate();
803 vol[2] = tofHit->GetStrip();
804 vol[3] = tofHit->GetPadx();
805 vol[4] = tofHit->GetPadz();
807 // 95% of efficiency to be inserted here
808 // edge effect to be inserted here
809 // cross talk to be inserted here
811 Float_t idealtime = tofHit->GetTof(); // unit s
812 idealtime *= 1.E+12; // conversion from s to ps
813 // fTimeRes is given usually in ps
814 Float_t tdctime = gRandom->Gaus(idealtime, fTimeRes);
817 // typical Landau Distribution to be inserted here
818 // instead of Gaussian Distribution
819 Float_t idealcharge = tofHit->GetEdep();
820 Float_t adccharge = gRandom->Gaus(idealcharge, fChrgRes);
821 digit[1] = adccharge;
822 Int_t tracknum = tofHit->GetTrack();
823 tracks[0] = tracknum;
827 // check if two digit are on the same pad; in that case we sum
828 // the two or more digits
829 Bool_t overlap = CheckOverlap(vol, digit, tracknum);
831 new ((*fSDigits)[nSdigits++]) AliTOFdigit(tracks, vol, digit);
832 //cout << "nSdigits" << endl;
833 } // end loop on hits for the current track
835 } // end loop on ntracks
837 } // close if TOF switched ON
839 gAlice->TreeS()->Fill();
840 gAlice->TreeS()->Print();
846 //---------------------------------------------------------------------
848 void AliTOF::Hits2SDigits()
851 // Use the TOF SDigitizer to make TOF SDigits
855 cout<<"ALiTOF::Hits2SDigits> start...\n";
858 char * fileSDigits = 0 ;
859 char * fileHeader = 0;
860 AliTOFSDigitizer * sd = new AliTOFSDigitizer(fileHeader,fileSDigits) ;
868 //___________________________________________________________________________
869 Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
872 // Checks if 2 or more hits belong to the same pad.
873 // In this case the data assigned to the digit object
874 // are the ones of the first hit in order of Time.
875 // 2 hits from the same track on the same pad are collected.
876 // Called only by Hits2SDigits.
877 // This procedure has to be optimized in the next TOF release.
880 Bool_t overlap = kFALSE;
883 for (Int_t ndig=0; ndig<fSDigits->GetEntries(); ndig++){
884 AliTOFdigit* currentDigit = (AliTOFdigit*)(fSDigits->UncheckedAt(ndig));
885 currentDigit->GetLocation(vol2);
887 // check on digit volume
888 for (Int_t i=0;i<=4;i++){
890 if (vol[i]!=vol2[i]) idem=kFALSE;}
892 if (idem){ // same pad fired
893 Float_t tdc2 = digit[0];
894 Float_t tdc1 = currentDigit->GetTdc();
896 // we separate two digits on the same pad if
897 // they are separated in time by at least 25 ns
898 // remember that tdc time is given in ps
900 if (TMath::Abs(tdc1-tdc2)<25000){
901 // in case of overlap we take the earliest
903 currentDigit->SetTdc(tdc2);
904 currentDigit->SetAdc(digit[1]);
907 currentDigit->SetTdc(tdc1);
908 currentDigit->SetAdc(digit[1]);
910 currentDigit->AddTrack(Track); // add track number in the track array
916 } // close if (idem) -> two digits on the same TOF pad
918 } // end loop on existing sdigits
924 //____________________________________________________________________________
925 void AliTOF::Digits2Raw(Int_t evNumber)
928 // Starting from digits, writes the
929 // Raw Data objects, i.e. a
930 // TClonesArray of 18 AliTOFRawSector objects
935 // do nothing if no particles
936 Int_t nparticles = gAlice->GetEvent(evNumber);
937 if (nparticles <= 0) return;
939 tD = gAlice->TreeD();
941 TClonesArray* tofdigits = this->Digits();
942 Int_t ndigits = tofdigits->GetEntriesFast();
944 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
946 for (Int_t isect=1;isect<=fNTof;isect++){
947 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(isect);
948 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
950 for (Int_t digit=0; digit<ndigits; digit++){
951 AliTOFdigit* currentDigit = (AliTOFdigit*)tofdigits->UncheckedAt(digit);
952 Int_t sector = currentDigit->GetSector();
954 Int_t pad = currentDigit -> GetTotPad();
955 Int_t roc = (Int_t)(pad/fNPadXRoc)-1;
956 if (roc>=fNRoc) printf("Wrong n. of ROC ! Roc = %i",roc);
957 Int_t padRoc = (Int_t) pad%fNPadXRoc;
958 Int_t fec = (Int_t)(padRoc/fNFec)-1;
959 Int_t tdc = (Int_t)(padRoc%fNFec)-1;
960 Float_t time = currentDigit->GetTdc();
961 Float_t charge = currentDigit->GetAdc();
962 AliTOFRoc* currentROC = (AliTOFRoc*)rocData->UncheckedAt(roc);
964 currentROC->AddItem(fec, tdc, error, charge, time);
965 } // close if (sector==isect) i.e. end loop on digits for the current sector
966 } // end loop on TOF digits
968 UInt_t totSize=16,rocSize=0;
969 UInt_t rocHead[14],rocChek[14];
970 UInt_t globalCheckSum=0;
972 for (UInt_t iRoc = 1; iRoc<(UInt_t)fNRoc; iRoc++){
973 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(iRoc);
974 rocSize = currentRoc->GetItems()*2+1;
975 totSize += rocSize*4;
976 if (rocSize>=TMath::Power(2,16)) rocSize=0;
977 rocHead[iRoc] = iRoc<<28;
978 rocHead[iRoc] += rocSize;
979 rocChek[iRoc] = currentRoc->GetCheckSum();
980 Int_t headCheck = currentRoc->BitCount(rocHead[iRoc]);
981 globalCheckSum += headCheck;
982 globalCheckSum += rocChek[iRoc];
985 AliTOFRoc* dummyRoc = new AliTOFRoc();
987 if (totSize>=TMath::Power(2,24)) totSize=0;
988 UInt_t header = totSize;
989 UInt_t sectId = ((UInt_t)isect)<<24;
991 globalCheckSum += dummyRoc->BitCount(header);
992 currentSector->SetGlobalCS(globalCheckSum);
993 currentSector->SetHeader(header);
997 //____________________________________________________________________________
998 void AliTOF::Raw2Digits(Int_t evNumber)
1001 // Converts Raw Data objects into digits objects.
1002 // We schematize the raw data with a
1003 // TClonesArray of 18 AliTOFRawSector objects
1015 Int_t nparticles = gAlice->GetEvent(evNumber);
1016 if (nparticles <= 0) return;
1018 tD = gAlice->TreeD();
1020 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
1022 for(Int_t nSec=1; nSec<=fNTof; nSec++){
1023 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(nSec);
1024 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
1025 for(Int_t nRoc=1; nRoc<=14; nRoc++){
1026 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(nRoc);
1027 Int_t currentItems = currentRoc->GetItems();
1028 for(Int_t item=1; item<currentItems; item++){
1029 Int_t nPad = currentRoc->GetTotPad(item);
1031 Int_t nStrip = (Int_t)(nPad/fPadXStr)+1;
1033 if (nStrip<=fNStripC+2*fNStripB+fNStripA) nPlate = 4;
1034 if (nStrip<=fNStripC+fNStripB+fNStripA) nPlate = 3;
1035 if (nStrip<=fNStripC+fNStripB) nPlate = 2;
1036 if (nStrip<=fNStripC) nPlate=1;
1040 case 2: nStrip -= (fNStripC);
1042 case 3: nStrip -= (fNStripC+fNStripB);
1044 case 4: nStrip -= (fNStripC+fNStripB+fNStripA);
1046 case 5: nStrip -= (fNStripC+2*fNStripB+fNStripA);
1050 Int_t pad = nPad%fPadXStr;
1051 if (pad==0) pad=fPadXStr;
1052 Int_t nPadX=0, nPadZ=0;
1053 (pad>fNpadX)? nPadX -= fNpadX : nPadX = pad ;
1055 (pad>fNpadX)? nPadZ = 2 : nPadZ = 1 ;
1058 Float_t tdc = currentRoc->GetTime(item,error);
1059 if (!error) digit[0]=tdc;
1060 digit[1] = currentRoc->GetCharge(item);
1061 AddDigit(tracks,vol,digit);
1066 tD->Write(0,TObject::kOverwrite);