Fix for the case of non-existent calibration files
[u/mrichter/AliRoot.git] / ITS / AliITSreconstruction.cxx
CommitLineData
e69020a0 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
88cb7938 16/* $Id$ */
8ace09b6 17/////////////////////////////////////////////////////////////////////////
18// //
7d62fb64 19// Class for ITS RecPoint reconstruction //
8ace09b6 20// //
21////////////////////////////////////////////////////////////////////////
b9d0a01d 22
e69020a0 23#include <TString.h>
e69020a0 24#include "AliRun.h"
88cb7938 25#include "AliRunLoader.h"
7d62fb64 26#include "AliITSDetTypeRec.h"
88cb7938 27#include "AliITSLoader.h"
e69020a0 28#include "AliITSreconstruction.h"
e69020a0 29#include "AliITSgeom.h"
30
fe7d86eb 31using std::endl;
32using std::cout;
e69020a0 33ClassImp(AliITSreconstruction)
34
35//______________________________________________________________________
88cb7938 36AliITSreconstruction::AliITSreconstruction():
37 fInit(kFALSE),
38 fEnt(0),
39 fEnt0(0),
8221b41b 40 fDetTypeRec(0x0),
88cb7938 41 fDfArp(kFALSE),
8221b41b 42 fITSgeom(0x0),
88cb7938 43 fLoader(0x0),
44 fRunLoader(0x0)
45{
e69020a0 46 // Default constructor.
47 // Inputs:
48 // none.
49 // Outputs:
50 // none.
51 // Return:
52 // A zero-ed constructed AliITSreconstruction class.
e69020a0 53 fDet[0] = fDet[1] = fDet[2] = kTRUE;
4d24e763 54}
55//______________________________________________________________________
4d24e763 56
88cb7938 57AliITSreconstruction::AliITSreconstruction(AliRunLoader *rl):
58 fInit(kFALSE),
59 fEnt(0),
60 fEnt0(0),
8221b41b 61 fDetTypeRec(0x0),
88cb7938 62 fDfArp(kFALSE),
8221b41b 63 fITSgeom(0x0),
88cb7938 64 fLoader(0x0),
65 fRunLoader(rl)
66{
67 fDet[0] = fDet[1] = fDet[2] = kTRUE;
e69020a0 68}
69//______________________________________________________________________
88cb7938 70AliITSreconstruction::AliITSreconstruction(const char* filename):
71 fInit(kFALSE),
72 fEnt(0),
73 fEnt0(0),
8221b41b 74 fDetTypeRec(0x0),
88cb7938 75 fDfArp(kFALSE),
8221b41b 76 fITSgeom(0x0),
88cb7938 77 fLoader(0x0),
78 fRunLoader(0x0)
79{
e69020a0 80 // Standard constructor.
81 // Inputs:
82 // const char* filename filename containing the digits to be
3e9ba728 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.
e69020a0 87 // Outputs:
88 // none.
89 // Return:
90 // A standardly constructed AliITSreconstruction class.
91
88cb7938 92 fDet[0] = fDet[1] = fDet[2] = kTRUE;
93
94 fRunLoader = AliRunLoader::Open(filename);
95 if (fRunLoader == 0x0)
96 {
a5a317a9 97 Error("AliITSreconstruction","Can not load the session %s \n",filename);
88cb7938 98 return;
99 }
88cb7938 100
e69020a0 101}
8221b41b 102
7d62fb64 103
104//______________________________________________________________________
e69020a0 105AliITSreconstruction::~AliITSreconstruction(){
e69020a0 106 // A destroyed AliITSreconstruction class.
7d62fb64 107
108 //fITS = 0;
88cb7938 109 delete fRunLoader;
7d62fb64 110
e69020a0 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
a5a317a9 121 Info("Init"," Init ITS reconstruction");
88cb7938 122 if (fRunLoader == 0x0)
123 {
124 Error("Init","Run Loader is NULL");
125 return kFALSE;
126 }
60b9526b 127 // fRunLoader->LoadgAlice();
128 // fRunLoader->LoadHeader();
88cb7938 129
130 fLoader = (AliITSLoader*) fRunLoader->GetLoader("ITSLoader");
131 if(!fLoader) {
132 Error("Init","ITS loader not found");
133 fInit = kFALSE;
134 }
135
e69020a0 136 // Now ready to init.
7d62fb64 137
60b9526b 138 //fRunLoader->CdGAFile();
c7dca079 139 fITSgeom = fLoader->GetITSgeom();
e69020a0 140
6cae184e 141 fDetTypeRec = new AliITSDetTypeRec();
142 fDetTypeRec->SetITSgeom(fITSgeom);
7d62fb64 143 fDetTypeRec->SetDefaults();
e69020a0 144 fDet[0] = fDet[1] = fDet[2] = kTRUE;
145 fEnt0 = 0;
88cb7938 146
60b9526b 147 fEnt = Int_t(fRunLoader->GetNumberOfEvents());
88cb7938 148
149 fLoader->LoadDigits("read");
150 fLoader->LoadRecPoints("recreate");
88cb7938 151 if (fLoader->TreeR() == 0x0) fLoader->MakeTree("R");
7d62fb64 152
6cae184e 153 fDetTypeRec->SetTreeAddressD(fLoader->TreeD());
154 fDetTypeRec->MakeBranchR(fLoader->TreeR());
7d62fb64 155 fDetTypeRec->SetTreeAddressR(fLoader->TreeR());
156
e69020a0 157 fInit = InitRec();
88cb7938 158
159 Info("Init"," Done\n\n\n");
160
e69020a0 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.
5d2c2f86 172
173
174 fDetTypeRec->SetDefaultClusterFindersV2();
175 Info("InitRec"," Done\n");
176 return kTRUE;
e69020a0 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;
88cb7938 188 Int_t evnt;
e8c2bf0d 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){
88cb7938 197 fDet[0] = fDet[1] = fDet[2] = kTRUE;
198 lopt = "All";
e69020a0 199 }else{
88cb7938 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;
e69020a0 206 } // end if strstr(opt,...)
207
208 if(!fInit){
88cb7938 209 cout << "Initilization Failed, Can't run Exec." << endl;
210 return;
e69020a0 211 } // end if !fInit
88cb7938 212 for(evnt=0;evnt<fEnt;evnt++)
213 {
a5a317a9 214 // Info("Exec","");
88cb7938 215 Info("Exec","Processing Event %d",evnt);
a5a317a9 216 // Info("Exec","");
88cb7938 217
218 fRunLoader->GetEvent(evnt);
219 if (fLoader->TreeR() == 0x0) fLoader->MakeTree("R");
7d62fb64 220 fDetTypeRec->MakeBranchR(0);
7d62fb64 221 fDetTypeRec->SetTreeAddressR(fLoader->TreeR());
222 fDetTypeRec->SetTreeAddressD(fLoader->TreeD());
6cae184e 223 fDetTypeRec->DigitsToRecPoints(fLoader->TreeD(),fLoader->TreeR(),0,lopt);
e69020a0 224 } // end for evnt
f243fbe6 225}
226//______________________________________________________________________
227void AliITSreconstruction::SetOutputFile(TString filename){
999cc3eb 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 }
e69020a0 239}