]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOF.cxx
Updated version of TOF digitization, N^2 problem solved (J.Chudoba)
[u/mrichter/AliRoot.git] / TOF / AliTOF.cxx
CommitLineData
4c039060 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/*
17$Log$
5919c40c 18Revision 1.30 2001/10/21 18:30:39 hristov
19Several pointers were set to zero in the default constructors to avoid memory management problems
20
2685bf00 21Revision 1.29 2001/10/17 14:19:24 hristov
22delete replaced by delete []
23
3ff0c331 24Revision 1.28 2001/10/05 12:02:01 vicinanz
25Minor improvements on Merger and SDigitizer
26
766a7c4e 27Revision 1.27 2001/10/02 13:03:13 vicinanz
28Minor improvements on the code
29
f3de6e9e 30Revision 1.26 2001/09/27 10:39:20 vicinanz
31SDigitizer and Merger added
32
517b7f8f 33Revision 1.25 2001/09/07 08:37:40 hristov
34Pointers initialised to 0 in the default constructor
35
519351ab 36Revision 1.24 2001/09/05 16:31:00 hristov
37The deletion of TOF folders temporarily commented out
38
5839f074 39Revision 1.23 2001/08/29 12:59:01 vicinanz
40Minor changes to the Digitizer procedure
41
0efc163f 42Revision 1.22 2001/08/28 08:45:58 vicinanz
43TTask and TFolder structures implemented
44
68861244 45Revision 1.21 2001/05/16 14:57:24 alibrary
46New files for folders and Stack
47
9e1a0ddb 48Revision 1.20 2001/05/04 10:09:47 vicinanz
49Major upgrades to the strip structure
50
b94fa26c 51Revision 1.19 2001/03/12 17:47:25 hristov
52Changes needed on Sun with CC 5.0
53
5cf7bbad 54Revision 1.18 2001/01/26 19:57:42 hristov
55Major upgrade of AliRoot code
56
2ab0c725 57Revision 1.17 2000/10/19 09:58:14 vicinanz
58Updated Hits2Digit procedure
59
c2af3d73 60Revision 1.16 2000/10/02 21:28:17 fca
61Removal of useless dependecies via forward declarations
62
94de3818 63Revision 1.15 2000/05/18 14:33:01 vicinanz
64Modified to be full HP compliant
65
f5489efc 66Revision 1.14 2000/05/15 19:32:36 fca
67Add AddHitList !!
68
c8bd506f 69Revision 1.13 2000/05/10 16:52:18 vicinanz
70New TOF version with holes for PHOS/RICH
71
2cef3cb2 72Revision 1.11.2.1 2000/05/10 09:37:15 vicinanz
73New version with Holes for PHOS/RICH
74
1cedd08a 75Revision 1.11 1999/11/05 22:39:06 fca
76New hits structure
77
826b71ec 78Revision 1.10 1999/11/01 20:41:57 fca
79Added protections against using the wrong version of FRAME
80
ab76897d 81Revision 1.9 1999/10/15 15:35:19 fca
82New version for frame1099 with and without holes
83
937fe4a4 84Revision 1.9 1999/09/29 09:24:33 fca
85Introduction of the Copyright and cvs Log
4c039060 86
937fe4a4 87*/
68861244 88
fe4da5cc 89///////////////////////////////////////////////////////////////////////////////
90// //
68861244 91// Time Of Flight //
fe4da5cc 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 //
937fe4a4 95//
96// VERSIONE WITH 5 SYMMETRIC MODULES ALONG Z AXIS
97// ==============================================
98//
99// VERSION WITH HOLES FOR PHOS AND TRD IN SPACEFRAME WITH HOLES
100//
101// Volume sensibile : FPAD
102//
103//
104//
105// Begin_Html
fe4da5cc 106/*
1439f98e 107<img src="picts/AliTOFClass.gif">
fe4da5cc 108*/
109//End_Html
937fe4a4 110//
111//
fe4da5cc 112// //
113///////////////////////////////////////////////////////////////////////////////
114
826b71ec 115#include <iostream.h>
68861244 116#include <strstream.h>
517b7f8f 117#include <fstream.h>
118#include <stdlib.h>
826b71ec 119
fe4da5cc 120#include "AliTOF.h"
68861244 121#include "AliTOFhit.h"
122#include "AliTOFdigit.h"
5919c40c 123#include "AliTOFSDigit.h"
68861244 124#include "AliTOFRawSector.h"
125#include "AliTOFRoc.h"
126#include "AliTOFRawDigit.h"
127
128#include "TROOT.h"
826b71ec 129#include "TBRIK.h"
2cef3cb2 130#include "TNode.h"
131#include "TObject.h"
0efc163f 132#include "TSystem.h"
94de3818 133#include "TTree.h"
2ab0c725 134#include "TFile.h"
68861244 135#include "TFolder.h"
136#include "TTask.h"
94de3818 137
fe4da5cc 138#include "AliRun.h"
94de3818 139#include "AliMC.h"
140#include "AliMagF.h"
fe4da5cc 141#include "AliConst.h"
2cef3cb2 142
fe4da5cc 143
144ClassImp(AliTOF)
145
146//_____________________________________________________________________________
147AliTOF::AliTOF()
148{
149 //
150 // Default constructor
151 //
519351ab 152 fFGeom = 0;
153 fDTask = 0;
154 fReTask = 0;
fe4da5cc 155 fIshunt = 0;
68861244 156 fSDigits = 0 ;
157 fDigits = 0 ;
2685bf00 158 fReconParticles = 0;
68861244 159 fName="TOF";
2685bf00 160 fMerger = 0;
517b7f8f 161/* fp
68861244 162 CreateTOFFolders();
517b7f8f 163*/
fe4da5cc 164}
165
166//_____________________________________________________________________________
167AliTOF::AliTOF(const char *name, const char *title)
168 : AliDetector(name,title)
169{
170 //
171 // AliTOF standard constructor
172 //
2cef3cb2 173 // Here are fixed some important parameters
174 //
175
68861244 176 // Initialization of hits, sdigits and digits array
2cef3cb2 177 //
517b7f8f 178 fHits = new TClonesArray("AliTOFhit", 1000);
c8bd506f 179 gAlice->AddHitList(fHits);
2cef3cb2 180 fIshunt = 0;
5919c40c 181 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
517b7f8f 182 fDigits = new TClonesArray("AliTOFdigit", 1000);
2cef3cb2 183 //
184 // Digitization parameters
fe4da5cc 185 //
2cef3cb2 186 // (Transfer Functions to be inserted here)
fe4da5cc 187 //
188 SetMarkerColor(7);
189 SetMarkerStyle(2);
190 SetMarkerSize(0.4);
2cef3cb2 191
192// General Geometrical Parameters
b94fa26c 193 fNTof = 18; // number of sectors
194 fRmax = 399.0;//cm
2cef3cb2 195 fRmin = 370.0;//cm
b94fa26c 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
517b7f8f 199 fZtof = 371.5;//cm total semi-length of TOF detector
2cef3cb2 200
201// Strip Parameters
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
b94fa26c 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
2cef3cb2 217
218// Physical performances
219 fTimeRes = 100.;//ps
220 fChrgRes = 100.;//pC
221
222// DAQ characteristics
68861244 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)
229 // (TARODA)
230 fNTdc = 32; // number of Tdc (Time to Digital Converter)
231 fNPadXRoc = (Int_t)fPadXSector/fNRoc; // number of pads for each ROC
517b7f8f 232 /* fp 25 Sept 2001
68861244 233 // Create TOF Folder Structure
517b7f8f 234 CreateTOFFolders();
235 */
68861244 236}
237
238//_____________________________________________________________________________
239void AliTOF::CreateTOFFolders()
240{
241 // create the ALICE TFolder
242 // create the ALICE TTasks
243 // create the ALICE main TFolder
244 // to be done by AliRun
245
246 TFolder * alice = new TFolder();
247 alice->SetNameTitle("FPAlice", "Alice Folder") ;
248 gROOT->GetListOfBrowsables()->Add(alice) ;
249
250 TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ;
251 // make it the owner of the objects that it contains
252 aliceF->SetOwner() ;
253 // geometry folder
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
257 aliceT->SetOwner() ;
258
259 TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ;
260 aliceT->Add(aliceDi);
261
262 TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
263 aliceT->Add(aliceRe);
264
265 char * tempo = new char[80] ;
266
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) ;
271
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) ;
276
3ff0c331 277 delete [] tempo ;
68861244 278
279 // creates the TOF geometry folder
280 geomF->AddFolder("TOF", "Geometry for TOF") ;
281}
282
283//_____________________________________________________________________________
284AliTOF::~AliTOF()
285{
517b7f8f 286 // dtor:
287 // it remove also the alice folder
68861244 288 // and task that TOF creates instead of AliRun
5839f074 289 /* PH Temporarily commented because of problems
68861244 290 TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ;
291 delete alice;
292 alice = 0;
5839f074 293 */
517b7f8f 294 if (fHits)
295 {
296 fHits->Delete ();
297 delete fHits;
298 fHits = 0;
299 }
300 if (fDigits)
301 {
302 fDigits->Delete ();
303 delete fDigits;
304 fDigits = 0;
305 }
306 if (fSDigits)
307 {
308 fSDigits->Delete ();
309 delete fSDigits;
310 fSDigits = 0;
311 }
312 if (fReconParticles)
313 {
314 fReconParticles->Delete ();
315 delete fReconParticles;
316 fReconParticles = 0;
317 }
318
fe4da5cc 319}
320
321//_____________________________________________________________________________
2cef3cb2 322void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits)
fe4da5cc 323{
324 //
325 // Add a TOF hit
68861244 326 // new with placement used
fe4da5cc 327 //
328 TClonesArray &lhits = *fHits;
2cef3cb2 329 new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits);
fe4da5cc 330}
331
332//_____________________________________________________________________________
2cef3cb2 333void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
fe4da5cc 334{
335 //
2cef3cb2 336 // Add a TOF digit
68861244 337 // new with placement used
2cef3cb2 338 //
339 TClonesArray &ldigits = *fDigits;
340 new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits);
fe4da5cc 341}
342
517b7f8f 343//___________________________________________
5919c40c 344void AliTOF::AddSDigit(Int_t tracknum, Int_t *vol, Float_t *digits)
517b7f8f 345{
346
347//
348// Add a TOF sdigit
349//
350
351 TClonesArray &lSDigits = *fSDigits;
5919c40c 352 new(lSDigits[fNSDigits++]) AliTOFSDigit(tracknum, vol, digits);
517b7f8f 353}
354
355//_____________________________________________________________________________
356void AliTOF::SetTreeAddress ()
357{
358 // Set branch address for the Hits and Digits Tree.
359 char branchname[30];
360 AliDetector::SetTreeAddress ();
361
362 TBranch *branch;
363 TTree *treeD = gAlice->TreeD ();
364
365
366 if (treeD)
367 {
368 if (fDigits)
369 {
370 branch = treeD->GetBranch (branchname);
371 if (branch)
372 branch->SetAddress (&fDigits);
373 }
374
375 }
5919c40c 376// if (fSDigits)
517b7f8f 377 // fSDigits->Clear ();
378
379 if (gAlice->TreeS () && fSDigits)
380 {
381 branch = gAlice->TreeS ()->GetBranch ("TOF");
382 if (branch)
383 branch->SetAddress (&fSDigits);
384 }
385
386 if (gAlice->TreeR() && fReconParticles)
387 {
388 branch = gAlice->TreeR()->GetBranch("TOF");
389 if (branch) branch->SetAddress(&fReconParticles) ;
390 }
391}
2cef3cb2 392
fe4da5cc 393//_____________________________________________________________________________
394void AliTOF::CreateGeometry()
395{
396 //
3fe3a833 397 // Common geometry code
fe4da5cc 398 //
399 //Begin_Html
400 /*
1439f98e 401 <img src="picts/AliTOFv23.gif">
fe4da5cc 402 */
403 //End_Html
404 //
fe4da5cc 405 const Double_t kPi=TMath::Pi();
2cef3cb2 406 const Double_t kDegrad=kPi/180.;
fe4da5cc 407 //
b94fa26c 408 Float_t xTof, yTof, wall;
937fe4a4 409
3fe3a833 410 // frame inbetween TOF modules
b94fa26c 411 wall = 4.;//cm
3fe3a833 412
2cef3cb2 413 // Sizes of TOF module with its support etc..
b94fa26c 414 xTof = 2.*(fRmin*TMath::Tan(10*kDegrad)-wall/2-.5);
2cef3cb2 415 yTof = fRmax-fRmin;
3fe3a833 416
937fe4a4 417// TOF module internal definitions
2cef3cb2 418 TOFpc(xTof, yTof, fZlenC, fZlenB, fZlenA, fZtof);
fe4da5cc 419}
420
421//_____________________________________________________________________________
68861244 422void AliTOF::DrawModule() const
fe4da5cc 423{
424 //
425 // Draw a shaded view of the common part of the TOF geometry
fe4da5cc 426 //
427
3fe3a833 428 cout << " Drawing of AliTOF"<< endl;
fe4da5cc 429 // Set everything unseen
cfce8870 430 gMC->Gsatt("*", "seen", -1);
fe4da5cc 431 //
432 // Set ALIC mother transparent
cfce8870 433 gMC->Gsatt("ALIC","SEEN",0);
fe4da5cc 434 //
435 // Set the volumes visible
2cef3cb2 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);
cfce8870 443 //
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);
449 gMC->DefaultRange();
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");
fe4da5cc 454}
455
456//_____________________________________________________________________________
457void AliTOF::CreateMaterials()
458{
459 //
460 // Defines TOF materials for all versions
2cef3cb2 461 // Authors : Maxim Martemianov, Boris Zagreev (ITEP)
462 // 18/09/98
b94fa26c 463 // Revision: F. Pierella 5-3-2001
464 // Bologna University
fe4da5cc 465 //
b94fa26c 466 Int_t isxfld = gAlice->Field()->Integ();
467 Float_t sxmgmx = gAlice->Field()->Max();
fe4da5cc 468 //
3fe3a833 469 //--- Quartz (SiO2)
470 Float_t aq[2] = { 28.0855,15.9994 };
471 Float_t zq[2] = { 14.,8. };
472 Float_t wq[2] = { 1.,2. };
473 Float_t dq = 2.20;
474 Int_t nq = -2;
b94fa26c 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
482 Int_t nfre = -3;
483/*
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
496*/
3fe3a833 497 // --- CO2
2cef3cb2 498 Float_t ac[2] = {12.,16.};
499 Float_t zc[2] = { 6., 8.};
500 Float_t wc[2] = { 1., 2.};
3fe3a833 501 Float_t dc = .001977;
502 Int_t nc = -2;
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. };
507 Float_t dmy = 1.39;
508 Int_t nmy = -3;
b94fa26c 509 // For polyethilene (CH2) - honeycomb -
3fe3a833 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
514 Int_t npe = -2;
515 // --- G10
fe4da5cc 516 Float_t ag10[4] = { 12.,1.,16.,28. };
2cef3cb2 517 Float_t zg10[4] = { 6.,1., 8.,14. };
fe4da5cc 518 Float_t wmatg10[4] = { .259,.288,.248,.205 };
3fe3a833 519 Float_t densg10 = 1.7;
520 Int_t nlmatg10 = -4;
521 // --- DME
fe4da5cc 522 Float_t adme[5] = { 12.,1.,16.,19.,79. };
2cef3cb2 523 Float_t zdme[5] = { 6.,1., 8., 9.,35. };
fe4da5cc 524 Float_t wmatdme[5] = { .4056,.0961,.2562,.1014,.1407 };
3fe3a833 525 Float_t densdme = .00205;
526 Int_t nlmatdme = 5;
527 // ---- ALUMINA (AL203)
2cef3cb2 528 Float_t aal[2] = { 27.,16.};
529 Float_t zal[2] = { 13., 8.};
fe4da5cc 530 Float_t wmatal[2] = { 2.,3. };
3fe3a833 531 Float_t densal = 2.3;
532 Int_t nlmatal = -2;
533 // -- Water
534 Float_t awa[2] = { 1., 16. };
535 Float_t zwa[2] = { 1., 8. };
536 Float_t wwa[2] = { 2., 1. };
537 Float_t dwa = 1.0;
538 Int_t nwa = -2;
fe4da5cc 539 //
3fe3a833 540 //AliMaterial(0, "Vacuum$", 1e-16, 1e-16, 1e-16, 1e16, 1e16);
2cef3cb2 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);
3fe3a833 550 AliMaterial(10, "C-TRD$", 12.01, 6., 2.265*18.8/69.282*15./100, 18.8, 74.4); // for 15%
2cef3cb2 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);
3fe3a833 555
556 Float_t epsil, stmin, deemax, stemax;
2cef3cb2 557
558 // Previous data
fe4da5cc 559 // EPSIL = 0.1 ! Tracking precision,
560 // STEMAX = 0.1 ! Maximum displacement for multiple scattering
561 // DEEMAX = 0.1 ! Maximum fractional energy loss, DLS
562 // STMIN = 0.1
2cef3cb2 563 //
564 // New data
565 epsil = .001; // Tracking precision,
566 stemax = -1.; // Maximum displacement for multiple scattering
567 deemax = -.3; // Maximum fractional energy loss, DLS
fe4da5cc 568 stmin = -.8;
937fe4a4 569
b94fa26c 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);
fe4da5cc 586}
587
588//_____________________________________________________________________________
68861244 589Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t ) const
fe4da5cc 590{
591 //
592 // Returns distance from mouse pointer to detector, default version
593 //
594 return 9999;
595}
517b7f8f 596
597//___________________________________________
598void AliTOF::ResetHits ()
599{
600 // Reset number of clusters and the cluster array for this detector
601 AliDetector::ResetHits ();
602}
603
604//____________________________________________
605void AliTOF::ResetDigits ()
606{
607 //
608 // Reset number of digits and the digits array for this detector
609 AliDetector::ResetDigits ();
610 //
611}
fe4da5cc 612//_____________________________________________________________________________
613void AliTOF::Init()
614{
615 //
616 // Initialise TOF detector after it has been built
617 //
fe4da5cc 618 // Set id of TOF sensitive volume
937fe4a4 619 if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD");
fe4da5cc 620 //
fe4da5cc 621}
622
2cef3cb2 623//____________________________________________________________________________
9e1a0ddb 624void AliTOF::MakeBranch(Option_t* option, const char *file)
2cef3cb2 625{
b94fa26c 626 //
627 // Initializes the Branches of the TOF inside the
628 // trees written for each event.
517b7f8f 629 // AliDetector::MakeBranch initializes just the
68861244 630 // Branch inside TreeH. Here we add the branches in
517b7f8f 631 // TreeD, TreeS and TreeR.
b94fa26c 632 //
2ab0c725 633 AliDetector::MakeBranch(option,file);
2cef3cb2 634
635 Int_t buffersize = 4000;
636 Char_t branchname[10];
637 sprintf(branchname,"%s",GetName());
2ab0c725 638
68861244 639 const char *oD = strstr(option,"D");
640 const char *oS = strstr(option,"S");
517b7f8f 641 const char *oR = strstr(option,"R");
68861244 642
643 if (oD)
644 //
645 // one branch for TOF digits
646 //
647
2cef3cb2 648
68861244 649 if (fDigits && gAlice->TreeD() && oD){
650 MakeBranchInTree(gAlice->TreeD(),
2ab0c725 651 branchname, &fDigits,buffersize, file) ;
2cef3cb2 652 }
68861244 653
654 if (oS)
655 //
656 // one branch for TOF sdigits
657 //
658
659
660 if (fSDigits && gAlice->TreeS() && oS){
661 MakeBranchInTree(gAlice->TreeS(),
662 branchname, &fSDigits,buffersize, file) ;
663 }
664
517b7f8f 665 if (oR)
666 //
667 // one branch for TOF reconstructed particles
668 //
669
670
671 if (fReconParticles && gAlice->TreeR() && oR){
672 MakeBranchInTree(gAlice->TreeR(),
673 branchname, &fReconParticles,buffersize, file) ;
674 }
675
68861244 676}
677
678//____________________________________________________________________________
679void AliTOF::Makehits(Bool_t hits)
680{
681// default argument used, see AliTOF.h
682// Enable/Disable the writing of the TOF-hits branch
683// on TreeH
684// by default : enabled for TOFv1, v2, v3, v4
685// disabled for TOFv0
686//
687 if (hits && (IsVersion()!=0))
688 fIdSens = gMC->VolId("FPAD");
689 else
690 cout << "Option for writing the TOF-hits branch on TreeH: disabled" << endl;
2cef3cb2 691}
692
693//____________________________________________________________________________
694void AliTOF::FinishEvent()
695{
68861244 696// do nothing
2cef3cb2 697}
698
2ab0c725 699//___________________________________________
700void AliTOF::SDigits2Digits()
701{
702//
517b7f8f 703// Generate digits performing merging
2ab0c725 704//
517b7f8f 705 /*
2ab0c725 706 int nparticles = gAlice->GetNtrack();
707 cout << "Particles :" <<nparticles<<endl;
708 if (nparticles > 0 ) {
517b7f8f 709
68861244 710 AliTOF::Hits2Digits();
517b7f8f 711
2ab0c725 712 }
517b7f8f 713 */
714 cout<<"AliTOF::SDigits2Digits"<<endl;
715 if (fMerger) {
716 fMerger->Init();
717 cout<<"AliTOF::SDigits2Digits Init"<<endl;
718 fMerger->Digitise();
719 cout<<"AliTOF::SDigits2Digits Digitise() "<<endl;
720 }
721}
722
723//---------------------------------------------------------------------
724void AliTOF::SetMerger(AliTOFMerger* merger)
725{
726// Set pointer to merger
727 fMerger = merger;
728}
729
730//---------------------------------------------------------------------
731AliTOFMerger* AliTOF::Merger()
732{
733// Return pointer to merger
734 return fMerger;
2ab0c725 735}
2cef3cb2 736
68861244 737
517b7f8f 738//---------------------------------------------------------------------
2cef3cb2 739
517b7f8f 740void AliTOF::Hits2SDigits()
741{
742//
743// Use the TOF SDigitizer to make TOF SDigits
744//
745//
746 //#ifdef DEBUG
747 cout<<"ALiTOF::Hits2SDigits> start...\n";
748 //#endif
68861244 749
517b7f8f 750 char * fileSDigits = 0 ;
751 char * fileHeader = 0;
752 AliTOFSDigitizer * sd = new AliTOFSDigitizer(fileHeader,fileSDigits) ;
68861244 753
517b7f8f 754 sd->Exec("") ;
755 sd->Print("");
68861244 756
517b7f8f 757 delete sd ;
68861244 758
2cef3cb2 759}
2cef3cb2 760//___________________________________________________________________________
761Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
b94fa26c 762{
2cef3cb2 763//
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.
517b7f8f 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.
2cef3cb2 770//
b94fa26c 771
517b7f8f 772 Bool_t overlap = kFALSE;
2cef3cb2 773 Int_t vol2[5];
774
517b7f8f 775 for (Int_t ndig=0; ndig<fSDigits->GetEntries(); ndig++){
776 AliTOFdigit* currentDigit = (AliTOFdigit*)(fSDigits->UncheckedAt(ndig));
2cef3cb2 777 currentDigit->GetLocation(vol2);
517b7f8f 778 Bool_t idem= kTRUE;
779 // check on digit volume
2cef3cb2 780 for (Int_t i=0;i<=4;i++){
517b7f8f 781 if (!idem) break;
782 if (vol[i]!=vol2[i]) idem=kFALSE;}
783
784 if (idem){ // same pad fired
b94fa26c 785 Float_t tdc2 = digit[0];
786 Float_t tdc1 = currentDigit->GetTdc();
517b7f8f 787
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
791
792 if (TMath::Abs(tdc1-tdc2)<25000){
793 // in case of overlap we take the earliest
794 if (tdc1>tdc2){
795 currentDigit->SetTdc(tdc2);
796 currentDigit->SetAdc(digit[1]);
797 }
798 else {
799 currentDigit->SetTdc(tdc1);
800 currentDigit->SetAdc(digit[1]);
801 }
802 currentDigit->AddTrack(Track); // add track number in the track array
517b7f8f 803 overlap = kTRUE;
f3de6e9e 804 return overlap;
805 } else
806 overlap= kFALSE;
517b7f8f 807
808 } // close if (idem) -> two digits on the same TOF pad
809
810 } // end loop on existing sdigits
811
b94fa26c 812 return overlap;
2cef3cb2 813}
814
815
816//____________________________________________________________________________
817void AliTOF::Digits2Raw(Int_t evNumber)
b94fa26c 818{
2cef3cb2 819//
820// Starting from digits, writes the
821// Raw Data objects, i.e. a
822// TClonesArray of 18 AliTOFRawSector objects
823//
824
b94fa26c 825 TTree* tD;
2cef3cb2 826
68861244 827 // do nothing if no particles
2cef3cb2 828 Int_t nparticles = gAlice->GetEvent(evNumber);
829 if (nparticles <= 0) return;
830
b94fa26c 831 tD = gAlice->TreeD();
2cef3cb2 832
b94fa26c 833 TClonesArray* tofdigits = this->Digits();
834 Int_t ndigits = tofdigits->GetEntriesFast();
2cef3cb2 835
b94fa26c 836 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
2cef3cb2 837
838 for (Int_t isect=1;isect<=fNTof;isect++){
b94fa26c 839 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(isect);
840 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
2cef3cb2 841
842 for (Int_t digit=0; digit<ndigits; digit++){
b94fa26c 843 AliTOFdigit* currentDigit = (AliTOFdigit*)tofdigits->UncheckedAt(digit);
2cef3cb2 844 Int_t sector = currentDigit->GetSector();
845 if (sector==isect){
b94fa26c 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);
855 Int_t error = 0;
856 currentROC->AddItem(fec, tdc, error, charge, time);
68861244 857 } // close if (sector==isect) i.e. end loop on digits for the current sector
858 } // end loop on TOF digits
2cef3cb2 859
b94fa26c 860 UInt_t totSize=16,rocSize=0;
861 UInt_t rocHead[14],rocChek[14];
862 UInt_t globalCheckSum=0;
2cef3cb2 863
864 for (UInt_t iRoc = 1; iRoc<(UInt_t)fNRoc; iRoc++){
b94fa26c 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];
2cef3cb2 875 }
876
b94fa26c 877 AliTOFRoc* dummyRoc = new AliTOFRoc();
878 totSize *= 4;
879 if (totSize>=TMath::Power(2,24)) totSize=0;
880 UInt_t header = totSize;
881 UInt_t sectId = ((UInt_t)isect)<<24;
882 header += sectId;
883 globalCheckSum += dummyRoc->BitCount(header);
884 currentSector->SetGlobalCS(globalCheckSum);
885 currentSector->SetHeader(header);
2cef3cb2 886 }
887}
888
889//____________________________________________________________________________
890void AliTOF::Raw2Digits(Int_t evNumber)
b94fa26c 891{
2cef3cb2 892//
893// Converts Raw Data objects into digits objects.
894// We schematize the raw data with a
895// TClonesArray of 18 AliTOFRawSector objects
896//
b94fa26c 897
898 TTree *tD;
2cef3cb2 899 Int_t vol[5];
900 Int_t tracks[3];
901 Float_t digit[2];
902
903 tracks[0]=0;
904 tracks[1]=0;
905 tracks[2]=0;
fe4da5cc 906
2cef3cb2 907 Int_t nparticles = gAlice->GetEvent(evNumber);
908 if (nparticles <= 0) return;
909
b94fa26c 910 tD = gAlice->TreeD();
2cef3cb2 911
b94fa26c 912 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
2cef3cb2 913
914 for(Int_t nSec=1; nSec<=fNTof; nSec++){
b94fa26c 915 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(nSec);
916 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
2cef3cb2 917 for(Int_t nRoc=1; nRoc<=14; nRoc++){
b94fa26c 918 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(nRoc);
2cef3cb2 919 Int_t currentItems = currentRoc->GetItems();
920 for(Int_t item=1; item<currentItems; item++){
921 Int_t nPad = currentRoc->GetTotPad(item);
922 vol[0] = nSec;
923 Int_t nStrip = (Int_t)(nPad/fPadXStr)+1;
924 Int_t nPlate = 5;
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;
929 vol[1] = nPlate;
930 switch (nPlate){
931 case 1: break;
932 case 2: nStrip -= (fNStripC);
933 break;
934 case 3: nStrip -= (fNStripC+fNStripB);
935 break;
936 case 4: nStrip -= (fNStripC+fNStripB+fNStripA);
937 break;
938 case 5: nStrip -= (fNStripC+2*fNStripB+fNStripA);
939 break;
940 }
941 vol[2] = nStrip;
b94fa26c 942 Int_t pad = nPad%fPadXStr;
943 if (pad==0) pad=fPadXStr;
2cef3cb2 944 Int_t nPadX=0, nPadZ=0;
b94fa26c 945 (pad>fNpadX)? nPadX -= fNpadX : nPadX = pad ;
2cef3cb2 946 vol[3] = nPadX;
b94fa26c 947 (pad>fNpadX)? nPadZ = 2 : nPadZ = 1 ;
2cef3cb2 948 vol[4] = nPadZ;
949 UInt_t error=0;
b94fa26c 950 Float_t tdc = currentRoc->GetTime(item,error);
951 if (!error) digit[0]=tdc;
2cef3cb2 952 digit[1] = currentRoc->GetCharge(item);
953 AddDigit(tracks,vol,digit);
954 }
955 }
956 }
b94fa26c 957 tD->Fill();
68861244 958 tD->Write(0,TObject::kOverwrite);
2cef3cb2 959}
960