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