]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/qaRec/AliTRDtrackInfoGen.cxx
fix wrong container interogation
[u/mrichter/AliRoot.git] / TRD / qaRec / AliTRDtrackInfoGen.cxx
index 40ba294a40c9204bac01262d103651abae796a46..ccc97a6b43077b5a9c62944c85ab4c7017f863aa 100644 (file)
@@ -46,6 +46,7 @@
 #include "AliESDHeader.h"
 #include "AliESDtrack.h"
 #include "AliMCParticle.h"
+#include "AliPID.h"
 #include "AliStack.h"
 #include "AliTRDtrackV1.h"
 #include "AliTrackReference.h"
@@ -181,7 +182,7 @@ void AliTRDtrackInfoGen::Exec(Option_t *){
   Int_t nTRD = 0, nTPC = 0, nclsTrklt;
   Int_t nTracks = fESD->GetNumberOfTracks();
   if(fDebugLevel>=1){ 
-    printf("%3d Tracks: ESD[%d] MC[%d]\n", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), nTracks, HasMCdata() ? mStack->GetNtrack() : 0);
+    printf("Entry[%3d] Tracks: ESD[%d] MC[%d]\n", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), nTracks, HasMCdata() ? mStack->GetNtrack() : 0);
   }
   AliESDtrack *esdTrack = 0x0;
   AliESDfriendTrack *esdFriendTrack = 0x0;
@@ -201,14 +202,6 @@ void AliTRDtrackInfoGen::Exec(Option_t *){
         op->Global2LocalPosition(xyz, op->GetAlpha());
         if(fDebugLevel>=2) printf("op @ X[%7.3f]\n", xyz[0]);
     }
-/*             if(xyz[0] < 270.){ 
-        printf("TPC track missing\n");
-    } else { */
-//                     op->GetXYZAt(ref->LocalX(), AliTracker::GetBz(), xyz);
-//                     op->Global2LocalPosition(xyz, op->GetAlpha());
-//                     dy = ref->LocalY()- xyz[1];
-//                     dz = ref->Z() - xyz[2];
-//     }
 
     // read MC info
     Int_t fPdg = -1;
