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