]> git.uio.no Git - u/mrichter/AliRoot.git/blame - AliGeant4/AliEventAction.cxx
Add tmevsin and mevsim libraries.
[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"
676fb573 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
676fb573 61 // trajectories processing
62 G4TrajectoryContainer* trajectoryContainer
63 = event->GetTrajectoryContainer();
64
65 G4int nofTrajectories = 0;
66 if (trajectoryContainer)
67 { nofTrajectories = trajectoryContainer->entries(); }
68
03b03ccb 69 if (fVerboseLevel>0 && nofTrajectories>0) {
676fb573 70 G4cout << " " << nofTrajectories;
5f1d09c5 71 G4cout << " trajectories stored." << G4endl;
676fb573 72 }
73
74 G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
75 if(pVVisManager && nofTrajectories>0)
76 {
77 G4UImanager::GetUIpointer()->ApplyCommand("/vis~/draw/current");
78
79 for (G4int i=0; i<nofTrajectories; i++)
80 {
81 G4VTrajectory* vtrajectory = (*(event->GetTrajectoryContainer()))[i];
82 G4Trajectory* trajectory = dynamic_cast<G4Trajectory*>(vtrajectory);
83 if (!trajectory) {
84 AliGlobals::Exception(
85 "AliEventAction::DisplayEvent: Unknown trajectory type.");
86 }
5f1d09c5 87 if ( (fDrawFlag == "ALL") ||
88 ((fDrawFlag == "CHARGED") && (trajectory->GetCharge() != 0.))){
89 trajectory->DrawTrajectory(50);
0646e189 90 // the argument number defines the size of the step points
91 // use 2000 to make step points well visible
676fb573 92 }
93 }
94 G4UImanager::GetUIpointer()->ApplyCommand("/vis~/show/view");
95 }
96}
97
98// public methods
99
100void AliEventAction::BeginOfEventAction(const G4Event* event)
101{
102// Called by G4 kernel at the beginning of event.
103// ---
104
105 G4int eventID = event->GetEventID();
106
03b03ccb 107 // reset the tracks counters
108 AliTrackingAction::Instance()->PrepareNewEvent();
676fb573 109
110 if (fVerboseLevel>0)
5f1d09c5 111 G4cout << ">>> Event " << event->GetEventID() << G4endl;
b1327f8f 112
113 fTimer->Start();
676fb573 114}
115
116void AliEventAction::EndOfEventAction(const G4Event* event)
117{
118// Called by G4 kernel at the end of event.
119// ---
120
03b03ccb 121 // finish the last primary track of the current event
122 AliTrackingAction* trackingAction = AliTrackingAction::Instance();
123 trackingAction->FinishPrimaryTrack();
676fb573 124
03b03ccb 125 // verbose output
676fb573 126 if (fVerboseLevel>0) {
03b03ccb 127 //G4int nofPrimaryTracks = trackingAction->GetNofPrimaryTracks();
128 G4int nofPrimaryTracks = gAlice->GetHeader()->GetNprimary();
129 G4int nofSavedTracks = gAlice->GetNtrack();
130 G4int nofAllTracks = trackingAction->GetNofTracks();
131
676fb573 132 G4cout << " " << nofPrimaryTracks <<
5f1d09c5 133 " primary tracks processed." << G4endl;
03b03ccb 134 G4cout << " " << nofSavedTracks <<
135 " tracks saved." << G4endl;
136 G4cout << " " << nofAllTracks <<
b1327f8f 137 " all tracks processed." << G4endl;
676fb573 138 }
139
140 // display event
141 DisplayEvent(event);
142
03b03ccb 143 // aliroot finish event
676fb573 144 gAlice->FinishEvent();
676fb573 145
e012a2ec 146 if (fVerboseLevel>0) {
147 // print time
148 fTimer->Stop();
03b03ccb 149 G4cout << "Time of this event: " << *fTimer << G4endl;
e012a2ec 150 }
b1327f8f 151 }