Remove TClonesArray deletions (Philippe Pillot)
authorlaphecet <laphecet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 30 Jan 2012 18:47:45 +0000 (18:47 +0000)
committerlaphecet <laphecet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 30 Jan 2012 18:47:45 +0000 (18:47 +0000)
MUON/AliMUONTrackReconstructor.cxx
MUON/AliMUONTrackReconstructorK.cxx
MUON/AliMUONTrackerQADataMakerRec.cxx
MUON/AliMUONVTrackReconstructor.cxx

index b906d2d..fde9b41 100644 (file)
@@ -125,21 +125,17 @@ Bool_t AliMUONTrackReconstructor::MakeTrackCandidates(AliMUONVClusterStore& clus
          fNRecTracks--;
        } else if (fNRecTracks > GetRecoParam()->GetMaxTrackCandidates()) {
          AliError(Form("Too many track candidates (%d tracks). Stop tracking.", fNRecTracks));
-         delete segments;
          return kFALSE;
        }
       } else {
        if ((fNRecTracks + segments->GetEntriesFast() - iseg - 1) > GetRecoParam()->GetMaxTrackCandidates()) {
          AliError(Form("Too many track candidates (%d tracks). Stop tracking.", fNRecTracks + segments->GetEntriesFast() - iseg - 1));
-         delete segments;
          return kFALSE;
        }
       }
       
     }
     
-    // delete the array of segments
-    delete segments;
   }
   
   // Keep all different tracks or only the best ones as required
@@ -210,14 +206,11 @@ Bool_t AliMUONTrackReconstructor::MakeMoreTrackCandidates(AliMUONVClusterStore&
        // abort tracking if there are too many candidates
        if ((fNRecTracks + segments->GetEntriesFast() - iSegment - 1) > GetRecoParam()->GetMaxTrackCandidates()) {
          AliError(Form("Too many track candidates (%d tracks). Stop tracking.", fNRecTracks + segments->GetEntriesFast() - iSegment - 1));
-         delete segments;
          return kFALSE;
        }
        
       }
       
-      // delete the array of segments
-      delete segments;
     }
   }
   
index db0b4bf..25ef67b 100644 (file)
@@ -123,21 +123,17 @@ Bool_t AliMUONTrackReconstructorK::MakeTrackCandidates(AliMUONVClusterStore& clu
          fNRecTracks--;
        } else if (fNRecTracks > GetRecoParam()->GetMaxTrackCandidates()) {
          AliError(Form("Too many track candidates (%d tracks). Stop tracking.", fNRecTracks));
-         delete segments;
          return kFALSE;
        }
       } else {
        if ((fNRecTracks + segments->GetEntriesFast() - iSegment - 1) > GetRecoParam()->GetMaxTrackCandidates()) {
          AliError(Form("Too many track candidates (%d tracks). Stop tracking.", fNRecTracks + segments->GetEntriesFast() - iSegment - 1));
-         delete segments;
          return kFALSE;
        }
       }
       
     }
     
-    // delete the array of segments
-    delete segments;
   }
   
   // Keep all different tracks if required
@@ -227,14 +223,11 @@ Bool_t AliMUONTrackReconstructorK::MakeMoreTrackCandidates(AliMUONVClusterStore&
        // abort tracking if there are too many candidates
        if ((fNRecTracks + segments->GetEntriesFast() - iSegment - 1) > GetRecoParam()->GetMaxTrackCandidates()) {
          AliError(Form("Too many track candidates (%d tracks). Stop tracking.", fNRecTracks + segments->GetEntriesFast() - iSegment - 1));
-         delete segments;
          return kFALSE;
        }
        
       }
       
-      // delete the array of segments
-      delete segments;
     }
   }
   
index 95e4649..a4fa641 100644 (file)
@@ -1586,14 +1586,13 @@ void AliMUONTrackerQADataMakerRec::MakeESDs(AliESDEvent* esd)
   AliCodeTimerAuto(Form("%s",AliRecoParam::GetEventSpecieName(AliRecoParam::AConvert(Master()->GetEventSpecie()))),0);
    
   // load ESD event in the interface
-  AliMUONESDInterface esdInterface;
-  if (GetRecoParam()) AliMUONESDInterface::ResetTracker(GetRecoParam(), kFALSE);
-  else AliError("Unable to get recoParam: use default ones for residual calculation");
-  esdInterface.LoadEvent(*esd);
+  if (!AliMUONESDInterface::GetTracker()) {
+    if (GetRecoParam()) AliMUONESDInterface::ResetTracker(GetRecoParam(), kFALSE);
+    else AliError("Unable to get recoParam: use default ones for residual calculation");
+  }
   
-  FillESDsData(AliMUONQAIndices::kESDnTracks,esdInterface.GetNTracks());
   
