]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTracker.cxx
- Compute parameter covariances including absorber dispersion effects
[u/mrichter/AliRoot.git] / MUON / AliMUONTracker.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 /// \class AliMUONTracker
20 ///
21 /// Steering class for use in global tracking framework;
22 /// reconstruct tracks from recpoints
23 ///
24 /// Actual tracking is performed by some AliMUONVTrackReconstructor children
25 /// Tracking modes (ORIGINAL, KALMAN) and associated options and parameters
26 /// can be changed by using:
27 /// AliMUONRecoParam *muonRecoParam = AliMUONRecoParam::GetLow(High)FluxParam();
28 /// muonRecoParam->Set...(); // see methods in AliMUONRecoParam.h for details
29 /// AliMUONReconstructor::SetRecoParam(muonRecoParam);
30 ///
31 /// \author Christian Finck and Laurent Aphecetche, SUBATECH Nantes
32 //-----------------------------------------------------------------------------
33
34 #include "AliMUONTracker.h"
35
36 #include "AliMUONReconstructor.h"
37 #include "AliMUONRecoParam.h"
38 #include "AliMUONTrack.h"
39 #include "AliMUONTrackExtrap.h"
40 #include "AliMUONTrackHitPattern.h"
41 #include "AliMUONTrackParam.h"
42 #include "AliMUONVCluster.h"
43 #include "AliMUONTrackReconstructor.h"
44 #include "AliMUONTrackReconstructorK.h"
45 #include "AliMUONTrackStoreV1.h"
46 #include "AliMUONTriggerChamberEff.h"
47 #include "AliMUONTriggerTrackStoreV1.h"
48 #include "AliMUONVClusterStore.h"
49 #include "AliMUONVTriggerStore.h"
50
51 #include "AliESDEvent.h"
52 #include "AliESDMuonTrack.h"
53 #include "AliESDVertex.h"
54 #include "AliLog.h"
55 #include "AliCodeTimer.h"
56
57 #include <Riostream.h>
58 #include <TTree.h>
59
60 /// \cond CLASSIMP
61 ClassImp(AliMUONTracker)
62 /// \endcond
63
64
65 //_____________________________________________________________________________
66 AliMUONTracker::AliMUONTracker(const AliMUONDigitMaker* digitMaker,
67                                const AliMUONGeometryTransformer* transformer,
68                                const AliMUONTriggerCircuit* triggerCircuit,
69                                AliMUONTriggerChamberEff* chamberEff)
70 : AliTracker(),
71   fDigitMaker(digitMaker), // not owner
72   fTransformer(transformer), // not owner
73   fTriggerCircuit(triggerCircuit), // not owner
74   fTrigChamberEff(chamberEff), // not owner
75   fTrackHitPatternMaker(0x0),
76   fTrackReco(0x0),
77   fClusterStore(0x0),
78   fTriggerStore(0x0)
79 {
80   /// constructor
81   if (fTransformer && fDigitMaker)
82     fTrackHitPatternMaker = new AliMUONTrackHitPattern(*fTransformer,*fDigitMaker);
83 }
84
85 //_____________________________________________________________________________
86 AliMUONTracker::~AliMUONTracker()
87 {
88   /// dtor
89   delete fTrackReco;
90   delete fTrackHitPatternMaker;
91   delete fClusterStore;
92   delete fTriggerStore;
93 }
94
95 //_____________________________________________________________________________
96 Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
97 {
98   /// Load clusterStore and triggerStore from clustersTree
99   delete fClusterStore;
100   delete fTriggerStore;
101
102   if ( ! clustersTree ) {
103     AliFatal("No clustersTree");
104     return 1;
105   }
106
107   fClusterStore = AliMUONVClusterStore::Create(*clustersTree);
108   fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
109   
110   if (!fClusterStore)
111   {
112     AliError("Could not get clusterStore");
113     return 1;
114   }
115   if (!fTriggerStore)
116   {
117     AliError("Could not get triggerStore");
118     return 2;
119   }
120   
121   fClusterStore->Connect(*clustersTree,kFALSE);
122   fTriggerStore->Connect(*clustersTree,kFALSE);
123   
124   clustersTree->GetEvent(0);
125
126   return 0;
127 }
128
129 //_____________________________________________________________________________
130 Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
131 {
132   /// Performs the tracking and store the resulting tracks in the ESD
133   AliDebug(1,"");
134   AliCodeTimerAuto("")
135   
136   if (!fTrackReco) CreateTrackReconstructor();
137   
138   // if the required tracking mode does not exist
139   if  (!fTrackReco) return 1;
140   
141   if (!fClusterStore) {
142     AliError("ClusterStore is NULL");
143     return 2;
144   }
145   
146   if (!fTriggerStore) {
147     AliError("TriggerStore is NULL");
148     return 3;
149   }
150   
151   // Make tracker tracks
152   AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
153   fTrackReco->EventReconstruct(*fClusterStore,*trackStore);
154   
155   // Make trigger tracks
156   AliMUONVTriggerTrackStore* triggerTrackStore(0x0);
157   if ( fTriggerCircuit ) {
158     triggerTrackStore = new AliMUONTriggerTrackStoreV1;
159     fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*triggerTrackStore);
160   }
161
162   // Match tracker/trigger tracks
163   if ( triggerTrackStore && fTrackHitPatternMaker ) {
164     fTrackReco->ValidateTracksWithTrigger(*trackStore,*triggerTrackStore,*fTriggerStore,*fTrackHitPatternMaker);
165   }
166   
167   // Compute trigger chamber efficiency
168   if( triggerTrackStore && fTrigChamberEff){
169       AliCodeTimerStart("EventChamberEff");
170       fTrigChamberEff->EventChamberEff(*fTriggerStore,*triggerTrackStore,*trackStore);
171       AliCodeTimerStop("EventChamberEff");
172   }
173   
174   // Fill ESD
175   FillESD(*trackStore,esd);
176   
177   // cleanup
178   delete trackStore;
179   delete triggerTrackStore;
180   
181   return 0;
182 }
183
184 //_____________________________________________________________________________
185 void AliMUONTracker::FillESD(AliMUONVTrackStore& trackStore, AliESDEvent* esd) const
186 {
187   /// Fill the ESD from the trackStore
188   AliDebug(1,"");
189   AliCodeTimerAuto("")
190   
191   // Get vertex 
192   Double_t vertex[3] = {0};
193   Double_t errXVtx = 0., errYVtx = 0.;
194   const AliESDVertex* esdVert = esd->GetVertex(); 
195   if (esdVert->GetNContributors()) 
196   {
197     esdVert->GetXYZ(vertex);
198     errXVtx = esdVert->GetXRes();
199     errYVtx = esdVert->GetYRes();
200     AliDebug(1,Form("found vertex (%e,%e,%e)",vertex[0],vertex[1],vertex[2]));
201   }
202   
203   // setting ESD MUON class
204   AliESDMuonTrack esdTrack;
205   
206   AliMUONTrack* track;
207   TIter next(trackStore.CreateIterator());
208   
209   while ( ( track = static_cast<AliMUONTrack*>(next()) ) )
210   {
211     AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track->GetTrackParamAtCluster())->First());
212     AliMUONTrackParam trackParamAtVtx(*trackParam);
213     
214     /// Extrapolate to vertex (which is set to (0,0,0) if not available, see above)
215     AliMUONTrackExtrap::ExtrapToVertex(&trackParamAtVtx, vertex[0],vertex[1],vertex[2],errXVtx,errYVtx);
216     
217     // setting data member of ESD MUON
218     
219     // at first station
220     trackParam->SetParamForUncorrected(esdTrack);
221     trackParam->SetCovFor(esdTrack);
222     // at vertex
223     trackParamAtVtx.SetParamFor(esdTrack);
224     // global info
225     esdTrack.SetChi2(track->GetGlobalChi2());
226     esdTrack.SetNHit(track->GetNClusters());
227     esdTrack.SetLocalTrigger(track->GetLocalTrigger());
228     esdTrack.SetChi2MatchTrigger(track->GetChi2MatchTrigger());
229     esdTrack.SetHitsPatternInTrigCh(track->GetHitsPatternInTrigCh());
230     // muon cluster map
231     while (trackParam) {
232       esdTrack.AddInMuonClusterMap(trackParam->GetClusterPtr()->GetChamberId());
233       trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->After(trackParam));
234     }
235     
236     // storing ESD MUON Track into ESD Event 
237     esd->AddMuonTrack(&esdTrack);
238   } // end of loop on tracks
239 }
240
241 //_____________________________________________________________________________
242 void AliMUONTracker::CreateTrackReconstructor()
243 {
244   /// Create track reconstructor, depending on tracking mode set in RecoParam
245   
246   TString opt(AliMUONReconstructor::GetRecoParam()->GetTrackingMode());
247   opt.ToUpper();
248   
249   if (strstr(opt,"ORIGINAL"))
250   {
251     fTrackReco = new AliMUONTrackReconstructor();
252   }
253   else if (strstr(opt,"KALMAN"))
254   {
255     fTrackReco = new AliMUONTrackReconstructorK();
256   }
257   else
258   {
259     AliError(Form("tracking mode \"%s\" does not exist",opt.Data()));
260     return;
261   }
262   
263   AliInfo(Form("Will use %s for tracking",fTrackReco->ClassName()));
264 }
265
266 //_____________________________________________________________________________
267 void AliMUONTracker::UnloadClusters()
268 {
269   /// Delete internal clusterStore
270   delete fClusterStore;
271   fClusterStore = 0x0;
272 }
273