]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Track matching returned to AliPHOSTracker
authorprsnko <prsnko@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 26 Jan 2010 17:51:43 +0000 (17:51 +0000)
committerprsnko <prsnko@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 26 Jan 2010 17:51:43 +0000 (17:51 +0000)
PHOS/AliPHOSReconstructor.cxx
PHOS/AliPHOSTracker.cxx

index 67e0ffdb450a976874ec8d06c8b90059d8e830b6..79618aebb611eb340db181fb64f1fe55ba09faf9 100644 (file)
@@ -305,6 +305,7 @@ void AliPHOSReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
     ec->SetM20(emcRP->GetM2z()) ;               //second moment M2z
     ec->SetNExMax(emcRP->GetNExMax());          //number of local maxima
     ec->SetEmcCpvDistance(ts->GetCpvDistance("r")); //Only radius, what about separate x,z????
+    ec->SetTrackDistance(ts->GetCpvDistance("x"),ts->GetCpvDistance("z")); 
     ec->SetClusterChi2(-1);                     //not yet implemented
     ec->SetTOF(emcRP->GetTime());               //Time of flight - already calibrated in EMCRecPoint
 
@@ -325,7 +326,21 @@ void AliPHOSReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
     arrayTrackMatched[0]= ts->GetTrackIndex();
     ec->AddTracksMatched(arrayTrackMatched);
     
-    esd->AddCaloCluster(ec);
+    Int_t index = esd->AddCaloCluster(ec);
+
+    //Set pointer to this cluster in ESD track
+    Int_t nt=esd->GetNumberOfTracks();
+    for (Int_t itr=0; itr<nt; itr++) {
+      AliESDtrack *esdTrack=esd->GetTrack(itr);
+      if(!esdTrack->IsPHOS())
+        continue ;
+      if(esdTrack->GetPHOScluster()==-recpart){ //we store negative cluster number
+        esdTrack->SetPHOScluster(index) ;
+//no garatie that only one track matched this cluster
+//      break ;
+      }
+    }
     delete ec;   
     delete [] fracList;
     delete [] absIdList;
index f3d956c04de1f18ed195edc6cf3fb2c552138566..543859cccdebeabf68b36aee300450d03f70c997 100644 (file)
@@ -40,6 +40,7 @@
 #include <AliLog.h>
 #include "AliPHOSTracker.h"
 #include "AliPHOSEmcRecPoint.h"
+#include "AliPHOSGeometry.h"
 #include "AliESDEvent.h"
 #include "AliESDtrack.h"
 #include "AliPHOSTrackSegmentMakerv1.h"
@@ -55,17 +56,6 @@ ClassImp(AliPHOSTracker)
 
 Bool_t AliPHOSTracker::fgDebug = kFALSE ;  
 
-
-// ***** Some geometrical constants (used in PropagateBack) 
-
-const Double_t kR=460.+ 9;  // Radial coord. of the centre of EMC module (cm)
-
-const Double_t kAlpha=20.*TMath::Pi()/180.;     // Segmentation angle (rad)
-const Double_t kYmax=kR*TMath::Tan(0.5*kAlpha); // Maximal possible y-coord.(cm)
-const Double_t kZmax=65.; // Approximately: the maximal possible z-coord.(cm)
-
-
-
 //____________________________________________________________________________
 AliPHOSTracker::AliPHOSTracker(): 
   AliTracker()
@@ -91,26 +81,166 @@ AliPHOSTracker::~AliPHOSTracker()
 }
 
 //____________________________________________________________________________
