]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALTracker.cxx
Updates
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTracker.cxx
index 015ce473332d5940b91bb0a2cf3d4028b67839d0..54d371b5eea94bbb8c6973f7195e4152ace91e70 100644 (file)
@@ -66,13 +66,14 @@ ClassImp(AliEMCALTracker)
 //
 //------------------------------------------------------------------------------
 //
-AliEMCALTracker::AliEMCALTracker() 
-: AliTracker(),
+AliEMCALTracker::AliEMCALTracker() 
+  AliTracker(),
   fCutPt(0),
   fCutNITS(0),
   fCutNTPC(50),
   fStep(20),
   fTrackCorrMode(kTrackCorrMMB),
+  fEMCalSurfaceDistance(440),
   fClusterWindow(50),
   fCutEta(0.025),
   fCutPhi(0.05),
@@ -92,20 +93,21 @@ AliEMCALTracker::AliEMCALTracker()
 //
 //------------------------------------------------------------------------------
 //
-AliEMCALTracker::AliEMCALTracker(const AliEMCALTracker& copy) 
-  : AliTracker(),
-    fCutPt(copy.fCutPt),
-    fCutNITS(copy.fCutNITS),
-    fCutNTPC(copy.fCutNTPC),
-    fStep(copy.fStep),
-    fTrackCorrMode(copy.fTrackCorrMode),
-    fClusterWindow(copy.fClusterWindow),
-    fCutEta(copy.fCutEta),
-    fCutPhi(copy.fCutPhi),
-    fITSTrackSA(copy.fITSTrackSA), 
-    fTracks((TObjArray*)copy.fTracks->Clone()),
-    fClusters((TObjArray*)copy.fClusters->Clone()),
-    fGeom(copy.fGeom)
+AliEMCALTracker::AliEMCALTracker(const AliEMCALTracker& copy) : 
+  AliTracker(),
+  fCutPt(copy.fCutPt),
+  fCutNITS(copy.fCutNITS),
+  fCutNTPC(copy.fCutNTPC),
+  fStep(copy.fStep),
+  fTrackCorrMode(copy.fTrackCorrMode),
+  fEMCalSurfaceDistance(copy.fEMCalSurfaceDistance),
+  fClusterWindow(copy.fClusterWindow),
+  fCutEta(copy.fCutEta),
+  fCutPhi(copy.fCutPhi),
+  fITSTrackSA(copy.fITSTrackSA), 
+  fTracks((TObjArray*)copy.fTracks->Clone()),
+  fClusters((TObjArray*)copy.fClusters->Clone()),
+  fGeom(copy.fGeom)
 {
   //
   // Copy constructor
@@ -134,11 +136,9 @@ void AliEMCALTracker::InitParameters()
   // Check if the instance of AliEMCALRecParam exists, 
   const AliEMCALRecParam* recParam = AliEMCALReconstructor::GetRecParam();
 
-  if(!recParam){
+  if (!recParam) {
     AliFatal("Reconstruction parameters for EMCAL not set!");
-  }
-  else{
+  } else {
     fCutEta  =  recParam->GetMthCutEta();
     fCutPhi  =  recParam->GetMthCutPhi();
     fStep    =  recParam->GetExtrapolateStep();
@@ -146,84 +146,82 @@ void AliEMCALTracker::InitParameters()
     fCutNITS =  recParam->GetTrkCutNITS();
     fCutNTPC =  recParam->GetTrkCutNTPC();
   }
-       
 }
-
 //
 //------------------------------------------------------------------------------
 //
 void AliEMCALTracker::Clear(Option_t* option)
 {
-       //
-       // Clearing method
-        // Deletes all objects in arrays and the arrays themselves
-       //
+  //
+  // Clearing method
+  // Deletes all objects in arrays and the arrays themselves
+  //
 
-       TString opt(option);
-       Bool_t clearTracks = opt.Contains("TRACKS");
-       Bool_t clearClusters = opt.Contains("CLUSTERS");
-       if (opt.Contains("ALL")) {
-               clearTracks = kTRUE;
-               clearClusters = kTRUE;
-       }
+  TString opt(option);
+  Bool_t clearTracks = opt.Contains("TRACKS");
+  Bool_t clearClusters = opt.Contains("CLUSTERS");
+  if (opt.Contains("ALL")) {
+    clearTracks = kTRUE;
+    clearClusters = kTRUE;
+  }
        
-       //fTracks is a collection of esdTrack
-       //When clearing this array, the linked objects should not be deleted
-       if (fTracks != 0x0 && clearTracks) {
-          fTracks->Clear();
-          delete fTracks;
-           fTracks = 0;
-       }
-       if (fClusters != 0x0 && clearClusters) {
-          fClusters->Delete();
-          delete fClusters;
-          fClusters = 0;
-       }
+  //fTracks is a collection of esdTrack
+  //When clearing this array, the linked objects should not be deleted
+  if (fTracks != 0x0 && clearTracks) {
+    fTracks->Clear();
+    delete fTracks;
+    fTracks = 0;
+  }
+  if (fClusters != 0x0 && clearClusters) {
+    fClusters->Delete();
+    delete fClusters;
+    fClusters = 0;
+  }
 }
 //
 //------------------------------------------------------------------------------
 //
 Int_t AliEMCALTracker::LoadClusters(TTree *cTree) 
 {
-       //
-       // Load EMCAL clusters in the form of AliEMCALRecPoint,
-       // from simulation temporary files.
-       // (When included in reconstruction chain, this method is used automatically)
-       //
+  //
+  // Load EMCAL clusters in the form of AliEMCALRecPoint,
+  // from simulation temporary files.
+  // (When included in reconstruction chain, this method is used automatically)
+  //
        
-       Clear("CLUSTERS");
-
-       cTree->SetBranchStatus("*",0); //disable all branches
-       cTree->SetBranchStatus("EMCALECARP",1); //Enable only the branch we need
+  Clear("CLUSTERS");
+  
+  cTree->SetBranchStatus("*",0); //disable all branches
+  cTree->SetBranchStatus("EMCALECARP",1); //Enable only the branch we need
 
-       TBranch *branch = cTree->GetBranch("EMCALECARP");
-       if (!branch) {
-               AliError("Can't get the branch with the EMCAL clusters");
-               return 1;
-       }
+  TBranch *branch = cTree->GetBranch("EMCALECARP");
+  if (!branch) {
+    AliError("Can't get the branch with the EMCAL clusters");
+    return 1;
+  }
        
-       TClonesArray *clusters = new TClonesArray("AliEMCALRecPoint", 1000);
-       branch->SetAddress(&clusters);
+  TClonesArray *clusters = new TClonesArray("AliEMCALRecPoint", 1000);
+  branch->SetAddress(&clusters);
        
-       //cTree->GetEvent(0);
-       branch->GetEntry(0);
-       Int_t nClusters = (Int_t)clusters->GetEntries();
-       if(fClusters) fClusters->Delete();
-       else fClusters = new TObjArray(0);
-       for (Int_t i = 0; i < nClusters; i++) {
-               AliEMCALRecPoint *cluster = (AliEMCALRecPoint*)clusters->At(i);
-               if (!cluster) continue;
-               AliEMCALMatchCluster *matchCluster = new AliEMCALMatchCluster(i, cluster);
-               fClusters->AddLast(matchCluster);
-       }
-
-       branch->SetAddress(0);
-        clusters->Delete();
-        delete clusters;
+  //cTree->GetEvent(0);
+  branch->GetEntry(0);
+  Int_t nClusters = (Int_t)clusters->GetEntries();
+  if (fClusters) fClusters->Delete();
+  else fClusters = new TObjArray(0);
+  for (Int_t i = 0; i < nClusters; i++) {
+    AliEMCALRecPoint *cluster = (AliEMCALRecPoint*)clusters->At(i);
+    if (!cluster) continue;
+    AliEMCALMatchCluster *matchCluster = new AliEMCALMatchCluster(i, cluster);
+    fClusters->AddLast(matchCluster);
+  }
 
-       AliInfo(Form("Collected %d RecPoints from Tree", fClusters->GetEntries()));
+  branch->SetAddress(0);
+  clusters->Delete();
+  delete clusters;
 
-       return 0;
+  AliDebug(1,Form("Collected %d RecPoints from Tree", fClusters->GetEntries()));
+  
+  return 0;
 }
 //
 //------------------------------------------------------------------------------
@@ -240,15 +238,14 @@ Int_t AliEMCALTracker::LoadClusters(AliESDEvent *esd)
   fClusters = new TObjArray(0);
   
   Int_t nClusters = esd->GetNumberOfCaloClusters();                    
-  for (Int_t i=0; i<nClusters; i++) 
-    {
-      AliESDCaloCluster *cluster = esd->GetCaloCluster(i);
-      if (!cluster || !cluster->IsEMCAL()) continue ; 
-      AliEMCALMatchCluster *matchCluster = new AliEMCALMatchCluster(i, cluster);
-      fClusters->AddLast(matchCluster);
-    }
+  for (Int_t i=0; i<nClusters; i++) {
+    AliESDCaloCluster *cluster = esd->GetCaloCluster(i);
+    if (!cluster || !cluster->IsEMCAL()) continue ; 
+    AliEMCALMatchCluster *matchCluster = new AliEMCALMatchCluster(i, cluster);
+    fClusters->AddLast(matchCluster);
+  }
   
-  AliInfo(Form("Collected %d clusters from ESD", fClusters->GetEntries()));
+  AliDebug(1,Form("Collected %d clusters from ESD", fClusters->GetEntries()));
   return 0;
 }
 //
