]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTracker.cxx
o Updates by Remi
[u/mrichter/AliRoot.git] / MUON / AliMUONTracker.cxx
index 5223dbc8734058000eab07af8cf09ac1d35bcc6a..eccf3727953412cb90ddc6630c2190acb4ce3620 100644 (file)
@@ -58,6 +58,7 @@
 #include <Riostream.h>
 #include <TRandom.h>
 #include <TTree.h>
+#include "AliLog.h"
 
 /// \cond CLASSIMP
 ClassImp(AliMUONTracker)
@@ -83,9 +84,11 @@ fIsOwnerOfClusterServer(kFALSE),
 fkDigitStore(digitStore), // not owner
 fInputClusterStore(0x0),
 fTriggerTrackStore(0x0),
-fkRecoParam(recoParam)
+fkRecoParam(recoParam),
+fInternalTrackStore(0x0)
 {
   /// constructor
+  
   if (fkTransformer)
     fTrackHitPatternMaker = new AliMUONTrackHitPattern(recoParam,*fkTransformer,fkDigitStore,triggerUtilities);
   
@@ -107,6 +110,7 @@ fkRecoParam(recoParam)
 AliMUONTracker::~AliMUONTracker()
 {
   /// dtor
+  
   delete fTrackReco;
   delete fTrackHitPatternMaker;
   delete fClusterStore;
@@ -114,6 +118,7 @@ AliMUONTracker::~AliMUONTracker()
   if ( fIsOwnerOfClusterServer ) delete fClusterServer;
   delete fInputClusterStore;
   delete fTriggerTrackStore;
+  delete fInternalTrackStore;
 }
 
 //_____________________________________________________________________________
@@ -145,16 +150,15 @@ Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
 {
   /// Load triggerStore from clustersTree
 
-  delete fTriggerStore;
-  delete fInputClusterStore;
-  fInputClusterStore=0x0;
-
   if ( ! clustersTree ) {
     AliFatal("No clustersTree");
     return 1;
   }
 
-  fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);
+  if ( !fTriggerStore ) 
+  {
+    fTriggerStore = AliMUONVTriggerStore::Create(*clustersTree);    
+  }
   
   if (!fTriggerStore)
   {
@@ -162,22 +166,32 @@ Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
     return 2;
   }
   
-  if ( fIsOwnerOfClusterServer )
+  if (!fInputClusterStore) 
   {
     fInputClusterStore = AliMUONVClusterStore::Create(*clustersTree);
-    if ( fInputClusterStore ) 
+    if (!fInputClusterStore)
     {
-      AliDebug(1,Form("Created %s from cluster tree",fInputClusterStore->ClassName()));
-      fInputClusterStore->Clear();
-      fInputClusterStore->Connect(*clustersTree,kFALSE);
+      AliError("Could not get clusterStore");
+      return 3;
     }
-    delete fClusterServer;
-    fClusterServer = new AliMUONLegacyClusterServer(*fkTransformer,fInputClusterStore,
-                                                                                                                                                                                                               GetRecoParam()->BypassSt4(),
-                                                                                                                                                                                                               GetRecoParam()->BypassSt5());
-    SetupClusterServer(*fClusterServer);
+    AliDebug(1,Form("Created %s from cluster tree",fInputClusterStore->ClassName()));
+  }
+    
+  if ( !fClusterServer && fIsOwnerOfClusterServer )
+  {
+    if ( !fClusterServer ) 
+    {
+      fClusterServer = new AliMUONLegacyClusterServer(*fkTransformer,fInputClusterStore,
+                                                      GetRecoParam()->BypassSt4(),
+                                                      GetRecoParam()->BypassSt5());
+      SetupClusterServer(*fClusterServer);
+    }
+
   }
   
+  fInputClusterStore->Clear();
+  fInputClusterStore->Connect(*clustersTree,kFALSE);
+  fTriggerStore->Clear();
   fTriggerStore->Connect(*clustersTree,kFALSE);
   
   clustersTree->GetEvent(0);
@@ -189,12 +203,21 @@ Int_t AliMUONTracker::LoadClusters(TTree* clustersTree)
 Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
 {
   /// Performs the tracking and store the resulting tracks in the ESD
-  AliDebug(1,"");
+  ///
+  /// note that we're dealing with two cluster stores here : fInputClusterStore
+  /// and ClusterStore().
+  /// The first one is read from the TreeR and may be used by the cluster server 
+  /// (that's the case for the legacy cluster server) to fill the other one.
+  /// The second one is more dynamic and might be created on the fly by the cluster
+  /// server (used by the combined tracking, in which case the first one is not used
+  /// at all).
+  
   AliCodeTimerAuto("",0)
   
   if (!fTrackReco) 
   {
-    fTrackReco = CreateTrackReconstructor(GetRecoParam(),fClusterServer);
+    fTrackReco = CreateTrackReconstructor(GetRecoParam(),fClusterServer,fkTransformer);
+    fInternalTrackStore = new AliMUONTrackStoreV1;
   }
   
   // if the required tracking mode does not exist
@@ -230,21 +253,19 @@ Int_t AliMUONTracker::Clusters2Tracks(AliESDEvent* esd)
     return 0;
   }
        
-  // Make tracker tracks
-  AliMUONVTrackStore* trackStore = new AliMUONTrackStoreV1;
-  fTrackReco->EventReconstruct(*(ClusterStore()),*trackStore);
+  fTrackReco->EventReconstruct(*(ClusterStore()),*fInternalTrackStore);
   
   // Match tracker/trigger tracks
   if ( fTrackHitPatternMaker ) 
   {
-    fTrackReco->ValidateTracksWithTrigger(*trackStore,*(TriggerTrackStore()),*fTriggerStore,*fTrackHitPatternMaker);
+    fTrackReco->ValidateTracksWithTrigger(*fInternalTrackStore,*(TriggerTrackStore()),*fTriggerStore,*fTrackHitPatternMaker);
   }
   
   // Fill ESD
-  FillESD(*trackStore,esd);
+  FillESD(*fInternalTrackStore,esd);
   
-  // cleanup
-  delete trackStore;
+  fInternalTrackStore->Clear();
+  ClusterStore()->Clear();
   
   return 0;
 }
