]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGHF/hfe/AliHFEreducedEventCreatorAOD.cxx
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / PWGHF / hfe / AliHFEreducedEventCreatorAOD.cxx
index 4f0ebd5ab5b9ef474bdd92b3adf3759101ea29d2..1e0e18d79bf0effd232c4e1643fd5ec03a11765e 100644 (file)
@@ -234,6 +234,7 @@ void AliHFEreducedEventCreatorAOD::UserExec(Option_t *){
   fHFEevent->SetRunNumber(fInputEvent->GetRunNumber());
 
   // Derive trigger 
+  AliDebug(1, "Get triggers\n");
   UInt_t trigger = fInputHandler->IsEventSelected();
   if(trigger & AliVEvent::kMB) fHFEevent->SetMBTrigger();
   if(trigger & AliVEvent::kCentral) fHFEevent->SetCentralTrigger();
@@ -241,55 +242,71 @@ void AliHFEreducedEventCreatorAOD::UserExec(Option_t *){
   if(trigger & AliVEvent::kEMCEJE) fHFEevent->SetEMCALTrigger();
 
   // Get Primary Vertex
+  AliDebug(1, "Get Primary Vertex\n");
   const AliVVertex *vertex = fInputEvent->GetPrimaryVertex();
   Double_t vtx[3];
-  vertex->GetXYZ(vtx);
+  Double_t vcov[6];
+  Int_t ncontrib = -1;
+  if(vertex) {
+    AliDebug(1, "Found vertex\n");
+    vertex->GetXYZ(vtx);
+    ncontrib = vertex->GetNContributors();
+    vertex->GetCovarianceMatrix(vcov);
+  }
   fHFEevent->SetVX(vtx[0]);
   fHFEevent->SetVY(vtx[1]);
   fHFEevent->SetVZ(vtx[2]);
-  Int_t ncontrib(vertex->GetNContributors());
   fHFEevent->SetNContribVertex(ncontrib);
-  Double_t vcov[6];
-  vertex->GetCovarianceMatrix(vcov);
-  fHFEevent->SetVertexResolution(TMath::Sqrt(vcov[5]));
+  fHFEevent->SetVertexResolution(TMath::Sqrt(TMath::Abs(vcov[5])));
   // Get Primary Vertex from SPD
   const AliVVertex *vertexSPD = aodE->GetPrimaryVertexSPD();
   if(vertexSPD){
-    memset(vtx, 0, sizeof(Double_t) *6);
+    AliDebug(1, "Found SPD vertex\n");
+    memset(vtx, 0, sizeof(Double_t) *3);
     vertexSPD->GetXYZ(vtx);
     fHFEevent->SetVXSPD(vtx[0]);
     fHFEevent->SetVYSPD(vtx[1]);
     fHFEevent->SetVZSPD(vtx[2]);
     fHFEevent->SetNContribVertexSPD(vertexSPD->GetNContributors());
     memset(vcov, 0, sizeof(Double_t)*6);
-    vertex->GetCovarianceMatrix(vcov);
-    fHFEevent->SetVertexResolutionSPD(TMath::Sqrt(vcov[5]));
+    vertexSPD->GetCovarianceMatrix(vcov);
+    AliDebug(1, Form("Covariance Matrix vcov[5] %f\n",vcov[5]));
+    fHFEevent->SetVertexResolutionSPD(TMath::Sqrt(TMath::Abs(vcov[5])));
   }
 
   // Get centrality
+  AliDebug(1, "Centrality\n");
   AliCentrality *hicent = fInputEvent->GetCentrality();
-  fHFEevent->SetCentrality(
+  if(hicent) fHFEevent->SetCentrality(
     hicent->GetCentralityPercentile("V0M"),
     hicent->GetCentralityPercentile("V0A"),
     hicent->GetCentralityPercentile("V0C"),
     hicent->GetCentralityPercentile("TKL"),
     hicent->GetCentralityPercentile("TRK"),
-    hicent->GetCentralityPercentile("ZNA")
+    hicent->GetCentralityPercentile("ZNA"),
+    hicent->GetCentralityPercentile("ZNC"),
+    hicent->GetCentralityPercentile("CL0"),
+    hicent->GetCentralityPercentile("CL1"),
+    hicent->GetCentralityPercentile("CND")
   );
 
   // Get VZERO Information
+  AliDebug(1, "VZERO info\n");
   AliVVZERO *vzeroinfo = fInputEvent->GetVZEROData();
   if(vzeroinfo) fHFEevent->SetV0Multiplicity(vzeroinfo->GetMTotV0A(), vzeroinfo->GetMTotV0C());
 
   // Get ZDC Information
+  AliDebug(1, "ZDC info\n");
   AliVZDC *zdcinfo = fInputEvent->GetZDCData();
   if(zdcinfo) fHFEevent->SetZDCEnergy(zdcinfo->GetZNAEnergy(), zdcinfo->GetZNCEnergy(), zdcinfo->GetZPAEnergy(), zdcinfo->GetZPCEnergy()); 
   
   // Set SPD multiplicity
+  AliDebug(1, "SPD multiplicity\n");
   AliAODTracklets *tls = aodE->GetTracklets();
   if(tls) fHFEevent->SetSPDMultiplicity(tls->GetNumberOfTracklets());
 
   // Look for kink mother
+  AliDebug(1, "Vertices\n");
   Int_t numberofvertices = aodE->GetNumberOfVertices();
   Double_t listofmotherkink[numberofvertices];
   Int_t numberofmotherkink = 0;
@@ -317,11 +334,13 @@ void AliHFEreducedEventCreatorAOD::UserExec(Option_t *){
   // Monte-Carlo info
   Int_t source(5);
   if(mcthere){
+    AliDebug(1, "Loop MC tracks\n");
     for(Int_t itrack = 0; itrack < fAODArrayMCInfo->GetEntriesFast(); itrack++) {
       mctrack = (AliAODMCParticle *)(fAODArrayMCInfo->At(itrack));
       if(!mctrack) continue;
       AliHFEreducedMCParticle hfemcpart;
-      if(fTrackCuts->CheckParticleCuts(static_cast<UInt_t>(AliHFEcuts::kStepMCGenerated), mctrack)) hfemcpart.SetSignal();
+      if(fTrackCuts->CheckParticleCuts(static_cast<UInt_t>(AliHFEcuts::kStepMCGenerated), mctrack)) continue;        
+      hfemcpart.SetSignal();
       // Kinematics
       hfemcpart.SetSignedPt(mctrack->Pt(), mctrack->Charge() > 0.);
       hfemcpart.SetP(mctrack->P());
@@ -360,6 +379,7 @@ void AliHFEreducedEventCreatorAOD::UserExec(Option_t *){
   Int_t counterdc=0;
   
   AliAODTrack *track = 0x0;
+  AliDebug(1, "Loop reconstructed tracks\n");
   for(Int_t itrack = 0; itrack < fInputEvent->GetNumberOfTracks(); itrack++){
     // Run track loop
     track = dynamic_cast<AliAODTrack *>(fInputEvent->GetTrack(itrack));
@@ -400,36 +420,40 @@ void AliHFEreducedEventCreatorAOD::UserExec(Option_t *){
     if(mcthere){
       // Fill Monte-Carlo Information
       Int_t label = TMath::Abs(track->GetLabel());
-      if(label && label < fAODArrayMCInfo->GetEntriesFast())
+      if(label < fAODArrayMCInfo->GetEntriesFast())
         mctrack = dynamic_cast<AliAODMCParticle *>(fAODArrayMCInfo->At(label));
-      if(!mctrack) continue;
-      if(fTrackCuts->CheckParticleCuts(static_cast<UInt_t>(AliHFEcuts::kStepMCGenerated), mctrack)) hfetrack.SetMCSignal();
-      // Kinematics
-      hfetrack.SetMCSignedPt(mctrack->Pt(),mctrack->Charge() > 0.);
-      hfetrack.SetMCP(mctrack->P());
-      hfetrack.SetMCEta(mctrack->Eta());
-      hfetrack.SetMCPhi(mctrack->Phi());
-      hfetrack.SetMCPDG(mctrack->GetPdgCode());
+      if(mctrack){ 
+        AliDebug(2, "Associated MC particle found\n");
+        if(fTrackCuts->CheckParticleCuts(static_cast<UInt_t>(AliHFEcuts::kStepMCGenerated), mctrack)) hfetrack.SetMCSignal();
+        // Kinematics
+        hfetrack.SetMCSignedPt(mctrack->Pt(),mctrack->Charge() > 0.);
+        hfetrack.SetMCP(mctrack->P());
+        hfetrack.SetMCEta(mctrack->Eta());
+        hfetrack.SetMCPhi(mctrack->Phi());
+        hfetrack.SetMCPDG(mctrack->GetPdgCode());
       
-      // Get Production Vertex in radial direction
-      hfetrack.SetMCProdVtx(mctrack->Xv(),mctrack->Yv(),mctrack->Zv());
+        // Get Production Vertex in radial direction
+        hfetrack.SetMCProdVtx(mctrack->Xv(),mctrack->Yv(),mctrack->Zv());
       
-      // Get Mother PDG code of the particle
-      Int_t motherlabel = TMath::Abs(mctrack->GetMother());
-      if(motherlabel >= 0 && motherlabel < fAODArrayMCInfo->GetEntriesFast()){
-        AliAODMCParticle *mother = dynamic_cast<AliAODMCParticle *>(fAODArrayMCInfo->At(motherlabel));
-        if(mother) hfetrack.SetMCMotherPdg(mother->GetPdgCode());
-      }
+        // Get Mother PDG code of the particle
+        Int_t motherlabel = TMath::Abs(mctrack->GetMother());
+        if(motherlabel >= 0 && motherlabel < fAODArrayMCInfo->GetEntriesFast()){
+          AliAODMCParticle *mother = dynamic_cast<AliAODMCParticle *>(fAODArrayMCInfo->At(motherlabel));
+          if(mother) hfetrack.SetMCMotherPdg(mother->GetPdgCode());
+        }
       
-      // derive source
-      source = 5;
-      if(fSignalCuts->IsCharmElectron(mctrack)) source = 0;
-      else if(fSignalCuts->IsBeautyElectron(mctrack)) source = 1;
-      else if(fSignalCuts->IsGammaElectron(mctrack)) source = 2;
-      else if(fSignalCuts->IsNonHFElectron(mctrack)) source = 3;
-      else if(TMath::Abs(mctrack->GetPdgCode()) == 11) source = 4;
-      else source = 5;
-      hfetrack.SetMCSource(source); 
+        // derive source
+        source = 5;
+        if(fSignalCuts->IsCharmElectron(mctrack)) source = 0;
+        else if(fSignalCuts->IsBeautyElectron(mctrack)) source = 1;
+        else if(fSignalCuts->IsGammaElectron(mctrack)) source = 2;
+        else if(fSignalCuts->IsNonHFElectron(mctrack)) source = 3;
+        else if(TMath::Abs(mctrack->GetPdgCode()) == 11) source = 4;
+        else source = 5;
+        hfetrack.SetMCSource(source); 
+      } else {
+        AliDebug(2, "Associated MC particle not found\n");
+      }
     }
 
     // HFE DCA
@@ -437,6 +461,9 @@ void AliHFEreducedEventCreatorAOD::UserExec(Option_t *){
             dcaz = -999.;
     fExtraCuts->GetImpactParameters((AliVTrack *)track,dcaxy,dcaz);
     hfetrack.SetDCA(dcaxy, dcaz);
+    Double_t hfeImpactParam(-999.), hfeImpactParamResol(-999.);
+    fExtraCuts->GetHFEImpactParameters((AliVTrack *)track,hfeImpactParam,hfeImpactParamResol);
+    hfetrack.SetHFEImpactParam(hfeImpactParam,hfeImpactParamResol);
 
     // Different number of clusters definitions
     Int_t nclustersITS(track->GetITSNcls()),
@@ -479,18 +506,17 @@ void AliHFEreducedEventCreatorAOD::UserExec(Option_t *){
 
 
     // Kink
-    Int_t kink = 0;
-    if(fExtraCuts->IsKinkDaughter(track)) kink = 1;
+    if(fExtraCuts->IsKinkDaughter(track)) hfetrack.SetIsKinkDaughter();
 
     // kink mother
-    Int_t kinkmotherpass = 0;
     for(Int_t kinkmother = 0; kinkmother < numberofmotherkink; kinkmother++) {
       if(track->GetID() == listofmotherkink[kinkmother]) {
-             kinkmotherpass = 1;
+             hfetrack.SetIsKinkMother();
              continue;
       }
     }
     
+    
     // Double counted
     Int_t id(track->GetID());
     for(Int_t l=0; l < counterdc; l++){
@@ -509,6 +535,7 @@ void AliHFEreducedEventCreatorAOD::UserExec(Option_t *){
     hfetrack.SetTPCsigmaEl(pid->NumberOfSigmasTPC(track, AliPID::kElectron));
     hfetrack.SetTOFsigmaEl(pid->NumberOfSigmasTOF(track, AliPID::kElectron));
     hfetrack.SetTOFmismatchProbability(pid->GetTOFMismatchProbability(track));
+    hfetrack.SetITSsigmaEl(pid->NumberOfSigmasITS(track, AliPID::kElectron));
     // Eta correction
     copyTrack.~AliAODTrack();
     new(&copyTrack) AliAODTrack(*track);
@@ -527,6 +554,7 @@ void AliHFEreducedEventCreatorAOD::UserExec(Option_t *){
 
     // If TOF cut
     if(fNbOfTOFSigma>0.0){
+      AliDebug(1, "TOF cut\n");
       if(!((status & AliVTrack::kTOFpid) == AliVTrack::kTOFpid)) continue; 
       if(TMath::Abs(pid->NumberOfSigmasTOF(track, AliPID::kElectron))> fNbOfTOFSigma) continue;
     }