fix to use default paramters for the SDD response.
[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
16/*
17$Log$
8f9d0004 18Revision 1.2 2002/01/31 18:52:09 nilsen
19Minor change to allow the use of files that are already open. grun.C macro
20that also does ITS digitizationa and Reconstruction all in one go.
21
3e9ba728 22Revision 1.1 2002/01/30 22:20:22 nilsen
23New TTask based method to do Digits To clusters. Works with files of multiple
24events in the file. Macro added to show how to use. Also the changes made
25in the nessesary complilation files.
26
e69020a0 27*/
28#include <TROOT.h>
29#include <TFile.h>
30#include <TSeqCollection.h>
31#include <TString.h>
32#include <TClonesArray.h>
33
34#include "AliRun.h"
35
36#include "AliITS.h"
37#include "AliITSDetType.h"
38#include "AliITSreconstruction.h"
39#include "AliITSsegmentationSPD.h"
40#include "AliITSsegmentationSDD.h"
41#include "AliITSsegmentationSSD.h"
42#include "AliITSClusterFinderSPD.h"
43#include "AliITSClusterFinderSDD.h"
44#include "AliITSClusterFinderSSD.h"
45#include "AliITSresponseSDD.h"
46#include "AliITSgeom.h"
47
48ClassImp(AliITSreconstruction)
49
50//______________________________________________________________________
51AliITSreconstruction::AliITSreconstruction(){
52 // Default constructor.
53 // Inputs:
54 // none.
55 // Outputs:
56 // none.
57 // Return:
58 // A zero-ed constructed AliITSreconstruction class.
59
60 fFilename = "";
61 fFile = 0;
62 fITS = 0;
63 fDet[0] = fDet[1] = fDet[2] = kTRUE;
64 fInit = kFALSE;
65}
66//______________________________________________________________________
67AliITSreconstruction::AliITSreconstruction(const char* filename){
68 // Standard constructor.
69 // Inputs:
70 // const char* filename filename containing the digits to be
3e9ba728 71 // reconstructed. If filename = 0 (nil)
72 // then no file is opened but a file is
73 // assumed to already be opened. This
74 // already opened file will be used.
e69020a0 75 // Outputs:
76 // none.
77 // Return:
78 // A standardly constructed AliITSreconstruction class.
79
80 fFilename = filename;
81
3e9ba728 82 if(filename){
83 fFile = (TFile*)gROOT->GetListOfFiles()->FindObject(fFilename.Data());
84 if(fFile) fFile->Close();
85 fFile = new TFile(fFilename.Data(),"UPDATE");
86 //
8f9d0004 87 if(gAlice) {
88 delete gAlice;
89 gAlice = 0;
90 }
3e9ba728 91 gAlice = (AliRun*)fFile->Get("gAlice");
92 if(!gAlice) {
93 cout << "gAlice not found on file. Aborting." << endl;
94 fInit = kFALSE;
95 return;
96 } // end if !gAlice
97 } // end if !filename.
e69020a0 98
99 Init();
100}
101//______________________________________________________________________
102AliITSreconstruction::~AliITSreconstruction(){
103 // Default constructor.
104 // Inputs:
105 // none.
106 // Outputs:
107 // none.
108 // Return:
109 // A destroyed AliITSreconstruction class.
110
111 if(fFile) fFile->Close();
112 fFile = 0;
113 fITS = 0;
114
115}
116//______________________________________________________________________
117Bool_t AliITSreconstruction::Init(){
118 // Class Initilizer.
119 // Inputs:
120 // none.
121 // Outputs:
122 // none.
123 // Return:
124 // kTRUE if no errors initilizing this class occurse else kFALSE
125 Int_t nparticles;
126
127 fITS = (AliITS*) gAlice->GetDetector("ITS");
128 if(!fITS){
129 cout << "ITS not found aborting. fITS=" << fITS << endl;
130 fInit = kFALSE;
131 return fInit;
132 } // end if !fITS
133 if(!(fITS->GetITSgeom())){
134 cout << "ITSgeom not found aborting."<< endl;
135 fInit = kFALSE;
136 return fInit;
137 } // end if !GetITSgeom()
138 // Now ready to init.
139
140 fDet[0] = fDet[1] = fDet[2] = kTRUE;
141 fEnt0 = 0;
142 fEnt = gAlice->GetEventsPerRun();
143 fITS->MakeTreeC();
144 nparticles = gAlice->GetEvent(fEnt0);
145
146 // finished init.
147 fInit = InitRec();
148 return fInit;
149}
150//______________________________________________________________________
151Bool_t AliITSreconstruction::InitRec(){
152 // Sets up Reconstruction part of AliITSDetType..
153 // Inputs:
154 // none.
155 // Outputs:
156 // none.
157 // Return:
158 // none.
159 AliITSDetType *idt;
160
161 // SPD
162 if(fDet[kSPD]){
163 idt = fITS->DetType(kSPD);
164 AliITSsegmentationSPD *segSPD = (AliITSsegmentationSPD*)
165 idt->GetSegmentationModel();
166 TClonesArray *digSPD = fITS->DigitsAddress(kSPD);
167 TClonesArray *recpSPD = fITS->ClustersAddress(kSPD);
168 AliITSClusterFinderSPD *recSPD = new AliITSClusterFinderSPD(segSPD,
169 digSPD,
170 recpSPD);
171 fITS->SetReconstructionModel(kSPD,recSPD);
172 } // end if fDet[kSPD].
173 // SDD
174 if(fDet[kSDD]){
175 idt = fITS->DetType(kSDD);
176 AliITSsegmentationSDD *segSDD = (AliITSsegmentationSDD*)
177 idt->GetSegmentationModel();
178 AliITSresponseSDD *resSDD = (AliITSresponseSDD*)
179 idt->GetResponseModel();
180 TClonesArray *digSDD = fITS->DigitsAddress(kSDD);
181 TClonesArray *recpSDD = fITS->ClustersAddress(kSDD);
182 AliITSClusterFinderSDD *recSDD =new AliITSClusterFinderSDD(segSDD,
183 resSDD,
184 digSDD,recpSDD);
185 fITS->SetReconstructionModel(kSDD,recSDD);
186 } // end if fDet[kSDD]
187 // SSD
188 if(fDet[kSSD]){
189 idt = fITS->DetType(kSSD);
190 AliITSsegmentationSSD *segSSD = (AliITSsegmentationSSD*)
191 idt->GetSegmentationModel();
192 TClonesArray *digSSD = fITS->DigitsAddress(kSSD);
193 AliITSClusterFinderSSD *recSSD =new AliITSClusterFinderSSD(segSSD,
194 digSSD);
195 fITS->SetReconstructionModel(kSSD,recSSD);
196 } // end if fDet[kSSD]
197
198 return kTRUE;
199}
200//______________________________________________________________________
201void AliITSreconstruction::Exec(const Option_t *opt){
202 // Main reconstruction function.
203 // Inputs:
204 // Option_t * opt list of subdetector to digitize. =0 all.
205 // Outputs:
206 // none.
207 // Return:
208 // none.
209 Option_t *lopt;
210 Int_t nparticles,evnt;
211
212 if(strstr(opt,"All")||strstr(opt,"ALL")||strstr(opt,"ITS")||opt==0){
213 fDet[0] = fDet[1] = fDet[2] = kTRUE;
214 lopt = "All";
215 }else{
216 fDet[0] = fDet[1] = fDet[2] = kFALSE;
217 if(strstr(opt,"SPD")) fDet[kSPD] = kTRUE;
218 if(strstr(opt,"SDD")) fDet[kSDD] = kTRUE;
219 if(strstr(opt,"SSD")) fDet[kSSD] = kTRUE;
220 if(fDet[kSPD] && fDet[kSDD] && fDet[kSSD]) lopt = "All";
221 else lopt = opt;
222 } // end if strstr(opt,...)
223
224 if(!fInit){
225 cout << "Initilization Failed, Can't run Exec." << endl;
226 return;
227 } // end if !fInit
228 for(evnt=0;evnt<fEnt;evnt++){
229 nparticles = gAlice->GetEvent(evnt);
230 gAlice->SetEvent(evnt);
231 if(!gAlice->TreeR()) gAlice->MakeTree("R");
232 fITS->MakeBranch("R");
233 fITS->DigitsToRecPoints(evnt,0,lopt);
234 } // end for evnt
235}