write ToT in the Raw Data
[u/mrichter/AliRoot.git] / TOF / AliTOFReconstructor.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
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 // class for TOF reconstruction                                              //
21 //                                                                           //
22 ///////////////////////////////////////////////////////////////////////////////
23
24
25 #include <TFile.h>
26
27 #include "AliLog.h"
28 #include "AliRun.h"
29 #include "AliRunLoader.h"
30
31 #include "AliTOFGeometry.h"
32 #include "AliTOFGeometryV4.h"
33 #include "AliTOFGeometryV5.h"
34 #include "AliTOFtracker.h"
35 #include "AliTOFtrackerMI.h"
36 #include "AliTOFClusterFinder.h"
37 #include "AliTOFReconstructor.h"
38
39 ClassImp(AliTOFReconstructor)
40
41 //_____________________________________________________________________________
42   void AliTOFReconstructor::Reconstruct(AliRunLoader* runLoader) const
43 {
44 // reconstruct clusters from digits
45
46   AliTOFClusterFinder *tofClus = new AliTOFClusterFinder(runLoader);
47   tofClus->Load();
48   for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++)
49     {
50       tofClus->Digits2RecPoints(iEvent);
51     }
52   tofClus->UnLoad();
53
54 }
55
56 //_____________________________________________________________________________
57 void AliTOFReconstructor::Reconstruct(AliRunLoader* runLoader,
58                                       AliRawReader *rawReader) const
59 {
60 // reconstruct clusters from Raw Data
61
62   AliTOFClusterFinder tofClus(runLoader);
63   tofClus.LoadClusters();
64   Int_t iEvent = 0;
65   while (rawReader->NextEvent()) {
66     tofClus.Digits2RecPoints(iEvent,rawReader);
67     //tofClus.Raw2Digits(iEvent,rawReader); // temporary solution
68     iEvent++;
69   }
70   tofClus.UnLoadClusters();
71
72 }
73
74 //_____________________________________________________________________________
75 void AliTOFReconstructor::Reconstruct(AliRawReader *rawReader,
76                                       TTree *clustersTree) const
77 {
78 // reconstruct clusters from Raw Data
79
80   AliTOFClusterFinder tofClus;
81   tofClus.Digits2RecPoints(rawReader, clustersTree);
82
83 }
84
85 //_____________________________________________________________________________
86 AliTracker* AliTOFReconstructor::CreateTracker(AliRunLoader* runLoader) const
87 {
88 // create a TOF tracker
89
90   AliTOFGeometry* geom = GetTOFGeometry(runLoader);
91   if (!geom) return NULL;
92   //  Double_t parPID[] = {130., 5.};
93   Double_t parPID[] = {80., 5.};
94   TString selectedTracker = GetOption();
95   // use MI tracker if selected
96   if (selectedTracker.Contains("MI")) return new AliTOFtrackerMI(geom,parPID);
97
98   return new AliTOFtracker(geom, parPID);
99 }
100
101 //_____________________________________________________________________________
102 void AliTOFReconstructor::FillESD(AliRunLoader* /*runLoader*/, 
103                                   AliESD* /*esd*/) const
104 {
105 // nothing to be done
106
107 }
108
109 //_____________________________________________________________________________
110 AliTOFGeometry* AliTOFReconstructor::GetTOFGeometry(AliRunLoader* runLoader) const
111 {
112 // get the TOF parameters
113
114   AliTOFGeometry *tofGeom;
115
116   runLoader->CdGAFile();
117   TDirectory *savedir=gDirectory; 
118   TFile *in=(TFile*)gFile;  
119   if (!in->IsOpen()) {
120     AliWarning("Geometry file is not open default  TOF geometry will be used");
121     tofGeom = new AliTOFGeometry();
122   }
123   else {
124     in->cd();  
125     tofGeom = (AliTOFGeometry*) in->Get("TOFgeometry");
126   }
127
128   savedir->cd();  
129
130   if (!tofGeom) {
131     AliError("no TOF geometry available");
132     return NULL;
133   }
134   return tofGeom;
135 }