]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSReconstructor.cxx
29-apr-2005 Library creation scripts for Linux gcc etc... introduced.
[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
25 #include "AliITSReconstructor.h"
26 #include "AliRunLoader.h"
27 #include "AliRawReader.h"
28 #include "AliITSclustererV2.h"
29 #include "AliITStrackerMI.h"
30 #include "AliITStrackerSA.h"
31 #include "AliITSVertexerIons.h"
32 #include "AliITSVertexerFast.h"
33 #include "AliITSVertexerPPZ.h"
34 #include "AliITSVertexerZ.h"
35 #include "AliESD.h"
36 #include "AliITSpidESD.h"
37 #include "AliV0vertexer.h"
38 #include "AliCascadeVertexer.h"
39 #include "AliRun.h"
40 #include "AliITS.h"
41
42
43 ClassImp(AliITSReconstructor)
44
45
46 //_____________________________________________________________________________
47 void AliITSReconstructor::Reconstruct(AliRunLoader* runLoader) const
48 {
49 // reconstruct clusters
50
51   AliLoader* loader = runLoader->GetLoader("ITSLoader");
52   if (!loader) {
53     Error("Reconstruct", "ITS loader not found");
54     return;
55   }
56   loader->LoadRecPoints("recreate");
57   loader->LoadDigits("read");
58   runLoader->LoadKinematics();
59
60   AliITSgeom* geom = GetITSgeom(runLoader);
61   if (!geom) return;
62   AliITSclustererV2 clusterer(geom);
63   Int_t nEvents = runLoader->GetNumberOfEvents();
64
65   for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
66     runLoader->GetEvent(iEvent);
67
68     TTree* treeClusters = loader->TreeR();
69     if (!treeClusters) {
70       loader->MakeTree("R");
71       treeClusters = loader->TreeR();
72     }
73     TTree* treeDigits = loader->TreeD();
74     if (!treeDigits) {
75       Error("Reconstruct", "Can't get digits tree !");
76       return;
77     }
78
79     clusterer.Digits2Clusters(treeDigits, treeClusters);
80          
81     loader->WriteRecPoints("OVERWRITE");
82   }
83
84   loader->UnloadRecPoints();
85   loader->UnloadDigits();
86   runLoader->UnloadKinematics();
87 }
88
89 //_____________________________________________________________________________
90 void AliITSReconstructor::Reconstruct(AliRunLoader* runLoader,
91                                       AliRawReader* rawReader) const
92 {
93 // reconstruct clusters from raw data
94
95   AliLoader* loader = runLoader->GetLoader("ITSLoader");
96   if (!loader) {
97     Error("Reconstruct", "ITS loader not found");
98     return;
99   }
100   loader->LoadRecPoints("recreate");
101
102   AliITSgeom* geom = GetITSgeom(runLoader);
103   if (!geom) return;
104   AliITSclustererV2 clusterer(geom);
105
106   Int_t iEvent = 0;
107   while (rawReader->NextEvent()) {
108     runLoader->GetEvent(iEvent++);
109
110     TTree* treeClusters = loader->TreeR();
111     if (!treeClusters) {
112       loader->MakeTree("R");
113       treeClusters = loader->TreeR();
114     }
115
116     clusterer.Digits2Clusters(rawReader);
117          
118     loader->WriteRecPoints("OVERWRITE");
119   }
120
121   loader->UnloadRecPoints();
122 }
123
124 //_____________________________________________________________________________
125 AliTracker* AliITSReconstructor::CreateTracker(AliRunLoader* runLoader) const
126 {
127 // create a ITS tracker
128
129   AliITSgeom* geom = GetITSgeom(runLoader);
130   if (!geom) return NULL; 
131   TString selectedTracker = GetOption();
132   if (selectedTracker.Contains("MI")) return new AliITStrackerMI(geom);
133   return new AliITStrackerSA(geom);
134 }
135
136 //_____________________________________________________________________________
137 AliVertexer* AliITSReconstructor::CreateVertexer(AliRunLoader* /*runLoader*/) const
138 {
139 // create a ITS vertexer
140
141   TString selectedVertexer = GetOption();
142   if(selectedVertexer.Contains("ions") || selectedVertexer.Contains("IONS")){
143     Info("CreateVertexer","a AliITSVertexerIons object has been selected\n");
144     return new AliITSVertexerIons("null");
145   }
146   if(selectedVertexer.Contains("smear") || selectedVertexer.Contains("SMEAR")){
147     Double_t smear[3]={0.005,0.005,0.01};
148     Info("CreateVertexer","a AliITSVertexerFast object has been selected\n"); 
149     return new AliITSVertexerFast(smear);
150   }
151   if(selectedVertexer.Contains("ppz") || selectedVertexer.Contains("PPZ")){
152     Info("CreateVertexer","a AliITSVertexerPPZ object has been selected\n");
153     return new AliITSVertexerPPZ("null");
154   }
155   // by default an AliITSVertexerZ object is instatiated
156   Info("CreateVertexer","a AliITSVertexerZ object has been selected\n");
157   return new AliITSVertexerZ("null");
158 }
159
160 //_____________________________________________________________________________
161 void AliITSReconstructor::FillESD(AliRunLoader* /*runLoader*/, 
162                                   AliESD* esd) const
163 {
164 // make PID, find V0s and cascades
165
166   Double_t parITS[] = {34., 0.15, 10.};
167   AliITSpidESD itsPID(parITS);
168   itsPID.MakePID(esd);
169
170   // V0 finding
171   Double_t cuts[]={33,  // max. allowed chi2
172                    0.16,// min. allowed negative daughter's impact parameter 
173                    0.05,// min. allowed positive daughter's impact parameter 
174                    0.08,// max. allowed DCA between the daughter tracks
175                    0.99,// max. allowed cosine of V0's pointing angle
176                    0.9,  // min. radius of the fiducial volume
177                    2.9   // max. radius of the fiducial volume
178   };
179   AliV0vertexer vtxer(cuts);
180   Double_t vtx[3], cvtx[6];
181   esd->GetVertex()->GetXYZ(vtx);
182   esd->GetVertex()->GetSigmaXYZ(cvtx);
183   vtxer.SetVertex(vtx);
184   vtxer.Tracks2V0vertices(esd);
185
186   // cascade finding
187   Double_t cts[]={33.,    // max. allowed chi2
188                   0.05,   // min. allowed V0 impact parameter 
189                   0.008,  // window around the Lambda mass 
190                   0.035,  // min. allowed bachelor's impact parameter 
191                   0.10,   // max. allowed DCA between a V0 and a track
192                   0.9985, //max. allowed cosine of the cascade pointing angle
193                   0.9,    // min. radius of the fiducial volume
194                   2.9     // max. radius of the fiducial volume
195   };
196   AliCascadeVertexer cvtxer=AliCascadeVertexer(cts);
197   cvtxer.SetVertex(vtx);
198   cvtxer.V0sTracks2CascadeVertices(esd);
199 }
200
201
202 //_____________________________________________________________________________
203 AliITSgeom* AliITSReconstructor::GetITSgeom(AliRunLoader* runLoader) const
204 {
205 // get the ITS geometry
206
207   if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
208   if (!runLoader->GetAliRun()) {
209     Error("GetITSgeom", "couldn't get AliRun object");
210     return NULL;
211   }
212   AliITS* its = (AliITS*) runLoader->GetAliRun()->GetDetector("ITS");
213   if (!its) {
214     Error("GetITSgeom", "couldn't get ITS detector");
215     return NULL;
216   }
217   if (!its->GetITSgeom()) {
218     Error("GetITSgeom", "no ITS geometry available");
219     return NULL;
220   }
221   return its->GetITSgeom();
222 }