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