]> git.uio.no Git - u/mrichter/AliRoot.git/blame - AliGeant4/AliEventAction.cxx
added fTimer
[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
6#include "AliEventAction.h"
7#include "AliEventActionMessenger.h"
8#include "AliRun.h"
9#include "AliTrackingAction.h"
10#include "AliSensitiveDetector.h"
11#include "AliGlobals.h"
12
13#include "TG4GeometryManager.h"
14
15#include <G4Event.hh>
16#include <G4TrajectoryContainer.hh>
17#include <G4Trajectory.hh>
18#include <G4VVisManager.hh>
19#include <G4UImanager.hh>
20#include <G4LogicalVolumeStore.hh>
21#include <G4VSensitiveDetector.hh>
22
23AliEventAction::AliEventAction()
24 : fVerboseLevel(1),
25 fDrawFlag("CHARGED")
26{
27//
28 fMessenger = new AliEventActionMessenger(this);
29}
30
31AliEventAction::AliEventAction(const AliEventAction& right) {
32//
33 AliGlobals::Exception("AliEventAction is protected from copying.");
34}
35
36AliEventAction::~AliEventAction() {
37//
38 delete fMessenger;
39}
40
41// operators
42
43AliEventAction& AliEventAction::operator=(const AliEventAction &right)
44{
45 // check assignement to self
46 if (this == &right) return *this;
47
48 AliGlobals::Exception("AliEventAction is protected from assigning.");
49
50 return *this;
51}
52
53// private methods
54
55void AliEventAction::DisplayEvent(const G4Event* event) const
56{
57// Draws trajectories.
58// ---
59
60
61 // trajectories processing
62 G4TrajectoryContainer* trajectoryContainer
63 = event->GetTrajectoryContainer();
64
65 G4int nofTrajectories = 0;
66 if (trajectoryContainer)
67 { nofTrajectories = trajectoryContainer->entries(); }
68
69 if (fVerboseLevel>0) {
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
107 // reset the counters (primary tracks, saved tracks)
108 AliTrackingAction* trackingAction
109 = AliTrackingAction::Instance();
110 trackingAction->PrepareNewEvent();
111
112 if (fVerboseLevel>0)
5f1d09c5 113 G4cout << ">>> Event " << event->GetEventID() << G4endl;
676fb573 114}
115
116void AliEventAction::EndOfEventAction(const G4Event* event)
117{
118// Called by G4 kernel at the end of event.
119// ---
120
121 // save the last primary track store of
122 // the current event
123 AliTrackingAction* trackingAction
124 = AliTrackingAction::Instance();
125 trackingAction->SaveAndDestroyTrack();
126
127 if (fVerboseLevel>0) {
128 G4int nofPrimaryTracks = trackingAction->GetNofPrimaryTracks();
129 G4cout << " " << nofPrimaryTracks <<
5f1d09c5 130 " primary tracks processed." << G4endl;
676fb573 131 }
132
133 // display event
134 DisplayEvent(event);
135
136 // aliroot
137 // store event header data
138 gAlice->GetHeader()->SetEvent(event->GetEventID());
139 gAlice->GetHeader()->SetNvertex(event->GetNumberOfPrimaryVertex());
140 gAlice->GetHeader()->SetNprimary(trackingAction->GetNofPrimaryTracks());
141 gAlice->GetHeader()->SetNtrack(trackingAction->GetNofSavedTracks());
142
143 gAlice->FinishEvent();
144}
145
146
147