]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALTracker.cxx
remove checking of MC lable of track and cluster to set the goodness or badness of...
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTracker.cxx
index 9b8d594a3d052908990d3efdb2cd3f3d6804e60f..3518383f4153017ab4f4a7b0234ec359ba8e8ad6 100644 (file)
@@ -58,8 +58,6 @@
 
 ClassImp(AliEMCALTracker)
 
-AliEMCALRecParam* AliEMCALTracker::fgkRecParam = 0;  // EMCAL rec. parameters
-
 //
 //------------------------------------------------------------------------------
 //
@@ -74,6 +72,8 @@ AliEMCALTracker::AliEMCALTracker()
     fCutAlphaMax(200.0),
     fCutAngle(100.0),
     fMaxDist(10.0),
+    fCutNITS(3.0),
+    fCutNTPC(20.0),
     fRho(1.0),
     fX0(1.0),
     fTracks(0),
@@ -87,8 +87,7 @@ AliEMCALTracker::AliEMCALTracker()
        // and all collections to NULL.
        // Output file name is set to a default value.
        //
-       
-       InitParameters();
+  InitParameters();
 }
 //
 //------------------------------------------------------------------------------
@@ -104,6 +103,8 @@ AliEMCALTracker::AliEMCALTracker(const AliEMCALTracker& copy)
     fCutAlphaMax(copy.fCutAlphaMax),
     fCutAngle(copy.fCutAngle),
     fMaxDist(copy.fMaxDist),
+    fCutNITS(copy.fCutNITS),
+    fCutNTPC(copy.fCutNTPC),
     fRho(copy.fRho),
     fX0(copy.fX0),
     fTracks((TObjArray*)copy.fTracks->Clone()),
@@ -133,6 +134,8 @@ AliEMCALTracker& AliEMCALTracker::operator=(const AliEMCALTracker& copy)
        fCutAlphaMax = copy.fCutAlphaMax;
        fCutAngle = copy.fCutAngle;
        fMaxDist = copy.fMaxDist;
+       fCutNITS = copy.fCutNITS;
+       fCutNTPC = copy.fCutNTPC;
        
        fTracks = (TObjArray*)copy.fTracks->Clone();
        fClusters = (TObjArray*)copy.fClusters->Clone();
@@ -152,27 +155,22 @@ void AliEMCALTracker::InitParameters()
        //
        
   // Check if the instance of AliEMCALRecParam exists, 
-  // if not, get it from OCDB if available, otherwise create a default one
-  
-  if (!fgkRecParam  && (AliCDBManager::Instance()->IsDefaultStorageSet())) {
-    AliCDBEntry *entry = (AliCDBEntry*) 
-      AliCDBManager::Instance()->Get("EMCAL/Config/RecParam");
-    if (entry) fgkRecParam =  (AliEMCALRecParam*) entry->GetObject();
-  }
-  
-  if(!fgkRecParam){
-    AliWarning("The Track Matching parameters for EMCAL nonitialized - Used default one");
-    fgkRecParam = new AliEMCALRecParam;
+  const AliEMCALRecParam* recParam = new AliEMCALRecParam();
+
+  if(!recParam){
+    AliFatal("Reconstruction parameters for EMCAL not set!");
   }
   
-  fCutX =  fgkRecParam->GetTrkCutX();
-  fCutY =  fgkRecParam->GetTrkCutY();
-  fCutZ =  fgkRecParam->GetTrkCutZ();
-  fMaxDist =  fgkRecParam->GetTrkCutR();
-  fCutAngle =  fgkRecParam->GetTrkCutAngle();
-  fCutAlphaMin =  fgkRecParam->GetTrkCutAlphaMin();
-  fCutAlphaMax =  fgkRecParam->GetTrkCutAlphaMax();
-  
+  fCutX =  recParam->GetTrkCutX();
+  fCutY =  recParam->GetTrkCutY();
+  fCutZ =  recParam->GetTrkCutZ();
+  fMaxDist =  recParam->GetTrkCutR();
+  fCutAngle =  recParam->GetTrkCutAngle();
+  fCutAlphaMin =  recParam->GetTrkCutAlphaMin();
+  fCutAlphaMax =  recParam->GetTrkCutAlphaMax();
+  fCutNITS = recParam->GetTrkCutNITS();
+  fCutNTPC = recParam->GetTrkCutNTPC();
+
 }
 //
 //------------------------------------------------------------------------------
@@ -289,9 +287,9 @@ Int_t AliEMCALTracker::LoadClusters(TTree *cTree)
         clusters->Delete();
         delete clusters;
         if (fClusters->IsEmpty())
-           AliWarning("No clusters collected");
+           AliDebug(1,"No clusters collected");
 
-       AliInfo(Form("Collected %d clusters (RecPoints)", fClusters->GetEntries()));
+       AliDebug(1,Form("Collected %d clusters (RecPoints)", fClusters->GetEntries()));
 
        return 0;
 }
