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