4 // Author: I. Hrivnacova
8 // See the class description in the header file.
11 // in order to avoid the odd dependency for the
12 // times system function this include must be the first
14 #include "AliRunAction.h"
15 #include "AliSDConstruction.h"
16 #include "AliGlobals.h"
18 #include "AliHeader.h"
21 #include "TG4SDManager.h"
22 #include "TG4VSDConstruction.h"
25 #include <G4VVisManager.hh>
26 #include <G4UImanager.hh>
28 //_____________________________________________________________________________
29 AliRunAction::AliRunAction()
38 //_____________________________________________________________________________
39 AliRunAction::AliRunAction(const AliRunAction& right)
42 AliGlobals::Exception("AliRunAction is protected from copying.");
45 //_____________________________________________________________________________
46 AliRunAction::~AliRunAction() {
53 //_____________________________________________________________________________
54 AliRunAction& AliRunAction::operator=(const AliRunAction &right)
56 // check assignement to self
57 if (this == &right) return *this;
59 AliGlobals::Exception("AliRunAction is protected from assigning.");
66 //_____________________________________________________________________________
67 AliSDConstruction* AliRunAction::GetSDConstruction() const
69 // Gets sensitive detectors construction and checks type.
72 TG4VSDConstruction* tg4SDConstruction
73 = TG4SDManager::Instance()->GetSDConstruction();
75 AliSDConstruction* aliSDConstruction
76 = dynamic_cast<AliSDConstruction*>(tg4SDConstruction);
78 if (!aliSDConstruction) {
79 G4String text = "AliRunAction::GetSDConstruction:\n";
80 text = text + " Unknown type.";
81 AliGlobals::Exception(text);
85 return aliSDConstruction;
90 //_____________________________________________________________________________
91 void AliRunAction::BeginOfRunAction(const G4Run* run)
93 // Called by G4 kernel at the beginning of run.
99 // store runID in the event header
100 gAlice->GetHeader()->SetRun(fRunID);
102 // create lego sensitive detectors
103 // if lego is instantiated
104 AliLego* lego = gAlice->Lego();
106 GetSDConstruction()->SetLego(lego);
107 G4UImanager::GetUIpointer()->ApplyCommand("/aliEvent/verbose 0");
108 G4UImanager::GetUIpointer()->ApplyCommand("/aliGenerator/set AliGenerator");
112 if (G4VVisManager::GetConcreteInstance()) {
113 G4UImanager::GetUIpointer()->ApplyCommand("/vis/scene/notifyHandlers");
116 G4cout << "### Run " << run->GetRunID() << " start." << G4endl;
120 //_____________________________________________________________________________
121 void AliRunAction::EndOfRunAction(const G4Run* run)
123 // Called by G4 kernel at the end of run.
128 // delete lego sensitive detectors
129 // if lego is instantiated
130 AliLego* lego = gAlice->Lego();
132 GetSDConstruction()->UnsetLego();
133 G4UImanager::GetUIpointer()->ApplyCommand("/aliEvent/verbose 1");
137 if (G4VVisManager::GetConcreteInstance()) {
138 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
141 G4cout << "Time of this run: " << *fTimer << G4endl;
142 G4cout << "Number of events processed: " << run->GetNumberOfEvent() << G4endl;