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