]> git.uio.no Git - u/mrichter/AliRoot.git/blame - AliGeant4/AliEventAction.cxx
New&delete used for array with variable size
[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
23AliEventAction::AliEventAction()
24 : fVerboseLevel(1),
25 fDrawFlag("CHARGED")
26{
27//
28 fMessenger = new AliEventActionMessenger(this);
b1327f8f 29 fTimer = new G4Timer();
676fb573 30}
31
32AliEventAction::AliEventAction(const AliEventAction& right) {
33//
34 AliGlobals::Exception("AliEventAction is protected from copying.");
35}
36
37AliEventAction::~AliEventAction() {
38//
39 delete fMessenger;
b1327f8f 40 delete fTimer;
676fb573 41}
42
43// operators
44
45AliEventAction& AliEventAction::operator=(const AliEventAction &right)
46{
47 // check assignement to self
48 if (this == &right) return *this;
49
50 AliGlobals::Exception("AliEventAction is protected from assigning.");
51
52 return *this;
53}
54
55// private methods
56
57void AliEventAction::DisplayEvent(const G4Event* event) const
58{
59// Draws trajectories.
60// ---
61
676fb573 62 // trajectories processing
63 G4TrajectoryContainer* trajectoryContainer
64 = event->GetTrajectoryContainer();
65
66 G4int nofTrajectories = 0;
67 if (trajectoryContainer)
68 { nofTrajectories = trajectoryContainer->entries(); }
69
03b03ccb 70 if (fVerboseLevel>0 && nofTrajectories>0) {
676fb573 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
03b03ccb 108 // reset the tracks counters
109 AliTrackingAction::Instance()->PrepareNewEvent();
676fb573 110
111 if (fVerboseLevel>0)
5f1d09c5 112 G4cout << ">>> Event " << event->GetEventID() << G4endl;
b1327f8f 113
114 fTimer->Start();
676fb573 115}
116
117void AliEventAction::EndOfEventAction(const G4Event* event)
118{
119// Called by G4 kernel at the end of event.
120// ---
121
03b03ccb 122 // finish the last primary track of the current event
123 AliTrackingAction* trackingAction = AliTrackingAction::Instance();
124 trackingAction->FinishPrimaryTrack();
676fb573 125
03b03ccb 126 // verbose output
676fb573 127 if (fVerboseLevel>0) {
d68d8174 128 G4cout << G4endl;
129 G4cout << ">>> End of Event " << event->GetEventID() << G4endl;
130 }
131
132 if (fVerboseLevel>1) {
03b03ccb 133 //G4int nofPrimaryTracks = trackingAction->GetNofPrimaryTracks();
134 G4int nofPrimaryTracks = gAlice->GetHeader()->GetNprimary();
135 G4int nofSavedTracks = gAlice->GetNtrack();
136 G4int nofAllTracks = trackingAction->GetNofTracks();
137
676fb573 138 G4cout << " " << nofPrimaryTracks <<
5f1d09c5 139 " primary tracks processed." << G4endl;
03b03ccb 140 G4cout << " " << nofSavedTracks <<
141 " tracks saved." << G4endl;
142 G4cout << " " << nofAllTracks <<
b1327f8f 143 " all tracks processed." << G4endl;
676fb573 144 }
145
146 // display event
147 DisplayEvent(event);
148
03b03ccb 149 // aliroot finish event
676fb573 150 gAlice->FinishEvent();
676fb573 151
d68d8174 152 if (fVerboseLevel>1) {
e012a2ec 153 // print time
154 fTimer->Stop();
03b03ccb 155 G4cout << "Time of this event: " << *fTimer << G4endl;
e012a2ec 156 }
b1327f8f 157 }