]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOF.cxx
New default values for baselines (F.Prino)
[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 **************************************************************************/
88cb7938 15/* $Id$ */
68861244 16
fe4da5cc 17///////////////////////////////////////////////////////////////////////////////
18// //
68861244 19// Time Of Flight //
fe4da5cc 20// This class contains the basic functions for the Time Of Flight //
21// detector. Functions specific to one particular geometry are //
22// contained in the derived classes //
d3c7bfac 23// //
24// VERSIONE WITH 5 SYMMETRIC MODULES ALONG Z AXIS //
25// ============================================================ //
26// //
27// VERSION WITH HOLES FOR PHOS AND TRD IN SPACEFRAME WITH HOLES //
28// //
29// Volume sensibile : FPAD //
30// //
31// //
32// //
33// //
34///////////////////////////////////////////////////////////////////////////////
937fe4a4 35// Begin_Html
fe4da5cc 36/*
1439f98e 37<img src="picts/AliTOFClass.gif">
fe4da5cc 38*/
39//End_Html
d3c7bfac 40
7ca4655f 41#include <TClonesArray.h>
42#include <TFile.h>
43#include <TFolder.h>
44#include <TROOT.h>
45#include <TTask.h>
46#include <TTree.h>
47#include <TVirtualMC.h>
515faf5d 48#include <TStopwatch.h>
fe4da5cc 49
88cb7938 50#include "AliConst.h"
51#include "AliLoader.h"
0e46b9ae 52#include "AliLog.h"
53#include "AliMC.h"
88cb7938 54#include "AliRun.h"
0e46b9ae 55
56#include "AliTOFDDLRawData.h"
57#include "AliTOFDigitizer.h"
88cb7938 58#include "AliTOFdigit.h"
88cb7938 59#include "AliTOFhitT0.h"
0e46b9ae 60#include "AliTOFhit.h"
61#include "AliTOFGeometry.h"
62#include "AliTOFSDigitizer.h"
63#include "AliTOFSDigit.h"
64#include "AliTOF.h"
65
66class AliTOFcluster;
67
68extern TFile *gFile;
69extern TROOT *gROOT;
70extern TVirtualMC *gMC;
71
72extern AliRun *gAlice;
73
fe4da5cc 74
75ClassImp(AliTOF)
76
77//_____________________________________________________________________________
655e379f 78AliTOF::AliTOF():
79 fFGeom(0x0),
80 fDTask(0x0),
81 fReTask(0x0),
82 fSDigits(0x0),
83 fNSDigits(0),
84 fReconParticles(0x0),
85 fIdSens(-1),
86 fTZero(kFALSE),
4f283355 87 fTOFHoles(kTRUE),
655e379f 88 fTOFGeometry(0x0)
fe4da5cc 89{
90 //
91 // Default constructor
92 //
0e9dd0cf 93
94 //by default all sectors switched on
95 for (Int_t ii=0; ii<18; ii++) fTOFSectors[ii]=0;
96
655e379f 97 fDigits = 0;
fe4da5cc 98 fIshunt = 0;
655e379f 99 fName = "TOF";
fe4da5cc 100}
101
102//_____________________________________________________________________________
792995c1 103AliTOF::AliTOF(const char *name, const char *title, Option_t *option)
655e379f 104 :
105 AliDetector(name,title),
106 fFGeom(0x0),
107 fDTask(0x0),
108 fReTask(0x0),
109 fSDigits(0x0),
110 fNSDigits(0),
111 fReconParticles(0x0),
112 fIdSens(-1),
113 fTZero(kFALSE),
4f283355 114 fTOFHoles(kTRUE),
655e379f 115 fTOFGeometry(0x0)
fe4da5cc 116{
117 //
118 // AliTOF standard constructor
119 //
2cef3cb2 120 // Here are fixed some important parameters
121 //
122
68861244 123 // Initialization of hits, sdigits and digits array
d599d913 124 // added option for time zero analysis
655e379f 125 //skowron
d3c7bfac 126 fTOFGeometry = new AliTOFGeometry();
88cb7938 127
0e9dd0cf 128 //by default all sectors switched on
129 for (Int_t ii=0; ii<18; ii++) fTOFSectors[ii]=0;
130
d599d913 131 if (strstr(option,"tzero")){
132 fHits = new TClonesArray("AliTOFhitT0", 1000);
88cb7938 133 fTZero = kTRUE;
655e379f 134 // AliWarning("tzero option requires AliTOFv4T0/AliTOFv5T0 as TOF version (check Your Config.C)");
d599d913 135 }else{
136 fHits = new TClonesArray("AliTOFhit", 1000);
88cb7938 137 fTZero = kFALSE;
d599d913 138 }
c630aafd 139 if (gAlice==0) {
d076c8d5 140 AliFatal("gAlice==0 !");
c630aafd 141 }
0e46b9ae 142
143 AliMC *mcApplication = (AliMC*)gAlice->GetMCApp();
144
145 if (mcApplication->GetHitLists())
146 mcApplication->AddHitList(fHits);
d076c8d5 147 else AliError("gAlice->GetHitLists()==0");
c630aafd 148
2cef3cb2 149 fIshunt = 0;
7e6dce66 150 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
151 fDigits = new TClonesArray("AliTOFdigit", 1000);
00711221 152
2cef3cb2 153 //
154 // Digitization parameters
fe4da5cc 155 //
2cef3cb2 156 // (Transfer Functions to be inserted here)
fe4da5cc 157 //
e939a978 158 //PH SetMarkerColor(7);
159 //PH SetMarkerStyle(2);
160 //PH SetMarkerSize(0.4);
2cef3cb2 161
2cef3cb2 162// Strip Parameters
7e6dce66 163 //fGapA = 4.; //cm Gap beetween tilted strip in A-type plate
164 //fGapB = 6.; //cm Gap beetween tilted strip in B-type plate
165
166 // Physical performances
167 //fTimeRes = 100.;//ps
168 //fChrgRes = 100.;//pC
169
68861244 170}
171
06e24a91 172//____________________________________________________________________________
d0eb8f39 173void AliTOF::SetTOFSectors(Int_t *sectors)
174{
175 // Setter for partial/full TOF configuration
176
06e24a91 177 for(Int_t isec=0;isec<18;isec++){
178 fTOFSectors[isec]=sectors[isec];
179 }
180}
181//____________________________________________________________________________
d0eb8f39 182void AliTOF::GetTOFSectors(Int_t *sectors) const
183{
184 // Getter for partial/full TOF configuration
06e24a91 185
186 for(Int_t isec=0;isec<18;isec++){
187 sectors[isec]=fTOFSectors[isec];
188 }
189}
7aeeaf38 190//_____________________________________________________________________________
191AliTOF::AliTOF(const AliTOF &source)
4f283355 192 :
193 AliDetector(),
655e379f 194 fFGeom(0x0),
195 fDTask(0x0),
196 fReTask(0x0),
197 fSDigits(0x0),
198 fNSDigits(0),
199 fReconParticles(0x0),
200 fIdSens(-1),
201 fTZero(kFALSE),
4f283355 202 fTOFHoles(kTRUE),
655e379f 203 fTOFGeometry(0x0)
7aeeaf38 204{
205 // copy constructor
206
207 this->fReconParticles=source.fReconParticles;
208 this->fSDigits=source.fSDigits;
209 this->fTOFGeometry=source.fTOFGeometry;
210
211}
212
213//_____________________________________________________________________________
214AliTOF& AliTOF::operator=(const AliTOF &source)
215{
216 // ass. op.
217
218 this->fReconParticles=source.fReconParticles;
219 this->fSDigits=source.fSDigits;
220 this->fTOFGeometry=source.fTOFGeometry;
221 return *this;
222
223}
224
68861244 225//_____________________________________________________________________________
226void AliTOF::CreateTOFFolders()
227{
228 // create the ALICE TFolder
229 // create the ALICE TTasks
230 // create the ALICE main TFolder
231 // to be done by AliRun
232
233 TFolder * alice = new TFolder();
234 alice->SetNameTitle("FPAlice", "Alice Folder") ;
235 gROOT->GetListOfBrowsables()->Add(alice) ;
236
237 TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ;
238 // make it the owner of the objects that it contains
239 aliceF->SetOwner() ;
240 // geometry folder
241 TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ;
242 TFolder * aliceT = alice->AddFolder("tasks", "Alice tasks Folder") ;
243 // make it the owner of the objects that it contains
244 aliceT->SetOwner() ;
245
246 TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ;
247 aliceT->Add(aliceDi);
248
249 TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
250 aliceT->Add(aliceRe);
251
252 char * tempo = new char[80] ;
253
254 // creates the TOF Digitizer and adds it to alice main (S)Digitizer task
255 sprintf(tempo, "%sDigitizers container",GetName() ) ;
256 fDTask = new TTask(GetName(), tempo);
257 aliceDi->Add(fDTask) ;
258
259 // creates the TOF reconstructioner and adds it to alice main Reconstructioner task
260 sprintf(tempo, "%sReconstructioner container",GetName() ) ;
261 fReTask = new TTask(GetName(), tempo);
262 aliceRe->Add(fReTask) ;
263
3ff0c331 264 delete [] tempo ;
68861244 265
266 // creates the TOF geometry folder
267 geomF->AddFolder("TOF", "Geometry for TOF") ;
268}
269
270//_____________________________________________________________________________
271AliTOF::~AliTOF()
272{
517b7f8f 273 // dtor:
274 // it remove also the alice folder
68861244 275 // and task that TOF creates instead of AliRun
5839f074 276 /* PH Temporarily commented because of problems
68861244 277 TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ;
278 delete alice;
279 alice = 0;
5839f074 280 */
517b7f8f 281 if (fHits)
282 {
283 fHits->Delete ();
284 delete fHits;
285 fHits = 0;
286 }
287 if (fDigits)
288 {
289 fDigits->Delete ();
290 delete fDigits;
291 fDigits = 0;
292 }
293 if (fSDigits)
294 {
88cb7938 295 fSDigits->Delete();
517b7f8f 296 delete fSDigits;
297 fSDigits = 0;
298 }
571dda3d 299
517b7f8f 300 if (fReconParticles)
301 {
302 fReconParticles->Delete ();
303 delete fReconParticles;
304 fReconParticles = 0;
305 }
306
fe4da5cc 307}
308
309//_____________________________________________________________________________
2cef3cb2 310void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits)
fe4da5cc 311{
312 //
313 // Add a TOF hit
68861244 314 // new with placement used
fe4da5cc 315 //
316 TClonesArray &lhits = *fHits;
2cef3cb2 317 new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits);
fe4da5cc 318}
d599d913 319
320//_____________________________________________________________________________
321void AliTOF::AddT0Hit(Int_t track, Int_t *vol, Float_t *hits)
322{
323 //
324 // Add a TOF hit
325 // new with placement used
326 //
327 TClonesArray &lhits = *fHits;
328 new(lhits[fNhits++]) AliTOFhitT0(fIshunt, track, vol, hits);
329}
330
fe4da5cc 331//_____________________________________________________________________________
bf33f8f0 332void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Int_t *digits)
fe4da5cc 333{
334 //
2cef3cb2 335 // Add a TOF digit
68861244 336 // new with placement used
2cef3cb2 337 //
338 TClonesArray &ldigits = *fDigits;
339 new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits);
fe4da5cc 340}
341
d3c7bfac 342//_____________________________________________________________________________
bf33f8f0 343void AliTOF::AddSDigit(Int_t tracknum, Int_t *vol, Int_t *digits)
517b7f8f 344{
345
346//
347// Add a TOF sdigit
348//
349
350 TClonesArray &lSDigits = *fSDigits;
5919c40c 351 new(lSDigits[fNSDigits++]) AliTOFSDigit(tracknum, vol, digits);
517b7f8f 352}
353
354//_____________________________________________________________________________
355void AliTOF::SetTreeAddress ()
356{
357 // Set branch address for the Hits and Digits Tree.
88cb7938 358
359 if (fLoader->TreeH())
360 {
361 if (fHits == 0x0)
362 {
363 if (fTZero) fHits = new TClonesArray("AliTOFhitT0", 1000);
364 else fHits = new TClonesArray("AliTOFhit", 1000);
365 }
366 }
517b7f8f 367 AliDetector::SetTreeAddress ();
368
369 TBranch *branch;
517b7f8f 370
88cb7938 371 if (fLoader->TreeS () )
517b7f8f 372 {
88cb7938 373 branch = fLoader->TreeS ()->GetBranch ("TOF");
374 if (branch) {
375 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit", 1000);
376 branch->SetAddress (&fSDigits);
377 }
517b7f8f 378 }
379
571dda3d 380 if (fLoader->TreeR() )
381 {
382 branch = fLoader->TreeR()->GetBranch("TOF");
383 if (branch)
384 {
385 if (fReconParticles == 0x0) fReconParticles = new TClonesArray("AliTOFcluster", 1000);
386 branch->SetAddress(&fReconParticles);
387 }
388 }
389
390 /*
88cb7938 391 if (fLoader->TreeR() && fReconParticles) //I do not know where this array is created - skowron
517b7f8f 392 {
88cb7938 393 branch = fLoader->TreeR()->GetBranch("TOF");
394 if (branch)
395 {
396 branch->SetAddress(&fReconParticles) ;
397 }
571dda3d 398 }
399 */
517b7f8f 400}
2cef3cb2 401
fe4da5cc 402//_____________________________________________________________________________
403void AliTOF::CreateGeometry()
404{
405 //
3fe3a833 406 // Common geometry code
fe4da5cc 407 //
408 //Begin_Html
409 /*
1439f98e 410 <img src="picts/AliTOFv23.gif">
fe4da5cc 411 */
412 //End_Html
413 //
937fe4a4 414
d3c7bfac 415 Float_t xTof, yTof;
416
dfef1a15 417 if (IsVersion()==8) {
418
419 xTof = 124.5;//fTOFGeometry->StripLength()+2.*(0.3+0.03); // cm, x-dimension of FTOA volume
420 yTof = fTOFGeometry->Rmax()-fTOFGeometry->Rmin(); // cm, y-dimension of FTOA volume
421 Float_t zTof = fTOFGeometry->ZlenA(); // cm, z-dimension of FTOA volume
422
423 // TOF module internal definitions
424 TOFpc(xTof, yTof, zTof);
425
426 } else if (IsVersion()==7) {
d3c7bfac 427
1ac1b685 428 xTof = 124.5;//fTOFGeometry->StripLength()+2.*(0.3+0.03); // cm, x-dimension of FTOA volume
d3c7bfac 429 yTof = fTOFGeometry->Rmax()-fTOFGeometry->Rmin(); // cm, y-dimension of FTOA volume
430 Float_t zTof = fTOFGeometry->ZlenA(); // cm, z-dimension of FTOA volume
431
432 // TOF module internal definitions
433 TOFpc(xTof, yTof, zTof, fTOFGeometry->ZlenB());
3fe3a833 434
d3c7bfac 435 } else {
436
437 Float_t wall = 4.;//cm // frame inbetween TOF modules
438
439 // Sizes of TOF module with its support etc..
440 xTof = 2.*(fTOFGeometry->Rmin()*TMath::Tan(10.*kDegrad)-wall/2.-0.5);
441 yTof = fTOFGeometry->Rmax()-fTOFGeometry->Rmin();
442
443 // TOF module internal definitions
444 TOFpc(xTof, yTof, fTOFGeometry->ZlenC(), fTOFGeometry->ZlenB(), fTOFGeometry->ZlenA(), fTOFGeometry->MaxhZtof());
445 }
3fe3a833 446
fe4da5cc 447}
448
449//_____________________________________________________________________________
ba380e33 450void AliTOF::DrawModule() const
fe4da5cc 451{
452 //
453 // Draw a shaded view of the common part of the TOF geometry
fe4da5cc 454 //
455
d076c8d5 456 AliInfo(" Drawing of AliTOF");
fe4da5cc 457 // Set everything unseen
cfce8870 458 gMC->Gsatt("*", "seen", -1);
fe4da5cc 459 //
460 // Set ALIC mother transparent
cfce8870 461 gMC->Gsatt("ALIC","SEEN",0);
fe4da5cc 462 //
463 // Set the volumes visible
2cef3cb2 464 gMC->Gsatt("FTOA","SEEN",1);
465 gMC->Gsatt("FTOB","SEEN",1);
466 gMC->Gsatt("FTOC","SEEN",1);
467 gMC->Gsatt("FLTA","SEEN",1);
468 gMC->Gsatt("FLTB","SEEN",1);
469 gMC->Gsatt("FLTC","SEEN",1);
470 gMC->Gsatt("FSTR","SEEN",1);
cfce8870 471 //
472 gMC->Gdopt("hide", "on");
473 gMC->Gdopt("shad", "on");
474 gMC->Gsatt("*", "fill", 7);
475 gMC->SetClipBox(".");
476 gMC->SetClipBox("*", 0, 1000, -1000, 1000, -1000, 1000);
477 gMC->DefaultRange();
478 gMC->Gdraw("alic", 40, 30, 0, 12, 9.5, .02, .02);
479 gMC->Gdhead(1111, "Time Of Flight");
480 gMC->Gdman(18, 4, "MAN");
481 gMC->Gdopt("hide","off");
fe4da5cc 482}
483
fe4da5cc 484//_____________________________________________________________________________
0e46b9ae 485Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t )
fe4da5cc 486{
487 //
488 // Returns distance from mouse pointer to detector, default version
489 //
490 return 9999;
491}
517b7f8f 492
493//___________________________________________
494void AliTOF::ResetHits ()
495{
496 // Reset number of clusters and the cluster array for this detector
497 AliDetector::ResetHits ();
498}
499
500//____________________________________________
501void AliTOF::ResetDigits ()
502{
503 //
504 // Reset number of digits and the digits array for this detector
505 AliDetector::ResetDigits ();
506 //
507}
d61f73d9 508//____________________________________________
509void AliTOF::ResetSDigits ()
510{
511 //
512 // Reset number of sdigits and the sdigits array for this detector
513 fNSDigits = 0;
e615b5b5 514 //fSDigits = 0x0;
d61f73d9 515 //
516}
fe4da5cc 517//_____________________________________________________________________________
518void AliTOF::Init()
519{
520 //
521 // Initialise TOF detector after it has been built
522 //
fe4da5cc 523 // Set id of TOF sensitive volume
937fe4a4 524 if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD");
d3c7bfac 525
526 /*
d076c8d5 527 // Save the geometry
528 TDirectory* saveDir = gDirectory;
529 gAlice->GetRunLoader()->CdGAFile();
530 fTOFGeometry->Write("TOFGeometry");
531 saveDir->cd();
d3c7bfac 532 */
fe4da5cc 533}
534
2cef3cb2 535//____________________________________________________________________________
88cb7938 536void AliTOF::MakeBranch(Option_t* option)
2cef3cb2 537{
b94fa26c 538 //
539 // Initializes the Branches of the TOF inside the
540 // trees written for each event.
517b7f8f 541 // AliDetector::MakeBranch initializes just the
68861244 542 // Branch inside TreeH. Here we add the branches in
517b7f8f 543 // TreeD, TreeS and TreeR.
b94fa26c 544 //
88cb7938 545 const char *oH = strstr(option,"H");
546 if (fLoader->TreeH() && oH)
547 {
548 if (fHits == 0x0)
549 {
550 if (fTZero) fHits = new TClonesArray("AliTOFhitT0", 1000);
551 else fHits = new TClonesArray("AliTOFhit", 1000);
552 }
553 }
554
555 AliDetector::MakeBranch(option);
2cef3cb2 556
557 Int_t buffersize = 4000;
558 Char_t branchname[10];
559 sprintf(branchname,"%s",GetName());
2ab0c725 560
68861244 561 const char *oD = strstr(option,"D");
562 const char *oS = strstr(option,"S");
517b7f8f 563 const char *oR = strstr(option,"R");
68861244 564
88cb7938 565 if (fLoader->TreeD() && oD){
566 if (fDigits == 0x0) fDigits = new TClonesArray("AliTOFdigit", 1000);
567 MakeBranchInTree(fLoader->TreeD(), branchname, &fDigits,buffersize, 0) ;
2cef3cb2 568 }
68861244 569
88cb7938 570 if (fLoader->TreeS() && oS){
571 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit", 1000);
572 MakeBranchInTree(fLoader->TreeS(), branchname, &fSDigits,buffersize, 0) ;
68861244 573 }
574
571dda3d 575 if (fLoader->TreeR() && oR){
576 if (fReconParticles == 0x0) fReconParticles = new TClonesArray("AliTOFcluster", 1000);
577 MakeBranchInTree(fLoader->TreeR(), branchname, &fReconParticles,buffersize, 0) ;
578 }
579
580 /*
88cb7938 581 if (fReconParticles && fLoader->TreeR() && oR){
582 MakeBranchInTree(fLoader->TreeR(), branchname, &fReconParticles,buffersize, 0) ;
517b7f8f 583 }
571dda3d 584 */
68861244 585}
586
587//____________________________________________________________________________
588void AliTOF::Makehits(Bool_t hits)
589{
590// default argument used, see AliTOF.h
591// Enable/Disable the writing of the TOF-hits branch
592// on TreeH
d3c7bfac 593// by default : enabled for TOFv1, v2, v3, v4, v5
68861244 594// disabled for TOFv0
595//
596 if (hits && (IsVersion()!=0))
597 fIdSens = gMC->VolId("FPAD");
598 else
d076c8d5 599 AliInfo("Option for writing the TOF-hits branch on TreeH: disabled");
2cef3cb2 600}
601
602//____________________________________________________________________________
603void AliTOF::FinishEvent()
604{
68861244 605// do nothing
2cef3cb2 606}
607
d3c7bfac 608//____________________________________________________________________________
517b7f8f 609void AliTOF::Hits2SDigits()
610{
611//
612// Use the TOF SDigitizer to make TOF SDigits
613//
d61f73d9 614
0e46b9ae 615// AliInfo("Start...");
68861244 616
be385a87 617 AliRunLoader * rl = fLoader->GetRunLoader();
618 AliTOFSDigitizer sd((rl->GetFileName()).Data());
d076c8d5 619 ToAliDebug(1, sd.Print(""));
68861244 620
be385a87 621 sd.Exec("") ;
d61f73d9 622
623}
624
d3c7bfac 625//____________________________________________________________________________
d61f73d9 626void AliTOF::Hits2SDigits(Int_t evNumber1, Int_t evNumber2)
627{
628//
629// Use the TOF SDigitizer to make TOF SDigits
630//
631
632 if ((evNumber2-evNumber1)==1)
96f8ea5a 633 AliDebug(1, Form("I am making sdigits for the %dth event", evNumber1));
634 if ((evNumber2-evNumber1)>1)
635 AliDebug(1, Form("I am making sdigits for the events from the %dth to the %dth", evNumber1, evNumber2-1));
d61f73d9 636
be385a87 637 AliRunLoader * rl = fLoader->GetRunLoader();
638 AliTOFSDigitizer sd((rl->GetFileName()).Data(),evNumber1,evNumber2) ;
d076c8d5 639 ToAliDebug(1, sd.Print(""));
68861244 640
be385a87 641 sd.Exec("") ;
d61f73d9 642
2cef3cb2 643}
d61f73d9 644
2cef3cb2 645//___________________________________________________________________________
c92eb8ad 646AliDigitizer* AliTOF::CreateDigitizer(AliRunDigitizer* manager) const
85a5290f 647{
648 return new AliTOFDigitizer(manager);
649}
650
651//___________________________________________________________________________
bf33f8f0 652Bool_t AliTOF::CheckOverlap(Int_t* vol, Int_t* digit,Int_t Track)
b94fa26c 653{
2cef3cb2 654//
655// Checks if 2 or more hits belong to the same pad.
656// In this case the data assigned to the digit object
657// are the ones of the first hit in order of Time.
517b7f8f 658// 2 hits from the same track on the same pad are collected.
659// Called only by Hits2SDigits.
660// This procedure has to be optimized in the next TOF release.
2cef3cb2 661//
b94fa26c 662
d3c7bfac 663 Bool_t overlap = kFALSE;
664 Int_t vol2[5];
665
666 for (Int_t ndig=0; ndig<fSDigits->GetEntries(); ndig++){
667 AliTOFdigit* currentDigit = (AliTOFdigit*)(fSDigits->UncheckedAt(ndig));
668 currentDigit->GetLocation(vol2);
669 Bool_t idem= kTRUE;
670 // check on digit volume
671 for (Int_t i=0;i<=4;i++){
672 if (!idem) break;
673 if (vol[i]!=vol2[i]) idem=kFALSE;}
674
675 if (idem){ // same pad fired
bf33f8f0 676 Int_t tdc2 = digit[0];
677 Int_t tdc1 = currentDigit->GetTdc();
d3c7bfac 678
679 // we separate two digits on the same pad if
680 // they are separated in time by at least 25 ns
681 // remember that tdc time is given in ps
682
683 if (TMath::Abs(tdc1-tdc2)<25000){
684 // in case of overlap we take the earliest
685 if (tdc1>tdc2){
686 currentDigit->SetTdc(tdc2);
687 currentDigit->SetAdc(digit[1]);
688 }
689 else {
690 currentDigit->SetTdc(tdc1);
691 currentDigit->SetAdc(digit[1]);
692 }
693 currentDigit->AddTrack(Track); // add track number in the track array
694 overlap = kTRUE;
695 return overlap;
696 } else
bf33f8f0 697 overlap= kFALSE;
517b7f8f 698
d3c7bfac 699 } // close if (idem) -> two digits on the same TOF pad
517b7f8f 700
d3c7bfac 701 } // end loop on existing sdigits
517b7f8f 702
d3c7bfac 703 return overlap;
2cef3cb2 704}
2cef3cb2 705//____________________________________________________________________________
7e6dce66 706void AliTOF::Digits2Raw()
b94fa26c 707{
2cef3cb2 708//
7e6dce66 709// Starting from the TOF digits, writes the Raw Data objects
2cef3cb2 710//
711
515faf5d 712 TStopwatch stopwatch;
713 stopwatch.Start();
714
7e6dce66 715 fLoader->LoadDigits();
2cef3cb2 716
7e6dce66 717 TTree* digits = fLoader->TreeD();
718 if (!digits) {
d076c8d5 719 AliError("no digits tree");
7e6dce66 720 return;
721 }
2cef3cb2 722
80ecd4d6 723 /*
d3c7bfac 724 fRunLoader->CdGAFile();
725 TFile *in=(TFile*)gFile;
726 in->cd();
727 AliTOFGeometry *geometry = (AliTOFGeometry*)in->Get("TOFgeometry");
80ecd4d6 728 */
729 AliTOFDDLRawData rawWriter;
d3c7bfac 730 //AliTOFDDLRawData rawWriter;
5b8979d4 731 rawWriter.SetVerbose(0);
515faf5d 732 //rawWriter.SetFakeOrphaneProduction(kTRUE);
733 //rawWriter.SetPackedAcquisitionMode(kFALSE);
734 if (rawWriter.GetPackedAcquisitionMode()) {
735 if(rawWriter.GetMatchingWindow()>8192)
dfef1a15 736 AliWarning(Form("You are running in packing mode and the matching window is %.2f ns, i.e. greater than 199.8848 ns",
f45f1432 737 rawWriter.GetMatchingWindow()*AliTOFGeometry::TdcBinWidth()*1.e-03));
515faf5d 738 }
2cef3cb2 739
ba795372 740 AliDebug(1,"Formatting raw data for TOF");
7e6dce66 741 digits->GetEvent(0);
742 rawWriter.RawDataTOF(digits->GetBranch("TOF"));
2cef3cb2 743
7e6dce66 744 fLoader->UnloadDigits();
745
515faf5d 746 AliDebug(1, Form("Execution time to write TOF raw data : R:%.2fs C:%.2fs",
747 stopwatch.RealTime(),stopwatch.CpuTime()));
748
7e6dce66 749}
d3c7bfac 750
751//____________________________________________________________________________
55991c8b 752void AliTOF::RecreateSDigitsArray() {
753//
754// delete TClonesArray fSDigits and create it again
755// needed for backward compatability with PPR test production
756//
858b6b16 757 fSDigits->Clear();
55991c8b 758}
d3c7bfac 759//____________________________________________________________________________
55991c8b 760void AliTOF::CreateSDigitsArray() {
761//
762// create TClonesArray fSDigits
763// needed for backward compatability with PPR test production
764//
765 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
766}