]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSreconstruction.cxx
Change needed on alphacxx6
[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 /* $Id$ */
17 /////////////////////////////////////////////////////////////////////////
18 //                                                                     //
19 //                                                                     //
20 //                                                                     //
21 ////////////////////////////////////////////////////////////////////////
22
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"
30 #include "AliRunLoader.h"
31
32 #include "AliITS.h"
33 #include "AliITSDetType.h"
34 #include "AliITSLoader.h"
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
45 ClassImp(AliITSreconstruction)
46
47 //______________________________________________________________________
48 AliITSreconstruction::AliITSreconstruction():
49  fInit(kFALSE),
50  fEnt(0),
51  fEnt0(0),
52  fITS(0x0),
53  fDfArp(kFALSE),
54  fLoader(0x0),
55  fRunLoader(0x0)
56 {
57     // Default constructor.
58     // Inputs:
59     //  none.
60     // Outputs:
61     //   none.
62     // Return:
63     //    A zero-ed constructed AliITSreconstruction class.
64     fDet[0] = fDet[1] = fDet[2] = kTRUE;
65 }
66 //______________________________________________________________________
67
68 AliITSreconstruction::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;
78 }
79 //______________________________________________________________________
80 AliITSreconstruction::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 {
89     // Standard constructor.
90     // Inputs:
91     //  const char* filename    filename containing the digits to be
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.
96     // Outputs:
97     //   none.
98     // Return:
99     //    A standardly constructed AliITSreconstruction class.
100
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
118 }
119 //______________________________________________________________________
120 AliITSreconstruction::~AliITSreconstruction(){
121     //    A destroyed AliITSreconstruction class.
122     delete fRunLoader;
123     fITS      = 0;
124 }
125 //______________________________________________________________________
126 Bool_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
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");
151     if(!fITS){
152       cout << "ITS not found aborting. fITS=" << fITS << endl;
153       fInit = kFALSE;
154       return fInit;
155     } // end if !fITS
156     if(!(fITS->GetITSgeom())){
157       cout << "ITSgeom not found aborting."<< endl;
158       fInit = kFALSE;
159       return fInit;
160     } // end if !GetITSgeom()
161     // Now ready to init.
162
163     fDet[0] = fDet[1] = fDet[2] = kTRUE;
164     fEnt0 = 0;
165
166     //fEnt  = gAlice->GetEventsPerRun();
167     fEnt = Int_t(fRunLoader->TreeE()->GetEntries());
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();
176     fInit = InitRec();
177
178     Info("Init","  Done\n\n\n");
179
180     return fInit;
181 }
182 //______________________________________________________________________
183 Bool_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]){
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);
203     } // end if fDet[kSPD].
204     // SDD
205     if(fDet[kSDD]){
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);
218     } // end if fDet[kSDD]
219     // SSD
220     if(fDet[kSSD]){
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);
229     } // end if fDet[kSSD]
230     Info("InitRec","    Done\n");
231     return kTRUE;
232 }
233 //______________________________________________________________________ 
234 void 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;
243     Int_t evnt;
244
245     if(strstr(opt,"All")||strstr(opt,"ALL")||strstr(opt,"ITS")||opt==0){
246       fDet[0] = fDet[1] = fDet[2] = kTRUE;
247       lopt = "All";
248     }else{
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;
255     } // end if strstr(opt,...)
256
257     if(!fInit){
258       cout << "Initilization Failed, Can't run Exec." << endl;
259       return;
260     } // end if !fInit
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");
270       fITS->MakeBranch("R");
271       if (fLoader->TreeC() == 0x0) fITS->MakeTreeC();
272       fITS->SetTreeAddress();
273       fITS->DigitsToRecPoints(evnt,0,lopt);
274     } // end for evnt
275 }
276 //______________________________________________________________________ 
277 void AliITSreconstruction::SetOutputFile(TString filename){
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   }
289 }