]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - AliGeant4/AliEventAction.cxx
Correcter eror by A. Dainese
[u/mrichter/AliRoot.git] / AliGeant4 / AliEventAction.cxx
index ee1c4933b63ee4690e9cddf3ea6487e2208fee43..57c8a1c6ab8e29c081199165939934ccb5f8ed8d 100644 (file)
@@ -1,6 +1,10 @@
 // $Id$
 // Category: event
 //
+// Author: I. Hrivnacova
+//
+// Class AliEventAction
+// ---------------------
 // See the class description in the header file.
 
 #include <G4Timer.hh>
@@ -8,7 +12,6 @@
    // times system function this include must be the first
 
 #include "AliEventAction.h"
-#include "AliEventActionMessenger.h"
 #include "AliTrackingAction.h"
 #include "AliGlobals.h"
 #include "AliRun.h"
 
 //_____________________________________________________________________________
 AliEventAction::AliEventAction()
-  : fVerboseLevel(1), 
+  : AliVerbose("eventAction"),
+    fMessenger(this),
     fDrawFlag("CHARGED")
 {
 //
-  fMessenger = new AliEventActionMessenger(this);
   fTimer = new G4Timer();
 }
 
 //_____________________________________________________________________________
-AliEventAction::AliEventAction(const AliEventAction& right) {
+AliEventAction::AliEventAction(const AliEventAction& right)
+  : AliVerbose(""),
+    fMessenger(this) {
 //
   AliGlobals::Exception("AliEventAction is protected from copying.");
 }
@@ -39,7 +44,6 @@ AliEventAction::AliEventAction(const AliEventAction& right) {
 //_____________________________________________________________________________
 AliEventAction::~AliEventAction() {
 //
-  delete fMessenger;
   delete fTimer;
 }
 
@@ -64,26 +68,22 @@ void AliEventAction::DisplayEvent(const G4Event* event) const
 // Draws trajectories.
 // ---
 
-  // trajectories processing
-  G4TrajectoryContainer* trajectoryContainer 
-    = event->GetTrajectoryContainer();
+  if (G4VVisManager::GetConcreteInstance()) {
 
-  G4int nofTrajectories = 0;
-  if (trajectoryContainer)
-  { nofTrajectories = trajectoryContainer->entries(); }
-  
-  if (fVerboseLevel>0 && nofTrajectories>0) {
-    G4cout << "    " << nofTrajectories; 
-    G4cout << " trajectories stored." << G4endl;
-  }  
+    // trajectories processing
+    G4TrajectoryContainer* trajectoryContainer 
+      = event->GetTrajectoryContainer();
 
-  G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
-  if(pVVisManager && nofTrajectories>0)
-  {
-    G4UImanager::GetUIpointer()->ApplyCommand("/vis~/draw/current");
+    G4int nofTrajectories = 0;
+    if (trajectoryContainer)
+      nofTrajectories = trajectoryContainer->entries(); 
+  
+    if (VerboseLevel() > 0 && nofTrajectories > 0) {
+      G4cout << "    " << nofTrajectories; 
+      G4cout << " trajectories stored." << G4endl;
+    }  
 
-    for (G4int i=0; i<nofTrajectories; i++)
-    { 
+    for (G4int i=0; i<nofTrajectories; i++) { 
       G4VTrajectory* vtrajectory = (*(event->GetTrajectoryContainer()))[i];
       G4Trajectory* trajectory = dynamic_cast<G4Trajectory*>(vtrajectory);
       if (!trajectory) {
@@ -97,8 +97,7 @@ void AliEventAction::DisplayEvent(const G4Event* event) const
            // use 2000 to make step points well visible
       }        
     }      
-    G4UImanager::GetUIpointer()->ApplyCommand("/vis~/show/view");
-  }  
+  }
 }
 
 // public methods
@@ -112,10 +111,12 @@ 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)
+  if (VerboseLevel() > 0) {
     G4cout << ">>> Event " << event->GetEventID() << G4endl;
+  }  
 
   fTimer->Start();
 }
@@ -128,26 +129,27 @@ 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) {
+  if (VerboseLevel() > 0) {
     G4cout << G4endl;
     G4cout << ">>> End of Event " << event->GetEventID() << G4endl;
   }
 
-  if (fVerboseLevel>1) {
+  if (VerboseLevel() > 1) {
     //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
@@ -156,7 +158,7 @@ void AliEventAction::EndOfEventAction(const G4Event* event)
   // aliroot finish event
   gAlice->FinishEvent();    
 
-  if (fVerboseLevel>1) {
+  if (VerboseLevel() > 1) {
     // print time
     fTimer->Stop();
     G4cout << "Time of this event: " << *fTimer << G4endl;