-  Int_t nTrackMatchTrig = 0;
+  Int_t nTrkTracks = 0, nTrackMatchTrig = 0;
   
   // loop over tracks
   Int_t nTracks = (Int_t) esd->GetNumberOfMuonTracks(); 
@@ -1602,23 +1601,25 @@ void AliMUONTrackerQADataMakerRec::MakeESDs(AliESDEvent* esd)
     // get the ESD track and skip "ghosts"
     AliESDMuonTrack* esdTrack = esd->GetMuonTrack(iTrack);
     if (!esdTrack->ContainTrackerData()) continue;
+    nTrkTracks++;
     
     // get corresponding MUON track
-    AliMUONTrack* track = esdInterface.FindTrack(esdTrack->GetUniqueID());
+    AliMUONTrack track;
+    AliMUONESDInterface::ESDToMUON(*esdTrack, track);
     
     if (esdTrack->ContainTriggerData()) nTrackMatchTrig++;
     
     FillESDsData(AliMUONQAIndices::kESDMomentum,esdTrack->P());
     FillESDsData(AliMUONQAIndices::kESDPt,esdTrack->Pt());
     FillESDsData(AliMUONQAIndices::kESDRapidity,esdTrack->Y());
-    FillESDsData(AliMUONQAIndices::kESDChi2,track->GetNormalizedChi2());
-    FillESDsData(AliMUONQAIndices::kESDProbChi2,TMath::Prob(track->GetGlobalChi2(),track->GetNDF()));
+    FillESDsData(AliMUONQAIndices::kESDChi2,track.GetNormalizedChi2());
+    FillESDsData(AliMUONQAIndices::kESDProbChi2,TMath::Prob(track.GetGlobalChi2(),track.GetNDF()));
     FillESDsData(AliMUONQAIndices::kESDThetaX,esdTrack->GetThetaXUncorrected() / TMath::Pi() * 180.);
     FillESDsData(AliMUONQAIndices::kESDThetaY,esdTrack->GetThetaYUncorrected() / TMath::Pi() * 180.);
-    FillESDsData(AliMUONQAIndices::kESDnClustersPerTrack,track->GetNClusters());
+    FillESDsData(AliMUONQAIndices::kESDnClustersPerTrack,track.GetNClusters());
     
     // loop over clusters
-    AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->First());
+    AliMUONTrackParam* trackParam = static_cast<AliMUONTrackParam*>(track.GetTrackParamAtCluster()->First());
     while (trackParam) {
       
       AliMUONVCluster* cluster = trackParam->GetClusterPtr();
@@ -1660,12 +1661,13 @@ void AliMUONTrackerQADataMakerRec::MakeESDs(AliESDEvent* esd)
       FillESDsData(AliMUONQAIndices::kESDSumLocalChi2YPerDE,deID, localChi2Y);
       FillESDsData(AliMUONQAIndices::kESDSumLocalChi2PerDE,deID, localChi2);
       
-      trackParam = static_cast<AliMUONTrackParam*>(track->GetTrackParamAtCluster()->After(trackParam));
+      trackParam = static_cast<AliMUONTrackParam*>(track.GetTrackParamAtCluster()->After(trackParam));
       
     }
     
   }
 
+  FillESDsData(AliMUONQAIndices::kESDnTracks,nTrkTracks);
   FillESDsData(AliMUONQAIndices::kESDMatchTrig,nTrackMatchTrig);
   //
 }
index 80a23b9..b6bc90d 100644 (file)
@@ -280,8 +280,7 @@ Bool_t AliMUONVTrackReconstructor::IsAcceptable(AliMUONTrackParam &trackParam)
 TClonesArray* AliMUONVTrackReconstructor::MakeSegmentsBetweenChambers(const AliMUONVClusterStore& clusterStore, Int_t ch1, Int_t ch2)
 {
   /// To make the list of segments from the list of clusters in the 2 given chambers.
-  /// Return a new TClonesArray of segments.
-  /// It is the responsibility of the user to delete it afterward.
+  /// Return a TClonesArray of new segments (segments made in a previous call of this function are removed).
   AliDebug(1,Form("Enter MakeSegmentsBetweenChambers (1..) %d-%d", ch1+1, ch2+1));
   AliCodeTimerAuto("",0);
   
@@ -305,7 +304,8 @@ TClonesArray* AliMUONVTrackReconstructor::MakeSegmentsBetweenChambers(const AliM
   TIter nextInCh2(clusterStore.CreateChamberIterator(ch2,ch2));
   
   // list of segments
-  TClonesArray *segments = new TClonesArray("AliMUONObjectPair", 100);
+  static TClonesArray *segments = new TClonesArray("AliMUONObjectPair", 100);
+  segments->Clear("C");
   
   // Loop over clusters in the first chamber of the station
   while ( ( cluster1 = static_cast<AliMUONVCluster*>(nextInCh1()) ) ) {