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