@@ -308,8 +306,8 @@ Int_t AliEMCALTracker::LoadClusters(AliESDEvent *esd)
        // make sure that tracks/clusters collections are empty
        Clear("CLUSTERS");
        
-       Int_t start = esd->GetFirstEMCALCluster();
-       Int_t nClustersEMC = esd->GetNumberOfEMCALClusters();
+       Int_t start = 0;
+       Int_t nClustersEMC = esd->GetNumberOfCaloClusters();
        Int_t end = start + nClustersEMC;
        
        fClusters = new TObjArray(0);
@@ -318,14 +316,14 @@ Int_t AliEMCALTracker::LoadClusters(AliESDEvent *esd)
        for (i = start; i < end; i++) {
                AliESDCaloCluster *cluster = esd->GetCaloCluster(i);
                if (!cluster) continue;
-               if (cluster->GetClusterType() != AliESDCaloCluster::kEMCALClusterv1) continue;
+        if (!cluster->IsEMCAL()) continue ; 
                AliEMCALMatchCluster *matchCluster = new AliEMCALMatchCluster(i, cluster);
                fClusters->AddLast(matchCluster);
        }
         if (fClusters->IsEmpty())
-           AliWarning("No clusters collected");
+           AliDebug(1,"No clusters collected");
        
-       AliInfo(Form("Collected %d clusters from ESD", fClusters->GetEntries()));
+       AliDebug(1,Form("Collected %d clusters from ESD", fClusters->GetEntries()));
 
        return 0;
 }
@@ -374,10 +372,10 @@ Int_t AliEMCALTracker::LoadTracks(AliESDEvent *esd)
                fTracks->AddLast(track);
        }
        if (fTracks->IsEmpty()) {
-               AliWarning("No tracks collected");
+               AliDebug(1,"No tracks collected");
        }
        
-       AliInfo(Form("Collected %d tracks", fTracks->GetEntries()));
+       AliDebug(1,Form("Collected %d tracks", fTracks->GetEntries()));
 
        return 0;
 }
@@ -422,17 +420,17 @@ Int_t AliEMCALTracker::PropagateBack(AliESDEvent* esd)
        // IF no clusters lie within the maximum allowed distance, no matches are assigned.
        Int_t nMatches = CreateMatches();
        if (!nMatches) {
-               AliInfo(Form("#clusters = %d -- #tracks = %d --> No good matches found.", nClusters, nTracks));
+               AliDebug(1,Form("#clusters = %d -- #tracks = %d --> No good matches found.", nClusters, nTracks));
                return 0;
        }
        else {
-               AliInfo(Form("#clusters = %d -- #tracks = %d --> Found %d matches.", nClusters, nTracks, nMatches));
+               AliDebug(1,Form("#clusters = %d -- #tracks = %d --> Found %d matches.", nClusters, nTracks, nMatches));
        }
        
        // step 4:
        // when more than 1 track share the same matched cluster, only the closest one is kept.
        Int_t nRemoved = SolveCompetitions();
-       AliInfo(Form("Removed %d duplicate matches", nRemoved));
+       AliDebug(1,Form("Removed %d duplicate matches", nRemoved));
        if (nRemoved >= nMatches) {
                AliError("Removed ALL matches! Check the algorithm or data. Nothing to save");
                return 5;
@@ -440,7 +438,7 @@ Int_t AliEMCALTracker::PropagateBack(AliESDEvent* esd)
        
        // step 5:
        // save obtained information setting the 'fEMCALindex' field of AliESDtrack object
-       Int_t nSaved = 0, trackID, nGood = 0, nFake = 0;
+       Int_t nSaved = 0, trackID;
        TListIter iter(fMatches);
        AliEMCALMatch *match = 0;
        while ( (match = (AliEMCALMatch*)iter.Next()) ) {
@@ -450,14 +448,12 @@ Int_t AliEMCALTracker::PropagateBack(AliESDEvent* esd)
                trackID = track->GetSeedIndex();
                AliESDtrack *esdTrack = esd->GetTrack(trackID);
                if (!esdTrack) continue;
-               if (TMath::Abs(esdTrack->GetLabel()) == cluster->Label()) {
-                       esdTrack->SetEMCALcluster(cluster->Index());
-                       nGood++;
-               }
-               else {
-                       esdTrack->SetEMCALcluster(-cluster->Index());
-                       nFake++;
-               }
+
+               // cut on its and tpc track hits
+               if(esdTrack->GetNcls(0)<=fCutNITS)continue;
+               if(esdTrack->GetNcls(1)<=fCutNTPC)continue;
+             
+               esdTrack->SetEMCALcluster(cluster->Index());
                nSaved++;
        }
        /*
@@ -474,18 +470,13 @@ Int_t AliEMCALTracker::PropagateBack(AliESDEvent* esd)
                else {
                        AliEMCALMatchCluster *cluster = (AliEMCALMatchCluster*)fClusters->At(clusterID);
                        if (!cluster) continue;
-                       if (esdTrack->GetLabel() == cluster->Label()) {
-                               nGood++;
-                               esdTrack->SetEMCALcluster(cluster->Index());
-                       }
-                       else {
-                               esdTrack->SetEMCALcluster(-cluster->Index());
-                       }
+               
+                       esdTrack->SetEMCALcluster(cluster->Index());
                        nSaved++;
                }
        }
        */
-       AliInfo(Form("Saved %d matches [%d good + %d fake]", nSaved, nGood, nFake));
+       AliDebug(1,Form("Saved %d matches", nSaved));
 
        return 0;
 }
