Implementation of single event reconstruction. Removal of the run loaders from the...
[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 "AliITSgeom.h"
31 #include "AliITSLoader.h"
32 #include "AliITStrackerMI.h"
33 #include "AliITStrackerV2.h"
34 #include "AliITStrackerSA.h"
35 #include "AliITSVertexerIons.h"
36 #include "AliITSVertexerFast.h"
37 #include "AliITSVertexer3D.h"
38 #include "AliITSVertexerZ.h"
39 #include "AliITSVertexerCosmics.h"
40 #include "AliESDEvent.h"
41 #include "AliITSpidESD.h"
42 #include "AliITSpidESD1.h"
43 #include "AliITSpidESD2.h"
44 #include "AliITSInitGeometry.h"
45
46
47 ClassImp(AliITSReconstructor)
48
49 AliITSRecoParam *AliITSReconstructor::fgkRecoParam =0;  // reconstruction parameters
50
51 //___________________________________________________________________________
52 AliITSReconstructor::AliITSReconstructor() : AliReconstructor(),
53 fItsPID(0),
54 fDetTypeRec(0)
55 {
56   // Default constructor
57   if (!fgkRecoParam) {
58     AliError("The Reconstruction parameters nonitialized - Used default one");
59     fgkRecoParam = AliITSRecoParam::GetHighFluxParam();
60   }
61 }
62  //___________________________________________________________________________
63 AliITSReconstructor::~AliITSReconstructor(){
64 // destructor
65   delete fItsPID;
66   if(fgkRecoParam) delete fgkRecoParam;
67   if(fDetTypeRec) delete fDetTypeRec;
68
69 //______________________________________________________________________
70 AliITSReconstructor::AliITSReconstructor(const AliITSReconstructor &ob) :AliReconstructor(ob),
71                                                                          fItsPID(ob.fItsPID),
72                                                                          fDetTypeRec(ob.fDetTypeRec)
73
74 {
75   // Copy constructor
76 }
77
78 //______________________________________________________________________
79 AliITSReconstructor& AliITSReconstructor::operator=(const AliITSReconstructor&  ob ){
80   // Assignment operator
81   this->~AliITSReconstructor();
82   new(this) AliITSReconstructor(ob);
83   return *this;
84 }
85
86 //______________________________________________________________________
87 void AliITSReconstructor::Init(AliRunLoader */*runLoader*/) {
88     // Initalize this constructor bet getting/creating the objects
89     // nesseary for a proper ITS reconstruction.
90     // Inputs:
91     //    AliRunLoader *runLoader   Pointer to the run loader to allow
92     //                              the getting of files/folders data
93     //                              needed to do reconstruction
94     // Output:
95     //   none.
96     // Return:
97     //   none.
98
99     AliITSInitGeometry initgeom;
100     AliITSgeom *geom = initgeom.CreateAliITSgeom();
101     AliInfo(Form("Geometry name: %s",(initgeom.GetGeometryName()).Data()));
102
103     fDetTypeRec = new AliITSDetTypeRec();
104     fDetTypeRec->SetITSgeom(geom);
105     fDetTypeRec->SetDefaults();
106     
107     return;
108 }
109
110 //_____________________________________________________________________________
111 void AliITSReconstructor::Reconstruct(TTree *digitsTree, TTree *clustersTree) const
112 {
113 // reconstruct clusters
114
115   TString option = GetOption();
116   Bool_t clusfinder=kTRUE;   // Default: V2 cluster finder
117   if(option.Contains("OrigCF"))clusfinder=kFALSE;
118
119   fDetTypeRec->SetTreeAddressD(digitsTree);
120   fDetTypeRec->MakeBranch(clustersTree,"R");
121   fDetTypeRec->SetTreeAddressR(clustersTree);
122   fDetTypeRec->DigitsToRecPoints(digitsTree,clustersTree,0,"All",clusfinder);    
123 }
124
125 //_________________________________________________________________
126 void AliITSReconstructor::Reconstruct(AliRawReader* rawReader, TTree *clustersTree) const
127 {
128   // reconstruct clusters from raw data
129  
130   fDetTypeRec->SetDefaultClusterFindersV2(kTRUE);
131   fDetTypeRec->DigitsToRecPoints(rawReader,clustersTree);
132 }
133
134 //_____________________________________________________________________________
135 AliTracker* AliITSReconstructor::CreateTracker(AliRunLoader* runLoader)const
136 {
137 // create a ITS tracker
138
139   
140   TString selectedTracker = GetOption();
141   AliTracker* tracker;    
142   if (selectedTracker.Contains("MI")) {
143     tracker = new AliITStrackerMI(0);
144   }  
145   else if (selectedTracker.Contains("V2")) {
146     tracker = new AliITStrackerV2(0);
147   }
148   else {
149     tracker =  new AliITStrackerSA(0);  // inherits from AliITStrackerMI
150     AliITStrackerSA *sat=(AliITStrackerSA*)tracker;
151     if(selectedTracker.Contains("onlyITS"))sat->SetSAFlag(kTRUE);
152     if(sat->GetSAFlag())AliDebug(1,"Tracking Performed in ITS only\n");
153     if(selectedTracker.Contains("cosmics")||selectedTracker.Contains("COSMICS"))
154       sat->SetOuterStartLayer(AliITSgeomTGeo::GetNLayers()-2);
155   }
156
157   TString selectedPIDmethod = GetOption();
158   AliITSLoader *loader = (AliITSLoader*)runLoader->GetLoader("ITSLoader");
159   if (!loader) {
160     Error("CreateTracker", "ITS loader not found");
161   }
162   if(selectedPIDmethod.Contains("LandauFitPID")){
163     loader->AdoptITSpid(new AliITSpidESD2((AliITStrackerMI*)tracker,loader));
164   }
165   else{
166     Double_t parITS[] = {0.15, 10.}; //PH positions of the MIP peak
167     loader->AdoptITSpid(new AliITSpidESD1(parITS));
168   }
169   return tracker;
170   
171 }
172
173 //_____________________________________________________________________________
174 AliVertexer* AliITSReconstructor::CreateVertexer(AliRunLoader* /*runLoader*/) const
175 {
176 // create a ITS vertexer
177
178   TString selectedVertexer = GetOption();
179   if(selectedVertexer.Contains("ions") || selectedVertexer.Contains("IONS")){
180     Info("CreateVertexer","a AliITSVertexerIons object has been selected\n");
181     return new AliITSVertexerIons("null");
182   }
183   if(selectedVertexer.Contains("smear") || selectedVertexer.Contains("SMEAR")){
184     Double_t smear[3]={0.005,0.005,0.01};
185     Info("CreateVertexer","a AliITSVertexerFast object has been selected\n"); 
186     return new AliITSVertexerFast(smear);
187   }
188   if(selectedVertexer.Contains("3d") || selectedVertexer.Contains("3D")){
189     Info("CreateVertexer","a AliITSVertexer3D object has been selected\n");
190     return new AliITSVertexer3D("null");
191   }
192   if(selectedVertexer.Contains("cosmics") || selectedVertexer.Contains("COSMICS")){
193     Info("CreateVertexer","a AliITSVertexerCosmics object has been selected\n");
194     return new AliITSVertexerCosmics();
195   }
196   // by default an AliITSVertexerZ object is instatiated
197   Info("CreateVertexer","a AliITSVertexerZ object has been selected\n");
198   return new AliITSVertexerZ("null");
199 }
200
201 //_____________________________________________________________________________
202 void AliITSReconstructor::FillESD(AliRunLoader* runLoader, 
203                                   AliESDEvent* esd) const
204 {
205 // make PID, find V0s and cascade
206   AliITSLoader *loader = (AliITSLoader*)runLoader->GetLoader("ITSLoader");
207   AliITSpidESD *pidESD = 0;
208   TString selectedPIDmethod = GetOption();
209   if(selectedPIDmethod.Contains("LandauFitPID")){
210     Info("FillESD","ITS LandauFitPID option has been selected\n");
211     pidESD=loader->GetITSpid();
212   }
213   else{
214     Info("FillESD","ITS default PID\n");
215     pidESD=loader->GetITSpid();
216   }
217   if(pidESD!=0){
218     pidESD->MakePID(esd);
219   }
220   else {
221     Error("FillESD","!! cannot do the PID !!\n");
222   }
223 }