X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=MUON%2FAliMUONRefitter.cxx;h=035f1d15ce2b307653ca14ccd356148ccd8dce0d;hb=2c8dd5b21a487fe2aeb1298f0db70f3d018eef07;hp=eefd745265d82475186a5bf0df809de37a56121b;hpb=5a240757bd78901da589c49d12109dbdd63cfe46;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONRefitter.cxx b/MUON/AliMUONRefitter.cxx index eefd745265d..035f1d15ce2 100644 --- a/MUON/AliMUONRefitter.cxx +++ b/MUON/AliMUONRefitter.cxx @@ -34,6 +34,7 @@ #include "AliMUONVTrackStore.h" #include "AliMUONTrack.h" #include "AliMUONTracker.h" +#include "AliMUONTrackParam.h" #include "AliLog.h" //----------------------------------------------------------------------------- @@ -109,7 +110,7 @@ AliMUONVTrackStore* AliMUONRefitter::ReconstructFromDigits() TIter next(fkESDInterface->CreateTrackIterator()); while ((track = static_cast(next()))) { AliMUONTrack *newTrack = RetrackFromDigits(*track); - newTrackStore->Add(newTrack); + if (newTrack) newTrackStore->Add(newTrack); delete newTrack; } @@ -162,7 +163,7 @@ AliMUONTrack* AliMUONRefitter::RetrackFromDigits(UInt_t trackId) //_____________________________________________________________________________ AliMUONTrack* AliMUONRefitter::RetrackFromClusters(UInt_t trackId) { - /// refit track "trackId" form the clusters (i.e. do not re-clusterize) + /// refit track "trackId" from the clusters (i.e. do not re-clusterize) /// it is the responsability of the user to delete the returned track if (!fkESDInterface) { @@ -212,7 +213,7 @@ AliMUONVClusterStore* AliMUONRefitter::ReClusterize(UInt_t trackId, UInt_t clust // re-clusterize TIter next(fkESDInterface->CreateDigitIterator(trackId, clusterId)); - fClusterServer->UseDigits(next); + fClusterServer->UseDigits(next,fkESDInterface->GetDigits()); fClusterServer->Clusterize(cluster->GetChamberId(),*clusterStore,AliMpArea(),fkRecoParam); return clusterStore; @@ -246,7 +247,7 @@ AliMUONVClusterStore* AliMUONRefitter::ReClusterize(UInt_t clusterId) // re-clusterize TIter next(fkESDInterface->CreateDigitIteratorInCluster(clusterId)); - fClusterServer->UseDigits(next); + fClusterServer->UseDigits(next,fkESDInterface->GetDigits()); fClusterServer->Clusterize(cluster->GetChamberId(),*clusterStore,AliMpArea(),fkRecoParam); return clusterStore; @@ -306,7 +307,7 @@ AliMUONTrack* AliMUONRefitter::RetrackFromDigits(const AliMUONTrack& track) // re-clusterize current cluster TIter nextDigit(fkESDInterface->CreateDigitIterator(trackId, cluster->GetUniqueID())); - fClusterServer->UseDigits(nextDigit); + fClusterServer->UseDigits(nextDigit,fkESDInterface->GetDigits()); Int_t nNewClusters = fClusterServer->Clusterize(cluster->GetChamberId(),*newClusterStore,AliMpArea(),fkRecoParam); // check that re-clusterizing succeeded @@ -318,13 +319,19 @@ AliMUONTrack* AliMUONRefitter::RetrackFromDigits(const AliMUONTrack& track) } // add the new cluster(s) to the tracks - AddClusterToTracks(*newClusterStore, *newTrackStore); + if (!AddClusterToTracks(*newClusterStore, *newTrackStore)) { + delete newClusterStore; + delete newTrackStore; + return 0x0; + } } + if (newTrackStore->GetSize() > 1000) AliInfo(Form("%d tracks to refit... be patient!!",newTrackStore->GetSize())); + // refit the tracks and pick up the best one AliMUONTrack *currentTrack, *bestTrack = 0x0; - Double_t currentChi2, bestChi2 = 1.e10; + Double_t currentChi2, bestChi2 = AliMUONTrack::MaxChi2(); Int_t currentNCluster, bestNClusters = 0; TIter next(newTrackStore->CreateIterator()); while ((currentTrack = static_cast(next()))) { @@ -334,7 +341,7 @@ AliMUONTrack* AliMUONRefitter::RetrackFromDigits(const AliMUONTrack& track) if (param) *param = *((AliMUONTrackParam*) track.GetTrackParamAtCluster()->First()); // refit the track - if (!fTracker->RefitTrack(*currentTrack)) break; + if (!fTracker->RefitTrack(*currentTrack)) continue; // find best track (the one with the higher number of cluster or the best chi2 in case of equality) currentNCluster = currentTrack->GetNClusters(); @@ -356,14 +363,20 @@ AliMUONTrack* AliMUONRefitter::RetrackFromDigits(const AliMUONTrack& track) } //_____________________________________________________________________________ -void AliMUONRefitter::AddClusterToTracks(const AliMUONVClusterStore &clusterStore, AliMUONVTrackStore &trackStore) +Bool_t AliMUONRefitter::AddClusterToTracks(const AliMUONVClusterStore &clusterStore, AliMUONVTrackStore &trackStore) { /// add clusters to each of the given tracks /// duplicate the tracks if there are several clusters and add one cluster per copy // create new track store if there are more than 1 cluster to add per track Int_t nClusters = clusterStore.GetSize(); - if (nClusters < 1) return; + if (nClusters < 1) return kTRUE; + + // check if we will exceed the maximum allowed number of tracks + if (nClusters * trackStore.GetSize() > fkRecoParam->GetMaxTrackCandidates()) { + AliError(Form("Too many track candidates (%d tracks). Stop refitting.", nClusters * trackStore.GetSize())); + return kFALSE; + } AliMUONTrackParam dummyParam; AliMUONTrack *currentTrack, *track; @@ -380,7 +393,7 @@ void AliMUONRefitter::AddClusterToTracks(const AliMUONVClusterStore &clusterStor // add the new cluster(s) to the tracks // duplicate the tracks if there are several clusters - // the loop after loading the last cluster which is added to the current track + // stop the loop after loading the last cluster which is added to the current track iCluster = 0; TIter nextCluster(clusterStore.CreateIterator()); while ((newCluster = static_cast(nextCluster())) && (iCluster < nClusters - 1)) { @@ -408,5 +421,7 @@ void AliMUONRefitter::AddClusterToTracks(const AliMUONVClusterStore &clusterStor } + return kTRUE; + }