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