]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - AliGeant4/AliRunAction.cxx
Hits cleaning inserted before reading new track
[u/mrichter/AliRoot.git] / AliGeant4 / AliRunAction.cxx
index c643b531695c026de2eb8f197c94d1289f359224..1d6499ab1b6050055fd91a98ee911a4e52e0ddf9 100644 (file)
@@ -1,6 +1,10 @@
 // $Id$
 // Category: run
 //
+// Author: I. Hrivnacova
+//
+// Class AliRunAction
+// ------------------
 // See the class description in the header file.
 
 #include <G4Timer.hh>
    // times system function this include must be the first
 
 #include "AliRunAction.h"
-#include "AliRunActionMessenger.h"
-#include "AliSDManager.h"
+#include "AliSDConstruction.h"
 #include "AliGlobals.h"
 #include "AliRun.h"
+#include "AliHeader.h"
 #include "AliLego.h"
 
-#include "TG4GeometryManager.h"
+#include "TG4SDManager.h"
+#include "TG4VSDConstruction.h"
 
 #include <G4Run.hh>
+#include <G4VVisManager.hh>
 #include <G4UImanager.hh>
 
-#include <TFile.h>
-
+//_____________________________________________________________________________
 AliRunAction::AliRunAction()
-  : fRunID(-1),
-    fVerboseLevel(0)
+  : AliVerbose("runAction"),
+    fRunID(-1) 
 {
 //
-  fMessenger = new AliRunActionMessenger(this);
   fTimer = new G4Timer;
 }
 
-AliRunAction::AliRunAction(const AliRunAction& right) {
+//_____________________________________________________________________________
+AliRunAction::AliRunAction(const AliRunAction& right) 
+  : AliVerbose("runAction") {
 //
   AliGlobals::Exception("AliRunAction is protected from copying.");
 }
 
+//_____________________________________________________________________________
 AliRunAction::~AliRunAction() {
 //
-  delete fMessenger;
   delete fTimer;
 }
 
 // operators
 
+//_____________________________________________________________________________
 AliRunAction& AliRunAction::operator=(const AliRunAction &right)
 {
   // check assignement to self
@@ -53,8 +60,33 @@ AliRunAction& AliRunAction::operator=(const AliRunAction &right)
   return *this;
 }
 
+// private methods
+
+//_____________________________________________________________________________
+AliSDConstruction* AliRunAction::GetSDConstruction() const
+{
+// Gets sensitive detectors construction and checks type.
+// ---
+
+  TG4VSDConstruction* tg4SDConstruction 
+     = TG4SDManager::Instance()->GetSDConstruction();
+
+  AliSDConstruction* aliSDConstruction
+     = dynamic_cast<AliSDConstruction*>(tg4SDConstruction);
+
+  if (!aliSDConstruction) {
+     G4String text = "AliRunAction::GetSDConstruction:\n";
+     text = text + "    Unknown type.";
+     AliGlobals::Exception(text);
+     return 0;
+  }
+  
+  return aliSDConstruction;
+}
+
 // public methods
 
+//_____________________________________________________________________________
 void AliRunAction::BeginOfRunAction(const G4Run* run)
 {
 // Called by G4 kernel at the beginning of run.
@@ -66,23 +98,28 @@ void AliRunAction::BeginOfRunAction(const G4Run* run)
   // store runID in the event header
   gAlice->GetHeader()->SetRun(fRunID);
 
-  // clear remaining G3 tables
-  if (fRunID == 0)
-    TG4GeometryManager::Instance()->ClearG3TablesFinal();
-
   // create lego sensitive detectors 
   // if lego is instantiated
   AliLego* lego = gAlice->Lego();
   if (lego) {
-    AliSDManager::Instance()->SetLego(lego);
-    G4UImanager::GetUIpointer()->ApplyCommand("/aliEvent/verbose 0");
+    GetSDConstruction()->SetLego(lego);
+    G4UImanager::GetUIpointer()->ApplyCommand("/aliVerbose/eventAction 0");
     G4UImanager::GetUIpointer()->ApplyCommand("/aliGenerator/set AliGenerator");
   }  
 
-  G4cout << "### Run " << run->GetRunID() << " start." << endl;
+  // notify graphics 
+  if (G4VVisManager::GetConcreteInstance()) {
+    G4UImanager::GetUIpointer()->ApplyCommand("/vis/scene/notifyHandlers");
+  } 
+
+  if (VerboseLevel() > 0) {
+    G4cout << "### Run " << run->GetRunID() << " start." << G4endl;
+  }
+    
   fTimer->Start();
 }
 
+//_____________________________________________________________________________
 void AliRunAction::EndOfRunAction(const G4Run* run)
 {
 // Called by G4 kernel at the end of run.
@@ -94,10 +131,17 @@ void AliRunAction::EndOfRunAction(const G4Run* run)
   // if lego is instantiated
   AliLego* lego = gAlice->Lego();
   if (lego) {
-    AliSDManager::Instance()->UnsetLego();
-    G4UImanager::GetUIpointer()->ApplyCommand("/aliEvent/verbose 1");
+    GetSDConstruction()->UnsetLego();
+    G4UImanager::GetUIpointer()->ApplyCommand("/aliVerbose/eventAction 0");
   }  
 
-  G4cout << "Number of events = " << run->GetNumberOfEvent() 
-         << " " << *fTimer << endl;
+  // update graphics 
+  if (G4VVisManager::GetConcreteInstance()) {
+     G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
+  }
+
+  if (VerboseLevel() > 0) {
+    G4cout << "Time of this run:   " << *fTimer << G4endl;
+    G4cout << "Number of events processed: " << run->GetNumberOfEvent() << G4endl;
+  }    
 }