update to use DCA from global tracks on TPC-only
authormaszyman <maszyman@cern.ch>
Mon, 3 Mar 2014 14:09:41 +0000 (15:09 +0100)
committermaszyman <maszyman@cern.ch>
Mon, 3 Mar 2014 14:10:25 +0000 (15:10 +0100)
PWGCF/FEMTOSCOPY/AliFemto/AliFemtoEventReaderAOD.cxx

index 243c8ef..f4e7ed0 100644 (file)
@@ -565,10 +565,13 @@ void AliFemtoEventReaderAOD::CopyAODtoFemtoEvent(AliFemtoEvent *tEvent)
 
 
     AliAODTrack *aodtrackpid;
-    if((fFilterBit ==  (1 << (7))) || fFilterMask==128) //for TPC Only tracks we have to copy PID information from corresponding global tracks
+    if((fFilterBit ==  (1 << (7))) || fFilterMask == 128) {//for TPC Only tracks we have to copy PID information from corresponding global tracks
       aodtrackpid = fEvent->GetTrack(labels[-1-fEvent->GetTrack(i)->GetID()]);
-    else
+    }
+    else {
       aodtrackpid = fEvent->GetTrack(i);
+    }
+
     CopyPIDtoFemtoTrack(aodtrackpid, trackCopy);
 
     if (mcP) {
@@ -854,8 +857,9 @@ void AliFemtoEventReaderAOD::CopyAODtoFemtoTrack(AliAODTrack *tAodTrack,
 
   if (!fDCAglobalTrack) {
 
-      tFemtoTrack->SetImpactD(tAodTrack->DCA());
-      tFemtoTrack->SetImpactZ(tAodTrack->ZAtDCA());
+    tFemtoTrack->SetImpactD(tAodTrack->DCA());
+    tFemtoTrack->SetImpactZ(tAodTrack->ZAtDCA());
+
 
     // double impact[2];
     // double covimpact[3];
@@ -1239,27 +1243,60 @@ void AliFemtoEventReaderAOD::CopyPIDtoFemtoTrack(AliAODTrack *tAodTrack,
 {
 
   if (fDCAglobalTrack) {
-    // // copying DCA information (taking it from global tracks gives better resolution than from TPC-only)
 
-    double impact[2];
-    double covimpact[3];
+    // code from Michael and Prabhat from AliAnalysisTaskDptDptCorrelations
+    const AliAODVertex* vertex = (AliAODVertex*) fEvent->GetPrimaryVertex();
+    float vertexX  = -999.;
+    float vertexY  = -999.;
+    float vertexZ  = -999.;
+
+    if(vertex) {
+      Double32_t fCov[6];
+      vertex->GetCovarianceMatrix(fCov);
+      if(vertex->GetNContributors() > 0) {
+        if(fCov[5] != 0) {
+          vertexX = vertex->GetX();
+          vertexY = vertex->GetY();
+          vertexZ = vertex->GetZ();
+
+        }
+      }
+    }
+
+    Double_t pos[3];
+    tAodTrack->GetXYZ(pos);
 
-    AliAODTrack* trk_clone = (AliAODTrack*)tAodTrack->Clone("trk_clone");
-    // if(!trk_clone->PropagateToDCA(fAODVertex,aod->GetMagneticField(),300.,dca,cov)) continue;
-    // if (!tAodTrack->PropagateToDCA(fEvent->GetPrimaryVertex(),fEvent->GetMagneticField(),10000,impact,covimpact)) {
-    if (!trk_clone->PropagateToDCA(fEvent->GetPrimaryVertex(),fEvent->GetMagneticField(),10000,impact,covimpact)) {
+    Double_t DCAX = pos[0] - vertexX;
+    Double_t DCAY = pos[1] - vertexY;
+    Double_t DCAZ = pos[2] - vertexZ;
 
-    // if (!tAodTrack->PropagateToDCA(fEvent->GetPrimaryVertex(),fEvent->GetMagneticField(),10000,impact,covimpact)) {
-      //cout << "sth went wrong with dca propagation" << endl;
-      tFemtoTrack->SetImpactD(-1000.0);
-      tFemtoTrack->SetImpactZ(-1000.0);
+    Double_t DCAXY = TMath::Sqrt((DCAX*DCAX) + (DCAY*DCAY));
 
-    }
-    else {
-      tFemtoTrack->SetImpactD(impact[0]);
-      tFemtoTrack->SetImpactZ(impact[1]);
-    }
-    delete trk_clone;
+    tFemtoTrack->SetImpactD(DCAXY);
+    tFemtoTrack->SetImpactZ(DCAZ);
+
+
+    // // // copying DCA information (taking it from global tracks gives better resolution than from TPC-only)
+
+    // double impact[2];
+    // double covimpact[3];
+
+    // AliAODTrack* trk_clone = (AliAODTrack*)tAodTrack->Clone("trk_clone");
+    // // if(!trk_clone->PropagateToDCA(fAODVertex,aod->GetMagneticField(),300.,dca,cov)) continue;
+    // // if (!tAodTrack->PropagateToDCA(fEvent->GetPrimaryVertex(),fEvent->GetMagneticField(),10000,impact,covimpact)) {
+    // if (!trk_clone->PropagateToDCA(fEvent->GetPrimaryVertex(),fEvent->GetMagneticField(),10000,impact,covimpact)) {
+
+    // // if (!tAodTrack->PropagateToDCA(fEvent->GetPrimaryVertex(),fEvent->GetMagneticField(),10000,impact,covimpact)) {
+    //   //cout << "sth went wrong with dca propagation" << endl;
+    //   tFemtoTrack->SetImpactD(-1000.0);
+    //   tFemtoTrack->SetImpactZ(-1000.0);
+
+    // }
+    // else {
+    //   tFemtoTrack->SetImpactD(impact[0]);
+    //   tFemtoTrack->SetImpactZ(impact[1]);
+    // }
+    // delete trk_clone;
   }
 
   double aodpid[10];