]>
Commit | Line | Data |
---|---|---|
676fb573 | 1 | // $Id$ |
2 | // Category: run | |
3 | // | |
4 | // See the class description in the header file. | |
5 | ||
6 | #include <G4Timer.hh> | |
7 | // in order to avoid the odd dependency for the | |
8 | // times system function this include must be the first | |
9 | ||
10 | #include "AliRunAction.h" | |
11 | #include "AliRunActionMessenger.h" | |
fdfcba4c | 12 | #include "AliSDConstruction.h" |
676fb573 | 13 | #include "AliGlobals.h" |
14 | #include "AliRun.h" | |
fbbe0dd8 | 15 | #include "AliHeader.h" |
676fb573 | 16 | #include "AliLego.h" |
17 | ||
18 | #include "TG4GeometryManager.h" | |
fdfcba4c | 19 | #include "TG4SDManager.h" |
20 | #include "TG4VSDConstruction.h" | |
676fb573 | 21 | |
22 | #include <G4Run.hh> | |
23 | #include <G4UImanager.hh> | |
24 | ||
fdfcba4c | 25 | //_____________________________________________________________________________ |
676fb573 | 26 | AliRunAction::AliRunAction() |
27 | : fRunID(-1), | |
28 | fVerboseLevel(0) | |
29 | { | |
30 | // | |
31 | fMessenger = new AliRunActionMessenger(this); | |
32 | fTimer = new G4Timer; | |
33 | } | |
34 | ||
fdfcba4c | 35 | //_____________________________________________________________________________ |
676fb573 | 36 | AliRunAction::AliRunAction(const AliRunAction& right) { |
37 | // | |
38 | AliGlobals::Exception("AliRunAction is protected from copying."); | |
39 | } | |
40 | ||
fdfcba4c | 41 | //_____________________________________________________________________________ |
676fb573 | 42 | AliRunAction::~AliRunAction() { |
43 | // | |
44 | delete fMessenger; | |
45 | delete fTimer; | |
46 | } | |
47 | ||
48 | // operators | |
49 | ||
fdfcba4c | 50 | //_____________________________________________________________________________ |
676fb573 | 51 | AliRunAction& AliRunAction::operator=(const AliRunAction &right) |
52 | { | |
53 | // check assignement to self | |
54 | if (this == &right) return *this; | |
55 | ||
56 | AliGlobals::Exception("AliRunAction is protected from assigning."); | |
57 | ||
58 | return *this; | |
59 | } | |
60 | ||
fdfcba4c | 61 | // private methods |
62 | ||
63 | //_____________________________________________________________________________ | |
64 | AliSDConstruction* AliRunAction::GetSDConstruction() const | |
65 | { | |
66 | // Gets sensitive detectors construction and checks type. | |
67 | // --- | |
68 | ||
69 | TG4VSDConstruction* tg4SDConstruction | |
70 | = TG4SDManager::Instance()->GetSDConstruction(); | |
71 | ||
72 | AliSDConstruction* aliSDConstruction | |
73 | = dynamic_cast<AliSDConstruction*>(tg4SDConstruction); | |
74 | ||
75 | if (!aliSDConstruction) { | |
76 | G4String text = "AliRunAction::GetSDConstruction:\n"; | |
77 | text = text + " Unknown type."; | |
78 | AliGlobals::Exception(text); | |
79 | return 0; | |
80 | } | |
81 | ||
82 | return aliSDConstruction; | |
83 | } | |
84 | ||
676fb573 | 85 | // public methods |
86 | ||
fdfcba4c | 87 | //_____________________________________________________________________________ |
676fb573 | 88 | void AliRunAction::BeginOfRunAction(const G4Run* run) |
89 | { | |
90 | // Called by G4 kernel at the beginning of run. | |
91 | // --- | |
92 | ||
93 | fRunID++; | |
94 | ||
95 | // aliroot | |
96 | // store runID in the event header | |
97 | gAlice->GetHeader()->SetRun(fRunID); | |
98 | ||
99 | // clear remaining G3 tables | |
100 | if (fRunID == 0) | |
101 | TG4GeometryManager::Instance()->ClearG3TablesFinal(); | |
102 | ||
103 | // create lego sensitive detectors | |
104 | // if lego is instantiated | |
105 | AliLego* lego = gAlice->Lego(); | |
106 | if (lego) { | |
fdfcba4c | 107 | GetSDConstruction()->SetLego(lego); |
676fb573 | 108 | G4UImanager::GetUIpointer()->ApplyCommand("/aliEvent/verbose 0"); |
109 | G4UImanager::GetUIpointer()->ApplyCommand("/aliGenerator/set AliGenerator"); | |
110 | } | |
111 | ||
5f1d09c5 | 112 | G4cout << "### Run " << run->GetRunID() << " start." << G4endl; |
676fb573 | 113 | fTimer->Start(); |
114 | } | |
115 | ||
fdfcba4c | 116 | //_____________________________________________________________________________ |
676fb573 | 117 | void AliRunAction::EndOfRunAction(const G4Run* run) |
118 | { | |
119 | // Called by G4 kernel at the end of run. | |
120 | // --- | |
121 | ||
122 | fTimer->Stop(); | |
123 | ||
124 | // delete lego sensitive detectors | |
125 | // if lego is instantiated | |
126 | AliLego* lego = gAlice->Lego(); | |
127 | if (lego) { | |
fdfcba4c | 128 | GetSDConstruction()->UnsetLego(); |
676fb573 | 129 | G4UImanager::GetUIpointer()->ApplyCommand("/aliEvent/verbose 1"); |
130 | } | |
131 | ||
a971b98e | 132 | G4cout << "Time of this run: " << *fTimer << G4endl; |
133 | G4cout << "Number of events processed: " << run->GetNumberOfEvent() << G4endl; | |
676fb573 | 134 | } |