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