@@ -217,7 +210,11 @@ void AliTRDtrackInfoGen::Exec(Option_t *){
       label = esdTrack->GetLabel();
       if(label < fMC->GetNumberOfTracks()) trackMap[TMath::Abs(label)] = kTRUE; // register the track
       //if (TMath::Abs(label) > mStack->GetNtrack()) continue; 
-      AliMCParticle *mcParticle = fMC->GetTrack(TMath::Abs(label));
+      AliMCParticle *mcParticle = 0x0; 
+      if(!(mcParticle = fMC->GetTrack(TMath::Abs(label)))){
+        printf("E - AliTRDtrackInfoGen::Exec() : MC particle missing for ESD label %d\n", label);
+        continue;
+      }
       fPdg = mcParticle->Particle()->GetPdgCode();
       Int_t nRefs = mcParticle->GetNumberOfTrackReferences();
       Int_t iref = 0; AliTrackReference *ref = 0x0; 
@@ -227,17 +224,6 @@ void AliTRDtrackInfoGen::Exec(Option_t *){
         //printf("\ttrackRef[%2d] @ %7.3f\n", iref, ref->LocalX());
         iref++;
       }
-      if(iref == nRefs){
-//                     if(!esdTrack->GetNcls(2)) continue;
-/*                     printf("No TRD Track References in the Track [%d] I\n", itrk);
-        printf("Label = %d ITS[%d] TPC[%d] TRD[%d]\n", label, esdTrack->GetITSLabel(), esdTrack->GetTPCLabel(), esdTrack->GetTRDLabel());
-        Int_t kref = 0;
-        while(kref<nRefs){
-          ref = mcParticle->GetTrackReference(kref);
-          printf("\ttrackRef[%2d] @ %7.3f\n", kref, ref->LocalX());
-          kref++;
-        }*/
-      }
 
       new(fTrackInfo) AliTRDtrackInfo();
       fTrackInfo->SetPDG(fPdg);
@@ -250,17 +236,6 @@ void AliTRDtrackInfoGen::Exec(Option_t *){
         fTrackInfo->AddTrackRef(ref);
         jref++;
       }
-      if(!fTrackInfo->GetNTrackRefs()){ 
-          //if(!esdTrack->GetNcls(2)) continue;
-  /*           printf("No TRD Track References in the Track [%d] II\n", itrk);
-            printf("Label = %d ITS[%d] TPC[%d] TRD[%d]\n", label, esdTrack->GetITSLabel(), esdTrack->GetTPCLabel(), esdTrack-  >GetTRDLabel());
-            Int_t kref = 0;
-            while(kref<nRefs){
-              ref = mcParticle->GetTrackReference(kref);
-              printf("\ttrackRef[%2d] @ %7.3f\n", kref, ref->LocalX());
-              kref++;
-            }*/
-      }
       if(fDebugLevel>=2) printf("NtrackRefs[%d(%d)]\n", fTrackInfo->GetNTrackRefs(), nRefs);
     } else {
       new (fTrackInfo) AliTRDtrackInfo();
@@ -270,8 +245,14 @@ void AliTRDtrackInfoGen::Exec(Option_t *){
     // copy some relevant info to TRD track info
     fTrackInfo->SetStatus(esdTrack->GetStatus());
     fTrackInfo->SetTrackId(esdTrack->GetID());
+    Double_t p[AliPID::kSPECIES]; esdTrack->GetTRDpid(p);
+    fTrackInfo->SetESDpid(p);
+    fTrackInfo->SetESDpidQuality(esdTrack->GetTRDpidQuality());
     fTrackInfo->SetLabel(label);
     fTrackInfo->SetNumberOfClustersRefit(esdTrack->GetNcls(2));
+    // some other Informations which we may wish to store in order to find problematic cases
+    fTrackInfo->SetKinkIndex(esdTrack->GetKinkIndex(0));
+    fTrackInfo->SetTPCncls(static_cast<UShort_t>(esdTrack->GetNcls(1)));
     nclsTrklt = 0;
   
 
@@ -281,35 +262,28 @@ void AliTRDtrackInfoGen::Exec(Option_t *){
       Int_t icalib = 0;
       while((calObject = esdFriendTrack->GetCalibObject(icalib++))){
         if(strcmp(calObject->IsA()->GetName(),"AliTRDtrackV1") != 0) continue; // Look for the TRDtrack
-        track = dynamic_cast<AliTRDtrackV1*>(calObject);
-        //nTRD++;
-        if(!esdTrack->GetNcls(2)){
-          printf("No TRD clusters but track\n");
-          nTRD++;  
-        }  
-        if(!track) continue;
+        if(!(track = dynamic_cast<AliTRDtrackV1*>(calObject))) break;
+        nTRD++;
         if(fDebugLevel>=3) printf("TRD track OK\n");
-        fTrackInfo->SetTRDtrack(track);
+        fTrackInfo->SetTrack(track);
         break;
       }
       if(fDebugLevel>=2) printf("Ntracklets[%d]\n", fTrackInfo->GetNTracklets());
     } else if(fDebugLevel>=2) printf("No ESD friends\n");
     if(op) fTrackInfo->SetOuterParam(op);
 
-    if(fDebugLevel >= 2){
-      Int_t ncls = esdTrack->GetNcls(2);
-      nclsTrklt = fTrackInfo->GetNumberOfClusters();
+    if(fDebugLevel >= 1){
+      AliTRDtrackInfo info(*fTrackInfo);
       (*fDebugStream) << "trackInfo"
-      << "ncls="       << ncls
-      << "Ncls="       << nclsTrklt
-      << "TrackInfo.=" << fTrackInfo
+      << "TrackInfo.=" << &info
       << "\n";
+      info.Delete("");
     }
   
     fContainer->Add(new AliTRDtrackInfo(*fTrackInfo));
     fTrackInfo->Delete("");
   }
-  if(fDebugLevel>=1) printf("%3d Tracks: TPC[%d] TRD[%d]\n", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), nTPC, nTRD);
+  if(fDebugLevel>=2) printf("%3d Tracks: TPC[%d] TRD[%d]\n", (Int_t)AliAnalysisManager::GetAnalysisManager()->GetCurrentEntry(), nTPC, nTRD);
 
   // Insert also MC tracks which are passing TRD where the track is not reconstructed
   if(HasMCdata()){
@@ -350,11 +324,11 @@ void AliTRDtrackInfoGen::Exec(Option_t *){
       fTrackInfo->SetPrimary(mcParticle->Particle()->IsPrimary());
       fTrackInfo->SetLabel(itk);
       if(fDebugLevel >= 1){
-        Int_t ncls = esdTrack->GetNcls(2);
+        AliTRDtrackInfo info(*fTrackInfo);
         (*fDebugStream) << "trackInfo"
-        << "ntrackRefs=" << ncls
-        << "TrackInfo.=" << fTrackInfo
+        << "TrackInfo.=" << &info
         << "\n";
+        info.Delete("");
       }
       if(fDebugLevel > 2)printf("Registering rejected MC track with label %d\n", itk);
       fContainer->Add(new AliTRDtrackInfo(*fTrackInfo));