Remove already deleted files that were recreated during merge.
[u/mrichter/AliRoot.git] / MUON / AliMUONTracker.cxx
CommitLineData
196471e9 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
ea94c18b 16/* $Id$ */
17
ee8a8d65 18//-----------------------------------------------------------------------------
27bf410b 19/// \class AliMUONTracker
e64fdf8a 20///
21/// Steering class for use in global tracking framework;
27bf410b 22/// reconstruct tracks from recpoints
23///
e64fdf8a 24/// Actual tracking is performed by some AliMUONVTrackReconstructor children
25///
26/// \author Christian Finck and Laurent Aphecetche, SUBATECH Nantes
ee8a8d65 27//-----------------------------------------------------------------------------
196471e9 28
29#include "AliMUONTracker.h"
e64fdf8a 30
e64fdf8a 31#include "AliMUONTrack.h"
32#include "AliMUONTrackExtrap.h"
33#include "AliMUONTrackHitPattern.h"
34#include "AliMUONTrackParam.h"
60765b06 35#include "AliMUONHitForRec.h"
196471e9 36#include "AliMUONTrackReconstructor.h"
e64fdf8a 37#include "AliMUONTrackReconstructorK.h"
38#include "AliMUONTrackStoreV1.h"
8c0b5e70 39#include "AliMUONTriggerChamberEff.h"
e64fdf8a 40#include "AliMUONTriggerTrackStoreV1.h"
41#include "AliMUONVClusterStore.h"
42#include "AliMUONVTriggerStore.h"
ea94c18b 43
af885e0f 44#include "AliESDEvent.h"
ea94c18b 45#include "AliESDMuonTrack.h"
46#include "AliESDVertex.h"
ea94c18b 47#include "AliLog.h"
2060b217 48#include "AliCodeTimer.h"
ea94c18b 49
e64fdf8a 50#include <Riostream.h>
51#include <TTree.h>
196471e9 52
ee8a8d65 53/// \cond CLASSIMP
54ClassImp(AliMUONTracker)
55/// \endcond
56
57
196471e9 58//_____________________________________________________________________________
d76c31f4 59AliMUONTracker::AliMUONTracker(const AliMUONDigitMaker* digitMaker,
e64fdf8a 60 const AliMUONGeometryTransformer* transformer,
8c0b5e70 61 const AliMUONTriggerCircuit* triggerCircuit,
6cfc11c3 62 AliMUONTriggerChamberEff* chamberEff)
e64fdf8a 63: AliTracker(),
e64fdf8a 64 fDigitMaker(digitMaker), // not owner
65 fTransformer(transformer), // not owner
66 fTriggerCircuit(triggerCircuit), // not owner
8c0b5e70 67 fTrigChamberEff(chamberEff), // not owner
e64fdf8a 68 fTrackHitPatternMaker(0x0),
69 fTrackReco(0x0),
70 fClusterStore(0x0),
71 fTriggerStore(0x0)
196471e9 72{
73 /// constructor
e64fdf8a 74 if (fTransformer && fDigitMaker)
75 {
76 fTrackHitPatternMaker = new AliMUONTrackHitPattern(*fTransformer,*fDigitMaker);
77 }
196471e9 78}
e64fdf8a 79
196471e9 80//_____________________________________________________________________________
81AliMUONTracker::~AliMUONTracker()
82{
e64fdf8a 83 /// dtor
196471e9 84 delete fTrackReco;
e64fdf8a 85 delete fTrackHitPatternMaker;
86 delete fClusterStore;
87 delete fTriggerStore;
196471e9 88}
89
90//_____________________________________________________________________________
e64fdf8a 91Int_t
92AliMUONTracker::LoadClusters(TTree* clustersTree)
196471e9 93{
e64fdf8a 94 /// Load clusterStore and triggerStore from clustersTree
95 delete fClusterStore;
96 delete fTriggerStore;
196471e9 97
6cfc11c3 98 if ( ! clustersTree ) {
99 AliFatal("No clustersTree");
100 return 1;
101 }
102
e64fdf8a 103 fClusterStore = AliMUONVClusterStore::Create(*clustersTree);
104 fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
105
106 if (!fClusterStore)
107 {
108 AliError("Could not get clusterStore");
109 return 1;
110 }
111 if (!fTriggerStore)
112 {
113 AliError("Could not get triggerStore");
114 return 2;
115 }
116
117 fClusterStore->Connect(*clustersTree,kFALSE);
118 fTriggerStore->Connect(*clustersTree,kFALSE);
119
120 clustersTree->GetEvent(0);
196471e9 121
e64fdf8a 122 return 0;
123}
196471e9 124
e64fdf8a 125//_____________________________________________________________________________
126Int_t
af885e0f 127AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
e64fdf8a 128{
6cfc11c3 129 /// Performs the tracking and store the resulting tracks in
130 /// the ESD
e64fdf8a 131
e64fdf8a 132 if (!fClusterStore)
133 {
134 AliError("ClusterStore is NULL");
6cfc11c3 135 return 2;
e64fdf8a 136 }
6cfc11c3 137
e64fdf8a 138 if (!fTriggerStore)
139 {
140 AliError("TriggerStore is NULL");
6cfc11c3 141 return 3;
e64fdf8a 142 }
e64fdf8a 143
144 AliMUONVTrackStore* trackStore(0x0);
145 AliMUONVTriggerTrackStore* triggerTrackStore(0x0);
146
147 // Make tracker tracks
148 if ( fClusterStore )
149 {
150 trackStore = new AliMUONTrackStoreV1;
151 Bool_t alone = ( ( fTriggerStore && fTriggerCircuit ) ? kFALSE : kTRUE );
e64fdf8a 152 fTrackReco->EventReconstruct(*fClusterStore,*trackStore);
153 }
154
155 if ( fTriggerStore && fTriggerCircuit )
156 {
157 // Make trigger tracks
158 triggerTrackStore = new AliMUONTriggerTrackStoreV1;
159 Bool_t alone = ( fClusterStore ? kFALSE : kTRUE );
e64fdf8a 160 fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*triggerTrackStore);
161 }
162
163 if ( trackStore && triggerTrackStore && fTriggerStore && fTrackHitPatternMaker )
164 {
165 fTrackReco->ValidateTracksWithTrigger(*trackStore,*triggerTrackStore,*fTriggerStore,*fTrackHitPatternMaker);
166 }
167
8c0b5e70 168 if( trackStore && triggerTrackStore && fTriggerStore && fTrigChamberEff){
2060b217 169 AliCodeTimerStart("EventChamberEff");
8c0b5e70 170 fTrigChamberEff->EventChamberEff(*fTriggerStore,*triggerTrackStore,*trackStore);
2060b217 171 AliCodeTimerStop("EventChamberEff");
8c0b5e70 172 }
173
e64fdf8a 174 FillESD(*trackStore,esd);
175
176 // cleanup
177 delete trackStore;
178 delete triggerTrackStore;
179
180 return 0;
181}
196471e9 182
e64fdf8a 183//_____________________________________________________________________________
184void
af885e0f 185AliMUONTracker::FillESD(AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
e64fdf8a 186{
187 /// Fill the ESD from the trackStore
e64fdf8a 188 AliDebug(1,"");
2060b217 189 AliCodeTimerAuto("")
e64fdf8a 190
191 // Get vertex
192 Double_t vertex[3] = {0};
193 const AliESDVertex* esdVert = esd->GetVertex();
194 if (esdVert->GetNContributors())
195 {
196 esdVert->GetXYZ(vertex);
197 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
198 }
199
200 // setting ESD MUON class
201 AliESDMuonTrack esdTrack;
202
203 AliMUONTrack* track;
204 TIter next(trackStore.CreateIterator());
205
206 while ( ( track = static_cast<AliMUONTrack*>(next()) ) )
207 {
208 AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track->GetTrackParamAtHit())->First());
209 AliMUONTrackParam trackParamAtVtx(*trackParam);
210
211 /// Extrapolate to vertex (which is set to (0,0,0) if not available, see above)
212 AliMUONTrackExtrap::ExtrapToVertex(&trackParamAtVtx, vertex[0],vertex[1],vertex[2]);
213
214 // setting data member of ESD MUON
215
216 // at first station
60765b06 217 trackParam->SetParamForUncorrected(esdTrack);
218 trackParam->SetCovFor(esdTrack);
e64fdf8a 219 // at vertex
60765b06 220 trackParamAtVtx.SetParamFor(esdTrack);
e64fdf8a 221 // global info
222 esdTrack.SetChi2(track->GetFitFMin());
223 esdTrack.SetNHit(track->GetNTrackHits());
224 esdTrack.SetLocalTrigger(track->GetLocalTrigger());
225 esdTrack.SetChi2MatchTrigger(track->GetChi2MatchTrigger());
226 esdTrack.SetHitsPatternInTrigCh(track->GetHitsPatternInTrigCh());
60765b06 227 // muon cluster map
228 AliMUONHitForRec* cluster = static_cast<AliMUONHitForRec*>((track->GetHitForRecAtHit())->First());
229 while (cluster) {
230 esdTrack.AddInMuonClusterMap(cluster->GetChamberNumber());
231 cluster = static_cast<AliMUONHitForRec*>((track->GetHitForRecAtHit())->After(cluster));
232 }
e64fdf8a 233
234 // storing ESD MUON Track into ESD Event
235 esd->AddMuonTrack(&esdTrack);
236 } // end of loop on tracks
196471e9 237}
238
239//_____________________________________________________________________________
e64fdf8a 240void AliMUONTracker::SetOption(Option_t* option)
196471e9 241{
e64fdf8a 242 /// set reconstructor class
243
244 if (strstr(option,"Original"))
245 {
246 fTrackReco = new AliMUONTrackReconstructor;
247 }
e64fdf8a 248 else
249 {
ea94c18b 250 fTrackReco = new AliMUONTrackReconstructorK();
e64fdf8a 251 }
252}
196471e9 253
e64fdf8a 254//_____________________________________________________________________________
255void
256AliMUONTracker::UnloadClusters()
257{
258 /// Delete internal clusterStore
259 delete fClusterStore;
260 fClusterStore = 0x0;
196471e9 261}
e64fdf8a 262