]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSreconstruction.cxx
Add/remove classes according to changes in MUON.
[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
7d62fb64 31
e69020a0 32ClassImp(AliITSreconstruction)
33
34//______________________________________________________________________
88cb7938 35AliITSreconstruction::AliITSreconstruction():
36 fInit(kFALSE),
37 fEnt(0),
38 fEnt0(0),
8221b41b 39 fDetTypeRec(0x0),
88cb7938 40 fDfArp(kFALSE),
8221b41b 41 fITSgeom(0x0),
88cb7938 42 fLoader(0x0),
43 fRunLoader(0x0)
44{
e69020a0 45 // Default constructor.
46 // Inputs:
47 // none.
48 // Outputs:
49 // none.
50 // Return:
51 // A zero-ed constructed AliITSreconstruction class.
e69020a0 52 fDet[0] = fDet[1] = fDet[2] = kTRUE;
4d24e763 53}
54//______________________________________________________________________
4d24e763 55
88cb7938 56AliITSreconstruction::AliITSreconstruction(AliRunLoader *rl):
57 fInit(kFALSE),
58 fEnt(0),
59 fEnt0(0),
8221b41b 60 fDetTypeRec(0x0),
88cb7938 61 fDfArp(kFALSE),
8221b41b 62 fITSgeom(0x0),
88cb7938 63 fLoader(0x0),
64 fRunLoader(rl)
65{
66 fDet[0] = fDet[1] = fDet[2] = kTRUE;
e69020a0 67}
68//______________________________________________________________________
88cb7938 69AliITSreconstruction::AliITSreconstruction(const char* filename):
70 fInit(kFALSE),
71 fEnt(0),
72 fEnt0(0),
8221b41b 73 fDetTypeRec(0x0),
88cb7938 74 fDfArp(kFALSE),
8221b41b 75 fITSgeom(0x0),
88cb7938 76 fLoader(0x0),
77 fRunLoader(0x0)
78{
e69020a0 79 // Standard constructor.
80 // Inputs:
81 // const char* filename filename containing the digits to be
3e9ba728 82 // reconstructed. If filename = 0 (nil)
83 // then no file is opened but a file is
84 // assumed to already be opened. This
85 // already opened file will be used.
e69020a0 86 // Outputs:
87 // none.
88 // Return:
89 // A standardly constructed AliITSreconstruction class.
90
88cb7938 91 fDet[0] = fDet[1] = fDet[2] = kTRUE;
92
93 fRunLoader = AliRunLoader::Open(filename);
94 if (fRunLoader == 0x0)
95 {
96 Error("AliITSreconstruction","Can not load the session",filename);
97 return;
98 }
99 fRunLoader->LoadgAlice();
100 gAlice = fRunLoader->GetAliRun();
101
102 if(!gAlice) {
103 Error("AliITSreconstruction","gAlice not found on file. Aborting.");
104 fInit = kFALSE;
105 return;
106 } // end if !gAlice
107
e69020a0 108}
8221b41b 109
7d62fb64 110//______________________________________________________________________
8221b41b 111AliITSreconstruction::AliITSreconstruction(const AliITSreconstruction &rec):TTask(rec),
112fInit(rec.fInit),
113fEnt(rec.fEnt),
114fEnt0(rec.fEnt0),
115fDetTypeRec(rec.fDetTypeRec),
116fDfArp(rec.fDfArp),
117fITSgeom(rec.fITSgeom),
118fLoader(rec.fLoader),
119fRunLoader(rec.fRunLoader)
120{
7d62fb64 121 // Copy constructor.
122
7d62fb64 123
124}
8221b41b 125
7d62fb64 126//______________________________________________________________________
8221b41b 127AliITSreconstruction& AliITSreconstruction::operator=(const AliITSreconstruction& source){
128 // Assignment operator.
129 this->~AliITSreconstruction();
130 new(this) AliITSreconstruction(source);
131 return *this;
132
7d62fb64 133}
134
e69020a0 135//______________________________________________________________________
136AliITSreconstruction::~AliITSreconstruction(){
e69020a0 137 // A destroyed AliITSreconstruction class.
7d62fb64 138
139 //fITS = 0;
88cb7938 140 delete fRunLoader;
7d62fb64 141
e69020a0 142}
143//______________________________________________________________________
144Bool_t AliITSreconstruction::Init(){
145 // Class Initilizer.
146 // Inputs:
147 // none.
148 // Outputs:
149 // none.
150 // Return:
151 // kTRUE if no errors initilizing this class occurse else kFALSE
88cb7938 152 Info("Init","");
153 if (fRunLoader == 0x0)
154 {
155 Error("Init","Run Loader is NULL");
156 return kFALSE;
157 }
158 fRunLoader->LoadgAlice();
159 fRunLoader->LoadHeader();
160
161 fLoader = (AliITSLoader*) fRunLoader->GetLoader("ITSLoader");
162 if(!fLoader) {
163 Error("Init","ITS loader not found");
164 fInit = kFALSE;
165 }
166
e69020a0 167 // Now ready to init.
7d62fb64 168
169 fRunLoader->CdGAFile();
c7dca079 170 fITSgeom = fLoader->GetITSgeom();
e69020a0 171
8e50d897 172 fDetTypeRec = new AliITSDetTypeRec(fLoader);
7d62fb64 173 fDetTypeRec->SetDefaults();
e69020a0 174 fDet[0] = fDet[1] = fDet[2] = kTRUE;
175 fEnt0 = 0;
88cb7938 176
8ace09b6 177 //fEnt = gAlice->GetEventsPerRun();
178 fEnt = Int_t(fRunLoader->TreeE()->GetEntries());
88cb7938 179
180 fLoader->LoadDigits("read");
181 fLoader->LoadRecPoints("recreate");
182 fLoader->LoadRawClusters("recreate");
183 if (fLoader->TreeR() == 0x0) fLoader->MakeTree("R");
7d62fb64 184 if (fLoader->TreeC() == 0x0) fLoader->MakeTree("C");
185
7d62fb64 186 fDetTypeRec->MakeBranchR(0);
187 fDetTypeRec->MakeBranchC();
188 fDetTypeRec->SetTreeAddress();
189 fDetTypeRec->SetTreeAddressR(fLoader->TreeR());
190
e69020a0 191 fInit = InitRec();
88cb7938 192
193 Info("Init"," Done\n\n\n");
194
e69020a0 195 return fInit;
196}
197//______________________________________________________________________
198Bool_t AliITSreconstruction::InitRec(){
199 // Sets up Reconstruction part of AliITSDetType..
200 // Inputs:
201 // none.
202 // Outputs:
203 // none.
204 // Return:
205 // none.
7d62fb64 206 /*
207 //AliITSDetType *idt;
208 fDetTypeRec->SetLoader(fLoader);
e69020a0 209 // SPD
7d62fb64 210 if(fDet[kSPD]){
211 Info("InitRec","SPD");
212 //idt = fITS->DetType(kSPD);
213 AliITSsegmentationSPD *segSPD = (AliITSsegmentationSPD*)fDetTypeRec->GetSegmentationModel(0);
214 TClonesArray *digSPD = fDetTypeRec->DigitsAddress(kSPD);
215 TClonesArray *recpSPD = fDetTypeRec->ClustersAddress(kSPD);
216 Info("InitRec","idt = %#x; digSPD = %#x; recpSPD = %#x",fDetTypeRec,digSPD,recpSPD);
88cb7938 217 AliITSClusterFinderSPD *recSPD = new AliITSClusterFinderSPD(segSPD,digSPD,recpSPD);
7d62fb64 218 fDetTypeRec->SetReconstructionModel(kSPD,recSPD);
e69020a0 219 } // end if fDet[kSPD].
7d62fb64 220 // SDD
221 if(fDet[kSDD]){
222 Info("InitRec","SDD");
223 // idt = fITS->DetType(kSDD);
224 AliITSsegmentationSDD *segSDD = (AliITSsegmentationSDD*)
225 fDetTypeRec->GetSegmentationModel(1);
226 AliITSresponseSDD *resSDD = (AliITSresponseSDD*)
227 fDetTypeRec->GetCalibrationModel(fDetTypeRec->GetITSgeom()->GetStartSDD());
228 TClonesArray *digSDD = fDetTypeRec->DigitsAddress(kSDD);
229 TClonesArray *recpSDD = fDetTypeRec->ClustersAddress(kSDD);
230 AliITSClusterFinderSDD *recSDD =new AliITSClusterFinderSDD(segSDD,
231 resSDD,
232 digSDD,recpSDD);
233 fDetTypeRec->SetReconstructionModel(kSDD,recSDD);
234 } // end if fDet[kSDD]
e69020a0 235 // SSD
7d62fb64 236 if(fDet[kSSD]){
237 Info("InitRec","SSD");
238 //idt = fITS->DetType(kSSD);
239 AliITSsegmentationSSD *segSSD = (AliITSsegmentationSSD*)
240 fDetTypeRec->GetSegmentationModel(2);
241 TClonesArray *digSSD = fDetTypeRec->DigitsAddress(kSSD);
88cb7938 242 AliITSClusterFinderSSD *recSSD =new AliITSClusterFinderSSD(segSSD,
7d62fb64 243 digSSD);
244 recSSD->SetITSgeom(fDetTypeRec->GetITSgeom());
245 fDetTypeRec->SetReconstructionModel(kSSD,recSSD);
e69020a0 246 } // end if fDet[kSSD]
7d62fb64 247 */
248 fDetTypeRec->SetDefaultClusterFinders();
88cb7938 249 Info("InitRec"," Done\n");
e69020a0 250 return kTRUE;
251}
252//______________________________________________________________________
253void AliITSreconstruction::Exec(const Option_t *opt){
254 // Main reconstruction function.
255 // Inputs:
256 // Option_t * opt list of subdetector to digitize. =0 all.
257 // Outputs:
258 // none.
259 // Return:
260 // none.
261 Option_t *lopt;
88cb7938 262 Int_t evnt;
e69020a0 263
264 if(strstr(opt,"All")||strstr(opt,"ALL")||strstr(opt,"ITS")||opt==0){
88cb7938 265 fDet[0] = fDet[1] = fDet[2] = kTRUE;
266 lopt = "All";
e69020a0 267 }else{
88cb7938 268 fDet[0] = fDet[1] = fDet[2] = kFALSE;
269 if(strstr(opt,"SPD")) fDet[kSPD] = kTRUE;
270 if(strstr(opt,"SDD")) fDet[kSDD] = kTRUE;
271 if(strstr(opt,"SSD")) fDet[kSSD] = kTRUE;
272 if(fDet[kSPD] && fDet[kSDD] && fDet[kSSD]) lopt = "All";
273 else lopt = opt;
e69020a0 274 } // end if strstr(opt,...)
275
276 if(!fInit){
88cb7938 277 cout << "Initilization Failed, Can't run Exec." << endl;
278 return;
e69020a0 279 } // end if !fInit
88cb7938 280 for(evnt=0;evnt<fEnt;evnt++)
281 {
282 Info("Exec","");
283 Info("Exec","Processing Event %d",evnt);
284 Info("Exec","");
285
286 fRunLoader->GetEvent(evnt);
287 if (fLoader->TreeR() == 0x0) fLoader->MakeTree("R");
7d62fb64 288 fDetTypeRec->MakeBranchR(0);
289 if (fLoader->TreeC() == 0x0){
290 fDetTypeRec->MakeTreeC();
291 fDetTypeRec->MakeBranchC();
292 }
293 fDetTypeRec->SetTreeAddressR(fLoader->TreeR());
294 fDetTypeRec->SetTreeAddressD(fLoader->TreeD());
295 fDetTypeRec->DigitsToRecPoints(evnt,0,lopt);
e69020a0 296 } // end for evnt
f243fbe6 297}
298//______________________________________________________________________
299void AliITSreconstruction::SetOutputFile(TString filename){
999cc3eb 300 // Set a new file name for recpoints.
301 // It must be called before Init()
302 if(!fLoader)fLoader = (AliITSLoader*) fRunLoader->GetLoader("ITSLoader");
303 if(fLoader){
304 Info("SetOutputFile","name for rec points is %s",filename.Data());
305 fLoader->SetRecPointsFileName(filename);
306 }
307 else {
308 Error("SetOutputFile",
309 "ITS loader not available. Not possible to set name: %s",filename.Data());
310 }
e69020a0 311}