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