]> git.uio.no Git - u/mrichter/AliRoot.git/blame - AliGeant4/AliEventAction.cxx
Initial version
[u/mrichter/AliRoot.git] / AliGeant4 / AliEventAction.cxx
CommitLineData
676fb573 1// $Id$
2// Category: event
3//
4// See the class description in the header file.
5
b1327f8f 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
676fb573 10#include "AliEventAction.h"
11#include "AliEventActionMessenger.h"
676fb573 12#include "AliTrackingAction.h"
676fb573 13#include "AliGlobals.h"
03b03ccb 14#include "AliRun.h"
d68d8174 15#include "AliHeader.h"
676fb573 16
676fb573 17#include <G4Event.hh>
18#include <G4TrajectoryContainer.hh>
19#include <G4Trajectory.hh>
20#include <G4VVisManager.hh>
21#include <G4UImanager.hh>
676fb573 22
78ca1e9c 23//_____________________________________________________________________________
676fb573 24AliEventAction::AliEventAction()
25 : fVerboseLevel(1),
26 fDrawFlag("CHARGED")
27{
28//
29 fMessenger = new AliEventActionMessenger(this);
b1327f8f 30 fTimer = new G4Timer();
676fb573 31}
32
78ca1e9c 33//_____________________________________________________________________________
676fb573 34AliEventAction::AliEventAction(const AliEventAction& right) {
35//
36 AliGlobals::Exception("AliEventAction is protected from copying.");
37}
38
78ca1e9c 39//_____________________________________________________________________________
676fb573 40AliEventAction::~AliEventAction() {
41//
42 delete fMessenger;
b1327f8f 43 delete fTimer;
676fb573 44}
45
46// operators
47
78ca1e9c 48//_____________________________________________________________________________
676fb573 49AliEventAction& AliEventAction::operator=(const AliEventAction &right)
50{
51 // check assignement to self
52 if (this == &right) return *this;
53
54 AliGlobals::Exception("AliEventAction is protected from assigning.");
55
56 return *this;
57}
58
59// private methods
60
78ca1e9c 61//_____________________________________________________________________________
676fb573 62void AliEventAction::DisplayEvent(const G4Event* event) const
63{
64// Draws trajectories.
65// ---
66
676fb573 67 // trajectories processing
68 G4TrajectoryContainer* trajectoryContainer
69 = event->GetTrajectoryContainer();
70
71 G4int nofTrajectories = 0;
72 if (trajectoryContainer)
73 { nofTrajectories = trajectoryContainer->entries(); }
74
03b03ccb 75 if (fVerboseLevel>0 && nofTrajectories>0) {
676fb573 76 G4cout << " " << nofTrajectories;
5f1d09c5 77 G4cout << " trajectories stored." << G4endl;
676fb573 78 }
79
80 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
81 if(pVVisManager && nofTrajectories>0)
82 {
83 G4UImanager::GetUIpointer()->ApplyCommand("/vis~/draw/current");
84
85 for (G4int i=0; i<nofTrajectories; i++)
86 {
87 G4VTrajectory* vtrajectory = (*(event->GetTrajectoryContainer()))[i];
88 G4Trajectory* trajectory = dynamic_cast<G4Trajectory*>(vtrajectory);
89 if (!trajectory) {
90 AliGlobals::Exception(
91 "AliEventAction::DisplayEvent: Unknown trajectory type.");
92 }
5f1d09c5 93 if ( (fDrawFlag == "ALL") ||
94 ((fDrawFlag == "CHARGED") && (trajectory->GetCharge() != 0.))){
95 trajectory->DrawTrajectory(50);
0646e189 96 // the argument number defines the size of the step points
97 // use 2000 to make step points well visible
676fb573 98 }
99 }
100 G4UImanager::GetUIpointer()->ApplyCommand("/vis~/show/view");
101 }
102}
103
104// public methods
105
78ca1e9c 106//_____________________________________________________________________________
676fb573 107void AliEventAction::BeginOfEventAction(const G4Event* event)
108{
109// Called by G4 kernel at the beginning of event.
110// ---
111
112 G4int eventID = event->GetEventID();
113
03b03ccb 114 // reset the tracks counters
115 AliTrackingAction::Instance()->PrepareNewEvent();
676fb573 116
117 if (fVerboseLevel>0)
5f1d09c5 118 G4cout << ">>> Event " << event->GetEventID() << G4endl;
b1327f8f 119
120 fTimer->Start();
676fb573 121}
122
78ca1e9c 123//_____________________________________________________________________________
676fb573 124void AliEventAction::EndOfEventAction(const G4Event* event)
125{
126// Called by G4 kernel at the end of event.
127// ---
128
03b03ccb 129 // finish the last primary track of the current event
130 AliTrackingAction* trackingAction = AliTrackingAction::Instance();
131 trackingAction->FinishPrimaryTrack();
676fb573 132
03b03ccb 133 // verbose output
676fb573 134 if (fVerboseLevel>0) {
d68d8174 135 G4cout << G4endl;
136 G4cout << ">>> End of Event " << event->GetEventID() << G4endl;
137 }
138
139 if (fVerboseLevel>1) {
03b03ccb 140 //G4int nofPrimaryTracks = trackingAction->GetNofPrimaryTracks();
141 G4int nofPrimaryTracks = gAlice->GetHeader()->GetNprimary();
142 G4int nofSavedTracks = gAlice->GetNtrack();
143 G4int nofAllTracks = trackingAction->GetNofTracks();
144
676fb573 145 G4cout << " " << nofPrimaryTracks <<
5f1d09c5 146 " primary tracks processed." << G4endl;
03b03ccb 147 G4cout << " " << nofSavedTracks <<
148 " tracks saved." << G4endl;
149 G4cout << " " << nofAllTracks <<
b1327f8f 150 " all tracks processed." << G4endl;
676fb573 151 }
152
153 // display event
154 DisplayEvent(event);
155
03b03ccb 156 // aliroot finish event
676fb573 157 gAlice->FinishEvent();
676fb573 158
d68d8174 159 if (fVerboseLevel>1) {
e012a2ec 160 // print time
161 fTimer->Stop();
03b03ccb 162 G4cout << "Time of this event: " << *fTimer << G4endl;
e012a2ec 163 }
b1327f8f 164 }