Fix for the case of non-existent calibration files
[u/mrichter/AliRoot.git] / ITS / AliITSreconstruction.cxx
... / ...
CommitLineData
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// Class for ITS RecPoint reconstruction //
20// //
21////////////////////////////////////////////////////////////////////////
22
23#include <TString.h>
24#include "AliRun.h"
25#include "AliRunLoader.h"
26#include "AliITSDetTypeRec.h"
27#include "AliITSLoader.h"
28#include "AliITSreconstruction.h"
29#include "AliITSgeom.h"
30
31using std::endl;
32using std::cout;
33ClassImp(AliITSreconstruction)
34
35//______________________________________________________________________
36AliITSreconstruction::AliITSreconstruction():
37 fInit(kFALSE),
38 fEnt(0),
39 fEnt0(0),
40 fDetTypeRec(0x0),
41 fDfArp(kFALSE),
42 fITSgeom(0x0),
43 fLoader(0x0),
44 fRunLoader(0x0)
45{
46 // Default constructor.
47 // Inputs:
48 // none.
49 // Outputs:
50 // none.
51 // Return:
52 // A zero-ed constructed AliITSreconstruction class.
53 fDet[0] = fDet[1] = fDet[2] = kTRUE;
54}
55//______________________________________________________________________
56
57AliITSreconstruction::AliITSreconstruction(AliRunLoader *rl):
58 fInit(kFALSE),
59 fEnt(0),
60 fEnt0(0),
61 fDetTypeRec(0x0),
62 fDfArp(kFALSE),
63 fITSgeom(0x0),
64 fLoader(0x0),
65 fRunLoader(rl)
66{
67 fDet[0] = fDet[1] = fDet[2] = kTRUE;
68}
69//______________________________________________________________________
70AliITSreconstruction::AliITSreconstruction(const char* filename):
71 fInit(kFALSE),
72 fEnt(0),
73 fEnt0(0),
74 fDetTypeRec(0x0),
75 fDfArp(kFALSE),
76 fITSgeom(0x0),
77 fLoader(0x0),
78 fRunLoader(0x0)
79{
80 // Standard constructor.
81 // Inputs:
82 // const char* filename filename containing the digits to be
83 // reconstructed. If filename = 0 (nil)
84 // then no file is opened but a file is
85 // assumed to already be opened. This
86 // already opened file will be used.
87 // Outputs:
88 // none.
89 // Return:
90 // A standardly constructed AliITSreconstruction class.
91
92 fDet[0] = fDet[1] = fDet[2] = kTRUE;
93
94 fRunLoader = AliRunLoader::Open(filename);
95 if (fRunLoader == 0x0)
96 {
97 Error("AliITSreconstruction","Can not load the session %s \n",filename);
98 return;
99 }
100
101}
102
103
104//______________________________________________________________________
105AliITSreconstruction::~AliITSreconstruction(){
106 // A destroyed AliITSreconstruction class.
107
108 //fITS = 0;
109 delete fRunLoader;
110
111}
112//______________________________________________________________________
113Bool_t AliITSreconstruction::Init(){
114 // Class Initilizer.
115 // Inputs:
116 // none.
117 // Outputs:
118 // none.
119 // Return:
120 // kTRUE if no errors initilizing this class occurse else kFALSE
121 Info("Init"," Init ITS reconstruction");
122 if (fRunLoader == 0x0)
123 {
124 Error("Init","Run Loader is NULL");
125 return kFALSE;
126 }
127 // fRunLoader->LoadgAlice();
128 // fRunLoader->LoadHeader();
129
130 fLoader = (AliITSLoader*) fRunLoader->GetLoader("ITSLoader");
131 if(!fLoader) {
132 Error("Init","ITS loader not found");
133 fInit = kFALSE;
134 }
135
136 // Now ready to init.
137
138 //fRunLoader->CdGAFile();
139 fITSgeom = fLoader->GetITSgeom();
140
141 fDetTypeRec = new AliITSDetTypeRec();
142 fDetTypeRec->SetITSgeom(fITSgeom);
143 fDetTypeRec->SetDefaults();
144 fDet[0] = fDet[1] = fDet[2] = kTRUE;
145 fEnt0 = 0;
146
147 fEnt = Int_t(fRunLoader->GetNumberOfEvents());
148
149 fLoader->LoadDigits("read");
150 fLoader->LoadRecPoints("recreate");
151 if (fLoader->TreeR() == 0x0) fLoader->MakeTree("R");
152
153 fDetTypeRec->SetTreeAddressD(fLoader->TreeD());
154 fDetTypeRec->MakeBranchR(fLoader->TreeR());
155 fDetTypeRec->SetTreeAddressR(fLoader->TreeR());
156
157 fInit = InitRec();
158
159 Info("Init"," Done\n\n\n");
160
161 return fInit;
162}
163//______________________________________________________________________
164Bool_t AliITSreconstruction::InitRec(){
165 // Sets up Reconstruction part of AliITSDetType..
166 // Inputs:
167 // none.
168 // Outputs:
169 // none.
170 // Return:
171 // none.
172
173
174 fDetTypeRec->SetDefaultClusterFindersV2();
175 Info("InitRec"," Done\n");
176 return kTRUE;
177}
178//______________________________________________________________________
179void AliITSreconstruction::Exec(const Option_t *opt){
180 // Main reconstruction function.
181 // Inputs:
182 // Option_t * opt list of subdetector to digitize. =0 all.
183 // Outputs:
184 // none.
185 // Return:
186 // none.
187 Option_t *lopt;
188 Int_t evnt;
189 Bool_t condition =kFALSE;
190 if(opt){
191 if(strstr(opt,"All")||strstr(opt,"ALL")||strstr(opt,"ITS"))condition =kTRUE;
192 }
193 else{
194 condition = kTRUE;
195 }
196 if(condition){
197 fDet[0] = fDet[1] = fDet[2] = kTRUE;
198 lopt = "All";
199 }else{
200 fDet[0] = fDet[1] = fDet[2] = kFALSE;
201 if(strstr(opt,"SPD")) fDet[kSPD] = kTRUE;
202 if(strstr(opt,"SDD")) fDet[kSDD] = kTRUE;
203 if(strstr(opt,"SSD")) fDet[kSSD] = kTRUE;
204 if(fDet[kSPD] && fDet[kSDD] && fDet[kSSD]) lopt = "All";
205 else lopt = opt;
206 } // end if strstr(opt,...)
207
208 if(!fInit){
209 cout << "Initilization Failed, Can't run Exec." << endl;
210 return;
211 } // end if !fInit
212 for(evnt=0;evnt<fEnt;evnt++)
213 {
214 // Info("Exec","");
215 Info("Exec","Processing Event %d",evnt);
216 // Info("Exec","");
217
218 fRunLoader->GetEvent(evnt);
219 if (fLoader->TreeR() == 0x0) fLoader->MakeTree("R");
220 fDetTypeRec->MakeBranchR(0);
221 fDetTypeRec->SetTreeAddressR(fLoader->TreeR());
222 fDetTypeRec->SetTreeAddressD(fLoader->TreeD());
223 fDetTypeRec->DigitsToRecPoints(fLoader->TreeD(),fLoader->TreeR(),0,lopt);
224 } // end for evnt
225}
226//______________________________________________________________________
227void AliITSreconstruction::SetOutputFile(TString filename){
228 // Set a new file name for recpoints.
229 // It must be called before Init()
230 if(!fLoader)fLoader = (AliITSLoader*) fRunLoader->GetLoader("ITSLoader");
231 if(fLoader){
232 Info("SetOutputFile","name for rec points is %s",filename.Data());
233 fLoader->SetRecPointsFileName(filename);
234 }
235 else {
236 Error("SetOutputFile",
237 "ITS loader not available. Not possible to set name: %s",filename.Data());
238 }
239}