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 <G4UImanager.hh>
27 //_____________________________________________________________________________
28 AliRunAction::AliRunAction()
37 //_____________________________________________________________________________
38 AliRunAction::AliRunAction(const AliRunAction& right)
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("/aliEvent/verbose 0");
107 G4UImanager::GetUIpointer()->ApplyCommand("/aliGenerator/set AliGenerator");
110 G4cout << "### Run " << run->GetRunID() << " start." << G4endl;
114 //_____________________________________________________________________________
115 void AliRunAction::EndOfRunAction(const G4Run* run)
117 // Called by G4 kernel at the end of run.
122 // delete lego sensitive detectors
123 // if lego is instantiated
124 AliLego* lego = gAlice->Lego();
126 GetSDConstruction()->UnsetLego();
127 G4UImanager::GetUIpointer()->ApplyCommand("/aliEvent/verbose 1");
130 G4cout << "Time of this run: " << *fTimer << G4endl;
131 G4cout << "Number of events processed: " << run->GetNumberOfEvent() << G4endl;