]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSreconstruction.cxx
Remove compilation of grndmq
[u/mrichter/AliRoot.git] / ITS / AliITSreconstruction.cxx
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$
18 Revision 1.4  2002/05/10 22:31:30  nilsen
19 Changes by Massimo Masera to allow Recpoints and Clusters to be written
20 to separate files.
21
22 Revision 1.3  2002/02/06 13:52:27  barbera
23 gAlice deletion corrected (from M. Masera)
24
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.
28
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.
33
34 */
35 #include <TROOT.h>
36 #include <TFile.h>
37 #include <TSeqCollection.h>
38 #include <TString.h>
39 #include <TClonesArray.h>
40
41 #include "AliRun.h"
42
43 #include "AliITS.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"
54
55 ClassImp(AliITSreconstruction)
56
57 //______________________________________________________________________
58 AliITSreconstruction::AliITSreconstruction(){
59     // Default constructor.
60     // Inputs:
61     //  none.
62     // Outputs:
63     //   none.
64     // Return:
65     //    A zero-ed constructed AliITSreconstruction class.
66
67     fFilename = "";
68     fFile     = 0;
69     fFile2    = 0;
70     fITS      = 0;
71     fDet[0] = fDet[1] = fDet[2] = kTRUE;
72     fInit     = kFALSE;
73 }
74 //______________________________________________________________________
75 AliITSreconstruction::AliITSreconstruction(const char* filename){
76     // Standard constructor.
77     // Inputs:
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.
83     // Outputs:
84     //   none.
85     // Return:
86     //    A standardly constructed AliITSreconstruction class.
87
88     fFilename = filename;
89     fFile2 = 0;
90     fFile = 0;
91     if(filename){
92         fFile = (TFile*)gROOT->GetListOfFiles()->FindObject(fFilename.Data());
93         if(fFile) fFile->Close();
94         fFile = new TFile(fFilename.Data(),"UPDATE");
95     if(gAlice) {
96       delete gAlice;
97       gAlice = 0;
98     }
99         gAlice = (AliRun*)fFile->Get("gAlice");
100         if(!gAlice) {
101             cout << "gAlice not found on file. Aborting." << endl;
102             fInit = kFALSE;
103             return;
104         } // end if !gAlice
105     } // end if !filename.
106 }
107 //______________________________________________________________________
108 AliITSreconstruction::~AliITSreconstruction(){
109     // Default constructor.
110     // Inputs:
111     //  none.
112     // Outputs:
113     //   none.
114     // Return:
115     //    A destroyed AliITSreconstruction class.
116
117     if(fFile) fFile->Close();
118     fFile     = 0;
119     fITS      = 0;
120     
121 }
122 //______________________________________________________________________
123 Bool_t AliITSreconstruction::Init(){
124     // Class Initilizer.
125     // Inputs:
126     //  none.
127     // Outputs:
128     //   none.
129     // Return:
130     //    kTRUE if no errors initilizing this class occurse else kFALSE
131     Int_t nparticles;
132     fITS = (AliITS*) gAlice->GetDetector("ITS");
133     if(!fITS){
134         cout << "ITS not found aborting. fITS=" << fITS << endl;
135         fInit = kFALSE;
136         return fInit;
137     } // end if !fITS
138     if(!(fITS->GetITSgeom())){
139         cout << "ITSgeom not found aborting."<< endl;
140         fInit = kFALSE;
141         return fInit;
142     } // end if !GetITSgeom()
143     // Now ready to init.
144
145     fDet[0] = fDet[1] = fDet[2] = kTRUE;
146     fEnt0 = 0;
147     fEnt  = gAlice->GetEventsPerRun();
148     fITS->MakeTreeC();
149     nparticles = gAlice->GetEvent(fEnt0);
150     
151     // finished init.
152     fInit = InitRec();
153     return fInit;
154 }
155 //______________________________________________________________________
156 Bool_t AliITSreconstruction::InitRec(){
157     // Sets up Reconstruction part of AliITSDetType..
158     // Inputs:
159     //      none.
160     // Outputs:
161     //      none.
162     // Return:
163     //      none.
164     AliITSDetType *idt;
165
166     // SPD
167     if(fDet[kSPD]){
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,
174                                                                     digSPD,
175                                                                     recpSPD);
176         fITS->SetReconstructionModel(kSPD,recSPD);
177     } // end if fDet[kSPD].
178     // SDD
179     if(fDet[kSDD]){
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,
188                                                                    resSDD,
189                                                                digSDD,recpSDD);
190         fITS->SetReconstructionModel(kSDD,recSDD);
191     } // end if fDet[kSDD]
192     // SSD
193     if(fDet[kSSD]){
194         idt = fITS->DetType(kSSD);
195         AliITSsegmentationSSD *segSSD = (AliITSsegmentationSSD*)
196                                          idt->GetSegmentationModel();
197         TClonesArray *digSSD = fITS->DigitsAddress(kSSD);
198         AliITSClusterFinderSSD *recSSD =new AliITSClusterFinderSSD(segSSD,
199                                                                    digSSD);
200         fITS->SetReconstructionModel(kSSD,recSSD);
201     } // end if fDet[kSSD]
202
203     return kTRUE;
204 }
205 //______________________________________________________________________ 
206 void AliITSreconstruction::Exec(const Option_t *opt){
207     // Main reconstruction function.
208     // Inputs:
209     //      Option_t * opt   list of subdetector to digitize. =0 all.
210     // Outputs:
211     //      none.
212     // Return:
213     //      none.
214     Option_t *lopt;
215     Int_t nparticles,evnt;
216
217     if(strstr(opt,"All")||strstr(opt,"ALL")||strstr(opt,"ITS")||opt==0){
218         fDet[0] = fDet[1] = fDet[2] = kTRUE;
219         lopt = "All";
220     }else{
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";
226         else lopt = opt;
227     } // end if strstr(opt,...)
228
229     if(!fInit){
230         cout << "Initilization Failed, Can't run Exec." << endl;
231         return;
232     } // end if !fInit
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()){
239         if(fFile2){
240           gAlice->MakeTree("R",fFile2);
241         }
242         else {
243           gAlice->MakeTree("R");
244         }
245       }
246       fITS->MakeBranch("R");
247       fITS->MakeTreeC();
248       fITS->DigitsToRecPoints(evnt,0,lopt);
249     } // end for evnt
250     curr->cd();
251 }
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);
257 }
258
259
260
261
262