@@ -265,9 +262,9 @@ Int_t AliEMCALTracker::LoadTracks(AliESDEvent *esd)
   Bool_t desc1 = (mask1 >> 3) & 0x1;
   Bool_t desc2 = (mask2 >> 3) & 0x1;
   if (desc1==0 || desc2==0) {
-    AliError(Form("TPC not in DAQ/RECO: %u (%u)/%u (%u)",
-                  mask1, esd->GetESDRun()->GetDetectorsInReco(),
-                  mask2, esd->GetESDRun()->GetDetectorsInDAQ()));
+//     AliError(Form("TPC not in DAQ/RECO: %u (%u)/%u (%u)",
+//                   mask1, esd->GetESDRun()->GetDetectorsInReco(),
+//                   mask2, esd->GetESDRun()->GetDetectorsInDAQ()));
     fITSTrackSA = kTRUE;
   }
   
@@ -276,27 +273,25 @@ Int_t AliEMCALTracker::LoadTracks(AliESDEvent *esd)
        
   Int_t nTracks = esd->GetNumberOfTracks();
   //Bool_t isKink=kFALSE;
-  for (Int_t i = 0; i < nTracks; i++) 
-    {
-      AliESDtrack *esdTrack = esd->GetTrack(i);
-      // set by default the value corresponding to "no match"
-      esdTrack->SetEMCALcluster(kUnmatched);
-      esdTrack->ResetStatus(AliESDtrack::kEMCALmatch);
-
-      //Select good quaulity tracks
-      if(esdTrack->Pt()<fCutPt) continue;
-      if(!fITSTrackSA)
-       if(esdTrack->GetNcls(1)<fCutNTPC)continue;
-
-      //Loose geometric cut
-      Double_t phi = esdTrack->Phi()*TMath::RadToDeg();
-      if(TMath::Abs(esdTrack->Eta())>0.8 || phi <= 20 || phi >= 240 ) continue;
-
-      fTracks->AddLast(esdTrack);
-    }
-
-      AliInfo(Form("Collected %d tracks", fTracks->GetEntries()));
-      return 0;
+  for (Int_t i = 0; i < nTracks; i++) {
+    AliESDtrack *esdTrack = esd->GetTrack(i);
+    // set by default the value corresponding to "no match"
+    esdTrack->SetEMCALcluster(kUnmatched);
+    esdTrack->ResetStatus(AliESDtrack::kEMCALmatch);
+    
+    //Select good quaulity tracks
+    if (esdTrack->Pt()<fCutPt) continue;
+    if (!fITSTrackSA)
+      if (esdTrack->GetNcls(1)<fCutNTPC) continue;
+    
+    //Loose geometric cut
+    Double_t phi = esdTrack->Phi()*TMath::RadToDeg();
+    if (TMath::Abs(esdTrack->Eta())>0.9 || phi <= 10 || phi >= 250) continue;
+    fTracks->AddLast(esdTrack);
+  }
+  
+  AliDebug(1,Form("Collected %d tracks", fTracks->GetEntries()));
+  return 0;
 }
 //
 //------------------------------------------------------------------------------
