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