]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MFT/AliMuonForwardTrackFinder.cxx
CA tracker - updates
[u/mrichter/AliRoot.git] / MFT / AliMuonForwardTrackFinder.cxx
index 39d4eaa8d658920ab91c78ae51643f0748ee018c..484d1328f5e8dbdcaea5560f00240442d2386ca3 100644 (file)
@@ -71,6 +71,8 @@ AliMuonForwardTrackFinder::AliMuonForwardTrackFinder():
   fRun(0),
   fNEventsToAnalyze(0),
   fSigmaClusterCut(0),
+  fScaleSigmaClusterCut(1.),
+  fGlobalTrackingDiverged(kFALSE),
   fChi2GlobalCut(0),
   fSigmaSpectrometerCut(0),
   fVertexErrorX(0.015),
@@ -152,7 +154,8 @@ AliMuonForwardTrackFinder::AliMuonForwardTrackFinder():
   fMuonForwardTracks(0),
   fMatchingMode(-1),
   fGRPData(0),
-  fRunInfo(0)
+  fRunInfo(0),
+  fBransonCorrection(kTRUE)
 
 {
 
@@ -421,11 +424,20 @@ Bool_t AliMuonForwardTrackFinder::LoadNextEvent() {
   
   AliInfo(Form(" **** analyzing event # %d  \n", fEv));
   
-  fTrackStore    = fMuonRecoCheck->ReconstructedTracks(fEv);
-  if (fTrackStore->IsEmpty()) return kFALSE;
+  fTrackStore = fMuonRecoCheck->ReconstructedTracks(fEv);
+  if (fTrackStore->IsEmpty()) {
+    AliInfo("fTrackStore Is Empty: exiting NOW!");
+    return kFALSE;
+  }
+  AliInfo("fTrackStore contains tracks!");
+
+  AliDebug(2, Form("Getting fMuonRecoCheck->ReconstructibleTracks(%d)", fEv));
   fTrackRefStore = fMuonRecoCheck->ReconstructibleTracks(fEv);
   
+  AliDebug(2, Form("Getting fRunLoader->GetEvent(%d)", fEv));
   fRunLoader->GetEvent(fEv);
+
+  AliDebug(2, Form("fMFTLoader->TreeR() = %p",fMFTLoader->TreeR()));
   if (!fMFTLoader->TreeR()->GetEvent()) return kFALSE;
   for (Int_t iPlane=0; iPlane<fNPlanesMFT; iPlane++) {
     AliDebug(1, Form("plane %02d: nClusters = %d\n", iPlane, (fMFT->GetRecPointsList(iPlane))->GetEntries()));
@@ -452,22 +464,19 @@ Int_t AliMuonForwardTrackFinder::LoadNextTrack() {
 
   // load next muon track from the reconstructed event
 
-  if (fCountRealTracksAnalyzed>fMaxNTracksToBeAnalyzed) return kFALSE;
-
+  if (fCountRealTracksAnalyzed>=fMaxNTracksToBeAnalyzed) return kFALSE;
   if (!fCountRealTracksAnalyzed) if (!LoadNextEvent()) return kFALSE;
-  if (fCountRealTracksAnalyzed==fMaxNTracksToBeAnalyzed) {
+
+  if (!fGlobalTrackingDiverged) {
+    while ( !(fMuonTrackReco = static_cast<AliMUONTrack*>(fNextTrack->Next())) ) if (!LoadNextEvent()) return kFALSE;
     fCountRealTracksAnalyzed++;
-    if (!LoadNextEvent()) return kFALSE;
+    fCountRealTracksAnalyzedOfEvent++;
   }
 
-  while ( !(fMuonTrackReco = static_cast<AliMUONTrack*>(fNextTrack->Next())) ) if (!LoadNextEvent()) return kFALSE;
-
   AliDebug(1, "**************************************************************************************\n");
   AliDebug(1, Form("***************************   MUON TRACK %3d   ***************************************\n", fCountRealTracksAnalyzedOfEvent));
   AliDebug(1, "**************************************************************************************\n");
 
-  fCountRealTracksAnalyzed++;
-
   fCandidateTracks -> Delete();
 
   fLabelMC = -1;
@@ -497,7 +506,7 @@ Int_t AliMuonForwardTrackFinder::LoadNextTrack() {
 
   Int_t motherPdg=0;
   if (fLabelMC>=0) {
-    fCountRealTracksWithRefMC++;
+    if (!fGlobalTrackingDiverged) fCountRealTracksWithRefMC++;
     if (fStack->Particle(fLabelMC)->GetFirstMother() != -1) {
       motherPdg = fStack->Particle(fStack->Particle(fLabelMC)->GetFirstMother())->GetPdgCode();
     }
@@ -505,12 +514,12 @@ Int_t AliMuonForwardTrackFinder::LoadNextTrack() {
 
   CheckCurrentMuonTrackable();
 
-  if (fMuonTrackReco->GetMatchTrigger()) fCountRealTracksWithRefMC_andTrigger++;
+  if (!fGlobalTrackingDiverged) if (fMuonTrackReco->GetMatchTrigger()) fCountRealTracksWithRefMC_andTrigger++;
   
   // the track we are going to build, starting from fMuonTrackReco and adding the MFT clusters
   AliMuonForwardTrack *track = new ((*fCandidateTracks)[0]) AliMuonForwardTrack();
-  track -> SetMUONTrack(fMuonTrackReco);
-  if (fLabelMC>=0 && fStack->Particle(fLabelMC)) track->SetMCTrackRef(fStack->Particle(fLabelMC));
+  track -> SetMUONTrack(new AliMUONTrack(*fMuonTrackReco));
+  if (fLabelMC>=0 && fStack->Particle(fLabelMC)) track->SetMCTrackRef(new TParticle(*(fStack->Particle(fLabelMC))));
   track -> SetMCLabel(fMuonTrackReco->GetMCLabel());
   track -> SetMatchTrigger(fMuonTrackReco->GetMatchTrigger());
 
@@ -547,6 +556,7 @@ Int_t AliMuonForwardTrackFinder::LoadNextTrack() {
   Double_t yEndOfAbsorber = trackParamEndOfAbsorber.GetBendingCoor();
   Double_t rAbsorber      = TMath::Sqrt(xEndOfAbsorber*xEndOfAbsorber + yEndOfAbsorber*yEndOfAbsorber);
   fHistRadiusEndOfAbsorber -> Fill(rAbsorber);
+  track -> SetRAtAbsorberEnd(rAbsorber);
   
   // if the radial distance of the track at the end of the absorber is smaller than a given radius, skip to the next track
   if (rAbsorber < fRAbsorberCut) return 4;
@@ -567,7 +577,11 @@ Int_t AliMuonForwardTrackFinder::LoadNextTrack() {
        fCurrentTrack = (AliMuonForwardTrack*) fCandidateTracks->UncheckedAt(iTrack);
        // if the old track is compatible with the new cluster, the track is updated and inserted as new track in the array 
        // (several new tracks can be created for one old track)
-       FindClusterInPlane(iPlane);   
+       if (FindClusterInPlane(iPlane) == kDiverged) {
+         fGlobalTrackingDiverged = kTRUE;
+         if (fScaleSigmaClusterCut>0) fScaleSigmaClusterCut -= 0.1;
+         return 6;
+       }
        if ((fNPlanesMFTAnalyzed-fCurrentTrack->GetNMFTClusters())>fNMaxMissingMFTClusters || fIsPlaneMandatory[iPlane]) {
          fCandidateTracks->Remove(fCurrentTrack);     // the old track is removed after the check;
        }
@@ -590,6 +604,9 @@ Int_t AliMuonForwardTrackFinder::LoadNextTrack() {
   
   // -------------------------- END OF THE CYCLE OVER THE MFT PLANES --------------------------------------------
   
+  fGlobalTrackingDiverged = kFALSE;
+  fScaleSigmaClusterCut = 1.0;
+
   AliDebug(1, "Finished cycle over planes");
 
   Double_t momentum = pt * TMath::CosH(eta);
@@ -684,26 +701,26 @@ Int_t AliMuonForwardTrackFinder::LoadNextTrack() {
 
     //    fOutputQAFile->cd();
 
-    Float_t finalCandidatesInfo[] = {Double_t(fRun),
-                                    Double_t(fEv),
-                                    Double_t(fCountRealTracksAnalyzedOfEvent),
-                                    Double_t(nFinalTracks),
-                                    Double_t(fLabelMC>=0),
-                                    xVtx, yVtx, zVtx,
-                                    motherPdg,
-                                    Double_t(fMuonTrackReco->GetMatchTrigger()),
-                                    Double_t(nClustersMC),
-                                    Double_t(nGoodClusters),
-                                    pt, theta, eta
-                                    chi2AtPlane[0],
-                                    chi2AtPlane[1],
-                                    chi2AtPlane[2],
-                                    chi2AtPlane[3],
-                                    chi2AtPlane[4],
-                                    chi2AtPlane[5],
-                                    chi2AtPlane[6],
-                                    chi2AtPlane[7],
-                                    chi2AtPlane[8]};
+    Float_t finalCandidatesInfo[] = {static_cast<Float_t>(fRun),
+                                    static_cast<Float_t>(fEv),
+                                    static_cast<Float_t>(fCountRealTracksAnalyzedOfEvent),
+                                    static_cast<Float_t>(nFinalTracks),
+                                    static_cast<Float_t>(fLabelMC>=0),
+                                    static_cast<Float_t>(xVtx), static_cast<Float_t>(yVtx), static_cast<Float_t>(zVtx),
+                                    static_cast<Float_t>(motherPdg),
+                                    static_cast<Float_t>(fMuonTrackReco->GetMatchTrigger()),
+                                    static_cast<Float_t>(nClustersMC),
+                                    static_cast<Float_t>(nGoodClusters),
+                                    static_cast<Float_t>(pt), static_cast<Float_t>(theta), static_cast<Float_t>(eta)
+                                    static_cast<Float_t>(chi2AtPlane[0]),
+                                    static_cast<Float_t>(chi2AtPlane[1]),
+                                    static_cast<Float_t>(chi2AtPlane[2]),
+                                    static_cast<Float_t>(chi2AtPlane[3]),
+                                    static_cast<Float_t>(chi2AtPlane[4]),
+                                    static_cast<Float_t>(chi2AtPlane[5]),
+                                    static_cast<Float_t>(chi2AtPlane[6]),
+                                    static_cast<Float_t>(chi2AtPlane[7]),
+                                    static_cast<Float_t>(chi2AtPlane[8])};
     
     fNtuFinalCandidates -> Fill(finalCandidatesInfo);
 
@@ -740,40 +757,41 @@ Int_t AliMuonForwardTrackFinder::LoadNextTrack() {
     FillPlanesWithTrackHistory();
     AliMuonForwardTrack *newTrack = (AliMuonForwardTrack*) fCandidateTracks->UncheckedAt(idBestCandidate);
     newTrack -> SetNWrongClustersMC(newTrack->GetNMFTClusters() - nGoodClustersBestCandidate);
+    newTrack -> SetTrackMCId(fRun*100000+fEv*1000+fCountRealTracksAnalyzedOfEvent);
     new ((*fMuonForwardTracks)[fMuonForwardTracks->GetEntries()]) AliMuonForwardTrack(*newTrack);
   }
 
   //  fOutputQAFile->cd();
   
-  Float_t finalBestCandidatesInfo[] = {Double_t(fRun),
-                                      Double_t(fEv),
-                                      Double_t(fCountRealTracksAnalyzedOfEvent),
-                                      Double_t(nFinalTracks),
-                                      Double_t(fLabelMC>=0),
-                                      xVtx, yVtx, zVtx,
-                                      motherPdg,
-                                      Double_t(fMuonTrackReco->GetMatchTrigger()),
-                                      Double_t(nClustersMC),
-                                      Double_t(nGoodClustersBestCandidate),
-                                      pt, theta, eta,
-                                      chi2HistoryForBestCandidate[0],
-                                      chi2HistoryForBestCandidate[1],
-                                      chi2HistoryForBestCandidate[2],
-                                      chi2HistoryForBestCandidate[3],
-                                      chi2HistoryForBestCandidate[4],
-                                      chi2HistoryForBestCandidate[5],
-                                      chi2HistoryForBestCandidate[6],
-                                      chi2HistoryForBestCandidate[7],
-                                      chi2HistoryForBestCandidate[8],
-                                      nClustersPerPlane[0],
-                                      nClustersPerPlane[1],
-                                      nClustersPerPlane[2],
-                                      nClustersPerPlane[3],
-                                      nClustersPerPlane[4],
-                                      nClustersPerPlane[5],
-                                      nClustersPerPlane[6],
-                                      nClustersPerPlane[7],
-                                      nClustersPerPlane[8]};
+  Float_t finalBestCandidatesInfo[] = {static_cast<Float_t>(fRun),
+                                      static_cast<Float_t>(fEv),
+                                      static_cast<Float_t>(fCountRealTracksAnalyzedOfEvent),
+                                      static_cast<Float_t>(nFinalTracks),
+                                      static_cast<Float_t>(fLabelMC>=0),
+                                      static_cast<Float_t>(xVtx), static_cast<Float_t>(yVtx), static_cast<Float_t>(zVtx),
+                                      static_cast<Float_t>(motherPdg),
+                                      static_cast<Float_t>(fMuonTrackReco->GetMatchTrigger()),
+                                      static_cast<Float_t>(nClustersMC),
+                                      static_cast<Float_t>(nGoodClustersBestCandidate),
+                                      static_cast<Float_t>(pt), static_cast<Float_t>(theta), static_cast<Float_t>(eta),
+                                      static_cast<Float_t>(chi2HistoryForBestCandidate[0]),
+                                      static_cast<Float_t>(chi2HistoryForBestCandidate[1]),
+                                      static_cast<Float_t>(chi2HistoryForBestCandidate[2]),
+                                      static_cast<Float_t>(chi2HistoryForBestCandidate[3]),
+                                      static_cast<Float_t>(chi2HistoryForBestCandidate[4]),
+                                      static_cast<Float_t>(chi2HistoryForBestCandidate[5]),
+                                      static_cast<Float_t>(chi2HistoryForBestCandidate[6]),
+                                      static_cast<Float_t>(chi2HistoryForBestCandidate[7]),
+                                      static_cast<Float_t>(chi2HistoryForBestCandidate[8]),
+                                      static_cast<Float_t>(nClustersPerPlane[0]),
+                                      static_cast<Float_t>(nClustersPerPlane[1]),
+                                      static_cast<Float_t>(nClustersPerPlane[2]),
+                                      static_cast<Float_t>(nClustersPerPlane[3]),
+                                      static_cast<Float_t>(nClustersPerPlane[4]),
+                                      static_cast<Float_t>(nClustersPerPlane[5]),
+                                      static_cast<Float_t>(nClustersPerPlane[6]),
+                                      static_cast<Float_t>(nClustersPerPlane[7]),
+                                      static_cast<Float_t>(nClustersPerPlane[8])};
   
   fNtuFinalBestCandidates -> Fill(finalBestCandidatesInfo);
   
@@ -787,15 +805,13 @@ Int_t AliMuonForwardTrackFinder::LoadNextTrack() {
   fCandidateTracks->Delete();
   fFinalBestCandidate = NULL;
   
-  fCountRealTracksAnalyzedOfEvent++;
-
   return 5;
   
 }
 
 //===========================================================================================================================================
 
-void AliMuonForwardTrackFinder::FindClusterInPlane(Int_t planeId) { 
+Int_t AliMuonForwardTrackFinder::FindClusterInPlane(Int_t planeId) { 
   
   AliDebug(2, Form(">>>> executing AliMuonForwardTrackFinder::FindClusterInPlane(%d)\n", planeId));
 
@@ -815,8 +831,14 @@ void AliMuonForwardTrackFinder::FindClusterInPlane(Int_t planeId) {
     Double_t xExtrap = gRandom->Gaus(0,fVertexErrorX);
     Double_t yExtrap = gRandom->Gaus(0,fVertexErrorY);
     Double_t zExtrap = gRandom->Gaus(0,fVertexErrorZ);
-    AliMUONTrackExtrap::ExtrapToVertex(&currentParamFront, xExtrap, yExtrap, zExtrap, fVertexErrorX, fVertexErrorY); 
-    AliMUONTrackExtrap::ExtrapToVertex(&currentParamBack,  xExtrap, yExtrap, zExtrap, fVertexErrorX, fVertexErrorY); 
+    if (fBransonCorrection) {
+      AliMUONTrackExtrap::ExtrapToVertex(&currentParamFront, xExtrap, yExtrap, zExtrap, fVertexErrorX, fVertexErrorY); 
+      AliMUONTrackExtrap::ExtrapToVertex(&currentParamBack,  xExtrap, yExtrap, zExtrap, fVertexErrorX, fVertexErrorY); 
+    }
+    else {
+      AliMUONTrackExtrap::ExtrapToVertexWithoutBranson(&currentParamFront, zExtrap);
+      AliMUONTrackExtrap::ExtrapToVertexWithoutBranson(&currentParamBack,  zExtrap);
+    }
     AliMUONTrackExtrap::ExtrapToVertex(&currentParamForResearchFront, xExtrap, yExtrap, zExtrap, fVertexErrorX, fVertexErrorY); 
     AliMUONTrackExtrap::ExtrapToVertex(&currentParamForResearchBack,  xExtrap, yExtrap, zExtrap, fVertexErrorX, fVertexErrorY); 
   }
@@ -871,7 +893,7 @@ void AliMuonForwardTrackFinder::FindClusterInPlane(Int_t planeId) {
 
   //---------------------------------------------------------------------------------------
 
-  Double_t chi2cut = 2.*fSigmaClusterCut*fSigmaClusterCut;     // depends on the number of variables (here, 2)
+  Double_t chi2cut = 2.*fScaleSigmaClusterCut*fScaleSigmaClusterCut*fSigmaClusterCut*fSigmaClusterCut;     // depends on the number of variables (here, 2)
   
   // Analyizing the clusters: FRONT ACTIVE ELEMENTS
   
@@ -906,8 +928,9 @@ void AliMuonForwardTrackFinder::FindClusterInPlane(Int_t planeId) {
     if (isGoodChi2) {
       AliDebug(3, Form("accepting cluster: chi2=%f (cut = %f)\n", chi2, chi2cut));
       AliMuonForwardTrack *newTrack = new ((*fCandidateTracks)[fCandidateTracks->GetEntriesFast()]) AliMuonForwardTrack(*fCurrentTrack);
+      if (fCandidateTracks->GetEntriesFast() > fMaxNCandidates) return kDiverged;
       newTrack->AddTrackParamAtMFTCluster(currentParamFront, *cluster);    // creating new track param and attaching the cluster
-      AliDebug(1, Form("After plane %02d: newTrack->GetNMFTClusters() = %d (fCurrentTrack->GetNMFTClusters() = %d)", 
+      AliDebug(2, Form("After plane %02d: newTrack->GetNMFTClusters() = %d (fCurrentTrack->GetNMFTClusters() = %d)", 
                       planeId, newTrack->GetNMFTClusters(), fCurrentTrack->GetNMFTClusters()));
       newTrack->SetPlaneExists(planeId);
       AliDebug(2, Form("current muon is trackable: %d\n", fIsCurrentMuonTrackable));
@@ -959,8 +982,9 @@ void AliMuonForwardTrackFinder::FindClusterInPlane(Int_t planeId) {
     if (isGoodChi2) {
       AliDebug(3,Form("accepting cluster: chi2=%f (cut = %f)\n", chi2, chi2cut));
       AliMuonForwardTrack *newTrack = new ((*fCandidateTracks)[fCandidateTracks->GetEntriesFast()]) AliMuonForwardTrack(*fCurrentTrack);
+      if (fCandidateTracks->GetEntriesFast() > fMaxNCandidates) return kDiverged;
       newTrack->AddTrackParamAtMFTCluster(currentParamBack, *cluster);    // creating new track param and attaching the cluster
-      AliDebug(1, Form("After plane %02d: newTrack->GetNMFTClusters() = %d (fCurrentTrack->GetNMFTClusters() = %d)", 
+      AliDebug(2, Form("After plane %02d: newTrack->GetNMFTClusters() = %d (fCurrentTrack->GetNMFTClusters() = %d)", 
                       planeId, newTrack->GetNMFTClusters(), fCurrentTrack->GetNMFTClusters()));
       newTrack->SetPlaneExists(planeId);
       AliDebug(2, Form("current muon is trackable: %d\n", fIsCurrentMuonTrackable));
@@ -989,6 +1013,8 @@ void AliMuonForwardTrackFinder::FindClusterInPlane(Int_t planeId) {
       fHistDistanceGoodClusterFromTrackAtLastPlane -> Fill(fDistanceFromGoodClusterAndTrackAtLastPlane);
     }
   }
+
+  return kConverged;
   
 }
 
@@ -1158,6 +1184,7 @@ Double_t AliMuonForwardTrackFinder::TryOneCluster(const AliMUONTrackParam &track
 void AliMuonForwardTrackFinder::SeparateFrontBackClusters() {
 
   for (Int_t iPlane=0; iPlane<fNPlanesMFT; iPlane++) {
+    printf("Separating front/back clusters\n");
     fMFTClusterArrayFront[iPlane]->Delete();
     fMFTClusterArrayBack[iPlane] ->Delete();
     for (Int_t iCluster=0; iCluster<fMFTClusterArray[iPlane]->GetEntries(); iCluster++) {
@@ -1387,12 +1414,13 @@ void AliMuonForwardTrackFinder::PrintParticleHistory() {
   TParticle *part = 0;
   if (fLabelMC>=0) part = fStack->Particle(fLabelMC);
 
-  AliDebug(1, Form("fStack->Particle(fLabelMC) = %p", part));
+  AliDebug(1, Form("fStack->Particle(%d) = %p", fLabelMC, part));
 
   if (part) {
+    AliDebug(1, Form("fStack->Particle(%d)->GetPdgCode() = %d", fLabelMC, part->GetPdgCode()));
     if (part->GetFirstMother() != -1) {
       TParticle *partMother = fStack->Particle(part->GetFirstMother());
-      AliDebug(1, Form("fStack->Particle(part->GetFirstMother() = %p", partMother));
+      AliDebug(1, Form("fStack->Particle(%d) = %p", part->GetFirstMother(), partMother));
       if (partMother) {
        Char_t newName[100];
        if (partMother->GetFirstMother() != -1) history += "...  #rightarrow ";
@@ -1401,6 +1429,8 @@ void AliMuonForwardTrackFinder::PrintParticleHistory() {
       }
     }
     Char_t newName[100];
+    AliDebug(1, Form("fStack->Particle(%d)->GetPdgCode() = %d", fLabelMC, part->GetPdgCode()));
+    AliDebug(1, Form("fStack->Particle(%d)->GetName() = %s", fLabelMC, part->GetName()));
     PDGNameConverter(part->GetName(), newName);
     history += Form("%s  at  z = %5.1f cm", newName, part->Vz());
     //  printf("%s", history.Data());