@@ -312,66 +307,65 @@ void AliEMCALTracker::SetTrackCorrectionMode(Option_t *option)
   TString opt(option);
   opt.ToUpper();
   
-  if (!opt.CompareTo("NONE")) 
-    {
-      fTrackCorrMode = kTrackCorrNone;
-    }
-  else if (!opt.CompareTo("MMB")) 
-    {
-      fTrackCorrMode = kTrackCorrMMB;
-    }
-  else 
-    {
-      cerr << "E-AliEMCALTracker::SetTrackCorrectionMode '" << option << "': Unrecognized option" << endl;
-    }
+  if (!opt.CompareTo("NONE")) {
+    fTrackCorrMode = kTrackCorrNone;
+  } else if (!opt.CompareTo("MMB")) {
+    fTrackCorrMode = kTrackCorrMMB;
+  } else  {
+    cerr << "E-AliEMCALTracker::SetTrackCorrectionMode '" << option << "': Unrecognized option" << endl;
+  }
 }
 //
 //------------------------------------------------------------------------------
 //
 Int_t AliEMCALTracker::PropagateBack(AliESDEvent* esd)
 {
-       //
-       // Main operation method.
-       // Gets external AliESD containing tracks to be matched.
-       // After executing match finding, stores in the same ESD object all infos
-       // and releases the object for further reconstruction steps.
-       //
-        //
-        // Note: should always return 0=OK, because otherwise all tracking
-        // is aborted for this event
+  //
+  // Main operation method.
+  // Gets external AliESD containing tracks to be matched.
+  // After executing match finding, stores in the same ESD object all infos
+  // and releases the object for further reconstruction steps.
+  //
+  //
+  // Note: should always return 0=OK, because otherwise all tracking
+  // is aborted for this event
   
-       if (!esd) {
-               AliError("NULL ESD passed");
-               return 1;
-       }
+  if (!esd)
+  {
+    AliError("NULL ESD passed");
+    return 1;
+  }
        
-       // step 1: collect clusters
-       Int_t okLoadClusters, nClusters;
-       if (!fClusters || (fClusters && fClusters->IsEmpty())) {
-               okLoadClusters = LoadClusters(esd);
-       }
-       nClusters = fClusters->GetEntries();
+  // step 1: collect clusters
+  Int_t okLoadClusters = 0;  
+  if (!fClusters || (fClusters && fClusters->IsEmpty()))
+    okLoadClusters = LoadClusters(esd);
+  
+  Int_t nClusters = fClusters->GetEntries();
                
-       // step 2: collect ESD tracks
-       Int_t nTracks, okLoadTracks;
-       okLoadTracks = LoadTracks(esd);
-       nTracks = fTracks->GetEntries();
-       
-       // step 3: for each track, find the closest cluster as matched within residual cuts
-       Int_t index=-1;
-       for (Int_t it = 0; it < nTracks; it++) 
-         {
-           AliESDtrack *track = (AliESDtrack*)fTracks->At(it);
-           index = FindMatchedCluster(track);
-           if (index>-1) 
-             {
-               AliEMCALMatchCluster *cluster = (AliEMCALMatchCluster*)fClusters->At(index);
-               track->SetEMCALcluster(cluster->Index());
-               track->SetStatus(AliESDtrack::kEMCALmatch);
-             }
-         }
+  // step 2: collect ESD tracks
+  Int_t nTracks, okLoadTracks;
+  okLoadTracks = LoadTracks(esd);
+  nTracks = fTracks->GetEntries();
+  
+  AliDebug(5,Form("Propagate back %d tracks ok %d, for %d clusters ok %d",
+                  nTracks,okLoadTracks,nClusters,okLoadClusters));
+  
+  // step 3: for each track, find the closest cluster as matched within residual cuts
+  Int_t index=-1;
+  for (Int_t it = 0; it < nTracks; it++)
+  {
+    AliESDtrack *track = (AliESDtrack*)fTracks->At(it);
+    index = FindMatchedCluster(track);
+    if (index>-1)
+    {
+      AliEMCALMatchCluster *cluster = (AliEMCALMatchCluster*)fClusters->At(index);
+      track->SetEMCALcluster(cluster->Index());
+      track->SetStatus(AliESDtrack::kEMCALmatch);
+    }
+  }
 
-       return 0;
+  return 0;
 }
 
 //
