]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - ITS/AliITSreconstruction.cxx
Added new creator which passes a pointer to type AliRun. Can now use either
[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/*
17$Log$
18Revision 1.5 2002/05/13 14:27:57 hristov
19TreeC created once per event (M.Masera)
20
21Revision 1.4 2002/05/10 22:31:30 nilsen
22Changes by Massimo Masera to allow Recpoints and Clusters to be written
23to separate files.
24
25Revision 1.3 2002/02/06 13:52:27 barbera
26gAlice deletion corrected (from M. Masera)
27
28Revision 1.2 2002/01/31 18:52:09 nilsen
29Minor change to allow the use of files that are already open. grun.C macro
30that also does ITS digitizationa and Reconstruction all in one go.
31
32Revision 1.1 2002/01/30 22:20:22 nilsen
33New TTask based method to do Digits To clusters. Works with files of multiple
34events in the file. Macro added to show how to use. Also the changes made
35in the nessesary complilation files.
36
37*/
38#include <TROOT.h>
39#include <TFile.h>
40#include <TSeqCollection.h>
41#include <TString.h>
42#include <TClonesArray.h>
43
44#include "AliRun.h"
45
46#include "AliITS.h"
47#include "AliITSDetType.h"
48#include "AliITSreconstruction.h"
49#include "AliITSsegmentationSPD.h"
50#include "AliITSsegmentationSDD.h"
51#include "AliITSsegmentationSSD.h"
52#include "AliITSClusterFinderSPD.h"
53#include "AliITSClusterFinderSDD.h"
54#include "AliITSClusterFinderSSD.h"
55#include "AliITSresponseSDD.h"
56#include "AliITSgeom.h"
57
58ClassImp(AliITSreconstruction)
59
60//______________________________________________________________________
61AliITSreconstruction::AliITSreconstruction(){
62 // Default constructor.
63 // Inputs:
64 // none.
65 // Outputs:
66 // none.
67 // Return:
68 // A zero-ed constructed AliITSreconstruction class.
69
70 fFilename = "";
71 fFile = 0;
72 fFile2 = 0;
73 fITS = 0;
74 fDet[0] = fDet[1] = fDet[2] = kTRUE;
75 fInit = kFALSE;
76 fArp = 0;
77 fDfArp = kFALSE;
78}
79//______________________________________________________________________
80AliITSreconstruction::AliITSreconstruction(AliRun *ar){
81 // Standard constructor.
82 // Inputs:
83 // AliRun *ar Pointer to an existing AliRun object. Assumed that
84 // this AliRun object will not be deleted by this distructor.
85 // Outputs:
86 // none.
87 // Return:
88 // A standardly constructed AliITSreconstruction class.
89
90 fFilename = "";
91 fFile = 0;
92 fFile2 = 0;
93 fITS = 0;
94 fDet[0] = fDet[1] = fDet[2] = kTRUE;
95 fInit = kFALSE;
96 fDfArp = kFALSE;
97 fArp = ar;
98}
99//______________________________________________________________________
100AliITSreconstruction::AliITSreconstruction(const char* filename){
101 // Standard constructor.
102 // Inputs:
103 // const char* filename filename containing the digits to be
104 // reconstructed. If filename = 0 (nil)
105 // then no file is opened but a file is
106 // assumed to already be opened. This
107 // already opened file will be used.
108 // Outputs:
109 // none.
110 // Return:
111 // A standardly constructed AliITSreconstruction class.
112
113 fFilename = filename;
114 fFile2 = 0;
115 fFile = 0;
116 fArp = 0;
117 fDfArp = kTRUE;
118 if(filename){
119 fFile = (TFile*)gROOT->GetListOfFiles()->FindObject(fFilename.Data());
120 if(fFile) fFile->Close();
121 fFile = new TFile(fFilename.Data(),"UPDATE");
122 if(fArp) {
123 delete fArp;
124 fArp = 0;
125 }
126 fArp = (AliRun*)fFile->Get("gAlice");
127 if(!fArp) {
128 cout << "gAlice not found on file. Aborting." << endl;
129 fInit = kFALSE;
130 return;
131 } // end if !fArp
132 } // end if !filename.
133}
134//______________________________________________________________________
135AliITSreconstruction::~AliITSreconstruction(){
136 // Default constructor.
137 // Inputs:
138 // none.
139 // Outputs:
140 // none.
141 // Return:
142 // A destroyed AliITSreconstruction class.
143
144 if(fFile) fFile->Close();
145 fFile = 0;
146 fITS = 0;
147 if(fDfArp){
148 if(fArp) delete fArp;
149 } // end if
150}
151//______________________________________________________________________
152Bool_t AliITSreconstruction::Init(){
153 // Class Initilizer.
154 // Inputs:
155 // none.
156 // Outputs:
157 // none.
158 // Return:
159 // kTRUE if no errors initilizing this class occurse else kFALSE
160 Int_t nparticles;
161 fITS = (AliITS*) fArp->GetDetector("ITS");
162 if(!fITS){
163 cout << "ITS not found aborting. fITS=" << fITS << endl;
164 fInit = kFALSE;
165 return fInit;
166 } // end if !fITS
167 if(!(fITS->GetITSgeom())){
168 cout << "ITSgeom not found aborting."<< endl;
169 fInit = kFALSE;
170 return fInit;
171 } // end if !GetITSgeom()
172 // Now ready to init.
173
174 fDet[0] = fDet[1] = fDet[2] = kTRUE;
175 fEnt0 = 0;
176 fEnt = fArp->GetEventsPerRun();
177 fITS->MakeTreeC();
178 nparticles = fArp->GetEvent(fEnt0);
179
180 // finished init.
181 fInit = InitRec();
182 return fInit;
183}
184//______________________________________________________________________
185Bool_t AliITSreconstruction::InitRec(){
186 // Sets up Reconstruction part of AliITSDetType..
187 // Inputs:
188 // none.
189 // Outputs:
190 // none.
191 // Return:
192 // none.
193 AliITSDetType *idt;
194
195 // SPD
196 if(fDet[kSPD]){
197 idt = fITS->DetType(kSPD);
198 AliITSsegmentationSPD *segSPD = (AliITSsegmentationSPD*)
199 idt->GetSegmentationModel();
200 TClonesArray *digSPD = fITS->DigitsAddress(kSPD);
201 TClonesArray *recpSPD = fITS->ClustersAddress(kSPD);
202 AliITSClusterFinderSPD *recSPD = new AliITSClusterFinderSPD(segSPD,
203 digSPD,
204 recpSPD);
205 fITS->SetReconstructionModel(kSPD,recSPD);
206 } // end if fDet[kSPD].
207 // SDD
208 if(fDet[kSDD]){
209 idt = fITS->DetType(kSDD);
210 AliITSsegmentationSDD *segSDD = (AliITSsegmentationSDD*)
211 idt->GetSegmentationModel();
212 AliITSresponseSDD *resSDD = (AliITSresponseSDD*)
213 idt->GetResponseModel();
214 TClonesArray *digSDD = fITS->DigitsAddress(kSDD);
215 TClonesArray *recpSDD = fITS->ClustersAddress(kSDD);
216 AliITSClusterFinderSDD *recSDD =new AliITSClusterFinderSDD(segSDD,
217 resSDD,
218 digSDD,recpSDD);
219 fITS->SetReconstructionModel(kSDD,recSDD);
220 } // end if fDet[kSDD]
221 // SSD
222 if(fDet[kSSD]){
223 idt = fITS->DetType(kSSD);
224 AliITSsegmentationSSD *segSSD = (AliITSsegmentationSSD*)
225 idt->GetSegmentationModel();
226 TClonesArray *digSSD = fITS->DigitsAddress(kSSD);
227 AliITSClusterFinderSSD *recSSD =new AliITSClusterFinderSSD(segSSD,
228 digSSD);
229 fITS->SetReconstructionModel(kSSD,recSSD);
230 } // end if fDet[kSSD]
231
232 return kTRUE;
233}
234//______________________________________________________________________
235void AliITSreconstruction::Exec(const Option_t *opt){
236 // Main reconstruction function.
237 // Inputs:
238 // Option_t * opt list of subdetector to digitize. =0 all.
239 // Outputs:
240 // none.
241 // Return:
242 // none.
243 Option_t *lopt;
244 Int_t nparticles,evnt;
245
246 if(strstr(opt,"All")||strstr(opt,"ALL")||strstr(opt,"ITS")||opt==0){
247 fDet[0] = fDet[1] = fDet[2] = kTRUE;
248 lopt = "All";
249 }else{
250 fDet[0] = fDet[1] = fDet[2] = kFALSE;
251 if(strstr(opt,"SPD")) fDet[kSPD] = kTRUE;
252 if(strstr(opt,"SDD")) fDet[kSDD] = kTRUE;
253 if(strstr(opt,"SSD")) fDet[kSSD] = kTRUE;
254 if(fDet[kSPD] && fDet[kSDD] && fDet[kSSD]) lopt = "All";
255 else lopt = opt;
256 } // end if strstr(opt,...)
257
258 if(!fInit){
259 cout << "Initilization Failed, Can't run Exec." << endl;
260 return;
261 } // end if !fInit
262 TDirectory *curr = gDirectory;
263 if(fFile2)fFile2->cd();
264 for(evnt=0;evnt<fEnt;evnt++){
265 nparticles = fArp->GetEvent(evnt);
266 fArp->SetEvent(evnt);
267 if(!fArp->TreeR()){
268 if(fFile2){
269 fArp->MakeTree("R",fFile2);
270 }
271 else {
272 fArp->MakeTree("R");
273 }
274 }
275 fITS->MakeBranch("R");
276 fITS->MakeTreeC();
277 fITS->DigitsToRecPoints(evnt,0,lopt);
278 } // end for evnt
279 curr->cd();
280}
281//______________________________________________________________________
282void AliITSreconstruction::SetOutputFile(TString filename){
283 // Set a file name for recpoints. Used only if this file is not the file
284 // containing digits. This obj is deleted by AliRun.
285 fFile2 = fArp->InitTreeFile("R",filename);
286}
287
288
289
290
291