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 df1bd6076a5f3a19bc5ce58bdc4230bcbfa16b2d..affb834baa7b3aba7a1a20b2444865d221c72770 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 f8b483611c42b74218f7d50ada0d30469ead4b84..b8d72342b90345500d706ffdc4b2550d23513141 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 a828c7a6c3085b36cbd99e3c04aa8f9e4c4949dc..b6efe7f420ac9cc57b8c6227648891b8b58b59fe 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;
 }