@@ -392,47 +386,68 @@ Int_t AliEMCALTracker::FindMatchedCluster(AliESDtrack *track)
   // Otherwise use the TPCInner point
   AliExternalTrackParam *trkParam = 0;
   
-  if(!fITSTrackSA){ 
+  if (!fITSTrackSA)
+  {
     const AliESDfriendTrack*  friendTrack = track->GetFriendTrack();
-    if(friendTrack && friendTrack->GetTPCOut())
+  
+    if (friendTrack && friendTrack->GetTPCOut())
       trkParam = const_cast<AliExternalTrackParam*>(friendTrack->GetTPCOut());
-    else if(track->GetInnerParam())
+    else if (track->GetInnerParam())
       trkParam = const_cast<AliExternalTrackParam*>(track->GetInnerParam());
   }
   else
     trkParam = new AliExternalTrackParam(*track);
   
-  if(!trkParam) return index;
+  if (!trkParam) return index;
   
   AliExternalTrackParam trkParamTmp(*trkParam);
-  Float_t eta, phi;
-  if(!AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&trkParamTmp, 430., track->GetMass(kTRUE), fStep, eta, phi))  return index;
-  track->SetTrackPhiEtaOnEMCal(phi,eta);
-  if(TMath::Abs(eta)>0.75 || (phi) < 70*TMath::DegToRad() || (phi) > 190*TMath::DegToRad()) return index;
+  Float_t eta, phi, pt;
+  if (!AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&trkParamTmp, fEMCalSurfaceDistance, track->GetMass(kTRUE), fStep, eta, phi, pt))
+  {
+    if (fITSTrackSA) delete trkParam;
+    return index;
+  }
+  
+  track->SetTrackPhiEtaPtOnEMCal(phi,eta,pt);
+  
+  if (TMath::Abs(eta)>0.75 || (phi) < 70*TMath::DegToRad() || (phi) > 190*TMath::DegToRad())
+  {
+    if (fITSTrackSA) delete trkParam;
+    return index;
+  }
 
   //Perform extrapolation
   Double_t trkPos[3];
   trkParamTmp.GetXYZ(trkPos);
   Int_t nclusters = fClusters->GetEntries();
