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.30 2001/10/21 18:30:39 hristov
19 Several pointers were set to zero in the default constructors to avoid memory management problems
21 Revision 1.29 2001/10/17 14:19:24 hristov
22 delete replaced by delete []
24 Revision 1.28 2001/10/05 12:02:01 vicinanz
25 Minor improvements on Merger and SDigitizer
27 Revision 1.27 2001/10/02 13:03:13 vicinanz
28 Minor improvements on the code
30 Revision 1.26 2001/09/27 10:39:20 vicinanz
31 SDigitizer and Merger added
33 Revision 1.25 2001/09/07 08:37:40 hristov
34 Pointers initialised to 0 in the default constructor
36 Revision 1.24 2001/09/05 16:31:00 hristov
37 The deletion of TOF folders temporarily commented out
39 Revision 1.23 2001/08/29 12:59:01 vicinanz
40 Minor changes to the Digitizer procedure
42 Revision 1.22 2001/08/28 08:45:58 vicinanz
43 TTask and TFolder structures implemented
45 Revision 1.21 2001/05/16 14:57:24 alibrary
46 New files for folders and Stack
48 Revision 1.20 2001/05/04 10:09:47 vicinanz
49 Major upgrades to the strip structure
51 Revision 1.19 2001/03/12 17:47:25 hristov
52 Changes needed on Sun with CC 5.0
54 Revision 1.18 2001/01/26 19:57:42 hristov
55 Major upgrade of AliRoot code
57 Revision 1.17 2000/10/19 09:58:14 vicinanz
58 Updated Hits2Digit procedure
60 Revision 1.16 2000/10/02 21:28:17 fca
61 Removal of useless dependecies via forward declarations
63 Revision 1.15 2000/05/18 14:33:01 vicinanz
64 Modified to be full HP compliant
66 Revision 1.14 2000/05/15 19:32:36 fca
69 Revision 1.13 2000/05/10 16:52:18 vicinanz
70 New TOF version with holes for PHOS/RICH
72 Revision 1.11.2.1 2000/05/10 09:37:15 vicinanz
73 New version with Holes for PHOS/RICH
75 Revision 1.11 1999/11/05 22:39:06 fca
78 Revision 1.10 1999/11/01 20:41:57 fca
79 Added protections against using the wrong version of FRAME
81 Revision 1.9 1999/10/15 15:35:19 fca
82 New version for frame1099 with and without holes
84 Revision 1.9 1999/09/29 09:24:33 fca
85 Introduction of the Copyright and cvs Log
89 ///////////////////////////////////////////////////////////////////////////////
92 // This class contains the basic functions for the Time Of Flight //
93 // detector. Functions specific to one particular geometry are //
94 // contained in the derived classes //
96 // VERSIONE WITH 5 SYMMETRIC MODULES ALONG Z AXIS
97 // ==============================================
99 // VERSION WITH HOLES FOR PHOS AND TRD IN SPACEFRAME WITH HOLES
101 // Volume sensibile : FPAD
107 <img src="picts/AliTOFClass.gif">
113 ///////////////////////////////////////////////////////////////////////////////
115 #include <iostream.h>
116 #include <strstream.h>
121 #include "AliTOFhit.h"
122 #include "AliTOFdigit.h"
123 #include "AliTOFSDigit.h"
124 #include "AliTOFRawSector.h"
125 #include "AliTOFRoc.h"
126 #include "AliTOFRawDigit.h"
141 #include "AliConst.h"
146 //_____________________________________________________________________________
150 // Default constructor
166 //_____________________________________________________________________________
167 AliTOF::AliTOF(const char *name, const char *title)
168 : AliDetector(name,title)
171 // AliTOF standard constructor
173 // Here are fixed some important parameters
176 // Initialization of hits, sdigits and digits array
178 fHits = new TClonesArray("AliTOFhit", 1000);
179 gAlice->AddHitList(fHits);
181 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
182 fDigits = new TClonesArray("AliTOFdigit", 1000);
184 // Digitization parameters
186 // (Transfer Functions to be inserted here)
192 // General Geometrical Parameters
193 fNTof = 18; // number of sectors
196 fZlenC = 177.5;//cm length of module C
197 fZlenB = 141.0;//cm length of module B
198 fZlenA = 106.0;//cm length of module A
199 fZtof = 371.5;//cm total semi-length of TOF detector
202 fStripLn = 122.0;//cm Strip Length
203 fSpace = 5.5;//cm Space Beetween the strip and the bottom of the plate
204 fDeadBndZ= 1.5;//cm Dead Boundaries of a Strip along Z direction (width)
205 fDeadBndX= 1.0;//cm Dead Boundaries of a Strip along X direction (length)
206 fXpad = 2.5;//cm X size of a pad
207 fZpad = 3.5;//cm Z size of a pad
208 fGapA = 4.; //cm Gap beetween tilted strip in A-type plate
209 fGapB = 6.; //cm Gap beetween tilted strip in B-type plate
210 fOverSpc = 15.3;//cm Space available for sensitive layers in radial direction
211 fNpadX = 48; // Number of pads in a strip along the X direction
212 fNpadZ = 2; // Number of pads in a strip along the Z direction
213 fPadXStr = fNpadX*fNpadZ; //Number of pads per strip
214 fNStripA = 15; // number of strips in A type module
215 fNStripB = 19; // number of strips in B type module
216 fNStripC = 20; // number of strips in C type module
218 // Physical performances
222 // DAQ characteristics
223 // cfr. TOF-TDR pag. 105 for Glossary
224 // TARODA : TOF-ALICE Read Out and Data Acquisition system
225 fPadXSector = 8928; // number of pad per sector -with no holes-
226 // ((15+2*19+2*20)*(48*2))
227 fNRoc = 14; // number of Roc (Read Out Controller) (TARODA)
228 fNFec = 32; // number of Fec (Front-End electronic Card)
230 fNTdc = 32; // number of Tdc (Time to Digital Converter)
231 fNPadXRoc = (Int_t)fPadXSector/fNRoc; // number of pads for each ROC
233 // Create TOF Folder Structure
238 //_____________________________________________________________________________
239 void AliTOF::CreateTOFFolders()
241 // create the ALICE TFolder
242 // create the ALICE TTasks
243 // create the ALICE main TFolder
244 // to be done by AliRun
246 TFolder * alice = new TFolder();
247 alice->SetNameTitle("FPAlice", "Alice Folder") ;
248 gROOT->GetListOfBrowsables()->Add(alice) ;
250 TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ;
251 // make it the owner of the objects that it contains
254 TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ;
255 TFolder * aliceT = alice->AddFolder("tasks", "Alice tasks Folder") ;
256 // make it the owner of the objects that it contains
259 TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ;
260 aliceT->Add(aliceDi);
262 TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
263 aliceT->Add(aliceRe);
265 char * tempo = new char[80] ;
267 // creates the TOF Digitizer and adds it to alice main (S)Digitizer task
268 sprintf(tempo, "%sDigitizers container",GetName() ) ;
269 fDTask = new TTask(GetName(), tempo);
270 aliceDi->Add(fDTask) ;
272 // creates the TOF reconstructioner and adds it to alice main Reconstructioner task
273 sprintf(tempo, "%sReconstructioner container",GetName() ) ;
274 fReTask = new TTask(GetName(), tempo);
275 aliceRe->Add(fReTask) ;
279 // creates the TOF geometry folder
280 geomF->AddFolder("TOF", "Geometry for TOF") ;
283 //_____________________________________________________________________________
287 // it remove also the alice folder
288 // and task that TOF creates instead of AliRun
289 /* PH Temporarily commented because of problems
290 TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ;
314 fReconParticles->Delete ();
315 delete fReconParticles;
321 //_____________________________________________________________________________
322 void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits)
326 // new with placement used
328 TClonesArray &lhits = *fHits;
329 new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits);
332 //_____________________________________________________________________________
333 void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
337 // new with placement used
339 TClonesArray &ldigits = *fDigits;
340 new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits);
343 //___________________________________________
344 void AliTOF::AddSDigit(Int_t tracknum, Int_t *vol, Float_t *digits)
351 TClonesArray &lSDigits = *fSDigits;
352 new(lSDigits[fNSDigits++]) AliTOFSDigit(tracknum, vol, digits);
355 //_____________________________________________________________________________
356 void AliTOF::SetTreeAddress ()
358 // Set branch address for the Hits and Digits Tree.
360 AliDetector::SetTreeAddress ();
363 TTree *treeD = gAlice->TreeD ();
370 branch = treeD->GetBranch (branchname);
372 branch->SetAddress (&fDigits);
377 // fSDigits->Clear ();
379 if (gAlice->TreeS () && fSDigits)
381 branch = gAlice->TreeS ()->GetBranch ("TOF");
383 branch->SetAddress (&fSDigits);
386 if (gAlice->TreeR() && fReconParticles)
388 branch = gAlice->TreeR()->GetBranch("TOF");
389 if (branch) branch->SetAddress(&fReconParticles) ;
393 //_____________________________________________________________________________
394 void AliTOF::CreateGeometry()
397 // Common geometry code
401 <img src="picts/AliTOFv23.gif">
405 const Double_t kPi=TMath::Pi();
406 const Double_t kDegrad=kPi/180.;
408 Float_t xTof, yTof, wall;
410 // frame inbetween TOF modules
413 // Sizes of TOF module with its support etc..
414 xTof = 2.*(fRmin*TMath::Tan(10*kDegrad)-wall/2-.5);
417 // TOF module internal definitions
418 TOFpc(xTof, yTof, fZlenC, fZlenB, fZlenA, fZtof);
421 //_____________________________________________________________________________
422 void AliTOF::DrawModule() const
425 // Draw a shaded view of the common part of the TOF geometry
428 cout << " Drawing of AliTOF"<< endl;
429 // Set everything unseen
430 gMC->Gsatt("*", "seen", -1);
432 // Set ALIC mother transparent
433 gMC->Gsatt("ALIC","SEEN",0);
435 // Set the volumes visible
436 gMC->Gsatt("FTOA","SEEN",1);
437 gMC->Gsatt("FTOB","SEEN",1);
438 gMC->Gsatt("FTOC","SEEN",1);
439 gMC->Gsatt("FLTA","SEEN",1);
440 gMC->Gsatt("FLTB","SEEN",1);
441 gMC->Gsatt("FLTC","SEEN",1);
442 gMC->Gsatt("FSTR","SEEN",1);
444 gMC->Gdopt("hide", "on");
445 gMC->Gdopt("shad", "on");
446 gMC->Gsatt("*", "fill", 7);
447 gMC->SetClipBox(".");
448 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
450 gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
451 gMC->Gdhead(1111, "Time Of Flight");
452 gMC->Gdman(18, 4, "MAN");
453 gMC->Gdopt("hide","off");
456 //_____________________________________________________________________________
457 void AliTOF::CreateMaterials()
460 // Defines TOF materials for all versions
461 // Authors : Maxim Martemianov, Boris Zagreev (ITEP)
463 // Revision: F. Pierella 5-3-2001
464 // Bologna University
466 Int_t isxfld = gAlice->Field()->Integ();
467 Float_t sxmgmx = gAlice->Field()->Max();
470 Float_t aq[2] = { 28.0855,15.9994 };
471 Float_t zq[2] = { 14.,8. };
472 Float_t wq[2] = { 1.,2. };
475 // --- Freon C2F4H2 (TOF-TDR pagg.)
476 // Geant Manual CONS110-1, pag. 43 (Geant, Detector Description and Simulation Tool)
477 Float_t afre[3] = {12.011,18.998,1.007};
478 Float_t zfre[3] = { 6., 9., 1.};
479 Float_t wfre[3] = { 2., 4., 2.};
480 Float_t densfre = 0.00375;
481 // http://www.fi.infn.it/sezione/prevprot/gas/freon.html
484 //-- Isobutane quencher C4H10 (5% in the sensitive mixture)
485 Float_t aiso[2] = {12.011,1.007};
486 Float_t ziso[2] = { 6., 1.};
487 Float_t wiso[2] = { 4., 10.};
488 Float_t densiso = .......; // (g/cm3) density
489 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
490 //-- SF6 (5% in the sensitive mixture)
491 Float_t asf[3] = {32.066,18.998};
492 Float_t zsf[3] = { 16., 9.};
493 Float_t wsf[3] = { 1., 6.};
494 Float_t denssf = .....; // (g/cm3) density
495 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
498 Float_t ac[2] = {12.,16.};
499 Float_t zc[2] = { 6., 8.};
500 Float_t wc[2] = { 1., 2.};
501 Float_t dc = .001977;
503 // For mylar (C5H4O2)
504 Float_t amy[3] = { 12., 1., 16. };
505 Float_t zmy[3] = { 6., 1., 8. };
506 Float_t wmy[3] = { 5., 4., 2. };
509 // For polyethilene (CH2) - honeycomb -
510 Float_t ape[2] = { 12., 1. };
511 Float_t zpe[2] = { 6., 1. };
512 Float_t wpe[2] = { 1., 2. };
513 Float_t dpe = 0.935*0.479; //To have 1%X0 for 1cm as for honeycomb
516 Float_t ag10[4] = { 12.,1.,16.,28. };
517 Float_t zg10[4] = { 6.,1., 8.,14. };
518 Float_t wmatg10[4] = { .259,.288,.248,.205 };
519 Float_t densg10 = 1.7;
522 Float_t adme[5] = { 12.,1.,16.,19.,79. };
523 Float_t zdme[5] = { 6.,1., 8., 9.,35. };
524 Float_t wmatdme[5] = { .4056,.0961,.2562,.1014,.1407 };
525 Float_t densdme = .00205;
527 // ---- ALUMINA (AL203)
528 Float_t aal[2] = { 27.,16.};
529 Float_t zal[2] = { 13., 8.};
530 Float_t wmatal[2] = { 2.,3. };
531 Float_t densal = 2.3;
534 Float_t awa[2] = { 1., 16. };
535 Float_t zwa[2] = { 1., 8. };
536 Float_t wwa[2] = { 2., 1. };
540 //AliMaterial(0, "Vacuum$", 1e-16, 1e-16, 1e-16, 1e16, 1e16);
541 AliMaterial( 1, "Air$",14.61,7.3,0.001205,30423.24,67500.);
542 AliMaterial( 2, "Cu $", 63.54, 29.0, 8.96, 1.43, 14.8);
543 AliMaterial( 3, "C $", 12.01, 6.0, 2.265,18.8, 74.4);
544 AliMixture ( 4, "Polyethilene$", ape, zpe, dpe, npe, wpe);
545 AliMixture ( 5, "G10$", ag10, zg10, densg10, nlmatg10, wmatg10);
546 AliMixture ( 6, "DME ", adme, zdme, densdme, nlmatdme, wmatdme);
547 AliMixture ( 7, "CO2$", ac, zc, dc, nc, wc);
548 AliMixture ( 8, "ALUMINA$", aal, zal, densal, nlmatal, wmatal);
549 AliMaterial( 9, "Al $", 26.98, 13., 2.7, 8.9, 37.2);
550 AliMaterial(10, "C-TRD$", 12.01, 6., 2.265*18.8/69.282*15./100, 18.8, 74.4); // for 15%
551 AliMixture (11, "Mylar$", amy, zmy, dmy, nmy, wmy);
552 AliMixture (12, "Freon$", afre, zfre, densfre, nfre, wfre);
553 AliMixture (13, "Quartz$", aq, zq, dq, nq, wq);
554 AliMixture (14, "Water$", awa, zwa, dwa, nwa, wwa);
556 Float_t epsil, stmin, deemax, stemax;
559 // EPSIL = 0.1 ! Tracking precision,
560 // STEMAX = 0.1 ! Maximum displacement for multiple scattering
561 // DEEMAX = 0.1 ! Maximum fractional energy loss, DLS
565 epsil = .001; // Tracking precision,
566 stemax = -1.; // Maximum displacement for multiple scattering
567 deemax = -.3; // Maximum fractional energy loss, DLS
570 AliMedium( 1, "Air$" , 1, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
571 AliMedium( 2, "Cu $" , 2, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
572 AliMedium( 3, "C $" , 3, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
573 AliMedium( 4, "Pol$" , 4, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
574 AliMedium( 5, "G10$" , 5, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
575 AliMedium( 6, "DME$" , 6, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
576 AliMedium( 7, "CO2$" , 7, 0, isxfld, sxmgmx, 10., -.01, -.1, .01, -.01);
577 AliMedium( 8,"ALUMINA$", 8, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
578 AliMedium( 9,"Al Frame$",9, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
579 AliMedium(10, "DME-S$", 6, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
580 AliMedium(11, "C-TRD$", 10, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
581 AliMedium(12, "Myl$" , 11, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
582 AliMedium(13, "Fre$" , 12, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
583 AliMedium(14, "Fre-S$", 12, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
584 AliMedium(15, "Glass$", 13, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
585 AliMedium(16, "Water$", 14, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
588 //_____________________________________________________________________________
589 Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t ) const
592 // Returns distance from mouse pointer to detector, default version
597 //___________________________________________
598 void AliTOF::ResetHits ()
600 // Reset number of clusters and the cluster array for this detector
601 AliDetector::ResetHits ();
604 //____________________________________________
605 void AliTOF::ResetDigits ()
608 // Reset number of digits and the digits array for this detector
609 AliDetector::ResetDigits ();
612 //_____________________________________________________________________________
616 // Initialise TOF detector after it has been built
618 // Set id of TOF sensitive volume
619 if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD");
623 //____________________________________________________________________________
624 void AliTOF::MakeBranch(Option_t* option, const char *file)
627 // Initializes the Branches of the TOF inside the
628 // trees written for each event.
629 // AliDetector::MakeBranch initializes just the
630 // Branch inside TreeH. Here we add the branches in
631 // TreeD, TreeS and TreeR.
633 AliDetector::MakeBranch(option,file);
635 Int_t buffersize = 4000;
636 Char_t branchname[10];
637 sprintf(branchname,"%s",GetName());
639 const char *oD = strstr(option,"D");
640 const char *oS = strstr(option,"S");
641 const char *oR = strstr(option,"R");
645 // one branch for TOF digits
649 if (fDigits && gAlice->TreeD() && oD){
650 MakeBranchInTree(gAlice->TreeD(),
651 branchname, &fDigits,buffersize, file) ;
656 // one branch for TOF sdigits
660 if (fSDigits && gAlice->TreeS() && oS){
661 MakeBranchInTree(gAlice->TreeS(),
662 branchname, &fSDigits,buffersize, file) ;
667 // one branch for TOF reconstructed particles
671 if (fReconParticles && gAlice->TreeR() && oR){
672 MakeBranchInTree(gAlice->TreeR(),
673 branchname, &fReconParticles,buffersize, file) ;
678 //____________________________________________________________________________
679 void AliTOF::Makehits(Bool_t hits)
681 // default argument used, see AliTOF.h
682 // Enable/Disable the writing of the TOF-hits branch
684 // by default : enabled for TOFv1, v2, v3, v4
685 // disabled for TOFv0
687 if (hits && (IsVersion()!=0))
688 fIdSens = gMC->VolId("FPAD");
690 cout << "Option for writing the TOF-hits branch on TreeH: disabled" << endl;
693 //____________________________________________________________________________
694 void AliTOF::FinishEvent()
699 //___________________________________________
700 void AliTOF::SDigits2Digits()
703 // Generate digits performing merging
706 int nparticles = gAlice->GetNtrack();
707 cout << "Particles :" <<nparticles<<endl;
708 if (nparticles > 0 ) {
710 AliTOF::Hits2Digits();
714 cout<<"AliTOF::SDigits2Digits"<<endl;
717 cout<<"AliTOF::SDigits2Digits Init"<<endl;
719 cout<<"AliTOF::SDigits2Digits Digitise() "<<endl;
723 //---------------------------------------------------------------------
724 void AliTOF::SetMerger(AliTOFMerger* merger)
726 // Set pointer to merger
730 //---------------------------------------------------------------------
731 AliTOFMerger* AliTOF::Merger()
733 // Return pointer to merger
738 //---------------------------------------------------------------------
740 void AliTOF::Hits2SDigits()
743 // Use the TOF SDigitizer to make TOF SDigits
747 cout<<"ALiTOF::Hits2SDigits> start...\n";
750 char * fileSDigits = 0 ;
751 char * fileHeader = 0;
752 AliTOFSDigitizer * sd = new AliTOFSDigitizer(fileHeader,fileSDigits) ;
760 //___________________________________________________________________________
761 Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
764 // Checks if 2 or more hits belong to the same pad.
765 // In this case the data assigned to the digit object
766 // are the ones of the first hit in order of Time.
767 // 2 hits from the same track on the same pad are collected.
768 // Called only by Hits2SDigits.
769 // This procedure has to be optimized in the next TOF release.
772 Bool_t overlap = kFALSE;
775 for (Int_t ndig=0; ndig<fSDigits->GetEntries(); ndig++){
776 AliTOFdigit* currentDigit = (AliTOFdigit*)(fSDigits->UncheckedAt(ndig));
777 currentDigit->GetLocation(vol2);
779 // check on digit volume
780 for (Int_t i=0;i<=4;i++){
782 if (vol[i]!=vol2[i]) idem=kFALSE;}
784 if (idem){ // same pad fired
785 Float_t tdc2 = digit[0];
786 Float_t tdc1 = currentDigit->GetTdc();
788 // we separate two digits on the same pad if
789 // they are separated in time by at least 25 ns
790 // remember that tdc time is given in ps
792 if (TMath::Abs(tdc1-tdc2)<25000){
793 // in case of overlap we take the earliest
795 currentDigit->SetTdc(tdc2);
796 currentDigit->SetAdc(digit[1]);
799 currentDigit->SetTdc(tdc1);
800 currentDigit->SetAdc(digit[1]);
802 currentDigit->AddTrack(Track); // add track number in the track array
808 } // close if (idem) -> two digits on the same TOF pad
810 } // end loop on existing sdigits
816 //____________________________________________________________________________
817 void AliTOF::Digits2Raw(Int_t evNumber)
820 // Starting from digits, writes the
821 // Raw Data objects, i.e. a
822 // TClonesArray of 18 AliTOFRawSector objects
827 // do nothing if no particles
828 Int_t nparticles = gAlice->GetEvent(evNumber);
829 if (nparticles <= 0) return;
831 tD = gAlice->TreeD();
833 TClonesArray* tofdigits = this->Digits();
834 Int_t ndigits = tofdigits->GetEntriesFast();
836 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
838 for (Int_t isect=1;isect<=fNTof;isect++){
839 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(isect);
840 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
842 for (Int_t digit=0; digit<ndigits; digit++){
843 AliTOFdigit* currentDigit = (AliTOFdigit*)tofdigits->UncheckedAt(digit);
844 Int_t sector = currentDigit->GetSector();
846 Int_t pad = currentDigit -> GetTotPad();
847 Int_t roc = (Int_t)(pad/fNPadXRoc)-1;
848 if (roc>=fNRoc) printf("Wrong n. of ROC ! Roc = %i",roc);
849 Int_t padRoc = (Int_t) pad%fNPadXRoc;
850 Int_t fec = (Int_t)(padRoc/fNFec)-1;
851 Int_t tdc = (Int_t)(padRoc%fNFec)-1;
852 Float_t time = currentDigit->GetTdc();
853 Float_t charge = currentDigit->GetAdc();
854 AliTOFRoc* currentROC = (AliTOFRoc*)rocData->UncheckedAt(roc);
856 currentROC->AddItem(fec, tdc, error, charge, time);
857 } // close if (sector==isect) i.e. end loop on digits for the current sector
858 } // end loop on TOF digits
860 UInt_t totSize=16,rocSize=0;
861 UInt_t rocHead[14],rocChek[14];
862 UInt_t globalCheckSum=0;
864 for (UInt_t iRoc = 1; iRoc<(UInt_t)fNRoc; iRoc++){
865 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(iRoc);
866 rocSize = currentRoc->GetItems()*2+1;
867 totSize += rocSize*4;
868 if (rocSize>=TMath::Power(2,16)) rocSize=0;
869 rocHead[iRoc] = iRoc<<28;
870 rocHead[iRoc] += rocSize;
871 rocChek[iRoc] = currentRoc->GetCheckSum();
872 Int_t headCheck = currentRoc->BitCount(rocHead[iRoc]);
873 globalCheckSum += headCheck;
874 globalCheckSum += rocChek[iRoc];
877 AliTOFRoc* dummyRoc = new AliTOFRoc();
879 if (totSize>=TMath::Power(2,24)) totSize=0;
880 UInt_t header = totSize;
881 UInt_t sectId = ((UInt_t)isect)<<24;
883 globalCheckSum += dummyRoc->BitCount(header);
884 currentSector->SetGlobalCS(globalCheckSum);
885 currentSector->SetHeader(header);
889 //____________________________________________________________________________
890 void AliTOF::Raw2Digits(Int_t evNumber)
893 // Converts Raw Data objects into digits objects.
894 // We schematize the raw data with a
895 // TClonesArray of 18 AliTOFRawSector objects
907 Int_t nparticles = gAlice->GetEvent(evNumber);
908 if (nparticles <= 0) return;
910 tD = gAlice->TreeD();
912 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
914 for(Int_t nSec=1; nSec<=fNTof; nSec++){
915 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(nSec);
916 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
917 for(Int_t nRoc=1; nRoc<=14; nRoc++){
918 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(nRoc);
919 Int_t currentItems = currentRoc->GetItems();
920 for(Int_t item=1; item<currentItems; item++){
921 Int_t nPad = currentRoc->GetTotPad(item);
923 Int_t nStrip = (Int_t)(nPad/fPadXStr)+1;
925 if (nStrip<=fNStripC+2*fNStripB+fNStripA) nPlate = 4;
926 if (nStrip<=fNStripC+fNStripB+fNStripA) nPlate = 3;
927 if (nStrip<=fNStripC+fNStripB) nPlate = 2;
928 if (nStrip<=fNStripC) nPlate=1;
932 case 2: nStrip -= (fNStripC);
934 case 3: nStrip -= (fNStripC+fNStripB);
936 case 4: nStrip -= (fNStripC+fNStripB+fNStripA);
938 case 5: nStrip -= (fNStripC+2*fNStripB+fNStripA);
942 Int_t pad = nPad%fPadXStr;
943 if (pad==0) pad=fPadXStr;
944 Int_t nPadX=0, nPadZ=0;
945 (pad>fNpadX)? nPadX -= fNpadX : nPadX = pad ;
947 (pad>fNpadX)? nPadZ = 2 : nPadZ = 1 ;
950 Float_t tdc = currentRoc->GetTime(item,error);
951 if (!error) digit[0]=tdc;
952 digit[1] = currentRoc->GetCharge(item);
953 AddDigit(tracks,vol,digit);
958 tD->Write(0,TObject::kOverwrite);