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