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