4 // Author: I. Hrivnacova
6 // Class AliEventAction
7 // ---------------------
8 // See the class description in the header file.
11 // in order to avoid the odd dependency for the
12 // times system function this include must be the first
14 #include "AliEventAction.h"
15 #include "AliTrackingAction.h"
16 #include "AliGlobals.h"
18 #include "AliHeader.h"
21 #include <G4TrajectoryContainer.hh>
22 #include <G4Trajectory.hh>
23 #include <G4VVisManager.hh>
24 #include <G4UImanager.hh>
26 //_____________________________________________________________________________
27 AliEventAction::AliEventAction()
28 : AliVerbose("eventAction"),
33 fTimer = new G4Timer();
36 //_____________________________________________________________________________
37 AliEventAction::AliEventAction(const AliEventAction& right)
41 AliGlobals::Exception("AliEventAction is protected from copying.");
44 //_____________________________________________________________________________
45 AliEventAction::~AliEventAction() {
52 //_____________________________________________________________________________
53 AliEventAction& AliEventAction::operator=(const AliEventAction &right)
55 // check assignement to self
56 if (this == &right) return *this;
58 AliGlobals::Exception("AliEventAction is protected from assigning.");
65 //_____________________________________________________________________________
66 void AliEventAction::DisplayEvent(const G4Event* event) const
68 // Draws trajectories.
71 if (G4VVisManager::GetConcreteInstance()) {
73 // trajectories processing
74 G4TrajectoryContainer* trajectoryContainer
75 = event->GetTrajectoryContainer();
77 G4int nofTrajectories = 0;
78 if (trajectoryContainer)
79 nofTrajectories = trajectoryContainer->entries();
81 if (VerboseLevel() > 0 && nofTrajectories > 0) {
82 G4cout << " " << nofTrajectories;
83 G4cout << " trajectories stored." << G4endl;
86 for (G4int i=0; i<nofTrajectories; i++) {
87 G4VTrajectory* vtrajectory = (*(event->GetTrajectoryContainer()))[i];
88 G4Trajectory* trajectory = dynamic_cast<G4Trajectory*>(vtrajectory);
90 AliGlobals::Exception(
91 "AliEventAction::DisplayEvent: Unknown trajectory type.");
93 if ( (fDrawFlag == "ALL") ||
94 ((fDrawFlag == "CHARGED") && (trajectory->GetCharge() != 0.))){
95 trajectory->DrawTrajectory(50);
96 // the argument number defines the size of the step points
97 // use 2000 to make step points well visible
105 //_____________________________________________________________________________
106 void AliEventAction::BeginOfEventAction(const G4Event* event)
108 // Called by G4 kernel at the beginning of event.
111 G4int eventID = event->GetEventID();
113 // reset the tracks counters
114 if(AliTrackingAction::Instance())
115 AliTrackingAction::Instance()->PrepareNewEvent();
117 if (VerboseLevel() > 0) {
118 G4cout << ">>> Event " << event->GetEventID() << G4endl;
124 //_____________________________________________________________________________
125 void AliEventAction::EndOfEventAction(const G4Event* event)
127 // Called by G4 kernel at the end of event.
130 // finish the last primary track of the current event
131 AliTrackingAction* trackingAction = AliTrackingAction::Instance();
132 if (trackingAction) trackingAction->FinishPrimaryTrack();
134 if (VerboseLevel() > 0) {
136 G4cout << ">>> End of Event " << event->GetEventID() << G4endl;
139 if (VerboseLevel() > 1) {
140 //G4int nofPrimaryTracks = trackingAction->GetNofPrimaryTracks();
141 G4int nofPrimaryTracks = gAlice->GetHeader()->GetNprimary();
142 G4int nofSavedTracks = gAlice->GetNtrack();
144 G4cout << " " << nofPrimaryTracks <<
145 " primary tracks processed." << G4endl;
146 G4cout << " " << nofSavedTracks <<
147 " tracks saved." << G4endl;
148 if (trackingAction) {
149 G4int nofAllTracks = trackingAction->GetNofTracks();
150 G4cout << " " << nofAllTracks <<
151 " all tracks processed." << G4endl;
158 // aliroot finish event
159 gAlice->FinishEvent();
161 if (VerboseLevel() > 1) {
164 G4cout << "Time of this event: " << *fTimer << G4endl;