merging RecPoints and ClustersV2. All ClusterFinders produce AliITSRecPoints objects...
[u/mrichter/AliRoot.git] / ITS / AliITSReconstructor.cxx
CommitLineData
121a60bd 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
e62c1aea 24#include "Riostream.h"
121a60bd 25#include "AliITSReconstructor.h"
00a7cc50 26#include "AliRun.h"
121a60bd 27#include "AliRunLoader.h"
113c12f1 28#include "AliRawReader.h"
00a7cc50 29#include "AliITSDetTypeRec.h"
7d62fb64 30#include "AliITSLoader.h"
e43c066c 31#include "AliITStrackerMI.h"
121a60bd 32#include "AliITStrackerSA.h"
33#include "AliITSVertexerIons.h"
34#include "AliITSVertexerFast.h"
35#include "AliITSVertexerPPZ.h"
36#include "AliITSVertexerZ.h"
37#include "AliESD.h"
38#include "AliITSpidESD.h"
e62c1aea 39#include "AliITSpidESD1.h"
40#include "AliITSpidESD2.h"
121a60bd 41#include "AliV0vertexer.h"
42#include "AliCascadeVertexer.h"
121a60bd 43
44ClassImp(AliITSReconstructor)
45
e62c1aea 46//___________________________________________________________________________
47AliITSReconstructor::AliITSReconstructor() : AliReconstructor(){
48 // Default constructor
49 fItsPID=0;
50}
51 //___________________________________________________________________________
52AliITSReconstructor::~AliITSReconstructor(){
53// destructor
54 delete fItsPID;
55}
56//______________________________________________________________________
57AliITSReconstructor::AliITSReconstructor(const AliITSReconstructor &ob) :AliReconstructor(ob) {
58 // Copy constructor
59 // Copies are not allowed. The method is protected to avoid misuse.
60 Error("AliITSpidESD2","Copy constructor not allowed\n");
61}
62
63//______________________________________________________________________
64AliITSReconstructor& AliITSReconstructor::operator=(const AliITSReconstructor& /* ob */){
65 // Assignment operator
66 // Assignment is not allowed. The method is protected to avoid misuse.
67 Error("= operator","Assignment operator not allowed\n");
68 return *this;
69}
00a7cc50 70
121a60bd 71//_____________________________________________________________________________
72void AliITSReconstructor::Reconstruct(AliRunLoader* runLoader) const
73{
74// reconstruct clusters
75
7d62fb64 76
00a7cc50 77 AliLoader* loader = runLoader->GetLoader("ITSLoader");
121a60bd 78 if (!loader) {
79 Error("Reconstruct", "ITS loader not found");
80 return;
81 }
00a7cc50 82 gAlice=runLoader->GetAliRun();
83 TDirectory* olddir = gDirectory;
84 runLoader->CdGAFile();
85 AliITSgeom* geom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
86 olddir->cd();
87 AliITSDetTypeRec* rec = new AliITSDetTypeRec();
88 rec->SetLoader((AliITSLoader*)loader);
89 rec->SetITSgeom(geom);
90 rec->SetDefaults();
91
121a60bd 92 loader->LoadRecPoints("recreate");
93 loader->LoadDigits("read");
94 runLoader->LoadKinematics();
00a7cc50 95 TString option = GetOption();
96 Bool_t clusfinder=kTRUE; // Default: V2 cluster finder
97 if(option.Contains("OrigCF"))clusfinder=kFALSE;
121a60bd 98
121a60bd 99 Int_t nEvents = runLoader->GetNumberOfEvents();
100
101 for (Int_t iEvent = 0; iEvent < nEvents; iEvent++) {
102 runLoader->GetEvent(iEvent);
00a7cc50 103 if(loader->TreeR()==0x0) loader->MakeTree("R");
104 rec->MakeBranch("R");
105 rec->SetTreeAddress();
106 rec->DigitsToRecPoints(iEvent,0,"All",clusfinder);
121a60bd 107 }
108
109 loader->UnloadRecPoints();
110 loader->UnloadDigits();
111 runLoader->UnloadKinematics();
112}
113
00a7cc50 114//_________________________________________________________________
115void AliITSReconstructor::Reconstruct(AliRunLoader* runLoader,
116 AliRawReader* rawReader) const
113c12f1 117{
00a7cc50 118// reconstruct clusters
113c12f1 119
00a7cc50 120
121 AliLoader* loader = runLoader->GetLoader("ITSLoader");
113c12f1 122 if (!loader) {
123 Error("Reconstruct", "ITS loader not found");
124 return;
125 }
00a7cc50 126 gAlice=runLoader->GetAliRun();
127 TDirectory* olddir = gDirectory;
128 runLoader->CdGAFile();
129 AliITSgeom* geom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
130 olddir->cd();
131
132 AliITSDetTypeRec* rec = new AliITSDetTypeRec();
133 rec->SetLoader((AliITSLoader*)loader);
134 rec->SetITSgeom(geom);
135 rec->SetDefaults();
136 rec->SetDefaultClusterFindersV2(kTRUE);
113c12f1 137
00a7cc50 138 loader->LoadRecPoints("recreate");
113c12f1 139
140 Int_t iEvent = 0;
113c12f1 141
00a7cc50 142 while(rawReader->NextEvent()) {
143 runLoader->GetEvent(iEvent++);
144 if(loader->TreeR()==0x0) loader->MakeTree("R");
145 rec->DigitsToRecPoints(rawReader);
113c12f1 146 }
147
148 loader->UnloadRecPoints();
149}
150
151//_____________________________________________________________________________
e62c1aea 152AliTracker* AliITSReconstructor::CreateTracker(AliRunLoader* runLoader)const
121a60bd 153{
154// create a ITS tracker
155
7d62fb64 156
121a60bd 157 AliITSgeom* geom = GetITSgeom(runLoader);
e43c066c 158 TString selectedTracker = GetOption();
e62c1aea 159 AliTracker* tracker;
160 if (selectedTracker.Contains("MI")) {
161 tracker = new AliITStrackerMI(geom);
162 }
163 else {
164 tracker = new AliITStrackerSA(geom); // inherits from AliITStrackerMI
165 }
7d62fb64 166
e62c1aea 167 TString selectedPIDmethod = GetOption();
168 AliITSLoader *loader = (AliITSLoader*)runLoader->GetLoader("ITSLoader");
169 if (!loader) {
170 Error("CreateTracker", "ITS loader not found");
171 }
172 if(selectedPIDmethod.Contains("LandauFitPID")){
173 loader->AdoptITSpid(new AliITSpidESD2((AliITStrackerMI*)tracker,loader));
174 }
175 else{
176 Double_t parITS[] = {34., 0.15, 10.};
177 loader->AdoptITSpid(new AliITSpidESD1(parITS));
178 }
179 return tracker;
7d62fb64 180
121a60bd 181}
182
183//_____________________________________________________________________________
184AliVertexer* AliITSReconstructor::CreateVertexer(AliRunLoader* /*runLoader*/) const
185{
186// create a ITS vertexer
187
f4d5a8d1 188 TString selectedVertexer = GetOption();
121a60bd 189 if(selectedVertexer.Contains("ions") || selectedVertexer.Contains("IONS")){
190 Info("CreateVertexer","a AliITSVertexerIons object has been selected\n");
191 return new AliITSVertexerIons("null");
192 }
193 if(selectedVertexer.Contains("smear") || selectedVertexer.Contains("SMEAR")){
194 Double_t smear[3]={0.005,0.005,0.01};
195 Info("CreateVertexer","a AliITSVertexerFast object has been selected\n");
196 return new AliITSVertexerFast(smear);
197 }
198 if(selectedVertexer.Contains("ppz") || selectedVertexer.Contains("PPZ")){
199 Info("CreateVertexer","a AliITSVertexerPPZ object has been selected\n");
200 return new AliITSVertexerPPZ("null");
201 }
202 // by default an AliITSVertexerZ object is instatiated
203 Info("CreateVertexer","a AliITSVertexerZ object has been selected\n");
204 return new AliITSVertexerZ("null");
205}
206
207//_____________________________________________________________________________
e62c1aea 208void AliITSReconstructor::FillESD(AliRunLoader* runLoader,
121a60bd 209 AliESD* esd) const
210{
e62c1aea 211// make PID, find V0s and cascade
212 AliITSLoader *loader = (AliITSLoader*)runLoader->GetLoader("ITSLoader");
213 AliITSpidESD *pidESD = 0;
214 TString selectedPIDmethod = GetOption();
215 if(selectedPIDmethod.Contains("LandauFitPID")){
149c4c59 216 Info("FillESD","ITS LandauFitPID option has been selected\n");
e62c1aea 217 pidESD=loader->GetITSpid();
218 }
219 else{
149c4c59 220 Info("FillESD","ITS default PID\n");
e62c1aea 221 pidESD=loader->GetITSpid();
222 }
223 if(pidESD!=0){
224 pidESD->MakePID(esd);
225 }
226 else {
227 Error("FillESD","!! cannot do the PID !!\n");
228 }
121a60bd 229 // V0 finding
230 Double_t cuts[]={33, // max. allowed chi2
231 0.16,// min. allowed negative daughter's impact parameter
232 0.05,// min. allowed positive daughter's impact parameter
233 0.08,// max. allowed DCA between the daughter tracks
234 0.99,// max. allowed cosine of V0's pointing angle
235 0.9, // min. radius of the fiducial volume
236 2.9 // max. radius of the fiducial volume
237 };
238 AliV0vertexer vtxer(cuts);
239 Double_t vtx[3], cvtx[6];
240 esd->GetVertex()->GetXYZ(vtx);
241 esd->GetVertex()->GetSigmaXYZ(cvtx);
242 vtxer.SetVertex(vtx);
243 vtxer.Tracks2V0vertices(esd);
244
245 // cascade finding
246 Double_t cts[]={33., // max. allowed chi2
247 0.05, // min. allowed V0 impact parameter
248 0.008, // window around the Lambda mass
249 0.035, // min. allowed bachelor's impact parameter
250 0.10, // max. allowed DCA between a V0 and a track
251 0.9985, //max. allowed cosine of the cascade pointing angle
252 0.9, // min. radius of the fiducial volume
253 2.9 // max. radius of the fiducial volume
254 };
255 AliCascadeVertexer cvtxer=AliCascadeVertexer(cts);
256 cvtxer.SetVertex(vtx);
257 cvtxer.V0sTracks2CascadeVertices(esd);
258}
259
260
261//_____________________________________________________________________________
262AliITSgeom* AliITSReconstructor::GetITSgeom(AliRunLoader* runLoader) const
263{
264// get the ITS geometry
265
266 if (!runLoader->GetAliRun()) runLoader->LoadgAlice();
267 if (!runLoader->GetAliRun()) {
268 Error("GetITSgeom", "couldn't get AliRun object");
269 return NULL;
270 }
7d62fb64 271
272 TDirectory * olddir = gDirectory;
273 runLoader->CdGAFile();
274 AliITSgeom* geom = (AliITSgeom*)gDirectory->Get("AliITSgeom");
275 olddir->cd();
276 if(!geom){
277 Error("GetITSgeom","no ITS geometry available");
121a60bd 278 return NULL;
279 }
7d62fb64 280
281 return geom;
121a60bd 282}
7d62fb64 283