]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ANALYSIS/AliCollisionNormalizationTask.cxx
Fix in the last caall to CleanOwnPrimaryVertex
[u/mrichter/AliRoot.git] / ANALYSIS / AliCollisionNormalizationTask.cxx
index 8344f9d70f284e40fdfb355ab91bda277c21614c..0d6a27695a67bb56ba2184ad9703f69332ec20fc 100644 (file)
@@ -69,7 +69,7 @@ AliCollisionNormalizationTask::~AliCollisionNormalizationTask()
   // histograms are in the output list and deleted when the output
   // list is deleted by the TSelector dtor
 
-  if (fOutput) {
+  if (fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) {
     delete fOutput;
     fOutput = 0;
   }
@@ -107,6 +107,9 @@ void AliCollisionNormalizationTask::UserExec(Option_t*)
 
   // Get the ESD
   AliESDEvent * aESD = dynamic_cast<AliESDEvent*>(fInputEvent);
+  if(!aESD) {
+    AliFatal("Cannot get ESD");
+  }
   if (strcmp(aESD->ClassName(),"AliESDEvent")) {
     AliFatal("Not processing ESDs");
   }
@@ -122,7 +125,8 @@ void AliCollisionNormalizationTask::UserExec(Option_t*)
   // NB never call IsEventSelected more than once per event
   // (statistics histogram would be altered)
 
-  Bool_t isSelected = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
+  // FIXME: using only MB events, foresee more events?
+  Bool_t isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
 
   // Get the Multiplicity cut
   const AliMultiplicity* mult = aESD->GetMultiplicity();
@@ -136,17 +140,10 @@ void AliCollisionNormalizationTask::UserExec(Option_t*)
 
   Int_t ntracklet = mult->GetNumberOfTracklets();
   const AliESDVertex * vtxESD = aESD->GetPrimaryVertexSPD();
-  if(vtxESD) {
-    // If there is a vertex from vertexer z with delta phi > 0.02 we
-    // don't consider it rec (we keep the event in bin0). If quality
-    // is good eneough we check the number of tracklets
-    // A similar selection is applied in IsEventInBinZero
-    // If the vertex is too far away, we don't consider it reconstructed either.
-    if ((vtxESD->IsFromVertexerZ() && vtxESD->GetDispersion() > 0.02) || TMath::Abs(vtxESD->GetZ()) > 15) {
-      vtxESD = 0;
-      ntracklet = 0; // Don't trust reconstructed tracklets if you don't trust clusters
-    } 
-  } 
+  if (IsEventInBinZero()) {
+    ntracklet = 0;
+    vtxESD    = 0;
+  }
   
   if (ntracklet > 0 && !vtxESD) {
     AliError("No vertex but reconstructed tracklets?");
@@ -159,11 +156,14 @@ void AliCollisionNormalizationTask::UserExec(Option_t*)
 
   if (fIsMC) {
     // Monte Carlo:  we fill 3 histos
+    if (!isSelected || !vtxESD) ntracklet = 0; //If the event does not pass the physics selection or is not rec, it goes in the bin0
     fCollisionNormalization->FillVzMCGen(vz, ntracklet, mcEvent);      
     // If triggered == passing the physics selection
-    if (isSelected) fCollisionNormalization->FillVzMCTrg(vz, ntracklet, mcEvent);
-    // If reconstructer == good enough vertex
-    if (vtxESD) fCollisionNormalization->FillVzMCRec(vz, ntracklet, mcEvent);    
+    if (isSelected) {
+      fCollisionNormalization->FillVzMCTrg(vz, ntracklet, mcEvent);
+      // If reconstructer == good enough vertex
+      if (vtxESD) fCollisionNormalization->FillVzMCRec(vz, ntracklet, mcEvent);    
+    }
   } else {
     if (isSelected) {
       // Passing the trigger
@@ -195,9 +195,13 @@ Bool_t AliCollisionNormalizationTask::IsEventInBinZero() {
 
   Bool_t isZeroBin = kTRUE;
   const AliESDEvent* esd= dynamic_cast<AliESDEvent*>(fInputEvent);
+  if (!esd){ 
+    Printf("AliCollisionNormalizationTask::IsEventInBinZero: Can't get ESD");
+    return kFALSE;   
+  }
   const AliMultiplicity* mult = esd->GetMultiplicity();
   if (!mult){
-    Printf("AliAnalysisTaskBGvsTime::IsBinZero: Can't get mult object");
+    Printf("AliCollisionNormalizationTask::IsEventInBinZero: Can't get mult object");
     return kFALSE;
   }
   Int_t ntracklet = mult->GetNumberOfTracklets();