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