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