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.31 2001/11/22 11:22:51 hristov
19 Updated version of TOF digitization, N^2 problem solved (J.Chudoba)
21 Revision 1.30 2001/10/21 18:30:39 hristov
22 Several pointers were set to zero in the default constructors to avoid memory management problems
24 Revision 1.29 2001/10/17 14:19:24 hristov
25 delete replaced by delete []
27 Revision 1.28 2001/10/05 12:02:01 vicinanz
28 Minor improvements on Merger and SDigitizer
30 Revision 1.27 2001/10/02 13:03:13 vicinanz
31 Minor improvements on the code
33 Revision 1.26 2001/09/27 10:39:20 vicinanz
34 SDigitizer and Merger added
36 Revision 1.25 2001/09/07 08:37:40 hristov
37 Pointers initialised to 0 in the default constructor
39 Revision 1.24 2001/09/05 16:31:00 hristov
40 The deletion of TOF folders temporarily commented out
42 Revision 1.23 2001/08/29 12:59:01 vicinanz
43 Minor changes to the Digitizer procedure
45 Revision 1.22 2001/08/28 08:45:58 vicinanz
46 TTask and TFolder structures implemented
48 Revision 1.21 2001/05/16 14:57:24 alibrary
49 New files for folders and Stack
51 Revision 1.20 2001/05/04 10:09:47 vicinanz
52 Major upgrades to the strip structure
54 Revision 1.19 2001/03/12 17:47:25 hristov
55 Changes needed on Sun with CC 5.0
57 Revision 1.18 2001/01/26 19:57:42 hristov
58 Major upgrade of AliRoot code
60 Revision 1.17 2000/10/19 09:58:14 vicinanz
61 Updated Hits2Digit procedure
63 Revision 1.16 2000/10/02 21:28:17 fca
64 Removal of useless dependecies via forward declarations
66 Revision 1.15 2000/05/18 14:33:01 vicinanz
67 Modified to be full HP compliant
69 Revision 1.14 2000/05/15 19:32:36 fca
72 Revision 1.13 2000/05/10 16:52:18 vicinanz
73 New TOF version with holes for PHOS/RICH
75 Revision 1.11.2.1 2000/05/10 09:37:15 vicinanz
76 New version with Holes for PHOS/RICH
78 Revision 1.11 1999/11/05 22:39:06 fca
81 Revision 1.10 1999/11/01 20:41:57 fca
82 Added protections against using the wrong version of FRAME
84 Revision 1.9 1999/10/15 15:35:19 fca
85 New version for frame1099 with and without holes
87 Revision 1.9 1999/09/29 09:24:33 fca
88 Introduction of the Copyright and cvs Log
92 ///////////////////////////////////////////////////////////////////////////////
95 // This class contains the basic functions for the Time Of Flight //
96 // detector. Functions specific to one particular geometry are //
97 // contained in the derived classes //
99 // VERSIONE WITH 5 SYMMETRIC MODULES ALONG Z AXIS
100 // ==============================================
102 // VERSION WITH HOLES FOR PHOS AND TRD IN SPACEFRAME WITH HOLES
104 // Volume sensibile : FPAD
110 <img src="picts/AliTOFClass.gif">
116 ///////////////////////////////////////////////////////////////////////////////
118 #include <iostream.h>
119 #include <strstream.h>
124 #include "AliTOFhit.h"
125 #include "AliTOFdigit.h"
126 #include "AliTOFSDigit.h"
127 #include "AliTOFRawSector.h"
128 #include "AliTOFRoc.h"
129 #include "AliTOFRawDigit.h"
144 #include "AliConst.h"
149 //_____________________________________________________________________________
153 // Default constructor
169 //_____________________________________________________________________________
170 AliTOF::AliTOF(const char *name, const char *title)
171 : AliDetector(name,title)
174 // AliTOF standard constructor
176 // Here are fixed some important parameters
179 // Initialization of hits, sdigits and digits array
188 fHits = new TClonesArray("AliTOFhit", 1000);
189 gAlice->AddHitList(fHits);
191 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
192 fDigits = new TClonesArray("AliTOFdigit", 1000);
194 // Digitization parameters
196 // (Transfer Functions to be inserted here)
202 // General Geometrical Parameters
203 fNTof = 18; // number of sectors
206 fZlenC = 177.5;//cm length of module C
207 fZlenB = 141.0;//cm length of module B
208 fZlenA = 106.0;//cm length of module A
209 fZtof = 371.5;//cm total semi-length of TOF detector
212 fStripLn = 122.0;//cm Strip Length
213 fSpace = 5.5;//cm Space Beetween the strip and the bottom of the plate
214 fDeadBndZ= 1.5;//cm Dead Boundaries of a Strip along Z direction (width)
215 fDeadBndX= 1.0;//cm Dead Boundaries of a Strip along X direction (length)
216 fXpad = 2.5;//cm X size of a pad
217 fZpad = 3.5;//cm Z size of a pad
218 fGapA = 4.; //cm Gap beetween tilted strip in A-type plate
219 fGapB = 6.; //cm Gap beetween tilted strip in B-type plate
220 fOverSpc = 15.3;//cm Space available for sensitive layers in radial direction
221 fNpadX = 48; // Number of pads in a strip along the X direction
222 fNpadZ = 2; // Number of pads in a strip along the Z direction
223 fPadXStr = fNpadX*fNpadZ; //Number of pads per strip
224 fNStripA = 15; // number of strips in A type module
225 fNStripB = 19; // number of strips in B type module
226 fNStripC = 20; // number of strips in C type module
228 // Physical performances
232 // DAQ characteristics
233 // cfr. TOF-TDR pag. 105 for Glossary
234 // TARODA : TOF-ALICE Read Out and Data Acquisition system
235 fPadXSector = 8928; // number of pad per sector -with no holes-
236 // ((15+2*19+2*20)*(48*2))
237 fNRoc = 14; // number of Roc (Read Out Controller) (TARODA)
238 fNFec = 32; // number of Fec (Front-End electronic Card)
240 fNTdc = 32; // number of Tdc (Time to Digital Converter)
241 fNPadXRoc = (Int_t)fPadXSector/fNRoc; // number of pads for each ROC
243 // Create TOF Folder Structure
248 //_____________________________________________________________________________
249 void AliTOF::CreateTOFFolders()
251 // create the ALICE TFolder
252 // create the ALICE TTasks
253 // create the ALICE main TFolder
254 // to be done by AliRun
256 TFolder * alice = new TFolder();
257 alice->SetNameTitle("FPAlice", "Alice Folder") ;
258 gROOT->GetListOfBrowsables()->Add(alice) ;
260 TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ;
261 // make it the owner of the objects that it contains
264 TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ;
265 TFolder * aliceT = alice->AddFolder("tasks", "Alice tasks Folder") ;
266 // make it the owner of the objects that it contains
269 TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ;
270 aliceT->Add(aliceDi);
272 TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
273 aliceT->Add(aliceRe);
275 char * tempo = new char[80] ;
277 // creates the TOF Digitizer and adds it to alice main (S)Digitizer task
278 sprintf(tempo, "%sDigitizers container",GetName() ) ;
279 fDTask = new TTask(GetName(), tempo);
280 aliceDi->Add(fDTask) ;
282 // creates the TOF reconstructioner and adds it to alice main Reconstructioner task
283 sprintf(tempo, "%sReconstructioner container",GetName() ) ;
284 fReTask = new TTask(GetName(), tempo);
285 aliceRe->Add(fReTask) ;
289 // creates the TOF geometry folder
290 geomF->AddFolder("TOF", "Geometry for TOF") ;
293 //_____________________________________________________________________________
297 // it remove also the alice folder
298 // and task that TOF creates instead of AliRun
299 /* PH Temporarily commented because of problems
300 TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ;
324 fReconParticles->Delete ();
325 delete fReconParticles;
331 //_____________________________________________________________________________
332 void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits)
336 // new with placement used
338 TClonesArray &lhits = *fHits;
339 new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits);
342 //_____________________________________________________________________________
343 void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
347 // new with placement used
349 TClonesArray &ldigits = *fDigits;
350 new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits);
353 //___________________________________________
354 void AliTOF::AddSDigit(Int_t tracknum, Int_t *vol, Float_t *digits)
361 TClonesArray &lSDigits = *fSDigits;
362 new(lSDigits[fNSDigits++]) AliTOFSDigit(tracknum, vol, digits);
365 //_____________________________________________________________________________
366 void AliTOF::SetTreeAddress ()
368 // Set branch address for the Hits and Digits Tree.
370 AliDetector::SetTreeAddress ();
373 TTree *treeD = gAlice->TreeD ();
380 branch = treeD->GetBranch (branchname);
382 branch->SetAddress (&fDigits);
387 // fSDigits->Clear ();
389 if (gAlice->TreeS () && fSDigits)
391 branch = gAlice->TreeS ()->GetBranch ("TOF");
393 branch->SetAddress (&fSDigits);
396 if (gAlice->TreeR() && fReconParticles)
398 branch = gAlice->TreeR()->GetBranch("TOF");
399 if (branch) branch->SetAddress(&fReconParticles) ;
403 //_____________________________________________________________________________
404 void AliTOF::CreateGeometry()
407 // Common geometry code
411 <img src="picts/AliTOFv23.gif">
415 const Double_t kPi=TMath::Pi();
416 const Double_t kDegrad=kPi/180.;
418 Float_t xTof, yTof, wall;
420 // frame inbetween TOF modules
423 // Sizes of TOF module with its support etc..
424 xTof = 2.*(fRmin*TMath::Tan(10*kDegrad)-wall/2-.5);
427 // TOF module internal definitions
428 TOFpc(xTof, yTof, fZlenC, fZlenB, fZlenA, fZtof);
431 //_____________________________________________________________________________
432 void AliTOF::DrawModule() const
435 // Draw a shaded view of the common part of the TOF geometry
438 cout << " Drawing of AliTOF"<< endl;
439 // Set everything unseen
440 gMC->Gsatt("*", "seen", -1);
442 // Set ALIC mother transparent
443 gMC->Gsatt("ALIC","SEEN",0);
445 // Set the volumes visible
446 gMC->Gsatt("FTOA","SEEN",1);
447 gMC->Gsatt("FTOB","SEEN",1);
448 gMC->Gsatt("FTOC","SEEN",1);
449 gMC->Gsatt("FLTA","SEEN",1);
450 gMC->Gsatt("FLTB","SEEN",1);
451 gMC->Gsatt("FLTC","SEEN",1);
452 gMC->Gsatt("FSTR","SEEN",1);
454 gMC->Gdopt("hide", "on");
455 gMC->Gdopt("shad", "on");
456 gMC->Gsatt("*", "fill", 7);
457 gMC->SetClipBox(".");
458 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
460 gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
461 gMC->Gdhead(1111, "Time Of Flight");
462 gMC->Gdman(18, 4, "MAN");
463 gMC->Gdopt("hide","off");
466 //_____________________________________________________________________________
467 void AliTOF::CreateMaterials()
470 // Defines TOF materials for all versions
471 // Authors : Maxim Martemianov, Boris Zagreev (ITEP)
473 // Revision: F. Pierella 5-3-2001
474 // Bologna University
476 Int_t isxfld = gAlice->Field()->Integ();
477 Float_t sxmgmx = gAlice->Field()->Max();
480 Float_t aq[2] = { 28.0855,15.9994 };
481 Float_t zq[2] = { 14.,8. };
482 Float_t wq[2] = { 1.,2. };
485 // --- Freon C2F4H2 (TOF-TDR pagg.)
486 // Geant Manual CONS110-1, pag. 43 (Geant, Detector Description and Simulation Tool)
487 Float_t afre[3] = {12.011,18.998,1.007};
488 Float_t zfre[3] = { 6., 9., 1.};
489 Float_t wfre[3] = { 2., 4., 2.};
490 Float_t densfre = 0.00375;
491 // http://www.fi.infn.it/sezione/prevprot/gas/freon.html
494 //-- Isobutane quencher C4H10 (5% in the sensitive mixture)
495 Float_t aiso[2] = {12.011,1.007};
496 Float_t ziso[2] = { 6., 1.};
497 Float_t wiso[2] = { 4., 10.};
498 Float_t densiso = .......; // (g/cm3) density
499 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
500 //-- SF6 (5% in the sensitive mixture)
501 Float_t asf[3] = {32.066,18.998};
502 Float_t zsf[3] = { 16., 9.};
503 Float_t wsf[3] = { 1., 6.};
504 Float_t denssf = .....; // (g/cm3) density
505 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
508 Float_t ac[2] = {12.,16.};
509 Float_t zc[2] = { 6., 8.};
510 Float_t wc[2] = { 1., 2.};
511 Float_t dc = .001977;
513 // For mylar (C5H4O2)
514 Float_t amy[3] = { 12., 1., 16. };
515 Float_t zmy[3] = { 6., 1., 8. };
516 Float_t wmy[3] = { 5., 4., 2. };
519 // For polyethilene (CH2) - honeycomb -
520 Float_t ape[2] = { 12., 1. };
521 Float_t zpe[2] = { 6., 1. };
522 Float_t wpe[2] = { 1., 2. };
523 Float_t dpe = 0.935*0.479; //To have 1%X0 for 1cm as for honeycomb
526 Float_t ag10[4] = { 12.,1.,16.,28. };
527 Float_t zg10[4] = { 6.,1., 8.,14. };
528 Float_t wmatg10[4] = { .259,.288,.248,.205 };
529 Float_t densg10 = 1.7;
532 Float_t adme[5] = { 12.,1.,16.,19.,79. };
533 Float_t zdme[5] = { 6.,1., 8., 9.,35. };
534 Float_t wmatdme[5] = { .4056,.0961,.2562,.1014,.1407 };
535 Float_t densdme = .00205;
537 // ---- ALUMINA (AL203)
538 Float_t aal[2] = { 27.,16.};
539 Float_t zal[2] = { 13., 8.};
540 Float_t wmatal[2] = { 2.,3. };
541 Float_t densal = 2.3;
544 Float_t awa[2] = { 1., 16. };
545 Float_t zwa[2] = { 1., 8. };
546 Float_t wwa[2] = { 2., 1. };
550 //AliMaterial(0, "Vacuum$", 1e-16, 1e-16, 1e-16, 1e16, 1e16);
551 AliMaterial( 1, "Air$",14.61,7.3,0.001205,30423.24,67500.);
552 AliMaterial( 2, "Cu $", 63.54, 29.0, 8.96, 1.43, 14.8);
553 AliMaterial( 3, "C $", 12.01, 6.0, 2.265,18.8, 74.4);
554 AliMixture ( 4, "Polyethilene$", ape, zpe, dpe, npe, wpe);
555 AliMixture ( 5, "G10$", ag10, zg10, densg10, nlmatg10, wmatg10);
556 AliMixture ( 6, "DME ", adme, zdme, densdme, nlmatdme, wmatdme);
557 AliMixture ( 7, "CO2$", ac, zc, dc, nc, wc);
558 AliMixture ( 8, "ALUMINA$", aal, zal, densal, nlmatal, wmatal);
559 AliMaterial( 9, "Al $", 26.98, 13., 2.7, 8.9, 37.2);
560 AliMaterial(10, "C-TRD$", 12.01, 6., 2.265*18.8/69.282*15./100, 18.8, 74.4); // for 15%
561 AliMixture (11, "Mylar$", amy, zmy, dmy, nmy, wmy);
562 AliMixture (12, "Freon$", afre, zfre, densfre, nfre, wfre);
563 AliMixture (13, "Quartz$", aq, zq, dq, nq, wq);
564 AliMixture (14, "Water$", awa, zwa, dwa, nwa, wwa);
566 Float_t epsil, stmin, deemax, stemax;
569 // EPSIL = 0.1 ! Tracking precision,
570 // STEMAX = 0.1 ! Maximum displacement for multiple scattering
571 // DEEMAX = 0.1 ! Maximum fractional energy loss, DLS
575 epsil = .001; // Tracking precision,
576 stemax = -1.; // Maximum displacement for multiple scattering
577 deemax = -.3; // Maximum fractional energy loss, DLS
580 AliMedium( 1, "Air$" , 1, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
581 AliMedium( 2, "Cu $" , 2, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
582 AliMedium( 3, "C $" , 3, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
583 AliMedium( 4, "Pol$" , 4, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
584 AliMedium( 5, "G10$" , 5, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
585 AliMedium( 6, "DME$" , 6, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
586 AliMedium( 7, "CO2$" , 7, 0, isxfld, sxmgmx, 10., -.01, -.1, .01, -.01);
587 AliMedium( 8,"ALUMINA$", 8, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
588 AliMedium( 9,"Al Frame$",9, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
589 AliMedium(10, "DME-S$", 6, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
590 AliMedium(11, "C-TRD$", 10, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
591 AliMedium(12, "Myl$" , 11, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
592 AliMedium(13, "Fre$" , 12, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
593 AliMedium(14, "Fre-S$", 12, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
594 AliMedium(15, "Glass$", 13, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
595 AliMedium(16, "Water$", 14, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
598 //_____________________________________________________________________________
599 Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t ) const
602 // Returns distance from mouse pointer to detector, default version
607 //___________________________________________
608 void AliTOF::ResetHits ()
610 // Reset number of clusters and the cluster array for this detector
611 AliDetector::ResetHits ();
614 //____________________________________________
615 void AliTOF::ResetDigits ()
618 // Reset number of digits and the digits array for this detector
619 AliDetector::ResetDigits ();
622 //_____________________________________________________________________________
626 // Initialise TOF detector after it has been built
628 // Set id of TOF sensitive volume
629 if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD");
633 //____________________________________________________________________________
634 void AliTOF::MakeBranch(Option_t* option, const char *file)
637 // Initializes the Branches of the TOF inside the
638 // trees written for each event.
639 // AliDetector::MakeBranch initializes just the
640 // Branch inside TreeH. Here we add the branches in
641 // TreeD, TreeS and TreeR.
643 AliDetector::MakeBranch(option,file);
645 Int_t buffersize = 4000;
646 Char_t branchname[10];
647 sprintf(branchname,"%s",GetName());
649 const char *oD = strstr(option,"D");
650 const char *oS = strstr(option,"S");
651 const char *oR = strstr(option,"R");
655 // one branch for TOF digits
659 if (fDigits && gAlice->TreeD() && oD){
660 MakeBranchInTree(gAlice->TreeD(),
661 branchname, &fDigits,buffersize, file) ;
666 // one branch for TOF sdigits
670 if (fSDigits && gAlice->TreeS() && oS){
671 MakeBranchInTree(gAlice->TreeS(),
672 branchname, &fSDigits,buffersize, file) ;
677 // one branch for TOF reconstructed particles
681 if (fReconParticles && gAlice->TreeR() && oR){
682 MakeBranchInTree(gAlice->TreeR(),
683 branchname, &fReconParticles,buffersize, file) ;
688 //____________________________________________________________________________
689 void AliTOF::Makehits(Bool_t hits)
691 // default argument used, see AliTOF.h
692 // Enable/Disable the writing of the TOF-hits branch
694 // by default : enabled for TOFv1, v2, v3, v4
695 // disabled for TOFv0
697 if (hits && (IsVersion()!=0))
698 fIdSens = gMC->VolId("FPAD");
700 cout << "Option for writing the TOF-hits branch on TreeH: disabled" << endl;
703 //____________________________________________________________________________
704 void AliTOF::FinishEvent()
709 //___________________________________________
710 void AliTOF::SDigits2Digits()
713 // Generate digits performing merging
716 int nparticles = gAlice->GetNtrack();
717 cout << "Particles :" <<nparticles<<endl;
718 if (nparticles > 0 ) {
720 AliTOF::Hits2Digits();
724 cout<<"AliTOF::SDigits2Digits"<<endl;
727 cout<<"AliTOF::SDigits2Digits Init"<<endl;
729 cout<<"AliTOF::SDigits2Digits Digitise() "<<endl;
733 //---------------------------------------------------------------------
734 void AliTOF::SetMerger(AliTOFMerger* merger)
736 // Set pointer to merger
740 //---------------------------------------------------------------------
741 AliTOFMerger* AliTOF::Merger()
743 // Return pointer to merger
748 //---------------------------------------------------------------------
750 void AliTOF::Hits2SDigits()
753 // Use the TOF SDigitizer to make TOF SDigits
757 cout<<"ALiTOF::Hits2SDigits> start...\n";
760 char * fileSDigits = 0 ;
761 char * fileHeader = 0;
762 AliTOFSDigitizer * sd = new AliTOFSDigitizer(fileHeader,fileSDigits) ;
770 //___________________________________________________________________________
771 Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
774 // Checks if 2 or more hits belong to the same pad.
775 // In this case the data assigned to the digit object
776 // are the ones of the first hit in order of Time.
777 // 2 hits from the same track on the same pad are collected.
778 // Called only by Hits2SDigits.
779 // This procedure has to be optimized in the next TOF release.
782 Bool_t overlap = kFALSE;
785 for (Int_t ndig=0; ndig<fSDigits->GetEntries(); ndig++){
786 AliTOFdigit* currentDigit = (AliTOFdigit*)(fSDigits->UncheckedAt(ndig));
787 currentDigit->GetLocation(vol2);
789 // check on digit volume
790 for (Int_t i=0;i<=4;i++){
792 if (vol[i]!=vol2[i]) idem=kFALSE;}
794 if (idem){ // same pad fired
795 Float_t tdc2 = digit[0];
796 Float_t tdc1 = currentDigit->GetTdc();
798 // we separate two digits on the same pad if
799 // they are separated in time by at least 25 ns
800 // remember that tdc time is given in ps
802 if (TMath::Abs(tdc1-tdc2)<25000){
803 // in case of overlap we take the earliest
805 currentDigit->SetTdc(tdc2);
806 currentDigit->SetAdc(digit[1]);
809 currentDigit->SetTdc(tdc1);
810 currentDigit->SetAdc(digit[1]);
812 currentDigit->AddTrack(Track); // add track number in the track array
818 } // close if (idem) -> two digits on the same TOF pad
820 } // end loop on existing sdigits
826 //____________________________________________________________________________
827 void AliTOF::Digits2Raw(Int_t evNumber)
830 // Starting from digits, writes the
831 // Raw Data objects, i.e. a
832 // TClonesArray of 18 AliTOFRawSector objects
837 // do nothing if no particles
838 Int_t nparticles = gAlice->GetEvent(evNumber);
839 if (nparticles <= 0) return;
841 tD = gAlice->TreeD();
843 TClonesArray* tofdigits = this->Digits();
844 Int_t ndigits = tofdigits->GetEntriesFast();
846 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
848 for (Int_t isect=1;isect<=fNTof;isect++){
849 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(isect);
850 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
852 for (Int_t digit=0; digit<ndigits; digit++){
853 AliTOFdigit* currentDigit = (AliTOFdigit*)tofdigits->UncheckedAt(digit);
854 Int_t sector = currentDigit->GetSector();
856 Int_t pad = currentDigit -> GetTotPad();
857 Int_t roc = (Int_t)(pad/fNPadXRoc)-1;
858 if (roc>=fNRoc) printf("Wrong n. of ROC ! Roc = %i",roc);
859 Int_t padRoc = (Int_t) pad%fNPadXRoc;
860 Int_t fec = (Int_t)(padRoc/fNFec)-1;
861 Int_t tdc = (Int_t)(padRoc%fNFec)-1;
862 Float_t time = currentDigit->GetTdc();
863 Float_t charge = currentDigit->GetAdc();
864 AliTOFRoc* currentROC = (AliTOFRoc*)rocData->UncheckedAt(roc);
866 currentROC->AddItem(fec, tdc, error, charge, time);
867 } // close if (sector==isect) i.e. end loop on digits for the current sector
868 } // end loop on TOF digits
870 UInt_t totSize=16,rocSize=0;
871 UInt_t rocHead[14],rocChek[14];
872 UInt_t globalCheckSum=0;
874 for (UInt_t iRoc = 1; iRoc<(UInt_t)fNRoc; iRoc++){
875 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(iRoc);
876 rocSize = currentRoc->GetItems()*2+1;
877 totSize += rocSize*4;
878 if (rocSize>=TMath::Power(2,16)) rocSize=0;
879 rocHead[iRoc] = iRoc<<28;
880 rocHead[iRoc] += rocSize;
881 rocChek[iRoc] = currentRoc->GetCheckSum();
882 Int_t headCheck = currentRoc->BitCount(rocHead[iRoc]);
883 globalCheckSum += headCheck;
884 globalCheckSum += rocChek[iRoc];
887 AliTOFRoc* dummyRoc = new AliTOFRoc();
889 if (totSize>=TMath::Power(2,24)) totSize=0;
890 UInt_t header = totSize;
891 UInt_t sectId = ((UInt_t)isect)<<24;
893 globalCheckSum += dummyRoc->BitCount(header);
894 currentSector->SetGlobalCS(globalCheckSum);
895 currentSector->SetHeader(header);
899 //____________________________________________________________________________
900 void AliTOF::Raw2Digits(Int_t evNumber)
903 // Converts Raw Data objects into digits objects.
904 // We schematize the raw data with a
905 // TClonesArray of 18 AliTOFRawSector objects
917 Int_t nparticles = gAlice->GetEvent(evNumber);
918 if (nparticles <= 0) return;
920 tD = gAlice->TreeD();
922 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
924 for(Int_t nSec=1; nSec<=fNTof; nSec++){
925 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(nSec);
926 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
927 for(Int_t nRoc=1; nRoc<=14; nRoc++){
928 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(nRoc);
929 Int_t currentItems = currentRoc->GetItems();
930 for(Int_t item=1; item<currentItems; item++){
931 Int_t nPad = currentRoc->GetTotPad(item);
933 Int_t nStrip = (Int_t)(nPad/fPadXStr)+1;
935 if (nStrip<=fNStripC+2*fNStripB+fNStripA) nPlate = 4;
936 if (nStrip<=fNStripC+fNStripB+fNStripA) nPlate = 3;
937 if (nStrip<=fNStripC+fNStripB) nPlate = 2;
938 if (nStrip<=fNStripC) nPlate=1;
942 case 2: nStrip -= (fNStripC);
944 case 3: nStrip -= (fNStripC+fNStripB);
946 case 4: nStrip -= (fNStripC+fNStripB+fNStripA);
948 case 5: nStrip -= (fNStripC+2*fNStripB+fNStripA);
952 Int_t pad = nPad%fPadXStr;
953 if (pad==0) pad=fPadXStr;
954 Int_t nPadX=0, nPadZ=0;
955 (pad>fNpadX)? nPadX -= fNpadX : nPadX = pad ;
957 (pad>fNpadX)? nPadZ = 2 : nPadZ = 1 ;
960 Float_t tdc = currentRoc->GetTime(item,error);
961 if (!error) digit[0]=tdc;
962 digit[1] = currentRoc->GetCharge(item);
963 AddDigit(tracks,vol,digit);
968 tD->Write(0,TObject::kOverwrite);