-  for(Int_t ic=0; ic<nclusters; ic++)
-    {
-      AliEMCALMatchCluster *cluster = (AliEMCALMatchCluster*)fClusters->At(ic);
-      Float_t clsPos[3] = {cluster->X(),cluster->Y(),cluster->Z()};
-      Double_t dR = TMath::Sqrt(TMath::Power(trkPos[0]-clsPos[0],2)+TMath::Power(trkPos[1]-clsPos[1],2)+TMath::Power(trkPos[2]-clsPos[2],2));
-//       printf("\n dR=%f,wind=%f\n",dR,fClusterWindow); //MARCEL
-      if(dR > fClusterWindow) continue;
+  for (Int_t ic=0; ic<nclusters; ic++)
+  {
+    AliEMCALMatchCluster *cluster = (AliEMCALMatchCluster*)fClusters->At(ic);
+    
+    Float_t clsPos[3] = {static_cast<Float_t>(cluster->X()),
+                         static_cast<Float_t>(cluster->Y()),
+                         static_cast<Float_t>(cluster->Z())};
+    
+    Double_t dR = TMath::Sqrt(TMath::Power(trkPos[0]-clsPos[0],2)+TMath::Power(trkPos[1]-clsPos[1],2)+TMath::Power(trkPos[2]-clsPos[2],2));
+    //printf("\n dR=%f,wind=%f\n",dR,fClusterWindow); //MARCEL
+    
+    if (dR > fClusterWindow) continue;
       
-      AliExternalTrackParam trkParTmp(trkParamTmp);
+    AliExternalTrackParam trkParTmp(trkParamTmp);
 
-      Float_t tmpEta, tmpPhi;
-      if(!AliEMCALRecoUtils::ExtrapolateTrackToPosition(&trkParTmp, clsPos,track->GetMass(kTRUE), 5, tmpEta, tmpPhi)) continue;
-      if(TMath::Abs(tmpPhi)<TMath::Abs(maxPhi) && TMath::Abs(tmpEta)<TMath::Abs(maxEta))
-        {
-          maxPhi=tmpPhi;
-          maxEta=tmpEta;
-          index=ic;
-        }
-      }
+    Float_t tmpEta, tmpPhi;
+    if (!AliEMCALRecoUtils::ExtrapolateTrackToPosition(&trkParTmp, clsPos,track->GetMass(kTRUE), 5, tmpEta, tmpPhi)) continue;
+    
+    if (TMath::Abs(tmpPhi)<TMath::Abs(maxPhi) && TMath::Abs(tmpEta)<TMath::Abs(maxEta))
+    {
+      maxPhi=tmpPhi;
+      maxEta=tmpEta;
+      index=ic;
+    }
+  }
+
+  if (fITSTrackSA) delete trkParam;
+  
   return index;
 }
 
