]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSReconstructor.cxx
Do not delete the loader, it is not owned by the class. Remove clusters to avoid...
[u/mrichter/AliRoot.git] / ITS / AliITSReconstructor.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 // class for ITS reconstruction                                              //
21 //                                                                           //
22 ///////////////////////////////////////////////////////////////////////////////
23
24 #include "Riostream.h"
25 #include "AliITSReconstructor.h"
26 #include "AliRun.h"
27 #include "AliRunLoader.h"
28 #include "AliRawReader.h"
29 #include "AliITSDetTypeRec.h"
30 #include "AliITSLoader.h"
31 #include "AliITStrackerMI.h"
32 #include "AliITStrackerV2.h"
33 #include "AliITStrackerSA.h"
34 #include "AliITSVertexerIons.h"
35 #include "AliITSVertexerFast.h"
36 #include "AliITSVertexer3D.h"
37 #include "AliITSVertexerZ.h"
38 #include "AliITSVertexerCosmics.h"
39 #include "AliESDEvent.h"
40 #include "AliITSpidESD.h"
41 #include "AliITSpidESD1.h"
42 #include "AliITSpidESD2.h"
43 #include "AliITSInitGeometry.h"
44
45
46 ClassImp(AliITSReconstructor)
47
48 AliITSRecoParam *AliITSReconstructor::fgkRecoParam =0;  // reconstruction parameters
49
50 //___________________________________________________________________________
51 AliITSReconstructor::AliITSReconstructor() : AliReconstructor(),
52 fItsPID(0)
53 {
54   // Default constructor
55   if (!fgkRecoParam) {
56     AliError("The Reconstruction parameters nonitialized - Used default one");
57     fgkRecoParam = AliITSRecoParam::GetHighFluxParam();
58   }
59 }
60  //___________________________________________________________________________
61 AliITSReconstructor::~AliITSReconstructor(){
62 // destructor
63   delete fItsPID;
64   if(fgkRecoParam) delete fgkRecoParam;
65
66 //______________________________________________________________________
67 AliITSReconstructor::AliITSReconstructor(const AliITSReconstructor &ob) :AliReconstructor(ob),
68                                                                          fItsPID(ob.fItsPID)
69 {
70   // Copy constructor
71 }
72
73 //______________________________________________________________________
74 AliITSReconstructor& AliITSReconstructor::operator=(const AliITSReconstructor&  ob ){
75   // Assignment operator
76   this->~AliITSReconstructor();
77   new(this) AliITSReconstructor(ob);
78   return *this;
79 }
80 //______________________________________________________________________
81 void AliITSReconstructor::Init(AliRunLoader *runLoader) const{
82     // Initalize this constructor bet getting/creating the objects
83     // nesseary for a proper ITS reconstruction.
84     // Inputs:
85     //    AliRunLoader *runLoader   Pointer to the run loader to allow
86     //                              the getting of files/folders data
87     //                              needed to do reconstruction
88     // Output:
89     //   none.
90     // Return:
91     //   none.
92
93     AliITSInitGeometry initgeom;
94     AliITSgeom *geom = initgeom.CreateAliITSgeom();
95     AliInfo(Form("Geometry name: %s",(initgeom.GetGeometryName()).Data()));
96     AliITSLoader* loader = static_cast<AliITSLoader*>
97         (runLoader->GetLoader("ITSLoader"));
98     if (!loader) {
99         Error("Init", "ITS loader not found");
100         return;
101     }
102     loader->SetITSgeom(geom);
103     return;
104 }
105 //_____________________________________________________________________________
106 void AliITSReconstructor::Reconstruct(AliRunLoader* runLoader) const
107 {
108 // reconstruct clusters
109
110
111   AliITSLoader* loader = static_cast<AliITSLoader*>(runLoader->GetLoader("ITSLoader"));
112   if (!loader) {
113     Error("Reconstruct", "ITS loader not found");
114     return;
115   }
116   AliITSDetTypeRec* rec = new AliITSDetTypeRec(loader);
117   rec->SetDefaults();
118
119   loader->LoadRecPoints("recreate");
120   loader->LoadDigits("read");
121   runLoader->LoadKinematics();
122   TString option = GetOption();
123   Bool_t clusfinder=kTRUE;   // Default: V2 cluster finder
124   if(option.Contains("OrigCF"))clusfinder=kFALSE;
125
126   Int_t nEvents = runLoader->GetNumberOfEvents();
127
128   for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
129     runLoader->GetEvent(iEvent);
130     if(loader->TreeR()==0x0) loader->MakeTree("R");
131     rec->MakeBranch("R");
132     rec->SetTreeAddress();
133     rec->DigitsToRecPoints(iEvent,0,"All",clusfinder);    
134   }
135
136   loader->UnloadRecPoints();
137   loader->UnloadDigits();
138   runLoader->UnloadKinematics();
139 }
140
141 //_________________________________________________________________
142 void AliITSReconstructor::Reconstruct(AliRunLoader* runLoader, 
143                                       AliRawReader* rawReader) const
144 {
145 // reconstruct clusters
146
147  
148   AliITSLoader* loader = static_cast<AliITSLoader*>(runLoader->GetLoader("ITSLoader"));
149   if (!loader) {
150     Error("Reconstruct", "ITS loader not found");
151     return;
152   }
153
154   AliITSDetTypeRec* rec = new AliITSDetTypeRec(loader);
155   rec->SetDefaults();
156   rec->SetDefaultClusterFindersV2(kTRUE);
157
158   loader->LoadRecPoints("recreate");
159
160   Int_t iEvent = 0;
161
162   while(rawReader->NextEvent()) {
163     runLoader->GetEvent(iEvent++);
164     if(loader->TreeR()==0x0) loader->MakeTree("R");
165     rec->DigitsToRecPoints(rawReader);
166   }
167
168   loader->UnloadRecPoints();
169 }
170
171 //_____________________________________________________________________________
172 AliTracker* AliITSReconstructor::CreateTracker(AliRunLoader* runLoader)const
173 {
174 // create a ITS tracker
175
176   
177   TString selectedTracker = GetOption();
178   AliTracker* tracker;    
179   if (selectedTracker.Contains("MI")) {
180     tracker = new AliITStrackerMI(0);
181   }  
182   else if (selectedTracker.Contains("V2")) {
183     tracker = new AliITStrackerV2(0);
184   }
185   else {
186     tracker =  new AliITStrackerSA(0);  // inherits from AliITStrackerMI
187     AliITStrackerSA *sat=(AliITStrackerSA*)tracker;
188     if(selectedTracker.Contains("onlyITS"))sat->SetSAFlag(kTRUE);
189     if(sat->GetSAFlag())AliDebug(1,"Tracking Performed in ITS only\n");
190     if(selectedTracker.Contains("cosmics")||selectedTracker.Contains("COSMICS"))
191       sat->SetOuterStartLayer(AliITSgeomTGeo::GetNLayers()-2);
192   }
193
194   TString selectedPIDmethod = GetOption();
195   AliITSLoader *loader = (AliITSLoader*)runLoader->GetLoader("ITSLoader");
196   if (!loader) {
197     Error("CreateTracker", "ITS loader not found");
198   }
199   if(selectedPIDmethod.Contains("LandauFitPID")){
200     loader->AdoptITSpid(new AliITSpidESD2((AliITStrackerMI*)tracker,loader));
201   }
202   else{
203     Double_t parITS[] = {0.15, 10.}; //PH positions of the MIP peak
204     loader->AdoptITSpid(new AliITSpidESD1(parITS));
205   }
206   return tracker;
207   
208 }
209
210 //_____________________________________________________________________________
211 AliVertexer* AliITSReconstructor::CreateVertexer(AliRunLoader* /*runLoader*/) const
212 {
213 // create a ITS vertexer
214
215   TString selectedVertexer = GetOption();
216   if(selectedVertexer.Contains("ions") || selectedVertexer.Contains("IONS")){
217     Info("CreateVertexer","a AliITSVertexerIons object has been selected\n");
218     return new AliITSVertexerIons("null");
219   }
220   if(selectedVertexer.Contains("smear") || selectedVertexer.Contains("SMEAR")){
221     Double_t smear[3]={0.005,0.005,0.01};
222     Info("CreateVertexer","a AliITSVertexerFast object has been selected\n"); 
223     return new AliITSVertexerFast(smear);
224   }
225   if(selectedVertexer.Contains("3d") || selectedVertexer.Contains("3D")){
226     Info("CreateVertexer","a AliITSVertexer3D object has been selected\n");
227     return new AliITSVertexer3D("null");
228   }
229   if(selectedVertexer.Contains("cosmics") || selectedVertexer.Contains("COSMICS")){
230     Info("CreateVertexer","a AliITSVertexerCosmics object has been selected\n");
231     return new AliITSVertexerCosmics();
232   }
233   // by default an AliITSVertexerZ object is instatiated
234   Info("CreateVertexer","a AliITSVertexerZ object has been selected\n");
235   return new AliITSVertexerZ("null");
236 }
237
238 //_____________________________________________________________________________
239 void AliITSReconstructor::FillESD(AliRunLoader* runLoader, 
240                                   AliESDEvent* esd) const
241 {
242 // make PID, find V0s and cascade
243   AliITSLoader *loader = (AliITSLoader*)runLoader->GetLoader("ITSLoader");
244   AliITSpidESD *pidESD = 0;
245   TString selectedPIDmethod = GetOption();
246   if(selectedPIDmethod.Contains("LandauFitPID")){
247     Info("FillESD","ITS LandauFitPID option has been selected\n");
248     pidESD=loader->GetITSpid();
249   }
250   else{
251     Info("FillESD","ITS default PID\n");
252     pidESD=loader->GetITSpid();
253   }
254   if(pidESD!=0){
255     pidESD->MakePID(esd);
256   }
257   else {
258     Error("FillESD","!! cannot do the PID !!\n");
259   }
260 }
261
262
263 //_____________________________________________________________________________
264 AliITSgeom* AliITSReconstructor::GetITSgeom(AliRunLoader* runLoader) const
265 {
266 // get the ITS geometry
267
268   if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
269   if (!runLoader->GetAliRun()) {
270     Error("GetITSgeom", "couldn't get AliRun object");
271     return NULL;
272   }
273   AliITSLoader *loader = (AliITSLoader*)runLoader->GetLoader("ITSLoader");
274   AliITSgeom* geom = (AliITSgeom*)loader->GetITSgeom();
275   if(!geom){
276     Error("GetITSgeom","no ITS geometry available");
277     return NULL;
278   }
279   
280   return geom;
281 }