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()
30 : AliVerbose("runAction"),
37 //_____________________________________________________________________________
38 AliRunAction::AliRunAction(const AliRunAction& right)
39 : AliVerbose("runAction") {
41 AliGlobals::Exception("AliRunAction is protected from copying.");
44 //_____________________________________________________________________________
45 AliRunAction::~AliRunAction() {
52 //_____________________________________________________________________________
53 AliRunAction& AliRunAction::operator=(const AliRunAction &right)
55 // check assignement to self
56 if (this == &right) return *this;
58 AliGlobals::Exception("AliRunAction is protected from assigning.");
65 //_____________________________________________________________________________
66 AliSDConstruction* AliRunAction::GetSDConstruction() const
68 // Gets sensitive detectors construction and checks type.
71 TG4VSDConstruction* tg4SDConstruction
72 = TG4SDManager::Instance()->GetSDConstruction();
74 AliSDConstruction* aliSDConstruction
75 = dynamic_cast<AliSDConstruction*>(tg4SDConstruction);
77 if (!aliSDConstruction) {
78 G4String text = "AliRunAction::GetSDConstruction:\n";
79 text = text + " Unknown type.";
80 AliGlobals::Exception(text);
84 return aliSDConstruction;
89 //_____________________________________________________________________________
90 void AliRunAction::BeginOfRunAction(const G4Run* run)
92 // Called by G4 kernel at the beginning of run.
98 // store runID in the event header
99 gAlice->GetHeader()->SetRun(fRunID);
101 // create lego sensitive detectors
102 // if lego is instantiated
103 AliLego* lego = gAlice->Lego();
105 GetSDConstruction()->SetLego(lego);
106 G4UImanager::GetUIpointer()->ApplyCommand("/aliVerbose/eventAction 0");
107 G4UImanager::GetUIpointer()->ApplyCommand("/aliGenerator/set AliGenerator");
111 if (G4VVisManager::GetConcreteInstance()) {
112 G4UImanager::GetUIpointer()->ApplyCommand("/vis/scene/notifyHandlers");
115 if (VerboseLevel() > 0) {
116 G4cout << "### Run " << run->GetRunID() << " start." << G4endl;
122 //_____________________________________________________________________________
123 void AliRunAction::EndOfRunAction(const G4Run* run)
125 // Called by G4 kernel at the end of run.
130 // delete lego sensitive detectors
131 // if lego is instantiated
132 AliLego* lego = gAlice->Lego();
134 GetSDConstruction()->UnsetLego();
135 G4UImanager::GetUIpointer()->ApplyCommand("/aliVerbose/eventAction 0");
139 if (G4VVisManager::GetConcreteInstance()) {
140 G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/update");
143 if (VerboseLevel() > 0) {
144 G4cout << "Time of this run: " << *fTimer << G4endl;
145 G4cout << "Number of events processed: " << run->GetNumberOfEvent() << G4endl;