]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFReconstructor.cxx
bug fixed
[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 <cstdlib>
25 #include "TObjArray.h"
26 #include "TString.h"
27
28 #include "AliLog.h"
29 #include "AliRawReader.h"
30
31 #include "AliTOFClusterFinder.h"
32 #include "AliTOFClusterFinderV1.h"
33 #include "AliTOFcalib.h"
34 #include "AliTOFtrackerMI.h"
35 #include "AliTOFtracker.h"
36 #include "AliTOFtrackerV1.h"
37 #include "AliTOFReconstructor.h"
38
39 class TTree;
40
41 class AliESDEvent;
42
43 ClassImp(AliTOFReconstructor)
44
45  //____________________________________________________________________
46 AliTOFReconstructor::AliTOFReconstructor() 
47   : AliReconstructor(),
48     fTOFcalib(0)
49 {
50 //
51 // ctor
52 //
53   
54   //Retrieving the TOF calibration info  
55   fTOFcalib    = new AliTOFcalib();
56   fTOFcalib->CreateCalObjects();
57
58   if(!fTOFcalib->ReadParOnlineDelayFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
59   if(!fTOFcalib->ReadParOnlineStatusFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
60
61   if(!fTOFcalib->ReadParOfflineFromCDB("TOF/Calib",-1)) {AliFatal("Exiting, no CDB object found!!!");exit(0);}  
62 }
63
64 //------------------------------------------------------------------------
65 AliTOFReconstructor::AliTOFReconstructor(const AliTOFReconstructor &source)
66   : AliReconstructor(source),
67     fTOFcalib(source.fTOFcalib)
68 {
69 //
70 // copy ctor
71 //
72 }
73
74 //------------------------------------------------------------------------
75 AliTOFReconstructor & AliTOFReconstructor::operator=(const AliTOFReconstructor &source)
76 {
77 //
78 // assignment op.
79 //
80   if (this == &source)
81     return *this;
82
83   fTOFcalib=source.fTOFcalib;
84   return *this;
85 }
86 //_____________________________________________________________________________
87 AliTOFReconstructor::~AliTOFReconstructor() 
88 {
89 //
90 // dtor
91 //
92   delete fTOFcalib;
93 }
94
95 //_____________________________________________________________________________
96 void AliTOFReconstructor::Reconstruct(AliRawReader *rawReader,
97                                       TTree *clustersTree) const
98 {
99   //
100   // reconstruct clusters from Raw Data
101   //
102
103   TString optionString = GetOption();
104   // use V1 cluster finder if selected
105   if (optionString.Contains("ClusterizerV1")) {
106     static AliTOFClusterFinderV1 tofClus(fTOFcalib);
107
108     // decoder version option
109     if (optionString.Contains("DecoderV1"))
110       tofClus.SetDecoderVersion(1);
111     else
112       tofClus.SetDecoderVersion(0);
113     
114     tofClus.Digits2RecPoints(rawReader, clustersTree);
115   }
116   else {
117     static AliTOFClusterFinder tofClus(fTOFcalib);
118     
119     // decoder version option
120     if (optionString.Contains("DecoderV1"))
121       tofClus.SetDecoderVersion(1);
122     else
123       tofClus.SetDecoderVersion(0);
124
125     tofClus.Digits2RecPoints(rawReader, clustersTree);
126   }
127
128 }
129
130 //_____________________________________________________________________________
131 void AliTOFReconstructor::Reconstruct(TTree *digitsTree,
132                                       TTree *clustersTree) const
133 {
134   //
135   // reconstruct clusters from digits
136   //
137
138   AliDebug(2,Form("Global Event loop mode: Creating Recpoints from Digits Tree")); 
139
140   TString optionString = GetOption();
141   // use V1 cluster finder if selected
142   if (optionString.Contains("ClusterizerV1")) {
143     static AliTOFClusterFinderV1 tofClus(fTOFcalib);
144
145     // decoder version option
146     if (optionString.Contains("DecoderV1"))
147       tofClus.SetDecoderVersion(1);
148     else
149       tofClus.SetDecoderVersion(0);
150     
151     tofClus.Digits2RecPoints(digitsTree, clustersTree);
152   }
153   else {
154     static AliTOFClusterFinder tofClus(fTOFcalib);
155
156     // decoder version option
157     if (optionString.Contains("DecoderV1"))
158       tofClus.SetDecoderVersion(1);
159     else
160       tofClus.SetDecoderVersion(0);
161     
162     tofClus.Digits2RecPoints(digitsTree, clustersTree);
163   }
164
165 }
166 //_____________________________________________________________________________
167   void AliTOFReconstructor::ConvertDigits(AliRawReader* reader, TTree* digitsTree) const
168 {
169 // reconstruct clusters from digits
170
171   AliDebug(2,Form("Global Event loop mode: Converting Raw Data to a Digits Tree")); 
172
173   TString optionString = GetOption();
174   // use V1 cluster finder if selected
175   if (optionString.Contains("ClusterizerV1")) {
176     static AliTOFClusterFinderV1 tofClus(fTOFcalib);
177
178     // decoder version option
179     if (optionString.Contains("DecoderV1"))
180       tofClus.SetDecoderVersion(1);
181     else
182       tofClus.SetDecoderVersion(0);
183     
184     tofClus.Raw2Digits(reader, digitsTree);
185   }
186   else {
187     static AliTOFClusterFinder tofClus(fTOFcalib);
188
189     // decoder version option
190     if (optionString.Contains("DecoderV1"))
191       tofClus.SetDecoderVersion(1);
192     else
193       tofClus.SetDecoderVersion(0);
194     
195     tofClus.Raw2Digits(reader, digitsTree);
196   }
197
198 }
199
200 //_____________________________________________________________________________
201 AliTracker* AliTOFReconstructor::CreateTracker() const
202 {
203
204   // 
205   // create a TOF tracker using 
206   // TOF Reco Param collected by STEER
207   //
208
209   TString selectedTracker = GetOption();
210  
211   AliTracker *tracker;
212   // use MI tracker if selected
213   if (selectedTracker.Contains("TrackerMI")) {
214     tracker = new AliTOFtrackerMI();
215   }
216   // use V1 tracker if selected
217   if (selectedTracker.Contains("TrackerV1")) {
218     tracker =  new AliTOFtrackerV1();
219   }
220   else {
221     tracker = new AliTOFtracker();
222   }
223   return tracker;
224
225 }