]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
adding option to reject injected tracks (copy from AliAnalysisTaskPhiCorrelations...
authorMichael Weber <m.weber@cern.ch>
Fri, 13 Dec 2013 18:15:32 +0000 (19:15 +0100)
committerMichael Weber <m.weber@cern.ch>
Fri, 13 Dec 2013 18:15:32 +0000 (19:15 +0100)
to be done: also for Balance Function

PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskEffContBF.cxx
PWGCF/EBYE/BalanceFunctions/AliAnalysisTaskEffContBF.h

index 6b1084f87501ec67ced18da0dec56b92bdd4c727..24c32bcef6d14c0faa963211e97de1c2b3c68b16 100644 (file)
 #include "AliAODEvent.h" 
 #include "AliAODInputHandler.h"
 #include "AliAODMCParticle.h"
+#include "AliAODMCHeader.h"
 #include "AliCentrality.h"
+#include "AliGenEventHeader.h"
 
+#include "AliLog.h"
 #include "AliAnalysisTaskEffContBF.h"
 
 // ---------------------------------------------------------------------
@@ -311,6 +314,38 @@ void AliAnalysisTaskEffContBF::UserExec(Option_t *) {
     AliError("ERROR: Could not retrieve MC event");
     return;
   }
+
+  // ==============================================================================================
+  // Copy from AliAnalysisTaskPhiCorrelations:
+  // For productions with injected signals, figure out above which label to skip particles/tracks
+  Int_t skipParticlesAbove = 0;
+  if (fInjectedSignals)
+  {
+    AliGenEventHeader* eventHeader = 0;
+    Int_t headers = 0;
+    
+    // AOD only
+    AliAODMCHeader* header = (AliAODMCHeader*) fAOD->GetList()->FindObject(AliAODMCHeader::StdBranchName());
+    if (!header)
+      AliFatal("fInjectedSignals set but no MC header found");
+    
+    headers = header->GetNCocktailHeaders();
+    eventHeader = header->GetCocktailHeader(0);
+    
+    
+    if (!eventHeader)
+      {
+       // We avoid AliFatal here, because the AOD productions sometimes have events where the MC header is missing 
+       // (due to unreadable Kinematics) and we don't want to loose the whole job because of a few events
+       AliError("First event header not found. Skipping this event.");
+       return;
+      }
+    
+    skipParticlesAbove = eventHeader->NProduced();
+    AliInfo(Form("Injected signals in this event (%d headers). Keeping particles/tracks of %s. Will skip particles/tracks above %d.", headers, eventHeader->ClassName(), skipParticlesAbove)); 
+  }
+  // ==============================================================================================
+
   
   // arrays for 2 particle histograms
   Int_t nMCLabelCounter         = 0;
@@ -391,6 +426,44 @@ void AliAnalysisTaskEffContBF::UserExec(Option_t *) {
                //if (!(AODmcTrack->IsPhysicalPrimary())) {
                //fHistContaminationSecondaries->Fill(track->Eta(),track->Pt(),phiDeg);
                //}
+
+               // ==============================================================================================
+               // Partial copy from AliAnalyseLeadingTrackUE::RemoveInjectedSignals:
+               // Skip tracks that come from injected signals
+               if (fInjectedSignals)
+                 {    
+     
+                   AliAODMCParticle* mother = AODmcTrack;
+                   
+                   // find the primary mother (if not already physical primary)
+                   while (!((AliAODMCParticle*)mother)->IsPhysicalPrimary())
+                     {
+                       if (((AliAODMCParticle*)mother)->GetMother() < 0)
+                         {
+                           mother = 0;
+                           break;
+                         }
+                       
+                       mother = (AliAODMCParticle*) fArrayMC->At(((AliAODMCParticle*)mother)->GetMother());
+                       if (!mother)
+                         break;
+                     }
+                   
+                   
+                   if (!mother)
+                     {
+                       AliError(Form("WARNING: No mother found for particle %d:", AODmcTrack->GetLabel()));
+                       continue;
+                     }
+
+                   if (mother->GetLabel() >= skipParticlesAbove)
+                     {
+                       //AliInfo(Form("Remove particle %d (>= %d)",mother->GetLabel(),skipParticlesAbove));
+                       continue;
+                     }
+                 }
+               // ==============================================================================================
+
                if (AODmcTrack->IsPhysicalPrimary()) {
                  if(gAODmcCharge > 0){
                    fHistContaminationPrimariesPlus->Fill(track->Eta(),track->Pt(),phiRad);
index 95f8ec328a6d5da64ba3015840a178048a699250..db7d49f6a02d1a1c75bd19812b66f27bc12e00bf 100644 (file)
@@ -58,6 +58,7 @@ class AliAnalysisTaskEffContBF : public AliAnalysisTaskSE {
     fCentralityEstimator("V0M"), 
     fCentralityPercentileMin(0.0), 
     fCentralityPercentileMax(5.0), 
+    fInjectedSignals(kFALSE),
     fVxMax(3.0), 
     fVyMax(3.0), 
     fVzMax(10.), 
@@ -106,6 +107,9 @@ class AliAnalysisTaskEffContBF : public AliAnalysisTaskSE {
     fCentralityPercentileMax=max;
   }
 
+  //Injected signals
+  void SetRejectInjectedSignals() {fInjectedSignals = kTRUE;}
+
   //Track cuts
   void SetMinNumberOfTPCClusters(Double_t min) {
     fMinNumberOfTPCClusters = min;}
@@ -186,6 +190,8 @@ class AliAnalysisTaskEffContBF : public AliAnalysisTaskSE {
   TString fCentralityEstimator;//"V0M","TRK","TKL","ZDC","FMD"
   Float_t fCentralityPercentileMin, fCentralityPercentileMax; //min-max centrality percentile
 
+  Bool_t fInjectedSignals;//Flag for using the rejection of injected signals
+
   Double_t fVxMax;//vxmax
   Double_t fVyMax;//vymax
   Double_t fVzMax;//vzmax