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