Remove printf and add trd_gasCO2
[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
96ebe67e 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);
e64fdf8a 30///
31/// \author Christian Finck and Laurent Aphecetche, SUBATECH Nantes
ee8a8d65 32//-----------------------------------------------------------------------------
196471e9 33
34#include "AliMUONTracker.h"
e64fdf8a 35
3304fa09 36#include "AliMUONReconstructor.h"
37#include "AliMUONRecoParam.h"
e64fdf8a 38#include "AliMUONTrack.h"
39#include "AliMUONTrackExtrap.h"
40#include "AliMUONTrackHitPattern.h"
41#include "AliMUONTrackParam.h"
96ebe67e 42#include "AliMUONVCluster.h"
196471e9 43#include "AliMUONTrackReconstructor.h"
e64fdf8a 44#include "AliMUONTrackReconstructorK.h"
45#include "AliMUONTrackStoreV1.h"
8c0b5e70 46#include "AliMUONTriggerChamberEff.h"
e64fdf8a 47#include "AliMUONTriggerTrackStoreV1.h"
48#include "AliMUONVClusterStore.h"
49#include "AliMUONVTriggerStore.h"
ea94c18b 50
af885e0f 51#include "AliESDEvent.h"
ea94c18b 52#include "AliESDMuonTrack.h"
53#include "AliESDVertex.h"
ea94c18b 54#include "AliLog.h"
2060b217 55#include "AliCodeTimer.h"
ea94c18b 56
e64fdf8a 57#include <Riostream.h>
58#include <TTree.h>
196471e9 59
ee8a8d65 60/// \cond CLASSIMP
61ClassImp(AliMUONTracker)
62/// \endcond
63
64
196471e9 65//_____________________________________________________________________________
d76c31f4 66AliMUONTracker::AliMUONTracker(const AliMUONDigitMaker* digitMaker,
e64fdf8a 67 const AliMUONGeometryTransformer* transformer,
8c0b5e70 68 const AliMUONTriggerCircuit* triggerCircuit,
6cfc11c3 69 AliMUONTriggerChamberEff* chamberEff)
e64fdf8a 70: AliTracker(),
e64fdf8a 71 fDigitMaker(digitMaker), // not owner
72 fTransformer(transformer), // not owner
73 fTriggerCircuit(triggerCircuit), // not owner
8c0b5e70 74 fTrigChamberEff(chamberEff), // not owner
e64fdf8a 75 fTrackHitPatternMaker(0x0),
76 fTrackReco(0x0),
77 fClusterStore(0x0),
78 fTriggerStore(0x0)
196471e9 79{
80 /// constructor
e64fdf8a 81 if (fTransformer && fDigitMaker)
e64fdf8a 82 fTrackHitPatternMaker = new AliMUONTrackHitPattern(*fTransformer,*fDigitMaker);
196471e9 83}
e64fdf8a 84
196471e9 85//_____________________________________________________________________________
86AliMUONTracker::~AliMUONTracker()
87{
e64fdf8a 88 /// dtor
196471e9 89 delete fTrackReco;
e64fdf8a 90 delete fTrackHitPatternMaker;
91 delete fClusterStore;
92 delete fTriggerStore;
196471e9 93}
94
95//_____________________________________________________________________________
3304fa09 96Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
196471e9 97{
e64fdf8a 98 /// Load clusterStore and triggerStore from clustersTree
99 delete fClusterStore;
100 delete fTriggerStore;
196471e9 101
6cfc11c3 102 if ( ! clustersTree ) {
103 AliFatal("No clustersTree");
104 return 1;
105 }
106
e64fdf8a 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);
196471e9 125
e64fdf8a 126 return 0;
127}
196471e9 128
e64fdf8a 129//_____________________________________________________________________________
3304fa09 130Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
e64fdf8a 131{
3304fa09 132 /// Performs the tracking and store the resulting tracks in the ESD
133 AliDebug(1,"");
134 AliCodeTimerAuto("")
e64fdf8a 135
3304fa09 136 if (!fTrackReco) CreateTrackReconstructor();
137
138 // if the required tracking mode does not exist
139 if (!fTrackReco) return 1;
140
141 if (!fClusterStore) {
e64fdf8a 142 AliError("ClusterStore is NULL");
6cfc11c3 143 return 2;
e64fdf8a 144 }
6cfc11c3 145
3304fa09 146 if (!fTriggerStore) {
e64fdf8a 147 AliError("TriggerStore is NULL");
6cfc11c3 148 return 3;
e64fdf8a 149 }
e64fdf8a 150
e64fdf8a 151 // Make tracker tracks
3304fa09 152 AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
153 fTrackReco->EventReconstruct(*fClusterStore,*trackStore);
e64fdf8a 154
3304fa09 155 // Make trigger tracks
156 AliMUONVTriggerTrackStore* triggerTrackStore(0x0);
157 if ( fTriggerCircuit ) {
e64fdf8a 158 triggerTrackStore = new AliMUONTriggerTrackStoreV1;
e64fdf8a 159 fTrackReco->EventReconstructTrigger(*fTriggerCircuit,*fTriggerStore,*triggerTrackStore);
160 }
161
3304fa09 162 // Match tracker/trigger tracks
163 if ( triggerTrackStore && fTrackHitPatternMaker ) {
e64fdf8a 164 fTrackReco->ValidateTracksWithTrigger(*trackStore,*triggerTrackStore,*fTriggerStore,*fTrackHitPatternMaker);
165 }
166
3304fa09 167 // Compute trigger chamber efficiency
168 if( triggerTrackStore && fTrigChamberEff){
2060b217 169 AliCodeTimerStart("EventChamberEff");
8c0b5e70 170 fTrigChamberEff->EventChamberEff(*fTriggerStore,*triggerTrackStore,*trackStore);
2060b217 171 AliCodeTimerStop("EventChamberEff");
8c0b5e70 172 }
3304fa09 173
174 // Fill ESD
e64fdf8a 175 FillESD(*trackStore,esd);
176
177 // cleanup
178 delete trackStore;
179 delete triggerTrackStore;
180
181 return 0;
182}
196471e9 183
e64fdf8a 184//_____________________________________________________________________________
3304fa09 185void AliMUONTracker::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 {
96ebe67e 208 AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>((track->GetTrackParamAtCluster())->First());
e64fdf8a 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
96ebe67e 222 esdTrack.SetChi2(track->GetGlobalChi2());
223 esdTrack.SetNHit(track->GetNClusters());
e64fdf8a 224 esdTrack.SetLocalTrigger(track->GetLocalTrigger());
225 esdTrack.SetChi2MatchTrigger(track->GetChi2MatchTrigger());
226 esdTrack.SetHitsPatternInTrigCh(track->GetHitsPatternInTrigCh());
60765b06 227 // muon cluster map
96ebe67e 228 while (trackParam) {
229 esdTrack.AddInMuonClusterMap(trackParam->GetClusterPtr()->GetChamberId());
230 trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->After(trackParam));
60765b06 231 }
e64fdf8a 232
233 // storing ESD MUON Track into ESD Event
234 esd->AddMuonTrack(&esdTrack);
235 } // end of loop on tracks
196471e9 236}
237
238//_____________________________________________________________________________
3304fa09 239void AliMUONTracker::CreateTrackReconstructor()
196471e9 240{
3304fa09 241 /// Create track reconstructor, depending on tracking mode set in RecoParam
242
243 TString opt(AliMUONReconstructor::GetRecoParam()->GetTrackingMode());
244 opt.ToUpper();
e64fdf8a 245
3304fa09 246 if (strstr(opt,"ORIGINAL"))
e64fdf8a 247 {
3304fa09 248 fTrackReco = new AliMUONTrackReconstructor();
e64fdf8a 249 }
3304fa09 250 else if (strstr(opt,"KALMAN"))
e64fdf8a 251 {
ea94c18b 252 fTrackReco = new AliMUONTrackReconstructorK();
e64fdf8a 253 }
3304fa09 254 else
255 {
256 AliError(Form("tracking mode \"%s\" does not exist",opt.Data()));
257 return;
258 }
259
260 AliInfo(Form("Will use %s for tracking",fTrackReco->ClassName()));
e64fdf8a 261}
196471e9 262
e64fdf8a 263//_____________________________________________________________________________
3304fa09 264void AliMUONTracker::UnloadClusters()
e64fdf8a 265{
266 /// Delete internal clusterStore
267 delete fClusterStore;
268 fClusterStore = 0x0;
196471e9 269}
e64fdf8a 270