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