@@ -942,35 +933,6 @@ Int_t AliEMCALTracker::CreateMatches()
                        }
                }
        }
-               
-       /*
-       // loop on clusters and tracks
-       Int_t icBest;
-       Double_t dist, distBest;
-       for (it = 0; it < nTracks; it++) {
-               AliEMCALTrack *track = (AliEMCALTrack*)fTracks->At(it);
-               if (!track) continue;
-               icBest = -1;
-               distBest = fMaxDist;
-               for (ic = 0; ic < nClusters; ic++) {
-                       AliEMCALMatchCluster *cluster = (AliEMCALMatchCluster*)fClusters->At(ic);
-                       if (!cluster) continue;
-                       dist = CheckPair(track, cluster);
-                       if (dist < distBest) {
-                               distBest = dist;
-                               icBest = ic;
-                       }
-               }
-               if (icBest >= 0) {
-                       track->SetMatchedClusterIndex(icBest);
-                       track->SetMatchedClusterDist(distBest);
-                       count++;
-               }
-               else {
-                       track->SetMatchedClusterIndex(-1);
-               }
-       }
-       */
        
        return count;
 }
@@ -1019,29 +981,6 @@ Int_t AliEMCALTracker::SolveCompetitions()
                }
        }
        
-       /*
-       Int_t it1, it2, nTracks = (Int_t)fTracks->GetEntries();
-       AliEMCALTrack *track1 = 0, *track2 = 0;
-       for (it1 = 0; it1 < nTracks; it1++) {
-               track1 = (AliEMCALTrack*)fTracks->At(it1);
-               if (!track1) continue;
-               if (track1->GetMatchedClusterIndex() < 0) continue;
-               for (it2 = it1+1; it2 < nTracks; it2++) {
-                       track2 = (AliEMCALTrack*)fTracks->At(it2);
-                       if (!track2) continue;
-                       if (track2->GetMatchedClusterIndex() < 0) continue;
-                       if (track1->GetMatchedClusterIndex() != track2->GetMatchedClusterIndex()) continue;
-                       count++;
-                       if (track1->GetMatchedClusterDist() < track2->GetMatchedClusterDist()) {
-                               track2->SetMatchedClusterIndex(-1);
-                       }
-                       else if (track2->GetMatchedClusterDist() < track1->GetMatchedClusterDist()) {
-                               track1->SetMatchedClusterIndex(-1);
-                       }
-               }
-       }
-       */
-       
        delete [] usedC;
        delete [] usedT;
 
@@ -1060,12 +999,29 @@ void AliEMCALTracker::UnloadClusters()
        
        Clear();
 }
+//
+//------------------------------------------------------------------------------
+//
+TVector3 AliEMCALTracker::FindExtrapolationPoint(Double_t x,Double_t y,Double_t z, AliESDtrack *track)
+{
+  //Method to determine extrapolation point of track at location x,y,z
+  AliEMCALTrack *tr = new AliEMCALTrack(*track);
+  TVector3 error(-100.,-100.,-100.);
+  if (!tr->PropagateToGlobal(x,y,z, 0.0, 0.0)) {
+    return error;
+  }
+  Double_t pos[3];
+  tr->GetXYZ(pos);
+  TVector3 ExTrPos(pos[0],pos[1],pos[2]);
+  return ExTrPos;
+}
+
 //
 //------------------------------------------------------------------------------
 //
 AliEMCALTracker::AliEMCALMatchCluster::AliEMCALMatchCluster(Int_t index, AliEMCALRecPoint *recPoint)
   : fIndex(index),
-    fLabel(recPoint->GetPrimaryIndex()),
+    fLabel(recPoint->GetPrimaryIndex()), //wrong!  fixed below
     fX(0.),
     fY(0.),
     fZ(0.)
@@ -1080,6 +1036,17 @@ AliEMCALTracker::AliEMCALMatchCluster::AliEMCALMatchCluster(Int_t index, AliEMCA
        fX = clpos.X();
        fY = clpos.Y();
        fZ = clpos.Z();
+
+       //AliEMCALRecPoint stores the track labels in the parents
+       //list, sorted according to the fractional contribution to the
+       //RecPoint.  The zeroth parent gave the highest contribution
+       Int_t multparent = 0;
+        Int_t *parents = recPoint->GetParents(multparent);
+        if(multparent > 0)
+          fLabel = parents[0];
+        else
+          fLabel = -1;
+
 }
 //
 //------------------------------------------------------------------------------