]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TOF/AliTOF.cxx
TOF raw data format: updated version
[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
06e24a91 160//____________________________________________________________________________
d0eb8f39 161void AliTOF::SetTOFSectors(Int_t *sectors)
162{
163 // Setter for partial/full TOF configuration
164
06e24a91 165 for(Int_t isec=0;isec<18;isec++){
166 fTOFSectors[isec]=sectors[isec];
167 }
168}
169//____________________________________________________________________________
d0eb8f39 170void AliTOF::GetTOFSectors(Int_t *sectors) const
171{
172 // Getter for partial/full TOF configuration
06e24a91 173
174 for(Int_t isec=0;isec<18;isec++){
175 sectors[isec]=fTOFSectors[isec];
176 }
177}
7aeeaf38 178//_____________________________________________________________________________
179AliTOF::AliTOF(const AliTOF &source)
180 :AliDetector()
181{
182 // copy constructor
183
184 this->fReconParticles=source.fReconParticles;
185 this->fSDigits=source.fSDigits;
186 this->fTOFGeometry=source.fTOFGeometry;
187
188}
189
190//_____________________________________________________________________________
191AliTOF& AliTOF::operator=(const AliTOF &source)
192{
193 // ass. op.
194
195 this->fReconParticles=source.fReconParticles;
196 this->fSDigits=source.fSDigits;
197 this->fTOFGeometry=source.fTOFGeometry;
198 return *this;
199
200}
201
68861244 202//_____________________________________________________________________________
203void AliTOF::CreateTOFFolders()
204{
205 // create the ALICE TFolder
206 // create the ALICE TTasks
207 // create the ALICE main TFolder
208 // to be done by AliRun
209
210 TFolder * alice = new TFolder();
211 alice->SetNameTitle("FPAlice", "Alice Folder") ;
212 gROOT->GetListOfBrowsables()->Add(alice) ;
213
214 TFolder * aliceF = alice->AddFolder("folders", "Alice memory Folder") ;
215 // make it the owner of the objects that it contains
216 aliceF->SetOwner() ;
217 // geometry folder
218 TFolder * geomF = aliceF->AddFolder("Geometry", "Geometry objects") ;
219 TFolder * aliceT = alice->AddFolder("tasks", "Alice tasks Folder") ;
220 // make it the owner of the objects that it contains
221 aliceT->SetOwner() ;
222
223 TTask * aliceDi = new TTask("(S)Digitizer", "Alice SDigitizer & Digitizer") ;
224 aliceT->Add(aliceDi);
225
226 TTask * aliceRe = new TTask("Reconstructioner", "Alice Reconstructioner") ;
227 aliceT->Add(aliceRe);
228
229 char * tempo = new char[80] ;
230
231 // creates the TOF Digitizer and adds it to alice main (S)Digitizer task
232 sprintf(tempo, "%sDigitizers container",GetName() ) ;
233 fDTask = new TTask(GetName(), tempo);
234 aliceDi->Add(fDTask) ;
235
236 // creates the TOF reconstructioner and adds it to alice main Reconstructioner task
237 sprintf(tempo, "%sReconstructioner container",GetName() ) ;
238 fReTask = new TTask(GetName(), tempo);
239 aliceRe->Add(fReTask) ;
240
3ff0c331 241 delete [] tempo ;
68861244 242
243 // creates the TOF geometry folder
244 geomF->AddFolder("TOF", "Geometry for TOF") ;
245}
246
247//_____________________________________________________________________________
248AliTOF::~AliTOF()
249{
517b7f8f 250 // dtor:
251 // it remove also the alice folder
68861244 252 // and task that TOF creates instead of AliRun
5839f074 253 /* PH Temporarily commented because of problems
68861244 254 TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ;
255 delete alice;
256 alice = 0;
5839f074 257 */
517b7f8f 258 if (fHits)
259 {
260 fHits->Delete ();
261 delete fHits;
262 fHits = 0;
263 }
264 if (fDigits)
265 {
266 fDigits->Delete ();
267 delete fDigits;
268 fDigits = 0;
269 }
270 if (fSDigits)
271 {
88cb7938 272 fSDigits->Delete();
517b7f8f 273 delete fSDigits;
274 fSDigits = 0;
275 }
571dda3d 276
517b7f8f 277 if (fReconParticles)
278 {
279 fReconParticles->Delete ();
280 delete fReconParticles;
281 fReconParticles = 0;
282 }
283
fe4da5cc 284}
285
286//_____________________________________________________________________________
2cef3cb2 287void AliTOF::AddHit(Int_t track, Int_t *vol, Float_t *hits)
fe4da5cc 288{
289 //
290 // Add a TOF hit
68861244 291 // new with placement used
fe4da5cc 292 //
293 TClonesArray &lhits = *fHits;
2cef3cb2 294 new(lhits[fNhits++]) AliTOFhit(fIshunt, track, vol, hits);
fe4da5cc 295}
d599d913 296
297//_____________________________________________________________________________
298void AliTOF::AddT0Hit(Int_t track, Int_t *vol, Float_t *hits)
299{
300 //
301 // Add a TOF hit
302 // new with placement used
303 //
304 TClonesArray &lhits = *fHits;
305 new(lhits[fNhits++]) AliTOFhitT0(fIshunt, track, vol, hits);
306}
307
fe4da5cc 308//_____________________________________________________________________________
2cef3cb2 309void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Float_t *digits)
fe4da5cc 310{
311 //
2cef3cb2 312 // Add a TOF digit
68861244 313 // new with placement used
2cef3cb2 314 //
315 TClonesArray &ldigits = *fDigits;
316 new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits);
fe4da5cc 317}
318
d3c7bfac 319//_____________________________________________________________________________
5919c40c 320void AliTOF::AddSDigit(Int_t tracknum, Int_t *vol, Float_t *digits)
517b7f8f 321{
322
323//
324// Add a TOF sdigit
325//
326
327 TClonesArray &lSDigits = *fSDigits;
5919c40c 328 new(lSDigits[fNSDigits++]) AliTOFSDigit(tracknum, vol, digits);
517b7f8f 329}
330
331//_____________________________________________________________________________
332void AliTOF::SetTreeAddress ()
333{
334 // Set branch address for the Hits and Digits Tree.
88cb7938 335
336 if (fLoader->TreeH())
337 {
338 if (fHits == 0x0)
339 {
340 if (fTZero) fHits = new TClonesArray("AliTOFhitT0", 1000);
341 else fHits = new TClonesArray("AliTOFhit", 1000);
342 }
343 }
517b7f8f 344 AliDetector::SetTreeAddress ();
345
346 TBranch *branch;
517b7f8f 347
88cb7938 348 if (fLoader->TreeS () )
517b7f8f 349 {
88cb7938 350 branch = fLoader->TreeS ()->GetBranch ("TOF");
351 if (branch) {
352 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit", 1000);
353 branch->SetAddress (&fSDigits);
354 }
517b7f8f 355 }
356
571dda3d 357 if (fLoader->TreeR() )
358 {
359 branch = fLoader->TreeR()->GetBranch("TOF");
360 if (branch)
361 {
362 if (fReconParticles == 0x0) fReconParticles = new TClonesArray("AliTOFcluster", 1000);
363 branch->SetAddress(&fReconParticles);
364 }
365 }
366
367 /*
88cb7938 368 if (fLoader->TreeR() && fReconParticles) //I do not know where this array is created - skowron
517b7f8f 369 {
88cb7938 370 branch = fLoader->TreeR()->GetBranch("TOF");
371 if (branch)
372 {
373 branch->SetAddress(&fReconParticles) ;
374 }
571dda3d 375 }
376 */
517b7f8f 377}
2cef3cb2 378
fe4da5cc 379//_____________________________________________________________________________
380void AliTOF::CreateGeometry()
381{
382 //
3fe3a833 383 // Common geometry code
fe4da5cc 384 //
385 //Begin_Html
386 /*
1439f98e 387 <img src="picts/AliTOFv23.gif">
fe4da5cc 388 */
389 //End_Html
390 //
937fe4a4 391
d3c7bfac 392 Float_t xTof, yTof;
393
394 if (IsVersion()==7) {
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
fe4da5cc 452//_____________________________________________________________________________
0e46b9ae 453Int_t AliTOF::DistancetoPrimitive(Int_t , Int_t )
fe4da5cc 454{
455 //
456 // Returns distance from mouse pointer to detector, default version
457 //
458 return 9999;
459}
517b7f8f 460
461//___________________________________________
462void AliTOF::ResetHits ()
463{
464 // Reset number of clusters and the cluster array for this detector
465 AliDetector::ResetHits ();
466}
467
468//____________________________________________
469void AliTOF::ResetDigits ()
470{
471 //
472 // Reset number of digits and the digits array for this detector
473 AliDetector::ResetDigits ();
474 //
475}
d61f73d9 476//____________________________________________
477void AliTOF::ResetSDigits ()
478{
479 //
480 // Reset number of sdigits and the sdigits array for this detector
481 fNSDigits = 0;
e615b5b5 482 //fSDigits = 0x0;
d61f73d9 483 //
484}
fe4da5cc 485//_____________________________________________________________________________
486void AliTOF::Init()
487{
488 //
489 // Initialise TOF detector after it has been built
490 //
fe4da5cc 491 // Set id of TOF sensitive volume
937fe4a4 492 if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD");
d3c7bfac 493
494 /*
d076c8d5 495 // Save the geometry
496 TDirectory* saveDir = gDirectory;
497 gAlice->GetRunLoader()->CdGAFile();
498 fTOFGeometry->Write("TOFGeometry");
499 saveDir->cd();
d3c7bfac 500 */
fe4da5cc 501}
502
2cef3cb2 503//____________________________________________________________________________
88cb7938 504void AliTOF::MakeBranch(Option_t* option)
2cef3cb2 505{
b94fa26c 506 //
507 // Initializes the Branches of the TOF inside the
508 // trees written for each event.
517b7f8f 509 // AliDetector::MakeBranch initializes just the
68861244 510 // Branch inside TreeH. Here we add the branches in
517b7f8f 511 // TreeD, TreeS and TreeR.
b94fa26c 512 //
88cb7938 513 const char *oH = strstr(option,"H");
514 if (fLoader->TreeH() && oH)
515 {
516 if (fHits == 0x0)
517 {
518 if (fTZero) fHits = new TClonesArray("AliTOFhitT0", 1000);
519 else fHits = new TClonesArray("AliTOFhit", 1000);
520 }
521 }
522
523 AliDetector::MakeBranch(option);
2cef3cb2 524
525 Int_t buffersize = 4000;
526 Char_t branchname[10];
527 sprintf(branchname,"%s",GetName());
2ab0c725 528
68861244 529 const char *oD = strstr(option,"D");
530 const char *oS = strstr(option,"S");
517b7f8f 531 const char *oR = strstr(option,"R");
68861244 532
88cb7938 533 if (fLoader->TreeD() && oD){
534 if (fDigits == 0x0) fDigits = new TClonesArray("AliTOFdigit", 1000);
535 MakeBranchInTree(fLoader->TreeD(), branchname, &fDigits,buffersize, 0) ;
2cef3cb2 536 }
68861244 537
88cb7938 538 if (fLoader->TreeS() && oS){
539 if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit", 1000);
540 MakeBranchInTree(fLoader->TreeS(), branchname, &fSDigits,buffersize, 0) ;
68861244 541 }
542
571dda3d 543 if (fLoader->TreeR() && oR){
544 if (fReconParticles == 0x0) fReconParticles = new TClonesArray("AliTOFcluster", 1000);
545 MakeBranchInTree(fLoader->TreeR(), branchname, &fReconParticles,buffersize, 0) ;
546 }
547
548 /*
88cb7938 549 if (fReconParticles && fLoader->TreeR() && oR){
550 MakeBranchInTree(fLoader->TreeR(), branchname, &fReconParticles,buffersize, 0) ;
517b7f8f 551 }
571dda3d 552 */
68861244 553}
554
555//____________________________________________________________________________
556void AliTOF::Makehits(Bool_t hits)
557{
558// default argument used, see AliTOF.h
559// Enable/Disable the writing of the TOF-hits branch
560// on TreeH
d3c7bfac 561// by default : enabled for TOFv1, v2, v3, v4, v5
68861244 562// disabled for TOFv0
563//
564 if (hits && (IsVersion()!=0))
565 fIdSens = gMC->VolId("FPAD");
566 else
d076c8d5 567 AliInfo("Option for writing the TOF-hits branch on TreeH: disabled");
2cef3cb2 568}
569
570//____________________________________________________________________________
571void AliTOF::FinishEvent()
572{
68861244 573// do nothing
2cef3cb2 574}
575
d3c7bfac 576//____________________________________________________________________________
517b7f8f 577void AliTOF::Hits2SDigits()
578{
579//
580// Use the TOF SDigitizer to make TOF SDigits
581//
d61f73d9 582
0e46b9ae 583// AliInfo("Start...");
68861244 584
be385a87 585 AliRunLoader * rl = fLoader->GetRunLoader();
586 AliTOFSDigitizer sd((rl->GetFileName()).Data());
d076c8d5 587 ToAliDebug(1, sd.Print(""));
68861244 588
be385a87 589 sd.Exec("") ;
d61f73d9 590
591}
592
d3c7bfac 593//____________________________________________________________________________
d61f73d9 594void AliTOF::Hits2SDigits(Int_t evNumber1, Int_t evNumber2)
595{
596//
597// Use the TOF SDigitizer to make TOF SDigits
598//
599
600 if ((evNumber2-evNumber1)==1)
d076c8d5 601 AliDebug(1, Form("I am making sdigits for the %dth event", evNumber1))
d61f73d9 602 else if ((evNumber2-evNumber1)>1)
d076c8d5 603 AliDebug(1, Form("I am making sdigits for the events from the "
604 "%dth to the %dth", evNumber1, evNumber2-1));
d61f73d9 605
be385a87 606 AliRunLoader * rl = fLoader->GetRunLoader();
607 AliTOFSDigitizer sd((rl->GetFileName()).Data(),evNumber1,evNumber2) ;
d076c8d5 608 ToAliDebug(1, sd.Print(""));
68861244 609
be385a87 610 sd.Exec("") ;
d61f73d9 611
2cef3cb2 612}
d61f73d9 613
2cef3cb2 614//___________________________________________________________________________
c92eb8ad 615AliDigitizer* AliTOF::CreateDigitizer(AliRunDigitizer* manager) const
85a5290f 616{
617 return new AliTOFDigitizer(manager);
618}
619
620//___________________________________________________________________________
2cef3cb2 621Bool_t AliTOF::CheckOverlap(Int_t* vol, Float_t* digit,Int_t Track)
b94fa26c 622{
2cef3cb2 623//
624// Checks if 2 or more hits belong to the same pad.
625// In this case the data assigned to the digit object
626// are the ones of the first hit in order of Time.
517b7f8f 627// 2 hits from the same track on the same pad are collected.
628// Called only by Hits2SDigits.
629// This procedure has to be optimized in the next TOF release.
2cef3cb2 630//
b94fa26c 631
d3c7bfac 632 Bool_t overlap = kFALSE;
633 Int_t vol2[5];
634
635 for (Int_t ndig=0; ndig<fSDigits->GetEntries(); ndig++){
636 AliTOFdigit* currentDigit = (AliTOFdigit*)(fSDigits->UncheckedAt(ndig));
637 currentDigit->GetLocation(vol2);
638 Bool_t idem= kTRUE;
639 // check on digit volume
640 for (Int_t i=0;i<=4;i++){
641 if (!idem) break;
642 if (vol[i]!=vol2[i]) idem=kFALSE;}
643
644 if (idem){ // same pad fired
645 Float_t tdc2 = digit[0];
646 Float_t tdc1 = currentDigit->GetTdc();
647
648 // we separate two digits on the same pad if
649 // they are separated in time by at least 25 ns
650 // remember that tdc time is given in ps
651
652 if (TMath::Abs(tdc1-tdc2)<25000){
653 // in case of overlap we take the earliest
654 if (tdc1>tdc2){
655 currentDigit->SetTdc(tdc2);
656 currentDigit->SetAdc(digit[1]);
657 }
658 else {
659 currentDigit->SetTdc(tdc1);
660 currentDigit->SetAdc(digit[1]);
661 }
662 currentDigit->AddTrack(Track); // add track number in the track array
663 overlap = kTRUE;
664 return overlap;
665 } else
f3de6e9e 666 overlap= kFALSE;
517b7f8f 667
d3c7bfac 668 } // close if (idem) -> two digits on the same TOF pad
517b7f8f 669
d3c7bfac 670 } // end loop on existing sdigits
517b7f8f 671
d3c7bfac 672 return overlap;
2cef3cb2 673}
2cef3cb2 674//____________________________________________________________________________
7e6dce66 675void AliTOF::Digits2Raw()
b94fa26c 676{
2cef3cb2 677//
7e6dce66 678// Starting from the TOF digits, writes the Raw Data objects
2cef3cb2 679//
680
7e6dce66 681 fLoader->LoadDigits();
2cef3cb2 682
7e6dce66 683 TTree* digits = fLoader->TreeD();
684 if (!digits) {
d076c8d5 685 AliError("no digits tree");
7e6dce66 686 return;
687 }
2cef3cb2 688
d3c7bfac 689 //AliRunLoader *rl = AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"read");
690 fRunLoader->CdGAFile();
691 TFile *in=(TFile*)gFile;
692 in->cd();
693 AliTOFGeometry *geometry = (AliTOFGeometry*)in->Get("TOFgeometry");
694
695 AliTOFDDLRawData rawWriter(geometry);
696 //AliTOFDDLRawData rawWriter;
7e6dce66 697 rawWriter.SetVerbose(0);
2cef3cb2 698
d076c8d5 699 AliInfo("Formatting raw data for TOF");
7e6dce66 700 digits->GetEvent(0);
701 rawWriter.RawDataTOF(digits->GetBranch("TOF"));
2cef3cb2 702
7e6dce66 703 fLoader->UnloadDigits();
704
705}
d3c7bfac 706
707//____________________________________________________________________________
55991c8b 708void AliTOF::RecreateSDigitsArray() {
709//
710// delete TClonesArray fSDigits and create it again
711// needed for backward compatability with PPR test production
712//
713 delete fSDigits;
714 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
715}
d3c7bfac 716//____________________________________________________________________________
55991c8b 717void AliTOF::CreateSDigitsArray() {
718//
719// create TClonesArray fSDigits
720// needed for backward compatability with PPR test production
721//
722 fSDigits = new TClonesArray("AliTOFSDigit", 1000);
723}