]>
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" | |
12 | #include "AliSDManager.h" | |
13 | #include "AliGlobals.h" | |
14 | #include "AliRun.h" | |
15 | #include "AliLego.h" | |
16 | ||
17 | #include "TG4GeometryManager.h" | |
18 | ||
19 | #include <G4Run.hh> | |
20 | #include <G4UImanager.hh> | |
21 | ||
22 | #include <TFile.h> | |
23 | ||
24 | AliRunAction::AliRunAction() | |
25 | : fRunID(-1), | |
26 | fVerboseLevel(0) | |
27 | { | |
28 | // | |
29 | fMessenger = new AliRunActionMessenger(this); | |
30 | fTimer = new G4Timer; | |
31 | } | |
32 | ||
33 | AliRunAction::AliRunAction(const AliRunAction& right) { | |
34 | // | |
35 | AliGlobals::Exception("AliRunAction is protected from copying."); | |
36 | } | |
37 | ||
38 | AliRunAction::~AliRunAction() { | |
39 | // | |
40 | delete fMessenger; | |
41 | delete fTimer; | |
42 | } | |
43 | ||
44 | // operators | |
45 | ||
46 | AliRunAction& AliRunAction::operator=(const AliRunAction &right) | |
47 | { | |
48 | // check assignement to self | |
49 | if (this == &right) return *this; | |
50 | ||
51 | AliGlobals::Exception("AliRunAction is protected from assigning."); | |
52 | ||
53 | return *this; | |
54 | } | |
55 | ||
56 | // public methods | |
57 | ||
58 | void AliRunAction::BeginOfRunAction(const G4Run* run) | |
59 | { | |
60 | // Called by G4 kernel at the beginning of run. | |
61 | // --- | |
62 | ||
63 | fRunID++; | |
64 | ||
65 | // aliroot | |
66 | // store runID in the event header | |
67 | gAlice->GetHeader()->SetRun(fRunID); | |
68 | ||
69 | // clear remaining G3 tables | |
70 | if (fRunID == 0) | |
71 | TG4GeometryManager::Instance()->ClearG3TablesFinal(); | |
72 | ||
73 | // create lego sensitive detectors | |
74 | // if lego is instantiated | |
75 | AliLego* lego = gAlice->Lego(); | |
76 | if (lego) { | |
77 | AliSDManager::Instance()->SetLego(lego); | |
78 | G4UImanager::GetUIpointer()->ApplyCommand("/aliEvent/verbose 0"); | |
79 | G4UImanager::GetUIpointer()->ApplyCommand("/aliGenerator/set AliGenerator"); | |
80 | } | |
81 | ||
82 | G4cout << "### Run " << run->GetRunID() << " start." << endl; | |
83 | fTimer->Start(); | |
84 | } | |
85 | ||
86 | void AliRunAction::EndOfRunAction(const G4Run* run) | |
87 | { | |
88 | // Called by G4 kernel at the end of run. | |
89 | // --- | |
90 | ||
91 | fTimer->Stop(); | |
92 | ||
93 | // delete lego sensitive detectors | |
94 | // if lego is instantiated | |
95 | AliLego* lego = gAlice->Lego(); | |
96 | if (lego) { | |
97 | AliSDManager::Instance()->UnsetLego(); | |
98 | G4UImanager::GetUIpointer()->ApplyCommand("/aliEvent/verbose 1"); | |
99 | } | |
100 | ||
101 | G4cout << "Number of events = " << run->GetNumberOfEvent() | |
102 | << " " << *fTimer << endl; | |
103 | } |