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