]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOF.cxx
bugfix: corrected calculation of slice and partition from track point Id
[u/mrichter/AliRoot.git] / TOF / AliTOF.cxx
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 /* $Id$ */
16
17 ///////////////////////////////////////////////////////////////////////////////
18 //                                                                           //
19 //  Time Of Flight                                                           //
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                                         //
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 ///////////////////////////////////////////////////////////////////////////////
35 // Begin_Html
36 /*
37 <img src="picts/AliTOFClass.gif">
38 */
39 //End_Html
40
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>
48 #include <TStopwatch.h>
49
50 #include "AliConst.h"
51 #include "AliLoader.h"
52 #include "AliLog.h"
53 #include "AliMC.h"
54 #include "AliRun.h"
55 #include "AliDAQ.h"
56 #include "AliRawReader.h"
57
58 //#include "AliTOFDDLRawData.h"
59 #include "AliTOFDigitizer.h"
60 #include "AliTOFdigit.h"
61 #include "AliTOFhitT0.h"
62 #include "AliTOFhit.h"
63 #include "AliTOFGeometry.h"
64 #include "AliTOFSDigitizer.h"
65 #include "AliTOFSDigit.h"
66 #include "AliTOF.h"
67 #include "AliTOFrawData.h"
68 #include "AliTOFRawStream.h"
69
70 class AliTOFcluster;
71
72 extern TROOT *gROOT;
73 extern TVirtualMC *gMC;
74
75 extern AliRun *gAlice;
76
77 ClassImp(AliTOF)
78
79 //_____________________________________________________________________________
80 AliTOF::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),
89   fTOFHoles(kTRUE),
90   fTOFGeometry(0x0),
91   fTOFRawWriter(AliTOFDDLRawData())
92 {
93   //
94   // Default constructor
95   //
96
97   //by default all sectors switched on
98   for (Int_t ii=0; ii<18; ii++) fTOFSectors[ii]=0;
99
100   fDigits = 0;
101   fIshunt   = 0;
102   fName = "TOF";
103
104 }
105  
106 //_____________________________________________________________________________
107 AliTOF::AliTOF(const char *name, const char *title, Option_t *option)
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),
118   fTOFHoles(kTRUE),
119   fTOFGeometry(0x0),
120   fTOFRawWriter(AliTOFDDLRawData())
121 {
122   //
123   // AliTOF standard constructor
124   // 
125   // Here are fixed some important parameters
126   //
127
128   // Initialization of hits, sdigits and digits array
129   // added option for time zero analysis
130   //skowron
131   fTOFGeometry = new AliTOFGeometry();
132
133   //by default all sectors switched on
134   for (Int_t ii=0; ii<18; ii++) fTOFSectors[ii]=0;
135
136   if (strstr(option,"tzero")){
137     fHits   = new TClonesArray("AliTOFhitT0",  1000);
138     fTZero = kTRUE;
139     //    AliWarning("tzero option requires AliTOFv4T0/AliTOFv5T0 as TOF version (check Your Config.C)");
140   }else{
141     fHits   = new TClonesArray("AliTOFhit",  1000);
142     fTZero = kFALSE;
143   }
144   if (gAlice==0) {
145      AliFatal("gAlice==0 !");
146   }
147
148   AliMC *mcApplication = (AliMC*)gAlice->GetMCApp();
149
150   if (mcApplication->GetHitLists())
151      mcApplication->AddHitList(fHits);
152   else AliError("gAlice->GetHitLists()==0");
153
154   fIshunt  = 0;
155   fSDigits = new TClonesArray("AliTOFSDigit", 1000);
156   fDigits  = new TClonesArray("AliTOFdigit",  1000);
157
158   //
159   // Digitization parameters
160   //
161   // (Transfer Functions to be inserted here)
162   //
163   //PH  SetMarkerColor(7);
164   //PH  SetMarkerStyle(2);
165   //PH  SetMarkerSize(0.4);
166
167 // Strip Parameters
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
175 }
176
177 //____________________________________________________________________________
178 void AliTOF::SetTOFSectors(Int_t * const sectors)
179 {
180   // Setter for partial/full TOF configuration
181
182   for(Int_t isec=0;isec<18;isec++){
183     fTOFSectors[isec]=sectors[isec];
184   }
185 }
186 //____________________________________________________________________________
187 void AliTOF::GetTOFSectors(Int_t *sectors) const
188 {
189   // Getter for partial/full TOF configuration
190
191   for(Int_t isec=0;isec<18;isec++){
192     sectors[isec]=fTOFSectors[isec];
193   }
194 }
195
196 //_____________________________________________________________________________
197 void 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
223   const Int_t kSize=80;
224   //char * tempo = new char[80] ;
225   char tempo[kSize];
226
227   // creates the TOF Digitizer and adds it to alice main (S)Digitizer task
228   snprintf(tempo,kSize, "%sDigitizers container",GetName() ) ;
229   fDTask = new TTask(GetName(), tempo);
230   aliceDi->Add(fDTask) ;
231
232   // creates the TOF reconstructioner and adds it to alice main Reconstructioner task
233   snprintf(tempo,kSize, "%sReconstructioner container",GetName() ) ;
234   fReTask = new TTask(GetName(), tempo);
235   aliceRe->Add(fReTask) ;
236
237   //delete [] tempo ;
238  
239   // creates the TOF geometry  folder
240   geomF->AddFolder("TOF", "Geometry for TOF") ;
241 }
242
243 //_____________________________________________________________________________
244 AliTOF::~AliTOF()
245 {
246   // dtor:
247   // it remove also the alice folder 
248   // and task that TOF creates instead of AliRun
249   /* PH Temporarily commented because of problems
250   TFolder * alice = (TFolder*)gROOT->GetListOfBrowsables()->FindObject("FPAlice") ;
251   delete alice;
252   alice = 0;
253   */
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     {
268       fSDigits->Delete();
269       delete fSDigits;
270       fSDigits = 0;
271     }
272
273   if (fReconParticles)
274     {
275       fReconParticles->Delete ();
276       delete fReconParticles;
277       fReconParticles = 0;
278     }
279
280 }
281
282 //_____________________________________________________________________________
283 void AliTOF::AddHit(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++]) AliTOFhit(fIshunt, track, vol, hits);
291 }
292
293 //_____________________________________________________________________________
294 void 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
304 //_____________________________________________________________________________
305 void AliTOF::AddDigit(Int_t *tracks, Int_t *vol, Int_t *digits)
306 {
307   //
308   // Add a TOF digit
309   // new with placement used
310   //
311   TClonesArray &ldigits = *fDigits;
312   new (ldigits[fNdigits++]) AliTOFdigit(tracks, vol, digits);
313 }
314
315 //_____________________________________________________________________________
316 void AliTOF::AddSDigit(Int_t tracknum, Int_t *vol, Int_t *digits)
317 {
318      
319 //
320 // Add a TOF sdigit
321 //
322         
323   TClonesArray &lSDigits = *fSDigits;   
324   new(lSDigits[fNSDigits++]) AliTOFSDigit(tracknum, vol, digits);
325 }
326
327 //_____________________________________________________________________________
328 void AliTOF::SetTreeAddress ()
329 {
330   // Set branch address for the Hits and Digits Tree.
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    }
340   AliDetector::SetTreeAddress ();
341
342   TBranch *branch;
343
344   if (fLoader->TreeS () )
345     {
346       branch = fLoader->TreeS ()->GetBranch ("TOF");
347       if (branch) {
348         if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit",  1000);
349         branch->SetAddress (&fSDigits);
350       }
351     }
352
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   /*
364   if (fLoader->TreeR() && fReconParticles) //I do not know where this array is created - skowron
365     {
366       branch = fLoader->TreeR()->GetBranch("TOF"); 
367       if (branch) 
368        {
369          branch->SetAddress(&fReconParticles) ;
370        }
371     }
372   */
373 }
374
375 //_____________________________________________________________________________
376 void AliTOF::CreateGeometry()
377 {
378   //
379   // Common geometry code 
380   //
381   //Begin_Html
382   /*
383     <img src="picts/AliTOFv23.gif">
384   */
385   //End_Html
386   //
387
388   Float_t xTof, yTof;
389
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) {
400
401     xTof = 124.5;//fTOFGeometry->StripLength()+2.*(0.3+0.03); // cm,  x-dimension of FTOA volume
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());
407
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   }
419
420 }
421
422
423 //___________________________________________
424 void AliTOF::ResetHits ()
425 {
426   // Reset number of clusters and the cluster array for this detector
427   AliDetector::ResetHits ();
428 }
429
430 //____________________________________________
431 void AliTOF::ResetDigits ()
432 {
433   //
434   // Reset number of digits and the digits array for this detector
435   AliDetector::ResetDigits ();
436   //
437
438 //____________________________________________
439 void AliTOF::ResetSDigits ()
440 {
441   //
442   // Reset number of sdigits and the sdigits array for this detector
443   fNSDigits = 0;
444   //fSDigits = 0x0;
445   //
446
447 //_____________________________________________________________________________
448 void AliTOF::Init()
449 {
450   //
451   // Initialise TOF detector after it has been built
452   //
453   // Set id of TOF sensitive volume
454   if (IsVersion() !=0) fIdSens=gMC->VolId("FPAD");
455
456   /*
457   // Save the geometry
458   TDirectory* saveDir = gDirectory;
459   AliRunLoader::Instance()->CdGAFile();
460   fTOFGeometry->Write("TOFGeometry");
461   saveDir->cd();
462   */
463 }
464
465 //____________________________________________________________________________
466 void AliTOF::MakeBranch(Option_t* option)
467 {
468  //
469  // Initializes the Branches of the TOF inside the 
470  // trees written for each event. 
471  // AliDetector::MakeBranch initializes just the 
472  // Branch inside TreeH. Here we add the branches in 
473  // TreeD, TreeS and TreeR.
474  //
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);
486
487   Int_t buffersize = 4000;
488   const Int_t kSize=10;
489   Char_t branchname[kSize];
490   snprintf(branchname,kSize,"%s",GetName());
491   
492   const char *oD = strstr(option,"D");
493   const char *oS = strstr(option,"S");
494   const char *oR = strstr(option,"R");
495
496   if (fLoader->TreeD() && oD){
497     if (fDigits == 0x0) fDigits = new TClonesArray("AliTOFdigit",  1000); 
498     MakeBranchInTree(fLoader->TreeD(), branchname, &fDigits,buffersize, 0) ;
499   }
500
501   if (fLoader->TreeS() && oS){
502     if (fSDigits == 0x0) fSDigits = new TClonesArray("AliTOFSDigit",  1000);
503     MakeBranchInTree(fLoader->TreeS(), branchname, &fSDigits,buffersize, 0) ;
504   }
505
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   /*
512   if (fReconParticles && fLoader->TreeR() && oR){
513     MakeBranchInTree(fLoader->TreeR(), branchname, &fReconParticles,buffersize, 0) ;
514   }
515   */
516 }
517
518 //____________________________________________________________________________
519 void 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
524 // by default :  enabled for TOFv1, v2, v3, v4, v5
525 //              disabled for TOFv0
526 // 
527    if (hits &&  (IsVersion()!=0))
528       fIdSens = gMC->VolId("FPAD");
529    else
530       AliInfo("Option for writing the TOF-hits branch on TreeH: disabled");
531 }
532
533 //____________________________________________________________________________
534 void AliTOF::FinishEvent()
535 {
536 // do nothing
537 }
538
539 //____________________________________________________________________________
540 void AliTOF::Hits2SDigits()
541 {
542 //
543 // Use the TOF SDigitizer to make TOF SDigits
544 //
545
546 //  AliInfo("Start...");
547   
548   AliRunLoader * rl = fLoader->GetRunLoader();
549   AliDebug(2,"Initialized runLoader");
550   AliTOFSDigitizer sd((rl->GetFileName()).Data());
551   AliDebug(2,"Initialized TOF sdigitizer");
552   //ToAliDebug(1, sd.Print(""));
553   //AliInfo("ToAliDebug");
554
555   //sd.Exec("all") ;
556   sd.Exec("partial") ;
557
558   AliDebug(2,"I am sorting from AliTOF class");
559
560 }
561
562 //____________________________________________________________________________
563 void 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) 
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));
573  
574   AliRunLoader * rl = fLoader->GetRunLoader();
575   AliTOFSDigitizer sd((rl->GetFileName()).Data(),evNumber1,evNumber2) ;
576   ToAliDebug(1, sd.Print(""));
577
578   sd.Exec("") ;
579
580 }
581
582 //___________________________________________________________________________
583 AliDigitizer* AliTOF::CreateDigitizer(AliRunDigitizer* manager) const
584 {
585   AliDebug(2,"I am creating the TOF digitizer");
586   return new AliTOFDigitizer(manager);
587 }
588
589 //___________________________________________________________________________
590 Bool_t AliTOF::CheckOverlap(const Int_t * const vol,
591                             Int_t* digit,Int_t Track)
592 {
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.
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.
600 //
601
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
615       Int_t tdc2 = digit[0];
616       Int_t tdc1 = currentDigit->GetTdc();
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 
636         overlap= kFALSE;
637
638     } // close if (idem) -> two digits on the same TOF pad
639
640   } // end loop on existing sdigits
641
642   return overlap;
643 }
644 //____________________________________________________________________________
645 void AliTOF::Digits2Raw()
646 {
647 //
648 // Starting from the TOF digits, writes the Raw Data objects
649 //
650
651   TStopwatch stopwatch;
652   stopwatch.Start();
653
654   fLoader->LoadDigits();
655
656   TTree* digits = fLoader->TreeD();
657   if (!digits) {
658     AliError("no digits tree");
659     return;
660   }
661   
662   //AliTOFDDLRawData rawWriter;
663   fTOFRawWriter.Clear();
664   fTOFRawWriter.SetVerbose(0);
665   if (fTOFRawWriter.GetPackedAcquisitionMode()) {
666     if(fTOFRawWriter.GetMatchingWindow()>8192)
667       AliWarning(Form("You are running in packing mode and the matching window is %.2f ns, i.e. greater than 199.8848 ns",
668                       fTOFRawWriter.GetMatchingWindow()*AliTOFGeometry::TdcBinWidth()*1.e-03));
669   }
670   
671   AliDebug(1,"Formatting raw data for TOF");
672   digits->GetEvent(0);
673   fTOFRawWriter.RawDataTOF(digits->GetBranch("TOF"));  
674
675   fLoader->UnloadDigits();
676   
677   AliDebug(1, Form("Execution time to write TOF raw data : R:%.2fs C:%.2fs",
678                    stopwatch.RealTime(),stopwatch.CpuTime()));
679
680 }
681
682 //____________________________________________________________________________
683 void AliTOF::RecreateSDigitsArray() {
684 //
685 // delete TClonesArray fSDigits and create it again
686 //  needed for backward compatability with PPR test production
687 //
688   fSDigits->Clear();
689 }
690 //____________________________________________________________________________
691 void AliTOF::CreateSDigitsArray() {
692 //
693 // create TClonesArray fSDigits
694 //  needed for backward compatability with PPR test production
695 //
696   fSDigits       = new TClonesArray("AliTOFSDigit",  1000);
697 }
698 //____________________________________________________________________________
699 Bool_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
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 //____________________________________________________________________________
728 void 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
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 }