]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOF.cxx
QA check for TOF hits updated
[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$
00711221 18Revision 1.34 2002/02/20 13:41:38 hristov
19Default arguments set only in the header file
20
792995c1 21Revision 1.33 2002/02/19 10:39:38 vicinanz
22t0 classes added and material update (steel added)
23
0440c089 24Revision 1.31 2001/11/22 11:22:51 hristov
25Updated version of TOF digitization, N^2 problem solved (J.Chudoba)
26
5919c40c 27Revision 1.30 2001/10/21 18:30:39 hristov
28Several pointers were set to zero in the default constructors to avoid memory management problems
29
2685bf00 30Revision 1.29 2001/10/17 14:19:24 hristov
31delete replaced by delete []
32
3ff0c331 33Revision 1.28 2001/10/05 12:02:01 vicinanz
34Minor improvements on Merger and SDigitizer
35
766a7c4e 36Revision 1.27 2001/10/02 13:03:13 vicinanz
37Minor improvements on the code
38
f3de6e9e 39Revision 1.26 2001/09/27 10:39:20 vicinanz
40SDigitizer and Merger added
41
517b7f8f 42Revision 1.25 2001/09/07 08:37:40 hristov
43Pointers initialised to 0 in the default constructor
44
519351ab 45Revision 1.24 2001/09/05 16:31:00 hristov
46The deletion of TOF folders temporarily commented out
47
5839f074 48Revision 1.23 2001/08/29 12:59:01 vicinanz
49Minor changes to the Digitizer procedure
50
0efc163f 51Revision 1.22 2001/08/28 08:45:58 vicinanz
52TTask and TFolder structures implemented
53
68861244 54Revision 1.21 2001/05/16 14:57:24 alibrary
55New files for folders and Stack
56
9e1a0ddb 57Revision 1.20 2001/05/04 10:09:47 vicinanz
58Major upgrades to the strip structure
59
b94fa26c 60Revision 1.19 2001/03/12 17:47:25 hristov
61Changes needed on Sun with CC 5.0
62
5cf7bbad 63Revision 1.18 2001/01/26 19:57:42 hristov
64Major upgrade of AliRoot code
65
2ab0c725 66Revision 1.17 2000/10/19 09:58:14 vicinanz
67Updated Hits2Digit procedure
68
c2af3d73 69Revision 1.16 2000/10/02 21:28:17 fca
70Removal of useless dependecies via forward declarations
71
94de3818 72Revision 1.15 2000/05/18 14:33:01 vicinanz
73Modified to be full HP compliant
74
f5489efc 75Revision 1.14 2000/05/15 19:32:36 fca
76Add AddHitList !!
77
c8bd506f 78Revision 1.13 2000/05/10 16:52:18 vicinanz
79New TOF version with holes for PHOS/RICH
80
2cef3cb2 81Revision 1.11.2.1 2000/05/10 09:37:15 vicinanz
82New version with Holes for PHOS/RICH
83
1cedd08a 84Revision 1.11 1999/11/05 22:39:06 fca
85New hits structure
86
826b71ec 87Revision 1.10 1999/11/01 20:41:57 fca
88Added protections against using the wrong version of FRAME
89
ab76897d 90Revision 1.9 1999/10/15 15:35:19 fca
91New version for frame1099 with and without holes
92
937fe4a4 93Revision 1.9 1999/09/29 09:24:33 fca
94Introduction of the Copyright and cvs Log
4c039060 95
937fe4a4 96*/
68861244 97
fe4da5cc 98///////////////////////////////////////////////////////////////////////////////
99// //
68861244 100// Time Of Flight //
fe4da5cc 101// This class contains the basic functions for the Time Of Flight //
102// detector. Functions specific to one particular geometry are //
103// contained in the derived classes //
937fe4a4 104//
105// VERSIONE WITH 5 SYMMETRIC MODULES ALONG Z AXIS
106// ==============================================
107//
108// VERSION WITH HOLES FOR PHOS AND TRD IN SPACEFRAME WITH HOLES
109//
110// Volume sensibile : FPAD
111//
112//
113//
114// Begin_Html
fe4da5cc 115/*
1439f98e 116<img src="picts/AliTOFClass.gif">
fe4da5cc 117*/
118//End_Html
937fe4a4 119//
120//
fe4da5cc 121// //
122///////////////////////////////////////////////////////////////////////////////
123
826b71ec 124#include <iostream.h>
68861244 125#include <strstream.h>
517b7f8f 126#include <fstream.h>
127#include <stdlib.h>
826b71ec 128
fe4da5cc 129#include "AliTOF.h"
68861244 130#include "AliTOFhit.h"
d599d913 131#include "AliTOFhitT0.h"
68861244 132#include "AliTOFdigit.h"
5919c40c 133#include "AliTOFSDigit.h"
68861244 134#include "AliTOFRawSector.h"
135#include "AliTOFRoc.h"
136#include "AliTOFRawDigit.h"
137
138#include "TROOT.h"
826b71ec 139#include "TBRIK.h"
2cef3cb2 140#include "TNode.h"
141#include "TObject.h"
0efc163f 142#include "TSystem.h"
94de3818 143#include "TTree.h"
2ab0c725 144#include "TFile.h"
68861244 145#include "TFolder.h"
146#include "TTask.h"
94de3818 147
fe4da5cc 148#include "AliRun.h"
94de3818 149#include "AliMC.h"
150#include "AliMagF.h"
fe4da5cc 151#include "AliConst.h"
2cef3cb2 152
fe4da5cc 153
154ClassImp(AliTOF)
155
156//_____________________________________________________________________________
157AliTOF::AliTOF()
158{
159 //
160 // Default constructor
161 //
00711221 162 fFGeom = 0x0;
163 fDTask = 0x0;
164 fReTask = 0x0;
fe4da5cc 165 fIshunt = 0;
68861244 166 fSDigits = 0 ;
167 fDigits = 0 ;
00711221 168 fReconParticles = 0x0;
68861244 169 fName="TOF";
00711221 170 fMerger = 0x0;
517b7f8f 171/* fp
68861244 172 CreateTOFFolders();
517b7f8f 173*/
fe4da5cc 174}
175
176//_____________________________________________________________________________
792995c1 177AliTOF::AliTOF(const char *name, const char *title, Option_t *option)
fe4da5cc 178 : AliDetector(name,title)
179{
180 //
181 // AliTOF standard constructor
182 //
2cef3cb2 183 // Here are fixed some important parameters
184 //
185
68861244 186 // Initialization of hits, sdigits and digits array
d599d913 187 // added option for time zero analysis
188 if (strstr(option,"tzero")){
189 fHits = new TClonesArray("AliTOFhitT0", 1000);
190 cout << "tzero option requires AliTOFv4T0 as TOF version (check Your Config.C)" << endl;
191 }else{
192 fHits = new TClonesArray("AliTOFhit", 1000);
193 }
c8bd506f 194 gAlice->AddHitList(fHits);
2cef3cb2 195 fIshunt = 0;
5919c40c 196 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
517b7f8f 197 fDigits = new TClonesArray("AliTOFdigit", 1000);
00711221 198
199 fFGeom = 0x0;
200 fDTask = 0x0;
201 fReTask = 0x0;
202 fReconParticles = 0x0;
203 fMerger = 0x0;
204
2cef3cb2 205 //
206 // Digitization parameters
fe4da5cc 207 //
2cef3cb2 208 // (Transfer Functions to be inserted here)
fe4da5cc 209 //
210 SetMarkerColor(7);
211 SetMarkerStyle(2);
212 SetMarkerSize(0.4);
2cef3cb2 213
214// General Geometrical Parameters
b94fa26c 215 fNTof = 18; // number of sectors
216 fRmax = 399.0;//cm
2cef3cb2 217 fRmin = 370.0;//cm
b94fa26c 218 fZlenC = 177.5;//cm length of module C
219 fZlenB = 141.0;//cm length of module B
220 fZlenA = 106.0;//cm length of module A
517b7f8f 221 fZtof = 371.5;//cm total semi-length of TOF detector
2cef3cb2 222
223// Strip Parameters
224 fStripLn = 122.0;//cm Strip Length
225 fSpace = 5.5;//cm Space Beetween the strip and the bottom of the plate
226 fDeadBndZ= 1.5;//cm Dead Boundaries of a Strip along Z direction (width)
227 fDeadBndX= 1.0;//cm Dead Boundaries of a Strip along X direction (length)
228 fXpad = 2.5;//cm X size of a pad
229 fZpad = 3.5;//cm Z size of a pad
230 fGapA = 4.; //cm Gap beetween tilted strip in A-type plate
231 fGapB = 6.; //cm Gap beetween tilted strip in B-type plate
232 fOverSpc = 15.3;//cm Space available for sensitive layers in radial direction
233 fNpadX = 48; // Number of pads in a strip along the X direction
234 fNpadZ = 2; // Number of pads in a strip along the Z direction
235 fPadXStr = fNpadX*fNpadZ; //Number of pads per strip
b94fa26c 236 fNStripA = 15; // number of strips in A type module
237 fNStripB = 19; // number of strips in B type module
238 fNStripC = 20; // number of strips in C type module
2cef3cb2 239
240// Physical performances
241 fTimeRes = 100.;//ps
242 fChrgRes = 100.;//pC
243
244// DAQ characteristics
68861244 245// cfr. TOF-TDR pag. 105 for Glossary
246// TARODA : TOF-ALICE Read Out and Data Acquisition system
247 fPadXSector = 8928; // number of pad per sector -with no holes-
248 // ((15+2*19+2*20)*(48*2))
249 fNRoc = 14; // number of Roc (Read Out Controller) (TARODA)
250 fNFec = 32; // number of Fec (Front-End electronic Card)
251 // (TARODA)
252 fNTdc = 32; // number of Tdc (Time to Digital Converter)
253 fNPadXRoc = (Int_t)fPadXSector/fNRoc; // number of pads for each ROC
517b7f8f 254 /* fp 25 Sept 2001
68861244 255 // Create TOF Folder Structure
517b7f8f 256 CreateTOFFolders();
257 */
68861244 258}
259
260//_____________________________________________________________________________
261void AliTOF::CreateTOFFolders()
262{
263 // create the ALICE TFolder
264 // create the ALICE TTasks
265 // create the ALICE main TFolder
266 // to be done by AliRun
267
268 TFolder * alice = new TFolder();
269 alice->SetNameTitle("FPAlice", "Alice Folder") ;
270 gROOT->GetListOfBrowsables()->Add(alice) ;
271
272 TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ;
273 // make it the owner of the objects that it contains
274 aliceF->SetOwner() ;
275 // geometry folder
276 TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ;
277 TFolder * aliceT = alice->AddFolder("tasks", "Alice tasks Folder") ;
278 // make it the owner of the objects that it contains
279 aliceT->SetOwner() ;
280
281 TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ;
282 aliceT->Add(aliceDi);
283
284 TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
285 aliceT->Add(aliceRe);
286
287 char * tempo = new char[80] ;
288
289 // creates the TOF Digitizer and adds it to alice main (S)Digitizer task
290 sprintf(tempo, "%sDigitizers container",GetName() ) ;
291 fDTask = new TTask(GetName(), tempo);
292 aliceDi->Add(fDTask) ;
293
294 // creates the TOF reconstructioner and adds it to alice main Reconstructioner task
295 sprintf(tempo, "%sReconstructioner container",GetName() ) ;
296 fReTask = new TTask(GetName(), tempo);
297 aliceRe->Add(fReTask) ;
298
3ff0c331 299 delete [] tempo ;
68861244 300
301 // creates the TOF geometry folder
302 geomF->AddFolder("TOF", "Geometry for TOF") ;
303}
304
305//_____________________________________________________________________________
306AliTOF::~AliTOF()
307{
517b7f8f 308 // dtor:
309 // it remove also the alice folder
68861244 310 // and task that TOF creates instead of AliRun
5839f074 311 /* PH Temporarily commented because of problems
68861244 312 TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ;
313 delete alice;
314 alice = 0;
5839f074 315 */
517b7f8f 316 if (fHits)
317 {
318 fHits->Delete ();
319 delete fHits;
320 fHits = 0;
321 }
322 if (fDigits)
323 {
324 fDigits->Delete ();
325 delete fDigits;
326 fDigits = 0;
327 }
328 if (fSDigits)
329 {
330 fSDigits->Delete ();
331 delete fSDigits;
332 fSDigits = 0;
333 }
334 if (fReconParticles)
335 {
336 fReconParticles->Delete ();
337 delete fReconParticles;
338 fReconParticles = 0;
339 }
340
fe4da5cc 341}
342
343//_____________________________________________________________________________
2cef3cb2 344void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits)
fe4da5cc 345{
346 //
347 // Add a TOF hit
68861244 348 // new with placement used
fe4da5cc 349 //
350 TClonesArray &lhits = *fHits;
2cef3cb2 351 new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits);
fe4da5cc 352}
d599d913 353
354//_____________________________________________________________________________
355void AliTOF::AddT0Hit(Int_t track, Int_t *vol, Float_t *hits)
356{
357 //
358 // Add a TOF hit
359 // new with placement used
360 //
361 TClonesArray &lhits = *fHits;
362 new(lhits[fNhits++]) AliTOFhitT0(fIshunt, track, vol, hits);
363}
364
fe4da5cc 365//_____________________________________________________________________________
2cef3cb2 366void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
fe4da5cc 367{
368 //
2cef3cb2 369 // Add a TOF digit
68861244 370 // new with placement used
2cef3cb2 371 //
372 TClonesArray &ldigits = *fDigits;
373 new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits);
fe4da5cc 374}
375
517b7f8f 376//___________________________________________
5919c40c 377void AliTOF::AddSDigit(Int_t tracknum, Int_t *vol, Float_t *digits)
517b7f8f 378{
379
380//
381// Add a TOF sdigit
382//
383
384 TClonesArray &lSDigits = *fSDigits;
5919c40c 385 new(lSDigits[fNSDigits++]) AliTOFSDigit(tracknum, vol, digits);
517b7f8f 386}
387
388//_____________________________________________________________________________
389void AliTOF::SetTreeAddress ()
390{
391 // Set branch address for the Hits and Digits Tree.
392 char branchname[30];
393 AliDetector::SetTreeAddress ();
394
395 TBranch *branch;
396 TTree *treeD = gAlice->TreeD ();
397
398
399 if (treeD)
400 {
401 if (fDigits)
402 {
403 branch = treeD->GetBranch (branchname);
404 if (branch)
405 branch->SetAddress (&fDigits);
406 }
407
408 }
5919c40c 409// if (fSDigits)
517b7f8f 410 // fSDigits->Clear ();
411
412 if (gAlice->TreeS () && fSDigits)
413 {
414 branch = gAlice->TreeS ()->GetBranch ("TOF");
415 if (branch)
416 branch->SetAddress (&fSDigits);
417 }
418
419 if (gAlice->TreeR() && fReconParticles)
420 {
421 branch = gAlice->TreeR()->GetBranch("TOF");
422 if (branch) branch->SetAddress(&fReconParticles) ;
423 }
424}
2cef3cb2 425
fe4da5cc 426//_____________________________________________________________________________
427void AliTOF::CreateGeometry()
428{
429 //
3fe3a833 430 // Common geometry code
fe4da5cc 431 //
432 //Begin_Html
433 /*
1439f98e 434 <img src="picts/AliTOFv23.gif">
fe4da5cc 435 */
436 //End_Html
437 //
fe4da5cc 438 const Double_t kPi=TMath::Pi();
2cef3cb2 439 const Double_t kDegrad=kPi/180.;
fe4da5cc 440 //
b94fa26c 441 Float_t xTof, yTof, wall;
937fe4a4 442
3fe3a833 443 // frame inbetween TOF modules
b94fa26c 444 wall = 4.;//cm
3fe3a833 445
2cef3cb2 446 // Sizes of TOF module with its support etc..
b94fa26c 447 xTof = 2.*(fRmin*TMath::Tan(10*kDegrad)-wall/2-.5);
2cef3cb2 448 yTof = fRmax-fRmin;
3fe3a833 449
937fe4a4 450// TOF module internal definitions
2cef3cb2 451 TOFpc(xTof, yTof, fZlenC, fZlenB, fZlenA, fZtof);
fe4da5cc 452}
453
454//_____________________________________________________________________________
68861244 455void AliTOF::DrawModule() const
fe4da5cc 456{
457 //
458 // Draw a shaded view of the common part of the TOF geometry
fe4da5cc 459 //
460
3fe3a833 461 cout << " Drawing of AliTOF"<< endl;
fe4da5cc 462 // Set everything unseen
cfce8870 463 gMC->Gsatt("*", "seen", -1);
fe4da5cc 464 //
465 // Set ALIC mother transparent
cfce8870 466 gMC->Gsatt("ALIC","SEEN",0);
fe4da5cc 467 //
468 // Set the volumes visible
2cef3cb2 469 gMC->Gsatt("FTOA","SEEN",1);
470 gMC->Gsatt("FTOB","SEEN",1);
471 gMC->Gsatt("FTOC","SEEN",1);
472 gMC->Gsatt("FLTA","SEEN",1);
473 gMC->Gsatt("FLTB","SEEN",1);
474 gMC->Gsatt("FLTC","SEEN",1);
475 gMC->Gsatt("FSTR","SEEN",1);
cfce8870 476 //
477 gMC->Gdopt("hide", "on");
478 gMC->Gdopt("shad", "on");
479 gMC->Gsatt("*", "fill", 7);
480 gMC->SetClipBox(".");
481 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
482 gMC->DefaultRange();
483 gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
484 gMC->Gdhead(1111, "Time Of Flight");
485 gMC->Gdman(18, 4, "MAN");
486 gMC->Gdopt("hide","off");
fe4da5cc 487}
488
489//_____________________________________________________________________________
490void AliTOF::CreateMaterials()
491{
492 //
493 // Defines TOF materials for all versions
2cef3cb2 494 // Authors : Maxim Martemianov, Boris Zagreev (ITEP)
495 // 18/09/98
b94fa26c 496 // Revision: F. Pierella 5-3-2001
497 // Bologna University
fe4da5cc 498 //
b94fa26c 499 Int_t isxfld = gAlice->Field()->Integ();
500 Float_t sxmgmx = gAlice->Field()->Max();
fe4da5cc 501 //
3fe3a833 502 //--- Quartz (SiO2)
503 Float_t aq[2] = { 28.0855,15.9994 };
504 Float_t zq[2] = { 14.,8. };
505 Float_t wq[2] = { 1.,2. };
506 Float_t dq = 2.20;
507 Int_t nq = -2;
b94fa26c 508 // --- Freon C2F4H2 (TOF-TDR pagg.)
509 // Geant Manual CONS110-1, pag. 43 (Geant, Detector Description and Simulation Tool)
510 Float_t afre[3] = {12.011,18.998,1.007};
511 Float_t zfre[3] = { 6., 9., 1.};
512 Float_t wfre[3] = { 2., 4., 2.};
513 Float_t densfre = 0.00375;
514// http://www.fi.infn.it/sezione/prevprot/gas/freon.html
515 Int_t nfre = -3;
516/*
517 //-- Isobutane quencher C4H10 (5% in the sensitive mixture)
518 Float_t aiso[2] = {12.011,1.007};
519 Float_t ziso[2] = { 6., 1.};
520 Float_t wiso[2] = { 4., 10.};
521 Float_t densiso = .......; // (g/cm3) density
522 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
523 //-- SF6 (5% in the sensitive mixture)
524 Float_t asf[3] = {32.066,18.998};
525 Float_t zsf[3] = { 16., 9.};
526 Float_t wsf[3] = { 1., 6.};
527 Float_t denssf = .....; // (g/cm3) density
528 Int_t nfre = -2; // < 0 i.e. proportion by number of atoms of each kind
529*/
3fe3a833 530 // --- CO2
2cef3cb2 531 Float_t ac[2] = {12.,16.};
532 Float_t zc[2] = { 6., 8.};
533 Float_t wc[2] = { 1., 2.};
3fe3a833 534 Float_t dc = .001977;
535 Int_t nc = -2;
536 // For mylar (C5H4O2)
537 Float_t amy[3] = { 12., 1., 16. };
538 Float_t zmy[3] = { 6., 1., 8. };
539 Float_t wmy[3] = { 5., 4., 2. };
540 Float_t dmy = 1.39;
541 Int_t nmy = -3;
b94fa26c 542 // For polyethilene (CH2) - honeycomb -
3fe3a833 543 Float_t ape[2] = { 12., 1. };
544 Float_t zpe[2] = { 6., 1. };
545 Float_t wpe[2] = { 1., 2. };
546 Float_t dpe = 0.935*0.479; //To have 1%X0 for 1cm as for honeycomb
547 Int_t npe = -2;
548 // --- G10
fe4da5cc 549 Float_t ag10[4] = { 12.,1.,16.,28. };
2cef3cb2 550 Float_t zg10[4] = { 6.,1., 8.,14. };
fe4da5cc 551 Float_t wmatg10[4] = { .259,.288,.248,.205 };
3fe3a833 552 Float_t densg10 = 1.7;
553 Int_t nlmatg10 = -4;
554 // --- DME
fe4da5cc 555 Float_t adme[5] = { 12.,1.,16.,19.,79. };
2cef3cb2 556 Float_t zdme[5] = { 6.,1., 8., 9.,35. };
fe4da5cc 557 Float_t wmatdme[5] = { .4056,.0961,.2562,.1014,.1407 };
3fe3a833 558 Float_t densdme = .00205;
559 Int_t nlmatdme = 5;
560 // ---- ALUMINA (AL203)
2cef3cb2 561 Float_t aal[2] = { 27.,16.};
562 Float_t zal[2] = { 13., 8.};
fe4da5cc 563 Float_t wmatal[2] = { 2.,3. };
3fe3a833 564 Float_t densal = 2.3;
565 Int_t nlmatal = -2;
566 // -- Water
567 Float_t awa[2] = { 1., 16. };
568 Float_t zwa[2] = { 1., 8. };
569 Float_t wwa[2] = { 2., 1. };
570 Float_t dwa = 1.0;
571 Int_t nwa = -2;
d599d913 572
573// stainless steel
574 Float_t asteel[4] = { 55.847,51.9961,58.6934,28.0855 };
575 Float_t zsteel[4] = { 26.,24.,28.,14. };
576 Float_t wsteel[4] = { .715,.18,.1,.005 };
577
fe4da5cc 578 //
3fe3a833 579 //AliMaterial(0, "Vacuum$", 1e-16, 1e-16, 1e-16, 1e16, 1e16);
2cef3cb2 580 AliMaterial( 1, "Air$",14.61,7.3,0.001205,30423.24,67500.);
581 AliMaterial( 2, "Cu $", 63.54, 29.0, 8.96, 1.43, 14.8);
582 AliMaterial( 3, "C $", 12.01, 6.0, 2.265,18.8, 74.4);
583 AliMixture ( 4, "Polyethilene$", ape, zpe, dpe, npe, wpe);
584 AliMixture ( 5, "G10$", ag10, zg10, densg10, nlmatg10, wmatg10);
585 AliMixture ( 6, "DME ", adme, zdme, densdme, nlmatdme, wmatdme);
586 AliMixture ( 7, "CO2$", ac, zc, dc, nc, wc);
587 AliMixture ( 8, "ALUMINA$", aal, zal, densal, nlmatal, wmatal);
588 AliMaterial( 9, "Al $", 26.98, 13., 2.7, 8.9, 37.2);
3fe3a833 589 AliMaterial(10, "C-TRD$", 12.01, 6., 2.265*18.8/69.282*15./100, 18.8, 74.4); // for 15%
2cef3cb2 590 AliMixture (11, "Mylar$", amy, zmy, dmy, nmy, wmy);
591 AliMixture (12, "Freon$", afre, zfre, densfre, nfre, wfre);
592 AliMixture (13, "Quartz$", aq, zq, dq, nq, wq);
593 AliMixture (14, "Water$", awa, zwa, dwa, nwa, wwa);
d599d913 594 AliMixture (15, "STAINLESS STEEL$", asteel, zsteel, 7.88, 4, wsteel);
3fe3a833 595
596 Float_t epsil, stmin, deemax, stemax;
2cef3cb2 597
598 // Previous data
fe4da5cc 599 // EPSIL = 0.1 ! Tracking precision,
600 // STEMAX = 0.1 ! Maximum displacement for multiple scattering
601 // DEEMAX = 0.1 ! Maximum fractional energy loss, DLS
602 // STMIN = 0.1
2cef3cb2 603 //
604 // New data
605 epsil = .001; // Tracking precision,
606 stemax = -1.; // Maximum displacement for multiple scattering
607 deemax = -.3; // Maximum fractional energy loss, DLS
fe4da5cc 608 stmin = -.8;
937fe4a4 609
b94fa26c 610 AliMedium( 1, "Air$" , 1, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
611 AliMedium( 2, "Cu $" , 2, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
612 AliMedium( 3, "C $" , 3, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
613 AliMedium( 4, "Pol$" , 4, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
614 AliMedium( 5, "G10$" , 5, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
615 AliMedium( 6, "DME$" , 6, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
616 AliMedium( 7, "CO2$" , 7, 0, isxfld, sxmgmx, 10., -.01, -.1, .01, -.01);
617 AliMedium( 8,"ALUMINA$", 8, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
618 AliMedium( 9,"Al Frame$",9, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
619 AliMedium(10, "DME-S$", 6, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
620 AliMedium(11, "C-TRD$", 10, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
621 AliMedium(12, "Myl$" , 11, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
622 AliMedium(13, "Fre$" , 12, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
623 AliMedium(14, "Fre-S$", 12, 1, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
624 AliMedium(15, "Glass$", 13, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
625 AliMedium(16, "Water$", 14, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
d599d913 626 AliMedium(17, "STEEL$", 15, 0, isxfld, sxmgmx, 10., stemax, deemax, epsil, stmin);
fe4da5cc 627}
628
629//_____________________________________________________________________________
68861244 630Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t ) const
fe4da5cc 631{
632 //
633 // Returns distance from mouse pointer to detector, default version
634 //
635 return 9999;
636}
517b7f8f 637
638//___________________________________________
639void AliTOF::ResetHits ()
640{
641 // Reset number of clusters and the cluster array for this detector
642 AliDetector::ResetHits ();
643}
644
645//____________________________________________
646void AliTOF::ResetDigits ()
647{
648 //
649 // Reset number of digits and the digits array for this detector
650 AliDetector::ResetDigits ();
651 //
652}
fe4da5cc 653//_____________________________________________________________________________
654void AliTOF::Init()
655{
656 //
657 // Initialise TOF detector after it has been built
658 //
fe4da5cc 659 // Set id of TOF sensitive volume
937fe4a4 660 if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD");
fe4da5cc 661 //
fe4da5cc 662}
663
2cef3cb2 664//____________________________________________________________________________
9e1a0ddb 665void AliTOF::MakeBranch(Option_t* option, const char *file)
2cef3cb2 666{
b94fa26c 667 //
668 // Initializes the Branches of the TOF inside the
669 // trees written for each event.
517b7f8f 670 // AliDetector::MakeBranch initializes just the
68861244 671 // Branch inside TreeH. Here we add the branches in
517b7f8f 672 // TreeD, TreeS and TreeR.
b94fa26c 673 //
2ab0c725 674 AliDetector::MakeBranch(option,file);
2cef3cb2 675
676 Int_t buffersize = 4000;
677 Char_t branchname[10];
678 sprintf(branchname,"%s",GetName());
2ab0c725 679
68861244 680 const char *oD = strstr(option,"D");
681 const char *oS = strstr(option,"S");
517b7f8f 682 const char *oR = strstr(option,"R");
68861244 683
684 if (oD)
685 //
686 // one branch for TOF digits
687 //
688
2cef3cb2 689
68861244 690 if (fDigits && gAlice->TreeD() && oD){
691 MakeBranchInTree(gAlice->TreeD(),
2ab0c725 692 branchname, &fDigits,buffersize, file) ;
2cef3cb2 693 }
68861244 694
695 if (oS)
696 //
697 // one branch for TOF sdigits
698 //
699
700
701 if (fSDigits && gAlice->TreeS() && oS){
702 MakeBranchInTree(gAlice->TreeS(),
703 branchname, &fSDigits,buffersize, file) ;
704 }
705
517b7f8f 706 if (oR)
707 //
708 // one branch for TOF reconstructed particles
709 //
710
711
712 if (fReconParticles && gAlice->TreeR() && oR){
713 MakeBranchInTree(gAlice->TreeR(),
714 branchname, &fReconParticles,buffersize, file) ;
715 }
716
68861244 717}
718
719//____________________________________________________________________________
720void AliTOF::Makehits(Bool_t hits)
721{
722// default argument used, see AliTOF.h
723// Enable/Disable the writing of the TOF-hits branch
724// on TreeH
725// by default : enabled for TOFv1, v2, v3, v4
726// disabled for TOFv0
727//
728 if (hits && (IsVersion()!=0))
729 fIdSens = gMC->VolId("FPAD");
730 else
731 cout << "Option for writing the TOF-hits branch on TreeH: disabled" << endl;
2cef3cb2 732}
733
734//____________________________________________________________________________
735void AliTOF::FinishEvent()
736{
68861244 737// do nothing
2cef3cb2 738}
739
2ab0c725 740//___________________________________________
741void AliTOF::SDigits2Digits()
742{
743//
517b7f8f 744// Generate digits performing merging
2ab0c725 745//
517b7f8f 746 /*
2ab0c725 747 int nparticles = gAlice->GetNtrack();
748 cout << "Particles :" <<nparticles<<endl;
749 if (nparticles > 0 ) {
517b7f8f 750
68861244 751 AliTOF::Hits2Digits();
517b7f8f 752
2ab0c725 753 }
517b7f8f 754 */
755 cout<<"AliTOF::SDigits2Digits"<<endl;
756 if (fMerger) {
757 fMerger->Init();
758 cout<<"AliTOF::SDigits2Digits Init"<<endl;
759 fMerger->Digitise();
760 cout<<"AliTOF::SDigits2Digits Digitise() "<<endl;
761 }
762}
763
764//---------------------------------------------------------------------
765void AliTOF::SetMerger(AliTOFMerger* merger)
766{
767// Set pointer to merger
768 fMerger = merger;
769}
770
771//---------------------------------------------------------------------
772AliTOFMerger* AliTOF::Merger()
773{
774// Return pointer to merger
775 return fMerger;
2ab0c725 776}
2cef3cb2 777
68861244 778
517b7f8f 779//---------------------------------------------------------------------
2cef3cb2 780
517b7f8f 781void AliTOF::Hits2SDigits()
782{
783//
784// Use the TOF SDigitizer to make TOF SDigits
785//
786//
787 //#ifdef DEBUG
788 cout<<"ALiTOF::Hits2SDigits> start...\n";
789 //#endif
68861244 790
517b7f8f 791 char * fileSDigits = 0 ;
792 char * fileHeader = 0;
793 AliTOFSDigitizer * sd = new AliTOFSDigitizer(fileHeader,fileSDigits) ;
68861244 794
517b7f8f 795 sd->Exec("") ;
796 sd->Print("");
68861244 797
517b7f8f 798 delete sd ;
68861244 799
2cef3cb2 800}
2cef3cb2 801//___________________________________________________________________________
802Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
b94fa26c 803{
2cef3cb2 804//
805// Checks if 2 or more hits belong to the same pad.
806// In this case the data assigned to the digit object
807// are the ones of the first hit in order of Time.
517b7f8f 808// 2 hits from the same track on the same pad are collected.
809// Called only by Hits2SDigits.
810// This procedure has to be optimized in the next TOF release.
2cef3cb2 811//
b94fa26c 812
517b7f8f 813 Bool_t overlap = kFALSE;
2cef3cb2 814 Int_t vol2[5];
815
517b7f8f 816 for (Int_t ndig=0; ndig<fSDigits->GetEntries(); ndig++){
817 AliTOFdigit* currentDigit = (AliTOFdigit*)(fSDigits->UncheckedAt(ndig));
2cef3cb2 818 currentDigit->GetLocation(vol2);
517b7f8f 819 Bool_t idem= kTRUE;
820 // check on digit volume
2cef3cb2 821 for (Int_t i=0;i<=4;i++){
517b7f8f 822 if (!idem) break;
823 if (vol[i]!=vol2[i]) idem=kFALSE;}
824
825 if (idem){ // same pad fired
b94fa26c 826 Float_t tdc2 = digit[0];
827 Float_t tdc1 = currentDigit->GetTdc();
517b7f8f 828
829 // we separate two digits on the same pad if
830 // they are separated in time by at least 25 ns
831 // remember that tdc time is given in ps
832
833 if (TMath::Abs(tdc1-tdc2)<25000){
834 // in case of overlap we take the earliest
835 if (tdc1>tdc2){
836 currentDigit->SetTdc(tdc2);
837 currentDigit->SetAdc(digit[1]);
838 }
839 else {
840 currentDigit->SetTdc(tdc1);
841 currentDigit->SetAdc(digit[1]);
842 }
843 currentDigit->AddTrack(Track); // add track number in the track array
517b7f8f 844 overlap = kTRUE;
f3de6e9e 845 return overlap;
846 } else
847 overlap= kFALSE;
517b7f8f 848
849 } // close if (idem) -> two digits on the same TOF pad
850
851 } // end loop on existing sdigits
852
b94fa26c 853 return overlap;
2cef3cb2 854}
855
856
857//____________________________________________________________________________
858void AliTOF::Digits2Raw(Int_t evNumber)
b94fa26c 859{
2cef3cb2 860//
861// Starting from digits, writes the
862// Raw Data objects, i.e. a
863// TClonesArray of 18 AliTOFRawSector objects
864//
865
b94fa26c 866 TTree* tD;
2cef3cb2 867
68861244 868 // do nothing if no particles
2cef3cb2 869 Int_t nparticles = gAlice->GetEvent(evNumber);
870 if (nparticles <= 0) return;
871
b94fa26c 872 tD = gAlice->TreeD();
2cef3cb2 873
b94fa26c 874 TClonesArray* tofdigits = this->Digits();
875 Int_t ndigits = tofdigits->GetEntriesFast();
2cef3cb2 876
b94fa26c 877 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
2cef3cb2 878
879 for (Int_t isect=1;isect<=fNTof;isect++){
b94fa26c 880 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(isect);
881 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
2cef3cb2 882
883 for (Int_t digit=0; digit<ndigits; digit++){
b94fa26c 884 AliTOFdigit* currentDigit = (AliTOFdigit*)tofdigits->UncheckedAt(digit);
2cef3cb2 885 Int_t sector = currentDigit->GetSector();
886 if (sector==isect){
b94fa26c 887 Int_t pad = currentDigit -> GetTotPad();
888 Int_t roc = (Int_t)(pad/fNPadXRoc)-1;
889 if (roc>=fNRoc) printf("Wrong n. of ROC ! Roc = %i",roc);
890 Int_t padRoc = (Int_t) pad%fNPadXRoc;
891 Int_t fec = (Int_t)(padRoc/fNFec)-1;
892 Int_t tdc = (Int_t)(padRoc%fNFec)-1;
893 Float_t time = currentDigit->GetTdc();
894 Float_t charge = currentDigit->GetAdc();
895 AliTOFRoc* currentROC = (AliTOFRoc*)rocData->UncheckedAt(roc);
896 Int_t error = 0;
897 currentROC->AddItem(fec, tdc, error, charge, time);
68861244 898 } // close if (sector==isect) i.e. end loop on digits for the current sector
899 } // end loop on TOF digits
2cef3cb2 900
b94fa26c 901 UInt_t totSize=16,rocSize=0;
902 UInt_t rocHead[14],rocChek[14];
903 UInt_t globalCheckSum=0;
2cef3cb2 904
905 for (UInt_t iRoc = 1; iRoc<(UInt_t)fNRoc; iRoc++){
b94fa26c 906 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(iRoc);
907 rocSize = currentRoc->GetItems()*2+1;
908 totSize += rocSize*4;
909 if (rocSize>=TMath::Power(2,16)) rocSize=0;
910 rocHead[iRoc] = iRoc<<28;
911 rocHead[iRoc] += rocSize;
912 rocChek[iRoc] = currentRoc->GetCheckSum();
913 Int_t headCheck = currentRoc->BitCount(rocHead[iRoc]);
914 globalCheckSum += headCheck;
915 globalCheckSum += rocChek[iRoc];
2cef3cb2 916 }
917
b94fa26c 918 AliTOFRoc* dummyRoc = new AliTOFRoc();
919 totSize *= 4;
920 if (totSize>=TMath::Power(2,24)) totSize=0;
921 UInt_t header = totSize;
922 UInt_t sectId = ((UInt_t)isect)<<24;
923 header += sectId;
924 globalCheckSum += dummyRoc->BitCount(header);
925 currentSector->SetGlobalCS(globalCheckSum);
926 currentSector->SetHeader(header);
2cef3cb2 927 }
928}
929
930//____________________________________________________________________________
931void AliTOF::Raw2Digits(Int_t evNumber)
b94fa26c 932{
2cef3cb2 933//
934// Converts Raw Data objects into digits objects.
935// We schematize the raw data with a
936// TClonesArray of 18 AliTOFRawSector objects
937//
b94fa26c 938
939 TTree *tD;
2cef3cb2 940 Int_t vol[5];
941 Int_t tracks[3];
942 Float_t digit[2];
943
944 tracks[0]=0;
945 tracks[1]=0;
946 tracks[2]=0;
fe4da5cc 947
2cef3cb2 948 Int_t nparticles = gAlice->GetEvent(evNumber);
949 if (nparticles <= 0) return;
950
b94fa26c 951 tD = gAlice->TreeD();
2cef3cb2 952
b94fa26c 953 TClonesArray* rawsectors = new TClonesArray("AliTOFRawSector",fNTof+2);
2cef3cb2 954
955 for(Int_t nSec=1; nSec<=fNTof; nSec++){
b94fa26c 956 AliTOFRawSector* currentSector = (AliTOFRawSector*)rawsectors->UncheckedAt(nSec);
957 TClonesArray* rocData = (TClonesArray*)currentSector->GetRocData();
2cef3cb2 958 for(Int_t nRoc=1; nRoc<=14; nRoc++){
b94fa26c 959 AliTOFRoc* currentRoc = (AliTOFRoc*)rocData->UncheckedAt(nRoc);
2cef3cb2 960 Int_t currentItems = currentRoc->GetItems();
961 for(Int_t item=1; item<currentItems; item++){
962 Int_t nPad = currentRoc->GetTotPad(item);
963 vol[0] = nSec;
964 Int_t nStrip = (Int_t)(nPad/fPadXStr)+1;
965 Int_t nPlate = 5;
966 if (nStrip<=fNStripC+2*fNStripB+fNStripA) nPlate = 4;
967 if (nStrip<=fNStripC+fNStripB+fNStripA) nPlate = 3;
968 if (nStrip<=fNStripC+fNStripB) nPlate = 2;
969 if (nStrip<=fNStripC) nPlate=1;
970 vol[1] = nPlate;
971 switch (nPlate){
972 case 1: break;
973 case 2: nStrip -= (fNStripC);
974 break;
975 case 3: nStrip -= (fNStripC+fNStripB);
976 break;
977 case 4: nStrip -= (fNStripC+fNStripB+fNStripA);
978 break;
979 case 5: nStrip -= (fNStripC+2*fNStripB+fNStripA);
980 break;
981 }
982 vol[2] = nStrip;
b94fa26c 983 Int_t pad = nPad%fPadXStr;
984 if (pad==0) pad=fPadXStr;
2cef3cb2 985 Int_t nPadX=0, nPadZ=0;
b94fa26c 986 (pad>fNpadX)? nPadX -= fNpadX : nPadX = pad ;
2cef3cb2 987 vol[3] = nPadX;
b94fa26c 988 (pad>fNpadX)? nPadZ = 2 : nPadZ = 1 ;
2cef3cb2 989 vol[4] = nPadZ;
990 UInt_t error=0;
b94fa26c 991 Float_t tdc = currentRoc->GetTime(item,error);
992 if (!error) digit[0]=tdc;
2cef3cb2 993 digit[1] = currentRoc->GetCharge(item);
994 AddDigit(tracks,vol,digit);
995 }
996 }
997 }
b94fa26c 998 tD->Fill();
68861244 999 tD->Write(0,TObject::kOverwrite);
2cef3cb2 1000}
1001