-Int_t AliPHOSTracker::LoadClusters(TTree *) {
+Int_t AliPHOSTracker::LoadClusters(TTree *cTree) {
   //--------------------------------------------------------------------
   // This function loads the PHOS clusters
   //--------------------------------------------------------------------
-  return 0 ; //At this stage we can not strore result 
-             // the closest track and distance to it
-             //We perform same task later in AliPHOSTrackSegmentMakerv1
+
+  TObjArray *arr=NULL;
+  TBranch *branch=cTree->GetBranch("PHOSEmcRP");
+  if (branch==0) {
+    AliError("No branch with the EMC clusters found !");
+    return 1;
+  }
+  branch->SetAddress(&arr);
+
+  for(Int_t m=0;m<5; m++) fModules[m]->Clear() ;
+
+  Int_t nclusters=0;
+  Int_t nentr=(Int_t)branch->GetEntries();
+  for (Int_t i=0; i<nentr; i++) {
+    if (!branch->GetEvent(i)) continue;
+    Int_t ncl=arr->GetEntriesFast();
+    while (ncl--) {
+      AliPHOSEmcRecPoint *cl=(AliPHOSEmcRecPoint*)arr->UncheckedAt(ncl);
+
+      Int_t m=cl->GetPHOSMod();
+      if ((m<1)||(m>5)) {
+         AliError(Form("Wrong module index: %d !",m));
+         continue ;
+      }
+
+      // Here is how the alignment is treated
+      // Misalignment is already in cluster coordinates
+//      if (!cl->Misalign()) AliWarning("Can't misalign this cluster !");
+
+      cl->SetBit(14,kFALSE); // The clusters are not yet attached to any track
+
+      TClonesArray &module=*fModules[m-1];
+      Int_t idx=module.GetEntriesFast();
+      new (module[idx]) AliPHOSEmcRecPoint(*cl); 
+
+      nclusters++;
+
+    }
+  }  
+  arr->Delete();
+  Info("LoadClusters","Number of loaded clusters: %d",nclusters);
+
+  return 0;
+
 }
 
 //____________________________________________________________________________
-Int_t AliPHOSTracker::PropagateBack(AliESDEvent *) {
+Int_t AliPHOSTracker::PropagateBack(AliESDEvent *esd) {
   //--------------------------------------------------------------------
   // Called by AliReconstruction 
   // Performs the track matching with the PHOS modules
   // Makes the PID
   //--------------------------------------------------------------------
 
-  return 0 ; //At this stage we can not strore result 
-             // the closest track and distance to it
-             //We perform same task later in AliPHOSTrackSegmentMakerv1
+  Int_t nt=esd->GetNumberOfTracks();
+
+  // *** Select and sort the ESD track in accordance with their quality
+  Double_t *quality=new Double_t[nt];
+  Int_t *index=new Int_t[nt];  
+  for (Int_t i=0; i<nt; i++) {
+     AliESDtrack *esdTrack=esd->GetTrack(i);
+     quality[i] = esdTrack->GetSigmaY2() + esdTrack->GetSigmaZ2();
+  }
+  TMath::Sort(nt,quality,index,kFALSE);
+
+  AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance() ;
+
+  // *** Start the matching
+  TVector3 vecEmc ;   // Local position of EMC recpoint
+  Double_t bz = GetBz() ; //For approximate matching
+  Double_t b[3];  //For final matching
+  Double_t gposTrack[3] ;
+  Int_t matched=0;
+  for (Int_t i=0; i<nt; i++) {
+     AliESDtrack *esdTrack=esd->GetTrack(index[i]);
+
+     // Skip the tracks having "wrong" status (has to be checked/tuned)
+     ULong_t status = esdTrack->GetStatus();
+     if ((status & AliESDtrack::kTPCout)   == 0) continue;
+//     if ((status & AliESDtrack::kTRDout)   == 0) continue;
+//     if ((status & AliESDtrack::kTRDrefit) == 1) continue;
+
+     //Continue extrapolation from TPC outer surface
+     const AliExternalTrackParam *outerParam=esdTrack->GetOuterParam();
+     if (!outerParam) continue;
+     AliExternalTrackParam t(*outerParam);
+
+     t.GetBxByBz(b) ;
+
+     //Loop over PHOS modules
+     Double_t dx=0,dz=0;
+     Double_t minDistance=999. ;
+     Int_t emcIndex=0  ;
+     for(Int_t mod=1; mod<=5; mod++){
+       if(fModules[mod-1]->GetEntriesFast()==0) //no PHOS clusters in this module or module does not exist
+         continue ;
+       
+       //Approximate direction to the current PHOS module
+       Double_t phiMod=(330.-20.*mod)/180.*TMath::Pi() ;
+       if(!t.Rotate(phiMod))
+         continue ;
+       TVector3 globaPos ;
+       geom->Local2Global(mod, 0.,0., globaPos) ;
+       const Double_t rPHOS = globaPos.Pt() ; //Distance to center of  PHOS module
+       const Double_t kYmax = 72.+10. ; //Size of the module (with some reserve) in phi direction
+       const Double_t kZmax = 64.+20. ; //Size of the module (with some reserve) in z direction
+       Double_t y;                       // Some tracks do not reach the PHOS
+       if (!t.GetYAt(rPHOS,bz,y)) continue; //    because of the bending
+
+       Double_t z;
+       if(!t.GetZAt(rPHOS,bz,z))
+         continue ;
+       if (TMath::Abs(z) > kZmax)
+         continue; // Some tracks miss the PHOS in Z
+       if(TMath::Abs(y) < kYmax){
+         t.PropagateToBxByBz(rPHOS,b);        // Propagate to the matching module
+      //t.CorrectForMaterial(...); // Correct for the TOF material, if needed
+         t.GetXYZ(gposTrack) ;
+         TVector3 globalPositionTr(gposTrack) ;
+         TVector3 localPositionTr ;
+         geom->Global2Local(localPositionTr,globalPositionTr,mod) ;
+         for(Int_t icl=0;icl<fModules[mod-1]->GetEntriesFast();icl++){
+           AliPHOSEmcRecPoint * clu =static_cast<AliPHOSEmcRecPoint*>(fModules[mod-1]->At(icl)) ;
+           clu->GetLocalPosition(vecEmc) ;
+           Double_t ddx = vecEmc.X()-localPositionTr.X();
+           Double_t ddz = vecEmc.Z()-localPositionTr.Z();
+           Double_t d2 = ddx*ddx + ddz*ddz;
+           if(d2 < minDistance) {
+             dx = ddx ;
+             dz = ddz ;
+             emcIndex=clu->GetIndexInList() ;
+             minDistance=d2 ;
+           }
+         }
+         break ;
+       }
+     } //Loop over modules
+     if(minDistance<999.){
+       //found some match
+       esdTrack->SetStatus(AliESDtrack::kPHOSmatch) ;
+       esdTrack->SetPHOScluster(-emcIndex) ; //Should be ESDCaloCluster index which is not known yet. Will be transformed later in FillESD().
+       esdTrack->SetPHOSdxdz(dx,dz) ;
+       matched++;
+     }
+
+  }
+    
+  Info("PropagateBack","Number of matched tracks: %d",matched);
+
+  delete[] quality;
+  delete[] index;
+
+  return 0;
+
 }
 
 //____________________________________________________________________________