added tests for existence trackingAction
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 5 Oct 2001 08:58:53 +0000 (08:58 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 5 Oct 2001 08:58:53 +0000 (08:58 +0000)
AliGeant4/AliEventAction.cxx
AliGeant4/AliPrimaryGeneratorAction.cxx
AliGeant4/AliStackingAction.cxx

index df1bd60..affb834 100644 (file)
@@ -115,7 +115,8 @@ void AliEventAction::BeginOfEventAction(const G4Event* event)
   G4int eventID = event->GetEventID();
 
   // reset the tracks counters
-  AliTrackingAction::Instance()->PrepareNewEvent();   
+  if(AliTrackingAction::Instance()) 
+    AliTrackingAction::Instance()->PrepareNewEvent();   
 
   if (fVerboseLevel>0)
     G4cout << ">>> Event " << event->GetEventID() << G4endl;
@@ -131,7 +132,7 @@ void AliEventAction::EndOfEventAction(const G4Event* event)
 
   // finish the last primary track of the current event
   AliTrackingAction* trackingAction = AliTrackingAction::Instance();
-  trackingAction->FinishPrimaryTrack();   
+  if (trackingAction) trackingAction->FinishPrimaryTrack();   
 
   // verbose output 
   if (fVerboseLevel>0) {
@@ -143,14 +144,16 @@ void AliEventAction::EndOfEventAction(const G4Event* event)
     //G4int nofPrimaryTracks = trackingAction->GetNofPrimaryTracks();
     G4int nofPrimaryTracks = gAlice->GetHeader()->GetNprimary();
     G4int nofSavedTracks = gAlice->GetNtrack();
-    G4int nofAllTracks = trackingAction->GetNofTracks();
-    
+   
     G4cout  << "    " << nofPrimaryTracks << 
                " primary tracks processed." << G4endl;
     G4cout  << "    " << nofSavedTracks << 
                " tracks saved." << G4endl;
-    G4cout  << "    " << nofAllTracks << 
-               " all tracks processed." << G4endl;
+    if (trackingAction) {
+       G4int nofAllTracks = trackingAction->GetNofTracks();
+       G4cout  << "    " << nofAllTracks << 
+                  " all tracks processed." << G4endl;
+    }    
   }           
 
   // display event
index f8b4836..b8d7234 100644 (file)
@@ -245,7 +245,7 @@ void AliPrimaryGeneratorAction::GeneratePrimaries(G4Event* event)
     // (they would be stored twice)
     AliTrackingAction* trackingAction
       =  AliTrackingAction::Instance();
-    trackingAction->SetSavePrimaries(false);
+    if (trackingAction) trackingAction->SetSavePrimaries(false);
   }  
   else {
     // use particle gun otherwise
@@ -254,7 +254,7 @@ void AliPrimaryGeneratorAction::GeneratePrimaries(G4Event* event)
     // primary particles have to be saved
     AliTrackingAction* trackingAction
       =  AliTrackingAction::Instance();
-    trackingAction->SetSavePrimaries(true);
+    if (trackingAction) trackingAction->SetSavePrimaries(true);
   }  
 }
 
index a828c7a..b6efe7f 100644 (file)
@@ -147,7 +147,10 @@ void AliStackingAction::PrepareNewEvent()
   //stackManager->ClearPostponeStack();
   stackManager->ResetPostponeStack();
   fTrackingAction = AliTrackingAction::Instance();
-  fSavePrimaries = fTrackingAction->GetSavePrimaries();
+  if (fTrackingAction)
+    fSavePrimaries = fTrackingAction->GetSavePrimaries();
+  else   
+    fSavePrimaries = false;
 }