@@ -441,52 +456,52 @@ Int_t AliEMCALTracker::FindMatchedCluster(AliESDtrack *track)
 //
 void AliEMCALTracker::UnloadClusters() 
 {
-       //
-       // Free memory from all arrays
-        // This method is called after the local tracking step
-        // so we can safely delete everything 
-       //
+  //
+  // Free memory from all arrays
+  // This method is called after the local tracking step
+  // so we can safely delete everything 
+  //
        
-       Clear();
+  Clear();
 }
 
 //
 //------------------------------------------------------------------------------
 //
-AliEMCALTracker::AliEMCALMatchCluster::AliEMCALMatchCluster(Int_t index, AliEMCALRecPoint *recPoint)
-  fIndex(index),
-    fX(0.),
-    fY(0.),
-    fZ(0.)
+AliEMCALTracker::AliEMCALMatchCluster::AliEMCALMatchCluster(Int_t index, AliEMCALRecPoint *recPoint) : 
+  fIndex(index),
+  fX(0.),
+  fY(0.),
+  fZ(0.)
 {
-       //
-       // Translates an AliEMCALRecPoint object into the internal format.
-       // Index of passed cluster in its native array must be specified.
-       //
-       TVector3 clpos;
-       recPoint->GetGlobalPosition(clpos);
-       
-       fX = clpos.X();
-       fY = clpos.Y();
-       fZ = clpos.Z();
+  //
+  // Translates an AliEMCALRecPoint object into the internal format.
+  // Index of passed cluster in its native array must be specified.
+  //
+  TVector3 clpos;
+  recPoint->GetGlobalPosition(clpos);
+  
+  fX = clpos.X();
+  fY = clpos.Y();
+  fZ = clpos.Z();
 }
 //
 //------------------------------------------------------------------------------
 //
-AliEMCALTracker::AliEMCALMatchCluster::AliEMCALMatchCluster(Int_t index, AliESDCaloCluster *caloCluster)
-  fIndex(index),
-    fX(0.),
-    fY(0.),
-    fZ(0.)
+AliEMCALTracker::AliEMCALMatchCluster::AliEMCALMatchCluster(Int_t index, AliESDCaloCluster *caloCluster) : 
+  fIndex(index),
+  fX(0.),
+  fY(0.),
+  fZ(0.)
 {
-       //
-       // Translates an AliESDCaloCluster object into the internal format.
-       // Index of passed cluster in its native array must be specified.
-       //
-       Float_t clpos[3]= {0., 0., 0.};
-       caloCluster->GetPosition(clpos);
+  //
+  // Translates an AliESDCaloCluster object into the internal format.
+  // Index of passed cluster in its native array must be specified.
+  //
+  Float_t clpos[3]= {0., 0., 0.};
+  caloCluster->GetPosition(clpos);
        
-       fX = (Double_t)clpos[0];
-       fY = (Double_t)clpos[1];
-       fZ = (Double_t)clpos[2];
+  fX = (Double_t)clpos[0];
+  fY = (Double_t)clpos[1];
+  fZ = (Double_t)clpos[2];
 }