Fix for the case of non-existent calibration files
[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 "AliRawReader.h"
28 #include "AliESDEvent.h"
29 #include "AliESDpid.h"
30 #include "AliITSgeom.h"
31 #include "AliITSLoader.h"
32 #include "AliITStrackerMI.h"
33 #include "AliITStrackerV2.h"
34 #include "AliITStrackerSA.h"
35 #include "AliITSVertexerFast.h"
36 #include "AliITSVertexerFixed.h"
37 #include "AliITSVertexer3D.h"
38 #include "AliITSVertexerZ.h"
39 #include "AliITSVertexerZD.h"
40 #include "AliITSVertexerCosmics.h"
41 #include "AliITSInitGeometry.h"
42 #include "AliITSTrackleterSPDEff.h"
43 #include "AliITSMultReconstructor.h"
44
45 ClassImp(AliITSReconstructor)
46
47 //___________________________________________________________________________
48 AliITSReconstructor::AliITSReconstructor() : AliReconstructor(),
49 fDetTypeRec(0)
50 {
51   // Default constructor
52 }
53  //___________________________________________________________________________
54 AliITSReconstructor::~AliITSReconstructor(){
55 // destructor
56   if(fDetTypeRec) delete fDetTypeRec;
57
58 //____________________________________________________________________________
59 void AliITSReconstructor::GetPidSettings(AliESDpid *ESDpid) {
60   //
61   // pass PID settings from AliITSRecoParam to AliESDpid
62   //
63   Int_t pidOpt = GetRecoParam()->GetPID();
64
65   if(pidOpt==1){
66     AliDebug(1,"ITS LandauFitPID option has been selected\n");
67     ESDpid->SetITSPIDmethod(AliESDpid::kITSLikelihood);
68   }
69   else{
70     AliDebug(1,"ITS default PID\n");
71     ESDpid->SetITSPIDmethod(AliESDpid::kITSTruncMean);
72   }
73 }
74 //______________________________________________________________________
75 void AliITSReconstructor::Init() {
76     // Initalize this constructor bet getting/creating the objects
77     // nesseary for a proper ITS reconstruction.
78     // Inputs:
79     //   none.
80     // Output:
81     //   none.
82     // Return:
83     //   none.
84
85     AliITSInitGeometry initgeom;
86     AliITSgeom *geom = initgeom.CreateAliITSgeom();
87     AliInfo(Form("Geometry name: %s",(initgeom.GetGeometryName()).Data()));
88
89     fDetTypeRec = new AliITSDetTypeRec();
90     fDetTypeRec->SetITSgeom(geom);
91     fDetTypeRec->SetDefaults();
92
93     return;
94 }
95
96 //_____________________________________________________________________________
97 void AliITSReconstructor::Reconstruct(TTree *digitsTree, TTree *clustersTree) const
98 {
99 // reconstruct clusters
100
101   Int_t cluFindOpt = GetRecoParam()->GetClusterFinder();
102   // cluFindOpt = 0 --> ClusterFinder V2 
103   // cluFindOpt = 1 --> as cluFindOpt = 0 for SPD and SSD. Fast SDD algo
104   TString recopt = GetRecoParam()->GetOptReco();
105   fDetTypeRec->SetTreeAddressD(digitsTree);
106   fDetTypeRec->MakeBranch(clustersTree,"R");
107   fDetTypeRec->SetTreeAddressR(clustersTree);
108   fDetTypeRec->DigitsToRecPoints(digitsTree,clustersTree,0,recopt.Data(),cluFindOpt);    
109 }
110
111 //_________________________________________________________________
112 void AliITSReconstructor::Reconstruct(AliRawReader* rawReader, TTree *clustersTree) const
113 {
114   // reconstruct clusters from raw data
115   Int_t cluFindOpt = GetRecoParam()->GetClusterFinder();
116   // cluFindOpt = 0 --> ClusterFinder V2 
117   // cluFindOpt = 1 --> as cluFindOpt = 0 for SPD and SSD. Fast SDD algo
118   TString recopt = GetRecoParam()->GetOptReco();
119   if(cluFindOpt == 0){
120     fDetTypeRec->SetDefaultClusterFindersV2(kTRUE);
121   }
122   else {
123     fDetTypeRec->SetDefaultClusterFindersV2(kTRUE,kTRUE);
124   }
125   fDetTypeRec->DigitsToRecPoints(rawReader,clustersTree,recopt.Data());
126 }
127
128 //_____________________________________________________________________________
129 AliTrackleter* AliITSReconstructor::CreateMultFinder() const
130 {
131   // create the SPD trackeleter for mult. reconstruction
132   AliITSMultReconstructor* multReco = new AliITSMultReconstructor();
133   multReco->SetHistOn(kFALSE);
134   multReco->SetDetTypeRec(fDetTypeRec);
135   return multReco;
136 }
137
138 //_____________________________________________________________________________
139 AliTracker* AliITSReconstructor::CreateTrackleter() const
140 {
141 // create the SPD trackeleter (for SPD PlaneEfficiency evaluation)
142   if(!GetRecoParam()->GetComputePlaneEff() || !GetRecoParam()->GetUseTrackletsPlaneEff()) return NULL;
143   //Int_t trackerOpt = GetRecoParam()->GetTracker();
144   AliTracker* trackleter;
145   trackleter = new AliITSTrackleterSPDEff();
146   AliITSTrackleterSPDEff *spdtrackleter=(AliITSTrackleterSPDEff*)trackleter;
147   // here set cuts (from RecoParam)
148   if(GetRecoParam()->GetBkgTrackletsPlaneEff()) spdtrackleter->SetReflectClusterAroundZAxisForLayer(1,kTRUE);
149   if(GetRecoParam()->GetMCTrackletsPlaneEff()) spdtrackleter->SetMC();
150   spdtrackleter->SetHistOn();
151   spdtrackleter->SetPhiWindowL2(GetRecoParam()->GetTrackleterPhiWindowL2());
152   spdtrackleter->SetZetaWindowL2(GetRecoParam()->GetTrackleterZetaWindowL2());
153   spdtrackleter->SetPhiWindowL1(GetRecoParam()->GetTrackleterPhiWindowL1());
154   spdtrackleter->SetZetaWindowL1(GetRecoParam()->GetTrackleterZetaWindowL1());
155   if(GetRecoParam()->GetUpdateOncePerEventPlaneEff()) spdtrackleter->SetUpdateOncePerEventPlaneEff();
156   spdtrackleter->SetMinContVtx(GetRecoParam()->GetMinContVtxPlaneEff());
157   return trackleter;
158 }
159
160 //_____________________________________________________________________________
161 AliTracker* AliITSReconstructor::CreateTracker() const
162 {
163 // create a ITS tracker
164
165   Int_t trackerOpt = GetRecoParam()->GetTracker();
166   AliTracker* tracker;    
167   if (trackerOpt==1) {
168     tracker = new AliITStrackerMI(0);
169     AliITStrackerMI *mit=(AliITStrackerMI*)tracker;
170     mit->SetDetTypeRec(fDetTypeRec);
171   }  
172   else if (trackerOpt==2) {
173     tracker = new AliITStrackerV2(0);
174   }
175   else {
176     tracker =  new AliITStrackerSA(0);  // inherits from AliITStrackerMI
177     AliITStrackerSA *sat=(AliITStrackerSA*)tracker;
178     sat->SetDetTypeRec(fDetTypeRec);
179     if(GetRecoParam()->GetTrackerSAOnly()) sat->SetSAFlag(kTRUE);
180     if(sat->GetSAFlag())AliDebug(1,"Tracking Performed in ITS only\n");
181         if(GetRecoParam()->GetInwardFindingSA()){
182        sat->SetInwardFinding();
183        sat->SetInnerStartLayer(GetRecoParam()->GetInnerStartLayerSA());
184         }else{
185       sat->SetOutwardFinding();
186       sat->SetOuterStartLayer(GetRecoParam()->GetOuterStartLayerSA());
187         }
188     sat->SetMinNPoints(GetRecoParam()->GetMinNPointsSA());
189   }
190
191   return tracker;
192   
193 }
194
195 //_____________________________________________________________________________
196 AliVertexer* AliITSReconstructor::CreateVertexer() const
197 {
198 // create a ITS vertexer
199
200   AliITSVertexer *vptr = NULL;
201   Int_t vtxOpt = GetRecoParam()->GetVertexer();
202   if(vtxOpt==3){
203     AliFatal("Option AliITSVertexerIons is no longer supported");
204     return vptr;
205   }
206   else if(vtxOpt==4){
207     Double_t smear[3]={GetRecoParam()->GetVertexerFastSmearX(),
208                        GetRecoParam()->GetVertexerFastSmearY(),
209                        GetRecoParam()->GetVertexerFastSmearZ()};
210     AliDebug(1,"AliITSVertexerFast has been selected"); 
211     vptr = new AliITSVertexerFast(smear);
212   }
213   else if(vtxOpt==1){
214     AliDebug(1,"AliITSVertexerZ has been selected");
215     AliITSVertexerZ* vtxrz =  new AliITSVertexerZ();
216     Int_t pileupAlgo=GetRecoParam()->GetSPDVertexerPileupAlgo();
217     if(pileupAlgo==3) vtxrz->SetSearchForPileup(kFALSE);
218     vptr = vtxrz;
219   }
220   else if(vtxOpt==2){
221     AliDebug(1,"AliITSVertexerCosmics has been selected");
222     vptr = new AliITSVertexerCosmics();
223   }
224   else if(vtxOpt==5){ 
225     AliDebug(1,"Vertex is fixed in the position of the TDI\n");
226     vptr = new AliITSVertexerFixed("TDI");
227   }
228   else if(vtxOpt==6){ 
229     AliDebug(1,"Vertex is fixed in the position of the TED\n");
230     vptr = new AliITSVertexerFixed("TED");
231   }
232   else if(vtxOpt==7){
233     AliDebug(1,"VertexerZD:  reconstruction of the Z coordinate with SDD \n");
234     AliITSVertexerZD*vtxrz = new AliITSVertexerZD();
235     vtxrz->SetSearchForPileup(kFALSE);
236     vptr = vtxrz;
237   }
238   else {
239   // by default an AliITSVertexer3D object is instatiated
240     AliITSVertexer3D*  vtxr = 
241        new AliITSVertexer3D(GetRecoParam()->GetVertexer3DWideFiducialRegionZ());
242     Float_t dzw=GetRecoParam()->GetVertexer3DWideFiducialRegionZ();
243     Float_t drw=GetRecoParam()->GetVertexer3DWideFiducialRegionR();
244     vtxr->SetWideFiducialRegion(dzw,drw);
245     Float_t dzn=GetRecoParam()->GetVertexer3DNarrowFiducialRegionZ();
246     Float_t drn=GetRecoParam()->GetVertexer3DNarrowFiducialRegionR();
247     vtxr->SetNarrowFiducialRegion(dzn,drn);
248     Float_t dphil=GetRecoParam()->GetVertexer3DLooseDeltaPhiCut();
249     Float_t dphit=GetRecoParam()->GetVertexer3DTightDeltaPhiCut();
250     vtxr->SetDeltaPhiCuts(dphil,dphit);
251     Float_t dcacut=GetRecoParam()->GetVertexer3DDCACut();
252     vtxr->SetDCACut(dcacut);
253     Int_t pileupAlgo=GetRecoParam()->GetSPDVertexerPileupAlgo();
254     vtxr->SetPileupAlgo(pileupAlgo);
255     UChar_t highmultAlgo=GetRecoParam()->GetSPDVertexerHighMultAlgo();
256     vtxr->SetHighMultAlgo(highmultAlgo);
257     AliDebug(1,Form("AliITSVertexer3D with pileup algo %d has been selected",pileupAlgo));
258     vptr = vtxr;
259   }
260   vptr->SetDetTypeRec(fDetTypeRec);
261   return vptr;
262 }
263
264 //_____________________________________________________________________________
265 void AliITSReconstructor::FillESD(TTree * /*digitsTree*/, TTree * /*clustersTree*/, 
266                                   AliESDEvent* /* esd */) const
267 {
268 // make PID, find V0s and cascade
269 /* Now done in AliESDpid
270   if(fItsPID!=0) fItsPID->MakePID(esd);
271   else AliError("!! cannot do the PID !!");
272 */
273 }