1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.4 2002/05/10 22:31:30 nilsen
19 Changes by Massimo Masera to allow Recpoints and Clusters to be written
22 Revision 1.3 2002/02/06 13:52:27 barbera
23 gAlice deletion corrected (from M. Masera)
25 Revision 1.2 2002/01/31 18:52:09 nilsen
26 Minor change to allow the use of files that are already open. grun.C macro
27 that also does ITS digitizationa and Reconstruction all in one go.
29 Revision 1.1 2002/01/30 22:20:22 nilsen
30 New TTask based method to do Digits To clusters. Works with files of multiple
31 events in the file. Macro added to show how to use. Also the changes made
32 in the nessesary complilation files.
37 #include <TSeqCollection.h>
39 #include <TClonesArray.h>
44 #include "AliITSDetType.h"
45 #include "AliITSreconstruction.h"
46 #include "AliITSsegmentationSPD.h"
47 #include "AliITSsegmentationSDD.h"
48 #include "AliITSsegmentationSSD.h"
49 #include "AliITSClusterFinderSPD.h"
50 #include "AliITSClusterFinderSDD.h"
51 #include "AliITSClusterFinderSSD.h"
52 #include "AliITSresponseSDD.h"
53 #include "AliITSgeom.h"
55 ClassImp(AliITSreconstruction)
57 //______________________________________________________________________
58 AliITSreconstruction::AliITSreconstruction(){
59 // Default constructor.
65 // A zero-ed constructed AliITSreconstruction class.
71 fDet[0] = fDet[1] = fDet[2] = kTRUE;
74 //______________________________________________________________________
75 AliITSreconstruction::AliITSreconstruction(const char* filename){
76 // Standard constructor.
78 // const char* filename filename containing the digits to be
79 // reconstructed. If filename = 0 (nil)
80 // then no file is opened but a file is
81 // assumed to already be opened. This
82 // already opened file will be used.
86 // A standardly constructed AliITSreconstruction class.
92 fFile = (TFile*)gROOT->GetListOfFiles()->FindObject(fFilename.Data());
93 if(fFile) fFile->Close();
94 fFile = new TFile(fFilename.Data(),"UPDATE");
99 gAlice = (AliRun*)fFile->Get("gAlice");
101 cout << "gAlice not found on file. Aborting." << endl;
105 } // end if !filename.
107 //______________________________________________________________________
108 AliITSreconstruction::~AliITSreconstruction(){
109 // Default constructor.
115 // A destroyed AliITSreconstruction class.
117 if(fFile) fFile->Close();
122 //______________________________________________________________________
123 Bool_t AliITSreconstruction::Init(){
130 // kTRUE if no errors initilizing this class occurse else kFALSE
132 fITS = (AliITS*) gAlice->GetDetector("ITS");
134 cout << "ITS not found aborting. fITS=" << fITS << endl;
138 if(!(fITS->GetITSgeom())){
139 cout << "ITSgeom not found aborting."<< endl;
142 } // end if !GetITSgeom()
143 // Now ready to init.
145 fDet[0] = fDet[1] = fDet[2] = kTRUE;
147 fEnt = gAlice->GetEventsPerRun();
149 nparticles = gAlice->GetEvent(fEnt0);
155 //______________________________________________________________________
156 Bool_t AliITSreconstruction::InitRec(){
157 // Sets up Reconstruction part of AliITSDetType..
168 idt = fITS->DetType(kSPD);
169 AliITSsegmentationSPD *segSPD = (AliITSsegmentationSPD*)
170 idt->GetSegmentationModel();
171 TClonesArray *digSPD = fITS->DigitsAddress(kSPD);
172 TClonesArray *recpSPD = fITS->ClustersAddress(kSPD);
173 AliITSClusterFinderSPD *recSPD = new AliITSClusterFinderSPD(segSPD,
176 fITS->SetReconstructionModel(kSPD,recSPD);
177 } // end if fDet[kSPD].
180 idt = fITS->DetType(kSDD);
181 AliITSsegmentationSDD *segSDD = (AliITSsegmentationSDD*)
182 idt->GetSegmentationModel();
183 AliITSresponseSDD *resSDD = (AliITSresponseSDD*)
184 idt->GetResponseModel();
185 TClonesArray *digSDD = fITS->DigitsAddress(kSDD);
186 TClonesArray *recpSDD = fITS->ClustersAddress(kSDD);
187 AliITSClusterFinderSDD *recSDD =new AliITSClusterFinderSDD(segSDD,
190 fITS->SetReconstructionModel(kSDD,recSDD);
191 } // end if fDet[kSDD]
194 idt = fITS->DetType(kSSD);
195 AliITSsegmentationSSD *segSSD = (AliITSsegmentationSSD*)
196 idt->GetSegmentationModel();
197 TClonesArray *digSSD = fITS->DigitsAddress(kSSD);
198 AliITSClusterFinderSSD *recSSD =new AliITSClusterFinderSSD(segSSD,
200 fITS->SetReconstructionModel(kSSD,recSSD);
201 } // end if fDet[kSSD]
205 //______________________________________________________________________
206 void AliITSreconstruction::Exec(const Option_t *opt){
207 // Main reconstruction function.
209 // Option_t * opt list of subdetector to digitize. =0 all.
215 Int_t nparticles,evnt;
217 if(strstr(opt,"All")||strstr(opt,"ALL")||strstr(opt,"ITS")||opt==0){
218 fDet[0] = fDet[1] = fDet[2] = kTRUE;
221 fDet[0] = fDet[1] = fDet[2] = kFALSE;
222 if(strstr(opt,"SPD")) fDet[kSPD] = kTRUE;
223 if(strstr(opt,"SDD")) fDet[kSDD] = kTRUE;
224 if(strstr(opt,"SSD")) fDet[kSSD] = kTRUE;
225 if(fDet[kSPD] && fDet[kSDD] && fDet[kSSD]) lopt = "All";
227 } // end if strstr(opt,...)
230 cout << "Initilization Failed, Can't run Exec." << endl;
233 TDirectory *curr = gDirectory;
234 if(fFile2)fFile2->cd();
235 for(evnt=0;evnt<fEnt;evnt++){
236 nparticles = gAlice->GetEvent(evnt);
237 gAlice->SetEvent(evnt);
238 if(!gAlice->TreeR()){
240 gAlice->MakeTree("R",fFile2);
243 gAlice->MakeTree("R");
246 fITS->MakeBranch("R");
248 fITS->DigitsToRecPoints(evnt,0,lopt);
252 //______________________________________________________________________
253 void AliITSreconstruction::SetOutputFile(TString filename){
254 // Set a file name for recpoints. Used only if this file is not the file
255 // containing digits. This obj is deleted by AliRun.
256 fFile2 = gAlice->InitTreeFile("R",filename);