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