Callback function for additional information about the stamp (Marian)
[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,
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
e64fdf8a 98 fClusterStore = AliMUONVClusterStore::Create(*clustersTree);
99 fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
100
101 if (!fClusterStore)
102 {
103 AliError("Could not get clusterStore");
104 return 1;
105 }
106 if (!fTriggerStore)
107 {
108 AliError("Could not get triggerStore");
109 return 2;
110 }
111
112 fClusterStore->Connect(*clustersTree,kFALSE);
113 fTriggerStore->Connect(*clustersTree,kFALSE);
114
115 clustersTree->GetEvent(0);
196471e9 116
e64fdf8a 117 return 0;
118}
196471e9 119
e64fdf8a 120//_____________________________________________________________________________
121Int_t
af885e0f 122AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
e64fdf8a 123{
124 /// Performs the tracking and store the resulting tracks in both
125 /// the TreeT and the ESD
126
127 Int_t rv(0);
d76c31f4 128
129 TTree *tracksTree = new TTree;
130
e64fdf8a 131 if (!fClusterStore)
132 {
133 AliError("ClusterStore is NULL");
134 rv=2;
135 }
136 if (!fTriggerStore)
137 {
138 AliError("TriggerStore is NULL");
139 rv=3;
140 }
141 if (!rv)
142 {
143 rv = Clusters2Tracks(*tracksTree,esd);
144 }
145 return rv;
146}
196471e9 147
e64fdf8a 148//_____________________________________________________________________________
af885e0f 149Int_t AliMUONTracker::Clusters2Tracks(TTree& tracksTree, AliESDEvent* esd)
e64fdf8a 150{
151 /// Performs the tracking
e64fdf8a 152 AliDebug(1,"");
2060b217 153 AliCodeTimerAuto("")
e64fdf8a 154
155 AliMUONVTrackStore* trackStore(0x0);
156 AliMUONVTriggerTrackStore* triggerTrackStore(0x0);
157
158 // Make tracker tracks
159 if ( fClusterStore )
160 {
161 trackStore = new AliMUONTrackStoreV1;
162 Bool_t alone = ( ( fTriggerStore && fTriggerCircuit ) ? kFALSE : kTRUE );
163 trackStore->Connect(tracksTree,alone);
164 fTrackReco->EventReconstruct(*fClusterStore,*trackStore);
165 }
166
167 if ( fTriggerStore && fTriggerCircuit )
168 {
169 // Make trigger tracks
170 triggerTrackStore = new AliMUONTriggerTrackStoreV1;
171 Bool_t alone = ( fClusterStore ? kFALSE : kTRUE );
172 triggerTrackStore->Connect(tracksTree,alone);
173 fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*triggerTrackStore);
174 }
175
176 if ( trackStore && triggerTrackStore && fTriggerStore && fTrackHitPatternMaker )
177 {
178 fTrackReco->ValidateTracksWithTrigger(*trackStore,*triggerTrackStore,*fTriggerStore,*fTrackHitPatternMaker);
179 }
180
181 // Fills output TreeT
2060b217 182 //tracksTree.Fill();
e64fdf8a 183
8c0b5e70 184 if( trackStore && triggerTrackStore && fTriggerStore && fTrigChamberEff){
2060b217 185 AliCodeTimerStart("EventChamberEff");
8c0b5e70 186 fTrigChamberEff->EventChamberEff(*fTriggerStore,*triggerTrackStore,*trackStore);
2060b217 187 AliCodeTimerStop("EventChamberEff");
8c0b5e70 188 }
189
e64fdf8a 190 FillESD(*trackStore,esd);
191
192 // cleanup
193 delete trackStore;
194 delete triggerTrackStore;
195
196 return 0;
197}
196471e9 198
e64fdf8a 199//_____________________________________________________________________________
200void
af885e0f 201AliMUONTracker::FillESD(AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
e64fdf8a 202{
203 /// Fill the ESD from the trackStore
e64fdf8a 204 AliDebug(1,"");
2060b217 205 AliCodeTimerAuto("")
e64fdf8a 206
207 // Get vertex
208 Double_t vertex[3] = {0};
209 const AliESDVertex* esdVert = esd->GetVertex();
210 if (esdVert->GetNContributors())
211 {
212 esdVert->GetXYZ(vertex);
213 AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
214 }
215
216 // setting ESD MUON class
217 AliESDMuonTrack esdTrack;
218
219 AliMUONTrack* track;
220 TIter next(trackStore.CreateIterator());
221
222 while ( ( track = static_cast<AliMUONTrack*>(next()) ) )
223 {
224 AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track->GetTrackParamAtHit())->First());
225 AliMUONTrackParam trackParamAtVtx(*trackParam);
226
227 /// Extrapolate to vertex (which is set to (0,0,0) if not available, see above)
228 AliMUONTrackExtrap::ExtrapToVertex(&trackParamAtVtx, vertex[0],vertex[1],vertex[2]);
229
230 // setting data member of ESD MUON
231
232 // at first station
60765b06 233 trackParam->SetParamForUncorrected(esdTrack);
234 trackParam->SetCovFor(esdTrack);
e64fdf8a 235 // at vertex
60765b06 236 trackParamAtVtx.SetParamFor(esdTrack);
e64fdf8a 237 // global info
238 esdTrack.SetChi2(track->GetFitFMin());
239 esdTrack.SetNHit(track->GetNTrackHits());
240 esdTrack.SetLocalTrigger(track->GetLocalTrigger());
241 esdTrack.SetChi2MatchTrigger(track->GetChi2MatchTrigger());
242 esdTrack.SetHitsPatternInTrigCh(track->GetHitsPatternInTrigCh());
60765b06 243 // muon cluster map
244 AliMUONHitForRec* cluster = static_cast<AliMUONHitForRec*>((track->GetHitForRecAtHit())->First());
245 while (cluster) {
246 esdTrack.AddInMuonClusterMap(cluster->GetChamberNumber());
247 cluster = static_cast<AliMUONHitForRec*>((track->GetHitForRecAtHit())->After(cluster));
248 }
e64fdf8a 249
250 // storing ESD MUON Track into ESD Event
251 esd->AddMuonTrack(&esdTrack);
252 } // end of loop on tracks
196471e9 253}
254
255//_____________________________________________________________________________
e64fdf8a 256void AliMUONTracker::SetOption(Option_t* option)
196471e9 257{
e64fdf8a 258 /// set reconstructor class
259
260 if (strstr(option,"Original"))
261 {
262 fTrackReco = new AliMUONTrackReconstructor;
263 }
e64fdf8a 264 else
265 {
ea94c18b 266 fTrackReco = new AliMUONTrackReconstructorK();
e64fdf8a 267 }
268}
196471e9 269
e64fdf8a 270//_____________________________________________________________________________
271void
272AliMUONTracker::UnloadClusters()
273{
274 /// Delete internal clusterStore
275 delete fClusterStore;
276 fClusterStore = 0x0;
196471e9 277}
e64fdf8a 278