safety measures when no name for PartonInfo is given
authormverweij <marta.verweij@cern.ch>
Mon, 3 Nov 2014 13:00:49 +0000 (14:00 +0100)
committermverweij <marta.verweij@cern.ch>
Mon, 3 Nov 2014 13:09:17 +0000 (14:09 +0100)
PWGJE/EMCALJetTasks/AliJetEmbeddingFromGenTask.cxx

index d5f81cf..e8d62dd 100644 (file)
@@ -129,10 +129,12 @@ Bool_t AliJetEmbeddingFromGenTask::ExecOnce()
     fNTracks = 0;
   }
 
-  if (!(InputEvent()->FindListObject(fPartonInfoName))) {
-  fStackPartonInfo = new AliStackPartonInfo("PartonsInfo");
-  fStackPartonInfo->SetName(fPartonInfoName);
-  InputEvent()->AddObject(fStackPartonInfo);
+  if(!fPartonInfoName.IsNull()) {
+    if (!(InputEvent()->FindListObject(fPartonInfoName))) {
+      fStackPartonInfo = new AliStackPartonInfo("PartonsInfo");
+      fStackPartonInfo->SetName(fPartonInfoName);
+      InputEvent()->AddObject(fStackPartonInfo);
+    }
   }
   return kTRUE;
 }
@@ -152,19 +154,21 @@ void AliJetEmbeddingFromGenTask::Run()
   const Int_t nprim = stack->GetNprimary();
   // reject if partons are missing from stack for some reason
   if(nprim < 8) return;
-  TParticle *part6 = stack->Particle(6);
-  TParticle *part7 = stack->Particle(7);
-
-  fStackPartonInfo->SetPartonFlag6(TMath::Abs(part6->GetPdgCode()));
-  fStackPartonInfo->SetPartonPt6(part6->Pt());
-  fStackPartonInfo->SetPartonEta6(part6->Eta());
-  fStackPartonInfo->SetPartonPhi6(part6->Phi());
-  
-  fStackPartonInfo->SetPartonFlag7(TMath::Abs(part7->GetPdgCode()));
-  fStackPartonInfo->SetPartonPt7(part7->Pt());
-  fStackPartonInfo->SetPartonEta7(part7->Eta());
-  fStackPartonInfo->SetPartonPhi7(part7->Phi());
-  
+  if(fStackPartonInfo) {
+    TParticle *part6 = stack->Particle(6);
+    TParticle *part7 = stack->Particle(7);
+    
+    fStackPartonInfo->SetPartonFlag6(TMath::Abs(part6->GetPdgCode()));
+    fStackPartonInfo->SetPartonPt6(part6->Pt());
+    fStackPartonInfo->SetPartonEta6(part6->Eta());
+    fStackPartonInfo->SetPartonPhi6(part6->Phi());
+    
+    fStackPartonInfo->SetPartonFlag7(TMath::Abs(part7->GetPdgCode()));
+    fStackPartonInfo->SetPartonPt7(part7->Pt());
+    fStackPartonInfo->SetPartonEta7(part7->Eta());
+    fStackPartonInfo->SetPartonPhi7(part7->Phi());
+  }
+
   for (Int_t i=0;i<nprim;++i) {
     if (!stack->IsPhysicalPrimary(i))
       continue;