@@ -267,7 +288,6 @@ void AliMUONTracker::FillESD(const AliMUONVTrackStore& trackStore, AliESDEvent*
   // fill ESD event including all info in ESD cluster if required and only for the given fraction of events
   AliMUONTrack* track;
   AliMUONLocalTrigger* locTrg;
-  AliESDMuonTrack esdTrack;
   TIter next(trackStore.CreateIterator());
   if (GetRecoParam()->SaveFullClusterInESD() && 
       gRandom->Uniform(100.) <= GetRecoParam()->GetPercentOfFullClusterInESD()) {
@@ -276,10 +296,9 @@ void AliMUONTracker::FillESD(const AliMUONVTrackStore& trackStore, AliESDEvent*
       
       if (track->GetMatchTrigger() > 0) {
        locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(track->LoCircuit()));
-       AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, &fkDigitStore, locTrg);
-      } else AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, &fkDigitStore);
+       AliMUONESDInterface::MUONToESD(*track, *esd, vertex, &fkDigitStore, locTrg);
+      } else AliMUONESDInterface::MUONToESD(*track, *esd, vertex, &fkDigitStore);
       
-      esd->AddMuonTrack(&esdTrack);
     }
     
   } else {
@@ -288,10 +307,9 @@ void AliMUONTracker::FillESD(const AliMUONVTrackStore& trackStore, AliESDEvent*
       
       if (track->GetMatchTrigger() > 0) {
        locTrg = static_cast<AliMUONLocalTrigger*>(fTriggerStore->FindLocal(track->LoCircuit()));
-       AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex, 0x0, locTrg);
-      } else AliMUONESDInterface::MUONToESD(*track, esdTrack, vertex);
+       AliMUONESDInterface::MUONToESD(*track, *esd, vertex, 0x0, locTrg);
+      } else AliMUONESDInterface::MUONToESD(*track, *esd, vertex);
       
-      esd->AddMuonTrack(&esdTrack);
     }
     
   }
@@ -313,16 +331,17 @@ void AliMUONTracker::FillESD(const AliMUONVTrackStore& trackStore, AliESDEvent*
     }
     if (matched) continue;
 
-    AliMUONESDInterface::MUONToESD(*locTrg, esdTrack, ghostId, triggerTrack);
+    AliMUONESDInterface::MUONToESD(*locTrg, *esd, ghostId, triggerTrack);
     
-    esd->AddMuonTrack(&esdTrack);
     ghostId -= 1;
   }
   
 }
 
 //_____________________________________________________________________________
-AliMUONVTrackReconstructor* AliMUONTracker::CreateTrackReconstructor(const AliMUONRecoParam* recoParam, AliMUONVClusterServer* clusterServer)
+AliMUONVTrackReconstructor* AliMUONTracker::CreateTrackReconstructor(const AliMUONRecoParam* recoParam,
+                                                                    AliMUONVClusterServer* clusterServer,
+                                                                    const AliMUONGeometryTransformer* transformer)
 {
   /// Create track reconstructor, depending on tracking mode set in RecoParam
   
@@ -333,11 +352,11 @@ AliMUONVTrackReconstructor* AliMUONTracker::CreateTrackReconstructor(const AliMU
   
   if (strstr(opt,"ORIGINAL"))
   {
-    trackReco = new AliMUONTrackReconstructor(recoParam,clusterServer);
+    trackReco = new AliMUONTrackReconstructor(recoParam,clusterServer,transformer);
   }
   else if (strstr(opt,"KALMAN"))
   {
-    trackReco = new AliMUONTrackReconstructorK(recoParam,clusterServer);
+    trackReco = new AliMUONTrackReconstructorK(recoParam,clusterServer,transformer);
   }
   else
   {
@@ -355,8 +374,7 @@ void AliMUONTracker::UnloadClusters()
 {
   /// Clear internal clusterStore
   
-  delete fInputClusterStore;
-  fInputClusterStore = 0x0;
+  fInputClusterStore->Clear();
 }